@fuf-stack/uniform 1.4.2 → 1.5.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.
- package/dist/Checkboxes/index.cjs +16 -0
- package/dist/{RadioGroup → Checkboxes}/index.cjs.map +1 -1
- package/dist/Checkboxes/index.d.cts +10 -0
- package/dist/Checkboxes/index.d.ts +10 -0
- package/dist/Checkboxes/index.js +16 -0
- package/dist/{CheckboxGroup-B1g42iP0.d.cts → Checkboxes-CR0Uu2g9.d.cts} +9 -9
- package/dist/{CheckboxGroup-B1g42iP0.d.ts → Checkboxes-CR0Uu2g9.d.ts} +9 -9
- package/dist/FieldArray/index.cjs +5 -5
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +4 -4
- package/dist/FieldArray-EP4otr2x.d.cts +160 -0
- package/dist/FieldArray-EP4otr2x.d.ts +160 -0
- package/dist/{FieldValidationError-CU_xw0BL.d.ts → FieldValidationError-DwtLkGMo.d.cts} +2 -2
- package/dist/{FieldValidationError-CU_xw0BL.d.cts → FieldValidationError-DwtLkGMo.d.ts} +2 -2
- package/dist/Form/index.cjs +6 -4
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +5 -3
- package/dist/Input/index.cjs +5 -5
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +4 -4
- package/dist/{Input-C6ujfEkn.d.ts → Input-CCIEnvIp.d.ts} +1 -1
- package/dist/{Input-BQkZtJx8.d.cts → Input-D7HT_8jf.d.cts} +1 -1
- package/dist/RadioBoxes/index.cjs +5 -5
- package/dist/RadioBoxes/index.d.cts +3 -2
- package/dist/RadioBoxes/index.d.ts +3 -2
- package/dist/RadioBoxes/index.js +4 -4
- package/dist/{RadioBoxes-CE3mYoFk.d.cts → RadioBoxes-DpkI28l0.d.cts} +3 -2
- package/dist/{RadioBoxes-CE3mYoFk.d.ts → RadioBoxes-DpkI28l0.d.ts} +3 -2
- package/dist/RadioTabs/index.cjs +5 -5
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +4 -4
- package/dist/{RadioTabs-BCWW3tru.d.cts → RadioTabs-DTDcAZoH.d.cts} +1 -1
- package/dist/{RadioTabs-BCWW3tru.d.ts → RadioTabs-DTDcAZoH.d.ts} +1 -1
- package/dist/Radios/index.cjs +16 -0
- package/dist/Radios/index.cjs.map +1 -0
- package/dist/Radios/index.d.cts +9 -0
- package/dist/Radios/index.d.ts +9 -0
- package/dist/Radios/index.js +16 -0
- package/dist/{RadioGroup-CAOX80Xx.d.cts → Radios-DprlJhoq.d.cts} +9 -9
- package/dist/{RadioGroup-CAOX80Xx.d.ts → Radios-DprlJhoq.d.ts} +9 -9
- package/dist/Select/index.cjs +5 -5
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +4 -4
- package/dist/{Select-CTRWinmO.d.cts → Select-CDkZmZp2.d.cts} +1 -1
- package/dist/{Select-CTRWinmO.d.ts → Select-CDkZmZp2.d.ts} +1 -1
- package/dist/SubmitButton/index.cjs +6 -4
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +5 -3
- package/dist/Switch/index.cjs +5 -5
- package/dist/Switch/index.js +4 -4
- package/dist/TextArea/index.cjs +5 -5
- package/dist/TextArea/index.d.cts +4 -2
- package/dist/TextArea/index.d.ts +4 -2
- package/dist/TextArea/index.js +4 -4
- package/dist/TextArea-DhxNWYNg.d.cts +86 -0
- package/dist/TextArea-DhxNWYNg.d.ts +86 -0
- package/dist/{chunk-Y3GELCDP.js → chunk-2QLCCB3L.js} +62 -67
- package/dist/chunk-2QLCCB3L.js.map +1 -0
- package/dist/chunk-3YDAYNNB.cjs +683 -0
- package/dist/chunk-3YDAYNNB.cjs.map +1 -0
- package/dist/chunk-4GBNXNCZ.js +683 -0
- package/dist/chunk-4GBNXNCZ.js.map +1 -0
- package/dist/{chunk-ULR4573W.cjs → chunk-4MMOSRT3.cjs} +40 -38
- package/dist/chunk-4MMOSRT3.cjs.map +1 -0
- package/dist/{chunk-FHRMVL6B.js → chunk-62BVHALF.js} +134 -89
- package/dist/chunk-62BVHALF.js.map +1 -0
- package/dist/{chunk-UGCZORU3.cjs → chunk-65BN4MRG.cjs} +9 -9
- package/dist/chunk-65BN4MRG.cjs.map +1 -0
- package/dist/{chunk-2B6CDMOZ.js → chunk-74NPRJVH.js} +16 -25
- package/dist/chunk-74NPRJVH.js.map +1 -0
- package/dist/chunk-76KOVUDN.js +138 -0
- package/dist/chunk-76KOVUDN.js.map +1 -0
- package/dist/{chunk-AYNTZPKL.cjs → chunk-7NWHDCME.cjs} +132 -87
- package/dist/chunk-7NWHDCME.cjs.map +1 -0
- package/dist/{chunk-IYDCKENI.js → chunk-CFH4VPJ4.js} +166 -26
- package/dist/chunk-CFH4VPJ4.js.map +1 -0
- package/dist/{chunk-KG4XCEPW.js → chunk-COLAXULB.js} +42 -40
- package/dist/chunk-COLAXULB.js.map +1 -0
- package/dist/{chunk-N2EEOWEP.cjs → chunk-DHO4HSO7.cjs} +59 -64
- package/dist/chunk-DHO4HSO7.cjs.map +1 -0
- package/dist/{chunk-77C6VN4L.cjs → chunk-EAJFV3AD.cjs} +50 -47
- package/dist/chunk-EAJFV3AD.cjs.map +1 -0
- package/dist/chunk-ELYGQTXB.js +47 -0
- package/dist/chunk-ELYGQTXB.js.map +1 -0
- package/dist/{chunk-FOVP54XP.cjs → chunk-EO4A7QGM.cjs} +18 -27
- package/dist/chunk-EO4A7QGM.cjs.map +1 -0
- package/dist/chunk-GVMEDVT5.cjs +117 -0
- package/dist/chunk-GVMEDVT5.cjs.map +1 -0
- package/dist/chunk-HSKFVCTS.js +103 -0
- package/dist/chunk-HSKFVCTS.js.map +1 -0
- package/dist/{chunk-2GYFDVXX.cjs → chunk-J5FFM7WG.cjs} +173 -33
- package/dist/chunk-J5FFM7WG.cjs.map +1 -0
- package/dist/{chunk-M2DNMSQZ.js → chunk-JLJB4A4K.js} +52 -49
- package/dist/chunk-JLJB4A4K.js.map +1 -0
- package/dist/{chunk-C64RKQEW.cjs → chunk-KBUECB4B.cjs} +3 -3
- package/dist/{chunk-C64RKQEW.cjs.map → chunk-KBUECB4B.cjs.map} +1 -1
- package/dist/chunk-NHEZXA4H.cjs +47 -0
- package/dist/chunk-NHEZXA4H.cjs.map +1 -0
- package/dist/chunk-RTFM4VRY.cjs +103 -0
- package/dist/chunk-RTFM4VRY.cjs.map +1 -0
- package/dist/{chunk-LJQ35BUK.js → chunk-RW35BB4P.js} +2 -2
- package/dist/{chunk-M7VM7XBE.js → chunk-SLTUNYTD.js} +8 -8
- package/dist/chunk-SLTUNYTD.js.map +1 -0
- package/dist/{chunk-YEKHVKS3.cjs → chunk-TFMVYQGN.cjs} +44 -42
- package/dist/chunk-TFMVYQGN.cjs.map +1 -0
- package/dist/chunk-TVMCTUQ4.js +117 -0
- package/dist/chunk-TVMCTUQ4.js.map +1 -0
- package/dist/chunk-Z353BLWI.cjs +138 -0
- package/dist/chunk-Z353BLWI.cjs.map +1 -0
- package/dist/{chunk-C52NGPIF.js → chunk-ZQ64MG7T.js} +48 -46
- package/dist/chunk-ZQ64MG7T.js.map +1 -0
- package/dist/helpers/index.cjs +4 -2
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.d.cts +54 -10
- package/dist/helpers/index.d.ts +54 -10
- package/dist/helpers/index.js +3 -1
- package/dist/hooks/index.cjs +7 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +86 -4
- package/dist/hooks/index.d.ts +86 -4
- package/dist/hooks/index.js +8 -4
- package/dist/index.cjs +20 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +30 -26
- package/dist/partials/FieldValidationError/index.cjs +2 -2
- package/dist/partials/FieldValidationError/index.d.cts +2 -2
- package/dist/partials/FieldValidationError/index.d.ts +2 -2
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +12 -11
- package/dist/CheckboxGroup/index.cjs +0 -16
- package/dist/CheckboxGroup/index.cjs.map +0 -1
- package/dist/CheckboxGroup/index.d.cts +0 -10
- package/dist/CheckboxGroup/index.d.ts +0 -10
- package/dist/CheckboxGroup/index.js +0 -16
- package/dist/FieldArray-DVQka7Bh.d.cts +0 -130
- package/dist/FieldArray-DVQka7Bh.d.ts +0 -130
- package/dist/RadioGroup/index.cjs +0 -16
- package/dist/RadioGroup/index.d.cts +0 -9
- package/dist/RadioGroup/index.d.ts +0 -9
- package/dist/RadioGroup/index.js +0 -16
- package/dist/TextArea-DnFGyl4a.d.cts +0 -27
- package/dist/TextArea-DnFGyl4a.d.ts +0 -27
- package/dist/chunk-2B6CDMOZ.js.map +0 -1
- package/dist/chunk-2GYFDVXX.cjs.map +0 -1
- package/dist/chunk-77C6VN4L.cjs.map +0 -1
- package/dist/chunk-AYNTZPKL.cjs.map +0 -1
- package/dist/chunk-C52NGPIF.js.map +0 -1
- package/dist/chunk-CQWA2DFV.js +0 -37
- package/dist/chunk-CQWA2DFV.js.map +0 -1
- package/dist/chunk-EEBHFSBY.cjs +0 -112
- package/dist/chunk-EEBHFSBY.cjs.map +0 -1
- package/dist/chunk-FHRMVL6B.js.map +0 -1
- package/dist/chunk-FOVP54XP.cjs.map +0 -1
- package/dist/chunk-IYDCKENI.js.map +0 -1
- package/dist/chunk-JZF4HUYO.cjs +0 -409
- package/dist/chunk-JZF4HUYO.cjs.map +0 -1
- package/dist/chunk-KG4XCEPW.js.map +0 -1
- package/dist/chunk-KQN55PEW.js +0 -76
- package/dist/chunk-KQN55PEW.js.map +0 -1
- package/dist/chunk-M2DNMSQZ.js.map +0 -1
- package/dist/chunk-M7VM7XBE.js.map +0 -1
- package/dist/chunk-N2EEOWEP.cjs.map +0 -1
- package/dist/chunk-NAZIH6HV.js +0 -409
- package/dist/chunk-NAZIH6HV.js.map +0 -1
- package/dist/chunk-RDBCJJI7.cjs +0 -88
- package/dist/chunk-RDBCJJI7.cjs.map +0 -1
- package/dist/chunk-RF7KNUCI.js +0 -88
- package/dist/chunk-RF7KNUCI.js.map +0 -1
- package/dist/chunk-UGCZORU3.cjs.map +0 -1
- package/dist/chunk-ULR4573W.cjs.map +0 -1
- package/dist/chunk-XKMLCM5K.js +0 -112
- package/dist/chunk-XKMLCM5K.js.map +0 -1
- package/dist/chunk-Y3AB4GV6.cjs +0 -37
- package/dist/chunk-Y3AB4GV6.cjs.map +0 -1
- package/dist/chunk-Y3GELCDP.js.map +0 -1
- package/dist/chunk-YEKHVKS3.cjs.map +0 -1
- package/dist/chunk-YGNY6CKU.cjs +0 -76
- package/dist/chunk-YGNY6CKU.cjs.map +0 -1
- /package/dist/{CheckboxGroup → Checkboxes}/index.js.map +0 -0
- /package/dist/{RadioGroup → Radios}/index.js.map +0 -0
- /package/dist/{chunk-LJQ35BUK.js.map → chunk-RW35BB4P.js.map} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
3
|
+
import { TVProps, TVClassName } from '@fuf-stack/pixel-utils';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
declare const textAreaVariants: tailwind_variants.TVReturnType<{
|
|
7
|
+
[key: string]: {
|
|
8
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
9
|
+
base?: tailwind_variants.ClassValue;
|
|
10
|
+
input?: tailwind_variants.ClassValue;
|
|
11
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
12
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
18
|
+
base?: tailwind_variants.ClassValue;
|
|
19
|
+
input?: tailwind_variants.ClassValue;
|
|
20
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
21
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | {}, {
|
|
25
|
+
/** wrapper around the whole input */
|
|
26
|
+
base: string;
|
|
27
|
+
/** clear button */
|
|
28
|
+
clearButton: string;
|
|
29
|
+
/** actual input element */
|
|
30
|
+
input: string;
|
|
31
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
32
|
+
inputWrapper: string;
|
|
33
|
+
}, undefined, {
|
|
34
|
+
[key: string]: {
|
|
35
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
36
|
+
base?: tailwind_variants.ClassValue;
|
|
37
|
+
input?: tailwind_variants.ClassValue;
|
|
38
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
39
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} | {}, {
|
|
43
|
+
/** wrapper around the whole input */
|
|
44
|
+
base: string;
|
|
45
|
+
/** clear button */
|
|
46
|
+
clearButton: string;
|
|
47
|
+
/** actual input element */
|
|
48
|
+
input: string;
|
|
49
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
50
|
+
inputWrapper: string;
|
|
51
|
+
}, tailwind_variants.TVReturnType<unknown, {
|
|
52
|
+
/** wrapper around the whole input */
|
|
53
|
+
base: string;
|
|
54
|
+
/** clear button */
|
|
55
|
+
clearButton: string;
|
|
56
|
+
/** actual input element */
|
|
57
|
+
input: string;
|
|
58
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
59
|
+
inputWrapper: string;
|
|
60
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
61
|
+
type VariantProps = TVProps<typeof textAreaVariants>;
|
|
62
|
+
type ClassName = TVClassName<typeof textAreaVariants>;
|
|
63
|
+
interface TextAreaProps extends VariantProps {
|
|
64
|
+
/** Child components. The content of the textarea. */
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
/** CSS class name */
|
|
67
|
+
className?: ClassName;
|
|
68
|
+
/** debounce delay in milliseconds for form state updates (default: 300ms) */
|
|
69
|
+
debounceDelay?: number;
|
|
70
|
+
/** Determines if the TextArea is disabled or not. */
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
/** Label displayed above the TextArea. */
|
|
73
|
+
label?: ReactNode;
|
|
74
|
+
/** Name the TextArea is registered at in HTML forms (react-hook-form). */
|
|
75
|
+
name: string;
|
|
76
|
+
/** placeholder for the textArea content. */
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
/** Id to grab element in internal tests. */
|
|
79
|
+
testId?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)
|
|
83
|
+
*/
|
|
84
|
+
declare const TextArea: ({ children, className: _className, debounceDelay, name, placeholder, ...uniformFieldProps }: TextAreaProps) => react_jsx_runtime.JSX.Element;
|
|
85
|
+
|
|
86
|
+
export { TextArea as T, type TextAreaProps as a };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
3
|
+
import { TVProps, TVClassName } from '@fuf-stack/pixel-utils';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
declare const textAreaVariants: tailwind_variants.TVReturnType<{
|
|
7
|
+
[key: string]: {
|
|
8
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
9
|
+
base?: tailwind_variants.ClassValue;
|
|
10
|
+
input?: tailwind_variants.ClassValue;
|
|
11
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
12
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
18
|
+
base?: tailwind_variants.ClassValue;
|
|
19
|
+
input?: tailwind_variants.ClassValue;
|
|
20
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
21
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | {}, {
|
|
25
|
+
/** wrapper around the whole input */
|
|
26
|
+
base: string;
|
|
27
|
+
/** clear button */
|
|
28
|
+
clearButton: string;
|
|
29
|
+
/** actual input element */
|
|
30
|
+
input: string;
|
|
31
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
32
|
+
inputWrapper: string;
|
|
33
|
+
}, undefined, {
|
|
34
|
+
[key: string]: {
|
|
35
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
36
|
+
base?: tailwind_variants.ClassValue;
|
|
37
|
+
input?: tailwind_variants.ClassValue;
|
|
38
|
+
inputWrapper?: tailwind_variants.ClassValue;
|
|
39
|
+
clearButton?: tailwind_variants.ClassValue;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} | {}, {
|
|
43
|
+
/** wrapper around the whole input */
|
|
44
|
+
base: string;
|
|
45
|
+
/** clear button */
|
|
46
|
+
clearButton: string;
|
|
47
|
+
/** actual input element */
|
|
48
|
+
input: string;
|
|
49
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
50
|
+
inputWrapper: string;
|
|
51
|
+
}, tailwind_variants.TVReturnType<unknown, {
|
|
52
|
+
/** wrapper around the whole input */
|
|
53
|
+
base: string;
|
|
54
|
+
/** clear button */
|
|
55
|
+
clearButton: string;
|
|
56
|
+
/** actual input element */
|
|
57
|
+
input: string;
|
|
58
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
59
|
+
inputWrapper: string;
|
|
60
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
61
|
+
type VariantProps = TVProps<typeof textAreaVariants>;
|
|
62
|
+
type ClassName = TVClassName<typeof textAreaVariants>;
|
|
63
|
+
interface TextAreaProps extends VariantProps {
|
|
64
|
+
/** Child components. The content of the textarea. */
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
/** CSS class name */
|
|
67
|
+
className?: ClassName;
|
|
68
|
+
/** debounce delay in milliseconds for form state updates (default: 300ms) */
|
|
69
|
+
debounceDelay?: number;
|
|
70
|
+
/** Determines if the TextArea is disabled or not. */
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
/** Label displayed above the TextArea. */
|
|
73
|
+
label?: ReactNode;
|
|
74
|
+
/** Name the TextArea is registered at in HTML forms (react-hook-form). */
|
|
75
|
+
name: string;
|
|
76
|
+
/** placeholder for the textArea content. */
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
/** Id to grab element in internal tests. */
|
|
79
|
+
testId?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)
|
|
83
|
+
*/
|
|
84
|
+
declare const TextArea: ({ children, className: _className, debounceDelay, name, placeholder, ...uniformFieldProps }: TextAreaProps) => react_jsx_runtime.JSX.Element;
|
|
85
|
+
|
|
86
|
+
export { TextArea as T, type TextAreaProps as a };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-CFH4VPJ4.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
useController,
|
|
9
|
-
useFormContext
|
|
10
|
-
} from "./chunk-IYDCKENI.js";
|
|
6
|
+
} from "./chunk-ELYGQTXB.js";
|
|
11
7
|
import {
|
|
8
|
+
__objRest,
|
|
12
9
|
__spreadProps,
|
|
13
10
|
__spreadValues
|
|
14
11
|
} from "./chunk-K2V4ULA2.js";
|
|
15
12
|
|
|
16
|
-
// src/
|
|
13
|
+
// src/Checkboxes/Checkboxes.tsx
|
|
17
14
|
import {
|
|
18
15
|
Checkbox as HeroCheckbox,
|
|
19
16
|
CheckboxGroup as HeroCheckboxGroup
|
|
@@ -21,14 +18,14 @@ import {
|
|
|
21
18
|
import { checkbox as heroCheckboxVariants } from "@heroui/theme";
|
|
22
19
|
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
23
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
-
var
|
|
21
|
+
var checkboxesVariants = tv({
|
|
25
22
|
slots: {
|
|
26
23
|
base: "group",
|
|
27
24
|
// Needs group for group-data condition
|
|
28
25
|
errorMessage: "text-tiny",
|
|
29
26
|
// see HeroUI styles for group-data condition,
|
|
30
27
|
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
31
|
-
label: "text-foreground group-data-[invalid=true]:!text-danger text-sm subpixel-antialiased",
|
|
28
|
+
label: "text-foreground group-data-[invalid=true]:!text-danger inline-flex text-sm subpixel-antialiased",
|
|
32
29
|
optionBase: "",
|
|
33
30
|
optionIcon: "",
|
|
34
31
|
optionLabel: "",
|
|
@@ -55,44 +52,39 @@ var checkboxGroupVariants = tv({
|
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
});
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
var Checkboxes = (_a) => {
|
|
56
|
+
var _b = _a, {
|
|
57
|
+
className = void 0,
|
|
58
|
+
color = "primary",
|
|
59
|
+
inline = false,
|
|
60
|
+
lineThrough = false,
|
|
61
|
+
options,
|
|
62
|
+
name
|
|
63
|
+
} = _b, uniformFieldProps = __objRest(_b, [
|
|
64
|
+
"className",
|
|
65
|
+
"color",
|
|
66
|
+
"inline",
|
|
67
|
+
"lineThrough",
|
|
68
|
+
"options",
|
|
69
|
+
"name"
|
|
70
|
+
]);
|
|
71
|
+
var _a2;
|
|
70
72
|
const {
|
|
73
|
+
disabled,
|
|
71
74
|
error: _error,
|
|
75
|
+
field: { onChange, value = [], ref, onBlur },
|
|
72
76
|
invalid,
|
|
77
|
+
label,
|
|
73
78
|
required,
|
|
74
79
|
testId
|
|
75
|
-
} =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const variants = checkboxGroupVariants({ lineThrough });
|
|
81
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
82
|
-
const heroCheckboxGroupClassNames = {
|
|
83
|
-
base: classNames.base,
|
|
84
|
-
label: classNames.label,
|
|
85
|
-
wrapper: classNames.wrapper
|
|
86
|
-
};
|
|
87
|
-
const heroCheckboxClassNames = {
|
|
88
|
-
base: classNames.optionBase,
|
|
89
|
-
icon: classNames.optionIcon,
|
|
90
|
-
label: classNames.optionLabel,
|
|
91
|
-
wrapper: classNames.optionWrapper
|
|
92
|
-
};
|
|
93
|
-
const errorFlat = _error && Object.values(
|
|
80
|
+
} = useUniformField(__spreadValues({
|
|
81
|
+
name,
|
|
82
|
+
showInvalidWhen: "immediate"
|
|
83
|
+
}, uniformFieldProps));
|
|
84
|
+
const errorFlat = (_a2 = _error && Object.values(
|
|
94
85
|
_error
|
|
95
|
-
).flat()
|
|
86
|
+
).flat()) != null ? _a2 : [];
|
|
87
|
+
const errorMessage = /* @__PURE__ */ jsx(FieldValidationError_default, { error: errorFlat, testId });
|
|
96
88
|
const getCheckboxValue = (inputValue) => {
|
|
97
89
|
if (Array.isArray(inputValue)) {
|
|
98
90
|
return inputValue;
|
|
@@ -112,38 +104,41 @@ var CheckboxGroup = ({
|
|
|
112
104
|
onChange,
|
|
113
105
|
value: getCheckboxValue(value)
|
|
114
106
|
};
|
|
115
|
-
const
|
|
107
|
+
const checkboxesProps = options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;
|
|
108
|
+
const variants = checkboxesVariants({ lineThrough });
|
|
109
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
110
|
+
const heroCheckboxGroupClassNames = {
|
|
111
|
+
base: classNames.base,
|
|
112
|
+
label: classNames.label,
|
|
113
|
+
wrapper: classNames.wrapper
|
|
114
|
+
};
|
|
115
|
+
const heroCheckboxClassNames = {
|
|
116
|
+
base: classNames.optionBase,
|
|
117
|
+
icon: classNames.optionIcon,
|
|
118
|
+
label: classNames.optionLabel,
|
|
119
|
+
wrapper: classNames.optionWrapper
|
|
120
|
+
};
|
|
116
121
|
return /* @__PURE__ */ jsx(
|
|
117
122
|
HeroCheckboxGroup,
|
|
118
123
|
__spreadProps(__spreadValues({
|
|
124
|
+
ref,
|
|
119
125
|
classNames: heroCheckboxGroupClassNames,
|
|
120
126
|
color: color === "info" ? "primary" : color,
|
|
121
127
|
"data-invalid": invalid,
|
|
122
128
|
"data-testid": testId,
|
|
129
|
+
errorMessage,
|
|
123
130
|
isDisabled: disabled,
|
|
124
131
|
isInvalid: invalid,
|
|
125
132
|
isRequired: required,
|
|
133
|
+
label: label ? /* @__PURE__ */ jsx("legend", { children: label }) : null,
|
|
126
134
|
name,
|
|
127
135
|
onBlur,
|
|
128
|
-
orientation: inline ? "horizontal" : "vertical"
|
|
129
|
-
|
|
130
|
-
FieldValidationError_default,
|
|
131
|
-
{
|
|
132
|
-
className: classNames.errorMessage,
|
|
133
|
-
error: errorFlat,
|
|
134
|
-
testId
|
|
135
|
-
}
|
|
136
|
-
),
|
|
137
|
-
label: showLabel && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
138
|
-
/* @__PURE__ */ jsxs("label", { children: [
|
|
139
|
-
label,
|
|
140
|
-
showTestIdCopyButton && /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
141
|
-
] }),
|
|
142
|
-
ref
|
|
143
|
-
}, checkboxGroupProps), {
|
|
136
|
+
orientation: inline ? "horizontal" : "vertical"
|
|
137
|
+
}, checkboxesProps), {
|
|
144
138
|
children: options == null ? void 0 : options.map((option) => {
|
|
139
|
+
var _a3;
|
|
145
140
|
const optionTestId = slugify(
|
|
146
|
-
`${testId}_option_${(option == null ? void 0 : option.testId)
|
|
141
|
+
`${testId}_option_${(_a3 = option == null ? void 0 : option.testId) != null ? _a3 : option == null ? void 0 : option.value}`,
|
|
147
142
|
{ replaceDots: true }
|
|
148
143
|
);
|
|
149
144
|
const hasSubline = !!option.labelSubline;
|
|
@@ -164,7 +159,7 @@ var CheckboxGroup = ({
|
|
|
164
159
|
classNames: optionClassNames,
|
|
165
160
|
"data-invalid": invalid,
|
|
166
161
|
"data-testid": optionTestId,
|
|
167
|
-
isDisabled: disabled || option.disabled,
|
|
162
|
+
isDisabled: !!disabled || option.disabled,
|
|
168
163
|
value: option == null ? void 0 : option.value,
|
|
169
164
|
"aria-label": typeof option.label === "string" ? option.label : option.value,
|
|
170
165
|
children: labelContent
|
|
@@ -175,13 +170,13 @@ var CheckboxGroup = ({
|
|
|
175
170
|
})
|
|
176
171
|
);
|
|
177
172
|
};
|
|
178
|
-
var
|
|
173
|
+
var Checkboxes_default = Checkboxes;
|
|
179
174
|
|
|
180
|
-
// src/
|
|
181
|
-
var
|
|
175
|
+
// src/Checkboxes/index.ts
|
|
176
|
+
var Checkboxes_default2 = Checkboxes_default;
|
|
182
177
|
|
|
183
178
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
Checkboxes_default,
|
|
180
|
+
Checkboxes_default2
|
|
186
181
|
};
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-2QLCCB3L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Checkboxes/Checkboxes.tsx","../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type {\n CheckboxGroupProps as HeroCheckboxGroupProps,\n CheckboxProps as HeroCheckboxProps,\n} from '@heroui/checkbox';\nimport type { ReactNode } from 'react';\nimport type { FieldError } from 'react-hook-form';\n\nimport {\n Checkbox as HeroCheckbox,\n CheckboxGroup as HeroCheckboxGroup,\n} from '@heroui/checkbox';\nimport { checkbox as heroCheckboxVariants } from '@heroui/theme';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const checkboxesVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n errorMessage: 'text-tiny',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:!text-danger inline-flex text-sm subpixel-antialiased',\n optionBase: '',\n optionIcon: '',\n optionLabel: '',\n optionLabelSubline: '!text-small text-foreground-400',\n optionWrapper: '',\n wrapper: '',\n },\n variants: {\n // see: https://github.com/heroui-inc/heroui/blob/canary/packages/core/theme/src/components/checkbox.ts\n color: {\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n ...heroCheckboxVariants.variants.color,\n } as const,\n lineThrough: {\n true: {\n optionLabel: [\n ...heroCheckboxVariants.variants.lineThrough.true.label,\n // fix stroke position when used with subline and enable animation\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof checkboxesVariants>;\ntype ClassName = TVClassName<typeof checkboxesVariants>;\n\nexport interface CheckboxOption {\n /** option label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n}\n\nexport interface CheckboxesProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Sets all checkboxes disabled */\n disabled?: boolean;\n /** Orientation of the checkboxes */\n inline?: boolean;\n /** Label displayed above the checkboxes */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Name the Field is registered on the form */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxOption[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Checkboxes component based on [HeroUI CheckboxGroup](https://www.heroui.com//docs/components/checkbox-group)\n */\nconst Checkboxes = ({\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n options,\n name,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const {\n disabled,\n error: _error,\n field: { onChange, value = [], ref, onBlur },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // Convert React Hook Form's nested error object structure to a flat array\n // RHF errors can be nested like: checkboxField.0 (individual checkbox errors)\n // and checkboxField._error (global field errors) - this flattens all\n // error values into a single array for rendering with FieldValidationError\n const errorFlat: FieldError[] =\n (_error &&\n Object.values(\n _error as unknown as Record<string, FieldError[]>,\n ).flat()) ??\n [];\n const errorMessage = (\n <FieldValidationError error={errorFlat} testId={testId} />\n );\n\n /**\n * Handles the checkboxes value changes based on the number of options:\n * 1. For single checkbox (options.length === 1):\n * - Converts undefined/empty array to [] for consistent controlled behavior\n * - Extracts single value from array for onChange\n *\n * Example: undefined → []\n * [value] → value\n *\n * 2. For multiple checkboxes:\n * - Uses raw value array with fallback to empty array\n * - Passes through onChange directly\n *\n * Example: undefined → []\n * ['value1', 'value2'] → ['value1', 'value2']\n */\n const getCheckboxValue = (inputValue: unknown): string[] => {\n if (Array.isArray(inputValue)) {\n return inputValue as string[];\n }\n if (inputValue) {\n return [inputValue as string];\n }\n return [];\n };\n\n const singleCheckboxProps = {\n value: getCheckboxValue(value),\n onChange: (newValue: string[]) => {\n onChange(newValue?.[0]);\n },\n };\n\n const multipleCheckboxProps = {\n onChange,\n value: getCheckboxValue(value),\n };\n\n const checkboxesProps =\n options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;\n\n // classNames from slots\n const variants = checkboxesVariants({ lineThrough });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // map slots to HeroUI class names\n const heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames'] = {\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n };\n const heroCheckboxClassNames: HeroCheckboxProps['classNames'] = {\n base: classNames.optionBase,\n icon: classNames.optionIcon,\n label: classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n };\n\n return (\n <HeroCheckboxGroup\n ref={ref}\n classNames={heroCheckboxGroupClassNames}\n color={color === 'info' ? 'primary' : color}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n {...checkboxesProps}\n >\n {options?.map((option) => {\n const optionTestId = slugify(\n `${testId}_option_${option?.testId ?? option?.value}`,\n { replaceDots: true },\n );\n\n // set content and classes depending option has subline\n const hasSubline = !!option.labelSubline;\n let labelContent: ReactNode;\n let optionClassNames = heroCheckboxClassNames;\n if (hasSubline) {\n labelContent = (\n <div className=\"flex grow flex-col items-start\">\n <span className={classNames.optionLabel}>{option.label}</span>\n <span className={classNames.optionLabelSubline}>\n {option.labelSubline}\n </span>\n </div>\n );\n // remove label classes from outer label when subline is used\n optionClassNames = { ...optionClassNames, label: '' };\n } else {\n labelContent = option.label;\n }\n\n return (\n <HeroCheckbox\n key={`index_${option.value}`}\n classNames={optionClassNames}\n data-invalid={invalid}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n value={option?.value}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n >\n {labelContent}\n </HeroCheckbox>\n );\n })}\n </HeroCheckboxGroup>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { Checkboxes };\n\nexport default Checkboxes;\n"],"mappings":"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","names":["_a","Checkboxes_default"]}
|