@fuf-stack/uniform 0.22.0 → 0.23.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/CheckboxGroup/index.cjs +2 -2
- package/dist/CheckboxGroup/index.js +2 -2
- package/dist/FieldArray/index.cjs +2 -2
- package/dist/FieldArray/index.js +2 -2
- package/dist/Form/index.cjs +2 -2
- package/dist/Form/index.js +2 -2
- package/dist/Input/index.cjs +4 -4
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +3 -3
- package/dist/{Input-DsBWaOSk.d.ts → Input-BpsVvxwO.d.ts} +2 -2
- package/dist/{Input-qD-RcDl4.d.cts → Input-Com9bFxL.d.cts} +2 -2
- package/dist/RadioBoxes/index.cjs +2 -2
- package/dist/RadioBoxes/index.js +2 -2
- package/dist/RadioGroup/index.cjs +2 -2
- package/dist/RadioGroup/index.js +2 -2
- package/dist/RadioTabs/index.cjs +4 -4
- package/dist/RadioTabs/index.js +3 -3
- package/dist/Select/index.cjs +2 -2
- package/dist/Select/index.js +2 -2
- package/dist/SubmitButton/index.cjs +2 -2
- package/dist/SubmitButton/index.js +2 -2
- package/dist/Switch/index.cjs +4 -4
- package/dist/Switch/index.d.cts +4 -2
- package/dist/Switch/index.d.ts +4 -2
- package/dist/Switch/index.js +3 -3
- package/dist/{Switch-CLs964dL.d.cts → Switch-BaMtW2HN.d.cts} +12 -3
- package/dist/{Switch-CLs964dL.d.ts → Switch-BaMtW2HN.d.ts} +12 -3
- package/dist/TextArea/index.cjs +4 -4
- package/dist/TextArea/index.js +3 -3
- package/dist/{chunk-NR5MV234.js → chunk-3PTHYFAU.js} +10 -2
- package/dist/chunk-3PTHYFAU.js.map +1 -0
- package/dist/{chunk-SHB3Z5GN.cjs → chunk-AZT3TDWZ.cjs} +3 -3
- package/dist/{chunk-SHB3Z5GN.cjs.map → chunk-AZT3TDWZ.cjs.map} +1 -1
- package/dist/{chunk-QTROOQ53.cjs → chunk-DOBUPJPN.cjs} +10 -2
- package/dist/chunk-DOBUPJPN.cjs.map +1 -0
- package/dist/{chunk-IZFO7YMQ.js → chunk-GHO2VFUQ.js} +2 -2
- package/dist/{chunk-IZFO7YMQ.js.map → chunk-GHO2VFUQ.js.map} +1 -1
- package/dist/{chunk-IAMV2JNU.cjs → chunk-I4OVSJFQ.cjs} +2 -2
- package/dist/chunk-I4OVSJFQ.cjs.map +1 -0
- package/dist/{chunk-XDHY7DXJ.js → chunk-NNKOK5EU.js} +2 -2
- package/dist/{chunk-I2PJDXWB.cjs → chunk-OWWUTKGY.cjs} +18 -41
- package/dist/chunk-OWWUTKGY.cjs.map +1 -0
- package/dist/chunk-P6HJOG7D.cjs +41 -0
- package/dist/chunk-P6HJOG7D.cjs.map +1 -0
- package/dist/chunk-Q2BOMFJ5.js +41 -0
- package/dist/chunk-Q2BOMFJ5.js.map +1 -0
- package/dist/{chunk-EPY6UDD3.js → chunk-QDFIRRB5.js} +4 -4
- package/dist/chunk-QDFIRRB5.js.map +1 -0
- package/dist/{chunk-2EYP66KF.cjs → chunk-SG6PWCRL.cjs} +5 -5
- package/dist/chunk-SG6PWCRL.cjs.map +1 -0
- package/dist/{chunk-KMDTMBYI.js → chunk-U5WBLGZV.js} +18 -41
- package/dist/chunk-U5WBLGZV.js.map +1 -0
- package/dist/hooks/index.cjs +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/useInputValueDebounce/index.cjs +3 -3
- package/dist/hooks/useInputValueDebounce/index.d.cts +6 -6
- package/dist/hooks/useInputValueDebounce/index.d.ts +6 -6
- package/dist/hooks/useInputValueDebounce/index.js +2 -2
- package/dist/hooks/useInputValueTransform/index.cjs +2 -2
- package/dist/hooks/useInputValueTransform/index.d.cts +28 -60
- package/dist/hooks/useInputValueTransform/index.d.ts +28 -60
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +6 -6
- package/package.json +4 -4
- package/dist/chunk-2EYP66KF.cjs.map +0 -1
- package/dist/chunk-EPY6UDD3.js.map +0 -1
- package/dist/chunk-G5UX55XC.js +0 -37
- package/dist/chunk-G5UX55XC.js.map +0 -1
- package/dist/chunk-I2PJDXWB.cjs.map +0 -1
- package/dist/chunk-IAMV2JNU.cjs.map +0 -1
- package/dist/chunk-KMDTMBYI.js.map +0 -1
- package/dist/chunk-NR5MV234.js.map +0 -1
- package/dist/chunk-QTROOQ53.cjs.map +0 -1
- package/dist/chunk-TSB65253.cjs +0 -37
- package/dist/chunk-TSB65253.cjs.map +0 -1
- /package/dist/{chunk-XDHY7DXJ.js.map → chunk-NNKOK5EU.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var _chunkOWWUTKGYcjs = require('../../chunk-OWWUTKGY.cjs');
|
|
4
|
+
require('../../chunk-P6HJOG7D.cjs');
|
|
5
5
|
require('../../chunk-555JRYCS.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.useInputValueDebounce =
|
|
8
|
+
exports.useInputValueDebounce = _chunkOWWUTKGYcjs.useInputValueDebounce;
|
|
9
9
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -8,10 +8,10 @@ interface UseInputValueDebounceOptions {
|
|
|
8
8
|
/** The onChange function to call with debounced value */
|
|
9
9
|
onChange: (...event: any[]) => void;
|
|
10
10
|
/** Value transformation functions */
|
|
11
|
-
|
|
11
|
+
transform?: InputValueTransform;
|
|
12
12
|
/** Input type to handle number conversion (optional) */
|
|
13
13
|
type?: 'text' | 'number' | 'password';
|
|
14
|
-
/** The
|
|
14
|
+
/** The initial form value */
|
|
15
15
|
value: string | number;
|
|
16
16
|
}
|
|
17
17
|
interface UseInputValueDebounceReturn {
|
|
@@ -40,9 +40,9 @@ interface UseInputValueDebounceReturn {
|
|
|
40
40
|
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
41
41
|
* @param options.onBlur Function to call after flushing debounced value
|
|
42
42
|
* @param options.onChange Function to call with debounced value
|
|
43
|
-
* @param options.
|
|
43
|
+
* @param options.transform Optional transform functions for display ↔ form value conversion
|
|
44
44
|
* @param options.type Input type for number conversion ('text' | 'number' | 'password')
|
|
45
|
-
* @param options.value The
|
|
45
|
+
* @param options.value The initial form value
|
|
46
46
|
* @returns Object containing enhanced onChange, onBlur, and immediate display value
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
@@ -80,11 +80,11 @@ interface UseInputValueDebounceReturn {
|
|
|
80
80
|
* debounceDelay: 300,
|
|
81
81
|
* onBlur: field.onBlur,
|
|
82
82
|
* onChange: field.onChange,
|
|
83
|
-
*
|
|
83
|
+
* transform: currencyTransform,
|
|
84
84
|
* value: field.value, // Display: "$100.00", Form: 100
|
|
85
85
|
* });
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange,
|
|
88
|
+
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange, transform, type, value, }: UseInputValueDebounceOptions) => UseInputValueDebounceReturn;
|
|
89
89
|
|
|
90
90
|
export { type UseInputValueDebounceOptions, type UseInputValueDebounceReturn, useInputValueDebounce };
|
|
@@ -8,10 +8,10 @@ interface UseInputValueDebounceOptions {
|
|
|
8
8
|
/** The onChange function to call with debounced value */
|
|
9
9
|
onChange: (...event: any[]) => void;
|
|
10
10
|
/** Value transformation functions */
|
|
11
|
-
|
|
11
|
+
transform?: InputValueTransform;
|
|
12
12
|
/** Input type to handle number conversion (optional) */
|
|
13
13
|
type?: 'text' | 'number' | 'password';
|
|
14
|
-
/** The
|
|
14
|
+
/** The initial form value */
|
|
15
15
|
value: string | number;
|
|
16
16
|
}
|
|
17
17
|
interface UseInputValueDebounceReturn {
|
|
@@ -40,9 +40,9 @@ interface UseInputValueDebounceReturn {
|
|
|
40
40
|
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
41
41
|
* @param options.onBlur Function to call after flushing debounced value
|
|
42
42
|
* @param options.onChange Function to call with debounced value
|
|
43
|
-
* @param options.
|
|
43
|
+
* @param options.transform Optional transform functions for display ↔ form value conversion
|
|
44
44
|
* @param options.type Input type for number conversion ('text' | 'number' | 'password')
|
|
45
|
-
* @param options.value The
|
|
45
|
+
* @param options.value The initial form value
|
|
46
46
|
* @returns Object containing enhanced onChange, onBlur, and immediate display value
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
@@ -80,11 +80,11 @@ interface UseInputValueDebounceReturn {
|
|
|
80
80
|
* debounceDelay: 300,
|
|
81
81
|
* onBlur: field.onBlur,
|
|
82
82
|
* onChange: field.onChange,
|
|
83
|
-
*
|
|
83
|
+
* transform: currencyTransform,
|
|
84
84
|
* value: field.value, // Display: "$100.00", Form: 100
|
|
85
85
|
* });
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
|
-
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange,
|
|
88
|
+
declare const useInputValueDebounce: ({ debounceDelay, onBlur, onChange, transform, type, value, }: UseInputValueDebounceOptions) => UseInputValueDebounceReturn;
|
|
89
89
|
|
|
90
90
|
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 _chunkP6HJOG7Dcjs = require('../../chunk-P6HJOG7D.cjs');
|
|
4
4
|
require('../../chunk-555JRYCS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.useInputValueTransform =
|
|
7
|
+
exports.useInputValueTransform = _chunkP6HJOG7Dcjs.useInputValueTransform;
|
|
8
8
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
interface InputValueTransform {
|
|
2
2
|
/** Transforms the form value to display value (e.g., 1000 → "$1,000") */
|
|
3
|
-
|
|
3
|
+
toDisplayValue: (value: string | number) => string | number;
|
|
4
4
|
/** Transforms the display value to form value (e.g., "$1,000" → 1000) */
|
|
5
|
-
|
|
5
|
+
toFormValue: (value: string) => string | number;
|
|
6
6
|
}
|
|
7
7
|
interface UseInputValueTransformOptions {
|
|
8
|
-
/** The current form field value */
|
|
9
|
-
value: string | number;
|
|
10
8
|
/** Input type for special number handling */
|
|
11
9
|
type?: 'text' | 'number' | 'password';
|
|
12
10
|
/** Value transformation functions */
|
|
13
|
-
|
|
11
|
+
transform?: InputValueTransform;
|
|
14
12
|
}
|
|
15
13
|
interface UseInputValueTransformReturn {
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/** Gets the form value from current display value */
|
|
21
|
-
getFormValue: () => string | number;
|
|
14
|
+
/** Converts any form value to display value */
|
|
15
|
+
toDisplayValue: (formValue: string | number) => string | number;
|
|
16
|
+
/** Converts any display value to form value */
|
|
17
|
+
toFormValue: (displayValue: string | number) => string | number;
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
|
-
* Custom hook
|
|
20
|
+
* Custom hook providing utility functions for value transformations between display and form values.
|
|
25
21
|
*
|
|
26
|
-
* This hook
|
|
27
|
-
* stored in the form (form value). It's particularly useful for:
|
|
22
|
+
* This hook provides pure conversion functions without any state management. It's useful for:
|
|
28
23
|
* - Currency formatting ($1,000 display vs 1000 stored)
|
|
29
24
|
* - Number inputs with special handling
|
|
30
25
|
* - Date formatting (MM/DD/YYYY display vs ISO date stored)
|
|
31
26
|
* - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)
|
|
32
27
|
*
|
|
33
28
|
* **Key Features:**
|
|
34
|
-
* -
|
|
35
|
-
* - Automatic external value synchronization (form resets, setValue calls)
|
|
29
|
+
* - Pure conversion functions (no state)
|
|
36
30
|
* - Special number input handling (empty string preservation)
|
|
37
31
|
* - Bidirectional value transformations
|
|
32
|
+
* - Memoized functions for performance
|
|
38
33
|
*
|
|
39
34
|
* @param options Configuration for value transformation
|
|
40
|
-
* @returns
|
|
35
|
+
* @returns Pure conversion utility functions
|
|
41
36
|
*
|
|
42
37
|
* @example
|
|
43
38
|
* ```tsx
|
|
@@ -47,70 +42,43 @@ interface UseInputValueTransformReturn {
|
|
|
47
42
|
* formValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0
|
|
48
43
|
* };
|
|
49
44
|
*
|
|
50
|
-
* const {
|
|
51
|
-
*
|
|
52
|
-
* transformValue: currencyTransform
|
|
45
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
46
|
+
* transform: currencyTransform
|
|
53
47
|
* });
|
|
54
|
-
* // displayValue = "$1,000"
|
|
55
|
-
* // getFormValue() = 1000
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```tsx
|
|
60
|
-
* // Phone number formatting
|
|
61
|
-
* const phoneTransform = {
|
|
62
|
-
* displayValue: (val) => {
|
|
63
|
-
* const cleaned = val.toString().replace(/\D/g, '');
|
|
64
|
-
* const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
|
|
65
|
-
* return match ? `(${match[1]}) ${match[2]}-${match[3]}` : val;
|
|
66
|
-
* },
|
|
67
|
-
* formValue: (val) => val.replace(/\D/g, '')
|
|
68
|
-
* };
|
|
69
48
|
*
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
* transformValue: phoneTransform
|
|
73
|
-
* });
|
|
74
|
-
* // displayValue = "(555) 123-4567"
|
|
75
|
-
* // getFormValue() = "5551234567"
|
|
49
|
+
* const displayVal = toDisplayValue(1000); // "$1,000"
|
|
50
|
+
* const formVal = toFormValue("$1,500"); // 1500
|
|
76
51
|
* ```
|
|
77
52
|
*
|
|
78
53
|
* @example
|
|
79
54
|
* ```tsx
|
|
80
55
|
* // Number input (no transforms needed)
|
|
81
|
-
* const {
|
|
82
|
-
* value: 42,
|
|
56
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
83
57
|
* type: 'number'
|
|
84
58
|
* });
|
|
59
|
+
*
|
|
85
60
|
* // Handles empty string → empty string (not NaN)
|
|
86
61
|
* // Handles "123" → 123 (string to number conversion)
|
|
87
62
|
* ```
|
|
88
63
|
*
|
|
89
64
|
* @example
|
|
90
65
|
* ```tsx
|
|
91
|
-
* //
|
|
92
|
-
* const MyInput = ({ field,
|
|
93
|
-
* const
|
|
94
|
-
* value: field.value,
|
|
95
|
-
* transformValue
|
|
96
|
-
* });
|
|
66
|
+
* // Integration with debouncing
|
|
67
|
+
* const MyInput = ({ field, transform }) => {
|
|
68
|
+
* const transform = useInputValueTransform({ transform });
|
|
97
69
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
70
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
71
|
+
* ...transform,
|
|
72
|
+
* initialValue: field.value,
|
|
73
|
+
* debounceDelay: 300,
|
|
74
|
+
* onBlur: field.onBlur,
|
|
101
75
|
* onChange: field.onChange,
|
|
102
|
-
* debounceDelay: 300
|
|
103
76
|
* });
|
|
104
77
|
*
|
|
105
|
-
* return
|
|
106
|
-
* <input
|
|
107
|
-
* value={displayValue}
|
|
108
|
-
* onChange={handleInputChange}
|
|
109
|
-
* />
|
|
110
|
-
* );
|
|
78
|
+
* return <input value={value} onChange={onChange} onBlur={onBlur} />;
|
|
111
79
|
* };
|
|
112
80
|
* ```
|
|
113
81
|
*/
|
|
114
|
-
declare const useInputValueTransform: ({
|
|
82
|
+
declare const useInputValueTransform: ({ type, transform, }: UseInputValueTransformOptions) => UseInputValueTransformReturn;
|
|
115
83
|
|
|
116
84
|
export { type InputValueTransform, type UseInputValueTransformOptions, type UseInputValueTransformReturn, useInputValueTransform };
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
interface InputValueTransform {
|
|
2
2
|
/** Transforms the form value to display value (e.g., 1000 → "$1,000") */
|
|
3
|
-
|
|
3
|
+
toDisplayValue: (value: string | number) => string | number;
|
|
4
4
|
/** Transforms the display value to form value (e.g., "$1,000" → 1000) */
|
|
5
|
-
|
|
5
|
+
toFormValue: (value: string) => string | number;
|
|
6
6
|
}
|
|
7
7
|
interface UseInputValueTransformOptions {
|
|
8
|
-
/** The current form field value */
|
|
9
|
-
value: string | number;
|
|
10
8
|
/** Input type for special number handling */
|
|
11
9
|
type?: 'text' | 'number' | 'password';
|
|
12
10
|
/** Value transformation functions */
|
|
13
|
-
|
|
11
|
+
transform?: InputValueTransform;
|
|
14
12
|
}
|
|
15
13
|
interface UseInputValueTransformReturn {
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/** Gets the form value from current display value */
|
|
21
|
-
getFormValue: () => string | number;
|
|
14
|
+
/** Converts any form value to display value */
|
|
15
|
+
toDisplayValue: (formValue: string | number) => string | number;
|
|
16
|
+
/** Converts any display value to form value */
|
|
17
|
+
toFormValue: (displayValue: string | number) => string | number;
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
|
-
* Custom hook
|
|
20
|
+
* Custom hook providing utility functions for value transformations between display and form values.
|
|
25
21
|
*
|
|
26
|
-
* This hook
|
|
27
|
-
* stored in the form (form value). It's particularly useful for:
|
|
22
|
+
* This hook provides pure conversion functions without any state management. It's useful for:
|
|
28
23
|
* - Currency formatting ($1,000 display vs 1000 stored)
|
|
29
24
|
* - Number inputs with special handling
|
|
30
25
|
* - Date formatting (MM/DD/YYYY display vs ISO date stored)
|
|
31
26
|
* - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)
|
|
32
27
|
*
|
|
33
28
|
* **Key Features:**
|
|
34
|
-
* -
|
|
35
|
-
* - Automatic external value synchronization (form resets, setValue calls)
|
|
29
|
+
* - Pure conversion functions (no state)
|
|
36
30
|
* - Special number input handling (empty string preservation)
|
|
37
31
|
* - Bidirectional value transformations
|
|
32
|
+
* - Memoized functions for performance
|
|
38
33
|
*
|
|
39
34
|
* @param options Configuration for value transformation
|
|
40
|
-
* @returns
|
|
35
|
+
* @returns Pure conversion utility functions
|
|
41
36
|
*
|
|
42
37
|
* @example
|
|
43
38
|
* ```tsx
|
|
@@ -47,70 +42,43 @@ interface UseInputValueTransformReturn {
|
|
|
47
42
|
* formValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0
|
|
48
43
|
* };
|
|
49
44
|
*
|
|
50
|
-
* const {
|
|
51
|
-
*
|
|
52
|
-
* transformValue: currencyTransform
|
|
45
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
46
|
+
* transform: currencyTransform
|
|
53
47
|
* });
|
|
54
|
-
* // displayValue = "$1,000"
|
|
55
|
-
* // getFormValue() = 1000
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```tsx
|
|
60
|
-
* // Phone number formatting
|
|
61
|
-
* const phoneTransform = {
|
|
62
|
-
* displayValue: (val) => {
|
|
63
|
-
* const cleaned = val.toString().replace(/\D/g, '');
|
|
64
|
-
* const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
|
|
65
|
-
* return match ? `(${match[1]}) ${match[2]}-${match[3]}` : val;
|
|
66
|
-
* },
|
|
67
|
-
* formValue: (val) => val.replace(/\D/g, '')
|
|
68
|
-
* };
|
|
69
48
|
*
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
* transformValue: phoneTransform
|
|
73
|
-
* });
|
|
74
|
-
* // displayValue = "(555) 123-4567"
|
|
75
|
-
* // getFormValue() = "5551234567"
|
|
49
|
+
* const displayVal = toDisplayValue(1000); // "$1,000"
|
|
50
|
+
* const formVal = toFormValue("$1,500"); // 1500
|
|
76
51
|
* ```
|
|
77
52
|
*
|
|
78
53
|
* @example
|
|
79
54
|
* ```tsx
|
|
80
55
|
* // Number input (no transforms needed)
|
|
81
|
-
* const {
|
|
82
|
-
* value: 42,
|
|
56
|
+
* const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
83
57
|
* type: 'number'
|
|
84
58
|
* });
|
|
59
|
+
*
|
|
85
60
|
* // Handles empty string → empty string (not NaN)
|
|
86
61
|
* // Handles "123" → 123 (string to number conversion)
|
|
87
62
|
* ```
|
|
88
63
|
*
|
|
89
64
|
* @example
|
|
90
65
|
* ```tsx
|
|
91
|
-
* //
|
|
92
|
-
* const MyInput = ({ field,
|
|
93
|
-
* const
|
|
94
|
-
* value: field.value,
|
|
95
|
-
* transformValue
|
|
96
|
-
* });
|
|
66
|
+
* // Integration with debouncing
|
|
67
|
+
* const MyInput = ({ field, transform }) => {
|
|
68
|
+
* const transform = useInputValueTransform({ transform });
|
|
97
69
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
70
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
71
|
+
* ...transform,
|
|
72
|
+
* initialValue: field.value,
|
|
73
|
+
* debounceDelay: 300,
|
|
74
|
+
* onBlur: field.onBlur,
|
|
101
75
|
* onChange: field.onChange,
|
|
102
|
-
* debounceDelay: 300
|
|
103
76
|
* });
|
|
104
77
|
*
|
|
105
|
-
* return
|
|
106
|
-
* <input
|
|
107
|
-
* value={displayValue}
|
|
108
|
-
* onChange={handleInputChange}
|
|
109
|
-
* />
|
|
110
|
-
* );
|
|
78
|
+
* return <input value={value} onChange={onChange} onBlur={onBlur} />;
|
|
111
79
|
* };
|
|
112
80
|
* ```
|
|
113
81
|
*/
|
|
114
|
-
declare const useInputValueTransform: ({
|
|
82
|
+
declare const useInputValueTransform: ({ type, transform, }: UseInputValueTransformOptions) => UseInputValueTransformReturn;
|
|
115
83
|
|
|
116
84
|
export { type InputValueTransform, type UseInputValueTransformOptions, type UseInputValueTransformReturn, useInputValueTransform };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkI4OVSJFQcjs = require('./chunk-I4OVSJFQ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkU3XAM5F4cjs = require('./chunk-U3XAM5F4.cjs');
|
|
@@ -9,10 +9,10 @@ var _chunkU3XAM5F4cjs = require('./chunk-U3XAM5F4.cjs');
|
|
|
9
9
|
var _chunkPL44Y7AMcjs = require('./chunk-PL44Y7AM.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkDOBUPJPNcjs = require('./chunk-DOBUPJPN.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkAZT3TDWZcjs = require('./chunk-AZT3TDWZ.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunkGKAVSIH3cjs = require('./chunk-GKAVSIH3.cjs');
|
|
@@ -27,7 +27,7 @@ var _chunkXALYGZ3Rcjs = require('./chunk-XALYGZ3R.cjs');
|
|
|
27
27
|
var _chunkTTD3KL6Ecjs = require('./chunk-TTD3KL6E.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkSG6PWCRLcjs = require('./chunk-SG6PWCRL.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkUOTSJ55Bcjs = require('./chunk-UOTSJ55B.cjs');
|
|
@@ -56,10 +56,10 @@ var _chunkY6EAPURVcjs = require('./chunk-Y6EAPURV.cjs');
|
|
|
56
56
|
var _chunkL4YPB7MUcjs = require('./chunk-L4YPB7MU.cjs');
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _chunkOWWUTKGYcjs = require('./chunk-OWWUTKGY.cjs');
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
var
|
|
62
|
+
var _chunkP6HJOG7Dcjs = require('./chunk-P6HJOG7D.cjs');
|
|
63
63
|
require('./chunk-555JRYCS.cjs');
|
|
64
64
|
|
|
65
65
|
|
|
@@ -88,5 +88,5 @@ require('./chunk-555JRYCS.cjs');
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
exports.CheckboxGroup = _chunkGKAVSIH3cjs.CheckboxGroup_default; exports.FieldArray = _chunkNMYLBRT5cjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkGNYQC5IJcjs.FieldValidationError_default; exports.Form = _chunkXALYGZ3Rcjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input =
|
|
91
|
+
exports.CheckboxGroup = _chunkGKAVSIH3cjs.CheckboxGroup_default; exports.FieldArray = _chunkNMYLBRT5cjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkGNYQC5IJcjs.FieldValidationError_default; exports.Form = _chunkXALYGZ3Rcjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input = _chunkSG6PWCRLcjs.Input_default; exports.RadioBoxes = _chunkUOTSJ55Bcjs.RadioBoxes_default; exports.RadioGroup = _chunkSGXLTMB5cjs.RadioGroup_default; exports.RadioTabs = _chunkI4OVSJFQcjs.RadioTabs_default; exports.Select = _chunkU3XAM5F4cjs.Select_default; exports.SubmitButton = _chunkPL44Y7AMcjs.SubmitButton_default; exports.Switch = _chunkDOBUPJPNcjs.Switch_default; exports.TextArea = _chunkAZT3TDWZcjs.TextArea_default; exports.checkFieldIsRequired = _chunkY6EAPURVcjs.checkFieldIsRequired; exports.fromNullishString = _chunkL4YPB7MUcjs.fromNullishString; exports.toFormFormat = _chunkL4YPB7MUcjs.toFormFormat; exports.toNullishString = _chunkL4YPB7MUcjs.toNullishString; exports.toValidationFormat = _chunkL4YPB7MUcjs.toValidationFormat; exports.useClientValidation = _chunkY6EAPURVcjs.useClientValidation; exports.useController = _chunkY6EAPURVcjs.useController; exports.useFieldArray = _chunkY6EAPURVcjs.useFieldArray; exports.useFormContext = _chunkY6EAPURVcjs.useFormContext; exports.useInput = _chunkY6EAPURVcjs.useInput; exports.useInputValueDebounce = _chunkOWWUTKGYcjs.useInputValueDebounce; exports.useInputValueTransform = _chunkP6HJOG7Dcjs.useInputValueTransform;
|
|
92
92
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ export { useFieldArray } from 'react-hook-form';
|
|
|
8
8
|
export { useInput } from '@heroui/input';
|
|
9
9
|
export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce } from './hooks/useInputValueDebounce/index.cjs';
|
|
10
10
|
export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform } from './hooks/useInputValueTransform/index.cjs';
|
|
11
|
-
export { I as Input, a as InputProps } from './Input-
|
|
11
|
+
export { I as Input, a as InputProps } from './Input-Com9bFxL.cjs';
|
|
12
12
|
export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-_TDlmw0L.cjs';
|
|
13
13
|
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-CU_xw0BL.cjs';
|
|
14
14
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-BmJBBZVd.cjs';
|
|
@@ -16,7 +16,7 @@ export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-BJijfixt.cjs
|
|
|
16
16
|
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-CT8PT7ky.cjs';
|
|
17
17
|
export { S as Select, a as SelectProps } from './Select-JRwrSDew.cjs';
|
|
18
18
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-C81VCkmx.cjs';
|
|
19
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
19
|
+
export { S as Switch, a as SwitchProps } from './Switch-BaMtW2HN.cjs';
|
|
20
20
|
export { T as TextArea, a as TextAreaProps } from './TextArea-DnFGyl4a.cjs';
|
|
21
21
|
import 'react/jsx-runtime';
|
|
22
22
|
import 'tailwind-variants';
|
|
@@ -27,3 +27,4 @@ import '@fuf-stack/veto';
|
|
|
27
27
|
import './FormContext-ldCpxKnY.cjs';
|
|
28
28
|
import '@fuf-stack/pixels';
|
|
29
29
|
import 'react-select';
|
|
30
|
+
import '@heroui/switch';
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { useFieldArray } from 'react-hook-form';
|
|
|
8
8
|
export { useInput } from '@heroui/input';
|
|
9
9
|
export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce } from './hooks/useInputValueDebounce/index.js';
|
|
10
10
|
export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform } from './hooks/useInputValueTransform/index.js';
|
|
11
|
-
export { I as Input, a as InputProps } from './Input-
|
|
11
|
+
export { I as Input, a as InputProps } from './Input-BpsVvxwO.js';
|
|
12
12
|
export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-_TDlmw0L.js';
|
|
13
13
|
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-CU_xw0BL.js';
|
|
14
14
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-BmJBBZVd.js';
|
|
@@ -16,7 +16,7 @@ export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-BJijfixt.js'
|
|
|
16
16
|
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-CT8PT7ky.js';
|
|
17
17
|
export { S as Select, a as SelectProps } from './Select-JRwrSDew.js';
|
|
18
18
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-C81VCkmx.js';
|
|
19
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
19
|
+
export { S as Switch, a as SwitchProps } from './Switch-BaMtW2HN.js';
|
|
20
20
|
export { T as TextArea, a as TextAreaProps } from './TextArea-DnFGyl4a.js';
|
|
21
21
|
import 'react/jsx-runtime';
|
|
22
22
|
import 'tailwind-variants';
|
|
@@ -27,3 +27,4 @@ import '@fuf-stack/veto';
|
|
|
27
27
|
import './FormContext-ldCpxKnY.js';
|
|
28
28
|
import '@fuf-stack/pixels';
|
|
29
29
|
import 'react-select';
|
|
30
|
+
import '@heroui/switch';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RadioTabs_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GHO2VFUQ.js";
|
|
4
4
|
import {
|
|
5
5
|
Select_default
|
|
6
6
|
} from "./chunk-TCYPTU4E.js";
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./chunk-3BE3GUCZ.js";
|
|
10
10
|
import {
|
|
11
11
|
Switch_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3PTHYFAU.js";
|
|
13
13
|
import {
|
|
14
14
|
TextArea_default
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NNKOK5EU.js";
|
|
16
16
|
import {
|
|
17
17
|
CheckboxGroup_default
|
|
18
18
|
} from "./chunk-O7DOVGO2.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./chunk-B62HKKMS.js";
|
|
28
28
|
import {
|
|
29
29
|
Input_default
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-QDFIRRB5.js";
|
|
31
31
|
import {
|
|
32
32
|
RadioBoxes_default
|
|
33
33
|
} from "./chunk-X2PR2IOK.js";
|
|
@@ -56,10 +56,10 @@ import {
|
|
|
56
56
|
} from "./chunk-57WY5GAE.js";
|
|
57
57
|
import {
|
|
58
58
|
useInputValueDebounce
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-U5WBLGZV.js";
|
|
60
60
|
import {
|
|
61
61
|
useInputValueTransform
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-Q2BOMFJ5.js";
|
|
63
63
|
import "./chunk-K2V4ULA2.js";
|
|
64
64
|
export {
|
|
65
65
|
CheckboxGroup_default as CheckboxGroup,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Hannes Tiede",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
"react-icons": "5.5.0",
|
|
144
144
|
"react-hook-form": "7.55.0",
|
|
145
145
|
"react-select": "5.10.1",
|
|
146
|
+
"@fuf-stack/pixels": "0.45.0",
|
|
146
147
|
"@fuf-stack/pixel-utils": "0.5.5",
|
|
147
|
-
"@fuf-stack/pixels": "0.43.10",
|
|
148
148
|
"@fuf-stack/veto": "0.12.1"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
"react-dom": "19.0.0",
|
|
156
156
|
"@repo/storybook-config": "0.0.1",
|
|
157
157
|
"@repo/tailwind-config": "0.0.1",
|
|
158
|
-
"@repo/
|
|
159
|
-
"@repo/
|
|
158
|
+
"@repo/vite-config": "0.0.1",
|
|
159
|
+
"@repo/tsup-config": "0.0.1"
|
|
160
160
|
},
|
|
161
161
|
"scripts": {
|
|
162
162
|
"build": "tsup --config node_modules/@repo/tsup-config/config.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-2EYP66KF.cjs","../src/Input/Input.tsx","../src/Input/index.ts"],"names":["Input_default"],"mappings":"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","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-2EYP66KF.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks';\n\nimport { Input as HeroInput } from '@heroui/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInputValueDebounce } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface InputProps {\n /** CSS class name */\n className?: string;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transformValue?: InputValueTransform;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className = undefined,\n debounceDelay = 300,\n disabled = false,\n endContent = undefined,\n label = undefined,\n name,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n transformValue = undefined,\n type = undefined,\n}: InputProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({\n control,\n disabled,\n name,\n });\n\n const {\n disabled: isDisabled,\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n } = field;\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n transformValue,\n type,\n value: fieldValue,\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <HeroInput\n className={cn(className)}\n classNames={{\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n endContent={endContent}\n errorMessage={\n error && <FieldValidationError error={error} testId={testId} />\n }\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </>\n )\n }\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n radius=\"sm\"\n ref={ref}\n size={size}\n startContent={startContent}\n type={type}\n // @ts-expect-error can be number for input type number\n value={value}\n variant=\"bordered\"\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks';\n\nimport { Input as HeroInput } from '@heroui/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInputValueDebounce } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface InputProps {\n /** CSS class name */\n className?: string;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transformValue?: InputValueTransform;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className = undefined,\n debounceDelay = 300,\n disabled = false,\n endContent = undefined,\n label = undefined,\n name,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n transformValue = undefined,\n type = undefined,\n}: InputProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({\n control,\n disabled,\n name,\n });\n\n const {\n disabled: isDisabled,\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n } = field;\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n transformValue,\n type,\n value: fieldValue,\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <HeroInput\n className={cn(className)}\n classNames={{\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n endContent={endContent}\n errorMessage={\n error && <FieldValidationError error={error} testId={testId} />\n }\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </>\n )\n }\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n radius=\"sm\"\n ref={ref}\n size={size}\n startContent={startContent}\n type={type}\n // @ts-expect-error can be number for input type number\n value={value}\n variant=\"bordered\"\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;;;;;;;;AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,UAAU;AAyFF,SAOP,UAPO,KAOP,YAPO;AArDjB,IAAM,QAAQ,CAAC;AAAA,EACb,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,QAAQ;AAAA,EACR;AAAA,EACA,cAAc;AAAA,EACd,OAAO;AAAA,EACP,eAAe;AAAA,EACf,QAAQ,UAAU;AAAA,EAClB,iBAAiB;AAAA,EACjB,OAAO;AACT,MAAkB;AAChB,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM,EAAE,OAAO,SAAS,UAAU,OAAO,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,MAAM,IAAI,cAAc;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM;AAAA,IACJ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AAGJ,QAAM,EAAE,UAAU,QAAQ,MAAM,IAAI,sBAAsB;AAAA,IACxD;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AAED,QAAM,uBAAuB,cAAc;AAC3C,QAAM,YAAY,SAAS;AAE3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,SAAS;AAAA,MACvB,YAAY;AAAA,QACV,cAAc;AAAA,MAChB;AAAA,MACA,eAAa;AAAA,MACb;AAAA,MACA,cACE,SAAS,oBAAC,gCAAqB,OAAc,QAAgB;AAAA,MAE/D;AAAA,MACA,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,OACE,aACE,iCACG;AAAA;AAAA,QACA,wBAAwB,oBAAC,iCAAsB,QAAgB;AAAA,SAClE;AAAA,MAGJ,gBAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA,SAAQ;AAAA;AAAA,EACV;AAEJ;AAEA,IAAO,gBAAQ;;;ACtHf,IAAOA,iBAAQ;","names":["Input_default"]}
|