@fuf-stack/uniform 1.6.5 → 1.8.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.
- package/dist/Checkboxes/index.cjs +13 -11
- package/dist/Checkboxes/index.cjs.map +1 -1
- package/dist/Checkboxes/index.d.cts +3 -2
- package/dist/Checkboxes/index.d.ts +3 -2
- package/dist/Checkboxes/index.js +12 -10
- package/dist/{Checkboxes-CR0Uu2g9.d.ts → Checkboxes-CDjOYw76.d.cts} +3 -0
- package/dist/{Checkboxes-CR0Uu2g9.d.cts → Checkboxes-wWzFP2sn.d.ts} +3 -0
- package/dist/FieldArray/index.cjs +13 -11
- package/dist/FieldArray/index.cjs.map +1 -1
- package/dist/FieldArray/index.js +12 -10
- package/dist/Form/index.cjs +13 -11
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.d.cts +3 -3
- package/dist/Form/index.d.ts +3 -3
- package/dist/Form/index.js +12 -10
- package/dist/{Form-Cu0lWRDN.d.cts → Form-BZZJPLsi.d.cts} +1 -1
- package/dist/{Form-C_11i6PA.d.ts → Form-zsUjI2yq.d.ts} +1 -1
- package/dist/FormContext-9Firwt4k.d.cts +14 -0
- package/dist/FormContext-9Firwt4k.d.ts +14 -0
- package/dist/Input/index.cjs +13 -11
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +12 -10
- package/dist/{Input-CCIEnvIp.d.ts → Input-BcdS2xBM.d.ts} +2 -2
- package/dist/{Input-D7HT_8jf.d.cts → Input-DMVTcinm.d.cts} +2 -2
- package/dist/RadioBoxes/index.cjs +13 -11
- package/dist/RadioBoxes/index.cjs.map +1 -1
- package/dist/RadioBoxes/index.js +12 -10
- package/dist/RadioTabs/index.cjs +13 -11
- package/dist/RadioTabs/index.cjs.map +1 -1
- package/dist/RadioTabs/index.js +12 -10
- package/dist/Radios/index.cjs +13 -11
- package/dist/Radios/index.cjs.map +1 -1
- package/dist/Radios/index.js +12 -10
- package/dist/Select/index.cjs +13 -11
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.js +12 -10
- package/dist/SubmitButton/index.cjs +13 -11
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +12 -10
- package/dist/Switch/index.cjs +13 -11
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.js +12 -10
- package/dist/TextArea/index.cjs +13 -11
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +12 -10
- package/dist/{chunk-HANR2BDX.cjs → chunk-4CWB5XBW.cjs} +5 -5
- package/dist/{chunk-HANR2BDX.cjs.map → chunk-4CWB5XBW.cjs.map} +1 -1
- package/dist/chunk-4F45XA7Y.cjs +26 -0
- package/dist/chunk-4F45XA7Y.cjs.map +1 -0
- package/dist/{chunk-42NCLEX4.cjs → chunk-4L3JXJ62.cjs} +35 -104
- package/dist/chunk-4L3JXJ62.cjs.map +1 -0
- package/dist/{chunk-RI45RSNN.js → chunk-4TQ53WAY.js} +2 -2
- package/dist/{chunk-4WYC2RBE.cjs → chunk-56TQOKG7.cjs} +6 -3
- package/dist/chunk-56TQOKG7.cjs.map +1 -0
- package/dist/{chunk-4Z7LIJHZ.cjs → chunk-6F5EZ6QN.cjs} +3 -3
- package/dist/{chunk-4Z7LIJHZ.cjs.map → chunk-6F5EZ6QN.cjs.map} +1 -1
- package/dist/chunk-6LQ2O6SC.cjs +115 -0
- package/dist/chunk-6LQ2O6SC.cjs.map +1 -0
- package/dist/{chunk-JMFDNTVC.cjs → chunk-7KEUEGRC.cjs} +9 -2
- package/dist/chunk-7KEUEGRC.cjs.map +1 -0
- package/dist/{chunk-HBVHOUAR.js → chunk-BUJNCVUR.js} +3 -3
- package/dist/{chunk-7KLFK2IT.js → chunk-CNTOODUQ.js} +6 -3
- package/dist/chunk-CNTOODUQ.js.map +1 -0
- package/dist/{chunk-CMTSX5UA.cjs → chunk-EB3RNELT.cjs} +6 -4
- package/dist/chunk-EB3RNELT.cjs.map +1 -0
- package/dist/{chunk-D3JYMGTB.js → chunk-EGFB5WEK.js} +47 -37
- package/dist/chunk-EGFB5WEK.js.map +1 -0
- package/dist/{chunk-AAGOHXSZ.js → chunk-EUO4VWRX.js} +2 -2
- package/dist/{chunk-D3EZXJQH.cjs → chunk-EUTTXFWA.cjs} +3 -3
- package/dist/{chunk-D3EZXJQH.cjs.map → chunk-EUTTXFWA.cjs.map} +1 -1
- package/dist/{chunk-QAQ3UP7W.cjs → chunk-FFGFPXNE.cjs} +3 -3
- package/dist/{chunk-QAQ3UP7W.cjs.map → chunk-FFGFPXNE.cjs.map} +1 -1
- package/dist/{chunk-X37C4SVI.js → chunk-FND5Z5BW.js} +4 -7
- package/dist/{chunk-X37C4SVI.js.map → chunk-FND5Z5BW.js.map} +1 -1
- package/dist/{chunk-4RIJJ5AV.js → chunk-GEJUMUTH.js} +55 -41
- package/dist/chunk-GEJUMUTH.js.map +1 -0
- package/dist/{chunk-CK362NWK.js → chunk-GKP3ONKO.js} +9 -2
- package/dist/chunk-GKP3ONKO.js.map +1 -0
- package/dist/{chunk-VDTYZM6N.cjs → chunk-IFBKJ5UZ.cjs} +6 -9
- package/dist/chunk-IFBKJ5UZ.cjs.map +1 -0
- package/dist/{chunk-IK5IWKUC.js → chunk-K33E67GR.js} +6 -6
- package/dist/{chunk-R6IWQWZ6.js → chunk-KGN5JQGG.js} +5 -3
- package/dist/{chunk-R6IWQWZ6.js.map → chunk-KGN5JQGG.js.map} +1 -1
- package/dist/{chunk-M7TOCXYB.js → chunk-KQQAESO7.js} +3 -3
- package/dist/chunk-KWJMKX5J.cjs +1 -0
- package/dist/{chunk-LTKRK3OS.cjs.map → chunk-KWJMKX5J.cjs.map} +1 -1
- package/dist/{chunk-NZ54JBSR.js → chunk-LKR6D3RL.js} +36 -105
- package/dist/chunk-LKR6D3RL.js.map +1 -0
- package/dist/{chunk-65UJEB4P.js → chunk-N24A7PIL.js} +2 -2
- package/dist/{chunk-BZ5OMN4Y.cjs → chunk-NTOYCWCJ.cjs} +12 -26
- package/dist/chunk-NTOYCWCJ.cjs.map +1 -0
- package/dist/{chunk-4ATOAQOF.cjs → chunk-OJGPW4Z6.cjs} +3 -3
- package/dist/{chunk-4ATOAQOF.cjs.map → chunk-OJGPW4Z6.cjs.map} +1 -1
- package/dist/{chunk-SOQ6GCN3.cjs → chunk-OQUTHTOK.cjs} +48 -38
- package/dist/chunk-OQUTHTOK.cjs.map +1 -0
- package/dist/chunk-PY4GCAFN.js +26 -0
- package/dist/chunk-PY4GCAFN.js.map +1 -0
- package/dist/{chunk-V3NNJJHY.cjs → chunk-S3H432Z2.cjs} +3 -3
- package/dist/{chunk-V3NNJJHY.cjs.map → chunk-S3H432Z2.cjs.map} +1 -1
- package/dist/{chunk-TB5WXGWX.js → chunk-SWPFSD3Y.js} +9 -27
- package/dist/chunk-SWPFSD3Y.js.map +1 -0
- package/dist/{chunk-HX2JJ2ZK.cjs → chunk-TJY5FK4B.cjs} +8 -8
- package/dist/{chunk-HX2JJ2ZK.cjs.map → chunk-TJY5FK4B.cjs.map} +1 -1
- package/dist/chunk-U45RW4FC.js +115 -0
- package/dist/chunk-U45RW4FC.js.map +1 -0
- package/dist/{chunk-NM66XFQH.js → chunk-UEOED4GU.js} +2 -2
- package/dist/{chunk-3NNANHVC.cjs → chunk-UT6VUGFP.cjs} +6 -6
- package/dist/{chunk-3NNANHVC.cjs.map → chunk-UT6VUGFP.cjs.map} +1 -1
- package/dist/chunk-V3GDAELU.js +1 -0
- package/dist/{chunk-I5RBXUIV.js → chunk-VUW522KH.js} +2 -2
- package/dist/{chunk-NUGEM725.js → chunk-WWGKXYZB.js} +2 -2
- package/dist/{chunk-PC3VCEGM.cjs → chunk-ZEJ45LLM.cjs} +3 -3
- package/dist/{chunk-PC3VCEGM.cjs.map → chunk-ZEJ45LLM.cjs.map} +1 -1
- package/dist/{chunk-HEGORLRF.cjs → chunk-ZFZK6EM2.cjs} +10 -28
- package/dist/chunk-ZFZK6EM2.cjs.map +1 -0
- package/dist/{chunk-MODD3TFE.js → chunk-ZJDU5EPE.js} +12 -26
- package/dist/chunk-ZJDU5EPE.js.map +1 -0
- package/dist/{chunk-7NZVPVK3.cjs → chunk-ZLTMRO6X.cjs} +56 -42
- package/dist/chunk-ZLTMRO6X.cjs.map +1 -0
- package/dist/hooks/index.cjs +17 -12
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +2 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +17 -12
- package/dist/hooks/useClientValidation/index.cjs +4 -3
- package/dist/hooks/useClientValidation/index.cjs.map +1 -1
- package/dist/hooks/useClientValidation/index.js +3 -2
- package/dist/hooks/useController/index.cjs +3 -2
- package/dist/hooks/useController/index.cjs.map +1 -1
- package/dist/hooks/useController/index.d.cts +1 -0
- package/dist/hooks/useController/index.d.ts +1 -0
- package/dist/hooks/useController/index.js +2 -1
- package/dist/hooks/useFormContext/index.cjs +3 -2
- package/dist/hooks/useFormContext/index.cjs.map +1 -1
- package/dist/hooks/useFormContext/index.d.cts +5 -1
- package/dist/hooks/useFormContext/index.d.ts +5 -1
- package/dist/hooks/useFormContext/index.js +2 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -3
- package/dist/hooks/useInputValueDebounce/index.cjs.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +17 -52
- package/dist/hooks/useInputValueDebounce/index.d.ts +17 -52
- package/dist/hooks/useInputValueDebounce/index.js +1 -2
- package/dist/hooks/useInputValueTransform/index.cjs +2 -2
- package/dist/hooks/useInputValueTransform/index.d.cts +31 -13
- package/dist/hooks/useInputValueTransform/index.d.ts +31 -13
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +7 -5
- package/dist/hooks/useUniformField/index.cjs.map +1 -1
- package/dist/hooks/useUniformField/index.d.cts +16 -5
- package/dist/hooks/useUniformField/index.d.ts +16 -5
- package/dist/hooks/useUniformField/index.js +6 -4
- package/dist/hooks/useUniformFieldArray/index.cjs +8 -6
- package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +2 -2
- package/dist/hooks/useUniformFieldArray/index.d.ts +2 -2
- package/dist/hooks/useUniformFieldArray/index.js +7 -5
- package/dist/hooks/useWatchUserChange/index.cjs +11 -0
- package/dist/hooks/useWatchUserChange/index.cjs.map +1 -0
- package/dist/hooks/useWatchUserChange/index.d.cts +73 -0
- package/dist/hooks/useWatchUserChange/index.d.ts +73 -0
- package/dist/hooks/useWatchUserChange/index.js +11 -0
- package/dist/hooks/useWatchUserChange/index.js.map +1 -0
- package/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +29 -24
- package/package.json +9 -3
- package/dist/FormContext-LRho0tno.d.cts +0 -8
- package/dist/FormContext-LRho0tno.d.ts +0 -8
- package/dist/chunk-35V726MB.js +0 -1
- package/dist/chunk-42NCLEX4.cjs.map +0 -1
- package/dist/chunk-4RIJJ5AV.js.map +0 -1
- package/dist/chunk-4WYC2RBE.cjs.map +0 -1
- package/dist/chunk-7KLFK2IT.js.map +0 -1
- package/dist/chunk-7NZVPVK3.cjs.map +0 -1
- package/dist/chunk-BZ5OMN4Y.cjs.map +0 -1
- package/dist/chunk-CK362NWK.js.map +0 -1
- package/dist/chunk-CMTSX5UA.cjs.map +0 -1
- package/dist/chunk-D3JYMGTB.js.map +0 -1
- package/dist/chunk-HEGORLRF.cjs.map +0 -1
- package/dist/chunk-JMFDNTVC.cjs.map +0 -1
- package/dist/chunk-LTKRK3OS.cjs +0 -1
- package/dist/chunk-MODD3TFE.js.map +0 -1
- package/dist/chunk-NZ54JBSR.js.map +0 -1
- package/dist/chunk-SOQ6GCN3.cjs.map +0 -1
- package/dist/chunk-TB5WXGWX.js.map +0 -1
- package/dist/chunk-VDTYZM6N.cjs.map +0 -1
- /package/dist/{chunk-RI45RSNN.js.map → chunk-4TQ53WAY.js.map} +0 -0
- /package/dist/{chunk-HBVHOUAR.js.map → chunk-BUJNCVUR.js.map} +0 -0
- /package/dist/{chunk-AAGOHXSZ.js.map → chunk-EUO4VWRX.js.map} +0 -0
- /package/dist/{chunk-IK5IWKUC.js.map → chunk-K33E67GR.js.map} +0 -0
- /package/dist/{chunk-M7TOCXYB.js.map → chunk-KQQAESO7.js.map} +0 -0
- /package/dist/{chunk-65UJEB4P.js.map → chunk-N24A7PIL.js.map} +0 -0
- /package/dist/{chunk-NM66XFQH.js.map → chunk-UEOED4GU.js.map} +0 -0
- /package/dist/{chunk-35V726MB.js.map → chunk-V3GDAELU.js.map} +0 -0
- /package/dist/{chunk-I5RBXUIV.js.map → chunk-VUW522KH.js.map} +0 -0
- /package/dist/{chunk-NUGEM725.js.map → chunk-WWGKXYZB.js.map} +0 -0
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface UseInputValueDebounceOptions {
|
|
1
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
4
2
|
/** Debounce delay in milliseconds (default: 300) */
|
|
5
3
|
debounceDelay?: number;
|
|
6
4
|
/** The onBlur function to call after flushing debounced value */
|
|
7
5
|
onBlur: () => void;
|
|
8
6
|
/** The onChange function to call with debounced value */
|
|
9
7
|
onChange: (...event: any[]) => void;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/** Input type to handle number conversion (optional) */
|
|
13
|
-
type?: 'text' | 'number' | 'password';
|
|
14
|
-
/** The initial form value */
|
|
15
|
-
value: string | number;
|
|
8
|
+
/** The field value */
|
|
9
|
+
value: TValue;
|
|
16
10
|
}
|
|
17
|
-
interface UseInputValueDebounceReturn {
|
|
11
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
18
12
|
/** Enhanced onChange function with debouncing */
|
|
19
13
|
onChange: (...event: any[]) => void;
|
|
20
14
|
/** Enhanced onBlur function that flushes current value immediately */
|
|
21
15
|
onBlur: () => void;
|
|
22
16
|
/** The field value that is displayed - updates immediately */
|
|
23
|
-
value:
|
|
17
|
+
value: TValue;
|
|
24
18
|
}
|
|
25
19
|
/**
|
|
26
|
-
* Custom hook for debouncing
|
|
20
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
27
21
|
*
|
|
28
|
-
* Provides immediate visual feedback by updating the
|
|
29
|
-
* while debouncing the actual
|
|
22
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
23
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
30
24
|
* any pending debounced changes are immediately flushed.
|
|
31
25
|
*
|
|
32
26
|
* **Key Features:**
|
|
33
|
-
* - **Debouncing**: Delays
|
|
34
|
-
* - **
|
|
35
|
-
* - **
|
|
36
|
-
* - **Immediate display updates**: UI stays responsive during debouncing
|
|
27
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
28
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
29
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
37
30
|
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
38
31
|
*
|
|
32
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
33
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
34
|
+
*
|
|
39
35
|
* @param options Configuration for debounced value handling
|
|
40
36
|
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
41
37
|
* @param options.onBlur Function to call after flushing debounced value
|
|
42
38
|
* @param options.onChange Function to call with debounced value
|
|
43
|
-
* @param options.
|
|
44
|
-
* @
|
|
45
|
-
* @param options.value The initial form value
|
|
46
|
-
* @returns Object containing enhanced onChange, onBlur, and immediate display value
|
|
39
|
+
* @param options.value The field value
|
|
40
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
47
41
|
*
|
|
48
42
|
* @example
|
|
49
43
|
* Basic usage with debouncing:
|
|
@@ -55,36 +49,7 @@ interface UseInputValueDebounceReturn {
|
|
|
55
49
|
* value: field.value,
|
|
56
50
|
* });
|
|
57
51
|
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* Number input with automatic conversion:
|
|
61
|
-
* ```tsx
|
|
62
|
-
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
63
|
-
* debounceDelay: 300,
|
|
64
|
-
* onBlur: field.onBlur,
|
|
65
|
-
* onChange: field.onChange,
|
|
66
|
-
* type: 'number',
|
|
67
|
-
* value: field.value, // Display: 123 (number), Form: 123 (number)
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* Currency formatting with transforms:
|
|
73
|
-
* ```tsx
|
|
74
|
-
* const currencyTransform = {
|
|
75
|
-
* displayValue: (val) => val ? `$${Number(val).toFixed(2)}` : '',
|
|
76
|
-
* formValue: (val) => Number(val.replace(/[$,]/g, '')) || 0
|
|
77
|
-
* };
|
|
78
|
-
*
|
|
79
|
-
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
80
|
-
* debounceDelay: 300,
|
|
81
|
-
* onBlur: field.onBlur,
|
|
82
|
-
* onChange: field.onChange,
|
|
83
|
-
* transform: currencyTransform,
|
|
84
|
-
* value: field.value, // Display: "$100.00", Form: 100
|
|
85
|
-
* });
|
|
86
|
-
* ```
|
|
87
52
|
*/
|
|
88
|
-
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange,
|
|
53
|
+
declare const useInputValueDebounce: <TValue = unknown>({ debounceDelay, onBlur, onChange, value, }: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
89
54
|
|
|
90
55
|
export { type UseInputValueDebounceOptions, type UseInputValueDebounceReturn, useInputValueDebounce };
|
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface UseInputValueDebounceOptions {
|
|
1
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
4
2
|
/** Debounce delay in milliseconds (default: 300) */
|
|
5
3
|
debounceDelay?: number;
|
|
6
4
|
/** The onBlur function to call after flushing debounced value */
|
|
7
5
|
onBlur: () => void;
|
|
8
6
|
/** The onChange function to call with debounced value */
|
|
9
7
|
onChange: (...event: any[]) => void;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/** Input type to handle number conversion (optional) */
|
|
13
|
-
type?: 'text' | 'number' | 'password';
|
|
14
|
-
/** The initial form value */
|
|
15
|
-
value: string | number;
|
|
8
|
+
/** The field value */
|
|
9
|
+
value: TValue;
|
|
16
10
|
}
|
|
17
|
-
interface UseInputValueDebounceReturn {
|
|
11
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
18
12
|
/** Enhanced onChange function with debouncing */
|
|
19
13
|
onChange: (...event: any[]) => void;
|
|
20
14
|
/** Enhanced onBlur function that flushes current value immediately */
|
|
21
15
|
onBlur: () => void;
|
|
22
16
|
/** The field value that is displayed - updates immediately */
|
|
23
|
-
value:
|
|
17
|
+
value: TValue;
|
|
24
18
|
}
|
|
25
19
|
/**
|
|
26
|
-
* Custom hook for debouncing
|
|
20
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
27
21
|
*
|
|
28
|
-
* Provides immediate visual feedback by updating the
|
|
29
|
-
* while debouncing the actual
|
|
22
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
23
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
30
24
|
* any pending debounced changes are immediately flushed.
|
|
31
25
|
*
|
|
32
26
|
* **Key Features:**
|
|
33
|
-
* - **Debouncing**: Delays
|
|
34
|
-
* - **
|
|
35
|
-
* - **
|
|
36
|
-
* - **Immediate display updates**: UI stays responsive during debouncing
|
|
27
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
28
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
29
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
37
30
|
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
38
31
|
*
|
|
32
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
33
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
34
|
+
*
|
|
39
35
|
* @param options Configuration for debounced value handling
|
|
40
36
|
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
41
37
|
* @param options.onBlur Function to call after flushing debounced value
|
|
42
38
|
* @param options.onChange Function to call with debounced value
|
|
43
|
-
* @param options.
|
|
44
|
-
* @
|
|
45
|
-
* @param options.value The initial form value
|
|
46
|
-
* @returns Object containing enhanced onChange, onBlur, and immediate display value
|
|
39
|
+
* @param options.value The field value
|
|
40
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
47
41
|
*
|
|
48
42
|
* @example
|
|
49
43
|
* Basic usage with debouncing:
|
|
@@ -55,36 +49,7 @@ interface UseInputValueDebounceReturn {
|
|
|
55
49
|
* value: field.value,
|
|
56
50
|
* });
|
|
57
51
|
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* Number input with automatic conversion:
|
|
61
|
-
* ```tsx
|
|
62
|
-
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
63
|
-
* debounceDelay: 300,
|
|
64
|
-
* onBlur: field.onBlur,
|
|
65
|
-
* onChange: field.onChange,
|
|
66
|
-
* type: 'number',
|
|
67
|
-
* value: field.value, // Display: 123 (number), Form: 123 (number)
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* Currency formatting with transforms:
|
|
73
|
-
* ```tsx
|
|
74
|
-
* const currencyTransform = {
|
|
75
|
-
* displayValue: (val) => val ? `$${Number(val).toFixed(2)}` : '',
|
|
76
|
-
* formValue: (val) => Number(val.replace(/[$,]/g, '')) || 0
|
|
77
|
-
* };
|
|
78
|
-
*
|
|
79
|
-
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
80
|
-
* debounceDelay: 300,
|
|
81
|
-
* onBlur: field.onBlur,
|
|
82
|
-
* onChange: field.onChange,
|
|
83
|
-
* transform: currencyTransform,
|
|
84
|
-
* value: field.value, // Display: "$100.00", Form: 100
|
|
85
|
-
* });
|
|
86
|
-
* ```
|
|
87
52
|
*/
|
|
88
|
-
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange,
|
|
53
|
+
declare const useInputValueDebounce: <TValue = unknown>({ debounceDelay, onBlur, onChange, value, }: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
89
54
|
|
|
90
55
|
export { type UseInputValueDebounceOptions, type UseInputValueDebounceReturn, useInputValueDebounce };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk56TQOKG7cjs = require('../../chunk-56TQOKG7.cjs');
|
|
4
4
|
require('../../chunk-555JRYCS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.useInputValueTransform =
|
|
7
|
+
exports.useInputValueTransform = _chunk56TQOKG7cjs.useInputValueTransform;
|
|
8
8
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
interface InputValueTransform {
|
|
2
|
-
/** Transforms the form value to display value (e.g., 1000 → "$1,000") */
|
|
3
|
-
toDisplayValue: (value:
|
|
4
|
-
/** Transforms the display value to form value (e.g., "$1,000" → 1000) */
|
|
5
|
-
toFormValue: (value:
|
|
1
|
+
interface InputValueTransform<TDisplay = unknown> {
|
|
2
|
+
/** Transforms the form value to display value (e.g., 1000 → "$1,000" or 'a' → ['a']) */
|
|
3
|
+
toDisplayValue: (value: unknown) => TDisplay;
|
|
4
|
+
/** Transforms the display value to form value (e.g., "$1,000" → 1000 or ['a'] → 'a') */
|
|
5
|
+
toFormValue: (value: TDisplay) => unknown;
|
|
6
6
|
}
|
|
7
|
-
interface UseInputValueTransformOptions {
|
|
7
|
+
interface UseInputValueTransformOptions<TDisplay = unknown> {
|
|
8
8
|
/** Input type for special number handling */
|
|
9
9
|
type?: 'text' | 'number' | 'password';
|
|
10
10
|
/** Value transformation functions */
|
|
11
|
-
transform?: InputValueTransform
|
|
11
|
+
transform?: InputValueTransform<TDisplay>;
|
|
12
12
|
}
|
|
13
|
-
interface UseInputValueTransformReturn {
|
|
13
|
+
interface UseInputValueTransformReturn<TDisplay = unknown> {
|
|
14
14
|
/** Converts any form value to display value */
|
|
15
|
-
toDisplayValue: (formValue:
|
|
15
|
+
toDisplayValue: (formValue: unknown) => TDisplay;
|
|
16
16
|
/** Converts any display value to form value */
|
|
17
|
-
toFormValue: (displayValue:
|
|
17
|
+
toFormValue: (displayValue: TDisplay) => unknown;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Custom hook providing utility functions for value transformations between display and form values.
|
|
@@ -24,9 +24,11 @@ interface UseInputValueTransformReturn {
|
|
|
24
24
|
* - Number inputs with special handling
|
|
25
25
|
* - Date formatting (MM/DD/YYYY display vs ISO date stored)
|
|
26
26
|
* - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)
|
|
27
|
+
* - Array/Object transformations (single value ↔ array, nested structures)
|
|
27
28
|
*
|
|
28
29
|
* **Key Features:**
|
|
29
30
|
* - Pure conversion functions (no state)
|
|
31
|
+
* - Generic support for any data type (strings, numbers, arrays, objects)
|
|
30
32
|
* - Special number input handling (empty string preservation)
|
|
31
33
|
* - Bidirectional value transformations
|
|
32
34
|
* - Memoized functions for performance
|
|
@@ -38,8 +40,8 @@ interface UseInputValueTransformReturn {
|
|
|
38
40
|
* ```tsx
|
|
39
41
|
* // Currency formatting
|
|
40
42
|
* const currencyTransform = {
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
+
* toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',
|
|
44
|
+
* toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0
|
|
43
45
|
* };
|
|
44
46
|
*
|
|
45
47
|
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
@@ -63,6 +65,22 @@ interface UseInputValueTransformReturn {
|
|
|
63
65
|
*
|
|
64
66
|
* @example
|
|
65
67
|
* ```tsx
|
|
68
|
+
* // Array to single value (for single checkbox)
|
|
69
|
+
* const singleValueTransform = {
|
|
70
|
+
* toDisplayValue: (val: string[]) => val?.[0] || '',
|
|
71
|
+
* toFormValue: (val: string) => val ? [val] : []
|
|
72
|
+
* };
|
|
73
|
+
*
|
|
74
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
75
|
+
* transform: singleValueTransform
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const displayVal = toDisplayValue(['option1']); // "option1"
|
|
79
|
+
* const formVal = toFormValue("option2"); // ["option2"]
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
66
84
|
* // Integration with debouncing
|
|
67
85
|
* const MyInput = ({ field, transform }) => {
|
|
68
86
|
* const transform = useInputValueTransform({ transform });
|
|
@@ -79,6 +97,6 @@ interface UseInputValueTransformReturn {
|
|
|
79
97
|
* };
|
|
80
98
|
* ```
|
|
81
99
|
*/
|
|
82
|
-
declare const useInputValueTransform: ({ type, transform, }: UseInputValueTransformOptions) => UseInputValueTransformReturn
|
|
100
|
+
declare const useInputValueTransform: <TDisplay = unknown>({ type, transform, }: UseInputValueTransformOptions<TDisplay>) => UseInputValueTransformReturn<TDisplay>;
|
|
83
101
|
|
|
84
102
|
export { type InputValueTransform, type UseInputValueTransformOptions, type UseInputValueTransformReturn, useInputValueTransform };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
interface InputValueTransform {
|
|
2
|
-
/** Transforms the form value to display value (e.g., 1000 → "$1,000") */
|
|
3
|
-
toDisplayValue: (value:
|
|
4
|
-
/** Transforms the display value to form value (e.g., "$1,000" → 1000) */
|
|
5
|
-
toFormValue: (value:
|
|
1
|
+
interface InputValueTransform<TDisplay = unknown> {
|
|
2
|
+
/** Transforms the form value to display value (e.g., 1000 → "$1,000" or 'a' → ['a']) */
|
|
3
|
+
toDisplayValue: (value: unknown) => TDisplay;
|
|
4
|
+
/** Transforms the display value to form value (e.g., "$1,000" → 1000 or ['a'] → 'a') */
|
|
5
|
+
toFormValue: (value: TDisplay) => unknown;
|
|
6
6
|
}
|
|
7
|
-
interface UseInputValueTransformOptions {
|
|
7
|
+
interface UseInputValueTransformOptions<TDisplay = unknown> {
|
|
8
8
|
/** Input type for special number handling */
|
|
9
9
|
type?: 'text' | 'number' | 'password';
|
|
10
10
|
/** Value transformation functions */
|
|
11
|
-
transform?: InputValueTransform
|
|
11
|
+
transform?: InputValueTransform<TDisplay>;
|
|
12
12
|
}
|
|
13
|
-
interface UseInputValueTransformReturn {
|
|
13
|
+
interface UseInputValueTransformReturn<TDisplay = unknown> {
|
|
14
14
|
/** Converts any form value to display value */
|
|
15
|
-
toDisplayValue: (formValue:
|
|
15
|
+
toDisplayValue: (formValue: unknown) => TDisplay;
|
|
16
16
|
/** Converts any display value to form value */
|
|
17
|
-
toFormValue: (displayValue:
|
|
17
|
+
toFormValue: (displayValue: TDisplay) => unknown;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Custom hook providing utility functions for value transformations between display and form values.
|
|
@@ -24,9 +24,11 @@ interface UseInputValueTransformReturn {
|
|
|
24
24
|
* - Number inputs with special handling
|
|
25
25
|
* - Date formatting (MM/DD/YYYY display vs ISO date stored)
|
|
26
26
|
* - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)
|
|
27
|
+
* - Array/Object transformations (single value ↔ array, nested structures)
|
|
27
28
|
*
|
|
28
29
|
* **Key Features:**
|
|
29
30
|
* - Pure conversion functions (no state)
|
|
31
|
+
* - Generic support for any data type (strings, numbers, arrays, objects)
|
|
30
32
|
* - Special number input handling (empty string preservation)
|
|
31
33
|
* - Bidirectional value transformations
|
|
32
34
|
* - Memoized functions for performance
|
|
@@ -38,8 +40,8 @@ interface UseInputValueTransformReturn {
|
|
|
38
40
|
* ```tsx
|
|
39
41
|
* // Currency formatting
|
|
40
42
|
* const currencyTransform = {
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
+
* toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',
|
|
44
|
+
* toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0
|
|
43
45
|
* };
|
|
44
46
|
*
|
|
45
47
|
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
@@ -63,6 +65,22 @@ interface UseInputValueTransformReturn {
|
|
|
63
65
|
*
|
|
64
66
|
* @example
|
|
65
67
|
* ```tsx
|
|
68
|
+
* // Array to single value (for single checkbox)
|
|
69
|
+
* const singleValueTransform = {
|
|
70
|
+
* toDisplayValue: (val: string[]) => val?.[0] || '',
|
|
71
|
+
* toFormValue: (val: string) => val ? [val] : []
|
|
72
|
+
* };
|
|
73
|
+
*
|
|
74
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
75
|
+
* transform: singleValueTransform
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const displayVal = toDisplayValue(['option1']); // "option1"
|
|
79
|
+
* const formVal = toFormValue("option2"); // ["option2"]
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
66
84
|
* // Integration with debouncing
|
|
67
85
|
* const MyInput = ({ field, transform }) => {
|
|
68
86
|
* const transform = useInputValueTransform({ transform });
|
|
@@ -79,6 +97,6 @@ interface UseInputValueTransformReturn {
|
|
|
79
97
|
* };
|
|
80
98
|
* ```
|
|
81
99
|
*/
|
|
82
|
-
declare const useInputValueTransform: ({ type, transform, }: UseInputValueTransformOptions) => UseInputValueTransformReturn
|
|
100
|
+
declare const useInputValueTransform: <TDisplay = unknown>({ type, transform, }: UseInputValueTransformOptions<TDisplay>) => UseInputValueTransformReturn<TDisplay>;
|
|
83
101
|
|
|
84
102
|
export { type InputValueTransform, type UseInputValueTransformOptions, type UseInputValueTransformReturn, useInputValueTransform };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOQUTHTOKcjs = require('../../chunk-OQUTHTOK.cjs');
|
|
4
|
+
require('../../chunk-OE5BOGGX.cjs');
|
|
4
5
|
require('../../chunk-NHEZXA4H.cjs');
|
|
5
|
-
require('../../chunk-
|
|
6
|
+
require('../../chunk-7KEUEGRC.cjs');
|
|
6
7
|
require('../../chunk-PCTYJUY7.cjs');
|
|
7
|
-
require('../../chunk-
|
|
8
|
-
require('../../chunk-
|
|
8
|
+
require('../../chunk-56TQOKG7.cjs');
|
|
9
|
+
require('../../chunk-6LQ2O6SC.cjs');
|
|
10
|
+
require('../../chunk-4L3JXJ62.cjs');
|
|
9
11
|
require('../../chunk-Z353BLWI.cjs');
|
|
10
12
|
require('../../chunk-555JRYCS.cjs');
|
|
11
13
|
|
|
12
14
|
|
|
13
|
-
exports.useUniformField =
|
|
15
|
+
exports.useUniformField = _chunkOQUTHTOKcjs.useUniformField;
|
|
14
16
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformField/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACF,4DAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformField/index.cjs"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformField/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACF,4DAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformField/index.cjs"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FieldValues, Path, FieldError } from 'react-hook-form';
|
|
3
|
+
import { InputValueTransform } from '../useInputValueTransform/index.cjs';
|
|
3
4
|
import { useController } from '../useController/index.cjs';
|
|
4
5
|
import { useFormContext } from '../useFormContext/index.cjs';
|
|
5
6
|
import { useInput } from '@heroui/input';
|
|
6
7
|
import '@fuf-stack/veto';
|
|
7
|
-
import '../../FormContext-
|
|
8
|
+
import '../../FormContext-9Firwt4k.cjs';
|
|
8
9
|
|
|
9
|
-
interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues> {
|
|
10
|
+
interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues, TDisplay = unknown> {
|
|
10
11
|
/** Form field name */
|
|
11
12
|
name: Path<TFieldValues> & string;
|
|
12
13
|
/** Disable the field */
|
|
@@ -15,6 +16,10 @@ interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues>
|
|
|
15
16
|
testId?: string;
|
|
16
17
|
/** Optional label content; pass false to suppress label entirely */
|
|
17
18
|
label?: ReactNode | false;
|
|
19
|
+
/** Input type for special number handling */
|
|
20
|
+
type?: 'text' | 'number' | 'password';
|
|
21
|
+
/** Optional value transformation between form and display values */
|
|
22
|
+
transform?: InputValueTransform<TDisplay>;
|
|
18
23
|
}
|
|
19
24
|
interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues> {
|
|
20
25
|
/** react-hook-form control instance for advanced integrations */
|
|
@@ -29,7 +34,7 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
29
34
|
error: FieldError[] | undefined;
|
|
30
35
|
/** Pre-built errorMessage node to plug into components */
|
|
31
36
|
errorMessage: ReactNode | null;
|
|
32
|
-
/** RHF controller field with
|
|
37
|
+
/** RHF controller field with transformed value/onChange (use this for simple components) */
|
|
33
38
|
field: ReturnType<typeof useController<TFieldValues>>['field'];
|
|
34
39
|
/** Helper to spread standardized error message props to underlying components */
|
|
35
40
|
getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];
|
|
@@ -45,7 +50,7 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
45
50
|
label: ReactNode | null;
|
|
46
51
|
/** onBlur handler from controller */
|
|
47
52
|
onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];
|
|
48
|
-
/** onChange handler from controller (with
|
|
53
|
+
/** onChange handler from controller (with transform applied) */
|
|
49
54
|
onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];
|
|
50
55
|
/** Ref to forward to underlying control */
|
|
51
56
|
ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];
|
|
@@ -62,6 +67,12 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
62
67
|
* Provides:
|
|
63
68
|
* - Enhanced form context (validation-aware state, `testId`, value transforms)
|
|
64
69
|
* - Controller field with nullish conversion handling
|
|
70
|
+
* - Value transformation via `transform` prop:
|
|
71
|
+
* • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)
|
|
72
|
+
* • Automatically applies `toDisplayValue` to field value for components
|
|
73
|
+
* • Automatically applies `toFormValue` to display value when onChange is called
|
|
74
|
+
* • Works with `type` prop for automatic number/string conversion
|
|
75
|
+
* • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata
|
|
65
76
|
* - Debounced `invalid` state with smart timing:
|
|
66
77
|
* • `true` (field becomes invalid): applies immediately so errors show right away
|
|
67
78
|
* • `false` (field becomes valid): delayed 200ms to allow smooth exit animations
|
|
@@ -78,6 +89,6 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
78
89
|
* - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,
|
|
79
90
|
* `getHelperWrapperProps` for consistent wiring to underlying UI components
|
|
80
91
|
*/
|
|
81
|
-
declare function useUniformField<TFieldValues extends FieldValues = FieldValues>(params: UseUniformFieldParams<TFieldValues>): UseUniformFieldReturn<TFieldValues>;
|
|
92
|
+
declare function useUniformField<TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>): UseUniformFieldReturn<TFieldValues>;
|
|
82
93
|
|
|
83
94
|
export { type UseUniformFieldParams, type UseUniformFieldReturn, useUniformField };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FieldValues, Path, FieldError } from 'react-hook-form';
|
|
3
|
+
import { InputValueTransform } from '../useInputValueTransform/index.js';
|
|
3
4
|
import { useController } from '../useController/index.js';
|
|
4
5
|
import { useFormContext } from '../useFormContext/index.js';
|
|
5
6
|
import { useInput } from '@heroui/input';
|
|
6
7
|
import '@fuf-stack/veto';
|
|
7
|
-
import '../../FormContext-
|
|
8
|
+
import '../../FormContext-9Firwt4k.js';
|
|
8
9
|
|
|
9
|
-
interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues> {
|
|
10
|
+
interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues, TDisplay = unknown> {
|
|
10
11
|
/** Form field name */
|
|
11
12
|
name: Path<TFieldValues> & string;
|
|
12
13
|
/** Disable the field */
|
|
@@ -15,6 +16,10 @@ interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues>
|
|
|
15
16
|
testId?: string;
|
|
16
17
|
/** Optional label content; pass false to suppress label entirely */
|
|
17
18
|
label?: ReactNode | false;
|
|
19
|
+
/** Input type for special number handling */
|
|
20
|
+
type?: 'text' | 'number' | 'password';
|
|
21
|
+
/** Optional value transformation between form and display values */
|
|
22
|
+
transform?: InputValueTransform<TDisplay>;
|
|
18
23
|
}
|
|
19
24
|
interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues> {
|
|
20
25
|
/** react-hook-form control instance for advanced integrations */
|
|
@@ -29,7 +34,7 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
29
34
|
error: FieldError[] | undefined;
|
|
30
35
|
/** Pre-built errorMessage node to plug into components */
|
|
31
36
|
errorMessage: ReactNode | null;
|
|
32
|
-
/** RHF controller field with
|
|
37
|
+
/** RHF controller field with transformed value/onChange (use this for simple components) */
|
|
33
38
|
field: ReturnType<typeof useController<TFieldValues>>['field'];
|
|
34
39
|
/** Helper to spread standardized error message props to underlying components */
|
|
35
40
|
getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];
|
|
@@ -45,7 +50,7 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
45
50
|
label: ReactNode | null;
|
|
46
51
|
/** onBlur handler from controller */
|
|
47
52
|
onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];
|
|
48
|
-
/** onChange handler from controller (with
|
|
53
|
+
/** onChange handler from controller (with transform applied) */
|
|
49
54
|
onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];
|
|
50
55
|
/** Ref to forward to underlying control */
|
|
51
56
|
ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];
|
|
@@ -62,6 +67,12 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
62
67
|
* Provides:
|
|
63
68
|
* - Enhanced form context (validation-aware state, `testId`, value transforms)
|
|
64
69
|
* - Controller field with nullish conversion handling
|
|
70
|
+
* - Value transformation via `transform` prop:
|
|
71
|
+
* • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)
|
|
72
|
+
* • Automatically applies `toDisplayValue` to field value for components
|
|
73
|
+
* • Automatically applies `toFormValue` to display value when onChange is called
|
|
74
|
+
* • Works with `type` prop for automatic number/string conversion
|
|
75
|
+
* • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata
|
|
65
76
|
* - Debounced `invalid` state with smart timing:
|
|
66
77
|
* • `true` (field becomes invalid): applies immediately so errors show right away
|
|
67
78
|
* • `false` (field becomes valid): delayed 200ms to allow smooth exit animations
|
|
@@ -78,6 +89,6 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
78
89
|
* - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,
|
|
79
90
|
* `getHelperWrapperProps` for consistent wiring to underlying UI components
|
|
80
91
|
*/
|
|
81
|
-
declare function useUniformField<TFieldValues extends FieldValues = FieldValues>(params: UseUniformFieldParams<TFieldValues>): UseUniformFieldReturn<TFieldValues>;
|
|
92
|
+
declare function useUniformField<TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>): UseUniformFieldReturn<TFieldValues>;
|
|
82
93
|
|
|
83
94
|
export { type UseUniformFieldParams, type UseUniformFieldReturn, useUniformField };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-EGFB5WEK.js";
|
|
4
|
+
import "../../chunk-NTDKZW4E.js";
|
|
4
5
|
import "../../chunk-ELYGQTXB.js";
|
|
5
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-GKP3ONKO.js";
|
|
6
7
|
import "../../chunk-AHJJIANM.js";
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-CNTOODUQ.js";
|
|
9
|
+
import "../../chunk-U45RW4FC.js";
|
|
10
|
+
import "../../chunk-LKR6D3RL.js";
|
|
9
11
|
import "../../chunk-76KOVUDN.js";
|
|
10
12
|
import "../../chunk-K2V4ULA2.js";
|
|
11
13
|
export {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var _chunkIFBKJ5UZcjs = require('../../chunk-IFBKJ5UZ.cjs');
|
|
4
|
+
require('../../chunk-OQUTHTOK.cjs');
|
|
5
|
+
require('../../chunk-OE5BOGGX.cjs');
|
|
5
6
|
require('../../chunk-NHEZXA4H.cjs');
|
|
6
|
-
require('../../chunk-
|
|
7
|
+
require('../../chunk-7KEUEGRC.cjs');
|
|
7
8
|
require('../../chunk-PCTYJUY7.cjs');
|
|
8
|
-
require('../../chunk-
|
|
9
|
-
require('../../chunk-
|
|
9
|
+
require('../../chunk-56TQOKG7.cjs');
|
|
10
|
+
require('../../chunk-6LQ2O6SC.cjs');
|
|
11
|
+
require('../../chunk-4L3JXJ62.cjs');
|
|
10
12
|
require('../../chunk-Z353BLWI.cjs');
|
|
11
13
|
require('../../chunk-555JRYCS.cjs');
|
|
12
14
|
|
|
13
15
|
|
|
14
|
-
exports.useUniformFieldArray =
|
|
16
|
+
exports.useUniformFieldArray = _chunkIFBKJ5UZcjs.useUniformFieldArray;
|
|
15
17
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformFieldArray/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACF,sEAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformFieldArray/index.cjs"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformFieldArray/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,4DAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC,oCAAiC;AACjC;AACE;AACF,sEAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/useUniformFieldArray/index.cjs"}
|
|
@@ -5,7 +5,7 @@ import { FieldValues, ArrayPath } from 'react-hook-form';
|
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import { useFormContext } from '../useFormContext/index.cjs';
|
|
7
7
|
import '@fuf-stack/veto';
|
|
8
|
-
import '../../FormContext-
|
|
8
|
+
import '../../FormContext-9Firwt4k.cjs';
|
|
9
9
|
|
|
10
10
|
interface UseUniformFieldArrayProps<TFieldValues extends FieldValues = FieldValues> {
|
|
11
11
|
/** Field name for the array */
|
|
@@ -43,7 +43,7 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
43
43
|
error: react_hook_form.FieldError[] | undefined;
|
|
44
44
|
errorMessage: ReactNode | null;
|
|
45
45
|
field: Omit<react_hook_form.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
|
|
46
|
-
onChange: (...
|
|
46
|
+
onChange: (...event: any[]) => void;
|
|
47
47
|
value: string;
|
|
48
48
|
};
|
|
49
49
|
getErrorMessageProps: ReturnType<typeof _heroui_input.useInput>["getErrorMessageProps"];
|