@yamada-ui/react 2.3.4-dev-20261116070336 → 2.3.4-dev-20261116074825

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.
Files changed (39) hide show
  1. package/dist/cjs/components/password-input/use-password-input.cjs +7 -24
  2. package/dist/cjs/components/password-input/use-password-input.cjs.map +1 -1
  3. package/dist/cjs/components/pin-input/use-pin-input.cjs +1 -4
  4. package/dist/cjs/components/pin-input/use-pin-input.cjs.map +1 -1
  5. package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs +1 -3
  6. package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
  7. package/dist/cjs/components/slider/use-slider.cjs +5 -16
  8. package/dist/cjs/components/slider/use-slider.cjs.map +1 -1
  9. package/dist/esm/components/password-input/use-password-input.js +7 -24
  10. package/dist/esm/components/password-input/use-password-input.js.map +1 -1
  11. package/dist/esm/components/pin-input/use-pin-input.js +1 -4
  12. package/dist/esm/components/pin-input/use-pin-input.js.map +1 -1
  13. package/dist/esm/components/saturation-slider/use-saturation-slider.js +1 -3
  14. package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
  15. package/dist/esm/components/slider/use-slider.js +5 -16
  16. package/dist/esm/components/slider/use-slider.js.map +1 -1
  17. package/dist/types/components/alert/alert.style.d.ts +1 -1
  18. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  19. package/dist/types/components/checkbox-card/checkbox-card.d.ts +3 -3
  20. package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
  21. package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
  22. package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
  23. package/dist/types/components/data-list/data-list.style.d.ts +1 -1
  24. package/dist/types/components/drawer/drawer.style.d.ts +2 -2
  25. package/dist/types/components/dropzone/dropzone.d.ts +1 -1
  26. package/dist/types/components/dropzone/dropzone.style.d.ts +1 -1
  27. package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
  28. package/dist/types/components/file-input/file-input.style.d.ts +1 -1
  29. package/dist/types/components/form/form.style.d.ts +1 -1
  30. package/dist/types/components/modal/modal.style.d.ts +2 -2
  31. package/dist/types/components/notice/notice.style.d.ts +1 -1
  32. package/dist/types/components/radio-card/radio-card.d.ts +3 -3
  33. package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
  34. package/dist/types/components/steps/steps.style.d.ts +1 -1
  35. package/dist/types/components/tag/tag.style.d.ts +1 -1
  36. package/dist/types/components/timeline/timeline.d.ts +1 -1
  37. package/dist/types/components/timeline/timeline.style.d.ts +1 -1
  38. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
  39. package/package.json +1 -1
@@ -1,9 +1,7 @@
1
1
  "use client";
2
- const require_ref = require("../../utils/ref.cjs");
3
2
  const require_props = require("../../core/components/props.cjs");
4
3
  const require_hooks_use_controllable_state_index = require("../../hooks/use-controllable-state/index.cjs");
5
4
  const require_i18n_provider = require("../../providers/i18n-provider/i18n-provider.cjs");
6
- const require_utils_index = require("../../utils/index.cjs");
7
5
  const require_use_field_props = require("../field/use-field-props.cjs");
8
6
  let react = require("react");
9
7
  // src/components/password-input/use-password-input.tsx
@@ -20,22 +18,10 @@ const usePasswordInput = (props = {}) => {
20
18
  ev.preventDefault();
21
19
  setVisible((prev) => !prev);
22
20
  }, [disabled, setVisible]);
23
- const getInputProps = (0, react.useCallback)(({ ref, ...props } = {}) => {
24
- return {
25
- ...require_props.mergeProps({
26
- type: visible ? "text" : "password",
27
- disabled,
28
- ...ariaProps,
29
- ...dataProps
30
- }, rest, props)({
31
- mergeEvent: false,
32
- mergeRef: false
33
- }),
34
- ref: require_ref.mergeRefs(ref, rest.ref),
35
- onBlur: (0, require_utils_index.utils_exports.handlerAll)(eventProps.onBlur, props.onBlur),
36
- onFocus: (0, require_utils_index.utils_exports.handlerAll)(eventProps.onFocus, props.onFocus)
37
- };
38
- }, [
21
+ const getInputProps = (0, react.useCallback)((props = {}) => require_props.mergeProps(ariaProps, dataProps, eventProps, {
22
+ type: visible ? "text" : "password",
23
+ disabled
24
+ }, rest, props)(), [
39
25
  visible,
40
26
  rest,
41
27
  disabled,
@@ -46,14 +32,11 @@ const usePasswordInput = (props = {}) => {
46
32
  return {
47
33
  setVisible,
48
34
  visible,
49
- getButtonProps: (0, react.useCallback)((props = {}) => ({
35
+ getButtonProps: (0, react.useCallback)((props = {}) => require_props.mergeProps(dataProps, {
50
36
  type: "button",
51
37
  "aria-label": t("Toggle password visibility"),
52
- disabled,
53
- ...dataProps,
54
- ...props,
55
- onClick: (0, require_utils_index.utils_exports.handlerAll)(props.onClick, onChangeVisibility)
56
- }), [
38
+ disabled
39
+ }, props, { onClick: onChangeVisibility })(), [
57
40
  onChangeVisibility,
58
41
  dataProps,
59
42
  disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"use-password-input.cjs","names":["useFieldProps","useControllableState","useI18n","useCallback","mergeProps","mergeRefs"],"sources":["../../../../src/components/password-input/use-password-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { handlerAll, mergeRefs } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UsePasswordInputProps extends HTMLProps<\"input\">, FieldProps {\n /**\n * Determines whether the password input is visible by default.\n *\n * @default false\n */\n defaultVisible?: boolean\n /**\n * Determines the visibility of the password input.\n *\n * @default false\n */\n visible?: boolean\n /**\n * Callback function that is triggered when the visibility of the password input changes.\n */\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport const usePasswordInput = (props: UsePasswordInputProps = {}) => {\n const {\n props: {\n defaultVisible,\n disabled,\n visible: visibleProp,\n onVisibleChange,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [visible, setVisible] = useControllableState({\n defaultValue: defaultVisible,\n value: visibleProp,\n onChange: onVisibleChange,\n })\n const { t } = useI18n(\"passwordInput\")\n\n const onChangeVisibility = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (disabled || ev.button !== 0) return\n\n ev.preventDefault()\n\n setVisible((prev) => !prev)\n },\n [disabled, setVisible],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => {\n const mergedProps = mergeProps(\n {\n type: visible ? \"text\" : \"password\",\n disabled,\n ...ariaProps,\n ...dataProps,\n },\n rest,\n props,\n )({\n mergeEvent: false,\n mergeRef: false,\n })\n\n return {\n ...mergedProps,\n ref: mergeRefs(ref, rest.ref),\n onBlur: handlerAll(eventProps.onBlur, props.onBlur),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus),\n }\n },\n [visible, rest, disabled, dataProps, eventProps, ariaProps],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n type: \"button\",\n \"aria-label\": t(\"Toggle password visibility\"),\n disabled,\n ...dataProps,\n ...props,\n onClick: handlerAll(props.onClick, onChangeVisibility),\n }),\n [onChangeVisibility, dataProps, disabled, t],\n )\n\n return {\n setVisible,\n visible,\n getButtonProps,\n getInputProps,\n }\n}\n\nexport type UsePasswordInputReturn = ReturnType<typeof usePasswordInput>\n"],"mappings":";;;;;;;;;AA+BA,MAAa,oBAAoB,QAA+B,CAAC,MAAM;CACrE,MAAM,EACJ,OAAO,EACL,gBACA,UACA,SAAS,aACT,iBACA,GAAG,QAEL,WACA,WACA,eACEA,wBAAAA,cAAc,KAAK;CACvB,MAAM,CAAC,SAAS,cAAcC,2CAAAA,qBAAqB;EACjD,cAAc;EACd,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,eAAe;CAErC,MAAM,sBAAA,GAAqBC,MAAAA,YAAAA,EACxB,OAAsC;EACrC,IAAI,YAAY,GAAG,WAAW,GAAG;EAEjC,GAAG,eAAe;EAElB,YAAY,SAAS,CAAC,IAAI;CAC5B,GACA,CAAC,UAAU,UAAU,CACvB;CAEA,MAAM,iBAAA,GAAqCA,MAAAA,YAAAA,EACxC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM;EAe1B,OAAO;GACL,GAfkBC,cAAAA,WAClB;IACE,MAAM,UAAU,SAAS;IACzB;IACA,GAAG;IACH,GAAG;GACL,GACA,MACA,KACF,CAAC,CAAC;IACA,YAAY;IACZ,UAAU;GACZ,CAGe;GACb,KAAKC,YAAAA,UAAU,KAAK,KAAK,GAAG;GAC5B,SAAA,GAAA,oBAAA,cAAQ,WAAA,CAAW,WAAW,QAAQ,MAAM,MAAM;GAClD,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,WAAW,SAAS,MAAM,OAAO;EACvD;CACF,GACA;EAAC;EAAS;EAAM;EAAU;EAAW;EAAY;CAAS,CAC5D;CAcA,OAAO;EACL;EACA;EACA,iBAAA,GAf2CF,MAAAA,YAAAA,EAC1C,QAAQ,CAAC,OAAO;GACf,MAAM;GACN,cAAc,EAAE,4BAA4B;GAC5C;GACA,GAAG;GACH,GAAG;GACH,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,kBAAkB;EACvD,IACA;GAAC;GAAoB;GAAW;GAAU;EAAC,CAM9B;EACb;CACF;AACF"}
1
+ {"version":3,"file":"use-password-input.cjs","names":["useFieldProps","useControllableState","useI18n","useCallback","mergeProps"],"sources":["../../../../src/components/password-input/use-password-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UsePasswordInputProps extends HTMLProps<\"input\">, FieldProps {\n /**\n * Determines whether the password input is visible by default.\n *\n * @default false\n */\n defaultVisible?: boolean\n /**\n * Determines the visibility of the password input.\n *\n * @default false\n */\n visible?: boolean\n /**\n * Callback function that is triggered when the visibility of the password input changes.\n */\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport const usePasswordInput = (props: UsePasswordInputProps = {}) => {\n const {\n props: {\n defaultVisible,\n disabled,\n visible: visibleProp,\n onVisibleChange,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [visible, setVisible] = useControllableState({\n defaultValue: defaultVisible,\n value: visibleProp,\n onChange: onVisibleChange,\n })\n const { t } = useI18n(\"passwordInput\")\n\n const onChangeVisibility = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (disabled || ev.button !== 0) return\n\n ev.preventDefault()\n\n setVisible((prev) => !prev)\n },\n [disabled, setVisible],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) =>\n mergeProps(\n ariaProps,\n dataProps,\n eventProps,\n { type: visible ? \"text\" : \"password\", disabled },\n rest,\n props,\n )(),\n [visible, rest, disabled, dataProps, eventProps, ariaProps],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n mergeProps(\n dataProps,\n {\n type: \"button\",\n \"aria-label\": t(\"Toggle password visibility\"),\n disabled,\n },\n props,\n { onClick: onChangeVisibility },\n )(),\n [onChangeVisibility, dataProps, disabled, t],\n )\n\n return {\n setVisible,\n visible,\n getButtonProps,\n getInputProps,\n }\n}\n\nexport type UsePasswordInputReturn = ReturnType<typeof usePasswordInput>\n"],"mappings":";;;;;;;AA8BA,MAAa,oBAAoB,QAA+B,CAAC,MAAM;CACrE,MAAM,EACJ,OAAO,EACL,gBACA,UACA,SAAS,aACT,iBACA,GAAG,QAEL,WACA,WACA,eACEA,wBAAAA,cAAc,KAAK;CACvB,MAAM,CAAC,SAAS,cAAcC,2CAAAA,qBAAqB;EACjD,cAAc;EACd,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,eAAe;CAErC,MAAM,sBAAA,GAAqBC,MAAAA,YAAAA,EACxB,OAAsC;EACrC,IAAI,YAAY,GAAG,WAAW,GAAG;EAEjC,GAAG,eAAe;EAElB,YAAY,SAAS,CAAC,IAAI;CAC5B,GACA,CAAC,UAAU,UAAU,CACvB;CAEA,MAAM,iBAAA,GAAqCA,MAAAA,YAAAA,EACxC,QAAQ,CAAC,MACRC,cAAAA,WACE,WACA,WACA,YACA;EAAE,MAAM,UAAU,SAAS;EAAY;CAAS,GAChD,MACA,KACF,CAAC,CAAC,GACJ;EAAC;EAAS;EAAM;EAAU;EAAW;EAAY;CAAS,CAC5D;CAiBA,OAAO;EACL;EACA;EACA,iBAAA,GAlB2CD,MAAAA,YAAAA,EAC1C,QAAQ,CAAC,MACRC,cAAAA,WACE,WACA;GACE,MAAM;GACN,cAAc,EAAE,4BAA4B;GAC5C;EACF,GACA,OACA,EAAE,SAAS,mBAAmB,CAChC,CAAC,CAAC,GACJ;GAAC;GAAoB;GAAW;GAAU;EAAC,CAM9B;EACb;CACF;AACF"}
@@ -133,10 +133,7 @@ const usePinInput = (props = {}) => {
133
133
  return {
134
134
  descendants,
135
135
  items,
136
- getInputProps: (0, react.useCallback)(({ index, ...props }) => require_props.mergeProps({
137
- ...ariaProps,
138
- ...dataProps,
139
- ...eventProps,
136
+ getInputProps: (0, react.useCallback)(({ index, ...props }) => require_props.mergeProps(ariaProps, dataProps, eventProps, {
140
137
  type: mask ? "password" : type === "number" ? "tel" : "text",
141
138
  "aria-labelledby": labelId,
142
139
  autoComplete: otp ? "one-time-code" : "off",
@@ -1 +1 @@
1
- {"version":3,"file":"use-pin-input.cjs","names":["createDescendants","useId","useFieldProps","useState","useControllableState","useCallback","mergeProps"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0)))\n nextValue = eventValue.charAt(1)\n else if (value.startsWith(eventValue.charAt(1)))\n nextValue = eventValue.charAt(0)\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n {\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;;;;;;;AAYA,MAAM,EACJ,oBAAoB,4BACpB,eAAe,uBACf,gBAAgB,2BACdA,oCAAAA,kBAAoC;AAQxC,MAAM,WAAW,UAAmB,OAAO,MAAM,EAAE;AAEnD,MAAM,YAAY,OAAe,SAAmC;CAMlE,QAFc,SAAS,iBAAiB,oBAAsB,WAAA,CAEjD,KAAK,KAAK;AACzB;AAmEA,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,QAAA,GAAOC,MAAAA,MAAAA,CAAM;CACnB,MAAM,EACJ,SAAS,EAAE,YAAY,CAAC,GACxB,OAAO,EACL,KAAK,MACL,OAAO,UACP,WACA,cACA,UACA,QAAQ,GACR,cAAc,MACd,MACA,MAAM,OACN,cAAc,KACd,UACA,OACA,U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AS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;EAC1B,IAAA,GAAA,oBAAA,cACA,gBAAA,CAAgB,KAAK,GACrB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,KAAK;GACxB,SAAS,QAAQ,KAAK;GACtB,WAAW,UAAU,KAAK;EAC5B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAMU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"use-pin-input.cjs","names":["createDescendants","useId","useFieldProps","useState","useControllableState","useCallback","mergeProps"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0)))\n nextValue = eventValue.charAt(1)\n else if (value.startsWith(eventValue.charAt(1)))\n nextValue = eventValue.charAt(0)\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n ariaProps,\n dataProps,\n eventProps,\n {\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n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AY,WAAW;EAE1C,IAAI,CAAC,YAAY;EAEjB,4BAA4B,WAAW,KAAK,MAAM,CAAC;CACrD,GAAG,CAAC,WAAW,WAAW,CAAC;CAE3B,MAAM,gBAAA,GAA2BA,MAAAA,YAAAA,EAC9B,UAAUC,cAAAA,WAAW,EAAE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAC,GACtD,CAAC,IAAI,CACP;CAoDA,OAAO;EACL;EACA;EACA,gBAAA,GApDAD,MAAAA,YAAAA,EACG,EAAE,OAAO,GAAG,YACXC,cAAAA,WACE,WACA,WACA,YACA;GACE,MAAM,OAAO,aAAa,SAAS,WAAW,QAAQ;GACtD,mBAAmB;GACnB,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;EAC1B,IAAA,GAAA,oBAAA,cACA,gBAAA,CAAgB,KAAK,GACrB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,KAAK;GACxB,SAAS,QAAQ,KAAK;GACtB,WAAW,UAAU,KAAK;EAC5B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAMU;EACZ;CACF;AACF"}
@@ -170,9 +170,7 @@ const useSaturationSlider = (props = {}) => {
170
170
  value,
171
171
  getInputProps,
172
172
  getRootProps,
173
- getThumbProps: (0, react.useCallback)((props = {}) => require_props.mergeProps({
174
- ...dataProps,
175
- ...ariaProps,
173
+ getThumbProps: (0, react.useCallback)((props = {}) => require_props.mergeProps(dataProps, ariaProps, {
176
174
  "aria-label": t("Saturation and brightness thumb"),
177
175
  "aria-labelledby": ariaLabelledBy,
178
176
  "aria-roledescription": "2D slider",
@@ -1 +1 @@
1
- {"version":3,"file":"use-saturation-slider.cjs","names":["useFieldProps","useI18n","useControllableState","usePanEvent","useCallback","mergeProps","visuallyHiddenAttributes","mergeRefs"],"sources":["../../../../src/components/saturation-slider/use-saturation-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n handlerAll,\n mergeRefs,\n roundNumberToStep,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { runKeyAction } from \"../../utils/dom\"\nimport { useFieldProps } from \"../field\"\n\nfunction clampValue(value: [number, number, number]) {\n return [\n clampNumber(value[0], 0, 360),\n clampNumber(value[1], 0, 1),\n clampNumber(value[2], 0, 1),\n ] as [number, number, number]\n}\n\nexport interface UseSaturationSliderProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The initial value of the saturation slider.\n *\n * @default [0, 0, 1]\n */\n defaultValue?: [number, number, number]\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * The value of the saturation slider.\n */\n value?: [number, number, number]\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: [number, number, number]) => string | undefined\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: [number, number, number]) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: [number, number, number]) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: [number, number, number]) => void\n}\n\nexport const useSaturationSlider = (props: UseSaturationSliderProps = {}) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n defaultValue = [0, 0, 1],\n disabled,\n getAriaValueText,\n readOnly,\n required,\n step = 0.01,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const { t } = useI18n(\"saturationSlider\")\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [h, s, v] = clampValue(value)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeEnd?.(panValue)\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n setValue(panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeStart?.(value)\n setValue(panValue)\n },\n })\n\n const onChange = useCallback(\n ([h, s, v]: [number, number, number]) => {\n if (!interactive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue([h, s, v])\n },\n [interactive, setValue],\n )\n\n const getPanValue = useCallback(\n (\n { x, y }: Point,\n { bottom, height, left, width }: DOMRect,\n ): [number, number, number] => {\n const diff = { x: x - left, y: bottom - y }\n const percent = { x: diff.x / width, y: diff.y / height }\n const clamp = {\n x: clampNumber(percent.x, 0, 1),\n y: clampNumber(percent.y, 0, 1),\n }\n const s = roundNumberToStep(clamp.x, 0, step)\n const v = roundNumberToStep(clamp.y, 0, step)\n\n return [h, parseFloat(s), parseFloat(v)]\n },\n [h, step],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => onChange([h, s, v - step]),\n ArrowLeft: () => onChange([h, s - step, v]),\n ArrowRight: () => onChange([h, s + step, v]),\n ArrowUp: () => onChange([h, s, v + step]),\n })\n },\n [h, onChange, s, step, v],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const merged = mergeProps(dataProps, rest, props)()\n\n return {\n ...merged,\n style: {\n ...rest.style,\n ...props.style,\n \"--x\": `${Math.abs(s * 100)}%`,\n \"--y\": `${Math.abs(100 - v * 100)}%`,\n backgroundColor: `hsl(${h}, 100%, 50%)`,\n backgroundImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n },\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n },\n [dataProps, eventProps, h, rest, s, v],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n ...props,\n ref: mergeRefs(props.ref, ref),\n }),\n [\n ariaProps,\n dataProps,\n disabled,\n h,\n id,\n name,\n readOnly,\n ref,\n required,\n s,\n v,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}) => getPanEventProps({ ...dataProps, ...props }),\n [dataProps, getPanEventProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n ...dataProps,\n ...ariaProps,\n \"aria-label\": t(\"Saturation and brightness thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-roledescription\": \"2D slider\",\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value) ??\n t(\"Saturation {saturation}%, Brightness {brightness}%\", {\n brightness: v * 100,\n saturation: s * 100,\n }),\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n props,\n { onKeyDown },\n )(),\n [\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n interactive,\n onKeyDown,\n s,\n t,\n v,\n value,\n ],\n )\n\n return {\n setValue,\n value,\n getInputProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;AAqBA,SAAS,WAAW,OAAiC;CACnD,OAAO;GACL,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,GAAG;GAC5B,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,CAAC;GAC1B,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,CAAC;CAC5B;AACF;AAqDA,MAAa,uBAAuB,QAAkC,CAAC,MAAM;CAC3E,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,eAAe;EAAC;EAAG;EAAG;CAAC,GACvB,UACA,kBACA,UACA,UACA,OAAO,KACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACEA,wBAAAA,cAAc,KAAK;CACvB,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,kBAAkB;CACxC,MAAM,CAAC,OAAO,YAAYC,2CAAAA,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,CAAC,GAAG,GAAG,KAAK,WAAW,KAAK;CAClC,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoBC,kCAAAA,YAA4B;EACxD,QAAQ,GAAG,OAAO,SAAS;GACzB,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,cAAc,QAAQ;EACxB;EACA,SAAS,GAAG,OA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,MAAM,iBAAiB;EAAE,GAAG;EAAW,GAAG;CAAM,CAAC,GAC3D,CAAC,WAAW,gBAAgB,CAC9B;CA0CA,OAAO;EACL;EACA;EACA;EACA;EACA,gBAAA,GA7CgCA,MAAAA,YAAAA,EAC/B,QAAQ,CAAC,MACRC,cAAAA,WACE;GACE,GAAG;GACH,GAAG;GACH,cAAc,EAAE,iCAAiC;GACjD,mBAAmB;GACnB,wBAAwB;GACxB,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB,IAAI;GACrB,kBACE,iBACA,mBAAmB,KAAK,KACxB,EAAE,sDAAsD;IACtD,YAAY,IAAI;IAChB,YAAY,IAAI;GAClB,CAAC;GACH,MAAM;GACN,UAAU,cAAc,IAAI;EAC9B,GACA,OACA,EAAE,UAAU,CACd,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAQY;EACZ;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-saturation-slider.cjs","names":["useFieldProps","useI18n","useControllableState","usePanEvent","useCallback","mergeProps","visuallyHiddenAttributes","mergeRefs"],"sources":["../../../../src/components/saturation-slider/use-saturation-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n handlerAll,\n mergeRefs,\n roundNumberToStep,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { runKeyAction } from \"../../utils/dom\"\nimport { useFieldProps } from \"../field\"\n\nfunction clampValue(value: [number, number, number]) {\n return [\n clampNumber(value[0], 0, 360),\n clampNumber(value[1], 0, 1),\n clampNumber(value[2], 0, 1),\n ] as [number, number, number]\n}\n\nexport interface UseSaturationSliderProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The initial value of the saturation slider.\n *\n * @default [0, 0, 1]\n */\n defaultValue?: [number, number, number]\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * The value of the saturation slider.\n */\n value?: [number, number, number]\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: [number, number, number]) => string | undefined\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: [number, number, number]) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: [number, number, number]) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: [number, number, number]) => void\n}\n\nexport const useSaturationSlider = (props: UseSaturationSliderProps = {}) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n defaultValue = [0, 0, 1],\n disabled,\n getAriaValueText,\n readOnly,\n required,\n step = 0.01,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const { t } = useI18n(\"saturationSlider\")\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [h, s, v] = clampValue(value)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeEnd?.(panValue)\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n setValue(panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeStart?.(value)\n setValue(panValue)\n },\n })\n\n const onChange = useCallback(\n ([h, s, v]: [number, number, number]) => {\n if (!interactive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue([h, s, v])\n },\n [interactive, setValue],\n )\n\n const getPanValue = useCallback(\n (\n { x, y }: Point,\n { bottom, height, left, width }: DOMRect,\n ): [number, number, number] => {\n const diff = { x: x - left, y: bottom - y }\n const percent = { x: diff.x / width, y: diff.y / height }\n const clamp = {\n x: clampNumber(percent.x, 0, 1),\n y: clampNumber(percent.y, 0, 1),\n }\n const s = roundNumberToStep(clamp.x, 0, step)\n const v = roundNumberToStep(clamp.y, 0, step)\n\n return [h, parseFloat(s), parseFloat(v)]\n },\n [h, step],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => onChange([h, s, v - step]),\n ArrowLeft: () => onChange([h, s - step, v]),\n ArrowRight: () => onChange([h, s + step, v]),\n ArrowUp: () => onChange([h, s, v + step]),\n })\n },\n [h, onChange, s, step, v],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const merged = mergeProps(dataProps, rest, props)()\n\n return {\n ...merged,\n style: {\n ...rest.style,\n ...props.style,\n \"--x\": `${Math.abs(s * 100)}%`,\n \"--y\": `${Math.abs(100 - v * 100)}%`,\n backgroundColor: `hsl(${h}, 100%, 50%)`,\n backgroundImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n },\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n },\n [dataProps, eventProps, h, rest, s, v],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n ...props,\n ref: mergeRefs(props.ref, ref),\n }),\n [\n ariaProps,\n dataProps,\n disabled,\n h,\n id,\n name,\n readOnly,\n ref,\n required,\n s,\n v,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}) => getPanEventProps({ ...dataProps, ...props }),\n [dataProps, getPanEventProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n dataProps,\n ariaProps,\n {\n \"aria-label\": t(\"Saturation and brightness thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-roledescription\": \"2D slider\",\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value) ??\n t(\"Saturation {saturation}%, Brightness {brightness}%\", {\n brightness: v * 100,\n saturation: s * 100,\n }),\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n props,\n { onKeyDown },\n )(),\n [\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n interactive,\n onKeyDown,\n s,\n t,\n v,\n value,\n ],\n )\n\n return {\n setValue,\n value,\n getInputProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;AAqBA,SAAS,WAAW,OAAiC;CACnD,OAAO;GACL,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,GAAG;GAC5B,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,CAAC;GAC1B,GAAA,oBAAA,cAAA,YAAA,CAAY,MAAM,IAAI,GAAG,CAAC;CAC5B;AACF;AAqDA,MAAa,uBAAuB,QAAkC,CAAC,MAAM;CAC3E,MAAM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om = require("../../utils/dom.cjs");
3
- const require_ref = require("../../utils/ref.cjs");
4
3
  const require_props = require("../../core/components/props.cjs");
5
4
  const require_hooks_use_controllable_state_index = require("../../hooks/use-controllable-state/index.cjs");
6
5
  const require_hooks_use_pan_event_index = require("../../hooks/use-pan-event/index.cjs");
@@ -134,10 +133,7 @@ const useSlider = (props = {}) => {
134
133
  tenStep
135
134
  ]);
136
135
  const getRootProps = (0, react.useCallback)((props = {}) => {
137
- const computedProps = require_props.mergeProps(dataProps, { "data-orientation": orientation }, rest, props, {
138
- onBlur: eventProps.onBlur,
139
- onFocus: eventProps.onFocus
140
- })();
136
+ const computedProps = require_props.mergeProps(dataProps, { "data-orientation": orientation }, rest, props, eventProps)();
141
137
  computedProps.style ??= {};
142
138
  if ((0, require_utils_index.utils_exports.isArray)(percent)) {
143
139
  computedProps.style["--range-start"] = `${Math.abs(percent[0])}%`;
@@ -154,20 +150,15 @@ const useSlider = (props = {}) => {
154
150
  percent,
155
151
  rest
156
152
  ]);
157
- const getInputProps = (0, react.useCallback)(({ index = 0, ...props } = {}) => ({
158
- ...require_dom.visuallyHiddenAttributes,
159
- ...dataProps,
160
- ...ariaProps,
153
+ const getInputProps = (0, react.useCallback)(({ index = 0, ...props } = {}) => require_props.mergeProps(require_dom.visuallyHiddenAttributes, dataProps, ariaProps, {
161
154
  id,
162
155
  type: "hidden",
163
156
  name,
164
157
  disabled,
165
158
  readOnly,
166
159
  required,
167
- value: range ? value[index] : value,
168
- ...props,
169
- ref: index === 0 ? require_ref.mergeRefs(props.ref, ref) : props.ref
170
- }), [
160
+ value: range ? value[index] : value
161
+ }, props, { ref: index === 0 ? ref : void 0 })(), [
171
162
  dataProps,
172
163
  ariaProps,
173
164
  id,
@@ -233,9 +224,7 @@ const useSlider = (props = {}) => {
233
224
  getRootProps,
234
225
  getThumbProps: (0, react.useCallback)(({ index = 0, ...rest } = {}) => {
235
226
  const { max, min } = getMinMax(index);
236
- return require_props.mergeProps({
237
- ...dataProps,
238
- ...ariaProps,
227
+ return require_props.mergeProps(dataProps, ariaProps, {
239
228
  "aria-label": t("Slider thumb"),
240
229
  "aria-labelledby": ariaLabelledBy,
241
230
  "aria-orientation": orientation,
@@ -1 +1 @@
1
- {"version":3,"file":"use-slider.cjs","names":["useFieldProps","useControllableState","useI18n","useRef","usePanEvent","useCallback","mergeProps","visuallyHiddenAttributes","mergeRefs"],"sources":["../../../../src/components/slider/use-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type {\n HTMLProps,\n HTMLRefAttributes,\n Orientation,\n PropGetter,\n RequiredPropGetter,\n} from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n dataAttr,\n isArray,\n isNumber,\n mergeRefs,\n percentToValue,\n roundNumberToStep,\n runKeyAction,\n valueToPercent,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseSliderProps<Y extends [number, number] | number = number>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The minimum distance between slider thumbs.\n * Useful for preventing the thumbs from being too close together.\n *\n * @default 0\n */\n betweenThumbs?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: Y\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 100\n */\n max?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The orientation of the slider.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * The value of the slider.\n */\n value?: Y\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: number, index: number) => string | undefined\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: Y) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Y) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Y) => void\n}\n\nexport const useSlider = <Y extends [number, number] | number = number>(\n props: UseSliderProps<Y> = {},\n) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n betweenThumbs = 0,\n defaultValue = 0 as Y,\n disabled,\n getAriaValueText,\n max = 100,\n min = 0,\n orientation = \"horizontal\",\n readOnly,\n required,\n step = 1,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { t } = useI18n(\"slider\")\n const currentIndex = useRef(0)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const start = currentIndex.current === 0\n const oppositeIndex = currentIndex.current === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeEnd?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n onChangeEnd?.(panValue as Y)\n }\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChange(currentIndex.current, panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const distances = value.map((value) => Math.abs(value - panValue))\n const closest = Math.min(...distances)\n const index = distances.indexOf(closest)\n\n currentIndex.current = index\n\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeStart?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n currentIndex.current = 0\n\n onChangeStart?.(value)\n }\n\n onChange(currentIndex.current, panValue)\n },\n })\n const range = !isNumber(value)\n const percent = (\n range\n ? value.map((value) => valueToPercent(value, min, max))\n : valueToPercent(value, min, max)\n ) as Y extends number ? number : number[]\n const tenStep = (max - min) / 10\n const oneStep = step || (max - min) / 100\n\n if (max < min) console.warn(\"Do not assign a number less than 'min' to 'max'\")\n\n const getMinMax = useCallback(\n (index: number) => {\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = range ? value[oppositeIndex] : value\n\n return {\n max: range ? (start ? oppositeValue - betweenThumbs : max) : max,\n min: range ? (start ? min : oppositeValue + betweenThumbs) : min,\n }\n },\n [betweenThumbs, max, min, range, value],\n )\n\n const getPanValue = useCallback(\n ({ x, y }: Point, { bottom, height, left, width }: DOMRect) => {\n const diff = orientation === \"horizontal\" ? x - left : bottom - y\n const length = orientation === \"horizontal\" ? width : height\n const percent = diff / length\n\n let nextValue = percentToValue(percent, min, max)\n\n nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [orientation, min, max, step],\n )\n\n const onChange = useCallback(\n (index: number, value: number) => {\n if (!interactive) return\n\n const { max, min } = getMinMax(index)\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue((prev) => {\n if (isArray(prev)) {\n const next = [...prev]\n\n next[index] = value\n\n return next as Y\n } else {\n return value as Y\n }\n })\n },\n [getMinMax, interactive, oneStep, setValue],\n )\n\n const stepUp = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! + step)\n : onChange(index, value + step),\n [oneStep, range, onChange, value],\n )\n\n const stepDown = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! - step)\n : onChange(index, value - step),\n [oneStep, range, onChange, value],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLDivElement>) => {\n const { max, min } = getMinMax(index)\n\n runKeyAction(ev, {\n ArrowDown: () => stepDown(index),\n ArrowLeft: () => stepDown(index),\n ArrowRight: () => stepUp(index),\n ArrowUp: () => stepUp(index),\n End: () => onChange(index, max),\n Home: () => onChange(index, min),\n PageDown: () => stepDown(index, tenStep),\n PageUp: () => stepUp(index, tenStep),\n })\n },\n [getMinMax, onChange, stepDown, stepUp, tenStep],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const computedProps: HTMLProps = mergeProps(\n dataProps,\n { \"data-orientation\": orientation },\n rest,\n props,\n { onBlur: eventProps.onBlur, onFocus: eventProps.onFocus },\n )()\n\n computedProps.style ??= {}\n\n if (isArray(percent)) {\n computedProps.style[\"--range-start\"] = `${Math.abs(percent[0]!)}%`\n computedProps.style[\"--range-end\"] = `${Math.abs(percent[1]!)}%`\n } else {\n computedProps.style[\"--range-start\"] = \"0%\"\n computedProps.style[\"--range-end\"] = `${Math.abs(percent)}%`\n }\n\n return computedProps\n },\n [dataProps, eventProps, orientation, percent, rest],\n )\n\n const getInputProps: PropGetter<\"input\", { index?: number }> = useCallback(\n ({ index = 0, ...props } = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: range ? value[index]! : value,\n ...props,\n ref: index === 0 ? mergeRefs(props.ref, ref) : props.ref,\n }),\n [\n dataProps,\n ariaProps,\n id,\n name,\n disabled,\n readOnly,\n required,\n range,\n value,\n ref,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props) =>\n getPanEventProps({\n ...dataProps,\n \"data-orientation\": orientation,\n ...props,\n }),\n [dataProps, getPanEventProps, orientation],\n )\n\n const getRangeProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n \"data-orientation\": orientation,\n \"data-range\": dataAttr(range),\n ...props,\n }),\n [dataProps, orientation, range],\n )\n\n const getMarkProps: RequiredPropGetter<\"div\", { value: number }> =\n useCallback(\n ({ style, value: valueProp, ...props }) => {\n const between = range\n ? value[0] < valueProp && valueProp < value[1]\n : valueProp < value\n const percent = valueToPercent(valueProp, min, max)\n\n return {\n ...dataProps,\n \"aria-hidden\": true,\n \"data-between\": dataAttr(between),\n \"data-orientation\": orientation,\n role: \"presentation\",\n ...props,\n style: { ...style, \"--mark-position\": `${percent}%` },\n }\n },\n [dataProps, max, min, orientation, range, value],\n )\n\n const getThumbProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ index = 0, ...rest } = {}) => {\n const { max, min } = getMinMax(index)\n\n return mergeProps(\n {\n ...dataProps,\n ...ariaProps,\n \"aria-label\": t(\"Slider thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-orientation\": orientation,\n \"aria-valuemax\": max,\n \"aria-valuemin\": min,\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n range\n ? {\n \"aria-valuenow\": value[index]!,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value[index]!, index) ??\n value[index]!.toString(),\n \"data-end\": dataAttr(index === 1),\n \"data-start\": dataAttr(index === 0),\n }\n : {\n \"aria-valuenow\": value,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value, index) ??\n value.toString(),\n \"data-end\": dataAttr(index === 0),\n },\n rest,\n { onKeyDown: onKeyDown(index) },\n )()\n },\n [\n t,\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n getMinMax,\n interactive,\n onKeyDown,\n orientation,\n range,\n value,\n ],\n )\n\n return {\n percent,\n range,\n setValue,\n stepDown,\n stepUp,\n value,\n getInputProps,\n getMarkProps,\n getRangeProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSliderReturn = ReturnType<typeof useSlider>\n"],"mappings":";;;;;;;;;;;AAyGA,MAAa,aACX,QAA2B,CAAC,MACzB;CACH,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,gBAAgB,GAChB,eAAe,GACf,UACA,kBACA,MAAM,KACN,MAAM,GACN,cAAc,cACd,UACA,UACA,OAAO,GACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACEA,wBAAAA,cAAc,KAAK;CACvB,MAAM,CAAC,OAAO,YAAYC,2CAAAA,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,QAAQ;CAC9B,MAAM,gBAAA,GAAeC,MAAAA,OAAAA,CAAO,CAAC;CAC7B,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoBC,kCAAAA,YAA4B;EACxD,QAAQ,GAAG,OAAO,SAAS;GACzB,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,IAAI,OAAO;IACT,MAAM,QAAQ,aAAa,YAAY;IACvC,MAAM,gBAAgB,aAAa,YAAY,IAAI,IAAI;IACvD,MAAM,gBAAgB,MAAM;IAE5B,cACG,QAAQ,CAAC,UAAU,aAAa,IAAI,CAAC,eAAe,QAAQ,CAC/D;GACF,OACE,cAAc,QAAa;EAE/B;EACA,SAAS,GAAG,OAAO,SAAS;GAC1B,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,SAAS,aAAa,SAAS,QAAQ;EACzC;EACA,UAAU,GAAG,OAAO,SAAS;GAC3B,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,IAAI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aAAA,GAAA,oBAAA,cAAY,SAAA,CAAS,UAAU,CAAC;IAChC,eAAA,GAAA,oBAAA,cAAc,SAAA,CAAS,UAAU,CAAC;GACpC,IACA;IACE,iBAAiB;IACjB,kBACE,iBACA,mBAAmB,OAAO,KAAK,KAC/B,MAAM,SAAS;IACjB,aAAA,GAAA,oBAAA,cAAY,SAAA,CAAS,UAAU,CAAC;GAClC,GACJ,MACA,EAAE,WAAW,UAAU,KAAK,EAAE,CAChC,CAAC,CAAC;EACJ,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAcY;EACZ;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-slider.cjs","names":["useFieldProps","useControllableState","useI18n","useRef","usePanEvent","useCallback","mergeProps","visuallyHiddenAttributes"],"sources":["../../../../src/components/slider/use-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type {\n HTMLProps,\n HTMLRefAttributes,\n Orientation,\n PropGetter,\n RequiredPropGetter,\n} from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n dataAttr,\n isArray,\n isNumber,\n percentToValue,\n roundNumberToStep,\n runKeyAction,\n valueToPercent,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseSliderProps<Y extends [number, number] | number = number>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The minimum distance between slider thumbs.\n * Useful for preventing the thumbs from being too close together.\n *\n * @default 0\n */\n betweenThumbs?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: Y\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 100\n */\n max?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The orientation of the slider.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * The value of the slider.\n */\n value?: Y\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: number, index: number) => string | undefined\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: Y) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Y) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Y) => void\n}\n\nexport const useSlider = <Y extends [number, number] | number = number>(\n props: UseSliderProps<Y> = {},\n) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n betweenThumbs = 0,\n defaultValue = 0 as Y,\n disabled,\n getAriaValueText,\n max = 100,\n min = 0,\n orientation = \"horizontal\",\n readOnly,\n required,\n step = 1,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { t } = useI18n(\"slider\")\n const currentIndex = useRef(0)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const start = currentIndex.current === 0\n const oppositeIndex = currentIndex.current === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeEnd?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n onChangeEnd?.(panValue as Y)\n }\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChange(currentIndex.current, panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const distances = value.map((value) => Math.abs(value - panValue))\n const closest = Math.min(...distances)\n const index = distances.indexOf(closest)\n\n currentIndex.current = index\n\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeStart?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n currentIndex.current = 0\n\n onChangeStart?.(value)\n }\n\n onChange(currentIndex.current, panValue)\n },\n })\n const range = !isNumber(value)\n const percent = (\n range\n ? value.map((value) => valueToPercent(value, min, max))\n : valueToPercent(value, min, max)\n ) as Y extends number ? number : number[]\n const tenStep = (max - min) / 10\n const oneStep = step || (max - min) / 100\n\n if (max < min) console.warn(\"Do not assign a number less than 'min' to 'max'\")\n\n const getMinMax = useCallback(\n (index: number) => {\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = range ? value[oppositeIndex] : value\n\n return {\n max: range ? (start ? oppositeValue - betweenThumbs : max) : max,\n min: range ? (start ? min : oppositeValue + betweenThumbs) : min,\n }\n },\n [betweenThumbs, max, min, range, value],\n )\n\n const getPanValue = useCallback(\n ({ x, y }: Point, { bottom, height, left, width }: DOMRect) => {\n const diff = orientation === \"horizontal\" ? x - left : bottom - y\n const length = orientation === \"horizontal\" ? width : height\n const percent = diff / length\n\n let nextValue = percentToValue(percent, min, max)\n\n nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [orientation, min, max, step],\n )\n\n const onChange = useCallback(\n (index: number, value: number) => {\n if (!interactive) return\n\n const { max, min } = getMinMax(index)\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue((prev) => {\n if (isArray(prev)) {\n const next = [...prev]\n\n next[index] = value\n\n return next as Y\n } else {\n return value as Y\n }\n })\n },\n [getMinMax, interactive, oneStep, setValue],\n )\n\n const stepUp = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! + step)\n : onChange(index, value + step),\n [oneStep, range, onChange, value],\n )\n\n const stepDown = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! - step)\n : onChange(index, value - step),\n [oneStep, range, onChange, value],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLDivElement>) => {\n const { max, min } = getMinMax(index)\n\n runKeyAction(ev, {\n ArrowDown: () => stepDown(index),\n ArrowLeft: () => stepDown(index),\n ArrowRight: () => stepUp(index),\n ArrowUp: () => stepUp(index),\n End: () => onChange(index, max),\n Home: () => onChange(index, min),\n PageDown: () => stepDown(index, tenStep),\n PageUp: () => stepUp(index, tenStep),\n })\n },\n [getMinMax, onChange, stepDown, stepUp, tenStep],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const computedProps: HTMLProps = mergeProps(\n dataProps,\n { \"data-orientation\": orientation },\n rest,\n props,\n eventProps,\n )()\n\n computedProps.style ??= {}\n\n if (isArray(percent)) {\n computedProps.style[\"--range-start\"] = `${Math.abs(percent[0]!)}%`\n computedProps.style[\"--range-end\"] = `${Math.abs(percent[1]!)}%`\n } else {\n computedProps.style[\"--range-start\"] = \"0%\"\n computedProps.style[\"--range-end\"] = `${Math.abs(percent)}%`\n }\n\n return computedProps\n },\n [dataProps, eventProps, orientation, percent, rest],\n )\n\n const getInputProps: PropGetter<\"input\", { index?: number }> = useCallback(\n ({ index = 0, ...props } = {}) =>\n mergeProps(\n visuallyHiddenAttributes,\n dataProps,\n ariaProps,\n {\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: range ? value[index]! : value,\n },\n props,\n { ref: index === 0 ? ref : undefined },\n )(),\n [\n dataProps,\n ariaProps,\n id,\n name,\n disabled,\n readOnly,\n required,\n range,\n value,\n ref,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props) =>\n getPanEventProps({\n ...dataProps,\n \"data-orientation\": orientation,\n ...props,\n }),\n [dataProps, getPanEventProps, orientation],\n )\n\n const getRangeProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n \"data-orientation\": orientation,\n \"data-range\": dataAttr(range),\n ...props,\n }),\n [dataProps, orientation, range],\n )\n\n const getMarkProps: RequiredPropGetter<\"div\", { value: number }> =\n useCallback(\n ({ style, value: valueProp, ...props }) => {\n const between = range\n ? value[0] < valueProp && valueProp < value[1]\n : valueProp < value\n const percent = valueToPercent(valueProp, min, max)\n\n return {\n ...dataProps,\n \"aria-hidden\": true,\n \"data-between\": dataAttr(between),\n \"data-orientation\": orientation,\n role: \"presentation\",\n ...props,\n style: { ...style, \"--mark-position\": `${percent}%` },\n }\n },\n [dataProps, max, min, orientation, range, value],\n )\n\n const getThumbProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ index = 0, ...rest } = {}) => {\n const { max, min } = getMinMax(index)\n\n return mergeProps(\n dataProps,\n ariaProps,\n {\n \"aria-label\": t(\"Slider thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-orientation\": orientation,\n \"aria-valuemax\": max,\n \"aria-valuemin\": min,\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n range\n ? {\n \"aria-valuenow\": value[index]!,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value[index]!, index) ??\n value[index]!.toString(),\n \"data-end\": dataAttr(index === 1),\n \"data-start\": dataAttr(index === 0),\n }\n : {\n \"aria-valuenow\": value,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value, index) ??\n value.toString(),\n \"data-end\": dataAttr(index === 0),\n },\n rest,\n { onKeyDown: onKeyDown(index) },\n )()\n },\n [\n t,\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n getMinMax,\n interactive,\n onKeyDown,\n orientation,\n range,\n value,\n ],\n )\n\n return {\n percent,\n range,\n setValue,\n stepDown,\n stepUp,\n value,\n getInputProps,\n getMarkProps,\n getRangeProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSliderReturn = ReturnType<typeof useSlider>\n"],"mappings":";;;;;;;;;;AAwGA,MAAa,aACX,QAA2B,CAAC,MACzB;CACH,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,gBAAgB,GAChB,eAAe,GACf,UACA,kBACA,MAAM,KACN,MAAM,GACN,cAAc,cACd,UACA,UACA,OAAO,GACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACEA,wBAAAA,cAAc,KAAK;CACvB,MAAM,CAAC,OAAO,YAAYC,2CAAAA,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAMC,sBAAAA,QAAQ,QAAQ;CAC9B,MAAM,gBAAA,GAAeC,MAAAA,OAAAA,CAAO,CAAC;CAC7B,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoBC,kCAAAA,YAA4B;EACxD,QAAQ,GAAG,OAAO,SAAS;GACzB,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,IAAI,OAAO;IACT,MAAM,QAAQ,aAAa,YAAY;IACvC,MAAM,gBAAgB,aAAa,YAAY,IAAI,IAAI;IACvD,MAAM,gBAAgB,MAAM;IAE5B,cACG,QAAQ,CAAC,UAAU,aAAa,IAAI,CAAC,eAAe,QAAQ,CAC/D;GACF,OACE,cAAc,QAAa;EAE/B;EACA,SAAS,GAAG,OAA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UAAU,cAAc,IAAI;GAC9B,GACA,QACI;IACE,iBAAiB,MAAM;IACvB,kBACE,iBACA,mBAAmB,MAAM,QAAS,KAAK,KACvC,MAAM,MAAM,CAAE,SAAS;IACzB,aAAA,GAAA,oBAAA,cAAY,SAAA,CAAS,UAAU,CAAC;IAChC,eAAA,GAAA,oBAAA,cAAc,SAAA,CAAS,UAAU,CAAC;GACpC,IACA;IACE,iBAAiB;IACjB,kBACE,iBACA,mBAAmB,OAAO,KAAK,KAC/B,MAAM,SAAS;IACjB,aAAA,GAAA,oBAAA,cAAY,SAAA,CAAS,UAAU,CAAC;GAClC,GACJ,MACA,EAAE,WAAW,UAAU,KAAK,EAAE,CAChC,CAAC,CAAC;EACJ,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAcY;EACZ;EACA;CACF;AACF"}
@@ -1,9 +1,7 @@
1
1
  "use client";
2
- import { mergeRefs } from "../../utils/ref.js";
3
2
  import { mergeProps } from "../../core/components/props.js";
4
3
  import { useControllableState } from "../../hooks/use-controllable-state/index.js";
5
4
  import { useI18n } from "../../providers/i18n-provider/i18n-provider.js";
6
- import { utils_exports } from "../../utils/index.js";
7
5
  import { useFieldProps } from "../field/use-field-props.js";
8
6
  import { useCallback } from "react";
9
7
  // src/components/password-input/use-password-input.tsx
@@ -20,22 +18,10 @@ const usePasswordInput = (props = {}) => {
20
18
  ev.preventDefault();
21
19
  setVisible((prev) => !prev);
22
20
  }, [disabled, setVisible]);
23
- const getInputProps = useCallback(({ ref, ...props } = {}) => {
24
- return {
25
- ...mergeProps({
26
- type: visible ? "text" : "password",
27
- disabled,
28
- ...ariaProps,
29
- ...dataProps
30
- }, rest, props)({
31
- mergeEvent: false,
32
- mergeRef: false
33
- }),
34
- ref: mergeRefs(ref, rest.ref),
35
- onBlur: (0, utils_exports.handlerAll)(eventProps.onBlur, props.onBlur),
36
- onFocus: (0, utils_exports.handlerAll)(eventProps.onFocus, props.onFocus)
37
- };
38
- }, [
21
+ const getInputProps = useCallback((props = {}) => mergeProps(ariaProps, dataProps, eventProps, {
22
+ type: visible ? "text" : "password",
23
+ disabled
24
+ }, rest, props)(), [
39
25
  visible,
40
26
  rest,
41
27
  disabled,
@@ -46,14 +32,11 @@ const usePasswordInput = (props = {}) => {
46
32
  return {
47
33
  setVisible,
48
34
  visible,
49
- getButtonProps: useCallback((props = {}) => ({
35
+ getButtonProps: useCallback((props = {}) => mergeProps(dataProps, {
50
36
  type: "button",
51
37
  "aria-label": t("Toggle password visibility"),
52
- disabled,
53
- ...dataProps,
54
- ...props,
55
- onClick: (0, utils_exports.handlerAll)(props.onClick, onChangeVisibility)
56
- }), [
38
+ disabled
39
+ }, props, { onClick: onChangeVisibility })(), [
57
40
  onChangeVisibility,
58
41
  dataProps,
59
42
  disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"use-password-input.js","names":["handlerAll"],"sources":["../../../../src/components/password-input/use-password-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { handlerAll, mergeRefs } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UsePasswordInputProps extends HTMLProps<\"input\">, FieldProps {\n /**\n * Determines whether the password input is visible by default.\n *\n * @default false\n */\n defaultVisible?: boolean\n /**\n * Determines the visibility of the password input.\n *\n * @default false\n */\n visible?: boolean\n /**\n * Callback function that is triggered when the visibility of the password input changes.\n */\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport const usePasswordInput = (props: UsePasswordInputProps = {}) => {\n const {\n props: {\n defaultVisible,\n disabled,\n visible: visibleProp,\n onVisibleChange,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [visible, setVisible] = useControllableState({\n defaultValue: defaultVisible,\n value: visibleProp,\n onChange: onVisibleChange,\n })\n const { t } = useI18n(\"passwordInput\")\n\n const onChangeVisibility = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (disabled || ev.button !== 0) return\n\n ev.preventDefault()\n\n setVisible((prev) => !prev)\n },\n [disabled, setVisible],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => {\n const mergedProps = mergeProps(\n {\n type: visible ? \"text\" : \"password\",\n disabled,\n ...ariaProps,\n ...dataProps,\n },\n rest,\n props,\n )({\n mergeEvent: false,\n mergeRef: false,\n })\n\n return {\n ...mergedProps,\n ref: mergeRefs(ref, rest.ref),\n onBlur: handlerAll(eventProps.onBlur, props.onBlur),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus),\n }\n },\n [visible, rest, disabled, dataProps, eventProps, ariaProps],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n type: \"button\",\n \"aria-label\": t(\"Toggle password visibility\"),\n disabled,\n ...dataProps,\n ...props,\n onClick: handlerAll(props.onClick, onChangeVisibility),\n }),\n [onChangeVisibility, dataProps, disabled, t],\n )\n\n return {\n setVisible,\n visible,\n getButtonProps,\n getInputProps,\n }\n}\n\nexport type UsePasswordInputReturn = ReturnType<typeof usePasswordInput>\n"],"mappings":";;;;;;;;;AA+BA,MAAa,oBAAoB,QAA+B,CAAC,MAAM;CACrE,MAAM,EACJ,OAAO,EACL,gBACA,UACA,SAAS,aACT,iBACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,CAAC,SAAS,cAAc,qBAAqB;EACjD,cAAc;EACd,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAM,QAAQ,eAAe;CAErC,MAAM,qBAAqB,aACxB,OAAsC;EACrC,IAAI,YAAY,GAAG,WAAW,GAAG;EAEjC,GAAG,eAAe;EAElB,YAAY,SAAS,CAAC,IAAI;CAC5B,GACA,CAAC,UAAU,UAAU,CACvB;CAEA,MAAM,gBAAqC,aACxC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM;EAe1B,OAAO;GACL,GAfkB,WAClB;IACE,MAAM,UAAU,SAAS;IACzB;IACA,GAAG;IACH,GAAG;GACL,GACA,MACA,KACF,CAAC,CAAC;IACA,YAAY;IACZ,UAAU;GACZ,CAGe;GACb,KAAK,UAAU,KAAK,KAAK,GAAG;GAC5B,SAAA,GAAQA,cAAAA,WAAAA,CAAW,WAAW,QAAQ,MAAM,MAAM;GAClD,UAAA,GAASA,cAAAA,WAAAA,CAAW,WAAW,SAAS,MAAM,OAAO;EACvD;CACF,GACA;EAAC;EAAS;EAAM;EAAU;EAAW;EAAY;CAAS,CAC5D;CAcA,OAAO;EACL;EACA;EACA,gBAf2C,aAC1C,QAAQ,CAAC,OAAO;GACf,MAAM;GACN,cAAc,EAAE,4BAA4B;GAC5C;GACA,GAAG;GACH,GAAG;GACH,UAAA,GAASA,cAAAA,WAAAA,CAAW,MAAM,SAAS,kBAAkB;EACvD,IACA;GAAC;GAAoB;GAAW;GAAU;EAAC,CAM9B;EACb;CACF;AACF"}
1
+ {"version":3,"file":"use-password-input.js","names":[],"sources":["../../../../src/components/password-input/use-password-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UsePasswordInputProps extends HTMLProps<\"input\">, FieldProps {\n /**\n * Determines whether the password input is visible by default.\n *\n * @default false\n */\n defaultVisible?: boolean\n /**\n * Determines the visibility of the password input.\n *\n * @default false\n */\n visible?: boolean\n /**\n * Callback function that is triggered when the visibility of the password input changes.\n */\n onVisibleChange?: (visible: boolean) => void\n}\n\nexport const usePasswordInput = (props: UsePasswordInputProps = {}) => {\n const {\n props: {\n defaultVisible,\n disabled,\n visible: visibleProp,\n onVisibleChange,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [visible, setVisible] = useControllableState({\n defaultValue: defaultVisible,\n value: visibleProp,\n onChange: onVisibleChange,\n })\n const { t } = useI18n(\"passwordInput\")\n\n const onChangeVisibility = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (disabled || ev.button !== 0) return\n\n ev.preventDefault()\n\n setVisible((prev) => !prev)\n },\n [disabled, setVisible],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) =>\n mergeProps(\n ariaProps,\n dataProps,\n eventProps,\n { type: visible ? \"text\" : \"password\", disabled },\n rest,\n props,\n )(),\n [visible, rest, disabled, dataProps, eventProps, ariaProps],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props = {}) =>\n mergeProps(\n dataProps,\n {\n type: \"button\",\n \"aria-label\": t(\"Toggle password visibility\"),\n disabled,\n },\n props,\n { onClick: onChangeVisibility },\n )(),\n [onChangeVisibility, dataProps, disabled, t],\n )\n\n return {\n setVisible,\n visible,\n getButtonProps,\n getInputProps,\n }\n}\n\nexport type UsePasswordInputReturn = ReturnType<typeof usePasswordInput>\n"],"mappings":";;;;;;;AA8BA,MAAa,oBAAoB,QAA+B,CAAC,MAAM;CACrE,MAAM,EACJ,OAAO,EACL,gBACA,UACA,SAAS,aACT,iBACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,CAAC,SAAS,cAAc,qBAAqB;EACjD,cAAc;EACd,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAM,QAAQ,eAAe;CAErC,MAAM,qBAAqB,aACxB,OAAsC;EACrC,IAAI,YAAY,GAAG,WAAW,GAAG;EAEjC,GAAG,eAAe;EAElB,YAAY,SAAS,CAAC,IAAI;CAC5B,GACA,CAAC,UAAU,UAAU,CACvB;CAEA,MAAM,gBAAqC,aACxC,QAAQ,CAAC,MACR,WACE,WACA,WACA,YACA;EAAE,MAAM,UAAU,SAAS;EAAY;CAAS,GAChD,MACA,KACF,CAAC,CAAC,GACJ;EAAC;EAAS;EAAM;EAAU;EAAW;EAAY;CAAS,CAC5D;CAiBA,OAAO;EACL;EACA;EACA,gBAlB2C,aAC1C,QAAQ,CAAC,MACR,WACE,WACA;GACE,MAAM;GACN,cAAc,EAAE,4BAA4B;GAC5C;EACF,GACA,OACA,EAAE,SAAS,mBAAmB,CAChC,CAAC,CAAC,GACJ;GAAC;GAAoB;GAAW;GAAU;EAAC,CAM9B;EACb;CACF;AACF"}
@@ -133,10 +133,7 @@ const usePinInput = (props = {}) => {
133
133
  return {
134
134
  descendants,
135
135
  items,
136
- getInputProps: useCallback(({ index, ...props }) => mergeProps({
137
- ...ariaProps,
138
- ...dataProps,
139
- ...eventProps,
136
+ getInputProps: useCallback(({ index, ...props }) => mergeProps(ariaProps, dataProps, eventProps, {
140
137
  type: mask ? "password" : type === "number" ? "tel" : "text",
141
138
  "aria-labelledby": labelId,
142
139
  autoComplete: otp ? "one-time-code" : "off",
@@ -1 +1 @@
1
- {"version":3,"file":"use-pin-input.js","names":["filterUndefined"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0)))\n nextValue = eventValue.charAt(1)\n else if (value.startsWith(eventValue.charAt(1)))\n nextValue = eventValue.charAt(0)\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n {\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;;;;;;;AAYA,MAAM,EACJ,oBAAoB,4BACpB,eAAe,uBACf,gBAAgB,2BACd,kBAAoC;AAQxC,MAAM,WAAW,UAAmB,OAAO,MAAM,EAAE;AAEnD,MAAM,YAAY,OAAe,SAAmC;CAMlE,QAFc,SAAS,iBAAiB,oBAAsB,WAAA,CAEjD,KAAK,KAAK;AACzB;AAmEA,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,OAAO,MAAM;CACnB,MAAM,EACJ,SAAS,EAAE,YAAY,CAAC,GACxB,OAAO,EACL,KAAK,MACL,OAAO,UACP,WACA,cACA,UACA,QAAQ,GACR,cAAc,MACd,MACA,MAAM,OACN,cAAc,KACd,UACA,OACA,UAAU,cACV,YACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,cAAc,uBAAuB;CAC3C,MAAM,CAAC,WAAW,gBAAgB,SAAkB,IAAI;CACxD,MAAM,CAAC,cAAc,mBAAmB,SAAiB,EAAE;CAC3D,MAAM,CAAC,QAAQ,aAAa,qBAA+B;EACzD,cAAc,QAAQ,YAAY,KAAK,CAAC;EACxC,OAAO,QAAQ,KAAK;EACpB,WAAW,WAAW,eAAe,OAAO,KAAK,EAAE,CAAC;CACtD,CAAC;CAED,MAAM,YAAY,aACf,UAAkB;EACjB,IAAI,CAAC,aAAa,CAAC,a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gB;EACd,IAAI,CAAC,WAAW;EAEhB,MAAM,aAAa,YAAY,WAAW;EAE1C,IAAI,CAAC,YAAY;EAEjB,4BAA4B,WAAW,KAAK,MAAM,CAAC;CACrD,GAAG,CAAC,WAAW,WAAW,CAAC;CAE3B,MAAM,eAA2B,aAC9B,UAAU,WAAW,EAAE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAC,GACtD,CAAC,IAAI,CACP;CAoDA,OAAO;EACL;EACA;EACA,eApDA,aACG,EAAE,OAAO,GAAG,YACX,WACE;GACE,GAAG;GACH,GAAG;GACH,GAAG;GACH,MAAM,OAAO,aAAa,SAAS,WAAW,QAAQ;GACtD,mBAAmB;GACnB,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;EAC1B,IAAA,GACAA,cAAAA,gBAAAA,CAAgB,KAAK,GACrB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,KAAK;GACxB,SAAS,QAAQ,KAAK;GACtB,WAAW,UAAU,KAAK;EAC5B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAMU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"use-pin-input.js","names":["filterUndefined"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0)))\n nextValue = eventValue.charAt(1)\n else if (value.startsWith(eventValue.charAt(1)))\n nextValue = eventValue.charAt(0)\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n ariaProps,\n dataProps,\n eventProps,\n {\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;;;;;;;AAYA,MAAM,EACJ,oBAAoB,4BACpB,eAAe,uBACf,gBAAgB,2BACd,kBAAoC;AAQxC,MAAM,WAAW,UAAmB,OAAO,MAAM,EAAE;AAEnD,MAAM,YAAY,OAAe,SAAmC;CAMlE,QAFc,SAAS,iBAAiB,oBAAsB,WAAA,CAEjD,KAAK,KAAK;AACzB;AAmEA,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,OAAO,MAAM;CACnB,MAAM,EACJ,SAAS,EAAE,YAAY,CAAC,GACxB,OAAO,EACL,KAAK,MACL,OAAO,UACP,WACA,cACA,UACA,QAAQ,GACR,cAAc,MACd,MACA,MAAM,OACN,cAAc,KACd,UACA,OACA,UAAU,cACV,YACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,cAAc,uBAAuB;CAC3C,MAAM,CAAC,WAAW,gBAAgB,SAAkB,IAAI;CACxD,MAAM,CAAC,cAAc,mBAAmB,SAAiB,EAAE;CAC3D,MAAM,CAAC,QAAQ,aAAa,qBAA+B;EACzD,cAAc,QAAQ,YAAY,KAAK,CAAC;EACxC,OAAO,QAAQ,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AAM,UAAU,aACb,gBAAwB,gBAAgB,KAAK,GAC9C,CAAC,CACH;CAEA,MAAM,SAAS,kBAAkB,gBAAgB,EAAE,GAAG,CAAC,CAAC;CAExD,gBAAgB;EACd,IAAI,CAAC,WAAW;EAEhB,MAAM,aAAa,YAAY,WAAW;EAE1C,IAAI,CAAC,YAAY;EAEjB,4BAA4B,WAAW,KAAK,MAAM,CAAC;CACrD,GAAG,CAAC,WAAW,WAAW,CAAC;CAE3B,MAAM,eAA2B,aAC9B,UAAU,WAAW,EAAE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAC,GACtD,CAAC,IAAI,CACP;CAoDA,OAAO;EACL;EACA;EACA,eApDA,aACG,EAAE,OAAO,GAAG,YACX,WACE,WACA,WACA,YACA;GACE,MAAM,OAAO,aAAa,SAAS,WAAW,QAAQ;GACtD,mBAAmB;GACnB,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;EAC1B,IAAA,GACAA,cAAAA,gBAAAA,CAAgB,KAAK,GACrB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,KAAK;GACxB,SAAS,QAAQ,KAAK;GACtB,WAAW,UAAU,KAAK;EAC5B,CACF,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAMU;EACZ;CACF;AACF"}
@@ -170,9 +170,7 @@ const useSaturationSlider = (props = {}) => {
170
170
  value,
171
171
  getInputProps,
172
172
  getRootProps,
173
- getThumbProps: useCallback((props = {}) => mergeProps({
174
- ...dataProps,
175
- ...ariaProps,
173
+ getThumbProps: useCallback((props = {}) => mergeProps(dataProps, ariaProps, {
176
174
  "aria-label": t("Saturation and brightness thumb"),
177
175
  "aria-labelledby": ariaLabelledBy,
178
176
  "aria-roledescription": "2D slider",
@@ -1 +1 @@
1
- {"version":3,"file":"use-saturation-slider.js","names":["clampNumber","roundNumberToStep","handlerAll"],"sources":["../../../../src/components/saturation-slider/use-saturation-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n handlerAll,\n mergeRefs,\n roundNumberToStep,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { runKeyAction } from \"../../utils/dom\"\nimport { useFieldProps } from \"../field\"\n\nfunction clampValue(value: [number, number, number]) {\n return [\n clampNumber(value[0], 0, 360),\n clampNumber(value[1], 0, 1),\n clampNumber(value[2], 0, 1),\n ] as [number, number, number]\n}\n\nexport interface UseSaturationSliderProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The initial value of the saturation slider.\n *\n * @default [0, 0, 1]\n */\n defaultValue?: [number, number, number]\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * The value of the saturation slider.\n */\n value?: [number, number, number]\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: [number, number, number]) => string | undefined\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: [number, number, number]) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: [number, number, number]) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: [number, number, number]) => void\n}\n\nexport const useSaturationSlider = (props: UseSaturationSliderProps = {}) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n defaultValue = [0, 0, 1],\n disabled,\n getAriaValueText,\n readOnly,\n required,\n step = 0.01,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const { t } = useI18n(\"saturationSlider\")\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [h, s, v] = clampValue(value)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeEnd?.(panValue)\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n setValue(panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeStart?.(value)\n setValue(panValue)\n },\n })\n\n const onChange = useCallback(\n ([h, s, v]: [number, number, number]) => {\n if (!interactive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue([h, s, v])\n },\n [interactive, setValue],\n )\n\n const getPanValue = useCallback(\n (\n { x, y }: Point,\n { bottom, height, left, width }: DOMRect,\n ): [number, number, number] => {\n const diff = { x: x - left, y: bottom - y }\n const percent = { x: diff.x / width, y: diff.y / height }\n const clamp = {\n x: clampNumber(percent.x, 0, 1),\n y: clampNumber(percent.y, 0, 1),\n }\n const s = roundNumberToStep(clamp.x, 0, step)\n const v = roundNumberToStep(clamp.y, 0, step)\n\n return [h, parseFloat(s), parseFloat(v)]\n },\n [h, step],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => onChange([h, s, v - step]),\n ArrowLeft: () => onChange([h, s - step, v]),\n ArrowRight: () => onChange([h, s + step, v]),\n ArrowUp: () => onChange([h, s, v + step]),\n })\n },\n [h, onChange, s, step, v],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const merged = mergeProps(dataProps, rest, props)()\n\n return {\n ...merged,\n style: {\n ...rest.style,\n ...props.style,\n \"--x\": `${Math.abs(s * 100)}%`,\n \"--y\": `${Math.abs(100 - v * 100)}%`,\n backgroundColor: `hsl(${h}, 100%, 50%)`,\n backgroundImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n },\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n },\n [dataProps, eventProps, h, rest, s, v],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n ...props,\n ref: mergeRefs(props.ref, ref),\n }),\n [\n ariaProps,\n dataProps,\n disabled,\n h,\n id,\n name,\n readOnly,\n ref,\n required,\n s,\n v,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}) => getPanEventProps({ ...dataProps, ...props }),\n [dataProps, getPanEventProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n {\n ...dataProps,\n ...ariaProps,\n \"aria-label\": t(\"Saturation and brightness thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-roledescription\": \"2D slider\",\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value) ??\n t(\"Saturation {saturation}%, Brightness {brightness}%\", {\n brightness: v * 100,\n saturation: s * 100,\n }),\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n props,\n { onKeyDown },\n )(),\n [\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n interactive,\n onKeyDown,\n s,\n t,\n v,\n value,\n ],\n )\n\n return {\n setValue,\n value,\n getInputProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;AAqBA,SAAS,WAAW,OAAiC;CACnD,OAAO;GACLA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,GAAG;GAC5BA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,CAAC;GAC1BA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,CAAC;CAC5B;AACF;AAqDA,MAAa,uBAAuB,QAAkC,CAAC,MAAM;CAC3E,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,eAAe;EAAC;EAAG;EAAG;CAAC,GACvB,UACA,kBACA,UACA,UACA,OAAO,KACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,EAAE,MAAM,QAAQ,kBAAkB;CACxC,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,CAAC,GAAG,GAAG,KAAK,WAAW,KAAK;CAClC,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoB,YAA4B;EACxD,QAAQ,GAAG,OAAO,SAAS;GACzB,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,cAAc,QAAQ;EACxB;EACA,SAAS,GAAG,OAAO,SA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,iCAAiC;GACjD,mBAAmB;GACnB,wBAAwB;GACxB,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB,IAAI;GACrB,kBACE,iBACA,mBAAmB,KAAK,KACxB,EAAE,sDAAsD;IACtD,YAAY,IAAI;IAChB,YAAY,IAAI;GAClB,CAAC;GACH,MAAM;GACN,UAAU,cAAc,IAAI;EAC9B,GACA,OACA,EAAE,UAAU,CACd,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAQY;EACZ;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-saturation-slider.js","names":["clampNumber","roundNumberToStep","handlerAll"],"sources":["../../../../src/components/saturation-slider/use-saturation-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n handlerAll,\n mergeRefs,\n roundNumberToStep,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { runKeyAction } from \"../../utils/dom\"\nimport { useFieldProps } from \"../field\"\n\nfunction clampValue(value: [number, number, number]) {\n return [\n clampNumber(value[0], 0, 360),\n clampNumber(value[1], 0, 1),\n clampNumber(value[2], 0, 1),\n ] as [number, number, number]\n}\n\nexport interface UseSaturationSliderProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The initial value of the saturation slider.\n *\n * @default [0, 0, 1]\n */\n defaultValue?: [number, number, number]\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * The value of the saturation slider.\n */\n value?: [number, number, number]\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: [number, number, number]) => string | undefined\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: [number, number, number]) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: [number, number, number]) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: [number, number, number]) => void\n}\n\nexport const useSaturationSlider = (props: UseSaturationSliderProps = {}) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n defaultValue = [0, 0, 1],\n disabled,\n getAriaValueText,\n readOnly,\n required,\n step = 0.01,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const { t } = useI18n(\"saturationSlider\")\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [h, s, v] = clampValue(value)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeEnd?.(panValue)\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n setValue(panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChangeStart?.(value)\n setValue(panValue)\n },\n })\n\n const onChange = useCallback(\n ([h, s, v]: [number, number, number]) => {\n if (!interactive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue([h, s, v])\n },\n [interactive, setValue],\n )\n\n const getPanValue = useCallback(\n (\n { x, y }: Point,\n { bottom, height, left, width }: DOMRect,\n ): [number, number, number] => {\n const diff = { x: x - left, y: bottom - y }\n const percent = { x: diff.x / width, y: diff.y / height }\n const clamp = {\n x: clampNumber(percent.x, 0, 1),\n y: clampNumber(percent.y, 0, 1),\n }\n const s = roundNumberToStep(clamp.x, 0, step)\n const v = roundNumberToStep(clamp.y, 0, step)\n\n return [h, parseFloat(s), parseFloat(v)]\n },\n [h, step],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => onChange([h, s, v - step]),\n ArrowLeft: () => onChange([h, s - step, v]),\n ArrowRight: () => onChange([h, s + step, v]),\n ArrowUp: () => onChange([h, s, v + step]),\n })\n },\n [h, onChange, s, step, v],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const merged = mergeProps(dataProps, rest, props)()\n\n return {\n ...merged,\n style: {\n ...rest.style,\n ...props.style,\n \"--x\": `${Math.abs(s * 100)}%`,\n \"--y\": `${Math.abs(100 - v * 100)}%`,\n backgroundColor: `hsl(${h}, 100%, 50%)`,\n backgroundImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n },\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n },\n [dataProps, eventProps, h, rest, s, v],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n ...props,\n ref: mergeRefs(props.ref, ref),\n }),\n [\n ariaProps,\n dataProps,\n disabled,\n h,\n id,\n name,\n readOnly,\n ref,\n required,\n s,\n v,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}) => getPanEventProps({ ...dataProps, ...props }),\n [dataProps, getPanEventProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n dataProps,\n ariaProps,\n {\n \"aria-label\": t(\"Saturation and brightness thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-roledescription\": \"2D slider\",\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value) ??\n t(\"Saturation {saturation}%, Brightness {brightness}%\", {\n brightness: v * 100,\n saturation: s * 100,\n }),\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n props,\n { onKeyDown },\n )(),\n [\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n interactive,\n onKeyDown,\n s,\n t,\n v,\n value,\n ],\n )\n\n return {\n setValue,\n value,\n getInputProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;AAqBA,SAAS,WAAW,OAAiC;CACnD,OAAO;GACLA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,GAAG;GAC5BA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,CAAC;GAC1BA,GAAAA,cAAAA,YAAAA,CAAY,MAAM,IAAI,GAAG,CAAC;CAC5B;AACF;AAqDA,MAAa,uBAAuB,QAAkC,CAAC,MAAM;CAC3E,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,eAAe;EAAC;EAAG;EAAG;CAAC,GACvB,UACA,kBACA,UACA,UACA,OAAO,KACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,EAAE,MAAM,QAAQ,kBAAkB;CACxC,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7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A;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,gBAA4B,aAC/B,QAAQ,CAAC,MAAM,iBAAiB;EAAE,GAAG;EAAW,GAAG;CAAM,CAAC,GAC3D,CAAC,WAAW,gBAAgB,CAC9B;CA0CA,OAAO;EACL;EACA;EACA;EACA;EACA,eA7CgC,aAC/B,QAAQ,CAAC,MACR,WACE,WACA,WACA;GACE,cAAc,EAAE,iCAAiC;GACjD,mBAAmB;GACnB,wBAAwB;GACxB,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB,IAAI;GACrB,kBACE,iBACA,mBAAmB,KAAK,KACxB,EAAE,sDAAsD;IACtD,YAAY,IAAI;IAChB,YAAY,IAAI;GAClB,CAAC;GACH,MAAM;GACN,UAAU,cAAc,IAAI;EAC9B,GACA,OACA,EAAE,UAAU,CACd,CAAC,CAAC,GACJ;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAQY;EACZ;EACA;CACF;AACF"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { runKeyAction, visuallyHiddenAttributes } from "../../utils/dom.js";
3
- import { mergeRefs } from "../../utils/ref.js";
4
3
  import { mergeProps } from "../../core/components/props.js";
5
4
  import { useControllableState } from "../../hooks/use-controllable-state/index.js";
6
5
  import { usePanEvent } from "../../hooks/use-pan-event/index.js";
@@ -134,10 +133,7 @@ const useSlider = (props = {}) => {
134
133
  tenStep
135
134
  ]);
136
135
  const getRootProps = useCallback((props = {}) => {
137
- const computedProps = mergeProps(dataProps, { "data-orientation": orientation }, rest, props, {
138
- onBlur: eventProps.onBlur,
139
- onFocus: eventProps.onFocus
140
- })();
136
+ const computedProps = mergeProps(dataProps, { "data-orientation": orientation }, rest, props, eventProps)();
141
137
  computedProps.style ??= {};
142
138
  if ((0, utils_exports.isArray)(percent)) {
143
139
  computedProps.style["--range-start"] = `${Math.abs(percent[0])}%`;
@@ -154,20 +150,15 @@ const useSlider = (props = {}) => {
154
150
  percent,
155
151
  rest
156
152
  ]);
157
- const getInputProps = useCallback(({ index = 0, ...props } = {}) => ({
158
- ...visuallyHiddenAttributes,
159
- ...dataProps,
160
- ...ariaProps,
153
+ const getInputProps = useCallback(({ index = 0, ...props } = {}) => mergeProps(visuallyHiddenAttributes, dataProps, ariaProps, {
161
154
  id,
162
155
  type: "hidden",
163
156
  name,
164
157
  disabled,
165
158
  readOnly,
166
159
  required,
167
- value: range ? value[index] : value,
168
- ...props,
169
- ref: index === 0 ? mergeRefs(props.ref, ref) : props.ref
170
- }), [
160
+ value: range ? value[index] : value
161
+ }, props, { ref: index === 0 ? ref : void 0 })(), [
171
162
  dataProps,
172
163
  ariaProps,
173
164
  id,
@@ -233,9 +224,7 @@ const useSlider = (props = {}) => {
233
224
  getRootProps,
234
225
  getThumbProps: useCallback(({ index = 0, ...rest } = {}) => {
235
226
  const { max, min } = getMinMax(index);
236
- return mergeProps({
237
- ...dataProps,
238
- ...ariaProps,
227
+ return mergeProps(dataProps, ariaProps, {
239
228
  "aria-label": t("Slider thumb"),
240
229
  "aria-labelledby": ariaLabelledBy,
241
230
  "aria-orientation": orientation,
@@ -1 +1 @@
1
- {"version":3,"file":"use-slider.js","names":["isNumber","valueToPercent","percentToValue","roundNumberToStep","clampNumber","isArray","dataAttr"],"sources":["../../../../src/components/slider/use-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type {\n HTMLProps,\n HTMLRefAttributes,\n Orientation,\n PropGetter,\n RequiredPropGetter,\n} from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n dataAttr,\n isArray,\n isNumber,\n mergeRefs,\n percentToValue,\n roundNumberToStep,\n runKeyAction,\n valueToPercent,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseSliderProps<Y extends [number, number] | number = number>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The minimum distance between slider thumbs.\n * Useful for preventing the thumbs from being too close together.\n *\n * @default 0\n */\n betweenThumbs?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: Y\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 100\n */\n max?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The orientation of the slider.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * The value of the slider.\n */\n value?: Y\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: number, index: number) => string | undefined\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: Y) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Y) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Y) => void\n}\n\nexport const useSlider = <Y extends [number, number] | number = number>(\n props: UseSliderProps<Y> = {},\n) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n betweenThumbs = 0,\n defaultValue = 0 as Y,\n disabled,\n getAriaValueText,\n max = 100,\n min = 0,\n orientation = \"horizontal\",\n readOnly,\n required,\n step = 1,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { t } = useI18n(\"slider\")\n const currentIndex = useRef(0)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const start = currentIndex.current === 0\n const oppositeIndex = currentIndex.current === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeEnd?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n onChangeEnd?.(panValue as Y)\n }\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChange(currentIndex.current, panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const distances = value.map((value) => Math.abs(value - panValue))\n const closest = Math.min(...distances)\n const index = distances.indexOf(closest)\n\n currentIndex.current = index\n\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeStart?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n currentIndex.current = 0\n\n onChangeStart?.(value)\n }\n\n onChange(currentIndex.current, panValue)\n },\n })\n const range = !isNumber(value)\n const percent = (\n range\n ? value.map((value) => valueToPercent(value, min, max))\n : valueToPercent(value, min, max)\n ) as Y extends number ? number : number[]\n const tenStep = (max - min) / 10\n const oneStep = step || (max - min) / 100\n\n if (max < min) console.warn(\"Do not assign a number less than 'min' to 'max'\")\n\n const getMinMax = useCallback(\n (index: number) => {\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = range ? value[oppositeIndex] : value\n\n return {\n max: range ? (start ? oppositeValue - betweenThumbs : max) : max,\n min: range ? (start ? min : oppositeValue + betweenThumbs) : min,\n }\n },\n [betweenThumbs, max, min, range, value],\n )\n\n const getPanValue = useCallback(\n ({ x, y }: Point, { bottom, height, left, width }: DOMRect) => {\n const diff = orientation === \"horizontal\" ? x - left : bottom - y\n const length = orientation === \"horizontal\" ? width : height\n const percent = diff / length\n\n let nextValue = percentToValue(percent, min, max)\n\n nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [orientation, min, max, step],\n )\n\n const onChange = useCallback(\n (index: number, value: number) => {\n if (!interactive) return\n\n const { max, min } = getMinMax(index)\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue((prev) => {\n if (isArray(prev)) {\n const next = [...prev]\n\n next[index] = value\n\n return next as Y\n } else {\n return value as Y\n }\n })\n },\n [getMinMax, interactive, oneStep, setValue],\n )\n\n const stepUp = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! + step)\n : onChange(index, value + step),\n [oneStep, range, onChange, value],\n )\n\n const stepDown = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! - step)\n : onChange(index, value - step),\n [oneStep, range, onChange, value],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLDivElement>) => {\n const { max, min } = getMinMax(index)\n\n runKeyAction(ev, {\n ArrowDown: () => stepDown(index),\n ArrowLeft: () => stepDown(index),\n ArrowRight: () => stepUp(index),\n ArrowUp: () => stepUp(index),\n End: () => onChange(index, max),\n Home: () => onChange(index, min),\n PageDown: () => stepDown(index, tenStep),\n PageUp: () => stepUp(index, tenStep),\n })\n },\n [getMinMax, onChange, stepDown, stepUp, tenStep],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const computedProps: HTMLProps = mergeProps(\n dataProps,\n { \"data-orientation\": orientation },\n rest,\n props,\n { onBlur: eventProps.onBlur, onFocus: eventProps.onFocus },\n )()\n\n computedProps.style ??= {}\n\n if (isArray(percent)) {\n computedProps.style[\"--range-start\"] = `${Math.abs(percent[0]!)}%`\n computedProps.style[\"--range-end\"] = `${Math.abs(percent[1]!)}%`\n } else {\n computedProps.style[\"--range-start\"] = \"0%\"\n computedProps.style[\"--range-end\"] = `${Math.abs(percent)}%`\n }\n\n return computedProps\n },\n [dataProps, eventProps, orientation, percent, rest],\n )\n\n const getInputProps: PropGetter<\"input\", { index?: number }> = useCallback(\n ({ index = 0, ...props } = {}) => ({\n ...visuallyHiddenAttributes,\n ...dataProps,\n ...ariaProps,\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: range ? value[index]! : value,\n ...props,\n ref: index === 0 ? mergeRefs(props.ref, ref) : props.ref,\n }),\n [\n dataProps,\n ariaProps,\n id,\n name,\n disabled,\n readOnly,\n required,\n range,\n value,\n ref,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props) =>\n getPanEventProps({\n ...dataProps,\n \"data-orientation\": orientation,\n ...props,\n }),\n [dataProps, getPanEventProps, orientation],\n )\n\n const getRangeProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n \"data-orientation\": orientation,\n \"data-range\": dataAttr(range),\n ...props,\n }),\n [dataProps, orientation, range],\n )\n\n const getMarkProps: RequiredPropGetter<\"div\", { value: number }> =\n useCallback(\n ({ style, value: valueProp, ...props }) => {\n const between = range\n ? value[0] < valueProp && valueProp < value[1]\n : valueProp < value\n const percent = valueToPercent(valueProp, min, max)\n\n return {\n ...dataProps,\n \"aria-hidden\": true,\n \"data-between\": dataAttr(between),\n \"data-orientation\": orientation,\n role: \"presentation\",\n ...props,\n style: { ...style, \"--mark-position\": `${percent}%` },\n }\n },\n [dataProps, max, min, orientation, range, value],\n )\n\n const getThumbProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ index = 0, ...rest } = {}) => {\n const { max, min } = getMinMax(index)\n\n return mergeProps(\n {\n ...dataProps,\n ...ariaProps,\n \"aria-label\": t(\"Slider thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-orientation\": orientation,\n \"aria-valuemax\": max,\n \"aria-valuemin\": min,\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n range\n ? {\n \"aria-valuenow\": value[index]!,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value[index]!, index) ??\n value[index]!.toString(),\n \"data-end\": dataAttr(index === 1),\n \"data-start\": dataAttr(index === 0),\n }\n : {\n \"aria-valuenow\": value,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value, index) ??\n value.toString(),\n \"data-end\": dataAttr(index === 0),\n },\n rest,\n { onKeyDown: onKeyDown(index) },\n )()\n },\n [\n t,\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n getMinMax,\n interactive,\n onKeyDown,\n orientation,\n range,\n value,\n ],\n )\n\n return {\n percent,\n range,\n setValue,\n stepDown,\n stepUp,\n value,\n getInputProps,\n getMarkProps,\n getRangeProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSliderReturn = ReturnType<typeof useSlider>\n"],"mappings":";;;;;;;;;;;AAyGA,MAAa,aACX,QAA2B,CAAC,MACzB;CACH,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,gBAAgB,GAChB,eAAe,GACf,UACA,kBACA,MAAM,KACN,MAAM,GACN,cAAc,cACd,UACA,UACA,OAAO,GACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAM,QAAQ,QAAQ;CAC9B,MAAM,eAAe,OAAO,CAAC;CAC7B,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoB,YAA4B;EACxD,QAAQ,GAAG,O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;IACjB,iBAAiB;IACjB,MAAM;IACN,UAAU,cAAc,IAAI;GAC9B,GACA,QACI;IACE,iBAAiB,MAAM;IACvB,kBACE,iBACA,mBAAmB,MAAM,QAAS,KAAK,KACvC,MAAM,MAAM,CAAE,SAAS;IACzB,aAAA,GAAYA,cAAAA,SAAAA,CAAS,UAAU,CAAC;IAChC,eAAA,GAAcA,cAAAA,SAAAA,CAAS,UAAU,CAAC;GACpC,IACA;IACE,iBAAiB;IACjB,kBACE,iBACA,mBAAmB,OAAO,KAAK,KAC/B,MAAM,SAAS;IACjB,aAAA,GAAYA,cAAAA,SAAAA,CAAS,UAAU,CAAC;GAClC,GACJ,MACA,EAAE,WAAW,UAAU,KAAK,EAAE,CAChC,CAAC,CAAC;EACJ,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAcY;EACZ;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-slider.js","names":["isNumber","valueToPercent","percentToValue","roundNumberToStep","clampNumber","isArray","dataAttr"],"sources":["../../../../src/components/slider/use-slider.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type {\n HTMLProps,\n HTMLRefAttributes,\n Orientation,\n PropGetter,\n RequiredPropGetter,\n} from \"../../core\"\nimport type { Point } from \"../../utils\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useRef } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { usePanEvent } from \"../../hooks/use-pan-event\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n clampNumber,\n dataAttr,\n isArray,\n isNumber,\n percentToValue,\n roundNumberToStep,\n runKeyAction,\n valueToPercent,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nexport interface UseSliderProps<Y extends [number, number] | number = number>\n extends\n Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"ref\">,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * The minimum distance between slider thumbs.\n * Useful for preventing the thumbs from being too close together.\n *\n * @default 0\n */\n betweenThumbs?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: Y\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 100\n */\n max?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The orientation of the slider.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * The value of the slider.\n */\n value?: Y\n /**\n * This is used to format the value so that screen readers\n * can speak out a more human-friendly value.\n *\n * It is used to set the `aria-valuetext` property of the input.\n */\n getAriaValueText?: (value: number, index: number) => string | undefined\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: Y) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Y) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Y) => void\n}\n\nexport const useSlider = <Y extends [number, number] | number = number>(\n props: UseSliderProps<Y> = {},\n) => {\n const {\n props: {\n id,\n ref,\n name,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n betweenThumbs = 0,\n defaultValue = 0 as Y,\n disabled,\n getAriaValueText,\n max = 100,\n min = 0,\n orientation = \"horizontal\",\n readOnly,\n required,\n step = 1,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const { t } = useI18n(\"slider\")\n const currentIndex = useRef(0)\n const interactive = !(disabled || readOnly)\n const [_, getPanEventProps] = usePanEvent<HTMLDivElement>({\n onEnd: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const start = currentIndex.current === 0\n const oppositeIndex = currentIndex.current === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeEnd?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n onChangeEnd?.(panValue as Y)\n }\n },\n onMove: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n onChange(currentIndex.current, panValue)\n },\n onStart: (_, point, rect) => {\n if (!interactive) return\n\n const panValue = getPanValue(point, rect)\n\n if (range) {\n const distances = value.map((value) => Math.abs(value - panValue))\n const closest = Math.min(...distances)\n const index = distances.indexOf(closest)\n\n currentIndex.current = index\n\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = value[oppositeIndex]\n\n onChangeStart?.(\n (start ? [panValue, oppositeValue] : [oppositeValue, panValue]) as Y,\n )\n } else {\n currentIndex.current = 0\n\n onChangeStart?.(value)\n }\n\n onChange(currentIndex.current, panValue)\n },\n })\n const range = !isNumber(value)\n const percent = (\n range\n ? value.map((value) => valueToPercent(value, min, max))\n : valueToPercent(value, min, max)\n ) as Y extends number ? number : number[]\n const tenStep = (max - min) / 10\n const oneStep = step || (max - min) / 100\n\n if (max < min) console.warn(\"Do not assign a number less than 'min' to 'max'\")\n\n const getMinMax = useCallback(\n (index: number) => {\n const start = index === 0\n const oppositeIndex = index === 0 ? 1 : 0\n const oppositeValue = range ? value[oppositeIndex] : value\n\n return {\n max: range ? (start ? oppositeValue - betweenThumbs : max) : max,\n min: range ? (start ? min : oppositeValue + betweenThumbs) : min,\n }\n },\n [betweenThumbs, max, min, range, value],\n )\n\n const getPanValue = useCallback(\n ({ x, y }: Point, { bottom, height, left, width }: DOMRect) => {\n const diff = orientation === \"horizontal\" ? x - left : bottom - y\n const length = orientation === \"horizontal\" ? width : height\n const percent = diff / length\n\n let nextValue = percentToValue(percent, min, max)\n\n nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [orientation, min, max, step],\n )\n\n const onChange = useCallback(\n (index: number, value: number) => {\n if (!interactive) return\n\n const { max, min } = getMinMax(index)\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue((prev) => {\n if (isArray(prev)) {\n const next = [...prev]\n\n next[index] = value\n\n return next as Y\n } else {\n return value as Y\n }\n })\n },\n [getMinMax, interactive, oneStep, setValue],\n )\n\n const stepUp = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! + step)\n : onChange(index, value + step),\n [oneStep, range, onChange, value],\n )\n\n const stepDown = useCallback(\n (index: number, step = oneStep) =>\n range\n ? onChange(index, value[index]! - step)\n : onChange(index, value - step),\n [oneStep, range, onChange, value],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLDivElement>) => {\n const { max, min } = getMinMax(index)\n\n runKeyAction(ev, {\n ArrowDown: () => stepDown(index),\n ArrowLeft: () => stepDown(index),\n ArrowRight: () => stepUp(index),\n ArrowUp: () => stepUp(index),\n End: () => onChange(index, max),\n Home: () => onChange(index, min),\n PageDown: () => stepDown(index, tenStep),\n PageUp: () => stepUp(index, tenStep),\n })\n },\n [getMinMax, onChange, stepDown, stepUp, tenStep],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => {\n const computedProps: HTMLProps = mergeProps(\n dataProps,\n { \"data-orientation\": orientation },\n rest,\n props,\n eventProps,\n )()\n\n computedProps.style ??= {}\n\n if (isArray(percent)) {\n computedProps.style[\"--range-start\"] = `${Math.abs(percent[0]!)}%`\n computedProps.style[\"--range-end\"] = `${Math.abs(percent[1]!)}%`\n } else {\n computedProps.style[\"--range-start\"] = \"0%\"\n computedProps.style[\"--range-end\"] = `${Math.abs(percent)}%`\n }\n\n return computedProps\n },\n [dataProps, eventProps, orientation, percent, rest],\n )\n\n const getInputProps: PropGetter<\"input\", { index?: number }> = useCallback(\n ({ index = 0, ...props } = {}) =>\n mergeProps(\n visuallyHiddenAttributes,\n dataProps,\n ariaProps,\n {\n id,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: range ? value[index]! : value,\n },\n props,\n { ref: index === 0 ? ref : undefined },\n )(),\n [\n dataProps,\n ariaProps,\n id,\n name,\n disabled,\n readOnly,\n required,\n range,\n value,\n ref,\n ],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props) =>\n getPanEventProps({\n ...dataProps,\n \"data-orientation\": orientation,\n ...props,\n }),\n [dataProps, getPanEventProps, orientation],\n )\n\n const getRangeProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n \"data-orientation\": orientation,\n \"data-range\": dataAttr(range),\n ...props,\n }),\n [dataProps, orientation, range],\n )\n\n const getMarkProps: RequiredPropGetter<\"div\", { value: number }> =\n useCallback(\n ({ style, value: valueProp, ...props }) => {\n const between = range\n ? value[0] < valueProp && valueProp < value[1]\n : valueProp < value\n const percent = valueToPercent(valueProp, min, max)\n\n return {\n ...dataProps,\n \"aria-hidden\": true,\n \"data-between\": dataAttr(between),\n \"data-orientation\": orientation,\n role: \"presentation\",\n ...props,\n style: { ...style, \"--mark-position\": `${percent}%` },\n }\n },\n [dataProps, max, min, orientation, range, value],\n )\n\n const getThumbProps: PropGetter<\"div\", { index?: number }> = useCallback(\n ({ index = 0, ...rest } = {}) => {\n const { max, min } = getMinMax(index)\n\n return mergeProps(\n dataProps,\n ariaProps,\n {\n \"aria-label\": t(\"Slider thumb\"),\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-orientation\": orientation,\n \"aria-valuemax\": max,\n \"aria-valuemin\": min,\n role: \"slider\",\n tabIndex: interactive ? 0 : -1,\n },\n range\n ? {\n \"aria-valuenow\": value[index]!,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value[index]!, index) ??\n value[index]!.toString(),\n \"data-end\": dataAttr(index === 1),\n \"data-start\": dataAttr(index === 0),\n }\n : {\n \"aria-valuenow\": value,\n \"aria-valuetext\":\n ariaValueText ??\n getAriaValueText?.(value, index) ??\n value.toString(),\n \"data-end\": dataAttr(index === 0),\n },\n rest,\n { onKeyDown: onKeyDown(index) },\n )()\n },\n [\n t,\n ariaLabelledBy,\n ariaProps,\n ariaValueText,\n dataProps,\n getAriaValueText,\n getMinMax,\n interactive,\n onKeyDown,\n orientation,\n range,\n value,\n ],\n )\n\n return {\n percent,\n range,\n setValue,\n stepDown,\n stepUp,\n value,\n getInputProps,\n getMarkProps,\n getRangeProps,\n getRootProps,\n getThumbProps,\n getTrackProps,\n onChange,\n }\n}\n\nexport type UseSliderReturn = ReturnType<typeof useSlider>\n"],"mappings":";;;;;;;;;;AAwGA,MAAa,aACX,QAA2B,CAAC,MACzB;CACH,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,gBAAgB,GAChB,eAAe,GACf,UACA,kBACA,MAAM,KACN,MAAM,GACN,cAAc,cACd,UACA,UACA,OAAO,GACP,OAAO,WACP,UAAU,cACV,aACA,eACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,EAAE,MAAM,QAAQ,QAAQ;CAC9B,MAAM,eAAe,OAAO,CAAC;CAC7B,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,GAAG,oBAAoB,YAA4B;EACxD,QAAQ,GAAG,OAAO,SAAS;GACzB,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,IAAI,OAAO;IACT,MAAM,QAAQ,aAAa,YAAY;IACvC,MAAM,gBAAgB,aAAa,YAAY,IAAI,IAAI;IACvD,MAAM,gBAAgB,MAAM;IAE5B,cACG,QAAQ,CAAC,UAAU,aAAa,I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BACA,mBAAmB,OAAO,KAAK,KAC/B,MAAM,SAAS;IACjB,aAAA,GAAYA,cAAAA,SAAAA,CAAS,UAAU,CAAC;GAClC,GACJ,MACA,EAAE,WAAW,UAAU,KAAK,EAAE,CAChC,CAAC,CAAC;EACJ,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAcY;EACZ;EACA;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const alertStyle: ComponentSlotStyle<"title" | "loading" | "icon" | "description" | "root", CSSPropObject<CSSSlotObject<"title" | "loading" | "icon" | "description" | "root">>, CSSModifierObject<CSSSlotObject<"title" | "loading" | "icon" | "description" | "root">>, {
4
+ export declare const alertStyle: ComponentSlotStyle<"title" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, CSSModifierObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, {
5
5
  island: {
6
6
  description: {
7
7
  color: "fg.muted";
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const carouselStyle: ComponentSlotStyle<"list" | "next" | "item" | "root" | "prev" | "trigger" | "indicator" | "indicators", CSSPropObject<CSSSlotObject<"list" | "next" | "item" | "root" | "prev" | "trigger" | "indicator" | "indicators">>, {
4
+ export declare const carouselStyle: ComponentSlotStyle<"list" | "next" | "item" | "root" | "prev" | "indicator" | "trigger" | "indicators", CSSPropObject<CSSSlotObject<"list" | "next" | "item" | "root" | "prev" | "indicator" | "trigger" | "indicators">>, {
5
5
  sm: {
6
6
  root: {
7
7
  h: "sm";
@@ -17,5 +17,5 @@ export declare const carouselStyle: ComponentSlotStyle<"list" | "next" | "item"
17
17
  h: "lg";
18
18
  };
19
19
  };
20
- }, CSSModifierObject<CSSSlotObject<"list" | "next" | "item" | "root" | "prev" | "trigger" | "indicator" | "indicators">>>;
20
+ }, CSSModifierObject<CSSSlotObject<"list" | "next" | "item" | "root" | "prev" | "indicator" | "trigger" | "indicators">>>;
21
21
  export type CarouselStyle = typeof carouselStyle;
@@ -63,7 +63,7 @@ export interface CheckboxCardRootProps<Y extends string = string> extends Merge<
63
63
  */
64
64
  rootProps?: HTMLStyledProps<"label">;
65
65
  }
66
- declare const component: <H extends "fragment" | As = "div", R extends import("@yamada-ui/utils").Dict = import("@yamada-ui/utils").Dict<any>>(el: H | import("react").FC<R>, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
66
+ declare const component: <H extends "fragment" | As = "div", R extends import("@yamada-ui/utils").Dict = import("@yamada-ui/utils").Dict<any>>(el: H | import("react").FC<R>, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
67
67
  justify: {
68
68
  end: {
69
69
  addon: {
@@ -209,7 +209,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
209
209
  };
210
210
  };
211
211
  };
212
- }>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, CheckboxCardPropsContext: import("react").Context<Partial<CheckboxCardRootProps<string>> | undefined>, useCheckboxCardPropsContext: () => Partial<CheckboxCardRootProps<string>> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
212
+ }>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, CheckboxCardPropsContext: import("react").Context<Partial<CheckboxCardRootProps<string>> | undefined>, useCheckboxCardPropsContext: () => Partial<CheckboxCardRootProps<string>> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
213
213
  justify: {
214
214
  end: {
215
215
  addon: {
@@ -355,7 +355,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
355
355
  };
356
356
  };
357
357
  };
358
- }>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, Merge<WithoutThemeProps<Y, ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
358
+ }>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, Merge<WithoutThemeProps<Y, ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
359
359
  justify: {
360
360
  end: {
361
361
  addon: {
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const checkboxCardStyle: ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
3
+ export declare const checkboxCardStyle: ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
4
4
  /**
5
5
  * The justify indicator of the component
6
6
  *
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const colorPickerStyle: ComponentSlotStyle<"input" | "content" | "icon" | "colorSwatch" | "root" | "eyeDropper" | "field", CSSPropObject<CSSSlotObject<"input" | "content" | "icon" | "colorSwatch" | "root" | "eyeDropper" | "field">>, {
4
+ export declare const colorPickerStyle: ComponentSlotStyle<"input" | "content" | "icon" | "root" | "colorSwatch" | "eyeDropper" | "field", CSSPropObject<CSSSlotObject<"input" | "content" | "icon" | "root" | "colorSwatch" | "eyeDropper" | "field">>, {
5
5
  xs: {
6
6
  field: {
7
7
  fontSize: "1em";
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const colorSelectorStyle: ComponentSlotStyle<"hueSlider" | "saturationSlider" | "root" | "eyeDropper" | "colorSwatchGroupLabel" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchItem", {
4
+ export declare const colorSelectorStyle: ComponentSlotStyle<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "colorSwatchGroupLabel" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchItem", {
5
5
  /**
6
6
  * The shape of the thumb and color swatch.
7
7
  *
@@ -22,5 +22,5 @@ export declare const colorSelectorStyle: ComponentSlotStyle<"hueSlider" | "satur
22
22
  md: {};
23
23
  lg: {};
24
24
  xl: {};
25
- }, CSSModifierObject<CSSSlotObject<"hueSlider" | "saturationSlider" | "root" | "eyeDropper" | "colorSwatchGroupLabel" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchItem">>>;
25
+ }, CSSModifierObject<CSSSlotObject<"root" | "hueSlider" | "saturationSlider" | "eyeDropper" | "colorSwatchGroupLabel" | "alphaSlider" | "colorSwatchGroup" | "colorSwatchItem">>>;
26
26
  export type ColorSelectorStyle = typeof colorSelectorStyle;
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const dataListStyle: ComponentSlotStyle<"term" | "description" | "item" | "root", {
3
+ export declare const dataListStyle: ComponentSlotStyle<"term" | "item" | "root" | "description", {
4
4
  /**
5
5
  * The orientation of the data list.
6
6
  *
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const drawerStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "content" | "overlay" | "closeButton" | "root" | "dragBar", {
4
+ export declare const drawerStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton" | "dragBar", {
5
5
  /**
6
6
  * The placement of the drawer.
7
7
  *
@@ -117,5 +117,5 @@ export declare const drawerStyle: ComponentSlotStyle<"body" | "footer" | "header
117
117
  rounded: "0";
118
118
  };
119
119
  };
120
- }, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "closeButton" | "root" | "dragBar">>>;
120
+ }, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton" | "dragBar">>>;
121
121
  export type DrawerStyle = typeof drawerStyle;
@@ -33,7 +33,7 @@ declare const DropzonePropsContext: import("react").Context<Partial<DropzoneRoot
33
33
  *
34
34
  * @see https://yamada-ui.com/docs/components/dropzone
35
35
  */
36
- export declare const DropzoneRoot: Component<({ children, errorBorderColor, focusBorderColor, loadingScheme, inputProps, loadingProps, overlayProps, ...rest }: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "description" | "root", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "description" | "root">>, {
36
+ export declare const DropzoneRoot: Component<({ children, errorBorderColor, focusBorderColor, loadingScheme, inputProps, loadingProps, overlayProps, ...rest }: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
37
37
  xs: {
38
38
  root: {
39
39
  minH: "xs";
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const dropzoneStyle: ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "description" | "root", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "description" | "root">>, {
4
+ export declare const dropzoneStyle: ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
5
5
  xs: {
6
6
  root: {
7
7
  minH: "xs";
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const emptyState: ComponentSlotStyle<"title" | "content" | "description" | "root" | "indicator", CSSPropObject<CSSSlotObject<"title" | "content" | "description" | "root" | "indicator">>, {
4
+ export declare const emptyState: ComponentSlotStyle<"title" | "content" | "root" | "description" | "indicator", CSSPropObject<CSSSlotObject<"title" | "content" | "root" | "description" | "indicator">>, {
5
5
  sm: {
6
6
  content: {
7
7
  gap: "xs";
@@ -47,5 +47,5 @@ export declare const emptyState: ComponentSlotStyle<"title" | "content" | "descr
47
47
  fontSize: "xl";
48
48
  };
49
49
  };
50
- }, CSSModifierObject<CSSSlotObject<"title" | "content" | "description" | "root" | "indicator">>>;
50
+ }, CSSModifierObject<CSSSlotObject<"title" | "content" | "root" | "description" | "indicator">>>;
51
51
  export type EmptyState = typeof emptyState;
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const fileInputStyle: ComponentSlotStyle<"tag" | "root", CSSPropObject<CSSSlotObject<"tag" | "root">>, {
4
+ export declare const fileInputStyle: ComponentSlotStyle<"root" | "tag", CSSPropObject<CSSSlotObject<"root" | "tag">>, {
5
5
  xs: {
6
6
  root: {
7
7
  "&:has(~ [data-input-element])"?: {
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const formStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "group" | "description" | "root" | "submitButton", CSSPropObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "group" | "description" | "root" | "submitButton">>, {
4
+ export declare const formStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "group" | "root" | "description" | "submitButton", CSSPropObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "group" | "root" | "description" | "submitButton">>, {
5
5
  sm: {
6
6
  body: {
7
7
  gap: "5";
@@ -1,7 +1,7 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const modalStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "content" | "overlay" | "closeButton" | "root", {
4
+ export declare const modalStyle: ComponentSlotStyle<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton", {
5
5
  /**
6
6
  * The placement of the modal.
7
7
  *
@@ -155,5 +155,5 @@ export declare const modalStyle: ComponentSlotStyle<"body" | "footer" | "header"
155
155
  p: "0";
156
156
  };
157
157
  };
158
- }, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "closeButton" | "root">>>;
158
+ }, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton">>>;
159
159
  export type ModalStyle = typeof modalStyle;
@@ -1,5 +1,5 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
3
3
  import "../../index.js";
4
- export declare const noticeStyle: ComponentSlotStyle<"content" | "closeButton" | "item" | "root", CSSPropObject<CSSSlotObject<"content" | "closeButton" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"content" | "closeButton" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"content" | "closeButton" | "item" | "root">>>;
4
+ export declare const noticeStyle: ComponentSlotStyle<"content" | "item" | "root" | "closeButton", CSSPropObject<CSSSlotObject<"content" | "item" | "root" | "closeButton">>, CSSModifierObject<CSSSlotObject<"content" | "item" | "root" | "closeButton">>, CSSModifierObject<CSSSlotObject<"content" | "item" | "root" | "closeButton">>>;
5
5
  export type NoticeStyle = typeof noticeStyle;
@@ -55,7 +55,7 @@ export interface RadioCardRootProps<Y extends string = string> extends Merge<HTM
55
55
  */
56
56
  rootProps?: HTMLStyledProps<"label">;
57
57
  }
58
- declare const component: <H extends "fragment" | As = "div", R extends import("@yamada-ui/utils").Dict = import("@yamada-ui/utils").Dict<any>>(el: H | import("react").FC<R>, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
58
+ declare const component: <H extends "fragment" | As = "div", R extends import("@yamada-ui/utils").Dict = import("@yamada-ui/utils").Dict<any>>(el: H | import("react").FC<R>, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
59
59
  justify: {
60
60
  end: {
61
61
  addon: {
@@ -228,7 +228,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
228
228
  };
229
229
  };
230
230
  };
231
- }>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, RadioCardPropsContext: import("react").Context<Partial<RadioCardRootProps<string>> | undefined>, useRadioCardPropsContext: () => Partial<RadioCardRootProps<string>> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
231
+ }>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, RadioCardPropsContext: import("react").Context<Partial<RadioCardRootProps<string>> | undefined>, useRadioCardPropsContext: () => Partial<RadioCardRootProps<string>> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
232
232
  justify: {
233
233
  end: {
234
234
  addon: {
@@ -401,7 +401,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
401
401
  };
402
402
  };
403
403
  };
404
- }>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, Merge<WithoutThemeProps<Y, ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
404
+ }>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, Merge<WithoutThemeProps<Y, ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
405
405
  justify: {
406
406
  end: {
407
407
  addon: {
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const radioCardStyle: ComponentSlotStyle<"group" | "description" | "root" | "indicator" | "addon", {
3
+ export declare const radioCardStyle: ComponentSlotStyle<"group" | "root" | "description" | "indicator" | "addon", {
4
4
  /**
5
5
  * The justify indicator of the component
6
6
  *
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const stepsStyle: ComponentSlotStyle<"title" | "list" | "separator" | "description" | "item" | "root" | "indicator", {
3
+ export declare const stepsStyle: ComponentSlotStyle<"title" | "list" | "separator" | "item" | "root" | "description" | "indicator", {
4
4
  /**
5
5
  * The orientation of the steps.
6
6
  *
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const tagStyle: ComponentSlotStyle<"content" | "icon" | "closeButton" | "root" | "endIcon" | "startIcon", {
3
+ export declare const tagStyle: ComponentSlotStyle<"content" | "icon" | "root" | "endIcon" | "startIcon" | "closeButton", {
4
4
  /**
5
5
  * If `true`, the tag is full rounded. Else, it'll be slightly round.
6
6
  *
@@ -61,7 +61,7 @@ declare const TimelinePropsContext: import("react").Context<Partial<TimelineRoot
61
61
  *
62
62
  * @see https://yamada-ui.com/docs/components/timeline
63
63
  */
64
- export declare const TimelineRoot: Component<({ variant: variantProp, children, index, items, ...rest }: WithoutThemeProps<TimelineRootProps, ComponentSlotStyle<"title" | "content" | "description" | "item" | "root" | "indicator" | "connector", {
64
+ export declare const TimelineRoot: Component<({ variant: variantProp, children, index, items, ...rest }: WithoutThemeProps<TimelineRootProps, ComponentSlotStyle<"title" | "content" | "item" | "root" | "description" | "indicator" | "connector", {
65
65
  align: {
66
66
  center: {
67
67
  content: {
@@ -1,6 +1,6 @@
1
1
  import { ComponentSlotStyle } from "../../core/system/index.type.js";
2
2
  import "../../index.js";
3
- export declare const timelineStyle: ComponentSlotStyle<"title" | "content" | "description" | "item" | "root" | "indicator" | "connector", {
3
+ export declare const timelineStyle: ComponentSlotStyle<"title" | "content" | "item" | "root" | "description" | "indicator" | "connector", {
4
4
  /**
5
5
  * The alignment of the timeline.
6
6
  *
@@ -123,7 +123,7 @@ declare const I18nContext: import("react").Context<I18nContext<{
123
123
  readonly toggle: {
124
124
  readonly "Toggle button": "Toggle button";
125
125
  };
126
- }, "progress" | "select" | "table" | "toggle" | "slider" | "autocomplete" | "avatar" | "breadcrumb" | "calendar" | "carousel" | "closeButton" | "colorPicker" | "colorSelector" | "colorSwatch" | "datePicker" | "hueSlider" | "numberInput" | "pagination" | "passwordInput" | "saturationSlider" | "sidebar" | "stat" | "tag" | "progress.Loading..." | "progress.{value} percent" | "select.Clear value" | "table.Clear sorting" | "table.Page size" | "table.Select all rows" | "table.Select row" | "table.Sort ascending" | "table.Sort descending" | "toggle.Toggle button" | "slider.Slider thumb" | "autocomplete.Clear value" | "autocomplete.No results found" | "avatar.Avatar Icon" | "breadcrumb.Breadcrumb" | "breadcrumb.Ellipsis" | "calendar.Choose the month" | "calendar.Choose the year" | "calendar.Go to the next month" | "calendar.Go to the previous month" | "calendar.Today" | "carousel.Go to next slide" | "carousel.Go to previous slide" | "carousel.Go to {page} slide" | "carousel.Slides" | "carousel.{page} of {total}" | "closeButton.Close" | "colorPicker.Pick a color" | "colorSelector.Pick a color" | "colorSwatch.Color swatch group" | "datePicker.Clear value" | "hueSlider.Blue" | "hueSlider.Cyan" | "hueSlider.Green" | "hueSlider.Magenta" | "hueSlider.Red" | "hueSlider.Yellow" | "numberInput.Decrease" | "numberInput.Increase" | "pagination.Go to first page" | "pagination.Go to last page" | "pagination.Go to next page" | "pagination.Go to page {value}" | "pagination.Go to previous page" | "pagination.Pagination" | "pagination.{value} / {total}" | "pagination.{value} of {total}" | "passwordInput.Password strength meter" | "passwordInput.Toggle password visibility" | "saturationSlider.Saturation and brightness thumb" | "saturationSlider.Saturation {saturation}%, Brightness {brightness}%" | "sidebar.Close sidebar" | "sidebar.Open sidebar" | "stat.Decreased by" | "stat.Increased by" | "tag.Close tag">>;
126
+ }, "progress" | "select" | "table" | "toggle" | "slider" | "tag" | "autocomplete" | "avatar" | "breadcrumb" | "calendar" | "carousel" | "closeButton" | "colorPicker" | "colorSelector" | "colorSwatch" | "datePicker" | "hueSlider" | "numberInput" | "pagination" | "passwordInput" | "saturationSlider" | "sidebar" | "stat" | "progress.Loading..." | "progress.{value} percent" | "select.Clear value" | "table.Clear sorting" | "table.Page size" | "table.Select all rows" | "table.Select row" | "table.Sort ascending" | "table.Sort descending" | "toggle.Toggle button" | "slider.Slider thumb" | "tag.Close tag" | "autocomplete.Clear value" | "autocomplete.No results found" | "avatar.Avatar Icon" | "breadcrumb.Breadcrumb" | "breadcrumb.Ellipsis" | "calendar.Choose the month" | "calendar.Choose the year" | "calendar.Go to the next month" | "calendar.Go to the previous month" | "calendar.Today" | "carousel.Go to next slide" | "carousel.Go to previous slide" | "carousel.Go to {page} slide" | "carousel.Slides" | "carousel.{page} of {total}" | "closeButton.Close" | "colorPicker.Pick a color" | "colorSelector.Pick a color" | "colorSwatch.Color swatch group" | "datePicker.Clear value" | "hueSlider.Blue" | "hueSlider.Cyan" | "hueSlider.Green" | "hueSlider.Magenta" | "hueSlider.Red" | "hueSlider.Yellow" | "numberInput.Decrease" | "numberInput.Increase" | "pagination.Go to first page" | "pagination.Go to last page" | "pagination.Go to next page" | "pagination.Go to page {value}" | "pagination.Go to previous page" | "pagination.Pagination" | "pagination.{value} / {total}" | "pagination.{value} of {total}" | "passwordInput.Password strength meter" | "passwordInput.Toggle password visibility" | "saturationSlider.Saturation and brightness thumb" | "saturationSlider.Saturation {saturation}%, Brightness {brightness}%" | "sidebar.Close sidebar" | "sidebar.Open sidebar" | "stat.Decreased by" | "stat.Increased by">>;
127
127
  export interface I18nProviderProps {
128
128
  children?: ReactNode;
129
129
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yamada-ui/react",
3
3
  "type": "module",
4
- "version": "2.3.4-dev-20261116070336",
4
+ "version": "2.3.4-dev-20261116074825",
5
5
  "description": "React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion",
6
6
  "keywords": [
7
7
  "yamada",