turbodombuilder - v0.9.66
    Preparing search index...

    Class Reifect<ClassType>

    Reifect

    A class to manage and apply dynamic properties, styles, classes, and transitions to a set of objects.

    Type Parameters

    • ClassType extends object = Node

      The object type this reifier will be applied to.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    fields: readonly ["properties", "classes", "styles", "replaceWith"] = ...
    knownFields: Set<string> = ...
    chainableStyleFields: Set<string> = ...
    timeRegex: RegExp = ...
    attachedObjectsData: WeakMap<ClassType, ReifectObjectData<"default", ClassType>> = ...
    attachedObjects: TurboNodeList<ClassType> = ...

    Accessors

    • get properties(): StatelessPropertyConfig<
          PartialRecord<keyof ClassType, any>,
          ClassType,
      >

      Returns StatelessPropertyConfig<PartialRecord<keyof ClassType, any>, ClassType>

      The properties to be assigned to the objects. It could take:

      • A record of {key: value} pairs.
      • An interpolation function that would return a record of {key: value} pairs.

      The interpolation function would take as arguments:

      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • set properties(
          value: StatelessPropertyConfig<
              PartialRecord<keyof ClassType, any>,
              ClassType,
          >,
      ): void

      Returns void

      The properties to be assigned to the objects. It could take:

      • A record of {key: value} pairs.
      • A record of {state: {key: value} pairs or an interpolation function that would return a record of {key: value} pairs}.
      • An interpolation function that would return a record of {key: value} pairs based on the state value.

      The interpolation function would take as arguments:

      • state: State: the state being applied to the object(s). Only passed to the callback function if it is defined for the whole field (and not for a specific state).
      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • Returns StatelessPropertyConfig<StylesType, ClassType>

      The styles to be assigned to the objects (only if they are eligible elements). It could take:

      • A record of {CSS property: value} pairs.
      • An interpolation function that would return a record of {key: value} pairs.

      The interpolation function would take as arguments:

      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • set styles(value: StatelessPropertyConfig<StylesType, ClassType>): void

      Returns void

      The styles to be assigned to the objects (only if they are eligible elements). It could take:

      • A record of {CSS property: value} pairs.
      • A record of {state: {CSS property: value} pairs or an interpolation function that would return a record of {key: value} pairs}.
      • An interpolation function that would return a record of {key: value} pairs based on the state value.

      The interpolation function would take as arguments:

      • state: State: the state being applied to the object(s). Only passed to the callback function if it is defined for the whole field (and not for a specific state).
      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • get classes(): StatelessPropertyConfig<string | string[], ClassType>

      Returns StatelessPropertyConfig<string | string[], ClassType>

      The classes to be assigned to the objects (only if they are eligible elements). It could take:

      • A string of space-separated classes.
      • An array of classes.
      • An interpolation function that would return a string of space-separated classes or an array of classes.

      The interpolation function would take as arguments:

      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • set classes(value: StatelessPropertyConfig<string | string[], ClassType>): void

      Parameters

      Returns void

      The classes to be assigned to the objects (only if they are eligible elements). It could take:

      • A string of space-separated classes.
      • An array of classes.
      • A record of {state: space-separated class string, array of classes, or an interpolation function that would return any of the latter}.
      • An interpolation function that would return a string of space-separated classes or an array of classes based on the state value.

      The interpolation function would take as arguments:

      • state: State: the state being applied to the object(s). Only passed to the callback function if it is defined for the whole field (and not for a specific state).
      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • Returns StatelessPropertyConfig<ClassType, ClassType>

      The object that should replace (in the DOM as well if eligible) the attached objects. It could take:

      • The object to be replaced with.
      • An interpolation function that would return the object to be replaced with.

      The interpolation function would take as arguments:

      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • set replaceWith(value: StatelessPropertyConfig<ClassType, ClassType>): void

      Returns void

      The object that should replace (in the DOM as well if eligible) the attached objects. It could take:

      • The object to be replaced with.
      • A record of {state: object to be replaced with, or an interpolation function that would return an object to be replaced with}.
      • An interpolation function that would return the object to be replaced with based on the state value.

      The interpolation function would take as arguments:

      • state: State: the state being applied to the object(s). Only passed to the callback function if it is defined for the whole field (and not for a specific state).
      • index: number: the index of the object in the applied list.
      • total: number: the total number of objects in the applied list.
      • object: ClassType: the object itself.
    • get states(): State[]

      Returns State[]

      All possible states.

    • set states(states: object | State[]): void

      Parameters

      Returns void

    • set propertiesEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • set classesEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • set stylesEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • set replacedWithEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • set enabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    Methods

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Function

      attach

      Parameters

      • object: ClassType

        The object to attach.

      • OptionalonSwitch: ReifectOnSwitchCallback<"default", ClassType>

        Optional callback fired when the reifier is applied to the object. The callback takes as parameters:

        • state: State: The state being applied to the object.
        • index: number: the index of the object in the applied list.
        • total: number: the total number of objects in the applied list.
        • object: ClassType: the object itself.
      • Optionalindex: number

        Optional index to specify the position at which to insert the object in the reifier's attached list.

      Returns this

      • The reifier itself, for method chaining.

      Attaches an object to the reifier.

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Function

      detach

      Parameters

      • ...objects: ClassType[]

        The objects to detach.

      Returns this

      • The reifier itself, for method chaining.

      Detaches one or more objects from the reifier.

    • Protected Function

      attachObject

      Parameters

      • object: ClassType

        The object to attach

      • OptionalonSwitch: ReifectOnSwitchCallback<"default", ClassType>

        Optional callback fired when the reifier is applied to the object. The callback takes as parameters:

        • state: State: The state being applied to the object.
        • index: number: the index of the object in the applied list.
        • total: number: the total number of objects in the applied list.
        • object: ClassType: the object itself.
      • Optionalindex: number

        Optional index to specify the position at which to insert the object in the reifier's attached list.

      Returns ReifectObjectData<"default", ClassType>

      • The created data entry.

      Function used to generate a data entry for the given object, and add it to the attached list at the provided index (if any).

    • Protected Function

      detachObject

      Parameters

      Returns void

      Function used to remove a data entry from the attached objects list.

    • Function

      stateOf

      Parameters

      • object: ClassType

        The object to determine the state for.

      Returns "default"

      • The current state of the reifect or undefined if not determinable.

      Determine the current state of the reifect on the provided object.

    • Protected Function

      parseState

      Parameters

      • value: boolean | "default"

        The value to parse.

      Returns "default"

      The parsed value, or null if the boolean could not be parsed.

      Parses a boolean into the corresponding state value.

    • Function

      reloadFor

      Parameters

      • object: ClassType

        The element to apply the string to.

      Returns this

      Itself for method chaining.

      Generates the transition CSS string for the provided transition with the correct interpolation information.

    • Parameters

      • object: ClassType
      • applyStylesInstantly: boolean = false

      Returns void

    • Returns void

    • Parameters

      Returns void

    • Returns void

    • Parameters

      Returns void

    • Returns void

    • Parameters

      Returns void

    • Returns void

    • Parameters

      • object: ClassType
      • Optionalstate: "default"
      • applyStylesInstantly: boolean = false

      Returns void

    • Returns void

    • Parameters

      Returns void

    • Parameters

      • states: object | "default"[]

      Returns "default"[]