@canard/schema-form
Version:
React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components
60 lines (59 loc) • 2.46 kB
TypeScript
import type { Fn } from '../../../../../@aileron/declare';
import type { ObjectNode } from '../../../../../core/nodes/ObjectNode';
import { 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__;
/** 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
*/
get value(): ObjectValue | undefined;
/**
* Applies input value to the object node.
* @param input - Object value to set
* @param option - Setting options
*/
applyValue(input: ObjectValue | undefined, option: UnionSetValueOption): void;
/**
* Gets the list of child nodes.
* @returns Empty array (Terminal strategy does not manage child nodes)
*/
get children(): 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: Fn<[ObjectValue | undefined]>, handleRefresh: Fn<[ObjectValue | undefined]>, handleSetDefaultValue: Fn<[ObjectValue | undefined]>);
/**
* 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__;
}