@fuf-stack/uniform 1.5.7 → 1.6.1

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.
Files changed (156) hide show
  1. package/dist/Checkboxes/index.cjs +12 -6
  2. package/dist/Checkboxes/index.cjs.map +1 -1
  3. package/dist/Checkboxes/index.js +11 -5
  4. package/dist/FieldArray/index.cjs +12 -6
  5. package/dist/FieldArray/index.cjs.map +1 -1
  6. package/dist/FieldArray/index.js +11 -5
  7. package/dist/Form/index.cjs +12 -6
  8. package/dist/Form/index.cjs.map +1 -1
  9. package/dist/Form/index.js +11 -5
  10. package/dist/Input/index.cjs +12 -6
  11. package/dist/Input/index.cjs.map +1 -1
  12. package/dist/Input/index.js +11 -5
  13. package/dist/RadioBoxes/index.cjs +12 -6
  14. package/dist/RadioBoxes/index.cjs.map +1 -1
  15. package/dist/RadioBoxes/index.js +11 -5
  16. package/dist/RadioTabs/index.cjs +12 -6
  17. package/dist/RadioTabs/index.cjs.map +1 -1
  18. package/dist/RadioTabs/index.js +11 -5
  19. package/dist/Radios/index.cjs +12 -6
  20. package/dist/Radios/index.cjs.map +1 -1
  21. package/dist/Radios/index.js +11 -5
  22. package/dist/Select/index.cjs +12 -6
  23. package/dist/Select/index.cjs.map +1 -1
  24. package/dist/Select/index.js +11 -5
  25. package/dist/SubmitButton/index.cjs +12 -6
  26. package/dist/SubmitButton/index.cjs.map +1 -1
  27. package/dist/SubmitButton/index.js +11 -5
  28. package/dist/Switch/index.cjs +12 -6
  29. package/dist/Switch/index.cjs.map +1 -1
  30. package/dist/Switch/index.js +11 -5
  31. package/dist/TextArea/index.cjs +12 -6
  32. package/dist/TextArea/index.cjs.map +1 -1
  33. package/dist/TextArea/index.js +11 -5
  34. package/dist/{chunk-KORRVEJL.cjs → chunk-345LYO4H.cjs} +3 -3
  35. package/dist/{chunk-KORRVEJL.cjs.map → chunk-345LYO4H.cjs.map} +1 -1
  36. package/dist/chunk-35V726MB.js +1 -0
  37. package/dist/chunk-35V726MB.js.map +1 -0
  38. package/dist/{chunk-RBQP2VHW.js → chunk-6C6YW5TM.js} +2 -2
  39. package/dist/{chunk-MLAU2DYU.cjs → chunk-A5Z75X7M.cjs} +3 -3
  40. package/dist/{chunk-MLAU2DYU.cjs.map → chunk-A5Z75X7M.cjs.map} +1 -1
  41. package/dist/chunk-AACO4OEK.cjs +100 -0
  42. package/dist/chunk-AACO4OEK.cjs.map +1 -0
  43. package/dist/chunk-AHJJIANM.js +7 -0
  44. package/dist/chunk-AHJJIANM.js.map +1 -0
  45. package/dist/{chunk-DFDZFIQN.js → chunk-BXGILW5C.js} +4 -4
  46. package/dist/chunk-CHNYQVWO.js +59 -0
  47. package/dist/chunk-CHNYQVWO.js.map +1 -0
  48. package/dist/chunk-CK362NWK.js +34 -0
  49. package/dist/chunk-CK362NWK.js.map +1 -0
  50. package/dist/chunk-D3NAUOYG.js +122 -0
  51. package/dist/chunk-D3NAUOYG.js.map +1 -0
  52. package/dist/{chunk-EALQ3KNW.cjs → chunk-E4DCVJS5.cjs} +3 -3
  53. package/dist/{chunk-EALQ3KNW.cjs.map → chunk-E4DCVJS5.cjs.map} +1 -1
  54. package/dist/{chunk-GE2QRIOE.cjs → chunk-F6JQYB53.cjs} +4 -4
  55. package/dist/{chunk-GE2QRIOE.cjs.map → chunk-F6JQYB53.cjs.map} +1 -1
  56. package/dist/{chunk-2ZM4P4G3.js → chunk-GUPJNFEX.js} +10 -6
  57. package/dist/{chunk-2ZM4P4G3.js.map → chunk-GUPJNFEX.js.map} +1 -1
  58. package/dist/{chunk-TCJK6IYV.js → chunk-H24QXVUI.js} +2 -2
  59. package/dist/{chunk-7FTSMHFL.js → chunk-HQGTCSHK.js} +2 -2
  60. package/dist/{chunk-CSTA3NED.cjs → chunk-IYULWK4H.cjs} +7 -5
  61. package/dist/chunk-IYULWK4H.cjs.map +1 -0
  62. package/dist/{chunk-LEEWUHKX.js → chunk-JKWNYLNS.js} +4 -4
  63. package/dist/chunk-JMFDNTVC.cjs +34 -0
  64. package/dist/chunk-JMFDNTVC.cjs.map +1 -0
  65. package/dist/chunk-LTKRK3OS.cjs +1 -0
  66. package/dist/chunk-LTKRK3OS.cjs.map +1 -0
  67. package/dist/{chunk-QIIMEQS3.js → chunk-MXUKW3PZ.js} +2 -2
  68. package/dist/{chunk-3UIFEC4R.cjs → chunk-NZBO4N3S.cjs} +3 -260
  69. package/dist/chunk-NZBO4N3S.cjs.map +1 -0
  70. package/dist/{chunk-UO52HWMC.cjs → chunk-NZIAIYPS.cjs} +4 -4
  71. package/dist/{chunk-UO52HWMC.cjs.map → chunk-NZIAIYPS.cjs.map} +1 -1
  72. package/dist/{chunk-P7Z25LOZ.cjs → chunk-OJHD2XHD.cjs} +3 -3
  73. package/dist/{chunk-P7Z25LOZ.cjs.map → chunk-OJHD2XHD.cjs.map} +1 -1
  74. package/dist/chunk-PCTYJUY7.cjs +7 -0
  75. package/dist/chunk-PCTYJUY7.cjs.map +1 -0
  76. package/dist/{chunk-47MZU3WD.js → chunk-PO5UQAU6.js} +2 -259
  77. package/dist/chunk-PO5UQAU6.js.map +1 -0
  78. package/dist/{chunk-UB44OT6Q.js → chunk-QRCV7JVB.js} +2 -2
  79. package/dist/{chunk-A5MP4JAG.cjs → chunk-RMCPVDAC.cjs} +3 -3
  80. package/dist/{chunk-A5MP4JAG.cjs.map → chunk-RMCPVDAC.cjs.map} +1 -1
  81. package/dist/{chunk-B5OTVY3W.js → chunk-SJZ7UUEE.js} +5 -3
  82. package/dist/{chunk-B5OTVY3W.js.map → chunk-SJZ7UUEE.js.map} +1 -1
  83. package/dist/chunk-TEIXBRF5.cjs +59 -0
  84. package/dist/chunk-TEIXBRF5.cjs.map +1 -0
  85. package/dist/chunk-TGJJZEHB.cjs +122 -0
  86. package/dist/chunk-TGJJZEHB.cjs.map +1 -0
  87. package/dist/{chunk-33X26MSK.js → chunk-TKFODQWI.js} +2 -2
  88. package/dist/{chunk-X5WF3MEZ.cjs → chunk-VPUMTPD3.cjs} +3 -3
  89. package/dist/{chunk-X5WF3MEZ.cjs.map → chunk-VPUMTPD3.cjs.map} +1 -1
  90. package/dist/{chunk-JABO2635.cjs → chunk-WFO4XPA3.cjs} +4 -4
  91. package/dist/{chunk-JABO2635.cjs.map → chunk-WFO4XPA3.cjs.map} +1 -1
  92. package/dist/{chunk-4XTUP7W7.cjs → chunk-XJBGXFVX.cjs} +10 -6
  93. package/dist/chunk-XJBGXFVX.cjs.map +1 -0
  94. package/dist/chunk-Z7FVILDT.js +100 -0
  95. package/dist/chunk-Z7FVILDT.js.map +1 -0
  96. package/dist/{chunk-LKBR2JGT.js → chunk-Z7NI5347.js} +2 -2
  97. package/dist/hooks/index.cjs +20 -7
  98. package/dist/hooks/index.cjs.map +1 -1
  99. package/dist/hooks/index.d.cts +10 -240
  100. package/dist/hooks/index.d.ts +10 -240
  101. package/dist/hooks/index.js +25 -12
  102. package/dist/hooks/useClientValidation/index.cjs +12 -0
  103. package/dist/hooks/useClientValidation/index.cjs.map +1 -0
  104. package/dist/hooks/useClientValidation/index.d.cts +78 -0
  105. package/dist/hooks/useClientValidation/index.d.ts +78 -0
  106. package/dist/hooks/useClientValidation/index.js +12 -0
  107. package/dist/hooks/useClientValidation/index.js.map +1 -0
  108. package/dist/hooks/useController/index.cjs +9 -0
  109. package/dist/hooks/useController/index.cjs.map +1 -0
  110. package/dist/hooks/useController/index.d.cts +28 -0
  111. package/dist/hooks/useController/index.d.ts +28 -0
  112. package/dist/hooks/useController/index.js +9 -0
  113. package/dist/hooks/useController/index.js.map +1 -0
  114. package/dist/hooks/useFormContext/index.cjs +11 -0
  115. package/dist/hooks/useFormContext/index.cjs.map +1 -0
  116. package/dist/hooks/useFormContext/index.d.cts +50 -0
  117. package/dist/hooks/useFormContext/index.d.ts +50 -0
  118. package/dist/hooks/useFormContext/index.js +11 -0
  119. package/dist/hooks/useFormContext/index.js.map +1 -0
  120. package/dist/hooks/useInput/index.cjs +8 -0
  121. package/dist/hooks/useInput/index.cjs.map +1 -0
  122. package/dist/hooks/useInput/index.d.cts +1 -0
  123. package/dist/hooks/useInput/index.d.ts +1 -0
  124. package/dist/hooks/useInput/index.js +8 -0
  125. package/dist/hooks/useInput/index.js.map +1 -0
  126. package/dist/hooks/useUniformField/index.cjs +14 -0
  127. package/dist/hooks/useUniformField/index.cjs.map +1 -0
  128. package/dist/hooks/useUniformField/index.d.cts +83 -0
  129. package/dist/hooks/useUniformField/index.d.ts +83 -0
  130. package/dist/hooks/useUniformField/index.js +14 -0
  131. package/dist/hooks/useUniformField/index.js.map +1 -0
  132. package/dist/hooks/useUniformFieldArray/index.cjs +15 -0
  133. package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -0
  134. package/dist/hooks/useUniformFieldArray/index.d.cts +70 -0
  135. package/dist/hooks/useUniformFieldArray/index.d.ts +70 -0
  136. package/dist/hooks/useUniformFieldArray/index.js +15 -0
  137. package/dist/hooks/useUniformFieldArray/index.js.map +1 -0
  138. package/dist/index.cjs +30 -17
  139. package/dist/index.cjs.map +1 -1
  140. package/dist/index.d.cts +6 -1
  141. package/dist/index.d.ts +6 -1
  142. package/dist/index.js +39 -26
  143. package/package.json +33 -3
  144. package/dist/chunk-3UIFEC4R.cjs.map +0 -1
  145. package/dist/chunk-47MZU3WD.js.map +0 -1
  146. package/dist/chunk-4XTUP7W7.cjs.map +0 -1
  147. package/dist/chunk-CSTA3NED.cjs.map +0 -1
  148. /package/dist/{chunk-RBQP2VHW.js.map → chunk-6C6YW5TM.js.map} +0 -0
  149. /package/dist/{chunk-DFDZFIQN.js.map → chunk-BXGILW5C.js.map} +0 -0
  150. /package/dist/{chunk-TCJK6IYV.js.map → chunk-H24QXVUI.js.map} +0 -0
  151. /package/dist/{chunk-7FTSMHFL.js.map → chunk-HQGTCSHK.js.map} +0 -0
  152. /package/dist/{chunk-LEEWUHKX.js.map → chunk-JKWNYLNS.js.map} +0 -0
  153. /package/dist/{chunk-QIIMEQS3.js.map → chunk-MXUKW3PZ.js.map} +0 -0
  154. /package/dist/{chunk-UB44OT6Q.js.map → chunk-QRCV7JVB.js.map} +0 -0
  155. /package/dist/{chunk-33X26MSK.js.map → chunk-TKFODQWI.js.map} +0 -0
  156. /package/dist/{chunk-LKBR2JGT.js.map → chunk-Z7NI5347.js.map} +0 -0
@@ -1,243 +1,13 @@
1
- import * as _fuf_stack_veto from '@fuf-stack/veto';
2
- import { VetoTypeAny, VetoInstance, VetoFormattedError } from '@fuf-stack/veto';
3
- import * as react_hook_form from 'react-hook-form';
4
- import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState, FieldValues, Path, FieldError, ArrayPath } from 'react-hook-form';
5
- import * as _heroui_input from '@heroui/input';
6
- import { useInput } from '@heroui/input';
1
+ export { clientValidationSchemaByName, useClientValidation } from './useClientValidation/index.js';
2
+ export { UseControllerProps, UseControllerReturn, useController } from './useController/index.js';
3
+ export { UseUniformFieldArrayProps, useUniformFieldArray } from './useUniformFieldArray/index.js';
4
+ export { checkFieldIsRequired, useFormContext } from './useFormContext/index.js';
7
5
  export { useInput } from '@heroui/input';
8
- import * as React from 'react';
9
- import { ReactNode } from 'react';
10
- import { D as DebugModeSettings } from '../FormContext-LRho0tno.js';
11
6
  export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce } from './useInputValueDebounce/index.js';
12
7
  export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform } from './useInputValueTransform/index.js';
13
-
14
- /**
15
- * Hook for adding dynamic client-side validation to forms.
16
- *
17
- * Automatically manages validation schema lifecycle: sets schema when data is provided,
18
- * clears schema when data is null/undefined, and cleans up on unmount.
19
- *
20
- * When the client validation schema changes, automatically re-validates all touched
21
- * fields to ensure they are validated against the new schema.
22
- *
23
- * @param data - Data to create validation schema from (or null/undefined to clear validation)
24
- * @param schemaFactory - Function that creates a validation schema from the data.
25
- *
26
- * @example
27
- * ```tsx
28
- * const { data: teamData } = useTeamQuery(teamId);
29
- *
30
- * useClientValidation(teamData, (data) =>
31
- * vt.object({
32
- * username: vt.string().refine(
33
- * (value) => !data.existingUsers.includes(value),
34
- * { message: 'Username already exists' }
35
- * )
36
- * })
37
- * );
38
- * ```
39
- */
40
- declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
41
-
42
- type UseControllerProps<TFieldValues extends object = object> = UseControllerProps$1<TFieldValues>;
43
- interface UseControllerReturn<TFieldValues extends object = object> {
44
- field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {
45
- onChange: (...event: any[]) => void;
46
- value: string;
47
- };
48
- formState: UseFormStateReturn<TFieldValues>;
49
- fieldState: ControllerFieldState;
50
- }
51
- /**
52
- * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.
53
- *
54
- * Key features:
55
- * 1. Empty strings ('') in the UI are stored as null in form state
56
- * 2. Null/undefined values in form state are displayed as empty strings in the UI
57
- * 3. Handles both direct value changes and React synthetic events
58
- * 4. Maintains the same API as react-hook-form's useController
59
- *
60
- * This enables consistent handling of empty/null values while keeping a clean API
61
- * for form inputs that expect string values.
62
- *
63
- * @see https://react-hook-form.com/docs/usecontroller
64
- */
65
- declare const useController: <TFieldValues extends object = object>(props: UseControllerProps<TFieldValues>) => UseControllerReturn<TFieldValues>;
66
-
67
- /** Schema check whether a field is required or optional */
68
- declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) => boolean;
69
- /**
70
- * Custom hook that extends react-hook-form's useFormContext to add validation and state management.
71
- */
72
- declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
73
- formState: react_hook_form.FormState<TFieldValues>;
74
- getFieldState: (name: Path<TFieldValues>, testId?: string) => {
75
- error: FieldError[] | undefined;
76
- invalid: boolean;
77
- required: boolean;
78
- testId: string;
79
- isDirty: boolean;
80
- isTouched: boolean;
81
- isValidating: boolean;
82
- };
83
- getValues: react_hook_form.UseFormGetValues<TFieldValues>;
84
- subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
85
- watch: react_hook_form.UseFormWatch<TFieldValues>;
86
- debugMode: "debug" | "debug-testids" | "off" | "disabled";
87
- debugModeSettings?: DebugModeSettings;
88
- preventSubmit: (prevent: boolean) => void;
89
- setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
90
- triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
91
- validation: {
92
- instance?: VetoInstance;
93
- errors?: VetoFormattedError;
94
- setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
95
- };
96
- setError: react_hook_form.UseFormSetError<TFieldValues>;
97
- clearErrors: react_hook_form.UseFormClearErrors<TFieldValues>;
98
- setValue: react_hook_form.UseFormSetValue<TFieldValues>;
99
- trigger: react_hook_form.UseFormTrigger<TFieldValues>;
100
- resetField: react_hook_form.UseFormResetField<TFieldValues>;
101
- reset: react_hook_form.UseFormReset<TFieldValues>;
102
- handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
103
- unregister: react_hook_form.UseFormUnregister<TFieldValues>;
104
- control: react_hook_form.Control<TFieldValues, TContext, TTransformedValues>;
105
- register: react_hook_form.UseFormRegister<TFieldValues>;
106
- setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
107
- };
108
-
109
- interface UseUniformFieldArrayProps<TFieldValues extends FieldValues = FieldValues> {
110
- /** Field name for the array */
111
- name: ArrayPath<TFieldValues>;
112
- /** Whether this is a flat array (array of primitives) */
113
- flat?: boolean;
114
- /** Initial value for new array elements */
115
- elementInitialValue?: unknown;
116
- /** Whether the last element cannot be removed (always maintain at least one element) */
117
- lastElementNotRemovable?: boolean;
118
- /** Disable the field */
119
- disabled?: boolean;
120
- /** Optional explicit test id used to build stable test ids */
121
- testId?: string;
122
- /** Optional label content; pass false to suppress label entirely */
123
- label?: ReactNode | false;
124
- }
125
- /**
126
- * Enhanced useFieldArray hook with initialization and animation logic.
127
- * Based on React Hook Form's useFieldArray with additional features:
128
- * - Automatic initialization when lastElementNotRemovable is set
129
- * - Animation control (disabled during initialization)
130
- * - Support for flat arrays (arrays of primitives)
131
- *
132
- * Note: Automatic validation triggering on length change is disabled to prevent
133
- * triggering form-wide validation. Array validation still runs on form submission.
134
- *
135
- * @see https://react-hook-form.com/docs/usefieldarray
136
- */
137
- declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldValues>({ name, flat, elementInitialValue: _elementInitialValue, lastElementNotRemovable, disabled, testId: explicitTestId, label, }: UseUniformFieldArrayProps<TFieldValues>) => {
138
- control: react_hook_form.Control<TFieldValues, any, TFieldValues>;
139
- debugMode: ReturnType<typeof useFormContext<TFieldValues_1>>["debugMode"];
140
- defaultValue: unknown;
141
- disabled: boolean | undefined;
142
- error: react_hook_form.FieldError[] | undefined;
143
- errorMessage: ReactNode | null;
144
- field: Omit<react_hook_form.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
145
- onChange: (... /** Initial value for new array elements */event: any[]) => void;
146
- value: string;
147
- };
148
- getErrorMessageProps: ReturnType<typeof _heroui_input.useInput>["getErrorMessageProps"];
149
- getHelperWrapperProps: ReturnType<typeof _heroui_input.useInput>["getHelperWrapperProps"];
150
- getLabelProps: ReturnType<typeof _heroui_input.useInput>["getLabelProps"];
151
- getValues: react_hook_form.UseFormGetValues<TFieldValues>;
152
- invalid: boolean;
153
- label: ReactNode | null;
154
- onBlur: ReturnType<typeof useController>["field"]["onBlur"];
155
- onChange: ReturnType<typeof useController>["field"]["onChange"];
156
- ref: ReturnType<typeof useController>["field"]["ref"];
157
- required: boolean;
158
- resetField: react_hook_form.UseFormResetField<TFieldValues>;
159
- testId: string;
160
- fields: react_hook_form.FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>, "id">[];
161
- append: react_hook_form.UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
162
- remove: react_hook_form.UseFieldArrayRemove;
163
- insert: react_hook_form.UseFieldArrayInsert<TFieldValues, ArrayPath<TFieldValues>>;
164
- move: react_hook_form.UseFieldArrayMove;
165
- disableAnimation: boolean;
166
- elementInitialValue: {};
167
- };
168
-
169
- interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues> {
170
- /** Form field name */
171
- name: Path<TFieldValues> & string;
172
- /** Disable the field */
173
- disabled?: boolean;
174
- /** Optional explicit test id used to build stable test ids */
175
- testId?: string;
176
- /** Optional label content; pass false to suppress label entirely */
177
- label?: ReactNode | false;
178
- }
179
- interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues> {
180
- /** react-hook-form control instance for advanced integrations */
181
- control: ReturnType<typeof useFormContext<TFieldValues>>['control'];
182
- /** Debug mode from Uniform provider */
183
- debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];
184
- /** Current value used to initialize uncontrolled components */
185
- defaultValue: unknown;
186
- /** Whether the field is currently disabled (from RHF) */
187
- disabled: boolean | undefined;
188
- /** Validation error(s) for the field */
189
- error: FieldError[] | undefined;
190
- /** Pre-built errorMessage node to plug into components */
191
- errorMessage: ReactNode | null;
192
- /** RHF controller field with nullish conversions applied */
193
- field: ReturnType<typeof useController<TFieldValues>>['field'];
194
- /** Helper to spread standardized error message props to underlying components */
195
- getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];
196
- /** Helper to spread standardized helper wrapper props (for spacing/animation) */
197
- getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];
198
- /** Helper to spread standardized label props to underlying components */
199
- getLabelProps: ReturnType<typeof useInput>['getLabelProps'];
200
- /** Access current form values (converted to validation-friendly format) */
201
- getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];
202
- /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */
203
- invalid: boolean;
204
- /** Computed label node including optional test id copy button */
205
- label: ReactNode | null;
206
- /** onBlur handler from controller */
207
- onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];
208
- /** onChange handler from controller (with nullish handling) */
209
- onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];
210
- /** Ref to forward to underlying control */
211
- ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];
212
- /** Whether the field is required according to validation schema */
213
- required: boolean;
214
- /** Reset a specific field in the form */
215
- resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];
216
- /** Generated HTML data-testid for the field */
217
- testId: string;
218
- }
219
- /**
220
- * Combines frequently used form field logic into a single hook.
221
- *
222
- * Provides:
223
- * - Enhanced form context (validation-aware state, `testId`, value transforms)
224
- * - Controller field with nullish conversion handling
225
- * - Debounced `invalid` state with smart timing:
226
- * • `true` (field becomes invalid): applies immediately so errors show right away
227
- * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations
228
- * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion
229
- * - Smart `invalid` visibility (via `showInvalid`):
230
- * • Shows errors when field is dirty OR touched OR form has been submitted
231
- * • Prevents showing errors on pristine/untouched fields for better UX
232
- * • Works well for all field types (text inputs, checkboxes, radios, arrays)
233
- * - Prebuilt `errorMessage` React node using `FieldValidationError`
234
- * - Computed `label` node which appends a `FieldCopyTestIdButton` in
235
- * `debug-testids` mode
236
- * - `defaultValue` for uncontrolled defaults and all usual field handlers
237
- * - Access to form utilities: `control`, `getValues`, `resetField`
238
- * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,
239
- * `getHelperWrapperProps` for consistent wiring to underlying UI components
240
- */
241
- declare function useUniformField<TFieldValues extends FieldValues = FieldValues>(params: UseUniformFieldParams<TFieldValues>): UseUniformFieldReturn<TFieldValues>;
242
-
243
- export { type UseControllerProps, type UseControllerReturn, type UseUniformFieldArrayProps, type UseUniformFieldParams, type UseUniformFieldReturn, checkFieldIsRequired, useClientValidation, useController, useFormContext, useUniformField, useUniformFieldArray };
8
+ export { UseUniformFieldParams, UseUniformFieldReturn, useUniformField } from './useUniformField/index.js';
9
+ import '@fuf-stack/veto/dist/types.d-CNPgNK-V';
10
+ import '@fuf-stack/veto';
11
+ import 'react-hook-form';
12
+ import 'react';
13
+ import '../FormContext-LRho0tno.js';
@@ -1,24 +1,37 @@
1
- import {
2
- checkFieldIsRequired,
3
- useClientValidation,
4
- useController,
5
- useFormContext,
6
- useInput,
7
- useUniformField,
8
- useUniformFieldArray
9
- } from "../chunk-47MZU3WD.js";
10
- import "../chunk-NTDKZW4E.js";
11
- import "../chunk-ELYGQTXB.js";
12
- import "../chunk-76KOVUDN.js";
1
+ import "../chunk-35V726MB.js";
13
2
  import {
14
3
  useInputValueDebounce
15
4
  } from "../chunk-MODD3TFE.js";
16
5
  import {
17
6
  useInputValueTransform
18
7
  } from "../chunk-7KLFK2IT.js";
8
+ import {
9
+ useUniformFieldArray
10
+ } from "../chunk-Z7FVILDT.js";
11
+ import {
12
+ useUniformField
13
+ } from "../chunk-D3NAUOYG.js";
14
+ import "../chunk-ELYGQTXB.js";
15
+ import {
16
+ useController
17
+ } from "../chunk-CK362NWK.js";
18
+ import {
19
+ useInput
20
+ } from "../chunk-AHJJIANM.js";
21
+ import "../chunk-NTDKZW4E.js";
22
+ import {
23
+ clientValidationSchemaByName,
24
+ useClientValidation
25
+ } from "../chunk-CHNYQVWO.js";
26
+ import {
27
+ checkFieldIsRequired,
28
+ useFormContext
29
+ } from "../chunk-PO5UQAU6.js";
30
+ import "../chunk-76KOVUDN.js";
19
31
  import "../chunk-K2V4ULA2.js";
20
32
  export {
21
33
  checkFieldIsRequired,
34
+ clientValidationSchemaByName,
22
35
  useClientValidation,
23
36
  useController,
24
37
  useFormContext,
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkTEIXBRF5cjs = require('../../chunk-TEIXBRF5.cjs');
5
+ require('../../chunk-NZBO4N3S.cjs');
6
+ require('../../chunk-Z353BLWI.cjs');
7
+ require('../../chunk-555JRYCS.cjs');
8
+
9
+
10
+
11
+ exports.clientValidationSchemaByName = _chunkTEIXBRF5cjs.clientValidationSchemaByName; exports.useClientValidation = _chunkTEIXBRF5cjs.useClientValidation;
12
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useClientValidation/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACA;AACF,2JAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useClientValidation/index.cjs"}
@@ -0,0 +1,78 @@
1
+ import * as _fuf_stack_veto_dist_types_d_CNPgNK_V from '@fuf-stack/veto/dist/types.d-CNPgNK-V';
2
+ import { VetoTypeAny } from '@fuf-stack/veto';
3
+
4
+ /**
5
+ * Hook for adding dynamic client-side validation to forms.
6
+ *
7
+ * Automatically manages validation schema lifecycle: sets schema when data is provided,
8
+ * clears schema when data is null/undefined, and cleans up on unmount.
9
+ *
10
+ * When the client validation schema changes, automatically re-validates all touched
11
+ * fields to ensure they are validated against the new schema.
12
+ *
13
+ * @param data - Data to create validation schema from (or null/undefined to clear validation)
14
+ * @param schemaFactory - Function that creates a validation schema from the data.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const { data: teamData } = useTeamQuery(teamId);
19
+ *
20
+ * useClientValidation(teamData, (data) =>
21
+ * vt.object({
22
+ * username: vt.string().refine(
23
+ * (value) => !data.existingUsers.includes(value),
24
+ * { message: 'Username already exists' }
25
+ * )
26
+ * })
27
+ * );
28
+ * ```
29
+ */
30
+ declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
31
+ /**
32
+ * Helper function to create a veto looseObject schema for a single field with nested path support.
33
+ *
34
+ * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
35
+ * All intermediate objects and arrays are marked as optional to allow partial data structures.
36
+ * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
37
+ *
38
+ * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name')
39
+ * @param fieldSchema - The veto validation schema for the field
40
+ * @returns A nested loose object schema matching the field path structure with proper type inference
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * // Simple field
45
+ * clientValidationSchemaByName('username', vt.string())
46
+ * // => objectLoose({ username: vt.string() })
47
+ * ```
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * // Nested field (with optional intermediate objects)
52
+ * clientValidationSchemaByName('user.profile.email', vt.string().email())
53
+ * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: vt.string().email() }).optional() }).optional() })
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * // Array field (with optional array)
59
+ * clientValidationSchemaByName('items.0.name', vt.string())
60
+ * // => objectLoose({ items: array(objectLoose({ name: vt.string() })).optional() })
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * // Usage with useClientValidation
66
+ * const { data: userData } = useUserQuery(userId);
67
+ *
68
+ * useClientValidation(userData, (data) =>
69
+ * clientValidationSchemaByName('username', vt.string().refine(
70
+ * (value) => !data.existingUsernames.includes(value),
71
+ * { message: 'Username already taken' }
72
+ * ))
73
+ * );
74
+ * ```
75
+ */
76
+ declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_CNPgNK_V.Z;
77
+
78
+ export { clientValidationSchemaByName, useClientValidation };
@@ -0,0 +1,78 @@
1
+ import * as _fuf_stack_veto_dist_types_d_CNPgNK_V from '@fuf-stack/veto/dist/types.d-CNPgNK-V';
2
+ import { VetoTypeAny } from '@fuf-stack/veto';
3
+
4
+ /**
5
+ * Hook for adding dynamic client-side validation to forms.
6
+ *
7
+ * Automatically manages validation schema lifecycle: sets schema when data is provided,
8
+ * clears schema when data is null/undefined, and cleans up on unmount.
9
+ *
10
+ * When the client validation schema changes, automatically re-validates all touched
11
+ * fields to ensure they are validated against the new schema.
12
+ *
13
+ * @param data - Data to create validation schema from (or null/undefined to clear validation)
14
+ * @param schemaFactory - Function that creates a validation schema from the data.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const { data: teamData } = useTeamQuery(teamId);
19
+ *
20
+ * useClientValidation(teamData, (data) =>
21
+ * vt.object({
22
+ * username: vt.string().refine(
23
+ * (value) => !data.existingUsers.includes(value),
24
+ * { message: 'Username already exists' }
25
+ * )
26
+ * })
27
+ * );
28
+ * ```
29
+ */
30
+ declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
31
+ /**
32
+ * Helper function to create a veto looseObject schema for a single field with nested path support.
33
+ *
34
+ * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
35
+ * All intermediate objects and arrays are marked as optional to allow partial data structures.
36
+ * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
37
+ *
38
+ * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name')
39
+ * @param fieldSchema - The veto validation schema for the field
40
+ * @returns A nested loose object schema matching the field path structure with proper type inference
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * // Simple field
45
+ * clientValidationSchemaByName('username', vt.string())
46
+ * // => objectLoose({ username: vt.string() })
47
+ * ```
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * // Nested field (with optional intermediate objects)
52
+ * clientValidationSchemaByName('user.profile.email', vt.string().email())
53
+ * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: vt.string().email() }).optional() }).optional() })
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * // Array field (with optional array)
59
+ * clientValidationSchemaByName('items.0.name', vt.string())
60
+ * // => objectLoose({ items: array(objectLoose({ name: vt.string() })).optional() })
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * // Usage with useClientValidation
66
+ * const { data: userData } = useUserQuery(userId);
67
+ *
68
+ * useClientValidation(userData, (data) =>
69
+ * clientValidationSchemaByName('username', vt.string().refine(
70
+ * (value) => !data.existingUsernames.includes(value),
71
+ * { message: 'Username already taken' }
72
+ * ))
73
+ * );
74
+ * ```
75
+ */
76
+ declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_CNPgNK_V.Z;
77
+
78
+ export { clientValidationSchemaByName, useClientValidation };
@@ -0,0 +1,12 @@
1
+ import {
2
+ clientValidationSchemaByName,
3
+ useClientValidation
4
+ } from "../../chunk-CHNYQVWO.js";
5
+ import "../../chunk-PO5UQAU6.js";
6
+ import "../../chunk-76KOVUDN.js";
7
+ import "../../chunk-K2V4ULA2.js";
8
+ export {
9
+ clientValidationSchemaByName,
10
+ useClientValidation
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkJMFDNTVCcjs = require('../../chunk-JMFDNTVC.cjs');
4
+ require('../../chunk-Z353BLWI.cjs');
5
+ require('../../chunk-555JRYCS.cjs');
6
+
7
+
8
+ exports.useController = _chunkJMFDNTVCcjs.useController;
9
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useController/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACF,wDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useController/index.cjs"}
@@ -0,0 +1,28 @@
1
+ import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState } from 'react-hook-form';
2
+
3
+ type UseControllerProps<TFieldValues extends object = object> = UseControllerProps$1<TFieldValues>;
4
+ interface UseControllerReturn<TFieldValues extends object = object> {
5
+ field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {
6
+ onChange: (...event: any[]) => void;
7
+ value: string;
8
+ };
9
+ formState: UseFormStateReturn<TFieldValues>;
10
+ fieldState: ControllerFieldState;
11
+ }
12
+ /**
13
+ * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.
14
+ *
15
+ * Key features:
16
+ * 1. Empty strings ('') in the UI are stored as null in form state
17
+ * 2. Null/undefined values in form state are displayed as empty strings in the UI
18
+ * 3. Handles both direct value changes and React synthetic events
19
+ * 4. Maintains the same API as react-hook-form's useController
20
+ *
21
+ * This enables consistent handling of empty/null values while keeping a clean API
22
+ * for form inputs that expect string values.
23
+ *
24
+ * @see https://react-hook-form.com/docs/usecontroller
25
+ */
26
+ declare const useController: <TFieldValues extends object = object>(props: UseControllerProps<TFieldValues>) => UseControllerReturn<TFieldValues>;
27
+
28
+ export { type UseControllerProps, type UseControllerReturn, useController };
@@ -0,0 +1,28 @@
1
+ import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState } from 'react-hook-form';
2
+
3
+ type UseControllerProps<TFieldValues extends object = object> = UseControllerProps$1<TFieldValues>;
4
+ interface UseControllerReturn<TFieldValues extends object = object> {
5
+ field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {
6
+ onChange: (...event: any[]) => void;
7
+ value: string;
8
+ };
9
+ formState: UseFormStateReturn<TFieldValues>;
10
+ fieldState: ControllerFieldState;
11
+ }
12
+ /**
13
+ * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.
14
+ *
15
+ * Key features:
16
+ * 1. Empty strings ('') in the UI are stored as null in form state
17
+ * 2. Null/undefined values in form state are displayed as empty strings in the UI
18
+ * 3. Handles both direct value changes and React synthetic events
19
+ * 4. Maintains the same API as react-hook-form's useController
20
+ *
21
+ * This enables consistent handling of empty/null values while keeping a clean API
22
+ * for form inputs that expect string values.
23
+ *
24
+ * @see https://react-hook-form.com/docs/usecontroller
25
+ */
26
+ declare const useController: <TFieldValues extends object = object>(props: UseControllerProps<TFieldValues>) => UseControllerReturn<TFieldValues>;
27
+
28
+ export { type UseControllerProps, type UseControllerReturn, useController };
@@ -0,0 +1,9 @@
1
+ import {
2
+ useController
3
+ } from "../../chunk-CK362NWK.js";
4
+ import "../../chunk-76KOVUDN.js";
5
+ import "../../chunk-K2V4ULA2.js";
6
+ export {
7
+ useController
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkNZBO4N3Scjs = require('../../chunk-NZBO4N3S.cjs');
5
+ require('../../chunk-Z353BLWI.cjs');
6
+ require('../../chunk-555JRYCS.cjs');
7
+
8
+
9
+
10
+ exports.checkFieldIsRequired = _chunkNZBO4N3Scjs.checkFieldIsRequired; exports.useFormContext = _chunkNZBO4N3Scjs.useFormContext;
11
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useFormContext/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACA;AACF,iIAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useFormContext/index.cjs"}
@@ -0,0 +1,50 @@
1
+ import * as _fuf_stack_veto from '@fuf-stack/veto';
2
+ import { VetoInstance, VetoFormattedError } from '@fuf-stack/veto';
3
+ import * as React from 'react';
4
+ import { D as DebugModeSettings } from '../../FormContext-LRho0tno.cjs';
5
+ import * as react_hook_form from 'react-hook-form';
6
+ import { FieldValues, Path, FieldError } from 'react-hook-form';
7
+
8
+ /** Schema check whether a field is required or optional */
9
+ declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) => boolean;
10
+ /**
11
+ * Custom hook that extends react-hook-form's useFormContext to add validation and state management.
12
+ */
13
+ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
14
+ formState: react_hook_form.FormState<TFieldValues>;
15
+ getFieldState: (name: Path<TFieldValues>, testId?: string) => {
16
+ error: FieldError[] | undefined;
17
+ invalid: boolean;
18
+ required: boolean;
19
+ testId: string;
20
+ isDirty: boolean;
21
+ isTouched: boolean;
22
+ isValidating: boolean;
23
+ };
24
+ getValues: react_hook_form.UseFormGetValues<TFieldValues>;
25
+ subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
26
+ watch: react_hook_form.UseFormWatch<TFieldValues>;
27
+ debugMode: "debug" | "debug-testids" | "off" | "disabled";
28
+ debugModeSettings?: DebugModeSettings;
29
+ preventSubmit: (prevent: boolean) => void;
30
+ setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
31
+ triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
32
+ validation: {
33
+ instance?: VetoInstance;
34
+ errors?: VetoFormattedError;
35
+ setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
36
+ };
37
+ setError: react_hook_form.UseFormSetError<TFieldValues>;
38
+ clearErrors: react_hook_form.UseFormClearErrors<TFieldValues>;
39
+ setValue: react_hook_form.UseFormSetValue<TFieldValues>;
40
+ trigger: react_hook_form.UseFormTrigger<TFieldValues>;
41
+ resetField: react_hook_form.UseFormResetField<TFieldValues>;
42
+ reset: react_hook_form.UseFormReset<TFieldValues>;
43
+ handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
44
+ unregister: react_hook_form.UseFormUnregister<TFieldValues>;
45
+ control: react_hook_form.Control<TFieldValues, TContext, TTransformedValues>;
46
+ register: react_hook_form.UseFormRegister<TFieldValues>;
47
+ setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
48
+ };
49
+
50
+ export { checkFieldIsRequired, useFormContext };