@canard/schema-form
Version:
React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components
67 lines (66 loc) • 2.79 kB
TypeScript
import type { Fn, Nullish } from '../../../../../@aileron/declare';
import type { ObjectNode } from '../../../../../core/nodes/ObjectNode';
import { type HandleChange, type UnionSetValueOption } from '../../../../../core/nodes/type';
import type { ObjectValue } from '../../../../../types';
import type { ObjectNodeStrategy } from '../type';
/**
* Strategy class for managing ObjectNode values as terminal.
* Implementation for handling simple object types.
*/
export declare class TerminalStrategy implements ObjectNodeStrategy {
/** Host ObjectNode instance that this strategy belongs to */
private readonly __host__;
/** Flag indicating whether to ignore additional properties */
private readonly __ignoreAdditionalProperties__;
/** Callback function to handle value changes */
private readonly __handleChange__;
/** Callback function to handle refresh operations */
private readonly __handleRefresh__;
/** Array of property keys defined in the JSON schema, used for ordering object properties */
private readonly __propertyKeys__;
/** Current value of the object node, initialized as empty object */
private __value__;
/**
* Gets the current value of the object.
* @returns Current value of the object node or undefined (if empty) or null (if nullable)
*/
get value(): ObjectValue | Nullish;
/**
* Applies input value to the object node.
* @param input - Object value to set
* @param option - Setting options
*/
applyValue(input: ObjectValue | Nullish, option: UnionSetValueOption): void;
/**
* Gets the list of child nodes.
* @returns Empty array (Terminal strategy does not manage child nodes)
*/
get children(): null;
/**
* Gets the list of subnodes.
* @returns Empty array (Terminal strategy does not manage subnodes)
*/
get subnodes(): null;
/**
* Initializes the TerminalStrategy object.
* @param host - Host ObjectNode object
* @param handleChange - Value change handler
* @param handleRefresh - Refresh handler
* @param handleSetDefaultValue - Default value setting handler
*/
constructor(host: ObjectNode, handleChange: HandleChange<ObjectValue | Nullish>, handleRefresh: Fn<[ObjectValue | Nullish]>, handleSetDefaultValue: Fn<[ObjectValue | Nullish]>);
/**
* Emits a value change event.
* @param input - New object value
* @param option - Option settings (default: SetValueOption.Default)
* @private
*/
private __emitChange__;
/**
* Parses input value into appropriate object format.
* @param input - Value to parse
* @returns {ObjectValue|undefined} Parsed object value or undefined
* @private
*/
private __parseValue__;
}