@fuf-stack/uniform 2.0.0-next.3 → 2.0.0-next.5
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 +50 -50
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +14 -12
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +27 -90
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +31 -39
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +6 -6
- package/dist/FieldArray/index.mjs +19 -17
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.mjs +10 -13
- package/dist/FieldCard/index.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-DcvQU0zN.mjs → FieldLayout-C9MEBZAC.mjs} +10 -17
- package/dist/FieldLayout-C9MEBZAC.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +1 -1
- package/dist/FieldReset/index.mjs +1 -1
- package/dist/{FieldValidationError-iAayfTEw.mjs → FieldValidationError-BuLvuRyi.mjs} +3 -3
- package/dist/FieldValidationError-BuLvuRyi.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.mjs +4 -4
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-PXkVlBdU.mjs → FormContext-CVq3glVW.mjs} +5 -5
- package/dist/FormContext-CVq3glVW.mjs.map +1 -0
- package/dist/{FormContext-BnNJYZOo.d.mts → FormContext-Dvt3MiKq.d.mts} +3 -3
- package/dist/{FormContext-BnNJYZOo.d.mts.map → FormContext-Dvt3MiKq.d.mts.map} +1 -1
- package/dist/Input/index.d.mts +583 -418
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +16 -19
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +101 -85
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +6 -14
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +590 -335
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +15 -15
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +52 -49
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +5 -13
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +762 -570
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +14 -15
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +658 -348
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +24 -32
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +1 -1
- package/dist/Switch/index.mjs +12 -17
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-3ujfKWwt.d.mts +990 -0
- package/dist/{Switch-Db2dpGz7.d.mts.map → Switch-3ujfKWwt.d.mts.map} +1 -1
- package/dist/SwitchBox/index.d.mts +583 -221
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +14 -18
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +544 -207
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +13 -16
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +47 -47
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +17 -22
- 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-X_0s1Lhu.mjs → fieldProps-DWfz2jSO.mjs} +2 -13
- package/dist/fieldProps-DWfz2jSO.mjs.map +1 -0
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +1 -1
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{Switch-Db2dpGz7.d.mts → partials/FieldHelper/index.d.mts} +308 -407
- 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 -13
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/{radioControlVariants-BYRfaD6y.mjs → radioControlVariants-CxA0og5-.mjs} +16 -12
- package/dist/radioControlVariants-CxA0og5-.mjs.map +1 -0
- package/dist/{switchVariants-D16b2VaT.mjs → switchVariants-B8dq8DYP.mjs} +12 -15
- package/dist/switchVariants-B8dq8DYP.mjs.map +1 -0
- package/dist/{timeVariants-CtXyNKmW.mjs → timeVariants-CIX6R59-.mjs} +17 -15
- package/dist/timeVariants-CIX6R59-.mjs.map +1 -0
- package/dist/{useController-JtIeurpw.mjs → useController-SEAuP3G4.mjs} +6 -6
- package/dist/useController-SEAuP3G4.mjs.map +1 -0
- package/dist/{useFormContext-piqnN2L-.mjs → useFormContext-CQzJhAU4.mjs} +12 -8
- package/dist/useFormContext-CQzJhAU4.mjs.map +1 -0
- package/dist/{FieldLabel-DrNWJIVh.mjs → useUniformField-BvPoQyLL.mjs} +6 -31
- package/dist/useUniformField-BvPoQyLL.mjs.map +1 -0
- package/package.json +6 -4
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +0 -1
- package/dist/FieldLabel-DrNWJIVh.mjs.map +0 -1
- package/dist/FieldLayout-DcvQU0zN.mjs.map +0 -1
- package/dist/FieldValidationError-iAayfTEw.mjs.map +0 -1
- package/dist/FormContext-PXkVlBdU.mjs.map +0 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +0 -1
- package/dist/switchVariants-D16b2VaT.mjs.map +0 -1
- package/dist/timeVariants-CtXyNKmW.mjs.map +0 -1
- package/dist/useController-JtIeurpw.mjs.map +0 -1
- package/dist/useFormContext-piqnN2L-.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.ts","../../src/Slider/Slider.tsx"],"mappings":";;;qBAOa,kBAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAA,SAAA,qBAYb,gCAAW,IAAA"}
|
package/dist/Slider/index.mjs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as useUniformField } from "../useUniformField-BvPoQyLL.mjs";
|
|
2
2
|
import { isValueEmpty } from "../helpers/index.mjs";
|
|
3
|
-
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";
|
|
4
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
|
-
import { Label, Slider, SliderFill, SliderOutput, SliderThumb, SliderTrack } from "react-aria-components";
|
|
12
|
+
import { Label, Slider as Slider$1, 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: [
|
|
@@ -34,10 +33,10 @@ const sliderVariants = tv({
|
|
|
34
33
|
"group-data-[invalid=true]:data-[focused=true]:outline-2",
|
|
35
34
|
"group-data-[invalid=true]:data-[focused=true]:outline-focus",
|
|
36
35
|
"group-data-[invalid=true]:data-[focused=true]:outline-offset-2",
|
|
37
|
-
"
|
|
36
|
+
"top-1/2 flex h-6 w-6 cursor-grab items-center justify-center rounded-full border-0 bg-primary shadow-small ring-transparent outline-transparent outline-solid",
|
|
38
37
|
"before:absolute before:h-11 before:w-11 before:rounded-full before:content-['']",
|
|
39
38
|
"after:h-5 after:w-5 after:rounded-full after:bg-background after:shadow-small after:transition-all after:content-['']",
|
|
40
|
-
"data-[
|
|
39
|
+
"data-[dragging=true]:cursor-grabbing data-[focus-visible=true]:z-10 data-[focused=true]:z-10",
|
|
41
40
|
"data-[focus-visible=true]:outline-2 data-[focus-visible=true]:outline-offset-2 data-[focus-visible=true]:outline-focus",
|
|
42
41
|
"data-[dragging=true]:after:scale-80 motion-reduce:after:transition-none"
|
|
43
42
|
],
|
|
@@ -220,7 +219,7 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
220
219
|
id: `${ids.control}-required`,
|
|
221
220
|
children: "Required selection."
|
|
222
221
|
}) : null,
|
|
223
|
-
/* @__PURE__ */ jsxs(Slider, {
|
|
222
|
+
/* @__PURE__ */ jsxs(Slider$1, {
|
|
224
223
|
"aria-invalid": associations["aria-invalid"],
|
|
225
224
|
"aria-label": associations["aria-label"],
|
|
226
225
|
id: associations.id,
|
|
@@ -264,26 +263,19 @@ const SliderControl = ({ field, className, endContent, fillOffset, maxValue = 10
|
|
|
264
263
|
step
|
|
265
264
|
})]
|
|
266
265
|
}),
|
|
267
|
-
|
|
268
|
-
className: classNames
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}), invalid ? /* @__PURE__ */ jsx("div", {
|
|
275
|
-
className: classNames.errorMessage,
|
|
276
|
-
"data-slot": "error-message",
|
|
277
|
-
id: ids.error,
|
|
278
|
-
children: errorMessage
|
|
279
|
-
}) : null]
|
|
280
|
-
}) : null
|
|
266
|
+
/* @__PURE__ */ jsx(FieldHelper, {
|
|
267
|
+
className: classNames,
|
|
268
|
+
description,
|
|
269
|
+
errorMessage,
|
|
270
|
+
ids,
|
|
271
|
+
invalid
|
|
272
|
+
})
|
|
281
273
|
]
|
|
282
274
|
});
|
|
283
275
|
};
|
|
284
276
|
// src/Slider/Slider.tsx
|
|
285
277
|
/** Form input field for choosing a numeric value along a track */
|
|
286
|
-
const Slider
|
|
278
|
+
const Slider = ({ className = void 0, endContent = void 0, fillOffset = void 0, maxValue = 100, minValue = 0, name, showSteps = false, size = "md", startContent = void 0, step = 1, ...uniformFieldProps }) => {
|
|
287
279
|
const { field, getValues } = useUniformField({
|
|
288
280
|
...uniformFieldProps,
|
|
289
281
|
name
|
|
@@ -306,7 +298,7 @@ const Slider$1 = ({ className = void 0, endContent = void 0, fillOffset = void 0
|
|
|
306
298
|
});
|
|
307
299
|
};
|
|
308
300
|
// src/Slider/index.ts
|
|
309
|
-
var Slider_default = Slider
|
|
301
|
+
var Slider_default = Slider;
|
|
310
302
|
export { Slider_default as default, sliderVariants };
|
|
311
303
|
|
|
312
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 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 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 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 {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 /** 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":";;;;;;;;;;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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,OACE,oBAAC,eAAD;EACa;EACC;EACL;EACK;EACK;EACP;EACA;EACC;EACL;EACQ;EACR;CACP,CAAA;AAEL;;AC1FA,IAAA,iBAAeC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["AriaSlider"],"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 'top-1/2 flex h-6 w-6 cursor-grab items-center justify-center rounded-full border-0 bg-primary shadow-small ring-transparent outline-transparent outline-solid',\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-[dragging=true]:cursor-grabbing data-[focus-visible=true]:z-10 data-[focused=true]:z-10',\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":";;;;;;;;;;;;;;AAOA,MAAa,iBAAiB,GAAG;CAC/B,QAAQ;CACR,OAAO;EACL,MAAM,CAEJ,SAEA,sBACF;EACA,YAAY;EACZ,QAAQ,CAAC,IAAI,4BAA4B;EAEzC,eAAe;EAGf,OAAO,CAAC,mBAAmB,MAAM,MAAM;EACvC,cAAc;EACd,MAAM;EACN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1FA,IAAA,iBAAe"}
|
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-3ujfKWwt.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-BvPoQyLL.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-B8dq8DYP.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";
|
|
@@ -140,20 +142,13 @@ const SwitchControl = ({ field, className, size, thumbIcon, endContent, startCon
|
|
|
140
142
|
children: label
|
|
141
143
|
}) : null
|
|
142
144
|
]
|
|
143
|
-
}),
|
|
144
|
-
className: classNames
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}), invalid ? /* @__PURE__ */ jsx("div", {
|
|
151
|
-
className: classNames.errorMessage,
|
|
152
|
-
"data-slot": "error-message",
|
|
153
|
-
id: ids.error,
|
|
154
|
-
children: errorMessage
|
|
155
|
-
}) : null]
|
|
156
|
-
}) : null]
|
|
145
|
+
}), /* @__PURE__ */ jsx(FieldHelper, {
|
|
146
|
+
className: classNames,
|
|
147
|
+
description,
|
|
148
|
+
errorMessage,
|
|
149
|
+
ids,
|
|
150
|
+
invalid
|
|
151
|
+
})]
|
|
157
152
|
});
|
|
158
153
|
};
|
|
159
154
|
// src/Switch/Switch.tsx
|
|
@@ -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 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 {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 /** 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;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;IAAa,UAAA;GAAuB,CAAA,IACpE;EACA;;AAEV;;;;;;;ACbA,MAAM,iBAAiB,EACrB,OACA,WACA,MACA,WACA,YAC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D;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;;;ACnIA,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;;ACzDA,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;EAAY,UAAA;CAAsB,CAAA,EAE3D,CAAA;AAEN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