@canard/schema-form
Version:
React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components
109 lines (108 loc) • 4.53 kB
TypeScript
import type { Fn } from '../../../../../@aileron/declare';
import type { ObjectNode } from '../../../../../core/nodes/ObjectNode';
import { type ChildNode, type SchemaNodeFactory, type UnionSetValueOption } from '../../../../../core/nodes/type';
import type { ObjectValue } from '../../../../../types';
import type { ObjectNodeStrategy } from '../type';
export declare class BranchStrategy implements ObjectNodeStrategy {
/** Host ObjectNode instance that this strategy belongs to */
private readonly __host__;
/** Callback function to handle value changes */
private readonly __handleChange__;
/** Callback function to handle refresh operations */
private readonly __handleRefresh__;
/** Callback function to handle computed properties updates */
private readonly __handleUpdateComputedProperties__;
/** Array of schema property keys in order */
private readonly __schemaKeys__;
/** Set of all oneOf schema keys, undefined if no oneOf schema exists */
private readonly __oneOfKeySet__?;
/** Array of key sets for each oneOf branch, undefined if no oneOf schema exists */
private readonly __oneOfKeySetList__?;
/** Array of child node arrays for each oneOf branch */
private readonly __oneOfChildNodeMapList__?;
/** Array of child nodes for regular properties (non-oneOf) */
private readonly __propertyChildren__;
/** Map of field conditions for conditional schema properties */
private readonly __fieldConditionMap__?;
/** Map of property keys to child nodes */
private readonly __childNodeMap__;
/** Current active children nodes (combination of property and oneOf children) */
private __children__;
/**
* Gets the child nodes of the object node.
* @returns List of child nodes
*/
get children(): ChildNode[];
/** Flag indicating whether the node is in isolation mode (affects condition processing) */
private __isolationMode__;
/** Flag indicating whether the strategy is locked to prevent recursive updates */
private __locked__;
/** Current committed value of the object node */
private __value__;
/** Draft value containing pending changes before commit */
private __draft__;
/**
* Gets the current value of the object.
* @returns Current value of the object node or undefined
*/
get value(): ObjectValue | undefined;
/**
* Applies input value to the object node.
* @param input - Object value to set
* @param option - Setting options
*/
applyValue(input: ObjectValue, option: UnionSetValueOption): void;
/**
* Propagates activation to all child nodes.
* @internal Internal implementation method. Do not call directly.
*/
activate(): void;
/**
* Initializes the BranchStrategy object.
* @param host - Host ObjectNode object
* @param handleChange - Value change handler
* @param handleRefresh - Refresh handler
* @param handleSetDefaultValue - Default value setting handler
* @param handleUpdateComputedProperties - Computed properties update handler
* @param nodeFactory - Node creation factory
*/
constructor(host: ObjectNode, handleChange: Fn<[ObjectValue | undefined]>, handleRefresh: Fn<[ObjectValue | undefined]>, handleSetDefaultValue: Fn<[ObjectValue | undefined]>, handleUpdateComputedProperties: Fn, nodeFactory: SchemaNodeFactory);
/**
* Reflects value changes and publishes related events.
* @param option - Setting options
* @private
*/
private __emitChange__;
/**
* Parses input value and processes it as an object.
* @param input - Object to parse
* @returns {ObjectValue|undefined} Parsed object
* @private
*/
private __parseValue__;
/**
* Propagates value changes to child nodes.
* @param replace - Whether to replace existing values
* @param option - Setting options
* @private
*/
private __propagate__;
/** Previously active oneOf index for tracking oneOf branch changes */
private __previousIndex__;
/**
* Updates child nodes when oneOf index changes, if oneOf schema exists.
* @private
*/
private __prepareOneOfChildren__;
/**
* Publishes a child node change event.
* @private
*/
private __publishChildrenChange__;
/**
* Publishes a value change request event.
* @param option - Change options (optional)
* @private
*/
private __publishRequestEmitChange__;
}