Options
All
  • Public
  • Public/Protected
  • All
Menu

this represent a highly interactable node of a form schema that is observable with useNode in order to notify React that attributes have been mutated.

Type parameters

Hierarchy

  • SchemaNode

Index

Constructors

  • Type parameters

    • T: unknown = any

    Parameters

    • context: FormContext<SharedContext>
    • schema: SchemaNodeServerDefinition
    • path: Path = ...
    • value: any = NO_VALUE
    • updateParent: (childrenName: string, childrenValue: any, isValid?: boolean, from?: NodeSource, isInitialValue?: boolean) => void = ...
        • (childrenName: string, childrenValue: any, isValid?: boolean, from?: NodeSource, isInitialValue?: boolean): void
        • This method allows bubbling up the values of the children when they change, for some type of nodes, we want to skip to the next parent because the node is an abstraction ei: the polymorphic and list nodes have values that represent their list of selected variants instead of the value of their children so they will just pass up the value to the next node above them. even though the method is public, it's an internal function.

          Parameters

          • childrenName: string
          • childrenValue: any
          • isValid: boolean = false
          • from: NodeSource = 'self'
          • isInitialValue: boolean = false

          Returns void

    Returns SchemaNode<T>

Properties

attributes: string[] = []

Cached list of all the children key names

children: NodeChildrenMap = {}

List of nodes with their names as a key

context: FormContext<SharedContext>
decorator: RegisteredDecorations = {}
depth: number
dirty: boolean = false
errors: ValidationError[] = []
invalidChildren: Map<string, true> = ...
isList: boolean = false
isVariant: boolean = false

True if the node is a polymorphic node Polymorphic nodes select their variant(s) to display The selection name is held in the value attribue

name: string
path: Path = ...
required: boolean = false

Indicates if this node's value is mandatory'

schema: SchemaNodeDefinition = ...

Converted schema received from the backend

type: string = ''
value: any = NO_VALUE

Accessors

  • get pathShort(): string
  • get pathVariant(): string
  • get uid(): string
  • Usefull for react key since it aims to be unique right now there is an issue with list items where removing an item from a list would result with the next element taking over the removed item's id and causing React's key to be the same.

    Returns string

Methods

  • Parameters

    • namespace: string = CLONED_SYMBOL

    Returns SchemaNode<T>

    a copy of the node that will not mutate the original one prefix is used to namespace the path used to store the node note: the node still shared the same context so they can refer to each other though SchemaNode.getNodeByPath

  • data(validate?: boolean): T extends never ? object : T
  • Parameters

    • validate: boolean = false

    Returns T extends never ? object : T

  • getErrorMessage(): string
  • getNodeByPath(fullPath: string): undefined | SchemaNode<any>
  • getOriginalNode(namespace?: string): undefined | SchemaNode<any>
  • Returns the node that was used to create this one through the SchemaNode.clone method. In order to make it possible, the cloned node have to be cloned with the keepContext set to true otherwise the sharedContext will not be the same.

    Parameters

    • namespace: string = CLONED_SYMBOL

    Returns undefined | SchemaNode<any>

  • isClone(namespace?: string): boolean
  • Tells if the current node is a node that was created using the SchemaNode.clone method.

    Parameters

    • namespace: string = CLONED_SYMBOL

    Returns boolean

  • isSameValueAsCloned(namespace?: string): boolean
  • Usefull to compare when a node that was cloned is modified some example where that could be usefull is when a cloned node manages a temporary value that is not stored in the server.

    Gotcha: In order to make it possible, the cloned node have to be cloned with the keepContext set to true otherwise the sharedContext will not be the same.

    Parameters

    • namespace: string = CLONED_SYMBOL

    Returns boolean

  • isValid(skipChildrenValidation?: boolean): boolean
  • Parameters

    • skipChildrenValidation: boolean = false

    Returns boolean

  • onChange(value: T, from?: NodeSource, isInitialValue?: boolean): ValidationError[]
  • onChildrenChange(childrenName: string, childrenValue: any, isValid?: boolean, from?: NodeSource, isInitialValue?: boolean): void
  • This method allows bubbling up the values of the children when they change, for some type of nodes, we want to skip to the next parent because the node is an abstraction ei: the polymorphic and list nodes have values that represent their list of selected variants instead of the value of their children so they will just pass up the value to the next node above them. even though the method is public, it's an internal function.

    Parameters

    • childrenName: string
    • childrenValue: any
    • isValid: boolean = false
    • from: NodeSource = 'self'
    • isInitialValue: boolean = false

    Returns void

  • remove(namespace?: string): boolean
  • Unregister the node from the context this is usefull when adding programmatically a node that is not part of the schema. A good example is the SchemaNode.clone method: It's a good practice to clean the cloned node when it's not used anymore

    Parameters

    • namespace: string = CLONED_SYMBOL

    Returns boolean

  • removeListItem(index: number): void
  • this is the main method used to update the list of errors for a given node. They get "cleanned" when the fields becomes dirty again as default behavior. there are a few preset of functions that automaticaly calls this method when configured in DeclarativeFormContext.validators

    Parameters

    Returns void

  • setListValues(items: any[]): void
  • subscribe(callback: (node: SchemaNode<any>) => void): () => void
  • Parameters

    Returns () => void

    Function Returned function unsuscribes the listener

      • (): void
      • Returns void

        Function Returned function unsuscribes the listener

Generated using TypeDoc