@formality-ui/react 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/ConfigContext.ts","../src/context/FormContext.ts","../src/context/GroupContext.ts","../src/components/FormalityProvider.tsx","../src/utils/makeProxyState.ts","../src/components/Form.tsx","../src/hooks/useInferredInputs.ts","../src/hooks/useConditions.ts","../src/hooks/usePropsEvaluation.ts","../src/hooks/useSubscriptions.ts","../src/components/Field.tsx","../src/components/FieldGroup.tsx","../src/components/UnusedFields.tsx","../src/hooks/useFormState.ts"],"names":["createContext","useContext","defaultGroupContext","useMemo","jsx","useWatch","result","evaluateDescriptor","useRef","useEffect","useState","useCallback","Fragment","useRHFFormContext"],"mappings":";;;;;;;AAwDA,IAAM,oBAAA,GAA2C;AAAA,EAC/C,QAAQ,EAAC;AAAA,EACT,YAAY,EAAC;AAAA,EACb,SAAS,EAAC;AAAA,EACV,YAAY,EAAC;AAAA,EACb,eAAe,EAAC;AAAA,EAChB,gBAAgB,EAAC;AAAA,EACjB,2BAAA,EAA6B,OAAA;AAAA,EAC7B,mBAAmB;AACrB,CAAA;AAQO,IAAM,aAAA,GAAgB,cAAkC,oBAAoB;AAEnF,aAAA,CAAc,WAAA,GAAc,wBAAA;AAOrB,SAAS,gBAAA,GAAuC;AACrD,EAAA,OAAO,WAAW,aAAa,CAAA;AACjC;ACqDO,IAAM,WAAA,GAAcA,cAAuC,IAAI;AAEtE,WAAA,CAAY,WAAA,GAAc,sBAAA;AAQnB,SAAS,cAAA,GAAiG;AAC/G,EAAA,MAAM,OAAA,GAAUC,WAAW,WAAW,CAAA;AAEtC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AAEA,EAAA,OAAO,OAAA;AACT;AClGA,IAAM,mBAAA,GAAyC;AAAA,EAC7C,KAAA,EAAO;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,YAAA,EAAc;AAAA,KACf,CAAA;AAED,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAA,EAAQ,gBAAA,EAAkB,MAAM,CAAC,CAAA;AAErC,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["// @formality-ui/react - ConfigContext\n// Global configuration context for Formality\n\nimport { createContext, useContext, type ComponentType } from 'react';\nimport type {\n InputConfig,\n ValidatorsConfig,\n ErrorMessagesConfig,\n SelectValue,\n} from '@formality-ui/core';\nimport type { InputTemplateProps } from '../types';\n\n/**\n * ConfigContextValue - Global configuration provided by FormalityProvider\n *\n * Contains all input types, transformers, validators, and global defaults\n * that apply across all forms in the application.\n */\nexport interface ConfigContextValue {\n /** Input type definitions (e.g., textField, switch, autocomplete) */\n inputs: Record<string, InputConfig>;\n\n /** Named formatters for value → display transformation */\n formatters: Record<string, (value: unknown) => unknown>;\n\n /** Named parsers for input → value transformation */\n parsers: Record<string, (value: unknown) => unknown>;\n\n /** Named validators and validator factories */\n validators: ValidatorsConfig;\n\n /** Error message templates by type key */\n errorMessages: ErrorMessagesConfig;\n\n /** Default template component for all inputs */\n defaultInputTemplate?: ComponentType<InputTemplateProps>;\n\n /** Named template components for specific input types */\n inputTemplates: Record<string, ComponentType<InputTemplateProps>>;\n\n /** Default prop name for passSubscriptions (default: 'state') */\n defaultSubscriptionPropName: string;\n\n /** Static default props for all fields */\n defaultFieldProps: Record<string, unknown>;\n\n /** Dynamic default props evaluated per-field */\n selectDefaultFieldProps?: SelectValue;\n}\n\n/**\n * Default configuration context values\n *\n * These are sensible defaults that can be overridden by FormalityProvider.\n * Per PRD 5.1: defaultSubscriptionPropName defaults to 'state'.\n */\nconst defaultConfigContext: ConfigContextValue = {\n inputs: {},\n formatters: {},\n parsers: {},\n validators: {},\n errorMessages: {},\n inputTemplates: {},\n defaultSubscriptionPropName: 'state',\n defaultFieldProps: {},\n};\n\n/**\n * ConfigContext - React context for global Formality configuration\n *\n * Provides access to input types, transformers, validators, and\n * global defaults to all forms and fields in the application.\n */\nexport const ConfigContext = createContext<ConfigContextValue>(defaultConfigContext);\n\nConfigContext.displayName = 'FormalityConfigContext';\n\n/**\n * useConfigContext - Hook to access global configuration\n *\n * @returns The current ConfigContextValue from the nearest FormalityProvider\n */\nexport function useConfigContext(): ConfigContextValue {\n return useContext(ConfigContext);\n}\n","// @formality-ui/react - FormContext\n// Form-level context for field registration and state management\n\nimport { createContext, useContext } from 'react';\nimport type { UseFormReturn, FieldValues } from 'react-hook-form';\nimport type { FormFieldsConfig, FormConfig, FormState } from '@formality-ui/core';\nimport type { WatcherSetterFn, DebouncedFunction } from '../types';\n\n/**\n * FormContextValue - Form-level configuration and operations\n *\n * Provides field registration, subscription management, and access\n * to form state for all fields within a Form component.\n */\nexport interface FormContextValue<TFieldValues extends FieldValues = FieldValues> {\n // ========================\n // Configuration\n // ========================\n\n /** Field configurations for this form */\n config: FormFieldsConfig;\n\n /** Form-level configuration (title, groups, input overrides) */\n formConfig: FormConfig;\n\n /** Original record passed to Form (for expression access) */\n record?: Record<string, unknown>;\n\n // ========================\n // Registry Operations\n // ========================\n\n /**\n * Register a field when it mounts\n * @param name - Field name\n */\n registerField: (name: string) => void;\n\n /**\n * Unregister a field when it unmounts\n * @param name - Field name\n */\n unregisterField: (name: string) => void;\n\n // ========================\n // Subscription Operations\n // ========================\n\n /**\n * Add a subscription from subscriber to target field\n * @param target - The field being watched\n * @param subscriber - The field watching\n */\n addSubscription: (target: string, subscriber: string) => void;\n\n /**\n * Remove a subscription from subscriber to target field\n * @param target - The field being watched\n * @param subscriber - The field watching\n */\n removeSubscription: (target: string, subscriber: string) => void;\n\n /**\n * Register a setter for a field's watchers state\n * @param name - Field name\n * @param setter - React state setter for watchers\n */\n registerWatcherSetter: (name: string, setter: WatcherSetterFn) => void;\n\n /**\n * Unregister a watcher setter when field unmounts\n * @param name - Field name\n */\n unregisterWatcherSetter: (name: string) => void;\n\n // ========================\n // Field State Operations\n // ========================\n\n /**\n * Programmatically change a field's value\n * @param name - Field name\n * @param value - New value\n */\n changeField: (name: string, value: unknown) => void;\n\n /**\n * Set a field's validating state\n * @param name - Field name\n * @param isValidating - Whether validation is in progress\n */\n setFieldValidating: (name: string, isValidating: boolean) => void;\n\n // ========================\n // State Access\n // ========================\n\n /**\n * Get the current complete form state\n * Used for expression evaluation and condition checking\n */\n getFormState: () => FormState;\n\n // ========================\n // Submission Operations\n // ========================\n\n /** Optional submit handler passed to Form */\n onSubmit?: (values: Partial<TFieldValues>) => void | Promise<void>;\n\n /** Debounced submit for auto-save forms */\n debouncedSubmit: DebouncedFunction;\n\n /** Immediate submit bypassing debounce */\n submitImmediate: () => void;\n\n // ========================\n // Unused Fields Tracking\n // ========================\n\n /** Fields in config but not rendered (for config-driven forms) */\n unusedFields: string[];\n\n // ========================\n // React Hook Form Integration\n // ========================\n\n /** React Hook Form methods passthrough */\n methods: UseFormReturn<TFieldValues>;\n}\n\n/**\n * FormContext - React context for form-level state and operations\n *\n * Must be provided by a Form component. No default value as\n * fields cannot function without a parent Form.\n */\nexport const FormContext = createContext<FormContextValue | null>(null);\n\nFormContext.displayName = 'FormalityFormContext';\n\n/**\n * useFormContext - Hook to access form-level context\n *\n * @throws Error if used outside a Form component\n * @returns The FormContextValue from the nearest Form component\n */\nexport function useFormContext<TFieldValues extends FieldValues = FieldValues>(): FormContextValue<TFieldValues> {\n const context = useContext(FormContext) as FormContextValue<TFieldValues> | null;\n\n if (!context) {\n throw new Error(\n 'useFormContext must be used within a Form component. ' +\n 'Make sure your component is wrapped in a <Form> component.'\n );\n }\n\n return context;\n}\n","// @formality-ui/react - GroupContext\n// Group-level context for nested disabled/visible state propagation\n\nimport { createContext, useContext } from 'react';\nimport type { ConditionDescriptor, GroupConfig } from '@formality-ui/core';\n\n/**\n * GroupState - Current computed state for a FieldGroup\n *\n * Contains the resolved disabled/visible states from condition\n * evaluation and the conditions/subscriptions used.\n */\nexport interface GroupState {\n /** Is the group disabled (propagates to all child fields) */\n isDisabled: boolean;\n\n /** Is the group visible (propagates to all child fields) */\n isVisible: boolean;\n\n /** Whether the group has a setValue condition */\n hasSetCondition: boolean;\n\n /** Value to set on all child fields (from group-level set/selectSet) */\n setValue: unknown;\n\n /** Conditions from group configuration */\n conditions: ConditionDescriptor[];\n\n /** Fields this group subscribes to */\n subscriptions: string[];\n}\n\n/**\n * GroupContextValue - Group-level configuration and state\n *\n * Provides inherited disabled/visible state and subscription\n * information to nested fields and groups.\n */\nexport interface GroupContextValue {\n /** Current computed state for the group */\n state: GroupState;\n\n /** Inherited subscriptions from parent groups */\n subscriptions: string[];\n\n /** Field names inferred from group conditions */\n inferredInputs: string[];\n\n /** Group configuration */\n config: GroupConfig;\n}\n\n/**\n * Default group context values\n *\n * When no FieldGroup is present, fields use these defaults:\n * - Not disabled\n * - Visible\n * - No conditions or subscriptions\n */\nconst defaultGroupContext: GroupContextValue = {\n state: {\n isDisabled: false,\n isVisible: true,\n hasSetCondition: false,\n setValue: undefined,\n conditions: [],\n subscriptions: [],\n },\n subscriptions: [],\n inferredInputs: [],\n config: { conditions: [], subscribesTo: [] },\n};\n\n/**\n * GroupContext - React context for group-level state\n *\n * Provides inherited disabled/visible state from parent groups\n * to child fields and nested groups.\n */\nexport const GroupContext = createContext<GroupContextValue>(defaultGroupContext);\n\nGroupContext.displayName = 'FormalityGroupContext';\n\n/**\n * useGroupContext - Hook to access group-level context\n *\n * @returns The GroupContextValue from the nearest FieldGroup or default\n */\nexport function useGroupContext(): GroupContextValue {\n return useContext(GroupContext);\n}\n","// @formality-ui/react - FormalityProvider\n// Global configuration provider for Formality forms\n\nimport { useMemo, type ReactNode, type ComponentType } from 'react';\nimport type {\n InputConfig,\n ValidatorsConfig,\n ErrorMessagesConfig,\n SelectValue,\n} from '@formality-ui/core';\nimport { ConfigContext, type ConfigContextValue } from '../context/ConfigContext';\nimport type { InputTemplateProps } from '../types';\n\n/**\n * FormalityProviderProps - Props for the FormalityProvider component\n *\n * Configures input types, transformers, validators, and global defaults\n * for all forms in the application.\n */\nexport interface FormalityProviderProps {\n /** Child components */\n children: ReactNode;\n\n /**\n * Input type definitions (REQUIRED)\n *\n * Defines how each input type (e.g., textField, switch, autocomplete)\n * behaves across all forms.\n *\n * @example\n * ```tsx\n * inputs={{\n * textField: { component: TextField, defaultValue: '' },\n * switch: { component: Switch, defaultValue: false },\n * }}\n * ```\n */\n inputs: Record<string, InputConfig>;\n\n /**\n * Named formatters for value → display transformation\n *\n * Transform form values before displaying in inputs.\n *\n * @example\n * ```tsx\n * formatters={{\n * currency: (v) => `$${Number(v).toFixed(2)}`,\n * uppercase: (v) => String(v).toUpperCase(),\n * }}\n * ```\n */\n formatters?: Record<string, (value: unknown) => unknown>;\n\n /**\n * Named parsers for input → value transformation\n *\n * Transform user input before storing in form state.\n *\n * @example\n * ```tsx\n * parsers={{\n * number: (v) => Number(v) || 0,\n * trim: (v) => String(v).trim(),\n * }}\n * ```\n */\n parsers?: Record<string, (value: unknown) => unknown>;\n\n /**\n * Named validators and validator factories\n *\n * Define reusable validation logic across forms.\n */\n validators?: ValidatorsConfig;\n\n /**\n * Error message templates by type key\n *\n * Map validation error types to human-readable messages.\n *\n * @example\n * ```tsx\n * errorMessages={{\n * required: 'This field is required',\n * minLength: 'Must be at least {min} characters',\n * }}\n * ```\n */\n errorMessages?: ErrorMessagesConfig;\n\n /**\n * Default template component for all inputs\n *\n * Wraps all inputs for consistent styling, labels, error display.\n */\n defaultInputTemplate?: ComponentType<InputTemplateProps>;\n\n /**\n * Named template components for specific input types\n *\n * Override the default template for specific input types.\n */\n inputTemplates?: Record<string, ComponentType<InputTemplateProps>>;\n\n /**\n * Default prop name for passSubscriptions (default: 'state')\n *\n * When a field has passSubscriptions: true, subscribed field states\n * are passed using this prop name.\n */\n defaultSubscriptionPropName?: string;\n\n /**\n * Static default props for all fields\n *\n * Props applied to every field unless overridden.\n */\n defaultFieldProps?: Record<string, unknown>;\n\n /**\n * Dynamic default props evaluated per-field\n *\n * Expression or function that computes default props.\n */\n selectDefaultFieldProps?: SelectValue;\n}\n\n/**\n * FormalityProvider - Global configuration provider for Formality\n *\n * Wraps your application to provide input types, transformers, validators,\n * and global defaults to all Formality forms.\n *\n * @example\n * ```tsx\n * import { FormalityProvider } from '@formality-ui/react';\n *\n * const inputs = {\n * textField: { component: TextInput, defaultValue: '' },\n * switch: { component: Toggle, defaultValue: false },\n * };\n *\n * function App() {\n * return (\n * <FormalityProvider\n * inputs={inputs}\n * formatters={{ currency: (v) => `$${v}` }}\n * errorMessages={{ required: 'Required' }}\n * >\n * <MyApp />\n * </FormalityProvider>\n * );\n * }\n * ```\n */\nexport function FormalityProvider({\n children,\n inputs,\n formatters = {},\n parsers = {},\n validators = {},\n errorMessages = {},\n defaultInputTemplate,\n inputTemplates = {},\n defaultSubscriptionPropName = 'state',\n defaultFieldProps = {},\n selectDefaultFieldProps,\n}: FormalityProviderProps): JSX.Element {\n // Memoize context value to prevent unnecessary re-renders\n // in descendant components that consume ConfigContext\n const contextValue = useMemo<ConfigContextValue>(\n () => ({\n inputs,\n formatters,\n parsers,\n validators,\n errorMessages,\n defaultInputTemplate,\n inputTemplates,\n defaultSubscriptionPropName,\n defaultFieldProps,\n selectDefaultFieldProps,\n }),\n [\n inputs,\n formatters,\n parsers,\n validators,\n errorMessages,\n defaultInputTemplate,\n inputTemplates,\n defaultSubscriptionPropName,\n defaultFieldProps,\n selectDefaultFieldProps,\n ]\n );\n\n return (\n <ConfigContext.Provider value={contextValue}>\n {children}\n </ConfigContext.Provider>\n );\n}\n","// @formality-ui/react - makeProxyState\n// Lazy property access utility for React performance optimization\n\n/**\n * Creates a proxy object with lazy property access via Object.defineProperty\n *\n * CRITICAL: This enables React's dependency tracking to only register\n * dependencies on actually accessed properties, not the entire object.\n *\n * Without proxy: accessing fieldState.value creates dependency on entire fieldState\n * With proxy: accessing fieldState.value only creates dependency on value property\n *\n * Performance Impact:\n * - Reduces unnecessary re-renders in condition-heavy forms\n * - Expression evaluation only subscribes to properties actually used\n * - Field states can change without triggering re-renders in unrelated fields\n *\n * Implementation Note:\n * Uses Object.defineProperty (NOT Proxy) because:\n * - Better performance for simple property access\n * - Works with Object.keys() iteration when enumerable: true\n * - Simpler debugging and stack traces\n *\n * @param source - The object to wrap with lazy getters\n * @returns A new object with getter properties that lazily access source\n *\n * @example\n * ```typescript\n * const source = { value: 5, isTouched: false };\n * const proxy = makeProxyState(source);\n *\n * // Properties are accessed lazily\n * console.log(proxy.value); // 5\n *\n * // Changes to source reflect in proxy (lazy access)\n * source.value = 10;\n * console.log(proxy.value); // 10\n *\n * // Object.keys still works\n * console.log(Object.keys(proxy)); // ['value', 'isTouched']\n * ```\n */\nexport function makeProxyState<T extends object>(source: T): T {\n const result = {} as T;\n\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n Object.defineProperty(result, key, {\n get: () => source[key],\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return result;\n}\n\n/**\n * Creates a nested proxy state, recursively wrapping objects\n *\n * Use this for deeply nested state objects where you want\n * lazy access at multiple levels.\n *\n * @param source - The object to wrap with lazy getters (recursively)\n * @returns A new object with recursive getter properties\n */\nexport function makeDeepProxyState<T extends object>(source: T): T {\n const result = {} as T;\n\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n const value = source[key];\n Object.defineProperty(result, key, {\n get: () => {\n const currentValue = source[key];\n if (\n currentValue !== null &&\n typeof currentValue === 'object' &&\n !Array.isArray(currentValue)\n ) {\n return makeDeepProxyState(currentValue as object);\n }\n return currentValue;\n },\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return result;\n}\n","// @formality-ui/react - Form Component\n// Core form component with React Hook Form integration\n\nimport {\n useMemo,\n useCallback,\n useRef,\n useState,\n useEffect,\n type ReactNode,\n} from 'react';\nimport {\n useForm,\n FormProvider,\n type FieldValues,\n type UseFormReturn,\n} from 'react-hook-form';\nimport { debounce } from 'lodash-es';\nimport {\n resolveAllInitialValues,\n resolveFormTitle,\n evaluateDescriptor,\n buildFormContext,\n extractValueField,\n transformFieldName,\n} from '@formality-ui/core';\nimport type {\n FormFieldsConfig,\n FormConfig,\n FormState,\n InputConfig,\n} from '@formality-ui/core';\nimport { FormContext, type FormContextValue } from '../context/FormContext';\nimport { GroupContext } from '../context/GroupContext';\nimport { useConfigContext } from '../context/ConfigContext';\nimport { makeProxyState } from '../utils/makeProxyState';\nimport type { WatcherSetterFn, DebouncedFunction } from '../types';\n\n/**\n * Form component props\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues> {\n /** Form content - can be static children or render function */\n children: ReactNode | ((api: FormRenderAPI<TFieldValues>) => ReactNode);\n\n /** Field configurations */\n config: FormFieldsConfig;\n\n /** Form-level configuration (title, groups, input overrides) */\n formConfig?: FormConfig;\n\n /** Submit handler */\n onSubmit?: (values: Partial<TFieldValues>) => void | Promise<void>;\n\n /** Initial record data */\n record?: Partial<TFieldValues>;\n\n /** Enable auto-save on field changes */\n autoSave?: boolean;\n\n /** Debounce milliseconds for auto-save (default: 1000) */\n debounce?: number;\n\n /** Form-level validation */\n validate?: (\n values: Partial<TFieldValues>\n ) => Record<string, string> | Promise<Record<string, string>>;\n}\n\n/**\n * API passed to render function children\n */\nexport interface FormRenderAPI<TFieldValues extends FieldValues = FieldValues> {\n /** Fields in config but not rendered */\n unusedFields: string[];\n\n /** React Hook Form formState */\n formState: UseFormReturn<TFieldValues>['formState'];\n\n /** React Hook Form methods */\n methods: UseFormReturn<TFieldValues>;\n\n /** Resolved form title (static or evaluated) */\n resolvedTitle?: string;\n}\n\n/**\n * Default group context for fields outside FieldGroup\n */\nconst defaultGroupContext = {\n state: {\n isDisabled: false,\n isVisible: true,\n hasSetCondition: false,\n setValue: undefined,\n conditions: [],\n subscriptions: [],\n },\n subscriptions: [],\n inferredInputs: [],\n config: { conditions: [], subscribesTo: [] },\n};\n\n/**\n * Form component - Core form wrapper with React Hook Form integration\n *\n * Provides:\n * - FormContext for field registration and subscription management\n * - React Hook Form integration with mode: 'onChange'\n * - Auto-save with debounced submission\n * - Config-driven default values\n * - Unused fields tracking for config-driven rendering\n *\n * @example\n * ```tsx\n * <Form\n * config={{\n * name: { type: 'textField', label: 'Name' },\n * email: { type: 'textField', label: 'Email' },\n * }}\n * onSubmit={(values) => console.log(values)}\n * >\n * <Field name=\"name\" />\n * <Field name=\"email\" />\n * <button type=\"submit\">Submit</button>\n * </Form>\n * ```\n */\nexport function Form<TFieldValues extends FieldValues = FieldValues>({\n children,\n config,\n formConfig = {},\n onSubmit,\n record,\n autoSave = false,\n debounce: debounceMs = 1000,\n validate,\n}: FormProps<TFieldValues>): JSX.Element {\n // Get provider configuration\n const providerConfig = useConfigContext();\n\n // Merge input configs (form overrides provider)\n const mergedInputs = useMemo((): Record<string, InputConfig> => {\n const formInputs =\n typeof formConfig.inputs === 'function'\n ? formConfig.inputs(providerConfig.inputs)\n : formConfig.inputs ?? {};\n\n // Merge provider inputs with form-level overrides\n const result: Record<string, InputConfig> = { ...providerConfig.inputs };\n for (const [key, override] of Object.entries(formInputs)) {\n if (result[key]) {\n result[key] = { ...result[key], ...override } as InputConfig;\n }\n }\n return result;\n }, [providerConfig.inputs, formConfig.inputs]);\n\n // Calculate default values from config\n const defaultValues = useMemo(() => {\n return resolveAllInitialValues(config, mergedInputs, record ?? {});\n }, [config, mergedInputs, record]);\n\n // Initialize React Hook Form\n const methods = useForm<TFieldValues>({\n mode: 'onChange',\n defaultValues: defaultValues as any,\n values: record as any,\n });\n\n // === REGISTRIES ===\n\n // Field registration\n const fieldRegistry = useRef(new Set<string>());\n const [registeredFields, setRegisteredFields] = useState<Set<string>>(\n new Set()\n );\n\n // Subscription management (inverted index: target → subscribers)\n const invertedSubscriptions = useRef(new Map<string, Set<string>>());\n\n // Watcher setters for notifying fields about subscribers\n const watcherSetters = useRef(new Map<string, WatcherSetterFn>());\n\n // Pending updates for fields not yet mounted\n const pendingWatcherUpdates = useRef(new Map<string, Set<string>>());\n\n // Validation state tracking\n const validatingFields = useRef(new Map<string, boolean>());\n\n // Auto-save tracking\n // pendingChanges accumulates field changes while debounce is pending\n const pendingChangedFields = useRef(new Set<string>());\n const pendingAffectedFields = useRef(new Set<string>());\n // executionVersion is incremented when a new auto-save starts, used to abort if new changes come in\n const executionVersionRef = useRef(0);\n\n // === REGISTRY OPERATIONS ===\n\n const registerField = useCallback((name: string) => {\n fieldRegistry.current.add(name);\n setRegisteredFields(new Set(fieldRegistry.current));\n }, []);\n\n const unregisterField = useCallback((name: string) => {\n fieldRegistry.current.delete(name);\n setRegisteredFields(new Set(fieldRegistry.current));\n }, []);\n\n // === SUBSCRIPTION OPERATIONS ===\n\n const addSubscription = useCallback((target: string, subscriber: string) => {\n // Update inverted index\n if (!invertedSubscriptions.current.has(target)) {\n invertedSubscriptions.current.set(target, new Set());\n }\n invertedSubscriptions.current.get(target)!.add(subscriber);\n\n // Notify target field if mounted\n const setter = watcherSetters.current.get(target);\n if (setter) {\n setter((prev) => ({ ...prev, [subscriber]: true }));\n } else {\n // Queue for later\n if (!pendingWatcherUpdates.current.has(target)) {\n pendingWatcherUpdates.current.set(target, new Set());\n }\n pendingWatcherUpdates.current.get(target)!.add(subscriber);\n }\n }, []);\n\n const removeSubscription = useCallback(\n (target: string, subscriber: string) => {\n invertedSubscriptions.current.get(target)?.delete(subscriber);\n\n const setter = watcherSetters.current.get(target);\n if (setter) {\n setter((prev) => {\n const next = { ...prev };\n delete next[subscriber];\n return next;\n });\n }\n },\n []\n );\n\n const registerWatcherSetter = useCallback(\n (name: string, setter: WatcherSetterFn) => {\n watcherSetters.current.set(name, setter);\n\n // Process pending subscriptions\n const pending = pendingWatcherUpdates.current.get(name);\n if (pending?.size) {\n setter((prev) => {\n const next = { ...prev };\n pending.forEach((sub) => {\n next[sub] = true;\n });\n return next;\n });\n pendingWatcherUpdates.current.delete(name);\n }\n },\n []\n );\n\n const unregisterWatcherSetter = useCallback((name: string) => {\n watcherSetters.current.delete(name);\n }, []);\n\n // === FIELD STATE OPERATIONS ===\n\n /**\n * Get all fields affected by a change to the given field.\n * This traverses the subscription graph to find all dependents,\n * including transitive dependencies (A -> B -> C).\n */\n const getAffectedFields = useCallback((changedField: string): Set<string> => {\n const affected = new Set<string>();\n const toProcess = [changedField];\n\n while (toProcess.length > 0) {\n const current = toProcess.pop()!;\n const subscribers = invertedSubscriptions.current.get(current);\n if (subscribers) {\n for (const subscriber of subscribers) {\n if (!affected.has(subscriber)) {\n affected.add(subscriber);\n toProcess.push(subscriber); // Check for transitive dependencies\n }\n }\n }\n }\n\n return affected;\n }, []);\n\n const changeField = useCallback(\n (name: string, value: unknown) => {\n // Auto-save trigger\n if (autoSave) {\n // Accumulate this change\n pendingChangedFields.current.add(name);\n\n // Add affected fields (those that depend on this field via conditions)\n const affected = getAffectedFields(name);\n for (const field of affected) {\n pendingAffectedFields.current.add(field);\n }\n\n // Trigger debounced auto-save\n debouncedSubmit();\n }\n },\n [autoSave, getAffectedFields]\n );\n\n const setFieldValidating = useCallback(\n (name: string, isValidating: boolean) => {\n validatingFields.current.set(name, isValidating);\n },\n []\n );\n\n // === STATE ACCESS ===\n\n const getFormState = useCallback((): FormState => {\n const values = methods.getValues();\n const formState = methods.formState;\n\n // Build proxy-wrapped field states\n const fields: Record<string, any> = {};\n Object.keys(config).forEach((name) => {\n const fieldState = methods.getFieldState(name as any, formState);\n fields[name] = makeProxyState({\n value: values[name as keyof typeof values],\n isTouched: fieldState.isTouched,\n isDirty: fieldState.isDirty,\n isValidating: validatingFields.current.get(name) ?? false,\n error: fieldState.error\n ? {\n type: fieldState.error.type,\n message: fieldState.error.message,\n }\n : undefined,\n invalid: fieldState.invalid,\n });\n });\n\n return {\n fields,\n record: record ?? {},\n errors: formState.errors as any,\n defaultValues: defaultValues,\n touchedFields: formState.touchedFields as any,\n dirtyFields: formState.dirtyFields as any,\n isDirty: formState.isDirty,\n isTouched: Object.keys(formState.touchedFields).length > 0,\n isValid: formState.isValid,\n isSubmitting: formState.isSubmitting,\n };\n }, [methods, config, record, defaultValues]);\n\n // === SUBMISSION ===\n\n const handleSubmit = useCallback(\n async (values: TFieldValues) => {\n // Check if any field is validating\n for (const [, isValidating] of validatingFields.current) {\n if (isValidating) return;\n }\n\n // Run form-level validation\n if (validate) {\n const errors = await validate(values);\n if (Object.keys(errors).length > 0) {\n Object.entries(errors).forEach(([field, message]) => {\n methods.setError(field as any, { message });\n });\n return;\n }\n }\n\n // Transform values for submission\n const submitValues = transformValuesForSubmit(values, config, mergedInputs);\n\n await onSubmit?.(submitValues);\n },\n [validate, methods, onSubmit, config, mergedInputs]\n );\n\n // Debounced submit for auto-save\n const debouncedSubmitRef = useRef<DebouncedFunction>();\n\n /**\n * Wait for specific fields to complete their validation.\n * Returns false if the version changed (new changes came in), true otherwise.\n */\n const waitForFieldValidation = useCallback(\n async (fields: string[], version: number): Promise<boolean> => {\n const maxWaitMs = 10000; // 10 second timeout\n const pollIntervalMs = 50;\n const startTime = Date.now();\n\n while (Date.now() - startTime < maxWaitMs) {\n // Check if version changed (new changes came in)\n if (executionVersionRef.current !== version) {\n return false;\n }\n\n // Check if all fields have completed validation\n const allDone = fields.every(\n (field) => !validatingFields.current.get(field)\n );\n if (allDone) {\n return true;\n }\n\n // Wait and check again\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n }\n\n // Timeout - proceed anyway\n return true;\n },\n []\n );\n\n /**\n * Execute auto-save: validate only changed/affected fields, wait for completion, then submit.\n * This prevents the issue where handleSubmit() validates ALL fields.\n */\n const executeAutoSave = useCallback(async () => {\n // Capture and increment execution version\n executionVersionRef.current++;\n const executionVersion = executionVersionRef.current;\n\n // Copy and clear pending fields\n const changedFields = new Set(pendingChangedFields.current);\n const affectedFields = new Set(pendingAffectedFields.current);\n pendingChangedFields.current.clear();\n pendingAffectedFields.current.clear();\n\n // If no fields changed, nothing to do\n if (changedFields.size === 0) {\n return;\n }\n\n // Get all fields that need validation (changed + affected by conditions)\n const fieldsToValidate = [...changedFields, ...affectedFields];\n\n // Wait for any in-flight validations on these fields to complete\n const validationsComplete = await waitForFieldValidation(\n fieldsToValidate,\n executionVersion\n );\n\n // If version changed while waiting, abort (new changes came in)\n if (!validationsComplete || executionVersionRef.current !== executionVersion) {\n return;\n }\n\n // Trigger validation ONLY on changed and affected fields (not ALL fields)\n if (fieldsToValidate.length > 0) {\n const isValid = await methods.trigger(fieldsToValidate as any);\n\n // Check version again after async validation\n if (executionVersionRef.current !== executionVersion) {\n return;\n }\n\n if (!isValid) {\n // Validation failed, don't submit\n return;\n }\n }\n\n // Wait for validations to complete after trigger\n const postTriggerComplete = await waitForFieldValidation(\n fieldsToValidate,\n executionVersion\n );\n\n if (!postTriggerComplete || executionVersionRef.current !== executionVersion) {\n return;\n }\n\n // Check if form is valid (may have other errors)\n const formState = methods.formState;\n if (Object.keys(formState.errors).length > 0) {\n return;\n }\n\n // All validations passed, submit\n const values = methods.getValues();\n await handleSubmit(values as TFieldValues);\n }, [methods, handleSubmit, waitForFieldValidation]);\n\n useEffect(() => {\n const debouncedFn = debounce(() => {\n executeAutoSave();\n }, debounceMs);\n\n // Attach lodash-style methods\n const fn = Object.assign(debouncedFn, {\n pending: () => false, // lodash debounce handles this internally\n }) as DebouncedFunction;\n\n debouncedSubmitRef.current = fn;\n\n return () => {\n debouncedFn.cancel();\n };\n }, [executeAutoSave, debounceMs]);\n\n const debouncedSubmit = useCallback(() => {\n debouncedSubmitRef.current?.();\n }, []);\n\n const submitImmediate = useCallback(() => {\n debouncedSubmitRef.current?.flush();\n }, []);\n\n // === UNUSED FIELDS ===\n\n const unusedFields = useMemo(() => {\n const allFields = Object.keys(config);\n return allFields.filter((name) => !registeredFields.has(name));\n }, [config, registeredFields]);\n\n // === RESOLVED TITLE ===\n\n const resolvedTitle = useMemo(() => {\n if (!formConfig.selectTitle && !formConfig.title) {\n return undefined;\n }\n\n // If selectTitle exists, evaluate it\n if (formConfig.selectTitle) {\n const formState = getFormState();\n const context = buildFormContext(\n formState.fields,\n formState.record,\n formState.errors,\n formState.defaultValues,\n formState.touchedFields,\n formState.dirtyFields\n );\n const evaluated = evaluateDescriptor(formConfig.selectTitle, context);\n return resolveFormTitle(formConfig.title, evaluated);\n }\n\n // Static title\n return resolveFormTitle(formConfig.title);\n }, [formConfig.title, formConfig.selectTitle, getFormState]);\n\n // === CONTEXT VALUE ===\n\n const contextValue = useMemo<FormContextValue<TFieldValues>>(\n () => ({\n config,\n formConfig,\n record,\n registerField,\n unregisterField,\n addSubscription,\n removeSubscription,\n registerWatcherSetter,\n unregisterWatcherSetter,\n changeField,\n setFieldValidating,\n getFormState,\n onSubmit,\n debouncedSubmit: debouncedSubmitRef.current!,\n submitImmediate,\n unusedFields,\n methods: methods as any,\n }),\n [\n config,\n formConfig,\n record,\n registerField,\n unregisterField,\n addSubscription,\n removeSubscription,\n registerWatcherSetter,\n unregisterWatcherSetter,\n changeField,\n setFieldValidating,\n getFormState,\n onSubmit,\n submitImmediate,\n unusedFields,\n methods,\n ]\n );\n\n // === RENDER ===\n\n // CRITICAL: Only access methods.formState when children is a function\n // Accessing formState ANYWHERE creates a subscription to the entire form state\n // This would cause ALL children to re-render on ANY field change\n const isRenderFunction = typeof children === 'function';\n\n return (\n <FormProvider {...methods}>\n <FormContext.Provider value={contextValue as any}>\n <GroupContext.Provider value={defaultGroupContext}>\n {isRenderFunction\n ? children({\n unusedFields,\n formState: methods.formState,\n methods: methods as any,\n resolvedTitle,\n })\n : children}\n </GroupContext.Provider>\n </FormContext.Provider>\n </FormProvider>\n );\n}\n\n/**\n * Transform values for submission\n *\n * Applies valueField extraction and field name transformation\n * based on input config settings.\n */\nfunction transformValuesForSubmit<T extends FieldValues>(\n values: T,\n config: FormFieldsConfig,\n inputs: Record<string, InputConfig>\n): Partial<T> {\n const result: Record<string, unknown> = {};\n\n for (const [name, value] of Object.entries(values)) {\n const fieldConfig = config[name];\n const type = fieldConfig?.type ?? 'textField';\n const inputConfig = inputs[type];\n\n if (inputConfig) {\n // Get the submit field name (may be transformed)\n const submitName = transformFieldName(name, inputConfig.getSubmitField);\n\n // Extract value from complex object if valueField is specified\n const submitValue = extractValueField(value, inputConfig.valueField);\n\n result[submitName] = submitValue;\n } else {\n result[name] = value;\n }\n }\n\n return result as Partial<T>;\n}\n\nexport type { FormContextValue };\n","// @formality-ui/react - useInferredInputs Hook\n// Infers field dependencies from selectProps and conditions\n\nimport { useMemo } from 'react';\nimport {\n inferFieldsFromDescriptor,\n inferFieldsFromConditions,\n} from '@formality-ui/core';\nimport type { ConditionDescriptor, SelectValue } from '@formality-ui/core';\n\ninterface UseInferredInputsOptions {\n /** Dynamic props descriptor to analyze for field references */\n selectProps?: SelectValue;\n\n /** Conditions to analyze for field references */\n conditions?: ConditionDescriptor[];\n\n /** Explicit field subscriptions */\n subscribesTo?: string[];\n}\n\n/**\n * Infers field dependencies from selectProps, conditions, and explicit subscriptions\n *\n * This hook analyzes:\n * - selectProps expressions for field references\n * - condition 'when' fields and 'selectWhen' expressions\n * - explicit subscribesTo declarations\n *\n * Used to automatically determine which fields a Field or FieldGroup\n * should subscribe to for reactive updates.\n *\n * @param options - Sources to analyze for field references\n * @returns Array of unique field names to subscribe to\n *\n * @example\n * ```tsx\n * const subscriptions = useInferredInputs({\n * selectProps: \"client.id\",\n * conditions: [{ when: 'signed', disabled: true }],\n * subscribesTo: ['contact'],\n * });\n * // → ['client', 'signed', 'contact']\n * ```\n */\nexport function useInferredInputs(options: UseInferredInputsOptions): string[] {\n const { selectProps, conditions = [], subscribesTo = [] } = options;\n\n return useMemo(() => {\n const inferred: string[] = [...subscribesTo];\n\n // Infer from selectProps expression/descriptor\n if (selectProps) {\n inferred.push(...inferFieldsFromDescriptor(selectProps));\n }\n\n // Infer from conditions (when fields, selectWhen expressions)\n if (conditions.length > 0) {\n inferred.push(...inferFieldsFromConditions(conditions));\n }\n\n // Return unique field names\n return [...new Set(inferred)];\n }, [selectProps, conditions, subscribesTo]);\n}\n","// @formality-ui/react - useConditions Hook\n// Evaluates conditions against current field values\n\nimport { useMemo } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { evaluateConditions, type ConditionResult, type FieldStateInput } from '@formality-ui/core';\nimport type { ConditionDescriptor } from '@formality-ui/core';\nimport { useFormContext } from '../context/FormContext';\nimport { useInferredInputs } from './useInferredInputs';\n\ninterface UseConditionsOptions {\n /** Conditions to evaluate */\n conditions: ConditionDescriptor[];\n\n /** Explicit field subscriptions */\n subscribesTo?: string[];\n\n /** Additional props for expression context */\n props?: Record<string, unknown>;\n}\n\n/**\n * Evaluates conditions against current field values\n *\n * This hook:\n * 1. Infers which fields to watch from conditions\n * 2. Subscribes to those fields via useWatch\n * 3. Evaluates conditions whenever watched values change\n *\n * Implements the condition evaluation rules:\n * - disabled: OR logic (any true = disabled)\n * - visible: AND logic (any false = hidden)\n * - setValue: last matching condition wins\n *\n * @param options - Conditions and subscription config\n * @returns Evaluation result with disabled, visible, and setValue states\n *\n * @example\n * ```tsx\n * const result = useConditions({\n * conditions: [\n * { when: 'signed', is: false, disabled: true },\n * { when: 'archived', truthy: true, visible: false },\n * ],\n * });\n * // result.disabled === true when signed is false\n * // result.visible === false when archived is truthy\n * ```\n */\nexport function useConditions(options: UseConditionsOptions): ConditionResult {\n const { conditions, subscribesTo, props } = options;\n const { record, methods } = useFormContext();\n\n // Infer fields to watch from conditions and explicit subscriptions\n const watchFields = useInferredInputs({\n conditions,\n subscribesTo,\n });\n\n // Watch inferred fields (only subscribe if there are fields to watch)\n // CRITICAL: useWatch provides ISOLATED subscriptions - only re-renders when these specific values change\n const watchedValues = useWatch({\n control: methods.control,\n name: watchFields.length > 0 ? (watchFields as any) : [],\n });\n\n // Build field values map from watched values\n const fieldValues = useMemo(() => {\n const values: Record<string, unknown> = {};\n\n if (watchFields.length === 0) {\n return values;\n }\n\n // CRITICAL: useWatch with an array of names ALWAYS returns an array of values,\n // regardless of how many fields are watched. Only useWatch({ name: 'string' })\n // returns a single value.\n if (Array.isArray(watchedValues)) {\n watchFields.forEach((field, i) => {\n values[field] = watchedValues[i];\n });\n } else {\n // Fallback: single field, single value (shouldn't happen with array name)\n values[watchFields[0]] = watchedValues;\n }\n\n return values;\n }, [watchFields, watchedValues]);\n\n // Build full field states with metadata\n // CRITICAL: Use getFieldState() for NON-REACTIVE access to field metadata\n // This prevents subscribing to the entire form state which causes all fields to re-validate\n // Field states are read on-demand when values change, not when ANY field's metadata changes\n const fieldStates = useMemo(() => {\n const states: Record<string, FieldStateInput> = {};\n\n if (watchFields.length === 0) {\n return states;\n }\n\n watchFields.forEach((fieldName) => {\n // getFieldState() reads current state without creating subscriptions\n const fieldState = methods.getFieldState(fieldName as any);\n states[fieldName] = {\n value: fieldValues[fieldName],\n isTouched: fieldState.isTouched,\n isDirty: fieldState.isDirty,\n error: fieldState.error,\n invalid: fieldState.invalid,\n isValidating: false, // Not easily available per-field\n };\n });\n\n return states;\n }, [watchFields, fieldValues, methods]);\n\n // Evaluate conditions whenever field values or states change\n return useMemo(() => {\n // Return empty result if no conditions\n if (conditions.length === 0) {\n return {\n disabled: undefined,\n visible: undefined,\n setValue: undefined,\n hasDisabledCondition: false,\n hasVisibleCondition: false,\n hasSetCondition: false,\n };\n }\n\n return evaluateConditions({\n conditions,\n fieldValues,\n fieldStates,\n record,\n props,\n });\n }, [conditions, fieldValues, fieldStates, record, props]);\n}\n","// @formality-ui/react - usePropsEvaluation Hook\n// Evaluates selectProps against current field values\n\nimport { useMemo } from 'react';\nimport { useWatch } from 'react-hook-form';\nimport {\n evaluateDescriptor,\n buildFieldContext,\n type FormState,\n} from '@formality-ui/core';\nimport type { SelectValue } from '@formality-ui/core';\nimport { useFormContext } from '../context/FormContext';\nimport { useInferredInputs } from './useInferredInputs';\nimport { makeProxyState } from '../utils/makeProxyState';\n\ninterface UsePropsEvaluationOptions {\n /** Dynamic props descriptor to evaluate */\n selectProps?: SelectValue;\n\n /** Explicit field subscriptions */\n subscribesTo?: string[];\n\n /** Current field name */\n fieldName: string;\n}\n\n/**\n * Evaluates selectProps against current field values\n *\n * This hook:\n * 1. Infers which fields to watch from selectProps expressions\n * 2. Subscribes to those fields via useWatch\n * 3. Evaluates selectProps whenever watched values change\n *\n * Handles both expression-based selectProps and function-based selectProps.\n *\n * @param options - selectProps and subscription config\n * @returns Evaluated props object\n *\n * @example\n * ```tsx\n * const props = usePropsEvaluation({\n * selectProps: {\n * options: \"client.id ? clientOptions : allOptions\",\n * disabled: \"!signed\",\n * },\n * fieldName: 'contact',\n * });\n * // props.options and props.disabled are evaluated against current state\n * ```\n */\nexport function usePropsEvaluation(\n options: UsePropsEvaluationOptions\n): Record<string, unknown> {\n const { selectProps, subscribesTo, fieldName } = options;\n const { record, methods } = useFormContext();\n\n // Infer fields to watch from selectProps and explicit subscriptions\n const watchFields = useInferredInputs({\n selectProps,\n subscribesTo,\n });\n\n // Watch inferred fields (only subscribe if there are fields to watch)\n const watchedValues = useWatch({\n control: methods.control,\n name: watchFields.length > 0 ? (watchFields as any) : [],\n });\n\n // Build form state for evaluation (needed for function-based selectProps)\n // CRITICAL: Only build state for watched fields to maintain performance isolation\n const formState = useMemo((): FormState => {\n // Build proxy-wrapped field states ONLY for watched fields\n // This prevents subscribing to the entire form state\n const fields: Record<string, any> = {};\n\n if (watchFields.length > 0) {\n // Handle single vs multiple watched values\n const values = watchFields.length === 1\n ? { [watchFields[0]]: watchedValues }\n : watchFields.reduce((acc, field, i) => {\n acc[field] = (watchedValues as unknown[])[i];\n return acc;\n }, {} as Record<string, unknown>);\n\n watchFields.forEach((name) => {\n // Create minimal proxy state with just the value\n // We don't need isTouched/isDirty/error for selectProps evaluation\n fields[name] = makeProxyState({\n value: values[name],\n isTouched: false,\n isDirty: false,\n isValidating: false,\n error: undefined,\n invalid: false,\n });\n });\n }\n\n return {\n fields,\n record: record ?? {},\n errors: {},\n defaultValues: {},\n touchedFields: {},\n dirtyFields: {},\n isDirty: false,\n isTouched: false,\n isValid: true,\n isSubmitting: false,\n };\n // Only depends on watchFields and watchedValues - NOT the entire form state\n }, [watchFields, watchedValues, record]);\n\n // Evaluate selectProps\n return useMemo(() => {\n if (!selectProps) {\n return {};\n }\n\n // Handle function selectProps\n if (typeof selectProps === 'function') {\n const result = selectProps(formState, methods);\n return (result as Record<string, unknown>) ?? {};\n }\n\n // Build evaluation context\n const context = buildFieldContext(formState, fieldName);\n\n // Evaluate descriptor (string expression, object with expressions, or array)\n const result = evaluateDescriptor(selectProps, context);\n\n return (result as Record<string, unknown>) ?? {};\n }, [selectProps, formState, methods, fieldName]);\n}\n","// @formality-ui/react - useSubscriptions Hook\n// Manages field subscriptions in the Form's inverted index\n\nimport { useEffect, useRef } from 'react';\nimport { useFormContext } from '../context/FormContext';\n\n/**\n * Manages field subscriptions\n *\n * This hook registers the current field as a subscriber to the target fields,\n * and cleans up subscriptions when the component unmounts or subscriptions change.\n *\n * Subscriptions are stored in the Form's inverted index (target → subscribers),\n * which allows target fields to know who is watching them (for optimization).\n *\n * @param fieldName - The subscribing field's name\n * @param subscriptions - Array of field names to subscribe to\n *\n * @example\n * ```tsx\n * // Contact field subscribes to client field\n * useSubscriptions('contact', ['client']);\n *\n * // When client changes, its watchers can be notified\n * // This enables features like passSubscriptions\n * ```\n */\nexport function useSubscriptions(\n fieldName: string,\n subscriptions: string[]\n): void {\n const { addSubscription, removeSubscription } = useFormContext();\n\n // Track previous subscriptions to properly cleanup on change\n const prevSubscriptionsRef = useRef<string[]>([]);\n\n useEffect(() => {\n const prevSubscriptions = prevSubscriptionsRef.current;\n\n // Find subscriptions to remove (in prev but not in current)\n const toRemove = prevSubscriptions.filter(\n (target) => !subscriptions.includes(target)\n );\n\n // Find subscriptions to add (in current but not in prev)\n const toAdd = subscriptions.filter(\n (target) => !prevSubscriptions.includes(target)\n );\n\n // Remove old subscriptions\n toRemove.forEach((target) => {\n removeSubscription(target, fieldName);\n });\n\n // Add new subscriptions\n toAdd.forEach((target) => {\n addSubscription(target, fieldName);\n });\n\n // Update ref for next comparison\n prevSubscriptionsRef.current = subscriptions;\n\n // Cleanup on unmount - remove all current subscriptions\n return () => {\n subscriptions.forEach((target) => {\n removeSubscription(target, fieldName);\n });\n };\n }, [fieldName, subscriptions, addSubscription, removeSubscription]);\n}\n","// @formality-ui/react - Field Component\n// Core field component with Controller integration\n\nimport {\n useMemo,\n useCallback,\n useEffect,\n useState,\n useRef,\n type ReactNode,\n} from 'react';\nimport {\n Controller,\n type ControllerFieldState,\n type UseFormStateReturn,\n type FieldValues,\n} from 'react-hook-form';\nimport {\n resolveInputConfig,\n mergeFieldProps,\n resolveLabel,\n parse,\n format,\n runValidator,\n resolveErrorMessage,\n} from '@formality-ui/core';\nimport type { FieldConfig, InputConfig } from '@formality-ui/core';\nimport { useFormContext } from '../context/FormContext';\nimport { useConfigContext } from '../context/ConfigContext';\nimport { useGroupContext } from '../context/GroupContext';\nimport { useConditions } from '../hooks/useConditions';\nimport { usePropsEvaluation } from '../hooks/usePropsEvaluation';\nimport { useInferredInputs } from '../hooks/useInferredInputs';\nimport { useSubscriptions } from '../hooks/useSubscriptions';\nimport type { WatcherSetterFn } from '../types';\n\n/**\n * Field component props\n */\nexport interface FieldProps {\n /** Field name (must match a key in Form's config) */\n name: string;\n\n /** Override the input type from config */\n type?: string;\n\n /** Override disabled state */\n disabled?: boolean;\n\n /** Override hidden state (inverse of visible) */\n hidden?: boolean;\n\n /** Custom render function for advanced use cases */\n children?: ReactNode | ((api: FieldRenderAPI) => ReactNode);\n\n /** Whether to register this field in Form's field registry (default: true) */\n shouldRegister?: boolean;\n\n /** Additional props to pass to the input component */\n [key: string]: unknown;\n}\n\n/**\n * API passed to render function children\n */\nexport interface FieldRenderAPI {\n /** React Hook Form field state */\n fieldState: ControllerFieldState;\n\n /** The rendered input component */\n renderedField: ReactNode;\n\n /** Final merged props passed to input */\n fieldProps: Record<string, unknown>;\n\n /** Map of fields watching this field */\n watchers: Record<string, boolean>;\n\n /** React Hook Form form state */\n formState: UseFormStateReturn<FieldValues>;\n}\n\n/**\n * Field component - Renders a form field with full Formality integration\n *\n * Provides:\n * - React Hook Form Controller integration\n * - Props resolution (8-layer merge)\n * - Condition evaluation (disabled/visible/setValue)\n * - Value transformation (parse/format)\n * - Validation (field + type validators)\n * - Subscription management\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Field name=\"email\" />\n *\n * // Override type\n * <Field name=\"status\" type=\"select\" />\n *\n * // Custom render\n * <Field name=\"name\">\n * {({ renderedField, fieldState }) => (\n * <div className={fieldState.error ? 'has-error' : ''}>\n * {renderedField}\n * </div>\n * )}\n * </Field>\n * ```\n */\nexport function Field({\n name,\n type: typeProp,\n disabled: disabledProp,\n hidden: hiddenProp,\n children,\n shouldRegister = true,\n ...restProps\n}: FieldProps): JSX.Element | null {\n const {\n config,\n formConfig,\n methods,\n registerField,\n unregisterField,\n registerWatcherSetter,\n unregisterWatcherSetter,\n changeField,\n setFieldValidating,\n } = useFormContext();\n\n const providerConfig = useConfigContext();\n const groupContext = useGroupContext();\n\n // Get field config\n const fieldConfig: FieldConfig = config[name] ?? {};\n\n // Resolve type\n const type = typeProp ?? fieldConfig.type ?? 'textField';\n\n // Resolve input config (merge provider + form)\n const inputConfig = useMemo((): InputConfig => {\n const formInputs =\n typeof formConfig.inputs === 'function'\n ? formConfig.inputs(providerConfig.inputs)\n : formConfig.inputs ?? {};\n\n // Merge provider inputs with form-level overrides\n const mergedInputs: Record<string, InputConfig> = { ...providerConfig.inputs };\n for (const [key, override] of Object.entries(formInputs)) {\n if (mergedInputs[key]) {\n mergedInputs[key] = { ...mergedInputs[key], ...override } as InputConfig;\n }\n }\n\n return resolveInputConfig(type, mergedInputs) ?? { component: 'input', defaultValue: '' };\n }, [type, providerConfig.inputs, formConfig.inputs]);\n\n // === REGISTRATION ===\n\n useEffect(() => {\n if (shouldRegister) {\n registerField(name);\n return () => unregisterField(name);\n }\n }, [name, shouldRegister, registerField, unregisterField]);\n\n // === WATCHER STATE ===\n\n const [watchers, setWatchers] = useState<Record<string, boolean>>({});\n\n useEffect(() => {\n registerWatcherSetter(name, setWatchers as WatcherSetterFn);\n return () => unregisterWatcherSetter(name);\n }, [name, registerWatcherSetter, unregisterWatcherSetter]);\n\n // === SUBSCRIPTIONS ===\n\n const inferredSubscriptions = useInferredInputs({\n selectProps: fieldConfig.selectProps,\n conditions: fieldConfig.conditions,\n subscribesTo: fieldConfig.subscribesTo,\n });\n\n // Merge with group subscriptions\n const allSubscriptions = useMemo(() => {\n return [...new Set([...inferredSubscriptions, ...groupContext.subscriptions])];\n }, [inferredSubscriptions, groupContext.subscriptions]);\n\n useSubscriptions(name, allSubscriptions);\n\n // === CONDITIONS ===\n\n const conditionResult = useConditions({\n conditions: fieldConfig.conditions ?? [],\n subscribesTo: fieldConfig.subscribesTo,\n props: { name },\n });\n\n // === APPLY SET VALUE FROM CONDITIONS ===\n // When a condition's set/selectSet evaluates, apply the value to the field\n // Priority: field-level conditions > group-level conditions\n // Store methods.setValue in a ref to avoid dependency issues\n const setValueRef = useRef(methods.setValue);\n setValueRef.current = methods.setValue;\n const getValuesRef = useRef(methods.getValues);\n getValuesRef.current = methods.getValues;\n\n // Determine effective setValue: field-level takes priority over group-level\n const effectiveSetValue = useMemo(() => {\n if (conditionResult.hasSetCondition) {\n return { hasCondition: true, value: conditionResult.setValue };\n }\n if (groupContext.state.hasSetCondition) {\n return { hasCondition: true, value: groupContext.state.setValue };\n }\n return { hasCondition: false, value: undefined };\n }, [\n conditionResult.hasSetCondition,\n conditionResult.setValue,\n groupContext.state.hasSetCondition,\n groupContext.state.setValue,\n ]);\n\n useEffect(() => {\n if (effectiveSetValue.hasCondition && effectiveSetValue.value !== undefined) {\n const currentValue = getValuesRef.current(name);\n // Only update if the value is actually different to avoid infinite loops\n if (currentValue !== effectiveSetValue.value) {\n setValueRef.current(name, effectiveSetValue.value, {\n shouldValidate: true,\n shouldDirty: true,\n shouldTouch: false,\n });\n }\n }\n }, [effectiveSetValue.hasCondition, effectiveSetValue.value, name]);\n\n // === DISABLED/VISIBLE RESOLUTION ===\n\n const isDisabled = useMemo(() => {\n // Resolution order: prop > config > condition > group > false\n if (disabledProp !== undefined) return disabledProp;\n if (fieldConfig.disabled !== undefined) return fieldConfig.disabled;\n if (conditionResult.hasDisabledCondition)\n return conditionResult.disabled ?? false;\n if (groupContext.state.isDisabled) return true;\n return false;\n }, [\n disabledProp,\n fieldConfig.disabled,\n conditionResult,\n groupContext.state.isDisabled,\n ]);\n\n const isVisible = useMemo(() => {\n // Resolution order: prop > config > condition > group > true\n if (hiddenProp !== undefined) return !hiddenProp;\n if (fieldConfig.hidden !== undefined) return !fieldConfig.hidden;\n if (conditionResult.hasVisibleCondition)\n return conditionResult.visible ?? true;\n if (!groupContext.state.isVisible) return false;\n return true;\n }, [hiddenProp, fieldConfig.hidden, conditionResult, groupContext.state.isVisible]);\n\n // === PROPS EVALUATION ===\n\n const evaluatedSelectProps = usePropsEvaluation({\n selectProps: fieldConfig.selectProps,\n subscribesTo: fieldConfig.subscribesTo,\n fieldName: name,\n });\n\n // Resolve label\n const label = useMemo(() => {\n return resolveLabel(name, fieldConfig, evaluatedSelectProps, restProps);\n }, [name, fieldConfig, evaluatedSelectProps, restProps]);\n\n // === VALIDATION ===\n\n const validationRules = useMemo(() => {\n return {\n ...fieldConfig.rules,\n validate: async (value: unknown) => {\n setFieldValidating(name, true);\n\n try {\n // Field-level validator\n if (fieldConfig.validator) {\n const result = await runValidator(\n fieldConfig.validator,\n value,\n methods.getValues(),\n providerConfig.validators\n );\n if (result !== true && result !== undefined) {\n return resolveErrorMessage(result, providerConfig.errorMessages);\n }\n }\n\n // Type-level validator\n if (inputConfig.validator) {\n const result = await runValidator(\n inputConfig.validator,\n value,\n methods.getValues(),\n providerConfig.validators\n );\n if (result !== true && result !== undefined) {\n return resolveErrorMessage(result, providerConfig.errorMessages);\n }\n }\n\n return true;\n } finally {\n setFieldValidating(name, false);\n }\n },\n };\n }, [\n fieldConfig.rules,\n fieldConfig.validator,\n inputConfig.validator,\n methods,\n providerConfig.validators,\n providerConfig.errorMessages,\n name,\n setFieldValidating,\n ]);\n\n // === CHANGE HANDLER ===\n\n const handleChange = useCallback(\n (onChange: (value: unknown) => void) => (newValue: unknown) => {\n // Parse value\n const parsedValue = parse(\n newValue,\n inputConfig.parser,\n providerConfig.parsers\n );\n\n // Update form value\n onChange(parsedValue);\n\n // Notify subscribers\n changeField(name, parsedValue);\n },\n [inputConfig.parser, providerConfig.parsers, changeField, name]\n );\n\n // Don't render if not visible\n if (!isVisible) {\n return null;\n }\n\n // === RENDER ===\n\n return (\n <Controller\n control={methods.control}\n name={name}\n rules={validationRules}\n render={({ field, fieldState, formState }) => {\n // Format value for display\n const formattedValue = format(\n field.value,\n inputConfig.formatter,\n providerConfig.formatters\n );\n\n // Merge props (8 layers)\n const finalProps = mergeFieldProps({\n providerDefaultFieldProps: providerConfig.defaultFieldProps,\n providerSelectDefaultFieldProps: {}, // Evaluated at provider level if needed\n formDefaultFieldProps: formConfig.defaultFieldProps,\n formSelectDefaultFieldProps: {}, // Evaluated at form level if needed\n inputProps: inputConfig.props,\n fieldConfigProps: fieldConfig.props,\n selectProps: evaluatedSelectProps,\n componentProps: restProps,\n coreProps: {\n name,\n label,\n disabled: isDisabled,\n error: fieldState.error?.message,\n [inputConfig.inputFieldProp ?? 'value']: formattedValue,\n onChange: handleChange(field.onChange),\n onBlur: field.onBlur,\n ref: field.ref,\n },\n });\n\n // Get component\n const Component = inputConfig.component as React.ComponentType<any>;\n\n // Render through template if present\n const template =\n inputConfig.template ??\n providerConfig.inputTemplates[type] ??\n providerConfig.defaultInputTemplate;\n\n const TemplateComponent = template as\n | React.ComponentType<any>\n | undefined;\n\n const renderedField = TemplateComponent ? (\n <TemplateComponent\n Field={Component}\n fieldProps={finalProps}\n fieldState={fieldState}\n formState={formState}\n />\n ) : (\n <Component {...finalProps} />\n );\n\n // Render children if function\n if (typeof children === 'function') {\n const result = children({\n fieldState,\n renderedField,\n fieldProps: finalProps,\n watchers,\n formState,\n });\n // Ensure we return a valid ReactElement\n return <>{result}</>;\n }\n\n return renderedField as React.ReactElement;\n }}\n />\n );\n}\n","// @formality-ui/react - FieldGroup Component\n// Groups fields with shared conditions and state propagation\n\nimport { useMemo, type ReactNode } from 'react';\nimport type { GroupConfig } from '@formality-ui/core';\nimport { useFormContext } from '../context/FormContext';\nimport {\n GroupContext,\n useGroupContext,\n type GroupContextValue,\n type GroupState,\n} from '../context/GroupContext';\nimport { useConditions } from '../hooks/useConditions';\nimport { useInferredInputs } from '../hooks/useInferredInputs';\n\n/**\n * FieldGroup component props\n */\nexport interface FieldGroupProps {\n /** Group name (must match a key in FormConfig.groups) */\n name: string;\n\n /** Fields to render within this group */\n children: ReactNode;\n}\n\n/**\n * FieldGroup component - Groups fields with shared conditions\n *\n * Provides:\n * - Group-level condition evaluation (disabled/visible)\n * - State propagation to nested fields:\n * - disabled: OR logic (child || parent)\n * - visible: AND logic (child && parent)\n * - Subscription accumulation from parent groups\n *\n * Groups can be nested, with state merging at each level.\n *\n * @example\n * ```tsx\n * // FormConfig\n * formConfig={{\n * groups: {\n * clientSection: {\n * conditions: [\n * { when: 'hasClient', is: false, visible: false }\n * ]\n * }\n * }\n * }}\n *\n * // Usage\n * <Form config={config} formConfig={formConfig}>\n * <Field name=\"hasClient\" />\n * <FieldGroup name=\"clientSection\">\n * <Field name=\"clientName\" />\n * <Field name=\"clientEmail\" />\n * </FieldGroup>\n * </Form>\n * ```\n */\nexport function FieldGroup({ name, children }: FieldGroupProps): JSX.Element {\n const { formConfig } = useFormContext();\n const parentContext = useGroupContext();\n\n // Get group config\n const groupConfig: GroupConfig = formConfig.groups?.[name] ?? {\n conditions: [],\n subscribesTo: [],\n };\n\n // Warn if group config not found (in development)\n if (process.env.NODE_ENV !== 'production' && !formConfig.groups?.[name]) {\n console.warn(\n `FieldGroup: No config found for group \"${name}\". ` +\n `Make sure to define it in formConfig.groups.`\n );\n }\n\n // Infer fields from conditions\n const inferredInputs = useInferredInputs({\n conditions: groupConfig.conditions,\n subscribesTo: groupConfig.subscribesTo,\n });\n\n // Evaluate conditions\n const conditionResult = useConditions({\n conditions: groupConfig.conditions ?? [],\n subscribesTo: groupConfig.subscribesTo,\n });\n\n // Merge with parent context state\n const mergedState = useMemo<GroupState>(() => {\n // Disabled: OR logic (any parent can disable)\n const isDisabled =\n (conditionResult.hasDisabledCondition\n ? conditionResult.disabled ?? false\n : false) || parentContext.state.isDisabled;\n\n // Visible: AND logic (any parent can hide)\n const isVisible =\n (conditionResult.hasVisibleCondition\n ? conditionResult.visible ?? true\n : true) && parentContext.state.isVisible;\n\n // setValue: This group's setValue takes priority, then parent's\n // (Child fields can still override with their own field-level conditions)\n const hasSetCondition =\n conditionResult.hasSetCondition || parentContext.state.hasSetCondition;\n const setValue = conditionResult.hasSetCondition\n ? conditionResult.setValue\n : parentContext.state.setValue;\n\n // Accumulate conditions and subscriptions\n const conditions = [\n ...parentContext.state.conditions,\n ...(groupConfig.conditions ?? []),\n ];\n\n const subscriptions = [\n ...parentContext.state.subscriptions,\n ...(groupConfig.subscribesTo ?? []),\n ];\n\n return {\n isDisabled,\n isVisible,\n hasSetCondition,\n setValue,\n conditions,\n subscriptions,\n };\n }, [conditionResult, parentContext.state, groupConfig]);\n\n // Build context value\n const contextValue = useMemo<GroupContextValue>(\n () => ({\n state: mergedState,\n subscriptions: mergedState.subscriptions,\n inferredInputs,\n config: groupConfig,\n }),\n [mergedState, inferredInputs, groupConfig]\n );\n\n // CRITICAL: Use span wrapper with display:none instead of returning null\n // This preserves children in DOM for state preservation (PRD Section 5.4, 18.10)\n return (\n <GroupContext.Provider value={contextValue}>\n <span\n style={{ display: mergedState.isVisible ? undefined : 'none' }}\n data-formality-group={name}\n >\n {children}\n </span>\n </GroupContext.Provider>\n );\n}\n","// @formality-ui/react - UnusedFields Component\n// Renders fields declared in config but not explicitly rendered\n\nimport { type ReactNode, useMemo } from 'react';\nimport { sortFieldsByOrder } from '@formality-ui/core';\nimport { useFormContext } from '../context/FormContext';\nimport { Field } from './Field';\n\n/**\n * UnusedFields component props\n */\nexport interface UnusedFieldsProps {\n /** Custom render function for each unused field */\n children?: (field: { name: string; component: ReactNode }) => ReactNode;\n}\n\n/**\n * UnusedFields component - Renders config-driven fields\n *\n * Renders fields that are declared in the Form's config but have not\n * been explicitly rendered using <Field> components. This enables\n * config-driven forms where not all fields need to be declared in JSX.\n *\n * Fields are tracked via the Form's field registry. When a <Field>\n * component mounts, it registers itself. UnusedFields renders all\n * fields that haven't been registered.\n *\n * @example\n * ```tsx\n * // All fields from config rendered automatically\n * <Form config={config}>\n * <UnusedFields />\n * </Form>\n *\n * // Mix explicit and automatic fields\n * <Form config={config}>\n * <Field name=\"name\" /> {/* Explicit with custom props *\\/}\n * <Field name=\"email\" /> {/* Explicit with custom props *\\/}\n * <UnusedFields /> {/* Renders remaining fields *\\/}\n * </Form>\n *\n * // Custom wrapper for unused fields\n * <Form config={config}>\n * <UnusedFields>\n * {({ name, component }) => (\n * <div key={name} className=\"auto-field\">\n * {component}\n * </div>\n * )}\n * </UnusedFields>\n * </Form>\n * ```\n */\nexport function UnusedFields({ children }: UnusedFieldsProps): JSX.Element {\n const { unusedFields, config } = useFormContext();\n\n // Sort unused fields by order property (PRD Section 15)\n const sortedFields = useMemo(() => {\n return sortFieldsByOrder(unusedFields, config);\n }, [unusedFields, config]);\n\n if (children) {\n // Custom render function\n return (\n <>\n {sortedFields.map((name) =>\n children({\n name,\n // CRITICAL: shouldRegister={false} prevents infinite loop (PRD 5.5, 18.9)\n component: <Field key={name} name={name} shouldRegister={false} />,\n })\n )}\n </>\n );\n }\n\n // Default render\n return (\n <>\n {sortedFields.map((name) => (\n // CRITICAL: shouldRegister={false} prevents infinite loop (PRD 5.5, 18.9)\n <Field key={name} name={name} shouldRegister={false} />\n ))}\n </>\n );\n}\n","// @formality-ui/react - useFormState Hook\n// Custom hook wrapping RHF's useWatch with proxy optimization\n// CRITICAL: This hook is designed for ISOLATED field subscriptions\n\nimport { useMemo } from 'react';\nimport {\n useWatch,\n useFormContext as useRHFFormContext,\n} from 'react-hook-form';\nimport type { FieldValues } from 'react-hook-form';\nimport { makeProxyState } from '../utils/makeProxyState';\nimport { useFormContext as useFormalityFormContext } from '../context/FormContext';\nimport type { CustomFieldState, IsolatedFormState } from '../types';\n\n/**\n * Options for useFormState hook\n */\nexport interface UseFormStateOptions {\n /**\n * Specific field name(s) to watch.\n * REQUIRED for performance - you must specify which fields you need.\n * Watching all fields defeats the purpose of isolation.\n */\n name: string | string[];\n}\n\n/**\n * Custom useFormState that provides ISOLATED field subscriptions\n *\n * CRITICAL PERFORMANCE REQUIREMENT:\n * You MUST specify which fields to watch via the `name` option.\n * This hook is designed to prevent the \"subscribe to everything\" anti-pattern.\n *\n * This hook provides:\n * - Proxy-wrapped field states to prevent unnecessary re-renders\n * - Record property access via lazy getter\n * - Integration with Formality's FormContext\n *\n * Performance Benefits:\n * - Only re-renders when specified fields change\n * - Expression evaluation only creates dependencies on used properties\n * - Field states can update independently without cross-field re-renders\n *\n * @example\n * ```tsx\n * function MyField() {\n * // Watch specific fields only\n * const formState = useFormState({ name: ['firstName', 'lastName'] });\n *\n * // Only re-renders when firstName or lastName change\n * const value = formState.fields.firstName?.value;\n *\n * // Access original record for expressions\n * const recordId = formState.record.id;\n * }\n * ```\n */\nexport function useFormState<TFieldValues extends FieldValues = FieldValues>(\n options: UseFormStateOptions\n): IsolatedFormState {\n // Get RHF context\n const rhfContext = useRHFFormContext<TFieldValues>();\n\n // Get Formality context (may not be available if used outside Form)\n let formalityContext: ReturnType<typeof useFormalityFormContext<TFieldValues>> | null = null;\n try {\n formalityContext = useFormalityFormContext<TFieldValues>();\n } catch {\n // Used outside Form - formalityContext stays null\n }\n\n // Determine field names to track - MUST be explicitly specified\n const fieldNames = useMemo(() => {\n return Array.isArray(options.name) ? options.name : [options.name];\n }, [options.name]);\n\n // Watch ONLY specified field values via useWatch (isolated subscription)\n const watchedValues = useWatch({\n control: rhfContext.control,\n name: fieldNames as any,\n });\n\n // Build proxy-wrapped field states for watched fields ONLY\n // CRITICAL: We do NOT call getFieldState which would subscribe to form state\n const fields = useMemo(() => {\n const result: Record<string, CustomFieldState> = {};\n\n if (fieldNames.length === 0) {\n return result;\n }\n\n // Handle single field vs multiple fields\n const values = fieldNames.length === 1\n ? [watchedValues]\n : (watchedValues as unknown[]);\n\n fieldNames.forEach((name, index) => {\n const value = values[index];\n\n // Create minimal proxy state with just the value\n // We intentionally do NOT access isTouched/isDirty/error from rhfFormState\n // as that would create subscriptions to the entire form state\n result[name] = makeProxyState({\n value,\n isTouched: false,\n isDirty: false,\n isValidating: false,\n error: undefined,\n invalid: false,\n });\n });\n\n return result;\n }, [fieldNames, watchedValues]);\n\n // Create result object with lazy record access\n const result = useMemo((): IsolatedFormState => {\n const base: IsolatedFormState = {\n fields,\n record: {}, // Will be overwritten by defineProperty\n // Provide minimal form-level state that doesn't require subscriptions\n isDirty: false,\n isTouched: false,\n isValid: true,\n isSubmitting: false,\n errors: {},\n touchedFields: {},\n dirtyFields: {},\n defaultValues: {},\n };\n\n // Add record property with lazy access\n Object.defineProperty(base, 'record', {\n get: () => formalityContext?.record ?? {},\n enumerable: true,\n configurable: true,\n });\n\n return base;\n }, [fields, formalityContext?.record]);\n\n return result;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@formality-ui/react",
3
+ "version": "0.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "sideEffects": false,
22
+ "dependencies": {
23
+ "jsep": "^1.4.0",
24
+ "jse-eval": "^1.5.2",
25
+ "lodash-es": "^4.17.21",
26
+ "@formality-ui/core": "0.0.0"
27
+ },
28
+ "peerDependencies": {
29
+ "react": "^18.0.0",
30
+ "react-dom": "^18.0.0",
31
+ "react-hook-form": "^7.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@testing-library/jest-dom": "^6.0.0",
35
+ "@testing-library/react": "^14.0.0",
36
+ "@testing-library/user-event": "^14.5.2",
37
+ "@types/lodash-es": "^4.17.12",
38
+ "@types/react": "^18.2.0",
39
+ "@types/react-dom": "^18.2.0",
40
+ "jsdom": "^24.0.0",
41
+ "react": "^18.2.0",
42
+ "react-dom": "^18.2.0",
43
+ "react-hook-form": "^7.50.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "dev": "tsup --watch",
48
+ "test": "vitest run"
49
+ }
50
+ }