@fuf-stack/uniform 2.0.0-next.1 → 2.0.0-next.4
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.d.mts +47 -27
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +26 -25
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +63 -86
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +43 -49
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +8 -16
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +25 -37
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +0 -4
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +14 -25
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +3 -5
- package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs.map → FieldCopyTestIdButton-D3_jZYJ1.mjs.map} +1 -1
- package/dist/FieldHelper-B1DWl7eu.mjs +38 -0
- package/dist/FieldHelper-B1DWl7eu.mjs.map +1 -0
- package/dist/FieldLabel-DMTqq0Jj.mjs +29 -0
- package/dist/FieldLabel-DMTqq0Jj.mjs.map +1 -0
- package/dist/{FieldLayout-BLW5S-Jm.mjs → FieldLayout-C9MEBZAC.mjs} +11 -19
- package/dist/FieldLayout-C9MEBZAC.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +420 -0
- package/dist/FieldReset/index.d.mts.map +1 -0
- package/dist/FieldReset/index.mjs +258 -0
- package/dist/FieldReset/index.mjs.map +1 -0
- package/dist/{FieldValidationError-DgkCL3cC.mjs → FieldValidationError-BuLvuRyi.mjs} +5 -7
- package/dist/FieldValidationError-BuLvuRyi.mjs.map +1 -0
- package/dist/Form/index.d.mts +12 -14
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +7 -10
- package/dist/Form/index.mjs.map +1 -1
- package/dist/FormContext-BnNJYZOo.d.mts +124 -0
- package/dist/FormContext-BnNJYZOo.d.mts.map +1 -0
- package/dist/{FormContext-CHctWFAP.mjs → FormContext-PXkVlBdU.mjs} +5 -9
- package/dist/{FormContext-CHctWFAP.mjs.map → FormContext-PXkVlBdU.mjs.map} +1 -1
- package/dist/Grid/index.d.mts +0 -2
- package/dist/Grid/index.d.mts.map +1 -1
- package/dist/Grid/index.mjs +1 -1
- package/dist/{Grid-DfcZeuib.mjs → Grid-DBL29Kwb.mjs} +3 -5
- package/dist/{Grid-DfcZeuib.mjs.map → Grid-DBL29Kwb.mjs.map} +1 -1
- package/dist/Input/index.d.mts +610 -393
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +24 -31
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +247 -2227
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +25 -37
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +599 -289
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +24 -27
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +164 -2077
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +12 -23
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +809 -484
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +69 -54
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +657 -281
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +42 -42
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts +0 -2
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +2 -4
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +1 -1
- package/dist/Switch/index.mjs +25 -32
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-aBYStBoY.d.mts +990 -0
- package/dist/Switch-aBYStBoY.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +606 -201
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +29 -33
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +565 -185
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +18 -23
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +60 -44
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +27 -36
- package/dist/Time/index.mjs.map +1 -1
- package/dist/fieldHelperVariants-ClP8taiS.mjs +20 -0
- package/dist/fieldHelperVariants-ClP8taiS.mjs.map +1 -0
- package/dist/fieldLabelVariants-C4ZqECec.mjs +13 -0
- package/dist/fieldLabelVariants-C4ZqECec.mjs.map +1 -0
- package/dist/{FieldDescription-C4l0HKGL.mjs → fieldProps-DWfz2jSO.mjs} +5 -17
- package/dist/fieldProps-DWfz2jSO.mjs.map +1 -0
- package/dist/helpers/index.d.mts +0 -6
- package/dist/helpers/index.d.mts.map +1 -1
- package/dist/helpers/index.mjs +3 -6
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.d.mts +0 -2
- package/dist/hooks/useClientValidation/index.d.mts.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +3 -5
- package/dist/hooks/useController/index.d.mts +0 -2
- package/dist/hooks/useController/index.d.mts.map +1 -1
- package/dist/hooks/useController/index.mjs +2 -3
- package/dist/hooks/useFormContext/index.d.mts +31 -52
- package/dist/hooks/useFormContext/index.d.mts.map +1 -1
- package/dist/hooks/useFormContext/index.mjs +2 -3
- package/dist/hooks/useInputValueDebounce/index.d.mts +0 -2
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +3 -5
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -1
- package/dist/hooks/useInputValueTransform/index.mjs +2 -3
- package/dist/hooks/useWatchFormReset/index.d.mts +0 -2
- package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +3 -5
- package/dist/hooks/useWatchUserChange/index.d.mts +0 -2
- package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +3 -5
- package/dist/{index-BS8IoBOn.d.mts → index-cevZBrIN.d.mts} +1 -3
- package/dist/index-cevZBrIN.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.d.mts +0 -2
- package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
- package/dist/{Switch-CvPO8IF9.d.mts → partials/FieldHelper/index.d.mts} +309 -361
- package/dist/partials/FieldHelper/index.d.mts.map +1 -0
- package/dist/partials/FieldHelper/index.mjs +7 -0
- package/dist/partials/FieldHelper/index.mjs.map +1 -0
- package/dist/partials/FieldLabel/index.d.mts +160 -0
- package/dist/partials/FieldLabel/index.d.mts.map +1 -0
- package/dist/partials/FieldLabel/index.mjs +7 -0
- package/dist/partials/FieldLabel/index.mjs.map +1 -0
- package/dist/partials/FieldValidationError/index.d.mts +13 -15
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/{radioControlVariants-Cm6WufWo.mjs → radioControlVariants-CbtG5U4_.mjs} +28 -25
- package/dist/radioControlVariants-CbtG5U4_.mjs.map +1 -0
- package/dist/{switchVariants-BaQw2DA7.mjs → switchVariants-0Xa7TQYg.mjs} +8 -11
- package/dist/switchVariants-0Xa7TQYg.mjs.map +1 -0
- package/dist/{timeVariants-B9HDfNYt.mjs → timeVariants-Bkt4iwXx.mjs} +14 -12
- package/dist/timeVariants-Bkt4iwXx.mjs.map +1 -0
- package/dist/{useController-BCFeZbBZ.mjs → useController-JtIeurpw.mjs} +3 -4
- package/dist/{useController-BCFeZbBZ.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
- package/dist/{useFormContext-BPjJjNnM.mjs → useFormContext-piqnN2L-.mjs} +3 -4
- package/dist/useFormContext-piqnN2L-.mjs.map +1 -0
- package/dist/{useInputValueTransform-Mw8YEOXT.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -3
- package/dist/{useInputValueTransform-Mw8YEOXT.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
- package/dist/{FieldLabel-DKzqkuY1.mjs → useUniformField-TTNPTsVn.mjs} +15 -37
- package/dist/useUniformField-TTNPTsVn.mjs.map +1 -0
- package/package.json +10 -7
- package/dist/FieldDescription-C4l0HKGL.mjs.map +0 -1
- package/dist/FieldLabel-DKzqkuY1.mjs.map +0 -1
- package/dist/FieldLayout-BLW5S-Jm.mjs.map +0 -1
- package/dist/FieldValidationError-DgkCL3cC.mjs.map +0 -1
- package/dist/FormContext-CsFiNvuJ.d.mts +0 -19
- package/dist/FormContext-CsFiNvuJ.d.mts.map +0 -1
- package/dist/Switch-CvPO8IF9.d.mts.map +0 -1
- package/dist/index-BS8IoBOn.d.mts.map +0 -1
- package/dist/radioControlVariants-Cm6WufWo.mjs.map +0 -1
- package/dist/switchVariants-BaQw2DA7.mjs.map +0 -1
- package/dist/timeVariants-B9HDfNYt.mjs.map +0 -1
- package/dist/useFormContext-BPjJjNnM.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Slider/sliderVariants.ts","../../src/Slider/Slider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Slider/sliderVariants.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsGf,YAAY,mBAAmB;UCpG1B;;EAEf;;EAEA,YAAY;;EAEZ,cAAc;;EAEd;;EAEA,aAAa;;EAEb;;EAEA;;;;;EAKA;;;;;EAKA;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA,eAAe;;;;;EAKf;;EAEA;;EAEA,YAAY;;;cAIR,WAAU,WAAA,YAAA,YAAA,UAAA,UAAA,MAAA,WAAA,MAAA,cAAA,SAAA,qBAYb,gCAAW,IAAA"}
|
package/dist/Slider/index.mjs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
+
import { t as useUniformField } from "../useUniformField-TTNPTsVn.mjs";
|
|
1
2
|
import { isValueEmpty } from "../helpers/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { t as getFieldControlProps } from "../fieldProps-DWfz2jSO.mjs";
|
|
4
|
+
import { t as FieldHelper } from "../FieldHelper-B1DWl7eu.mjs";
|
|
5
|
+
import { t as FieldLabel } from "../FieldLabel-DMTqq0Jj.mjs";
|
|
6
|
+
import { t as fieldHelperVariants } from "../fieldHelperVariants-ClP8taiS.mjs";
|
|
7
|
+
import { t as fieldLabelVariants } from "../fieldLabelVariants-C4ZqECec.mjs";
|
|
8
|
+
import { useEffect, useMemo } from "react";
|
|
5
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
10
|
import { tv } from "@fuf-stack/pixel-utils";
|
|
7
11
|
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
8
12
|
import { Label, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack } from "react-aria-components";
|
|
9
13
|
import { useHover } from "react-aria/useHover";
|
|
10
|
-
|
|
14
|
+
// src/Slider/sliderVariants.ts
|
|
11
15
|
const sliderVariants = tv({
|
|
16
|
+
extend: fieldHelperVariants,
|
|
12
17
|
slots: {
|
|
13
|
-
base: [
|
|
14
|
-
"group",
|
|
15
|
-
"flex w-full flex-col",
|
|
16
|
-
"gap-y-1.5"
|
|
17
|
-
],
|
|
18
|
-
description: "text-foreground-500 text-tiny",
|
|
18
|
+
base: ["group", "flex w-full flex-col"],
|
|
19
19
|
endContent: "",
|
|
20
|
-
errorMessage: ["ml-1 mt-1", "m-0 text-danger text-tiny"],
|
|
21
20
|
filler: ["", "absolute h-full bg-primary"],
|
|
22
|
-
helperWrapper: "
|
|
23
|
-
label: "
|
|
24
|
-
labelWrapper:
|
|
21
|
+
helperWrapper: "pt-2",
|
|
22
|
+
label: [fieldLabelVariants.base, "pb-0"],
|
|
23
|
+
labelWrapper: "flex w-full items-center justify-between pb-1.5",
|
|
25
24
|
mark: "",
|
|
26
25
|
startContent: "",
|
|
27
26
|
step: [
|
|
@@ -69,6 +68,10 @@ const sliderVariants = tv({
|
|
|
69
68
|
thumb: "cursor-default",
|
|
70
69
|
visualBase: "opacity-disabled"
|
|
71
70
|
} },
|
|
71
|
+
readOnly: { true: {
|
|
72
|
+
base: "cursor-not-allowed **:cursor-not-allowed",
|
|
73
|
+
visualBase: "opacity-disabled"
|
|
74
|
+
} },
|
|
72
75
|
invalid: { true: {
|
|
73
76
|
filler: "bg-danger",
|
|
74
77
|
thumb: "bg-danger",
|
|
@@ -81,8 +84,7 @@ const sliderVariants = tv({
|
|
|
81
84
|
size: "sm"
|
|
82
85
|
}]
|
|
83
86
|
});
|
|
84
|
-
|
|
85
|
-
//#region src/Slider/subcomponents/SliderTrackControl.tsx
|
|
87
|
+
// src/Slider/subcomponents/SliderTrackControl.tsx
|
|
86
88
|
/**
|
|
87
89
|
* Slider track with fill, step markers and the editable thumb
|
|
88
90
|
*
|
|
@@ -155,15 +157,14 @@ const SliderTrackControl = ({ className: classNames, endContent, fillOffset, inp
|
|
|
155
157
|
]
|
|
156
158
|
});
|
|
157
159
|
};
|
|
158
|
-
|
|
159
|
-
//#region src/Slider/subcomponents/SliderControl.tsx
|
|
160
|
+
// src/Slider/subcomponents/SliderControl.tsx
|
|
160
161
|
/**
|
|
161
162
|
* Slider presentation with label, value output and thumb focus routing
|
|
162
163
|
*
|
|
163
164
|
* @see https://react-aria.adobe.com/Slider
|
|
164
165
|
*/
|
|
165
166
|
const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 100, minValue = 0, getCurrentValue, showSteps, size, startContent, step = 1 }) => {
|
|
166
|
-
const { value: displayValue, description, disabled, errorMessage, ids, ref: inputRef, invalid, label = void 0, name, onBlur, onChange: onValueChange, required, testId } = field;
|
|
167
|
+
const { value: displayValue, description, disabled, errorMessage, ids, ref: inputRef, invalid, label = void 0, name, onBlur, onChange: onValueChange, readOnly, required, testId } = field;
|
|
167
168
|
const controlProps = getFieldControlProps(field);
|
|
168
169
|
const styling = useStyling();
|
|
169
170
|
const { hoverProps, isHovered } = useHover({ isDisabled: disabled });
|
|
@@ -179,18 +180,26 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
}, [inputRef]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (readOnly) controlRef.current?.setAttribute("aria-readonly", "true");
|
|
185
|
+
else controlRef.current?.removeAttribute("aria-readonly");
|
|
186
|
+
}, [controlRef, readOnly]);
|
|
182
187
|
const associations = controlProps;
|
|
183
188
|
const describedBy = [associations["aria-describedby"], required ? `${ids.control}-required` : void 0].filter(Boolean).join(" ") || void 0;
|
|
184
189
|
const rawValue = displayValue != null ? Number(displayValue) : minValue;
|
|
185
190
|
const value = Math.min(maxValue, Math.max(minValue, rawValue));
|
|
186
191
|
const variants = styling.resolve(sliderVariants, {
|
|
187
|
-
size,
|
|
188
192
|
disabled,
|
|
189
|
-
invalid
|
|
193
|
+
invalid,
|
|
194
|
+
readOnly,
|
|
195
|
+
size
|
|
190
196
|
});
|
|
191
197
|
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
198
|
+
const handleValueChange = (nextValue) => {
|
|
199
|
+
if (!readOnly) onValueChange(nextValue);
|
|
200
|
+
};
|
|
192
201
|
const handleValueCommit = (nextValue) => {
|
|
193
|
-
if (isValueEmpty(getCurrentValue())) onValueChange(nextValue);
|
|
202
|
+
if (!readOnly && isValueEmpty(getCurrentValue())) onValueChange(nextValue);
|
|
194
203
|
};
|
|
195
204
|
const handleFocus = (event) => {
|
|
196
205
|
if (event.target === event.currentTarget && !disabled) controlRef.current?.focus();
|
|
@@ -199,6 +208,7 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
199
208
|
className: classNames.base,
|
|
200
209
|
"data-component": "slider",
|
|
201
210
|
"data-invalid": invalid,
|
|
211
|
+
"data-readonly": readOnly || void 0,
|
|
202
212
|
"data-required": required,
|
|
203
213
|
"data-testid": testId,
|
|
204
214
|
onFocus: handleFocus,
|
|
@@ -221,7 +231,7 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
221
231
|
isDisabled: disabled,
|
|
222
232
|
maxValue,
|
|
223
233
|
minValue,
|
|
224
|
-
onChange:
|
|
234
|
+
onChange: handleValueChange,
|
|
225
235
|
onChangeEnd: handleValueCommit,
|
|
226
236
|
step,
|
|
227
237
|
value,
|
|
@@ -253,25 +263,17 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
253
263
|
step
|
|
254
264
|
})]
|
|
255
265
|
}),
|
|
256
|
-
|
|
257
|
-
className: classNames
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}), invalid ? /* @__PURE__ */ jsx("div", {
|
|
264
|
-
className: classNames.errorMessage,
|
|
265
|
-
"data-slot": "error-message",
|
|
266
|
-
id: ids.error,
|
|
267
|
-
children: errorMessage
|
|
268
|
-
}) : null]
|
|
269
|
-
}) : null
|
|
266
|
+
/* @__PURE__ */ jsx(FieldHelper, {
|
|
267
|
+
className: classNames,
|
|
268
|
+
description,
|
|
269
|
+
errorMessage,
|
|
270
|
+
ids,
|
|
271
|
+
invalid
|
|
272
|
+
})
|
|
270
273
|
]
|
|
271
274
|
});
|
|
272
275
|
};
|
|
273
|
-
|
|
274
|
-
//#region src/Slider/Slider.tsx
|
|
276
|
+
// src/Slider/Slider.tsx
|
|
275
277
|
/** Form input field for choosing a numeric value along a track */
|
|
276
278
|
const Slider$1 = ({ className = void 0, endContent = void 0, fillOffset = void 0, maxValue = 100, minValue = 0, name, showSteps = false, size = "md", startContent = void 0, step = 1, ...uniformFieldProps }) => {
|
|
277
279
|
const { field, getValues } = useUniformField({
|
|
@@ -295,10 +297,8 @@ const Slider$1 = ({ className = void 0, endContent = void 0, fillOffset = void 0
|
|
|
295
297
|
step
|
|
296
298
|
});
|
|
297
299
|
};
|
|
298
|
-
|
|
299
|
-
//#region src/Slider/index.ts
|
|
300
|
+
// src/Slider/index.ts
|
|
300
301
|
var Slider_default = Slider$1;
|
|
301
|
-
//#endregion
|
|
302
302
|
export { Slider_default as default, sliderVariants };
|
|
303
303
|
|
|
304
304
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["AriaSlider","Slider","Slider"],"sources":["../../src/Slider/sliderVariants.ts","../../src/Slider/subcomponents/SliderTrackControl.tsx","../../src/Slider/subcomponents/SliderControl.tsx","../../src/Slider/Slider.tsx","../../src/Slider/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nexport const sliderVariants = tv({\n slots: {\n base: [\n // Enables group-data selectors used by slider slots.\n 'group',\n // Match shared field wrapper layout.\n 'flex w-full flex-col',\n // Keep spacing between label/track consistent.\n 'gap-y-1.5',\n ],\n description: 'text-foreground-500 text-tiny',\n endContent: '',\n errorMessage: ['ml-1 mt-1', 'm-0 text-danger text-tiny'],\n filler: ['', 'absolute h-full bg-primary'],\n helperWrapper: 'relative ml-0 block p-0',\n // Field-level invalid styling is supplied by the owning group.\n label:\n 'cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n labelWrapper: ['mb-1', 'flex w-full items-center justify-between'],\n mark: '',\n startContent: '',\n step: [\n '',\n // marker positioning\n 'absolute top-1/2 h-1.5 w-1.5 -translate-x-1/2 -translate-y-1/2',\n // marker surface\n 'rounded-full bg-default-300/50',\n // selected range and RTL positioning\n 'data-[in-range=true]:bg-background/50 rtl:translate-x-1/2',\n ],\n // Mouse submission can focus an invalid thumb without keyboard focus-visible.\n thumb: [\n 'group-data-[invalid=true]:data-[focused=true]:outline-2',\n 'group-data-[invalid=true]:data-[focused=true]:outline-focus',\n 'group-data-[invalid=true]:data-[focused=true]:outline-offset-2',\n // thumb layout and surface\n 'outline-solid top-1/2 flex h-6 w-6 cursor-grab items-center justify-center rounded-full border-0 bg-primary shadow-small outline-transparent ring-transparent',\n // expanded pointer target\n \"before:absolute before:h-11 before:w-11 before:rounded-full before:content-['']\",\n // inner thumb surface\n \"after:h-5 after:w-5 after:rounded-full after:bg-background after:shadow-small after:transition-all after:content-['']\",\n // focus and drag stacking\n 'data-[focus-visible=true]:z-10 data-[focused=true]:z-10 data-[dragging=true]:cursor-grabbing',\n // keyboard focus outline\n 'data-[focus-visible=true]:outline-2 data-[focus-visible=true]:outline-offset-2 data-[focus-visible=true]:outline-focus',\n // pressed thumb and reduced motion\n 'data-[dragging=true]:after:scale-80 motion-reduce:after:transition-none',\n ],\n track: [\n '',\n // track geometry and surface\n 'relative my-1.5 flex h-3 w-full rounded-full border-x-[12px] border-x-transparent bg-default-300/50',\n // fill colors at the track ends\n 'data-[fill-end=true]:border-e-primary data-[fill-start=true]:border-s-primary',\n ],\n trackWrapper: ['', 'relative flex items-center gap-2'],\n value: ['', 'text-small'],\n visualBase: 'flex w-full flex-col gap-1',\n },\n variants: {\n size: {\n lg: {\n step: 'h-2 w-2',\n thumb: 'h-7 w-7 shadow-none',\n track: 'my-1 h-7 border-x-[14px]',\n value: 'text-medium',\n },\n md: {},\n sm: {\n step: 'data-[in-range=false]:bg-default-200 data-[in-range=true]:bg-primary',\n thumb: 'h-5 w-5 after:h-4 after:w-4',\n track: 'my-2 h-1 border-x-[10px]',\n },\n },\n disabled: {\n true: { thumb: 'cursor-default', visualBase: 'opacity-disabled' },\n },\n invalid: {\n true: {\n filler: 'bg-danger',\n thumb: 'bg-danger',\n track:\n 'data-[fill-end=true]:border-e-danger data-[fill-start=true]:border-s-danger',\n },\n },\n },\n compoundVariants: [\n {\n class: { step: 'data-[in-range=true]:bg-danger' },\n invalid: true,\n size: 'sm',\n },\n ],\n});\n\nexport type VariantProps = TVProps<typeof sliderVariants>;\n\nexport type ClassName = TVClassName<typeof sliderVariants>;\n\nexport type SliderClassNames = Record<\n keyof ReturnType<typeof sliderVariants>,\n string\n>;\n","import type { RefObject } from 'react';\nimport type { SliderProps } from '../Slider';\nimport type { SliderClassNames } from '../sliderVariants';\n\nimport { SliderFill, SliderThumb, SliderTrack } from 'react-aria-components';\n\ninterface SliderTrackControlProps extends Pick<\n SliderProps,\n 'endContent' | 'fillOffset' | 'name' | 'showSteps' | 'startContent'\n> {\n /** CSS class name */\n className: SliderClassNames;\n /** Ref forwarded to the native range input */\n inputRef: RefObject<HTMLInputElement | null>;\n /** Shows validation failure */\n invalid: boolean;\n /** Largest displayed value */\n maxValue: number;\n /** Smallest displayed value */\n minValue: number;\n /** Callback when the thumb loses focus */\n onBlur: () => void;\n /** Distance between selectable values */\n step: number;\n}\n\n/**\n * Slider track with fill, step markers and the editable thumb\n *\n * @see https://react-aria.adobe.com/Slider\n */\nconst SliderTrackControl = ({\n className: classNames,\n endContent,\n fillOffset,\n inputRef,\n invalid,\n maxValue,\n minValue,\n name,\n onBlur,\n showSteps,\n startContent,\n step,\n}: SliderTrackControlProps) => {\n const stepCount = showSteps\n ? Math.max(0, Math.floor((maxValue - minValue) / (step > 0 ? step : 1)) + 1)\n : 0;\n\n const offset = fillOffset ?? minValue;\n const offsetPercent =\n maxValue === minValue\n ? 0\n : (Math.min(maxValue, Math.max(minValue, offset)) - minValue) /\n (maxValue - minValue);\n\n return (\n <div className={classNames.trackWrapper} data-slot=\"track-wrapper\">\n {startContent ? (\n <div className={classNames.startContent} data-slot=\"startContent\">\n {startContent}\n </div>\n ) : null}\n <SliderTrack\n className={classNames.track}\n data-slot=\"track\"\n render={(props, { state }) => {\n const percent = state.getThumbPercent(0);\n const start = Math.min(offsetPercent, percent);\n const end = Math.max(offsetPercent, percent);\n\n return (\n <div\n {...props}\n data-fill-end={\n fillOffset === undefined ? end - start === 1 : end === 1\n }\n data-fill-start={\n fillOffset === undefined ? end - start > 0 : start === 0\n }\n data-thumb-hidden=\"false\"\n data-vertical=\"false\"\n >\n {props.children}\n </div>\n );\n }}\n >\n {({ state }) => {\n const percent = state.getThumbPercent(0);\n const start = Math.min(offsetPercent, percent);\n const end = Math.max(offsetPercent, percent);\n\n return (\n <>\n <SliderFill\n className={classNames.filler}\n data-slot=\"filler\"\n offset={fillOffset}\n />\n {Array.from({ length: stepCount }, (_, index) => {\n const point = state.getValuePercent(minValue + index * step);\n\n return (\n <span\n key={index}\n aria-hidden\n className={classNames.step}\n data-in-range={point >= start && point <= end}\n data-slot=\"step\"\n style={{ insetInlineStart: `${point * 100}%` }}\n />\n );\n })}\n <SliderThumb\n className={classNames.thumb}\n data-slot=\"thumb\"\n inputRef={inputRef}\n isInvalid={invalid}\n name={name}\n onBlur={onBlur}\n />\n </>\n );\n }}\n </SliderTrack>\n {endContent ? (\n <div className={classNames.endContent} data-slot=\"endContent\">\n {endContent}\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SliderTrackControl;\n","import type { FocusEvent } from 'react';\nimport type { UniformField } from '../../hooks/useUniformField/types';\nimport type { SliderProps } from '../Slider';\n\nimport { useMemo } from 'react';\nimport {\n Slider as AriaSlider,\n Label,\n SliderOutput,\n} from 'react-aria-components';\nimport { useHover } from 'react-aria/useHover';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { isValueEmpty } from '../../helpers';\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldDescription from '../../partials/FieldDescription/FieldDescription';\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { sliderVariants } from '../sliderVariants';\nimport SliderTrackControl from './SliderTrackControl';\n\ninterface SliderControlProps extends Omit<\n SliderProps,\n keyof UniformField | 'transform'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, number>;\n /** Reads the stored value at interaction completion */\n getCurrentValue: () => unknown;\n}\n\n/**\n * Slider presentation with label, value output and thumb focus routing\n *\n * @see https://react-aria.adobe.com/Slider\n */\nconst SliderControl = ({\n field,\n className,\n endContent,\n fillOffset,\n maxValue = 100,\n minValue = 0,\n getCurrentValue,\n showSteps,\n size,\n startContent,\n step = 1,\n}: SliderControlProps) => {\n const {\n value: displayValue,\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label = undefined,\n name,\n onBlur,\n onChange: onValueChange,\n required,\n testId,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n const { hoverProps, isHovered } = useHover({ isDisabled: disabled });\n\n // forward the thumb ref while keeping it available for wrapper focus\n const controlRef = useMemo(() => {\n let current: HTMLInputElement | null = null;\n\n return {\n get current() {\n return current;\n },\n set current(node: HTMLInputElement | null) {\n current = node;\n inputRef(node);\n },\n };\n }, [inputRef]);\n\n const associations = controlProps;\n const describedBy =\n [\n associations['aria-describedby'],\n required ? `${ids.control}-required` : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const rawValue = displayValue != null ? Number(displayValue) : minValue;\n const value = Math.min(maxValue, Math.max(minValue, rawValue));\n\n // classNames from slots\n const variants = styling.resolve(sliderVariants, { size, disabled, invalid });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n // an empty field may finish at the displayed minimum without emitting a change\n const handleValueCommit = (nextValue: number) => {\n if (isValueEmpty(getCurrentValue())) {\n onValueChange(nextValue);\n }\n };\n\n // route wrapper focus to the editable thumb\n const handleFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && !disabled) {\n controlRef.current?.focus();\n }\n };\n\n return (\n <div\n className={classNames.base}\n data-component=\"slider\"\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n onFocus={handleFocus}\n tabIndex={disabled ? undefined : -1}\n >\n {required ? (\n <span className=\"sr-only\" id={`${ids.control}-required`}>\n Required selection.\n </span>\n ) : null}\n <AriaSlider<number>\n aria-invalid={associations['aria-invalid']}\n aria-label={associations['aria-label']}\n id={associations.id}\n {...hoverProps}\n aria-describedby={describedBy}\n className={classNames.visualBase}\n data-hover={isHovered}\n data-slot=\"base\"\n isDisabled={disabled}\n maxValue={maxValue}\n minValue={minValue}\n onChange={onValueChange}\n onChangeEnd={handleValueCommit}\n step={step}\n value={value}\n >\n {/* label and current value */}\n {label ? (\n <div className={classNames.labelWrapper} data-slot=\"labelWrapper\">\n {label ? (\n <FieldLabel\n as={Label}\n className={classNames.label}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n ) : null}\n <SliderOutput className={classNames.value} data-slot=\"value\" />\n </div>\n ) : null}\n\n {/* slider track and surrounding content */}\n <SliderTrackControl\n className={classNames}\n endContent={endContent}\n fillOffset={fillOffset}\n inputRef={controlRef}\n invalid={invalid}\n maxValue={maxValue}\n minValue={minValue}\n name={name}\n onBlur={onBlur}\n showSteps={showSteps}\n startContent={startContent}\n step={step}\n />\n </AriaSlider>\n\n {/* help text and validation messages */}\n {description || invalid ? (\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldDescription\n className={classNames.description}\n id={ids.description}\n >\n {description}\n </FieldDescription>\n {invalid ? (\n <div\n className={classNames.errorMessage}\n data-slot=\"error-message\"\n id={ids.error}\n >\n {errorMessage}\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SliderControl;\n","import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { ClassName } from './sliderVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport SliderControl from './subcomponents/SliderControl';\n\nexport { sliderVariants } from './sliderVariants';\n\nexport interface SliderProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\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 /** Field label */\n label?: string;\n /**\n * The maximum value of the slider\n * @default 100\n */\n maxValue?: number;\n /**\n * The minimum value of the slider\n * @default 0\n */\n minValue?: number;\n /** Field name */\n name: string;\n /**\n * Whether to show step dots on the slider\n * @default false\n */\n showSteps?: boolean;\n /** Control size */\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 for e2e tests */\n testId?: string;\n /** Transform between stored form values and numeric slider values. Range and step use display units. */\n transform?: InputValueTransform<number>;\n}\n\n/** Form input field for choosing a numeric value along a track */\nconst Slider = ({\n className = undefined,\n endContent = undefined,\n fillOffset = undefined,\n maxValue = 100,\n minValue = 0,\n name,\n showSteps = false,\n size = 'md',\n startContent = undefined,\n step = 1,\n ...uniformFieldProps\n}: SliderProps) => {\n const { field, getValues } = useUniformField({\n ...uniformFieldProps,\n name,\n });\n\n const getCurrentValue = (): unknown => {\n return getValues(name);\n };\n\n return (\n <SliderControl\n className={className}\n endContent={endContent}\n field={field}\n fillOffset={fillOffset}\n getCurrentValue={getCurrentValue}\n maxValue={maxValue}\n minValue={minValue}\n showSteps={showSteps}\n size={size}\n startContent={startContent}\n step={step}\n />\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { sliderVariants } from './Slider';\n\nexport default Slider;\n"],"mappings":";;;;;;;;;;AAIA,MAAa,iBAAiB,GAAG;CAC/B,OAAO;EACL,MAAM;GAEJ;GAEA;GAEA;EACF;EACA,aAAa;EACb,YAAY;EACZ,cAAc,CAAC,aAAa,2BAA2B;EACvD,QAAQ,CAAC,IAAI,4BAA4B;EACzC,eAAe;EAEf,OACE;EACF,cAAc,CAAC,QAAQ,0CAA0C;EACjE,MAAM;EACN,cAAc;EACd,MAAM;GACJ;GAEA;GAEA;GAEA;EACF;EAEA,OAAO;GACL;GACA;GACA;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;EACF;EACA,OAAO;GACL;GAEA;GAEA;EACF;EACA,cAAc,CAAC,IAAI,kCAAkC;EACrD,OAAO,CAAC,IAAI,YAAY;EACxB,YAAY;CACd;CACA,UAAU;EACR,MAAM;GACJ,IAAI;IACF,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;GACT;GACA,IAAI,CAAC;GACL,IAAI;IACF,MAAM;IACN,OAAO;IACP,OAAO;GACT;EACF;EACA,UAAU,EACR,MAAM;GAAE,OAAO;GAAkB,YAAY;EAAmB,EAClE;EACA,SAAS,EACP,MAAM;GACJ,QAAQ;GACR,OAAO;GACP,OACE;EACJ,EACF;CACF;CACA,kBAAkB,CAChB;EACE,OAAO,EAAE,MAAM,iCAAiC;EAChD,SAAS;EACT,MAAM;CACR,CACF;AACF,CAAC;;;;;;;;AClED,MAAM,sBAAsB,EAC1B,WAAW,YACX,YACA,YACA,UACA,SACA,UACA,UACA,MACA,QACA,WACA,cACA,WAC6B;CAC7B,MAAM,YAAY,YACd,KAAK,IAAI,GAAG,KAAK,OAAO,WAAW,aAAa,OAAO,IAAI,OAAO,EAAE,IAAI,CAAC,IACzE;CAGJ,MAAM,gBACJ,aAAa,WAC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ACX,WAAW,GACX,MACA,YAAY,OACZ,OAAO,MACP,eAAe,KAAA,GACf,OAAO,GACP,GAAG,wBACc;CACjB,MAAM,EAAE,OAAO,cAAc,gBAAgB;EAC3C,GAAG;EACH;CACF,CAAC;CAED,MAAM,wBAAiC;EACrC,OAAO,UAAU,IAAI;CACvB;CAEA,OACE,oBAAC,eAAD;EACa;EACC;EACL;EACK;EACK;EACP;EACA;EACC;EACL;EACQ;EACR;CACP,CAAA;AAEL;;;ACxFA,IAAA,iBAAeC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["AriaSlider","Slider","Slider"],"sources":["../../src/Slider/sliderVariants.ts","../../src/Slider/subcomponents/SliderTrackControl.tsx","../../src/Slider/subcomponents/SliderControl.tsx","../../src/Slider/Slider.tsx","../../src/Slider/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nimport { fieldHelperVariants } from '../partials/FieldHelper/fieldHelperVariants';\nimport { fieldLabelVariants } from '../partials/FieldLabel/fieldLabelVariants';\n\nexport const sliderVariants = tv({\n extend: fieldHelperVariants,\n slots: {\n base: [\n // Enables group-data selectors used by slider slots.\n 'group',\n // Match shared field wrapper layout.\n 'flex w-full flex-col',\n ],\n endContent: '',\n filler: ['', 'absolute h-full bg-primary'],\n // clears the thumb focus outline below the track row\n helperWrapper: 'pt-2',\n // Field-level invalid styling is supplied by the owning group.\n // the label row carries the spacing to the track\n label: [fieldLabelVariants.base, 'pb-0'],\n labelWrapper: 'flex w-full items-center justify-between pb-1.5',\n mark: '',\n startContent: '',\n step: [\n '',\n // marker positioning\n 'absolute top-1/2 h-1.5 w-1.5 -translate-x-1/2 -translate-y-1/2',\n // marker surface\n 'rounded-full bg-default-300/50',\n // selected range and RTL positioning\n 'data-[in-range=true]:bg-background/50 rtl:translate-x-1/2',\n ],\n // Mouse submission can focus an invalid thumb without keyboard focus-visible.\n thumb: [\n 'group-data-[invalid=true]:data-[focused=true]:outline-2',\n 'group-data-[invalid=true]:data-[focused=true]:outline-focus',\n 'group-data-[invalid=true]:data-[focused=true]:outline-offset-2',\n // thumb layout and surface\n 'outline-solid top-1/2 flex h-6 w-6 cursor-grab items-center justify-center rounded-full border-0 bg-primary shadow-small outline-transparent ring-transparent',\n // expanded pointer target\n \"before:absolute before:h-11 before:w-11 before:rounded-full before:content-['']\",\n // inner thumb surface\n \"after:h-5 after:w-5 after:rounded-full after:bg-background after:shadow-small after:transition-all after:content-['']\",\n // focus and drag stacking\n 'data-[focus-visible=true]:z-10 data-[focused=true]:z-10 data-[dragging=true]:cursor-grabbing',\n // keyboard focus outline\n 'data-[focus-visible=true]:outline-2 data-[focus-visible=true]:outline-offset-2 data-[focus-visible=true]:outline-focus',\n // pressed thumb and reduced motion\n 'data-[dragging=true]:after:scale-80 motion-reduce:after:transition-none',\n ],\n track: [\n '',\n // track geometry and surface\n 'relative my-1.5 flex h-3 w-full rounded-full border-x-[12px] border-x-transparent bg-default-300/50',\n // fill colors at the track ends\n 'data-[fill-end=true]:border-e-primary data-[fill-start=true]:border-s-primary',\n ],\n trackWrapper: ['', 'relative flex items-center gap-2'],\n value: ['', 'text-small'],\n visualBase: 'flex w-full flex-col gap-1',\n },\n variants: {\n size: {\n lg: {\n step: 'h-2 w-2',\n thumb: 'h-7 w-7 shadow-none',\n track: 'my-1 h-7 border-x-[14px]',\n value: 'text-medium',\n },\n md: {},\n sm: {\n step: 'data-[in-range=false]:bg-default-200 data-[in-range=true]:bg-primary',\n thumb: 'h-5 w-5 after:h-4 after:w-4',\n track: 'my-2 h-1 border-x-[10px]',\n },\n },\n disabled: {\n true: { thumb: 'cursor-default', visualBase: 'opacity-disabled' },\n },\n readOnly: {\n true: {\n // inner controls set their own cursors, override every descendant\n base: 'cursor-not-allowed **:cursor-not-allowed',\n visualBase: 'opacity-disabled',\n },\n },\n invalid: {\n true: {\n filler: 'bg-danger',\n thumb: 'bg-danger',\n track:\n 'data-[fill-end=true]:border-e-danger data-[fill-start=true]:border-s-danger',\n },\n },\n },\n compoundVariants: [\n {\n class: { step: 'data-[in-range=true]:bg-danger' },\n invalid: true,\n size: 'sm',\n },\n ],\n});\n\nexport type VariantProps = TVProps<typeof sliderVariants>;\n\nexport type ClassName = TVClassName<typeof sliderVariants>;\n\nexport type SliderClassNames = Record<\n keyof ReturnType<typeof sliderVariants>,\n string\n>;\n","import type { RefObject } from 'react';\nimport type { SliderProps } from '../Slider';\nimport type { SliderClassNames } from '../sliderVariants';\n\nimport { SliderFill, SliderThumb, SliderTrack } from 'react-aria-components';\n\ninterface SliderTrackControlProps extends Pick<\n SliderProps,\n 'endContent' | 'fillOffset' | 'name' | 'showSteps' | 'startContent'\n> {\n /** CSS class name */\n className: SliderClassNames;\n /** Ref forwarded to the native range input */\n inputRef: RefObject<HTMLInputElement | null>;\n /** Shows validation failure */\n invalid: boolean;\n /** Largest displayed value */\n maxValue: number;\n /** Smallest displayed value */\n minValue: number;\n /** Callback when the thumb loses focus */\n onBlur: () => void;\n /** Distance between selectable values */\n step: number;\n}\n\n/**\n * Slider track with fill, step markers and the editable thumb\n *\n * @see https://react-aria.adobe.com/Slider\n */\nconst SliderTrackControl = ({\n className: classNames,\n endContent,\n fillOffset,\n inputRef,\n invalid,\n maxValue,\n minValue,\n name,\n onBlur,\n showSteps,\n startContent,\n step,\n}: SliderTrackControlProps) => {\n const stepCount = showSteps\n ? Math.max(0, Math.floor((maxValue - minValue) / (step > 0 ? step : 1)) + 1)\n : 0;\n\n const offset = fillOffset ?? minValue;\n const offsetPercent =\n maxValue === minValue\n ? 0\n : (Math.min(maxValue, Math.max(minValue, offset)) - minValue) /\n (maxValue - minValue);\n\n return (\n <div className={classNames.trackWrapper} data-slot=\"track-wrapper\">\n {startContent ? (\n <div className={classNames.startContent} data-slot=\"startContent\">\n {startContent}\n </div>\n ) : null}\n <SliderTrack\n className={classNames.track}\n data-slot=\"track\"\n render={(props, { state }) => {\n const percent = state.getThumbPercent(0);\n const start = Math.min(offsetPercent, percent);\n const end = Math.max(offsetPercent, percent);\n\n return (\n <div\n {...props}\n data-fill-end={\n fillOffset === undefined ? end - start === 1 : end === 1\n }\n data-fill-start={\n fillOffset === undefined ? end - start > 0 : start === 0\n }\n data-thumb-hidden=\"false\"\n data-vertical=\"false\"\n >\n {props.children}\n </div>\n );\n }}\n >\n {({ state }) => {\n const percent = state.getThumbPercent(0);\n const start = Math.min(offsetPercent, percent);\n const end = Math.max(offsetPercent, percent);\n\n return (\n <>\n <SliderFill\n className={classNames.filler}\n data-slot=\"filler\"\n offset={fillOffset}\n />\n {Array.from({ length: stepCount }, (_, index) => {\n const point = state.getValuePercent(minValue + index * step);\n\n return (\n <span\n key={index}\n aria-hidden\n className={classNames.step}\n data-in-range={point >= start && point <= end}\n data-slot=\"step\"\n style={{ insetInlineStart: `${point * 100}%` }}\n />\n );\n })}\n <SliderThumb\n className={classNames.thumb}\n data-slot=\"thumb\"\n inputRef={inputRef}\n isInvalid={invalid}\n name={name}\n onBlur={onBlur}\n />\n </>\n );\n }}\n </SliderTrack>\n {endContent ? (\n <div className={classNames.endContent} data-slot=\"endContent\">\n {endContent}\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SliderTrackControl;\n","import type { FocusEvent } from 'react';\nimport type { UniformField } from '../../hooks/useUniformField/types';\nimport type { SliderProps } from '../Slider';\n\nimport { useEffect, useMemo } from 'react';\nimport {\n Slider as AriaSlider,\n Label,\n SliderOutput,\n} from 'react-aria-components';\nimport { useHover } from 'react-aria/useHover';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { isValueEmpty } from '../../helpers';\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldHelper from '../../partials/FieldHelper/FieldHelper';\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { sliderVariants } from '../sliderVariants';\nimport SliderTrackControl from './SliderTrackControl';\n\ninterface SliderControlProps extends Omit<\n SliderProps,\n keyof UniformField | 'transform'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, number>;\n /** Reads the stored value at interaction completion */\n getCurrentValue: () => unknown;\n}\n\n/**\n * Slider presentation with label, value output and thumb focus routing\n *\n * @see https://react-aria.adobe.com/Slider\n */\nconst SliderControl = ({\n field,\n className,\n endContent,\n fillOffset,\n maxValue = 100,\n minValue = 0,\n getCurrentValue,\n showSteps,\n size,\n startContent,\n step = 1,\n}: SliderControlProps) => {\n const {\n value: displayValue,\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label = undefined,\n name,\n onBlur,\n onChange: onValueChange,\n readOnly,\n required,\n testId,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n const { hoverProps, isHovered } = useHover({ isDisabled: disabled });\n\n // forward the thumb ref while keeping it available for wrapper focus\n const controlRef = useMemo(() => {\n let current: HTMLInputElement | null = null;\n\n return {\n get current() {\n return current;\n },\n set current(node: HTMLInputElement | null) {\n current = node;\n inputRef(node);\n },\n };\n }, [inputRef]);\n\n // React Aria's thumb input has no read-only prop, mark it directly so screen\n // readers announce the state when keyboard focus reaches the thumb\n useEffect(() => {\n if (readOnly) {\n controlRef.current?.setAttribute('aria-readonly', 'true');\n } else {\n controlRef.current?.removeAttribute('aria-readonly');\n }\n }, [controlRef, readOnly]);\n\n const associations = controlProps;\n const describedBy =\n [\n associations['aria-describedby'],\n required ? `${ids.control}-required` : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const rawValue = displayValue != null ? Number(displayValue) : minValue;\n const value = Math.min(maxValue, Math.max(minValue, rawValue));\n\n // classNames from slots\n const variants = styling.resolve(sliderVariants, {\n disabled,\n invalid,\n readOnly,\n size,\n });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n // Slider has no read-only mode, read-only values ignore changes so the\n // controlled thumb keeps the stored value\n const handleValueChange = (nextValue: number) => {\n if (!readOnly) {\n onValueChange(nextValue);\n }\n };\n\n // an empty field may finish at the displayed minimum without emitting a change\n const handleValueCommit = (nextValue: number) => {\n if (!readOnly && isValueEmpty(getCurrentValue())) {\n onValueChange(nextValue);\n }\n };\n\n // route wrapper focus to the editable thumb\n const handleFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && !disabled) {\n controlRef.current?.focus();\n }\n };\n\n return (\n <div\n className={classNames.base}\n data-component=\"slider\"\n data-invalid={invalid}\n data-readonly={readOnly || undefined}\n data-required={required}\n data-testid={testId}\n onFocus={handleFocus}\n tabIndex={disabled ? undefined : -1}\n >\n {required ? (\n <span className=\"sr-only\" id={`${ids.control}-required`}>\n Required selection.\n </span>\n ) : null}\n <AriaSlider<number>\n aria-invalid={associations['aria-invalid']}\n aria-label={associations['aria-label']}\n id={associations.id}\n {...hoverProps}\n aria-describedby={describedBy}\n className={classNames.visualBase}\n data-hover={isHovered}\n data-slot=\"base\"\n isDisabled={disabled}\n maxValue={maxValue}\n minValue={minValue}\n onChange={handleValueChange}\n onChangeEnd={handleValueCommit}\n step={step}\n value={value}\n >\n {/* label and current value */}\n {label ? (\n <div className={classNames.labelWrapper} data-slot=\"labelWrapper\">\n {label ? (\n <FieldLabel\n as={Label}\n className={classNames.label}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n ) : null}\n <SliderOutput className={classNames.value} data-slot=\"value\" />\n </div>\n ) : null}\n\n {/* slider track and surrounding content */}\n <SliderTrackControl\n className={classNames}\n endContent={endContent}\n fillOffset={fillOffset}\n inputRef={controlRef}\n invalid={invalid}\n maxValue={maxValue}\n minValue={minValue}\n name={name}\n onBlur={onBlur}\n showSteps={showSteps}\n startContent={startContent}\n step={step}\n />\n </AriaSlider>\n\n {/* help text and validation messages */}\n <FieldHelper\n className={classNames}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n />\n </div>\n );\n};\n\nexport default SliderControl;\n","import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { ClassName } from './sliderVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport SliderControl from './subcomponents/SliderControl';\n\nexport { sliderVariants } from './sliderVariants';\n\nexport interface SliderProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\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 /** Field label */\n label?: string;\n /**\n * The maximum value of the slider\n * @default 100\n */\n maxValue?: number;\n /**\n * The minimum value of the slider\n * @default 0\n */\n minValue?: number;\n /** Field name */\n name: string;\n /** Prevents changes while keeping the value in validation and submission */\n readOnly?: boolean;\n /**\n * Whether to show step dots on the slider\n * @default false\n */\n showSteps?: boolean;\n /** Control size */\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 for e2e tests */\n testId?: string;\n /** Transform between stored form values and numeric slider values. Range and step use display units. */\n transform?: InputValueTransform<number>;\n}\n\n/** Form input field for choosing a numeric value along a track */\nconst Slider = ({\n className = undefined,\n endContent = undefined,\n fillOffset = undefined,\n maxValue = 100,\n minValue = 0,\n name,\n showSteps = false,\n size = 'md',\n startContent = undefined,\n step = 1,\n ...uniformFieldProps\n}: SliderProps) => {\n const { field, getValues } = useUniformField({\n ...uniformFieldProps,\n name,\n });\n\n const getCurrentValue = (): unknown => {\n return getValues(name);\n };\n\n return (\n <SliderControl\n className={className}\n endContent={endContent}\n field={field}\n fillOffset={fillOffset}\n getCurrentValue={getCurrentValue}\n maxValue={maxValue}\n minValue={minValue}\n showSteps={showSteps}\n size={size}\n startContent={startContent}\n step={step}\n />\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { sliderVariants } from './Slider';\n\nexport default Slider;\n"],"mappings":";;;;;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;CACjB,MAAM,EAAE,OAAO,cAAc,gBAAgB;EAC3C,GAAG;EACH;CACF,CAAC;CAED,MAAM,wBAAiC;EACrC,OAAO,UAAU,IAAI;CACvB;CAEA,OACE,oBAAC,eAAD;EACa;EACC;EACL;EACK;EACK;EACP;EACA;EACC;EACL;EACQ;EACR;CACP,CAAA;AAEL;;AC1FA,IAAA,iBAAeC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { ButtonProps } from "@fuf-stack/pixels";
|
|
3
|
-
//#region src/SubmitButton/SubmitButton.d.ts
|
|
4
3
|
interface SubmitButtonProps {
|
|
5
4
|
/** sets HTML aria-label attribute */
|
|
6
5
|
ariaLabel?: string;
|
|
@@ -39,6 +38,5 @@ interface SubmitButtonProps {
|
|
|
39
38
|
* features `isSubmitting` and `triggerSubmit` and how to re-add them safely.
|
|
40
39
|
*/
|
|
41
40
|
declare const SubmitButton: ({ ariaLabel, children, className, color, icon, loading, remoteFormId, size, testId }: SubmitButtonProps) => import("react").JSX.Element;
|
|
42
|
-
//#endregion
|
|
43
41
|
export { type SubmitButtonProps, SubmitButton as default };
|
|
44
42
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/SubmitButton/SubmitButton.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/SubmitButton/SubmitButton.tsx"],"mappings":";;UAOiB;;EAEf;;EAEA,WAAW;;EAEX;;EAEA,QAAQ;;EAER,OAAO;;EAEP;;;;EAIA;;EAEA,OAAO;;EAEP;;;;;;;;;;;;;;;;;cAkBI,iBAAgB,WAAA,UAAA,WAAA,OAAA,MAAA,SAAA,cAAA,MAAA,UAUnB,sCAAiB,IAAA"}
|
|
@@ -2,7 +2,7 @@ import { Button } from "@fuf-stack/pixels";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { slugify } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
5
|
-
|
|
5
|
+
// src/SubmitButton/SubmitButton.tsx
|
|
6
6
|
/**
|
|
7
7
|
* Submit button for a uniform `Form`.
|
|
8
8
|
*
|
|
@@ -34,10 +34,8 @@ const SubmitButton = ({ ariaLabel = "Submit form", children = "Submit", classNam
|
|
|
34
34
|
children
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
//#region src/SubmitButton/index.ts
|
|
37
|
+
// src/SubmitButton/index.ts
|
|
39
38
|
var SubmitButton_default = SubmitButton;
|
|
40
|
-
//#endregion
|
|
41
39
|
export { SubmitButton_default as default };
|
|
42
40
|
|
|
43
41
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/SubmitButton/SubmitButton.tsx","../../src/SubmitButton/index.ts"],"sourcesContent":["import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\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 /** id of the form this button should submit when it is rendered OUTSIDE that\n * form (e.g. a modal footer). Associates the button with the form via the\n * native HTML `form` attribute — set the same id on `<Form remoteFormId>`. */\n remoteFormId?: string;\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 * Submit button for a uniform `Form`.\n *\n * It is a plain native submit button (`type=\"submit\"`) and reads no form\n * context, so it works both inside a `<Form>` and standalone. Submission is\n * handled entirely by the browser:\n * - click submits the associated form,\n * - pressing Enter in a form field triggers native implicit form submission.\n *\n * When rendered OUTSIDE the form it belongs to, pass `remoteFormId` (matching the\n * form's `remoteFormId`) to associate them via the native HTML `form` attribute.\n *\n * See SUBMITBUTTON_CONTEXT.md for the (intentionally dropped) context-based\n * features `isSubmitting` and `triggerSubmit` and how to re-add them safely.\n */\nconst SubmitButton = ({\n ariaLabel = 'Submit form',\n children = 'Submit',\n className = undefined,\n color = 'success',\n icon = undefined,\n loading = false,\n remoteFormId = undefined,\n size = 'md',\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n ariaLabel={ariaLabel}\n className={cn(className)}\n color={color}\n dataComponent=\"submit-button\"\n // associate with a form rendered elsewhere via the native `form` attribute\n // (see remoteFormId prop) so the button can submit a form it is not a DOM\n // descendant of\n form={remoteFormId}\n icon={icon}\n loading={loading}\n size={size}\n testId={slugify(testId, { replaceDots: true })}\n // type=\"submit\" makes the button a submit control of its form. Required for\n // the browser's native \"implicit form submission\" (pressing Enter in a form\n // field submits the form and thereby runs its validation).\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 default SubmitButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,gBAAgB,EACpB,YAAY,eACZ,WAAW,UACX,YAAY,KAAA,GACZ,QAAQ,WACR,OAAO,KAAA,GACP,UAAU,OACV,eAAe,KAAA,GACf,OAAO,MACP,SAAS,2BACc;CACvB,MAAM,EAAE,OAAO,WAAW;CAC1B,OACE,oBAAC,QAAD;EACa;EACX,WAAW,GAAG,SAAS;EAChB;EACP,eAAc;EAId,MAAM;EACA;EACG;EACH;EACN,QAAQ,QAAQ,QAAQ,EAAE,aAAa,KAAK,CAAC;EAI7C,MAAK;EAEJ;CACK,CAAA;AAEZ
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/SubmitButton/SubmitButton.tsx","../../src/SubmitButton/index.ts"],"sourcesContent":["import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\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 /** id of the form this button should submit when it is rendered OUTSIDE that\n * form (e.g. a modal footer). Associates the button with the form via the\n * native HTML `form` attribute — set the same id on `<Form remoteFormId>`. */\n remoteFormId?: string;\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 * Submit button for a uniform `Form`.\n *\n * It is a plain native submit button (`type=\"submit\"`) and reads no form\n * context, so it works both inside a `<Form>` and standalone. Submission is\n * handled entirely by the browser:\n * - click submits the associated form,\n * - pressing Enter in a form field triggers native implicit form submission.\n *\n * When rendered OUTSIDE the form it belongs to, pass `remoteFormId` (matching the\n * form's `remoteFormId`) to associate them via the native HTML `form` attribute.\n *\n * See SUBMITBUTTON_CONTEXT.md for the (intentionally dropped) context-based\n * features `isSubmitting` and `triggerSubmit` and how to re-add them safely.\n */\nconst SubmitButton = ({\n ariaLabel = 'Submit form',\n children = 'Submit',\n className = undefined,\n color = 'success',\n icon = undefined,\n loading = false,\n remoteFormId = undefined,\n size = 'md',\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n ariaLabel={ariaLabel}\n className={cn(className)}\n color={color}\n dataComponent=\"submit-button\"\n // associate with a form rendered elsewhere via the native `form` attribute\n // (see remoteFormId prop) so the button can submit a form it is not a DOM\n // descendant of\n form={remoteFormId}\n icon={icon}\n loading={loading}\n size={size}\n testId={slugify(testId, { replaceDots: true })}\n // type=\"submit\" makes the button a submit control of its form. Required for\n // the browser's native \"implicit form submission\" (pressing Enter in a form\n // field submits the form and thereby runs its validation).\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 default SubmitButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,gBAAgB,EACpB,YAAY,eACZ,WAAW,UACX,YAAY,KAAA,GACZ,QAAQ,WACR,OAAO,KAAA,GACP,UAAU,OACV,eAAe,KAAA,GACf,OAAO,MACP,SAAS,2BACc;CACvB,MAAM,EAAE,OAAO,WAAW;CAC1B,OACE,oBAAC,QAAD;EACa;EACX,WAAW,GAAG,SAAS;EAChB;EACP,eAAc;EAId,MAAM;EACA;EACG;EACH;EACN,QAAQ,QAAQ,QAAQ,EAAE,aAAa,KAAK,CAAC;EAI7C,MAAK;EAEJ;CACK,CAAA;AAEZ;;AC3EA,IAAA,uBAAe"}
|
package/dist/Switch/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SwitchProps, r as switchVariants, t as Switch } from "../Switch-
|
|
1
|
+
import { n as SwitchProps, r as switchVariants, t as Switch } from "../Switch-aBYStBoY.mjs";
|
|
2
2
|
export { type SwitchProps, Switch as default, switchVariants };
|
package/dist/Switch/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as useUniformField } from "../useUniformField-TTNPTsVn.mjs";
|
|
2
|
+
import { t as getFieldControlProps } from "../fieldProps-DWfz2jSO.mjs";
|
|
3
|
+
import { t as FieldHelper } from "../FieldHelper-B1DWl7eu.mjs";
|
|
4
|
+
import { t as FieldLabel } from "../FieldLabel-DMTqq0Jj.mjs";
|
|
5
|
+
import { t as switchVariants } from "../switchVariants-0Xa7TQYg.mjs";
|
|
4
6
|
import { cloneElement, isValidElement } from "react";
|
|
5
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
@@ -11,7 +13,7 @@ import { mergeProps } from "react-aria/mergeProps";
|
|
|
11
13
|
import { useSwitch } from "react-aria/useSwitch";
|
|
12
14
|
import { VisuallyHidden } from "react-aria/VisuallyHidden";
|
|
13
15
|
import { useToggleState } from "react-stately/useToggleState";
|
|
14
|
-
|
|
16
|
+
// src/Switch/subcomponents/SwitchIcon.tsx
|
|
15
17
|
/** Applies switch icon dimensions and slot styling to an element */
|
|
16
18
|
const SwitchIcon = ({ children, className }) => {
|
|
17
19
|
return /* @__PURE__ */ jsx(Fragment, { children: isValidElement(children) ? cloneElement(children, {
|
|
@@ -20,8 +22,7 @@ const SwitchIcon = ({ children, className }) => {
|
|
|
20
22
|
className
|
|
21
23
|
}) : children });
|
|
22
24
|
};
|
|
23
|
-
|
|
24
|
-
//#region src/Switch/subcomponents/SwitchThumb.tsx
|
|
25
|
+
// src/Switch/subcomponents/SwitchThumb.tsx
|
|
25
26
|
/** Thumb icon content, including the consumer's selection-aware render callback */
|
|
26
27
|
const SwitchThumb = ({ className, selected, thumbIcon = void 0 }) => {
|
|
27
28
|
return /* @__PURE__ */ jsx(Fragment, { children: typeof thumbIcon === "function" ? thumbIcon({
|
|
@@ -35,8 +36,7 @@ const SwitchThumb = ({ className, selected, thumbIcon = void 0 }) => {
|
|
|
35
36
|
children: thumbIcon
|
|
36
37
|
}) });
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
-
//#region src/Switch/subcomponents/SwitchTrack.tsx
|
|
39
|
+
// src/Switch/subcomponents/SwitchTrack.tsx
|
|
40
40
|
/** Visual switch track, thumb and optional leading and trailing icons */
|
|
41
41
|
const SwitchTrack = ({ className: classNames, endContent, selected, startContent, thumbIcon }) => {
|
|
42
42
|
return /* @__PURE__ */ jsxs("span", {
|
|
@@ -64,19 +64,19 @@ const SwitchTrack = ({ className: classNames, endContent, selected, startContent
|
|
|
64
64
|
]
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
|
-
|
|
68
|
-
//#region src/Switch/subcomponents/SwitchControl.tsx
|
|
67
|
+
// src/Switch/subcomponents/SwitchControl.tsx
|
|
69
68
|
/**
|
|
70
69
|
* Switch presentation with native input, focus and thumb content
|
|
71
70
|
*
|
|
72
71
|
* @see https://react-aria.adobe.com/useSwitch
|
|
73
72
|
*/
|
|
74
73
|
const SwitchControl = ({ field, className, size, thumbIcon, endContent, startContent }) => {
|
|
75
|
-
const { description, disabled, errorMessage, ids, ref: inputRef, invalid, label, name, onBlur, onChange: onValueChange, required, testId, value } = field;
|
|
74
|
+
const { description, disabled, errorMessage, ids, ref: inputRef, invalid, label, name, onBlur, onChange: onValueChange, readOnly, required, testId, value } = field;
|
|
76
75
|
const controlProps = getFieldControlProps(field);
|
|
77
76
|
const styling = useStyling();
|
|
78
77
|
const controlRef = useObjectRef(inputRef);
|
|
79
78
|
const state = useToggleState({
|
|
79
|
+
isReadOnly: readOnly,
|
|
80
80
|
isSelected: !!value,
|
|
81
81
|
onChange: onValueChange
|
|
82
82
|
});
|
|
@@ -85,6 +85,7 @@ const SwitchControl = ({ field, className, size, thumbIcon, endContent, startCon
|
|
|
85
85
|
children: label,
|
|
86
86
|
isDisabled: disabled,
|
|
87
87
|
isInvalid: invalid,
|
|
88
|
+
isReadOnly: readOnly,
|
|
88
89
|
isRequired: required,
|
|
89
90
|
name,
|
|
90
91
|
onBlur,
|
|
@@ -93,8 +94,9 @@ const SwitchControl = ({ field, className, size, thumbIcon, endContent, startCon
|
|
|
93
94
|
const { focusProps, isFocused, isFocusVisible } = useFocusRing();
|
|
94
95
|
const { hoverProps, isHovered } = useHover({ isDisabled: disabled });
|
|
95
96
|
const variants = styling.resolve(switchVariants, {
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
disabled,
|
|
98
|
+
readOnly,
|
|
99
|
+
size
|
|
98
100
|
});
|
|
99
101
|
const classNames = styling.variantsToClassNames(variants, className, "outerWrapper");
|
|
100
102
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -110,6 +112,7 @@ const SwitchControl = ({ field, className, size, thumbIcon, endContent, startCon
|
|
|
110
112
|
"data-hover": isHovered || void 0,
|
|
111
113
|
"data-invalid": invalid,
|
|
112
114
|
"data-pressed": isPressed || void 0,
|
|
115
|
+
"data-readonly": readOnly || void 0,
|
|
113
116
|
"data-required": required,
|
|
114
117
|
"data-selected": state.isSelected || void 0,
|
|
115
118
|
"data-slot": "base",
|
|
@@ -139,24 +142,16 @@ const SwitchControl = ({ field, className, size, thumbIcon, endContent, startCon
|
|
|
139
142
|
children: label
|
|
140
143
|
}) : null
|
|
141
144
|
]
|
|
142
|
-
}),
|
|
143
|
-
className: classNames
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}), invalid ? /* @__PURE__ */ jsx("div", {
|
|
150
|
-
className: classNames.errorMessage,
|
|
151
|
-
"data-slot": "error-message",
|
|
152
|
-
id: ids.error,
|
|
153
|
-
children: errorMessage
|
|
154
|
-
}) : null]
|
|
155
|
-
}) : null]
|
|
145
|
+
}), /* @__PURE__ */ jsx(FieldHelper, {
|
|
146
|
+
className: classNames,
|
|
147
|
+
description,
|
|
148
|
+
errorMessage,
|
|
149
|
+
ids,
|
|
150
|
+
invalid
|
|
151
|
+
})]
|
|
156
152
|
});
|
|
157
153
|
};
|
|
158
|
-
|
|
159
|
-
//#region src/Switch/Switch.tsx
|
|
154
|
+
// src/Switch/Switch.tsx
|
|
160
155
|
/** Form toggle field for a boolean value */
|
|
161
156
|
const Switch = ({ className = void 0, endContent = void 0, name, size = "md", startContent = void 0, thumbIcon = void 0, ...uniformProps }) => {
|
|
162
157
|
const { field } = useUniformField({
|
|
@@ -172,10 +167,8 @@ const Switch = ({ className = void 0, endContent = void 0, name, size = "md", st
|
|
|
172
167
|
thumbIcon
|
|
173
168
|
});
|
|
174
169
|
};
|
|
175
|
-
|
|
176
|
-
//#region src/Switch/index.ts
|
|
170
|
+
// src/Switch/index.ts
|
|
177
171
|
var Switch_default = Switch;
|
|
178
|
-
//#endregion
|
|
179
172
|
export { Switch_default as default, switchVariants };
|
|
180
173
|
|
|
181
174
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/Switch/subcomponents/SwitchIcon.tsx","../../src/Switch/subcomponents/SwitchThumb.tsx","../../src/Switch/subcomponents/SwitchTrack.tsx","../../src/Switch/subcomponents/SwitchControl.tsx","../../src/Switch/Switch.tsx","../../src/Switch/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cloneElement, isValidElement } from 'react';\n\ninterface SwitchIconProps {\n /** Icon content */\n children: ReactNode;\n /** CSS class name */\n className: string;\n}\n\n/** Applies switch icon dimensions and slot styling to an element */\nconst SwitchIcon = ({ children, className }: SwitchIconProps) => {\n return (\n <>\n {isValidElement<{ className?: string; width?: string; height?: string }>(\n children,\n )\n ? cloneElement(children, { width: '1em', height: '1em', className })\n : children}\n </>\n );\n};\n\nexport default SwitchIcon;\n","import type { ReactNode } from 'react';\n\nimport SwitchIcon from './SwitchIcon';\n\nexport interface SwitchThumbIconProps {\n /** CSS class name */\n className: string;\n /** Selected state as a string */\n 'data-checked': string;\n /** Icon height */\n height: string;\n /** Current toggle state */\n isSelected: boolean;\n /** Icon width */\n width: string;\n}\n\ninterface SwitchThumbProps {\n /** CSS class name */\n className: string;\n /** Current toggle state supplied to the icon callback */\n selected: boolean;\n /** Content or render callback inside the toggle thumb */\n thumbIcon?: ReactNode | ((props: SwitchThumbIconProps) => ReactNode);\n}\n\n/** Thumb icon content, including the consumer's selection-aware render callback */\nconst SwitchThumb = ({\n className,\n selected,\n thumbIcon = undefined,\n}: SwitchThumbProps) => {\n return (\n <>\n {typeof thumbIcon === 'function' ? (\n thumbIcon({\n width: '1em',\n height: '1em',\n className,\n 'data-checked': String(selected),\n isSelected: selected,\n })\n ) : (\n <SwitchIcon className={className}>{thumbIcon}</SwitchIcon>\n )}\n </>\n );\n};\n\nexport default SwitchThumb;\n","import type { SwitchProps } from '../Switch';\n\nimport SwitchIcon from './SwitchIcon';\nimport SwitchThumb from './SwitchThumb';\n\ninterface SwitchTrackProps extends Pick<\n SwitchProps,\n 'endContent' | 'startContent' | 'thumbIcon'\n> {\n /** CSS class name */\n className: Record<\n 'endContent' | 'startContent' | 'thumb' | 'thumbIcon' | 'wrapper',\n string\n >;\n /** Current toggle state supplied to the thumb */\n selected: boolean;\n}\n\n/** Visual switch track, thumb and optional leading and trailing icons */\nconst SwitchTrack = ({\n className: classNames,\n endContent,\n selected,\n startContent,\n thumbIcon,\n}: SwitchTrackProps) => {\n return (\n <span aria-hidden className={classNames.wrapper} data-slot=\"wrapper\">\n {startContent ? (\n <SwitchIcon className={classNames.startContent}>\n {startContent}\n </SwitchIcon>\n ) : null}\n <span className={classNames.thumb} data-slot=\"thumb\">\n <SwitchThumb\n className={classNames.thumbIcon}\n selected={selected}\n thumbIcon={thumbIcon}\n />\n </span>\n {endContent ? (\n <SwitchIcon className={classNames.endContent}>{endContent}</SwitchIcon>\n ) : null}\n </span>\n );\n};\n\nexport default SwitchTrack;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { SwitchProps } from '../Switch';\n\nimport { mergeProps } from 'react-aria/mergeProps';\nimport { useFocusRing } from 'react-aria/useFocusRing';\nimport { useHover } from 'react-aria/useHover';\nimport { useObjectRef } from 'react-aria/useObjectRef';\nimport { useSwitch } from 'react-aria/useSwitch';\nimport { VisuallyHidden } from 'react-aria/VisuallyHidden';\nimport { useToggleState } from 'react-stately/useToggleState';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldDescription from '../../partials/FieldDescription/FieldDescription';\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { switchVariants } from '../switchVariants';\nimport SwitchTrack from './SwitchTrack';\n\ninterface SwitchControlProps extends Pick<\n SwitchProps,\n 'className' | 'endContent' | 'size' | 'startContent' | 'thumbIcon'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, boolean>;\n}\n\n/**\n * Switch presentation with native input, focus and thumb content\n *\n * @see https://react-aria.adobe.com/useSwitch\n */\nconst SwitchControl = ({\n field,\n className,\n size,\n thumbIcon,\n endContent,\n startContent,\n}: SwitchControlProps) => {\n const {\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label,\n name,\n onBlur,\n onChange: onValueChange,\n required,\n testId,\n value,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n const controlRef = useObjectRef<HTMLInputElement>(inputRef);\n const state = useToggleState({\n isSelected: !!value,\n onChange: onValueChange,\n });\n const { inputProps, labelProps, isPressed } = useSwitch(\n {\n ...controlProps,\n children: label,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n name,\n onBlur,\n validationBehavior: 'aria',\n },\n state,\n controlRef,\n );\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const { hoverProps, isHovered } = useHover({ isDisabled: disabled });\n\n // classNames from slots\n const variants = styling.resolve(switchVariants, { size, disabled });\n const classNames = styling.variantsToClassNames(\n variants,\n className,\n 'outerWrapper',\n );\n\n return (\n <div\n className={classNames.outerWrapper}\n data-component=\"switch\"\n data-slot=\"outer-wrapper\"\n >\n <label\n {...mergeProps(labelProps, hoverProps)}\n className={classNames.base}\n data-disabled={disabled ? true : undefined}\n data-focus={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-hover={isHovered || undefined}\n data-invalid={invalid}\n data-pressed={isPressed || undefined}\n data-required={required}\n data-selected={state.isSelected || undefined}\n data-slot=\"base\"\n data-testid={testId}\n htmlFor={ids.control}\n >\n {/* native toggle for keyboard and assistive technology */}\n <VisuallyHidden elementType=\"span\">\n <input\n {...mergeProps(inputProps, focusProps, controlProps)}\n ref={controlRef}\n data-slot=\"input\"\n />\n </VisuallyHidden>\n\n {/* toggle track and thumb */}\n <SwitchTrack\n className={classNames}\n endContent={endContent}\n selected={state.isSelected}\n startContent={startContent}\n thumbIcon={thumbIcon}\n />\n {label ? (\n <FieldLabel\n as=\"span\"\n className={classNames.label}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n ) : null}\n </label>\n\n {/* help text and validation messages */}\n {description || invalid ? (\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldDescription\n className={classNames.description}\n id={ids.description}\n >\n {description}\n </FieldDescription>\n {invalid ? (\n <div\n className={classNames.errorMessage}\n data-slot=\"error-message\"\n id={ids.error}\n >\n {errorMessage}\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SwitchControl;\n","import type { ReactNode } from 'react';\nimport type { SwitchThumbIconProps } from './subcomponents/SwitchThumb';\nimport type { ClassName } from './switchVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport SwitchControl from './subcomponents/SwitchControl';\n\nexport type { SwitchThumbIconProps } from './subcomponents/SwitchThumb';\n\nexport { switchVariants } from './switchVariants';\n\nexport interface SwitchProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** Field label */\n label?: ReactNode;\n /** Field name */\n name: string;\n /** Control size */\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 for e2e tests */\n testId?: string;\n /** Content or render callback inside the toggle thumb */\n thumbIcon?: ReactNode | ((props: SwitchThumbIconProps) => ReactNode);\n}\n\n/** Form toggle field for a boolean value */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = 'md',\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformProps\n}: SwitchProps) => {\n const { field } = useUniformField({\n ...uniformProps,\n name,\n });\n\n return (\n <SwitchControl\n className={className}\n endContent={endContent}\n field={field}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { switchVariants } from './Switch';\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;;;;;AAYA,MAAM,cAAc,EAAE,UAAU,gBAAiC;CAC/D,OACE,oBAAA,UAAA,EAAA,UACG,eACC,QACF,IACI,aAAa,UAAU;EAAE,OAAO;EAAO,QAAQ;EAAO;CAAU,CAAC,IACjE,SACJ,CAAA;AAEN;;;;ACKA,MAAM,eAAe,EACnB,WACA,UACA,YAAY,KAAA,QACU;CACtB,OACE,oBAAA,UAAA,EAAA,UACG,OAAO,cAAc,aACpB,UAAU;EACR,OAAO;EACP,QAAQ;EACR;EACA,gBAAgB,OAAO,QAAQ;EAC/B,YAAY;CACd,CAAC,IAED,oBAAC,YAAD;EAAuB;EAAY,UAAA;CAAsB,CAAA,EAE3D,CAAA;AAEN;;;;AC5BA,MAAM,eAAe,EACnB,WAAW,YACX,YACA,UACA,cACA,gBACsB;CACtB,OACE,qBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,WAAW;EAAS,aAAU;EAA3D,UAAA;GACG,eACC,oBAAC,YAAD;IAAY,WAAW,WAAW;IAC/B,UAAA;GACS,CAAA,IACV;GACJ,oBAAC,QAAD;IAAM,WAAW,WAAW;IAAO,aAAU;IAC3C,UAAA,oBAAC,aAAD;KACE,WAAW,WAAW;KACZ;KACC;IACZ,CAAA;GACG,CAAA;GACL,aACC,oBAAC,YAAD;IAAY,WAAW,WAAW;IAA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ACX,CAAA;IACa,CAAA;IAGhB,oBAAC,aAAD;KACE,WAAW;KACC;KACZ,UAAU,MAAM;KACF;KACH;IACZ,CAAA;IACA,QACC,oBAAC,YAAD;KACE,IAAG;KACH,WAAW,WAAW;KACtB,IAAI,IAAI;KACE;KAET,UAAA;IACS,CAAA,IACV;GACC;EAGN,CAAA,GAAA,eAAe,UACd,qBAAC,OAAD;GAAK,WAAW,WAAW;GAAe,aAAU;GAApD,UAAA,CACE,oBAAC,kBAAD;IACE,WAAW,WAAW;IACtB,IAAI,IAAI;IAEP,UAAA;GACe,CAAA,GACjB,UACC,oBAAC,OAAD;IACE,WAAW,WAAW;IACtB,aAAU;IACV,IAAI,IAAI;IAEP,UAAA;GACE,CAAA,IACH,IACD;EACH,CAAA,IAAA,IACD;;AAET;;;;AC7HA,MAAM,UAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,MACA,OAAO,MACP,eAAe,KAAA,GACf,YAAY,KAAA,GACZ,GAAG,mBACc;CACjB,MAAM,EAAE,UAAU,gBAAgB;EAChC,GAAG;EACH;CACF,CAAC;CAED,OACE,oBAAC,eAAD;EACa;EACC;EACL;EACD;EACQ;EACH;CACZ,CAAA;AAEL;;;ACvDA,IAAA,iBAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/Switch/subcomponents/SwitchIcon.tsx","../../src/Switch/subcomponents/SwitchThumb.tsx","../../src/Switch/subcomponents/SwitchTrack.tsx","../../src/Switch/subcomponents/SwitchControl.tsx","../../src/Switch/Switch.tsx","../../src/Switch/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cloneElement, isValidElement } from 'react';\n\ninterface SwitchIconProps {\n /** Icon content */\n children: ReactNode;\n /** CSS class name */\n className: string;\n}\n\n/** Applies switch icon dimensions and slot styling to an element */\nconst SwitchIcon = ({ children, className }: SwitchIconProps) => {\n return (\n <>\n {isValidElement<{ className?: string; width?: string; height?: string }>(\n children,\n )\n ? cloneElement(children, { width: '1em', height: '1em', className })\n : children}\n </>\n );\n};\n\nexport default SwitchIcon;\n","import type { ReactNode } from 'react';\n\nimport SwitchIcon from './SwitchIcon';\n\nexport interface SwitchThumbIconProps {\n /** CSS class name */\n className: string;\n /** Selected state as a string */\n 'data-checked': string;\n /** Icon height */\n height: string;\n /** Current toggle state */\n isSelected: boolean;\n /** Icon width */\n width: string;\n}\n\ninterface SwitchThumbProps {\n /** CSS class name */\n className: string;\n /** Current toggle state supplied to the icon callback */\n selected: boolean;\n /** Content or render callback inside the toggle thumb */\n thumbIcon?: ReactNode | ((props: SwitchThumbIconProps) => ReactNode);\n}\n\n/** Thumb icon content, including the consumer's selection-aware render callback */\nconst SwitchThumb = ({\n className,\n selected,\n thumbIcon = undefined,\n}: SwitchThumbProps) => {\n return (\n <>\n {typeof thumbIcon === 'function' ? (\n thumbIcon({\n width: '1em',\n height: '1em',\n className,\n 'data-checked': String(selected),\n isSelected: selected,\n })\n ) : (\n <SwitchIcon className={className}>{thumbIcon}</SwitchIcon>\n )}\n </>\n );\n};\n\nexport default SwitchThumb;\n","import type { SwitchProps } from '../Switch';\n\nimport SwitchIcon from './SwitchIcon';\nimport SwitchThumb from './SwitchThumb';\n\ninterface SwitchTrackProps extends Pick<\n SwitchProps,\n 'endContent' | 'startContent' | 'thumbIcon'\n> {\n /** CSS class name */\n className: Record<\n 'endContent' | 'startContent' | 'thumb' | 'thumbIcon' | 'wrapper',\n string\n >;\n /** Current toggle state supplied to the thumb */\n selected: boolean;\n}\n\n/** Visual switch track, thumb and optional leading and trailing icons */\nconst SwitchTrack = ({\n className: classNames,\n endContent,\n selected,\n startContent,\n thumbIcon,\n}: SwitchTrackProps) => {\n return (\n <span aria-hidden className={classNames.wrapper} data-slot=\"wrapper\">\n {startContent ? (\n <SwitchIcon className={classNames.startContent}>\n {startContent}\n </SwitchIcon>\n ) : null}\n <span className={classNames.thumb} data-slot=\"thumb\">\n <SwitchThumb\n className={classNames.thumbIcon}\n selected={selected}\n thumbIcon={thumbIcon}\n />\n </span>\n {endContent ? (\n <SwitchIcon className={classNames.endContent}>{endContent}</SwitchIcon>\n ) : null}\n </span>\n );\n};\n\nexport default SwitchTrack;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { SwitchProps } from '../Switch';\n\nimport { mergeProps } from 'react-aria/mergeProps';\nimport { useFocusRing } from 'react-aria/useFocusRing';\nimport { useHover } from 'react-aria/useHover';\nimport { useObjectRef } from 'react-aria/useObjectRef';\nimport { useSwitch } from 'react-aria/useSwitch';\nimport { VisuallyHidden } from 'react-aria/VisuallyHidden';\nimport { useToggleState } from 'react-stately/useToggleState';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldHelper from '../../partials/FieldHelper/FieldHelper';\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { switchVariants } from '../switchVariants';\nimport SwitchTrack from './SwitchTrack';\n\ninterface SwitchControlProps extends Pick<\n SwitchProps,\n 'className' | 'endContent' | 'size' | 'startContent' | 'thumbIcon'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, boolean>;\n}\n\n/**\n * Switch presentation with native input, focus and thumb content\n *\n * @see https://react-aria.adobe.com/useSwitch\n */\nconst SwitchControl = ({\n field,\n className,\n size,\n thumbIcon,\n endContent,\n startContent,\n}: SwitchControlProps) => {\n const {\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label,\n name,\n onBlur,\n onChange: onValueChange,\n readOnly,\n required,\n testId,\n value,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n const controlRef = useObjectRef<HTMLInputElement>(inputRef);\n const state = useToggleState({\n isReadOnly: readOnly,\n isSelected: !!value,\n onChange: onValueChange,\n });\n const { inputProps, labelProps, isPressed } = useSwitch(\n {\n ...controlProps,\n children: label,\n isDisabled: disabled,\n isInvalid: invalid,\n isReadOnly: readOnly,\n isRequired: required,\n name,\n onBlur,\n validationBehavior: 'aria',\n },\n state,\n controlRef,\n );\n const { focusProps, isFocused, isFocusVisible } = useFocusRing();\n const { hoverProps, isHovered } = useHover({ isDisabled: disabled });\n\n // classNames from slots\n const variants = styling.resolve(switchVariants, {\n disabled,\n readOnly,\n size,\n });\n const classNames = styling.variantsToClassNames(\n variants,\n className,\n 'outerWrapper',\n );\n\n return (\n <div\n className={classNames.outerWrapper}\n data-component=\"switch\"\n data-slot=\"outer-wrapper\"\n >\n <label\n {...mergeProps(labelProps, hoverProps)}\n className={classNames.base}\n data-disabled={disabled ? true : undefined}\n data-focus={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-hover={isHovered || undefined}\n data-invalid={invalid}\n data-pressed={isPressed || undefined}\n data-readonly={readOnly || undefined}\n data-required={required}\n data-selected={state.isSelected || undefined}\n data-slot=\"base\"\n data-testid={testId}\n htmlFor={ids.control}\n >\n {/* native toggle for keyboard and assistive technology */}\n <VisuallyHidden elementType=\"span\">\n <input\n {...mergeProps(inputProps, focusProps, controlProps)}\n ref={controlRef}\n data-slot=\"input\"\n />\n </VisuallyHidden>\n\n {/* toggle track and thumb */}\n <SwitchTrack\n className={classNames}\n endContent={endContent}\n selected={state.isSelected}\n startContent={startContent}\n thumbIcon={thumbIcon}\n />\n {label ? (\n <FieldLabel\n as=\"span\"\n className={classNames.label}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n ) : null}\n </label>\n\n {/* help text and validation messages */}\n <FieldHelper\n className={classNames}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n />\n </div>\n );\n};\n\nexport default SwitchControl;\n","import type { ReactNode } from 'react';\nimport type { SwitchThumbIconProps } from './subcomponents/SwitchThumb';\nimport type { ClassName } from './switchVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport SwitchControl from './subcomponents/SwitchControl';\n\nexport type { SwitchThumbIconProps } from './subcomponents/SwitchThumb';\n\nexport { switchVariants } from './switchVariants';\n\nexport interface SwitchProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** Field label */\n label?: ReactNode;\n /** Field name */\n name: string;\n /** Prevents toggling while keeping the value in validation and submission */\n readOnly?: boolean;\n /** Control size */\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 for e2e tests */\n testId?: string;\n /** Content or render callback inside the toggle thumb */\n thumbIcon?: ReactNode | ((props: SwitchThumbIconProps) => ReactNode);\n}\n\n/** Form toggle field for a boolean value */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = 'md',\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformProps\n}: SwitchProps) => {\n const { field } = useUniformField({\n ...uniformProps,\n name,\n });\n\n return (\n <SwitchControl\n className={className}\n endContent={endContent}\n field={field}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { switchVariants } from './Switch';\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAM,cAAc,EAAE,UAAU,gBAAiC;CAC/D,OACE,oBAAA,UAAA,EAAA,UACG,eACC,QACF,IACI,aAAa,UAAU;EAAE,OAAO;EAAO,QAAQ;EAAO;CAAU,CAAC,IACjE,SACJ,CAAA;AAEN;;;ACKA,MAAM,eAAe,EACnB,WACA,UACA,YAAY,KAAA,QACU;CACtB,OACE,oBAAA,UAAA,EAAA,UACG,OAAO,cAAc,aACpB,UAAU;EACR,OAAO;EACP,QAAQ;EACR;EACA,gBAAgB,OAAO,QAAQ;EAC/B,YAAY;CACd,CAAC,IAED,oBAAC,YAAD;EAAuB;EA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