@fuf-stack/uniform 1.9.0 → 1.10.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 +5 -10
- package/dist/Checkboxes/index.cjs.map +1 -1
- package/dist/Checkboxes/index.d.cts +2 -2
- package/dist/Checkboxes/index.d.ts +2 -2
- package/dist/Checkboxes/index.js +4 -9
- package/dist/{Checkboxes-CDjOYw76.d.cts → Checkboxes-CBgO9itq.d.cts} +2 -0
- package/dist/{Checkboxes-wWzFP2sn.d.ts → Checkboxes-CFbsc6zg.d.ts} +2 -0
- package/dist/FieldArray/index.cjs +7 -10
- package/dist/FieldArray/index.cjs.map +1 -1
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +6 -9
- package/dist/{FieldArray-Cql1zcch.d.cts → FieldArray-72vn2MG9.d.cts} +2 -2
- package/dist/{FieldArray-Cql1zcch.d.ts → FieldArray-72vn2MG9.d.ts} +2 -2
- package/dist/FieldCard/index.cjs +19 -0
- package/dist/FieldCard/index.cjs.map +1 -0
- package/dist/FieldCard/index.d.cts +95 -0
- package/dist/FieldCard/index.d.ts +95 -0
- package/dist/FieldCard/index.js +19 -0
- package/dist/Form/index.cjs +3 -13
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +2 -12
- package/dist/Input/index.cjs +6 -10
- 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 +5 -9
- package/dist/{Input-DMVTcinm.d.cts → Input-BGYDOpbo.d.cts} +4 -2
- package/dist/{Input-BcdS2xBM.d.ts → Input-__SqMh2n.d.ts} +4 -2
- package/dist/{RadioBox-B0s3q9g6.d.cts → RadioBox-DnqCiTR1.d.cts} +2 -0
- package/dist/{RadioBox-B0s3q9g6.d.ts → RadioBox-DnqCiTR1.d.ts} +2 -0
- package/dist/RadioBoxes/index.cjs +5 -10
- package/dist/RadioBoxes/index.cjs.map +1 -1
- package/dist/RadioBoxes/index.d.cts +2 -2
- package/dist/RadioBoxes/index.d.ts +2 -2
- package/dist/RadioBoxes/index.js +4 -9
- package/dist/RadioTabs/index.cjs +5 -10
- package/dist/RadioTabs/index.cjs.map +1 -1
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +4 -9
- package/dist/{RadioTabs-D9Px3XEs.d.cts → RadioTabs-DkR5fvl4.d.cts} +3 -1
- package/dist/{RadioTabs-D9Px3XEs.d.ts → RadioTabs-DkR5fvl4.d.ts} +3 -1
- package/dist/Radios/index.cjs +5 -10
- package/dist/Radios/index.cjs.map +1 -1
- package/dist/Radios/index.d.cts +2 -2
- package/dist/Radios/index.d.ts +2 -2
- package/dist/Radios/index.js +4 -9
- package/dist/{Radios-DprlJhoq.d.cts → Radios-lLVlvY_B.d.cts} +3 -1
- package/dist/{Radios-DprlJhoq.d.ts → Radios-lLVlvY_B.d.ts} +3 -1
- package/dist/Select/index.cjs +6 -10
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.d.cts +3 -2
- package/dist/Select/index.d.ts +3 -2
- package/dist/Select/index.js +5 -9
- package/dist/{Select-CDkZmZp2.d.cts → Select-DWlnKj5c.d.cts} +8 -5
- package/dist/{Select-CDkZmZp2.d.ts → Select-DWlnKj5c.d.ts} +8 -5
- package/dist/Slider/index.cjs +5 -5
- package/dist/Slider/index.d.cts +2 -2
- package/dist/Slider/index.d.ts +2 -2
- package/dist/Slider/index.js +4 -4
- package/dist/{Slider-CIVhjJy1.d.cts → Slider-CxHvafJA.d.cts} +4 -2
- package/dist/{Slider-CIVhjJy1.d.ts → Slider-CxHvafJA.d.ts} +4 -2
- package/dist/SubmitButton/index.cjs +3 -13
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +2 -12
- package/dist/Switch/index.cjs +5 -10
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.d.cts +2 -2
- package/dist/Switch/index.d.ts +2 -2
- package/dist/Switch/index.js +4 -9
- package/dist/{Switch-CqBVdRJe.d.cts → Switch-B4AuHAMX.d.cts} +2 -0
- package/dist/{Switch-CqBVdRJe.d.ts → Switch-B4AuHAMX.d.ts} +2 -0
- package/dist/SwitchBox/index.cjs +5 -10
- package/dist/SwitchBox/index.cjs.map +1 -1
- package/dist/SwitchBox/index.js +4 -9
- package/dist/TextArea/index.cjs +6 -10
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.d.cts +2 -2
- package/dist/TextArea/index.d.ts +2 -2
- package/dist/TextArea/index.js +5 -9
- package/dist/{TextArea-DhxNWYNg.d.cts → TextArea-CYcFOcun.d.cts} +2 -0
- package/dist/{TextArea-DhxNWYNg.d.ts → TextArea-CYcFOcun.d.ts} +2 -0
- package/dist/{chunk-246OISWB.js → chunk-2EQEKXG2.js} +4 -2
- package/dist/chunk-2EQEKXG2.js.map +1 -0
- package/dist/chunk-36LBVB45.js +1 -0
- package/dist/chunk-3JAVQAL5.cjs +1 -0
- package/dist/{chunk-KWJMKX5J.cjs.map → chunk-3JAVQAL5.cjs.map} +1 -1
- package/dist/{chunk-NTOYCWCJ.cjs → chunk-3ZQXSGR2.cjs} +1 -1
- package/dist/{chunk-NTOYCWCJ.cjs.map → chunk-3ZQXSGR2.cjs.map} +1 -1
- package/dist/{chunk-7FOSZV75.js → chunk-4KEI3VRK.js} +9 -6
- package/dist/chunk-4KEI3VRK.js.map +1 -0
- package/dist/{chunk-V65AMUKK.cjs → chunk-4LLSZ6GN.cjs} +6 -4
- package/dist/chunk-4LLSZ6GN.cjs.map +1 -0
- package/dist/{chunk-UUGSI3FD.js → chunk-5UGCZ7OA.js} +2 -2
- package/dist/chunk-5UGCZ7OA.js.map +1 -0
- package/dist/{chunk-LTE7PW7F.cjs → chunk-6UORUDZV.cjs} +5 -3
- package/dist/chunk-6UORUDZV.cjs.map +1 -0
- package/dist/{chunk-XMCL3F4W.js → chunk-7TUWJWLN.js} +4 -2
- package/dist/chunk-7TUWJWLN.js.map +1 -0
- package/dist/chunk-7WBYC3BC.js +149 -0
- package/dist/chunk-7WBYC3BC.js.map +1 -0
- package/dist/{chunk-DQAZSXD6.js → chunk-BUFKWZNC.js} +2 -2
- package/dist/chunk-BUFKWZNC.js.map +1 -0
- package/dist/{chunk-A3PYIWG2.js → chunk-BZ2PD2JG.js} +1 -1
- package/dist/chunk-BZ2PD2JG.js.map +1 -0
- package/dist/{chunk-XC3C2W4M.cjs → chunk-CM2LLV5N.cjs} +5 -3
- package/dist/chunk-CM2LLV5N.cjs.map +1 -0
- package/dist/{chunk-IZZTVGEW.js → chunk-FHYUMBE3.js} +4 -2
- package/dist/chunk-FHYUMBE3.js.map +1 -0
- package/dist/chunk-FQDOJIQF.cjs +149 -0
- package/dist/chunk-FQDOJIQF.cjs.map +1 -0
- package/dist/{chunk-XXLYUZY4.js → chunk-GQF5HVA4.js} +5 -5
- package/dist/chunk-GQF5HVA4.js.map +1 -0
- package/dist/{chunk-7O6LAGV2.cjs → chunk-HYOALQIV.cjs} +7 -7
- package/dist/chunk-HYOALQIV.cjs.map +1 -0
- package/dist/{chunk-IU4RL2D7.cjs → chunk-IZ5SPNVQ.cjs} +9 -6
- package/dist/chunk-IZ5SPNVQ.cjs.map +1 -0
- package/dist/{chunk-RRG5ZLVF.cjs → chunk-JRE5KEX3.cjs} +1 -1
- package/dist/{chunk-RRG5ZLVF.cjs.map → chunk-JRE5KEX3.cjs.map} +1 -1
- package/dist/{chunk-2OXNDD5W.cjs → chunk-KOV7U4QA.cjs} +6 -3
- package/dist/chunk-KOV7U4QA.cjs.map +1 -0
- package/dist/{chunk-ZJDU5EPE.js → chunk-LEMQGDFE.js} +1 -1
- package/dist/{chunk-XBVXMQBW.js → chunk-M5IL7INR.js} +4 -2
- package/dist/chunk-M5IL7INR.js.map +1 -0
- package/dist/{chunk-CG7GDQAP.js → chunk-MODH7W2M.js} +5 -3
- package/dist/chunk-MODH7W2M.js.map +1 -0
- package/dist/{chunk-VIV3MSIX.cjs → chunk-MSJP25N4.cjs} +5 -3
- package/dist/chunk-MSJP25N4.cjs.map +1 -0
- package/dist/{chunk-MEYGGRBQ.cjs → chunk-MVFEXRWQ.cjs} +3 -3
- package/dist/chunk-MVFEXRWQ.cjs.map +1 -0
- package/dist/{chunk-CEVS6WSG.js → chunk-O5KAFUBE.js} +7 -4
- package/dist/chunk-O5KAFUBE.js.map +1 -0
- package/dist/{chunk-YCCBMAN2.cjs → chunk-OED4DYBD.cjs} +9 -6
- package/dist/chunk-OED4DYBD.cjs.map +1 -0
- package/dist/{chunk-FUMQULCR.cjs → chunk-OIKPQMQ2.cjs} +3 -3
- package/dist/chunk-OIKPQMQ2.cjs.map +1 -0
- package/dist/{chunk-Y7YEI6T2.js → chunk-P2TT7HU5.js} +1 -1
- package/dist/chunk-P2TT7HU5.js.map +1 -0
- package/dist/{chunk-JQQ32JOD.cjs → chunk-PTCZOUQX.cjs} +1 -1
- package/dist/chunk-PTCZOUQX.cjs.map +1 -0
- package/dist/{chunk-MHQ2V7UW.js → chunk-QPKHR6WH.js} +4 -2
- package/dist/chunk-QPKHR6WH.js.map +1 -0
- package/dist/{chunk-SR76XJW4.cjs → chunk-V45YAJT4.cjs} +7 -5
- package/dist/chunk-V45YAJT4.cjs.map +1 -0
- package/dist/{chunk-THCIT66I.cjs → chunk-WRKONOOV.cjs} +5 -3
- package/dist/chunk-WRKONOOV.cjs.map +1 -0
- package/dist/{chunk-7WKVH43M.cjs → chunk-XSS4REAS.cjs} +5 -3
- package/dist/chunk-XSS4REAS.cjs.map +1 -0
- package/dist/{chunk-JICFOKDO.js → chunk-XSVEW3KN.js} +5 -3
- package/dist/chunk-XSVEW3KN.js.map +1 -0
- package/dist/{chunk-LUO4I3TW.js → chunk-YMXUVBQ3.js} +5 -2
- package/dist/chunk-YMXUVBQ3.js.map +1 -0
- package/dist/hooks/useFormContext/index.cjs +2 -1
- package/dist/hooks/useFormContext/index.cjs.map +1 -1
- package/dist/hooks/useFormContext/index.d.cts +2 -2
- package/dist/hooks/useFormContext/index.d.ts +2 -2
- package/dist/hooks/useFormContext/index.js +1 -0
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -2
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +4 -4
- package/dist/hooks/useUniformField/index.d.cts +9 -5
- package/dist/hooks/useUniformField/index.d.ts +9 -5
- package/dist/hooks/useUniformField/index.js +3 -3
- package/dist/hooks/useUniformFieldArray/index.cjs +6 -5
- package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +6 -5
- package/dist/hooks/useUniformFieldArray/index.d.ts +6 -5
- package/dist/hooks/useUniformFieldArray/index.js +5 -4
- package/dist/index.cjs +31 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -16
- package/dist/index.d.ts +17 -16
- package/dist/index.js +41 -35
- package/package.json +8 -8
- package/dist/chunk-246OISWB.js.map +0 -1
- package/dist/chunk-2OXNDD5W.cjs.map +0 -1
- package/dist/chunk-7FOSZV75.js.map +0 -1
- package/dist/chunk-7O6LAGV2.cjs.map +0 -1
- package/dist/chunk-7WKVH43M.cjs.map +0 -1
- package/dist/chunk-A3PYIWG2.js.map +0 -1
- package/dist/chunk-CEVS6WSG.js.map +0 -1
- package/dist/chunk-CG7GDQAP.js.map +0 -1
- package/dist/chunk-DQAZSXD6.js.map +0 -1
- package/dist/chunk-FUMQULCR.cjs.map +0 -1
- package/dist/chunk-IU4RL2D7.cjs.map +0 -1
- package/dist/chunk-IZZTVGEW.js.map +0 -1
- package/dist/chunk-JICFOKDO.js.map +0 -1
- package/dist/chunk-JQQ32JOD.cjs.map +0 -1
- package/dist/chunk-KWJMKX5J.cjs +0 -1
- package/dist/chunk-LTE7PW7F.cjs.map +0 -1
- package/dist/chunk-LUO4I3TW.js.map +0 -1
- package/dist/chunk-MEYGGRBQ.cjs.map +0 -1
- package/dist/chunk-MHQ2V7UW.js.map +0 -1
- package/dist/chunk-SR76XJW4.cjs.map +0 -1
- package/dist/chunk-THCIT66I.cjs.map +0 -1
- package/dist/chunk-UUGSI3FD.js.map +0 -1
- package/dist/chunk-V3GDAELU.js +0 -1
- package/dist/chunk-V65AMUKK.cjs.map +0 -1
- package/dist/chunk-VIV3MSIX.cjs.map +0 -1
- package/dist/chunk-XBVXMQBW.js.map +0 -1
- package/dist/chunk-XC3C2W4M.cjs.map +0 -1
- package/dist/chunk-XMCL3F4W.js.map +0 -1
- package/dist/chunk-XXLYUZY4.js.map +0 -1
- package/dist/chunk-Y7YEI6T2.js.map +0 -1
- package/dist/chunk-YCCBMAN2.cjs.map +0 -1
- package/dist/hooks/index.cjs +0 -49
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.d.cts +0 -14
- package/dist/hooks/index.d.ts +0 -14
- package/dist/hooks/index.js +0 -49
- /package/dist/{hooks → FieldCard}/index.js.map +0 -0
- /package/dist/{chunk-V3GDAELU.js.map → chunk-36LBVB45.js.map} +0 -0
- /package/dist/{chunk-ZJDU5EPE.js.map → chunk-LEMQGDFE.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOED4DYBDcjs = require('./chunk-OED4DYBD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -57,6 +57,7 @@ var Slider = (_a) => {
|
|
|
57
57
|
"maxValue"
|
|
58
58
|
]);
|
|
59
59
|
const {
|
|
60
|
+
ariaLabel,
|
|
60
61
|
disabled,
|
|
61
62
|
field,
|
|
62
63
|
getErrorMessageProps,
|
|
@@ -69,7 +70,7 @@ var Slider = (_a) => {
|
|
|
69
70
|
required,
|
|
70
71
|
errorMessage,
|
|
71
72
|
testId
|
|
72
|
-
} =
|
|
73
|
+
} = _chunkOED4DYBDcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
73
74
|
name
|
|
74
75
|
}, uniformFieldProps));
|
|
75
76
|
const visualSliderRef = _react.useRef.call(void 0, null);
|
|
@@ -111,6 +112,7 @@ var Slider = (_a) => {
|
|
|
111
112
|
_slider.Slider,
|
|
112
113
|
{
|
|
113
114
|
ref: visualSliderRef,
|
|
115
|
+
"aria-label": ariaLabel,
|
|
114
116
|
color: invalid ? "danger" : "primary",
|
|
115
117
|
endContent,
|
|
116
118
|
fillOffset,
|
|
@@ -119,6 +121,7 @@ var Slider = (_a) => {
|
|
|
119
121
|
maxValue,
|
|
120
122
|
minValue,
|
|
121
123
|
name: `${name}_slider`,
|
|
124
|
+
onBlur,
|
|
122
125
|
showSteps,
|
|
123
126
|
size,
|
|
124
127
|
startContent,
|
|
@@ -159,4 +162,4 @@ var Slider_default2 = Slider_default;
|
|
|
159
162
|
|
|
160
163
|
|
|
161
164
|
exports.Slider_default = Slider_default; exports.Slider_default2 = Slider_default2;
|
|
162
|
-
//# sourceMappingURL=chunk-
|
|
165
|
+
//# sourceMappingURL=chunk-KOV7U4QA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-KOV7U4QA.cjs","../src/Slider/Slider.tsx","../src/Slider/index.ts"],"names":["_a","Slider_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,8BAAuB;AAEvB,wCAAuC;AACvC,6DAA+B;AAE/B,oDAAyC;AAwHrC,+CAAA;AApHG,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,UAAA,EAAY,EAAA;AAAA,IACZ,YAAA,EAAc,WAAA;AAAA,IACd,MAAA,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AA,EAAA,KAAA,EAAA,EAAAA,GAAAA,CAAyB,KAAA,CAAA,CAAA;AAAA,YAC3B;AAAA,UAAA;AAAA,QACF,EAAA,CACF,CAAA;AAAA,wBAEA,6BAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAK,eAAA;AAAA,YACL,YAAA,EAAY,SAAA;AAAA,YACZ,KAAA,EAAO,QAAA,EAAU,SAAA,EAAW,SAAA;AAAA,YAC5B,UAAA;AAAA,YACA,UAAA;AAAA,YACA,UAAA,EAAY,QAAA;AAAA,YACZ,KAAA;AAAA,YACA,QAAA;AAAA,YACA,QAAA;AAAA,YACA,IAAA,EAAM,CAAA,EAAA;AAEN,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACO,YAAA;AACP,YAAA;AACE,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACF,YAAA;AAEA,YAAA;AACE,cAAA;AACF,YAAA;AAAA,UAAA;AACF,QAAA;AACA,wBAAA;AAEA,MAAA;AAAA,IAAA;AACF,EAAA;AAEJ;AAEO;ADjDY;AACA;AEvJZC;AFyJY;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-KOV7U4QA.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Slider as HeroUISlider } from '@heroui/slider';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const sliderVariants = tv({\n slots: {\n base: 'group',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n filler: '',\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-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n labelWrapper: '',\n mark: '',\n startContent: '',\n step: '',\n thumb: '',\n track: '',\n trackWrapper: '',\n value: '',\n },\n});\n\ntype VariantProps = TVProps<typeof sliderVariants>;\ntype ClassName = TVClassName<typeof sliderVariants>;\n\nexport interface SliderProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** input field is disabled */\n disabled?: boolean;\n /** Content to display at the end of the slider */\n endContent?: ReactNode;\n /** The offset from where the fill should start */\n fillOffset?: number;\n /** form field label */\n label?: string;\n /** form field name */\n name: string;\n /**\n * Whether to show step dots on the slider\n * @default false\n */\n showSteps?: boolean;\n /**\n * The size of the slider\n * @default \"md\"\n */\n size?: 'sm' | 'md' | 'lg';\n /** Content to display at the start of the slider */\n startContent?: ReactNode;\n /**\n * The step value of the slider\n * @default 1\n */\n step?: number;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /**\n * The minimum value of the slider\n * @default 0\n */\n minValue?: number;\n /**\n * The maximum value of the slider\n * @default 100\n */\n maxValue?: number;\n}\n\n/**\n * Slider component based on [HeroUI Slider](https://www.heroui.com//docs/components/slider)\n */\nconst Slider = ({\n className = undefined,\n endContent = undefined,\n fillOffset = undefined,\n name,\n showSteps = false,\n size = 'md',\n startContent = undefined,\n step = 1,\n minValue = 0,\n maxValue = 100,\n ...uniformFieldProps\n}: SliderProps) => {\n const {\n ariaLabel,\n disabled,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n errorMessage,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual slider to forward focus\n const visualSliderRef = useRef<HTMLDivElement>(null);\n\n // classNames from slots\n const variants = sliderVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // Get the current value, defaulting to minValue if null/undefined\n const currentValue = field.value != null ? Number(field.value) : minValue;\n\n return (\n <div\n className={classNames.base}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n disabled={disabled}\n max={maxValue}\n min={minValue}\n name={name}\n onBlur={onBlur}\n step={step}\n tabIndex={-1}\n type=\"range\"\n value={currentValue}\n onChange={(e) => {\n onChange(Number(e.target.value));\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual slider to show focus ring\n visualSliderRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroUISlider component */}\n <HeroUISlider\n ref={visualSliderRef}\n aria-label={ariaLabel}\n color={invalid ? 'danger' : 'primary'}\n endContent={endContent}\n fillOffset={fillOffset}\n isDisabled={disabled}\n label={label}\n maxValue={maxValue}\n minValue={minValue}\n name={`${name}_slider`}\n // Mark field as touched when tabbing away (keyboard navigation)\n onBlur={onBlur}\n showSteps={showSteps}\n size={size}\n startContent={startContent}\n step={step}\n value={currentValue}\n classNames={{\n endContent: classNames.endContent,\n filler: classNames.filler,\n label: classNames.label,\n labelWrapper: classNames.labelWrapper,\n mark: classNames.mark,\n startContent: classNames.startContent,\n step: classNames.step,\n thumb: classNames.thumb,\n track: classNames.track,\n trackWrapper: classNames.trackWrapper,\n value: classNames.value,\n }}\n onChange={(value) => {\n onChange(value);\n }}\n // Mark field as touched when drag interaction ends (mouse/touch)\n onChangeEnd={(_value) => {\n onBlur();\n }}\n />\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n </div>\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { Slider };\n\nexport default Slider;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4KEI3VRK.js";
|
|
4
4
|
import {
|
|
5
5
|
__objRest,
|
|
6
6
|
__spreadProps,
|
|
@@ -137,6 +137,7 @@ var RadioBoxes = (_a) => {
|
|
|
137
137
|
"options"
|
|
138
138
|
]);
|
|
139
139
|
const {
|
|
140
|
+
ariaLabel,
|
|
140
141
|
defaultValue,
|
|
141
142
|
errorMessage,
|
|
142
143
|
invalid,
|
|
@@ -163,6 +164,7 @@ var RadioBoxes = (_a) => {
|
|
|
163
164
|
HeroRadioGroup,
|
|
164
165
|
{
|
|
165
166
|
ref,
|
|
167
|
+
"aria-label": ariaLabel,
|
|
166
168
|
classNames,
|
|
167
169
|
"data-invalid": invalid,
|
|
168
170
|
"data-required": required,
|
|
@@ -214,4 +216,4 @@ export {
|
|
|
214
216
|
RadioBoxes_default,
|
|
215
217
|
RadioBoxes_default2
|
|
216
218
|
};
|
|
217
|
-
//# sourceMappingURL=chunk-
|
|
219
|
+
//# sourceMappingURL=chunk-M5IL7INR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\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 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\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-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\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 onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;;AAKA,SAAS,cAAc,sBAAsB;AAE7C,SAAS,SAAS,MAAAA,KAAI,wBAAAC,6BAA4B;;;ACHlD,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAE/B,SAAS,IAAI,IAAI,4BAA4B;AAsErC,cAWF,YAXE;AAp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} from "./chunk-4KEI3VRK.js";
|
|
4
4
|
import {
|
|
5
5
|
useFormContext
|
|
6
6
|
} from "./chunk-ZZW7JZ2U.js";
|
|
@@ -99,6 +99,7 @@ var Select = (_a) => {
|
|
|
99
99
|
]);
|
|
100
100
|
var _a2;
|
|
101
101
|
const {
|
|
102
|
+
ariaLabel,
|
|
102
103
|
disabled,
|
|
103
104
|
errorMessage,
|
|
104
105
|
field: { onBlur, onChange, ref, value },
|
|
@@ -152,7 +153,7 @@ var Select = (_a) => {
|
|
|
152
153
|
unstyled: true,
|
|
153
154
|
"aria-errormessage": "",
|
|
154
155
|
"aria-invalid": invalid,
|
|
155
|
-
"aria-
|
|
156
|
+
"aria-label": ariaLabel,
|
|
156
157
|
"data-testid": testId,
|
|
157
158
|
filterOption,
|
|
158
159
|
formatOptionLabel: renderOptionLabel,
|
|
@@ -167,6 +168,7 @@ var Select = (_a) => {
|
|
|
167
168
|
onInputChange,
|
|
168
169
|
options,
|
|
169
170
|
placeholder,
|
|
171
|
+
"aria-labelledby": label ? (_a2 = getTriggerProps()["aria-labelledby"]) == null ? void 0 : _a2.split(" ")[1] : void 0,
|
|
170
172
|
classNames: {
|
|
171
173
|
control: () => {
|
|
172
174
|
return cn(classNames.control, {
|
|
@@ -287,4 +289,4 @@ export {
|
|
|
287
289
|
Select_default,
|
|
288
290
|
Select_default2
|
|
289
291
|
};
|
|
290
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
//# sourceMappingURL=chunk-MODH7W2M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'duration-150! rounded-lg border-2 border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\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 'pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased text-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: 'rounded-sm p-2 text-foreground-500',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface SelectOption {\n /** option label */\n label?: ReactNode;\n /** option value */\n value: string;\n}\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value, { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Get getFieldState to check isTouched in onChange callback\n const { getFieldState } = useFormContext();\n\n // Track if the select is focused\n const [isFocused, setIsFocused] = useState(false);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\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-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n aria-label={ariaLabel}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n name={name}\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n // set aria-labelledby to the label id so that the select is accessible\n aria-labelledby={\n label\n ? getTriggerProps()['aria-labelledby']?.split(' ')[1]\n : undefined\n }\n classNames={{\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n input: () => {\n return classNames.input;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n );\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) => {\n return cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n onBlur={(_e) => {\n setIsFocused(false);\n onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return _option.value;\n }),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n // Mark field as touched immediately when a selection is made if not already touched\n // This ensures validation errors show right away (isTouched becomes true)\n // For Select components, selecting an option is a complete user action\n // (unlike text inputs where typing is ongoing), so we mark as touched immediately\n const { isTouched: currentIsTouched } = getFieldState(name, testId);\n if (!currentIsTouched) {\n onBlur();\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n // set complete option as value by current field value\n value={options.find((option) => {\n return option.value === value;\n })}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;;;AAIA,SAAS,gBAAgB;AACzB,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,SAAS,IAAI,4BAA4B;AAmG7C,cAgGL,YAhGK;AA9FF,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,gBACE;AAAA,IACF,SACE;AAAA,IACF,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,mBACE;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,oBAAoB;AAAA,IACpB,OAAO;AAAA;AAAA;AAAA,IAGP,OACE;AAAA,IACF,kBAAkB;AAAA,IAClB,gBAAgB;A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C1B,CAAC;AAAA;AAAA,QACH;AAAA,QACC,UACC,oBAAC,wCAAQ,sBAAsB,IAA9B,EACC,8BAAC,wCAAQ,qBAAqB,IAA7B,EAAiC,yBAAa,IACjD,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;AAEA,IAAO,iBAAQ;;;AC9Wf,IAAOC,kBAAQ;","names":["_a","Select_default"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOED4DYBDcjs = require('./chunk-OED4DYBD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -46,6 +46,7 @@ var Switch = (_a) => {
|
|
|
46
46
|
]);
|
|
47
47
|
var _a2;
|
|
48
48
|
const {
|
|
49
|
+
ariaLabel,
|
|
49
50
|
defaultValue,
|
|
50
51
|
disabled,
|
|
51
52
|
errorMessage,
|
|
@@ -59,7 +60,7 @@ var Switch = (_a) => {
|
|
|
59
60
|
ref,
|
|
60
61
|
required,
|
|
61
62
|
testId
|
|
62
|
-
} =
|
|
63
|
+
} = _chunkOED4DYBDcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
63
64
|
name
|
|
64
65
|
}, uniformFieldProps));
|
|
65
66
|
const visualSwitchRef = _react.useRef.call(void 0, null);
|
|
@@ -88,6 +89,7 @@ var Switch = (_a) => {
|
|
|
88
89
|
_switch.Switch,
|
|
89
90
|
{
|
|
90
91
|
ref: visualSwitchRef,
|
|
92
|
+
"aria-label": ariaLabel,
|
|
91
93
|
classNames,
|
|
92
94
|
"data-invalid": invalid,
|
|
93
95
|
"data-required": required,
|
|
@@ -126,4 +128,4 @@ var Switch_default2 = Switch_default;
|
|
|
126
128
|
|
|
127
129
|
|
|
128
130
|
exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
131
|
+
//# sourceMappingURL=chunk-MSJP25N4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MSJP25N4.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":["_a","Switch_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAAuB;AAEvB,wCAAqC;AACrC,6DAA+B;AAE/B,oDAA6C;AAuFzC,+CAAA;AAnFG,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,UAAA,EAAY,EAAA;AAAA,IACZ,YAAA,EAAc,WAAA;AAAA;AAAA;AAAA,IAGd,KAAA,EACE,yNAAA;AAAA,IACF,YAAA,EAAc,sBAAA;AAAA,IACd,YAAA,EAAc,EAAA;AAAA,IACd,KAAA,EAAO,EAAA;AAAA,IACP,SAAA,EAAW,EAAA;AAAA,IACX,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AA+BD,IAAM,OAAA,EAAS,CAAC,EAAA,EAAA,GAQG;AARH,EAAA,IAAA,GAAA,EAAA,EAAA,EACd;AAAA,IAAA,UAAA,EAAY,KAAA,CAAA;AAAA,IACZ,WAAA,EAAa,KAAA,CAAA;AAAA,IACb,IAAA;AAAA,IACA,KAAA,EAAO,KAAA,CAAA;AAAA,IACP,aAAA,EAAe,KAAA,CAAA;AAAA,IACf,UAAA,EAAY,KAAA;AAAA,EAjEd,EAAA,EA2DgB,EAAA,EAOX,kBAAA,EAAA,yCAAA,EAPW,EAOX;AAAA,IANH,WAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAjEF,EAAA,IAAAA,GAAAA;AAoEE,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA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AAA,CACF,CAAA;AAAA,oBAEA,6BAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,GAAA,EAAK,eAAA;AAAA,QACL,YAAA,EAAY,SAAA;AAAA,QACZ,UAAA;AAAA,QACA,cAAA,EAAc,OAAA;AAAA,QACd,eAAA,EAAe,QAAA;AAAA,QACf,aAAA,EAAa,MAAA;AAAA,QACb,eAAA,EAAiB,CAAC,CAAC,YAAA;AAAA,QACnB,UAAA;AAAA,QACA,UAAA,EAAY,QAAA;AAAA,QACZ,UAAA,EAAY,CAAC,CAAC,KAAA,CAAM,KAAA;AAAA,QACpB,IAAA,EAAM,CAAA,EAAA;AACN,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AAEC,QAAA;AAAA,MAAA;AACH,IAAA;AAEE,IAAA;AAAC,MAAA;AAAA,MAAA;AAEC,QAAA;AACEA,UAAAA;AAAyB;AAEzB,UAAA;AACF,QAAA;AAEA,QAAA;AAA+C,MAAA;AAE/C,IAAA;AACN,EAAA;AAEJ;AAEO;AD9BQ;AACA;AErHRC;AFuHQ;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MSJP25N4.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\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-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = undefined,\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchProps) => {\n const {\n ariaLabel,\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n onBlur={onBlur}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroSwitch component */}\n <HeroSwitch\n ref={visualSwitchRef}\n aria-label={ariaLabel}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultSelected={!!defaultValue}\n endContent={endContent}\n isDisabled={disabled}\n isSelected={!!field.value}\n name={`${name}_switch`}\n onValueChange={onChange}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n >\n {label}\n </HeroSwitch>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOED4DYBDcjs = require('./chunk-OED4DYBD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkUUGUQGMXcjs = require('./chunk-UUGUQGMX.cjs');
|
|
@@ -24,7 +24,7 @@ var useUniformFieldArray = ({
|
|
|
24
24
|
testId: explicitTestId,
|
|
25
25
|
label
|
|
26
26
|
}) => {
|
|
27
|
-
const uniformField =
|
|
27
|
+
const uniformField = _chunkOED4DYBDcjs.useUniformField.call(void 0, {
|
|
28
28
|
name,
|
|
29
29
|
disabled,
|
|
30
30
|
testId: explicitTestId,
|
|
@@ -100,4 +100,4 @@ var useUniformFieldArray = ({
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
exports.useUniformFieldArray = useUniformFieldArray;
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-MVFEXRWQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MVFEXRWQ.cjs","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAqD;AACrD,gDAAkD;AAElD,sDAAiC;AAqC1B,IAAM,qBAAA,EAAuB,CAElC;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,KAAA;AAAA,EACP,mBAAA,EAAqB,qBAAA,EAAuB,IAAA;AAAA,EAC5C,wBAAA,EAA0B,KAAA;AAAA,EAC1B,QAAA;AAAA,EACA,MAAA,EAAQ,cAAA;AAAA,EACR;AACF,CAAA,EAAA,GAA+C;AAE7C,EAAA,MAAM,aAAA,EAAe,+CAAA;AAA8B,IACjD,IAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,cAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,QAAQ,EAAA,EAAI,YAAA;AAEpB,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,KAAK,EAAA,EAAI,0CAAA;AAAiB,IAChE,OAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,OAAA,EAAS,SAAS,EAAA,EAAI,8CAAA,CAA6B;AAQ3D,EAAA,MAAM,gBAAA,EAAkB,4BAAA,CAAQ,EAAA,GAAM;AACpC,IAAA,OAAO,wBAAA,GAA2B,MAAA,CAAO,OAAA,IAAW,CAAA;AAAA,EACtD,CAAA,EAAG,CAAC,uBAAA,EAAyB,MAAA,CAAO,MAAM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;AAGnB,QAAA,QAAA,CAAS,IAAA,EAA4B,CAAC,mBAAmB,CAAA,EAAU;AAAA,UACjE,WAAA,EAAa,KAAA;AAAA,UACb,WAAA,EAAa;AAAA,QACf,CAAC,CAAA;AAGD,QAAA,cAAA,CAAe,QAAA,EAAU,IAAA;AAKzB,QAAA,GAAA,CAAI,CAAC,qBAAA,GAAwB,gBAAA,EAAkB;AAC7C,UAAA,UAAA,CAAW,CAAA,EAAA,GAAM;AACf,YAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA,UAC3B,CAAA,EAAG,CAAC,CAAA;AAAA,QACN;AAAA,MACF;AAAA,IACF,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,CAAC,eAAe;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,8CAAA;AAAA;AAAA,IAEL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;ADvFA;AACA;AACE;AACF,oDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MVFEXRWQ.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useInputValueDebounce
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LEMQGDFE.js";
|
|
4
4
|
import {
|
|
5
5
|
useUniformField
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4KEI3VRK.js";
|
|
7
7
|
import {
|
|
8
8
|
__objRest,
|
|
9
9
|
__spreadProps,
|
|
@@ -52,6 +52,7 @@ var Input = (_a) => {
|
|
|
52
52
|
"type"
|
|
53
53
|
]);
|
|
54
54
|
const {
|
|
55
|
+
ariaLabel,
|
|
55
56
|
disabled,
|
|
56
57
|
field: {
|
|
57
58
|
onChange: fieldOnChange,
|
|
@@ -85,6 +86,8 @@ var Input = (_a) => {
|
|
|
85
86
|
const classNames = variantsToClassNames(variants, _className, "base");
|
|
86
87
|
const commonProps = __spreadValues({
|
|
87
88
|
ref,
|
|
89
|
+
// Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)
|
|
90
|
+
"aria-label": !placeholder || placeholder.trim() === "" ? ariaLabel : void 0,
|
|
88
91
|
classNames: {
|
|
89
92
|
base: classNames.base,
|
|
90
93
|
clearButton: classNames.clearButton,
|
|
@@ -111,7 +114,7 @@ var Input = (_a) => {
|
|
|
111
114
|
variant: "bordered"
|
|
112
115
|
}, clearableProps);
|
|
113
116
|
if (type === "number") {
|
|
114
|
-
const numberValue = value !== "" && value != null && !Number.isNaN(Number(value)) ? Number(value) :
|
|
117
|
+
const numberValue = value !== "" && value != null && !Number.isNaN(Number(value)) ? Number(value) : null;
|
|
115
118
|
return /* @__PURE__ */ jsx(
|
|
116
119
|
HeroNumberInput,
|
|
117
120
|
__spreadProps(__spreadValues({}, commonProps), {
|
|
@@ -142,4 +145,4 @@ export {
|
|
|
142
145
|
Input_default,
|
|
143
146
|
Input_default2
|
|
144
147
|
};
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-O5KAFUBE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\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 */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\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 transform?: InputValueTransform<string>;\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: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\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 value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\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":";;;;;;;;;;;;;AAKA,SAAS,SAAS,iBAAiB;AACnC,SAAS,eAAe,uBAAuB;AAE/C,SAAS,IAAI,4BAA4B;AA+JnC;AAzJC,IAAM,gBAAgB,GAAG;AAAA,EAC9B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA;AAAA,I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Aa,WAAW;AAAA;AAAA,MAExB,eAAe;AAAA,MACf,OAAO,WAAW;AAAA,MAClB,cAAc,WAAW;AAAA,IAC3B;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,SAAS;AAAA,KACN;AAIL,MAAI,SAAS,UAAU;AAErB,UAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,KAAK,CAAC,IACxD,OAAO,KAAK,IACZ;AAEN,WACE;AAAA,MAAC;AAAA,uCACK,cADL;AAAA,QAIC,OAAO;AAAA,QAEP,eAAe;AAAA,UACb,aAAa;AAAA,QACf;AAAA,QAEA,UAAU,CAAC,MAAoD;AAC7D,cAAI,OAAO,MAAM,UAAU;AAEzB,qBAAS;AAAA,cACP,QAAQ,EAAE,OAAO,OAAO,CAAC,EAAE;AAAA,YAC7B,CAAwC;AAAA,UAC1C,OAAO;AAEL,qBAAS,CAAC;AAAA,UACZ;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AAGA,SACE,oBAAC,4CAAc,cAAd,EAA2B,UAAoB,MAAY,QAAc;AAE9E;AAEA,IAAO,gBAAQ;;;AChMf,IAAOA,iBAAQ;","names":["Input_default"]}
|
|
@@ -9,15 +9,15 @@ var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
|
|
|
9
9
|
var _chunkNV4YVZYXcjs = require('./chunk-NV4YVZYX.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkUUGUQGMXcjs = require('./chunk-UUGUQGMX.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
12
|
var _chunkPCTYJUY7cjs = require('./chunk-PCTYJUY7.cjs');
|
|
16
13
|
|
|
17
14
|
|
|
18
15
|
var _chunk56TQOKG7cjs = require('./chunk-56TQOKG7.cjs');
|
|
19
16
|
|
|
20
17
|
|
|
18
|
+
var _chunkUUGUQGMXcjs = require('./chunk-UUGUQGMX.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
21
|
var _chunkTKICOKNScjs = require('./chunk-TKICOKNS.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
@@ -34,10 +34,11 @@ var useDebouncedInvalid = (invalid, delayMs) => {
|
|
|
34
34
|
}
|
|
35
35
|
return debouncedInvalid;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
var useUniformField = (params) => {
|
|
38
38
|
var _a;
|
|
39
39
|
const {
|
|
40
40
|
name,
|
|
41
|
+
ariaLabel: customAriaLabel,
|
|
41
42
|
disabled = false,
|
|
42
43
|
testId: explicitTestId,
|
|
43
44
|
label,
|
|
@@ -104,7 +105,9 @@ function useUniformField(params) {
|
|
|
104
105
|
label,
|
|
105
106
|
labelPlacement: "outside"
|
|
106
107
|
});
|
|
108
|
+
const ariaLabel = customAriaLabel != null ? customAriaLabel : typeof label === "string" ? label : name;
|
|
107
109
|
return {
|
|
110
|
+
ariaLabel,
|
|
108
111
|
control,
|
|
109
112
|
debugMode,
|
|
110
113
|
defaultValue,
|
|
@@ -128,9 +131,9 @@ function useUniformField(params) {
|
|
|
128
131
|
resetField,
|
|
129
132
|
testId
|
|
130
133
|
};
|
|
131
|
-
}
|
|
134
|
+
};
|
|
132
135
|
|
|
133
136
|
|
|
134
137
|
|
|
135
138
|
exports.useUniformField = useUniformField;
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-OED4DYBD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OED4DYBD.cjs","../src/hooks/useUniformField/useUniformField.tsx"],"names":["_a"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC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AAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF,CAAA;AD9JA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OED4DYBD.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isTestEnvironment } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Debounce invalid state changes to prevent UI flicker on rapid changes.\n *\n * Primary purpose: Reduce UI flicker when validation state changes rapidly\n * (e.g., during fast typing). Without debouncing, error messages would flash\n * in/out rapidly, creating a poor UX.\n *\n * Secondary benefit: When animations are enabled (default), gives time for\n * enter/exit animations to complete smoothly.\n *\n * Behavior:\n * - Debounces both true → false and false → true transitions by `delayMs`\n * - Disabled in test environments for immediate snapshots\n */\nconst useDebouncedInvalid = (invalid: boolean, delayMs: number) => {\n const debouncedInvalid = useDebounce(invalid, delayMs);\n\n // Disable debouncing in test environments for immediate snapshots\n if (isTestEnvironment()) {\n return invalid;\n }\n\n return debouncedInvalid;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOED4DYBDcjs = require('./chunk-OED4DYBD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -88,7 +88,7 @@ var SwitchBox = (_a) => {
|
|
|
88
88
|
ref,
|
|
89
89
|
required,
|
|
90
90
|
testId
|
|
91
|
-
} =
|
|
91
|
+
} = _chunkOED4DYBDcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
92
92
|
name
|
|
93
93
|
}, uniformFieldProps));
|
|
94
94
|
const visualSwitchRef = _react.useRef.call(void 0, null);
|
|
@@ -212,4 +212,4 @@ var SwitchBox_default2 = SwitchBox_default;
|
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
exports.switchBoxVariants = switchBoxVariants; exports.SwitchBox_default = SwitchBox_default; exports.SwitchBox_default2 = SwitchBox_default2;
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-OIKPQMQ2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OIKPQMQ2.cjs","../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"names":["_a","SwitchBox_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAAuB;AAEvB,wCAA0B;AAC1B,6DAA+B;AAE/B,oDAA6C;AAgJrC,+CAAA;AA5ID,IAAM,kBAAA,EAAoB,4BAAA;AAAG,EAClC,KAAA,EAAO;AAAA,IACL,GAAA,EAAK,6JAAA;AAAA,IACL,WAAA,EAAa,4BAAA;AAAA,IACb,IAAA,EAAM,EAAA;AAAA,IACN,KAAA,EACE,iKAAA;AAAA,IACF,OAAA,EAAS,EAAA;AAAA,IACT,KAAA,EAAO,EAAA;AAAA,IACP,SAAA,EAAW;AAAA,EACb,CAAA;AAAA,EACA,QAAA,EAAU;AAAA,IACR,UAAA,EAAY;AAAA,MACV,IAAA,EAAM;AAAA,QACJ,GAAA,EAAK;AAAA,MACP;AAAA,IACF,CAAA;AAAA,IACA,SAAA,EAAW;AAAA,MACT,IAAA,EAAM;AAAA,QACJ,GAAA,EAAK,gBAAA;AAAA,QACL,KAAA,EAAO;AAAA,MACT;AAAA,IACF,CAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI;AAAA,QACF,GAAA,EAAK,WAAA;AAAA,QACL,WAAA,EAAa,SAAA;AAAA,QACb,KAAA,EAAO;AAAA,MACT,CAAA;AAAA,MACA,EAAA,EAA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,gBAAA;AACC,gBAAA;AAC8B,cAAA;AAG9C,YAAA;AACF,UAAA;AACE,QAAA;AAAA,MAAA;AACN,IAAA;AACC,IAAA;AACE,MAAA;AAAA,MAAA;AAEC,QAAA;AACEA,UAAAA;AAAyB;AAEzB,UAAA;AACF,QAAA;AAEA,QAAA;AAA+C,MAAA;AAE/C,IAAA;AACN,EAAA;AAEJ;AAEO;ADrCI;AACA;AEvMJC;AFyMI;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OIKPQMQ2.cjs","sourcesContent":[null,"import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <div>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\nexport { SwitchBox };\n\nexport default SwitchBox;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"sourcesContent":["import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;;;AAKA,SAAS,MAAAA,KAAI,eAAe;;;ACL5B,SAAS,WAAW,gBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,OAAO,kBAAkB;AAElC,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AAKrB,OAAO;AAqDO,cAkBN,YAlBM;AA7Cd,IAAM,kBAAkB,CAAC,EAAE,YAAY,OAAU,MAA4B;AAC3E,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,SAAS,cAAc,aAAa,mBAAmB;AAAA,IACpE;AAAA,IACA;AAAA,IACA,YAAY,EAAE,OAAO;AAAA,IACrB;AAAA,EACF,IAAI,eAAe;AAEnB,QAAM,kBAAkB,cAAc;AACtC,QAAM,gBAAgB,cAAc,WAAW,cAAc;AAC7D,QAAM,mBAAmB,cAAc;AAIvC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkC,CAAC,CAAC;AAEhE,YAAU,MAAM;AAtClB;AAwCI,QAAI,CAAC,eAAe;AAClB,aAAO;AAAA,IACT;AAGA,eAAU,eAAU,MAAV,YAAe,CAAC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AA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA,YACF;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,0BAAQ;;;ADlEL,SACE,OAAAC,MADF,QAAAC,aAAA;AA/CV,IAAM,UAAU,QAAQ,IAAI,aAAa;AA0BzC,IAAM,OAAO,CAAC;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,oBAAoB;AACtB,MAAiB;AACf,SACE,gBAAAD;AAAA,IAAC;AAAA;AAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC,WAAC,EAAE,cAAc,QAAQ,MAAM;AAvDtC;AAwDQ,eACE,gBAAAC,MAAC,SAAI,WAAU,8CACb;AAAA,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACC,WAAWE,IAAG,QAAQ,SAAS;AAAA,cAC/B,sBAAoB;AAAA,cACpB,eAAa,SAAQ,+BAAU,SAAV,YAAkB,EAAE;AAAA,cACzC;AAAA,cACA,UAAU;AAAA,cAET;AAAA;AAAA,UACH;AAAA,UAEC,CAAC,WAAW,EAAC,+BAAO,YACnB,gBAAAF,KAAC,2BAAgB,WAAU,eAAc;AAAA,WAE7C;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,eAAQ;;;AExEf,IAAOG,gBAAQ;","names":["cn","_a","jsx","jsxs","cn","Form_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-PTCZOUQX.cjs","../src/SubmitButton/SubmitButton.tsx","../src/SubmitButton/index.ts"],"names":["SubmitButton_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACDA,oDAA4B;AAC5B,2CAAuB;AA0CnB,+CAAA;AAhBJ,IAAM,aAAA,EAAe,CAAC;AAAA,EACpB,UAAA,EAAY,aAAA;AAAA,EACZ,SAAA,EAAW,QAAA;AAAA,EACX,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,MAAA,EAAQ,SAAA;AAAA,EACR,KAAA,EAAO,KAAA,CAAA;AAAA,EACP,QAAA,EAAU,KAAA;AAAA,EACV,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS;AACX,CAAA,EAAA,GAAyB;AACvB,EAAA,MAAM;AAAA,IACJ,SAAA,EAAW,EAAE,aAAa,CAAA;AAAA,IAC1B;AAAA,EACF,EAAA,EAAI,8CAAA,CAAe;AAEnB,EAAA,uBACE,6BAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,SAAA,EAAW,4BAAA,SAAY,CAAA;AAAA,MACvB,KAAA;AAAA,MACA,QAAA,EAAU,YAAA;AAAA,MACV,IAAA;AAAA,MACA,OAAA,EAAS,QAAA,GAAW,YAAA;AAAA,MAIpB,OAAA,EAAS,aAAA;AAAA,MACT,IAAA;AAAA,MACA,MAAA,EAAQ,iCAAA,MAAQ,EAAQ,EAAE,WAAA,EAAa,KAAK,CAAC,CAAA;AAAA,MAC7C,IAAA,EAAK,QAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EACH,CAAA;AAEJ,CAAA;AAEA,IAAO,qBAAA,EAAQ,YAAA;AD1Bf;AACA;AEnCA,IAAOA,sBAAAA,EAAQ,oBAAA;AFqCf;AACA;AACE;AACA;AACF,2GAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-PTCZOUQX.cjs","sourcesContent":[null,"import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\nimport { useFormContext } from '../hooks/useFormContext';\n\nexport interface SubmitButtonProps {\n /** sets HTML aria-label attribute */\n ariaLabel?: string;\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** color of the submit button */\n color?: ButtonProps['color'];\n /** icon of the submit button */\n icon?: ButtonProps['icon'];\n /** If set loading animation is shown */\n loading?: boolean;\n /** size of the submit button */\n size?: ButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * From SubmitButton\n */\nconst SubmitButton = ({\n ariaLabel = 'Submit form',\n children = 'Submit',\n className = undefined,\n color = 'success',\n icon = undefined,\n loading = false,\n size = 'md',\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const {\n formState: { isSubmitting },\n triggerSubmit,\n } = useFormContext();\n\n return (\n <Button\n ariaLabel={ariaLabel}\n className={cn(className)}\n color={color}\n disabled={isSubmitting}\n icon={icon}\n loading={loading || isSubmitting}\n // @ts-expect-error we use form context triggerSubmit\n // here so that submit button also works in special\n // scenarios (e.g. when used in modal)\n onClick={triggerSubmit}\n size={size}\n testId={slugify(testId, { replaceDots: true })}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n","import SubmitButton from './SubmitButton';\n\nexport type { SubmitButtonProps } from './SubmitButton';\n\nexport { SubmitButton };\n\nexport default SubmitButton;\n"]}
|