@fuf-stack/uniform 1.8.10 → 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 +3 -8
- 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 +2 -7
- 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 +5 -8
- 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 +4 -7
- 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 +4 -8
- 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 +3 -7
- 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/{RadioBoxes-DpkI28l0.d.cts → RadioBox-DnqCiTR1.d.cts} +89 -37
- package/dist/{RadioBoxes-DpkI28l0.d.ts → RadioBox-DnqCiTR1.d.ts} +89 -37
- package/dist/RadioBoxes/index.cjs +5 -8
- 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 +6 -9
- package/dist/RadioTabs/index.cjs +3 -8
- 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 +2 -7
- package/dist/{RadioTabs-DTDcAZoH.d.cts → RadioTabs-DkR5fvl4.d.cts} +18 -1
- package/dist/{RadioTabs-DTDcAZoH.d.ts → RadioTabs-DkR5fvl4.d.ts} +18 -1
- package/dist/Radios/index.cjs +3 -8
- 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 +2 -7
- 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 +4 -8
- 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 +3 -7
- 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 +19 -0
- package/dist/Slider/index.cjs.map +1 -0
- package/dist/Slider/index.d.cts +10 -0
- package/dist/Slider/index.d.ts +10 -0
- package/dist/Slider/index.js +19 -0
- package/dist/Slider-CxHvafJA.d.cts +155 -0
- package/dist/Slider-CxHvafJA.d.ts +155 -0
- 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 +3 -8
- 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 +2 -7
- package/dist/{Switch-Hr6PnK98.d.cts → Switch-B4AuHAMX.d.cts} +6 -4
- package/dist/{Switch-Hr6PnK98.d.ts → Switch-B4AuHAMX.d.ts} +6 -4
- package/dist/SwitchBox/index.cjs +21 -0
- package/dist/SwitchBox/index.cjs.map +1 -0
- package/dist/SwitchBox/index.d.cts +11 -0
- package/dist/SwitchBox/index.d.ts +11 -0
- package/dist/SwitchBox/index.js +21 -0
- package/dist/SwitchBox/index.js.map +1 -0
- package/dist/SwitchBox-q1I7a0NX.d.cts +146 -0
- package/dist/SwitchBox-q1I7a0NX.d.ts +146 -0
- package/dist/TextArea/index.cjs +4 -8
- 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 +3 -7
- 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-EFZXZNJO.js → chunk-2EQEKXG2.js} +4 -2
- package/dist/chunk-2EQEKXG2.js.map +1 -0
- package/dist/chunk-36LBVB45.js +1 -0
- package/dist/chunk-36LBVB45.js.map +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-BIC7IWER.js → chunk-4KEI3VRK.js} +6 -3
- package/dist/chunk-4KEI3VRK.js.map +1 -0
- package/dist/{chunk-PFFTE4NW.cjs → chunk-4LLSZ6GN.cjs} +6 -4
- package/dist/chunk-4LLSZ6GN.cjs.map +1 -0
- package/dist/chunk-5UGCZ7OA.js +215 -0
- package/dist/chunk-5UGCZ7OA.js.map +1 -0
- package/dist/{chunk-MEIT57H2.cjs → chunk-6UORUDZV.cjs} +5 -3
- package/dist/chunk-6UORUDZV.cjs.map +1 -0
- package/dist/chunk-7TUWJWLN.js +131 -0
- 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-QE4J4AMH.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-37RM7TVP.cjs → chunk-CM2LLV5N.cjs} +5 -3
- package/dist/chunk-CM2LLV5N.cjs.map +1 -0
- package/dist/{chunk-OTFX4BWZ.js → chunk-FHYUMBE3.js} +80 -46
- 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-TN7OSO3T.js → chunk-GQF5HVA4.js} +5 -5
- package/dist/chunk-GQF5HVA4.js.map +1 -0
- package/dist/{chunk-6AQ5R4U4.cjs → chunk-HYOALQIV.cjs} +7 -7
- package/dist/chunk-HYOALQIV.cjs.map +1 -0
- package/dist/{chunk-NG2KM4CA.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-KOV7U4QA.cjs +165 -0
- package/dist/chunk-KOV7U4QA.cjs.map +1 -0
- package/dist/{chunk-ZJDU5EPE.js → chunk-LEMQGDFE.js} +1 -1
- package/dist/chunk-M5IL7INR.js +219 -0
- package/dist/chunk-M5IL7INR.js.map +1 -0
- package/dist/{chunk-R5AOS4DQ.js → chunk-MODH7W2M.js} +5 -3
- package/dist/chunk-MODH7W2M.js.map +1 -0
- package/dist/chunk-MSJP25N4.cjs +131 -0
- package/dist/chunk-MSJP25N4.cjs.map +1 -0
- package/dist/{chunk-OYDNTOOU.cjs → chunk-MVFEXRWQ.cjs} +3 -3
- package/dist/chunk-MVFEXRWQ.cjs.map +1 -0
- package/dist/{chunk-7WHL6K5T.js → chunk-O5KAFUBE.js} +7 -4
- package/dist/chunk-O5KAFUBE.js.map +1 -0
- package/dist/{chunk-ZNX2PT6C.cjs → chunk-OED4DYBD.cjs} +6 -3
- package/dist/chunk-OED4DYBD.cjs.map +1 -0
- package/dist/chunk-OIKPQMQ2.cjs +215 -0
- 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-2UHJBGKV.js → chunk-QPKHR6WH.js} +4 -2
- package/dist/chunk-QPKHR6WH.js.map +1 -0
- package/dist/{chunk-WWSJQUTT.cjs → chunk-V45YAJT4.cjs} +7 -5
- package/dist/chunk-V45YAJT4.cjs.map +1 -0
- package/dist/chunk-WRKONOOV.cjs +219 -0
- package/dist/chunk-WRKONOOV.cjs.map +1 -0
- package/dist/{chunk-DUYZ7WW3.cjs → chunk-XSS4REAS.cjs} +80 -46
- package/dist/chunk-XSS4REAS.cjs.map +1 -0
- package/dist/{chunk-GRQVGEYI.js → chunk-XSVEW3KN.js} +5 -3
- package/dist/chunk-XSVEW3KN.js.map +1 -0
- package/dist/chunk-YMXUVBQ3.js +165 -0
- 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 +2 -2
- package/dist/hooks/useUniformField/index.d.cts +9 -5
- package/dist/hooks/useUniformField/index.d.ts +9 -5
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +4 -3
- 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 +3 -2
- package/dist/index.cjs +41 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -14
- package/dist/index.d.ts +17 -14
- package/dist/index.js +45 -27
- package/package.json +19 -8
- package/dist/chunk-2UHJBGKV.js.map +0 -1
- package/dist/chunk-37RM7TVP.cjs.map +0 -1
- package/dist/chunk-44STFB2F.cjs +0 -170
- package/dist/chunk-44STFB2F.cjs.map +0 -1
- package/dist/chunk-5ZMXUK6O.js +0 -170
- package/dist/chunk-5ZMXUK6O.js.map +0 -1
- package/dist/chunk-6AQ5R4U4.cjs.map +0 -1
- package/dist/chunk-7WHL6K5T.js.map +0 -1
- package/dist/chunk-A3PYIWG2.js.map +0 -1
- package/dist/chunk-BIC7IWER.js.map +0 -1
- package/dist/chunk-DUYZ7WW3.cjs.map +0 -1
- package/dist/chunk-EFZXZNJO.js.map +0 -1
- package/dist/chunk-GRQVGEYI.js.map +0 -1
- package/dist/chunk-HBPVEZJN.js +0 -105
- package/dist/chunk-HBPVEZJN.js.map +0 -1
- package/dist/chunk-JQQ32JOD.cjs.map +0 -1
- package/dist/chunk-KWJMKX5J.cjs +0 -1
- package/dist/chunk-MEIT57H2.cjs.map +0 -1
- package/dist/chunk-NG2KM4CA.cjs.map +0 -1
- package/dist/chunk-OTFX4BWZ.js.map +0 -1
- package/dist/chunk-OYDNTOOU.cjs.map +0 -1
- package/dist/chunk-PEADXODY.cjs +0 -105
- package/dist/chunk-PEADXODY.cjs.map +0 -1
- package/dist/chunk-PFFTE4NW.cjs.map +0 -1
- package/dist/chunk-QE4J4AMH.js.map +0 -1
- package/dist/chunk-R5AOS4DQ.js.map +0 -1
- package/dist/chunk-TN7OSO3T.js.map +0 -1
- package/dist/chunk-V3GDAELU.js +0 -1
- package/dist/chunk-WWSJQUTT.cjs.map +0 -1
- package/dist/chunk-Y7YEI6T2.js.map +0 -1
- package/dist/chunk-ZNX2PT6C.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 → Slider/index.js.map} +0 -0
- /package/dist/{chunk-ZJDU5EPE.js.map → chunk-LEMQGDFE.js.map} +0 -0
|
@@ -61,6 +61,8 @@ declare const textAreaVariants: tailwind_variants.TVReturnType<{
|
|
|
61
61
|
type VariantProps = TVProps<typeof textAreaVariants>;
|
|
62
62
|
type ClassName = TVClassName<typeof textAreaVariants>;
|
|
63
63
|
interface TextAreaProps extends VariantProps {
|
|
64
|
+
/** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */
|
|
65
|
+
ariaLabel?: string;
|
|
64
66
|
/** Child components. The content of the textarea. */
|
|
65
67
|
children?: ReactNode;
|
|
66
68
|
/** CSS class name */
|
|
@@ -61,6 +61,8 @@ declare const textAreaVariants: tailwind_variants.TVReturnType<{
|
|
|
61
61
|
type VariantProps = TVProps<typeof textAreaVariants>;
|
|
62
62
|
type ClassName = TVClassName<typeof textAreaVariants>;
|
|
63
63
|
interface TextAreaProps extends VariantProps {
|
|
64
|
+
/** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */
|
|
65
|
+
ariaLabel?: string;
|
|
64
66
|
/** Child components. The content of the textarea. */
|
|
65
67
|
children?: ReactNode;
|
|
66
68
|
/** CSS class name */
|
|
@@ -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
|
__spreadValues
|
|
@@ -41,6 +41,7 @@ var Radios = (_a) => {
|
|
|
41
41
|
"options"
|
|
42
42
|
]);
|
|
43
43
|
const {
|
|
44
|
+
ariaLabel,
|
|
44
45
|
disabled,
|
|
45
46
|
errorMessage,
|
|
46
47
|
field: { onBlur, onChange, ref },
|
|
@@ -66,6 +67,7 @@ var Radios = (_a) => {
|
|
|
66
67
|
HeroRadioGroup,
|
|
67
68
|
{
|
|
68
69
|
ref,
|
|
70
|
+
"aria-label": ariaLabel,
|
|
69
71
|
classNames,
|
|
70
72
|
"data-invalid": invalid,
|
|
71
73
|
"data-required": required,
|
|
@@ -113,4 +115,4 @@ export {
|
|
|
113
115
|
Radios_default,
|
|
114
116
|
Radios_default2
|
|
115
117
|
};
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-2EQEKXG2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Radios/Radios.tsx","../src/Radios/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\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 radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\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 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 <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"],"mappings":";;;;;;;;;AAGA;AAAA,EACE,SAAS;AAAA,EACT,cAAc;AAAA,OACT;AAEP,SAAS,SAAS,IAAI,4BAA4B;AA8G7B;AA1Gd,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,aACE;AAAA;AAAA,IAEF,OACE;AAAA,IACF,SAAS;AAAA,EACX;AACF,CAAC;AAwCD,IAAM,SAAS,CAAC,OAMiB;AANjB,eACd;AAAA,gBAAY;AAAA,IAC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OAAO;AAAA,cAEb,WAAAC,MAAA,OAAO,UAAP,OAAAA,MAAgB,OAAO;AAAA;AAAA,YAPnB,OAAO;AAAA,UAQd;AAAA,QAEJ;AACA,eAAO;AAAA,MACT,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;;;AC9If,IAAOC,kBAAQ;","names":["_a","_b","Radios_default"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-36LBVB45.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-3JAVQAL5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3JAVQAL5.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3JAVQAL5.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3ZQXSGR2.cjs","../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"names":["_a"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAAyD;AA0DlD,IAAM,sBAAA,EAAwB,CAAmB;AAAA,EACtD,cAAA,EAAgB,GAAA;AAAA,EAChB,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAA,GAAiF;AAE/E,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,EAAA,EAAI,6BAAA,KAAsB,CAAA;AAE9D,EAAA,MAAM,WAAA,EAAa,2BAAA,IAAkC,CAAA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KAAA,CAAM,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,QAC5C,EAAA,KAAO;AACL,UAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,QACnB;AAAA,MACF,CAAA;AAGA,MAAA,GAAA,CAAI,cAAA,GAAiB,CAAA,EAAG;AACtB,QAAA,eAAA,CAAgB,CAAA;AAAA,MAClB,EAAA,KAAO;AACL,QAAA,UAAA,CAAW,QAAA,EAAU,UAAA,CAAW,eAAA,EAAiB,aAAa,CAAA;AAAA,MAChE;AAAA,IACF,CAAA;AAAA,IACA,CAAC,QAAA,EAAU,aAAa;AAAA,EAC1B,CAAA;AAGA,EAAA,MAAM,WAAA,EAAa,gCAAA,CAAY,EAAA,GAAM;AAEnC,IAAA,GAAA,CAAI,UAAA,CAAW,OAAA,EAAS;AACtB,MAAA,YAAA,CAAa,UAAA,CAAW,OAAO,CAAA;AAC/B,MAAA,UAAA,CAAW,QAAA,EAAU,IAAA;AACrB,MAAA,QAAA,CAAS,YAAY,CAAA;AAAA,IACvB;AACA,IAAA,MAAA,CAAO,CAAA;AAAA,EACT,CAAA,EAAG,CAAC,QAAA,EAAU,MAAA,EAAQ,YAAY,CAAC,CAAA;AAEnC,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,UAAA;AAAA,IACR,KAAA,EAAO;AAAA,EACT,CAAA;AACF,CAAA;ADnEA;AACA;AACE;AACF,sDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3ZQXSGR2.cjs","sourcesContent":[null,"import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n"]}
|
|
@@ -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
|
export {
|
|
134
137
|
useUniformField
|
|
135
138
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-4KEI3VRK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,mBAAmB;AAiOtB,mBAGI,KAHJ;AAzMN,IAAM,sBAAsB,CAAC,SAAkB,YAAoB;AACjE,QAAM,mBAAmB,YAAY,SAAS,OAAO;AAGrD,MAAI,kBAAkB,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AA+FO,IAAM,kBAAkB,CAI7B,WACwC;AA3I1C;AA4IE,QAAM;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW,EAAE,YA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ACA,gBAAgB;AAAA,EAClB,CAAC;AAKH,QAAM,YACJ,4CAAoB,OAAO,UAAU,WAAW,QAAQ;AAE1D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,OAAO,iCACF,QADE;AAAA,MAEL,OAAO;AAAA,MACP,UAAU;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["_a"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOED4DYBDcjs = require('./chunk-OED4DYBD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkUUGUQGMXcjs = require('./chunk-UUGUQGMX.cjs');
|
|
@@ -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 },
|
|
@@ -109,7 +110,7 @@ var Select = (_a) => {
|
|
|
109
110
|
label,
|
|
110
111
|
required,
|
|
111
112
|
testId
|
|
112
|
-
} =
|
|
113
|
+
} = _chunkOED4DYBDcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
113
114
|
name
|
|
114
115
|
}, uniformFieldProps));
|
|
115
116
|
const { getFieldState } = _chunkUUGUQGMXcjs.useFormContext.call(void 0, );
|
|
@@ -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 _pixelutils.cn.call(void 0, classNames.control, {
|
|
@@ -287,4 +289,4 @@ var Select_default2 = Select_default;
|
|
|
287
289
|
|
|
288
290
|
|
|
289
291
|
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
290
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
//# sourceMappingURL=chunk-4LLSZ6GN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-4LLSZ6GN.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["_a","Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACRA,8BAAyB;AACzB,qGAAwC;AAExC,wCAA0B;AAE1B,oDAAsD;AAmG7C,+CAAA;AA9FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,qOAAA;AAAA,IACF,eAAA,EAAiB,cAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EAAa,EAAA;AAAA,IACb,iBAAA,EACE,+FAA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AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACE,kBAAA;AACA,kBAAA;AACF,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACA,gBAAA;AACF,cAAA;AACE,gBAAA;AACE,kBAAA;AACA,kBAAA;AACD,gBAAA;AACH,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACM,cAAA;AACF,gBAAA;AACG,kBAAA;AACC,oBAAA;AACF,kBAAA;AACF,gBAAA;AACF,cAAA;AACE,gBAAA;AACF,cAAA;AAKA,cAAA;AACI,cAAA;AACF,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACF,YAAA;AAEA,YAAA;AACE,cAAA;AACD,YAAA;AAAA,UAAA;AACH,QAAA;AAEE,QAAA;AAGE,MAAA;AAAA,IAAA;AACN,EAAA;AAEJ;AAEO;ADzFW;AACA;AEtRXC;AFwRW;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-4LLSZ6GN.cjs","sourcesContent":[null,"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"]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-4KEI3VRK.js";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./chunk-K2V4ULA2.js";
|
|
9
|
+
|
|
10
|
+
// src/SwitchBox/SwitchBox.tsx
|
|
11
|
+
import { useRef } from "react";
|
|
12
|
+
import { useSwitch } from "@heroui/switch";
|
|
13
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
14
|
+
import { cn, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var switchBoxVariants = tv({
|
|
17
|
+
slots: {
|
|
18
|
+
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",
|
|
19
|
+
description: "text-foreground opacity-70",
|
|
20
|
+
icon: "",
|
|
21
|
+
label: '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-["*"]',
|
|
22
|
+
wrapper: "",
|
|
23
|
+
thumb: "",
|
|
24
|
+
thumbIcon: ""
|
|
25
|
+
},
|
|
26
|
+
variants: {
|
|
27
|
+
isDisabled: {
|
|
28
|
+
true: {
|
|
29
|
+
box: "pointer-events-none opacity-disabled"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
isInvalid: {
|
|
33
|
+
true: {
|
|
34
|
+
box: "!border-danger",
|
|
35
|
+
label: "!text-danger"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
size: {
|
|
39
|
+
sm: {
|
|
40
|
+
box: "gap-2 p-3",
|
|
41
|
+
description: "text-xs",
|
|
42
|
+
label: "text-xs"
|
|
43
|
+
},
|
|
44
|
+
md: {
|
|
45
|
+
box: "gap-4 p-4",
|
|
46
|
+
description: "text-small",
|
|
47
|
+
label: "text-sm"
|
|
48
|
+
},
|
|
49
|
+
lg: {
|
|
50
|
+
box: "gap-4 p-5",
|
|
51
|
+
description: "text-small",
|
|
52
|
+
label: "text-base"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
size: "md"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var SwitchBox = (_a) => {
|
|
61
|
+
var _b = _a, {
|
|
62
|
+
className = void 0,
|
|
63
|
+
description = void 0,
|
|
64
|
+
icon = void 0,
|
|
65
|
+
name,
|
|
66
|
+
size = void 0,
|
|
67
|
+
thumbIcon = void 0
|
|
68
|
+
} = _b, uniformFieldProps = __objRest(_b, [
|
|
69
|
+
"className",
|
|
70
|
+
"description",
|
|
71
|
+
"icon",
|
|
72
|
+
"name",
|
|
73
|
+
"size",
|
|
74
|
+
"thumbIcon"
|
|
75
|
+
]);
|
|
76
|
+
var _a2;
|
|
77
|
+
const {
|
|
78
|
+
defaultValue,
|
|
79
|
+
disabled,
|
|
80
|
+
errorMessage,
|
|
81
|
+
field,
|
|
82
|
+
getErrorMessageProps,
|
|
83
|
+
getHelperWrapperProps,
|
|
84
|
+
invalid,
|
|
85
|
+
label,
|
|
86
|
+
onBlur,
|
|
87
|
+
onChange,
|
|
88
|
+
ref,
|
|
89
|
+
required,
|
|
90
|
+
testId
|
|
91
|
+
} = useUniformField(__spreadValues({
|
|
92
|
+
name
|
|
93
|
+
}, uniformFieldProps));
|
|
94
|
+
const visualSwitchRef = useRef(null);
|
|
95
|
+
const {
|
|
96
|
+
Component,
|
|
97
|
+
slots,
|
|
98
|
+
isSelected,
|
|
99
|
+
getBaseProps,
|
|
100
|
+
getInputProps,
|
|
101
|
+
getWrapperProps
|
|
102
|
+
} = useSwitch({
|
|
103
|
+
defaultSelected: !!defaultValue,
|
|
104
|
+
isDisabled: disabled,
|
|
105
|
+
isSelected: !!field.value,
|
|
106
|
+
name: `${name}_switch`,
|
|
107
|
+
onValueChange: onChange,
|
|
108
|
+
size,
|
|
109
|
+
thumbIcon
|
|
110
|
+
});
|
|
111
|
+
const variants = switchBoxVariants({
|
|
112
|
+
isDisabled: disabled,
|
|
113
|
+
isInvalid: invalid,
|
|
114
|
+
size
|
|
115
|
+
});
|
|
116
|
+
const classNames = variantsToClassNames(variants, className, "box");
|
|
117
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
118
|
+
/* @__PURE__ */ jsxs(
|
|
119
|
+
Component,
|
|
120
|
+
__spreadProps(__spreadValues({}, getBaseProps()), {
|
|
121
|
+
className: classNames.box,
|
|
122
|
+
"data-invalid": invalid,
|
|
123
|
+
"data-required": required,
|
|
124
|
+
"data-testid": testId,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsxs(VisuallyHidden, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
"input",
|
|
129
|
+
{
|
|
130
|
+
ref,
|
|
131
|
+
"aria-label": typeof label === "string" ? label : name,
|
|
132
|
+
checked: !!field.value,
|
|
133
|
+
name,
|
|
134
|
+
tabIndex: -1,
|
|
135
|
+
type: "checkbox",
|
|
136
|
+
onChange: (e) => {
|
|
137
|
+
onChange(e.target.checked);
|
|
138
|
+
},
|
|
139
|
+
onFocus: () => {
|
|
140
|
+
var _a3;
|
|
141
|
+
(_a3 = visualSwitchRef.current) == null ? void 0 : _a3.focus();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
"input",
|
|
147
|
+
__spreadProps(__spreadValues({
|
|
148
|
+
ref: visualSwitchRef
|
|
149
|
+
}, getInputProps()), {
|
|
150
|
+
onBlur: (e) => {
|
|
151
|
+
var _a3, _b2;
|
|
152
|
+
(_b2 = (_a3 = getInputProps()).onBlur) == null ? void 0 : _b2.call(_a3, e);
|
|
153
|
+
onBlur();
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
)
|
|
157
|
+
] }),
|
|
158
|
+
!icon ? /* @__PURE__ */ jsx(
|
|
159
|
+
"span",
|
|
160
|
+
__spreadProps(__spreadValues({}, getWrapperProps()), {
|
|
161
|
+
className: cn(getWrapperProps().className, classNames.wrapper),
|
|
162
|
+
children: /* @__PURE__ */ jsx("span", { className: cn(slots.thumb({ class: classNames.thumb })), children: thumbIcon && typeof thumbIcon === "function" ? thumbIcon({
|
|
163
|
+
isSelected: !!isSelected,
|
|
164
|
+
className: slots.thumbIcon({ class: classNames.thumbIcon }),
|
|
165
|
+
width: "1em",
|
|
166
|
+
height: "1em",
|
|
167
|
+
"data-checked": isSelected ? "true" : "false"
|
|
168
|
+
}) : thumbIcon })
|
|
169
|
+
})
|
|
170
|
+
) : null,
|
|
171
|
+
icon ? /* @__PURE__ */ jsx("div", { className: classNames.icon, children: icon }) : null,
|
|
172
|
+
/* @__PURE__ */ jsxs("div", { className: "grow", children: [
|
|
173
|
+
label ? /* @__PURE__ */ jsx("div", { className: classNames.label, children: label }) : null,
|
|
174
|
+
description ? /* @__PURE__ */ jsx("div", { className: classNames.description, children: description }) : null
|
|
175
|
+
] }),
|
|
176
|
+
icon ? /* @__PURE__ */ jsx(
|
|
177
|
+
"span",
|
|
178
|
+
__spreadProps(__spreadValues({}, getWrapperProps()), {
|
|
179
|
+
className: cn(getWrapperProps().className, classNames.wrapper),
|
|
180
|
+
children: /* @__PURE__ */ jsx("span", { className: cn(slots.thumb({ class: classNames.thumb })), children: thumbIcon && typeof thumbIcon === "function" ? thumbIcon({
|
|
181
|
+
isSelected: !!isSelected,
|
|
182
|
+
className: slots.thumbIcon({ class: classNames.thumbIcon }),
|
|
183
|
+
width: "1em",
|
|
184
|
+
height: "1em",
|
|
185
|
+
"data-checked": isSelected ? "true" : "false"
|
|
186
|
+
}) : thumbIcon })
|
|
187
|
+
})
|
|
188
|
+
) : null
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
),
|
|
192
|
+
invalid ? /* @__PURE__ */ jsx(
|
|
193
|
+
"div",
|
|
194
|
+
__spreadProps(__spreadValues({}, getHelperWrapperProps()), {
|
|
195
|
+
className: cn(
|
|
196
|
+
(_a2 = getHelperWrapperProps()) == null ? void 0 : _a2.className,
|
|
197
|
+
// force helper to be visible (for some reason it's hidden by default) and remove margin
|
|
198
|
+
"ml-0 block"
|
|
199
|
+
),
|
|
200
|
+
children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: errorMessage }))
|
|
201
|
+
})
|
|
202
|
+
) : null
|
|
203
|
+
] });
|
|
204
|
+
};
|
|
205
|
+
var SwitchBox_default = SwitchBox;
|
|
206
|
+
|
|
207
|
+
// src/SwitchBox/index.ts
|
|
208
|
+
var SwitchBox_default2 = SwitchBox_default;
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
switchBoxVariants,
|
|
212
|
+
SwitchBox_default,
|
|
213
|
+
SwitchBox_default2
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=chunk-5UGCZ7OA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;AAIA,SAAS,cAAc;AAEvB,SAAS,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AA,QAEC,WAAW;AAAA,WACTA,MAAA,sBAAsB,MAAtB,gBAAAA,IAAyB;AAAA;AAAA,UAEzB;AAAA,QACF;AAAA,QAEA,8BAAC,wCAAQ,qBAAqB,IAA7B,EAAiC,yBAAa;AAAA;AAAA,IACjD,IACE;AAAA,KACN;AAEJ;AAEA,IAAO,oBAAQ;;;AC3Of,IAAOE,qBAAQ;","names":["_a","_b","SwitchBox_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
|
|
|
@@ -41,6 +41,7 @@ var Radios = (_a) => {
|
|
|
41
41
|
"options"
|
|
42
42
|
]);
|
|
43
43
|
const {
|
|
44
|
+
ariaLabel,
|
|
44
45
|
disabled,
|
|
45
46
|
errorMessage,
|
|
46
47
|
field: { onBlur, onChange, ref },
|
|
@@ -49,7 +50,7 @@ var Radios = (_a) => {
|
|
|
49
50
|
required,
|
|
50
51
|
defaultValue,
|
|
51
52
|
testId
|
|
52
|
-
} =
|
|
53
|
+
} = _chunkOED4DYBDcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
53
54
|
name
|
|
54
55
|
}, uniformFieldProps));
|
|
55
56
|
const variants = radiosVariants();
|
|
@@ -66,6 +67,7 @@ var Radios = (_a) => {
|
|
|
66
67
|
_radio.RadioGroup,
|
|
67
68
|
{
|
|
68
69
|
ref,
|
|
70
|
+
"aria-label": ariaLabel,
|
|
69
71
|
classNames,
|
|
70
72
|
"data-invalid": invalid,
|
|
71
73
|
"data-required": required,
|
|
@@ -113,4 +115,4 @@ var Radios_default2 = Radios_default;
|
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
exports.Radios_default = Radios_default; exports.Radios_default2 = Radios_default2;
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-6UORUDZV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-6UORUDZV.cjs","../src/Radios/Radios.tsx","../src/Radios/index.ts"],"names":["_a","_b","Radios_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA;AACE;AACA;AAAc,sCACT;AAEP,oDAAkD;AA8G7B,+CAAA;AA1Gd,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,aAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA,IACV,WAAA,EAAa,8CAAA;AAAA,IACb,eAAA,EAAiB,EAAA;AAAA,IACjB,SAAA,EAAW,SAAA;AAAA,IACX,gBAAA,EAAkB,EAAA;AAAA,IAClB,WAAA,EACE,+HAAA;AAAA;AAAA,IAEF,KAAA,EACE,qGAAA;AAAA,IACF,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AAwCD,IAAM,OAAA,EAAS,CAAC,EAAA,EAAA,GAMiB;AANjB,EAAA,IAAA,GAAA,EAAA,EAAA,EACd;AAAA,IAAA,UAAA,EAAY,KAAA,CAAA;AAAA,IACZ,OAAA,EAAS,KAAA;AAAA,IACT,IAAA;AAAA,IACA;AAAA,EAxEF,EAAA,EAoEgB,EAAA,EAKX,kBAAA,EAAA,yCAAA,EALW,EAKX;AAAA,IAJH,WAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,QAAA;AAAA,IACA,YAAA;AAAA,IACA,KAAA,EAAO,EAAE,MAAA,EAAQ,QAAA,EAAU,IAAI,CAAA;AAAA,IAC/B,OAAA;AAAA,IACA,KAAA;AAAA,IACA,Q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A,EAAQ;AACrB,UAAA,MAAM,aAAA,EAAe,iCAAA;AAAA,YACnB,CAAA,EAAA;AACA,YAAA;AACF,UAAA;AACA,UAAA;AACG,YAAA;AAAA,YAAA;AAAA,cAAA;AAEa,cAAA;AACC,cAAA;AACoB,cAAA;AACjC,cAAA;AACc,cAAA;AAEU,YAAA;AAPnB,YAAA;AAQP,UAAA;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADvCM;AACA;AExGNC;AF0GM;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-6UORUDZV.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\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 radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\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 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 <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"]}
|