@yamada-ui/react 2.3.4-dev-20261116071016 → 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.
- package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs +1 -3
- package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
- package/dist/cjs/components/slider/use-slider.cjs +5 -16
- package/dist/cjs/components/slider/use-slider.cjs.map +1 -1
- package/dist/esm/components/saturation-slider/use-saturation-slider.js +1 -3
- package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
- package/dist/esm/components/slider/use-slider.js +5 -16
- package/dist/esm/components/slider/use-slider.js.map +1 -1
- package/dist/types/components/accordion/accordion.style.d.ts +1 -1
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/avatar/avatar.d.ts +3 -3
- package/dist/types/components/avatar/avatar.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/types/components/bubble/bubble.style.d.ts +1 -1
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/chart/cartesian-chart.style.d.ts +1 -1
- package/dist/types/components/chart/polar-chart.style.d.ts +1 -1
- package/dist/types/components/checkbox-card/checkbox-card.d.ts +3 -3
- package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
- package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
- package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
- package/dist/types/components/data-list/data-list.style.d.ts +1 -1
- package/dist/types/components/drawer/drawer.style.d.ts +2 -2
- package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
- package/dist/types/components/file-input/file-input.style.d.ts +1 -1
- package/dist/types/components/flip/flip.d.ts +1 -1
- package/dist/types/components/flip/flip.style.d.ts +1 -1
- package/dist/types/components/list/list.style.d.ts +2 -2
- package/dist/types/components/marquee/marquee.style.d.ts +1 -1
- package/dist/types/components/modal/modal.style.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
- package/dist/types/components/notice/notice.style.d.ts +1 -1
- package/dist/types/components/number-input/number-input.style.d.ts +1 -1
- package/dist/types/components/pagination/pagination.style.d.ts +1 -1
- package/dist/types/components/radio-card/radio-card.d.ts +3 -3
- package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
- package/dist/types/components/rating/rating.style.d.ts +2 -2
- package/dist/types/components/reorder/reorder.style.d.ts +1 -1
- package/dist/types/components/resizable/resizable.style.d.ts +2 -2
- package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
- package/dist/types/components/select/select.style.d.ts +1 -1
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/tag/tag.style.d.ts +1 -1
- package/dist/types/components/timeline/timeline.d.ts +1 -1
- package/dist/types/components/timeline/timeline.style.d.ts +1 -1
- package/dist/types/components/tree/tree.style.d.ts +1 -1
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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,OAAO,SAAS;GAC1B,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,SAAS,QAAQ;EACnB;EACA,UAAU,GAAG,OA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ACA;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,EACJ,OAAO,EACL,IACA,KACA,MACA,mBAAmB,gBACnB,kBAAkB,eAClB,eAAe;EAAC;EAAG;EAAG;CAAC,GACvB,UACA,kBACA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oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,WAAW,OAAO;EACvD;CACF,GACA;EAAC;EAAW;EAAY;EAAG;EAAM;EAAG;CAAC,CACvC;CAEA,MAAM,iBAAA,GAAqCD,MAAAA,YAAAA,EACxC,QAAQ,CAAC,OAAO;EACf,GAAGE,YAAAA;EACH,GAAG;EACH,GAAG;EACH;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,OAAO;GAAC;GAAG;GAAG;EAAC,CAAC,CAAC,SAAS;EAC1B,GAAG;EACH,KAAKC,YAAAA,UAAU,MAAM,KAAK,GAAG;CAC/B,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,iBAAA,GAA4BH,MAAAA,YAAAA,EAC/B,QAAQ,CAAC,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,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
|
const require_dom = 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
|
-
|
|
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,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AAA,WACL;IACE,GAAG;IACH,GAAG;IACH,cAAc,EAAE,cAAc;IAC9B,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;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,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;GA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;EACA;EACA,gBAAA,GAjE2DA,MAAAA,YAAAA,EAC1D,EAAE,QAAQ,GAAG,GAAG,SAAS,CAAC,MAAM;GAC/B,MAAM,EAAE,KAAK,QAAQ,UAAU,KAAK;GAEpC,OAAOC,cAAAA,WACL,WACA,WACA;IACE,cAAc,EAAE,cAAc;IAC9B,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;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,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"}
|
|
@@ -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,SAAS;GAC1B,IAAI,CAAC,aAAa;GAElB,MAAM,WAAW,YAAY,OAAO,IAAI;GAExC,SAAS,QAAQ;EACnB;EACA,U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ACE,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;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,CAAC,GAAG,GAAG,KAAK,WAAW,KAAK;CAClC,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,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
|
-
|
|
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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EACF,GACA;GAAC;GAAW;GAAK;GAAK;GAAa;GAAO;EAAK,CAiEtC;EACX;EACA;EACA,eAjE2D,aAC1D,EAAE,QAAQ,GAAG,GAAG,SAAS,CAAC,MAAM;GAC/B,MAAM,EAAE,KAAK,QAAQ,UAAU,KAAK;GAEpC,OAAO,WACL;IACE,GAAG;IACH,GAAG;IACH,cAAc,EAAE,cAAc;IAC9B,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;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,YAA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AiB;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,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 accordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "
|
|
4
|
+
export declare const accordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "item" | "root", CSSPropObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, {
|
|
5
5
|
panel: {
|
|
6
6
|
button: {
|
|
7
7
|
rounded: "l2";
|
|
@@ -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 autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "
|
|
4
|
+
export declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "field" | "empty" | "indicator" | "valueText", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "field" | "empty" | "indicator" | "valueText">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
empty: {
|
|
7
7
|
gap: "1.5";
|
|
@@ -21,7 +21,7 @@ export interface AvatarProps extends HTMLStyledProps, ThemeProps<AvatarStyle>, U
|
|
|
21
21
|
*/
|
|
22
22
|
imageProps?: AvatarImageProps;
|
|
23
23
|
}
|
|
24
|
-
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<"image" | "group" | "
|
|
24
|
+
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<"image" | "group" | "root" | "fallback", {
|
|
25
25
|
shape: {
|
|
26
26
|
circle: {
|
|
27
27
|
root: {
|
|
@@ -140,7 +140,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
|
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
|
-
}>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, AvatarPropsContext: import("react").Context<Partial<AvatarProps> | undefined>, useAvatarPropsContext: () => Partial<AvatarProps> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"image" | "group" | "
|
|
143
|
+
}>>> | undefined, { name, className, ...options }?: ComponentOptions) => (initialProps?: InitialProps<R>, ...superProps: SuperProps<R>[]) => H extends "fragment" ? import("react").FunctionComponent<R> : Component<Exclude<H, "fragment">, R>, AvatarPropsContext: import("react").Context<Partial<AvatarProps> | undefined>, useAvatarPropsContext: () => Partial<AvatarProps> | undefined, useRootComponentProps: <Y extends import("@yamada-ui/utils").Dict = {}, R extends keyof Y = keyof Y>(props: Y, slot?: ComponentSlot<ComponentSlotName<ComponentSlotStyle<"image" | "group" | "root" | "fallback", {
|
|
144
144
|
shape: {
|
|
145
145
|
circle: {
|
|
146
146
|
root: {
|
|
@@ -259,7 +259,7 @@ declare const component: <H extends "fragment" | As = "div", R extends import("@
|
|
|
259
259
|
};
|
|
260
260
|
};
|
|
261
261
|
};
|
|
262
|
-
}>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, import("@yamada-ui/utils").Merge<WithoutThemeProps<Y, ComponentSlotStyle<"image" | "group" | "
|
|
262
|
+
}>>> | undefined, { className, withContext, transferProps }?: UseComponentPropsOptions<R>) => [CSSSlotObject, import("@yamada-ui/utils").Merge<WithoutThemeProps<Y, ComponentSlotStyle<"image" | "group" | "root" | "fallback", {
|
|
263
263
|
shape: {
|
|
264
264
|
circle: {
|
|
265
265
|
root: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
2
2
|
import "../../index.js";
|
|
3
|
-
export declare const avatarStyle: ComponentSlotStyle<"image" | "group" | "
|
|
3
|
+
export declare const avatarStyle: ComponentSlotStyle<"image" | "group" | "root" | "fallback", {
|
|
4
4
|
/**
|
|
5
5
|
* The shape 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 breadcrumbStyle: ComponentSlotStyle<"link" | "list" | "separator" | "ellipsis" | "
|
|
4
|
+
export declare const breadcrumbStyle: ComponentSlotStyle<"link" | "list" | "separator" | "ellipsis" | "item" | "root", CSSPropObject<CSSSlotObject<"link" | "list" | "separator" | "ellipsis" | "item" | "root">>, {
|
|
5
5
|
sm: {
|
|
6
6
|
list: {
|
|
7
7
|
fontSize: "sm";
|
|
@@ -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 bubbleStyle: ComponentSlotStyle<"content" | "group" | "
|
|
4
|
+
export declare const bubbleStyle: ComponentSlotStyle<"content" | "group" | "item" | "root" | "reactions", CSSPropObject<CSSSlotObject<"content" | "group" | "item" | "root" | "reactions">>, {
|
|
5
5
|
sm: {
|
|
6
6
|
content: {
|
|
7
7
|
"--space-y": "spaces.2";
|
|
@@ -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 calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "
|
|
4
|
+
export declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "prev" | "month" | "week" | "weekday" | "day" | "months" | "years" | "weeks" | "control", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, the calendar will be fixed rows.
|
|
7
7
|
*
|
|
@@ -73,5 +73,5 @@ export declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "ce
|
|
|
73
73
|
"--font-size": "fontSizes.xl";
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "
|
|
76
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "prev" | "month" | "week" | "weekday" | "day" | "months" | "years" | "weeks" | "control">>>;
|
|
77
77
|
export type CalendarStyle = typeof calendarStyle;
|
|
@@ -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" | "
|
|
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" | "prev"
|
|
|
17
17
|
h: "lg";
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
}, CSSModifierObject<CSSSlotObject<"list" | "next" | "
|
|
20
|
+
}, CSSModifierObject<CSSSlotObject<"list" | "next" | "item" | "root" | "prev" | "indicator" | "trigger" | "indicators">>>;
|
|
21
21
|
export type CarouselStyle = typeof carouselStyle;
|
|
@@ -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 cartesianChartStyle: ComponentSlotStyle<"area" | "line" | "grid" | "bar" | "dot" | "root" | "
|
|
4
|
+
export declare const cartesianChartStyle: ComponentSlotStyle<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine", CSSPropObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>>;
|
|
5
5
|
export type CartesianChartStyle = typeof cartesianChartStyle;
|
|
@@ -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 polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "
|
|
4
|
+
export declare const polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "radial" | "labelLine" | "activeDot" | "labelList" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector", CSSPropObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "radial" | "labelLine" | "activeDot" | "labelList" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "radial" | "labelLine" | "activeDot" | "labelList" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "radial" | "labelLine" | "activeDot" | "labelList" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>>;
|
|
5
5
|
export type PolarChartStyle = typeof polarChartStyle;
|
|
@@ -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" | "root" | "
|
|
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" | "root" | "
|
|
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" | "root" | "
|
|
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" | "root" | "
|
|
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" | "
|
|
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<"
|
|
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<"
|
|
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" | "
|
|
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" | "
|
|
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" | "
|
|
120
|
+
}, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton" | "dragBar">>>;
|
|
121
121
|
export type DrawerStyle = typeof drawerStyle;
|
|
@@ -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" | "root" | "
|
|
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" | "root"
|
|
|
47
47
|
fontSize: "xl";
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
-
}, CSSModifierObject<CSSSlotObject<"title" | "content" | "root" | "
|
|
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<"
|
|
4
|
+
export declare const fileInputStyle: ComponentSlotStyle<"root" | "tag", CSSPropObject<CSSSlotObject<"root" | "tag">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
root: {
|
|
7
7
|
"&:has(~ [data-input-element])"?: {
|
|
@@ -67,5 +67,5 @@ declare const FlipPropsContext: import("react").Context<Partial<FlipProps> | und
|
|
|
67
67
|
*
|
|
68
68
|
* @see https://yamada-ui.com/docs/components/flip
|
|
69
69
|
*/
|
|
70
|
-
export declare const Flip: Component<({ defaultValue, delay, disabled, duration, from, orientation, readOnly, to, transition, value: valueProp, onChange, onClick: onClickProp, ...rest }: WithoutThemeProps<FlipProps, ComponentSlotStyle<"from" | "to" | "
|
|
70
|
+
export declare const Flip: Component<({ defaultValue, delay, disabled, duration, from, orientation, readOnly, to, transition, value: valueProp, onChange, onClick: onClickProp, ...rest }: WithoutThemeProps<FlipProps, ComponentSlotStyle<"from" | "to" | "item" | "root", CSSPropObject<CSSSlotObject<"from" | "to" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"from" | "to" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"from" | "to" | "item" | "root">>>, keyof FlipProps>) => import("react").JSX.Element, FlipProps>;
|
|
71
71
|
export { FlipPropsContext, useFlipPropsContext };
|
|
@@ -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 flipStyle: ComponentSlotStyle<"from" | "to" | "
|
|
4
|
+
export declare const flipStyle: ComponentSlotStyle<"from" | "to" | "item" | "root", CSSPropObject<CSSSlotObject<"from" | "to" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"from" | "to" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"from" | "to" | "item" | "root">>>;
|
|
5
5
|
export type FlipStyle = typeof flipStyle;
|
|
@@ -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 listStyle: ComponentSlotStyle<"icon" | "
|
|
4
|
+
export declare const listStyle: ComponentSlotStyle<"icon" | "item" | "root", {
|
|
5
5
|
styleType: {
|
|
6
6
|
circle: {
|
|
7
7
|
root: {
|
|
@@ -35,5 +35,5 @@ export declare const listStyle: ComponentSlotStyle<"icon" | "root" | "item", {
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
}, CSSModifierObject<CSSSlotObject<"icon" | "
|
|
38
|
+
}, CSSModifierObject<CSSSlotObject<"icon" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"icon" | "item" | "root">>>;
|
|
39
39
|
export type ListStyle = typeof listStyle;
|
|
@@ -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 marqueeStyle: ComponentSlotStyle<"content" | "group" | "
|
|
4
|
+
export declare const marqueeStyle: ComponentSlotStyle<"content" | "group" | "item" | "root" | "edge", CSSPropObject<CSSSlotObject<"content" | "group" | "item" | "root" | "edge">>, CSSModifierObject<CSSSlotObject<"content" | "group" | "item" | "root" | "edge">>, CSSModifierObject<CSSSlotObject<"content" | "group" | "item" | "root" | "edge">>>;
|
|
5
5
|
export type MarqueeStyle = typeof marqueeStyle;
|
|
@@ -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" | "
|
|
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" | "
|
|
158
|
+
}, CSSModifierObject<CSSSlotObject<"body" | "footer" | "header" | "title" | "content" | "overlay" | "root" | "closeButton">>>;
|
|
159
159
|
export type ModalStyle = typeof modalStyle;
|
|
@@ -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 nativeAccordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "
|
|
4
|
+
export declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "item" | "root", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, animate the accordion items when they are expanded or collapsed.
|
|
7
7
|
*
|
|
@@ -31,7 +31,7 @@ export declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "panel"
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "
|
|
34
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, {
|
|
35
35
|
panel: {
|
|
36
36
|
button: {
|
|
37
37
|
rounded: "l2";
|
|
@@ -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" | "
|
|
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;
|
|
@@ -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 numberInputStyle: ComponentSlotStyle<"button" | "root" | "
|
|
4
|
+
export declare const numberInputStyle: ComponentSlotStyle<"button" | "root" | "field" | "decrement" | "increment" | "control", CSSPropObject<CSSSlotObject<"button" | "root" | "field" | "decrement" | "increment" | "control">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
control: {
|
|
7
7
|
boxSize: "calc({--height} - {spaces.2})";
|
|
@@ -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 paginationStyle: ComponentSlotStyle<"text" | "
|
|
4
|
+
export declare const paginationStyle: ComponentSlotStyle<"text" | "item" | "root", CSSPropObject<CSSSlotObject<"text" | "item" | "root">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
item: {
|
|
7
7
|
fontSize: "{font-size}";
|
|
@@ -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" | "root" | "
|
|
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" | "root" | "
|
|
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" | "root" | "
|
|
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" | "root" | "
|
|
3
|
+
export declare const radioCardStyle: 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 { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.type.js";
|
|
3
3
|
import "../../index.js";
|
|
4
|
-
export declare const ratingStyle: ComponentSlotStyle<"group" | "icon" | "
|
|
4
|
+
export declare const ratingStyle: ComponentSlotStyle<"group" | "icon" | "item" | "root", CSSPropObject<CSSSlotObject<"group" | "icon" | "item" | "root">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
icon: {
|
|
7
7
|
fontSize: "md";
|
|
@@ -27,5 +27,5 @@ export declare const ratingStyle: ComponentSlotStyle<"group" | "icon" | "root" |
|
|
|
27
27
|
fontSize: "3xl";
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
}, CSSModifierObject<CSSSlotObject<"group" | "icon" | "
|
|
30
|
+
}, CSSModifierObject<CSSSlotObject<"group" | "icon" | "item" | "root">>>;
|
|
31
31
|
export type RatingStyle = typeof ratingStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
2
2
|
import "../../index.js";
|
|
3
|
-
export declare const reorderStyle: ComponentSlotStyle<"
|
|
3
|
+
export declare const reorderStyle: ComponentSlotStyle<"item" | "root" | "trigger", {
|
|
4
4
|
/**
|
|
5
5
|
* The orientation of the reorder.
|
|
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 resizableStyle: ComponentSlotStyle<"icon" | "
|
|
4
|
+
export declare const resizableStyle: ComponentSlotStyle<"icon" | "item" | "root" | "trigger", {
|
|
5
5
|
/**
|
|
6
6
|
* The orientation of the resizable.
|
|
7
7
|
*
|
|
@@ -19,7 +19,7 @@ export declare const resizableStyle: ComponentSlotStyle<"icon" | "root" | "item"
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
}, CSSModifierObject<CSSSlotObject<"icon" | "
|
|
22
|
+
}, CSSModifierObject<CSSSlotObject<"icon" | "item" | "root" | "trigger">>, {
|
|
23
23
|
border: {
|
|
24
24
|
icon: {
|
|
25
25
|
bg: "colorScheme.muted";
|
|
@@ -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 segmentedControlStyle: ComponentSlotStyle<"
|
|
4
|
+
export declare const segmentedControlStyle: ComponentSlotStyle<"item" | "root" | "indicator", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, the segmented control will be full rounded.
|
|
7
7
|
*
|
|
@@ -113,5 +113,5 @@ export declare const segmentedControlStyle: ComponentSlotStyle<"root" | "item" |
|
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
|
-
}, CSSModifierObject<CSSSlotObject<"
|
|
116
|
+
}, CSSModifierObject<CSSSlotObject<"item" | "root" | "indicator">>>;
|
|
117
117
|
export type SegmentedControlStyle = typeof segmentedControlStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.type.js";
|
|
2
2
|
import "../../index.js";
|
|
3
|
-
export declare const selectStyle: ComponentSlotStyle<"label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "
|
|
3
|
+
export declare const selectStyle: ComponentSlotStyle<"label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "field" | "indicator" | "valueText", {
|
|
4
4
|
/**
|
|
5
5
|
* If `true`, wrap the value text.
|
|
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" | "
|
|
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" | "
|
|
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" | "
|
|
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" | "
|
|
3
|
+
export declare const timelineStyle: ComponentSlotStyle<"title" | "content" | "item" | "root" | "description" | "indicator" | "connector", {
|
|
4
4
|
/**
|
|
5
5
|
* The alignment of the timeline.
|
|
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 treeStyle: ComponentSlotStyle<"label" | "checkbox" | "group" | "end" | "start" | "element" | "
|
|
3
|
+
export declare const treeStyle: ComponentSlotStyle<"label" | "checkbox" | "group" | "end" | "start" | "element" | "item" | "root" | "indicator", {
|
|
4
4
|
/**
|
|
5
5
|
* The shape of the component
|
|
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" | "
|
|
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-
|
|
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",
|