@yamada-ui/color-picker 1.4.10-dev-20241115173924 → 1.4.10-dev-20241117113320
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-YU3KOEL7.mjs → chunk-AJTCPCFF.mjs} +2 -2
- package/dist/{chunk-RW7HCRPR.mjs → chunk-ASZZSRFB.mjs} +2 -2
- package/dist/{chunk-XCHWCHHP.mjs → chunk-LEN56PPD.mjs} +4 -4
- package/dist/chunk-LEN56PPD.mjs.map +1 -0
- package/dist/{chunk-TED6IK5W.mjs → chunk-QWG3QE6A.mjs} +2 -2
- package/dist/color-picker.js +3 -3
- package/dist/color-picker.js.map +1 -1
- package/dist/color-picker.mjs +4 -4
- package/dist/color-selector.js +3 -3
- package/dist/color-selector.js.map +1 -1
- package/dist/color-selector.mjs +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/saturation-slider.js +3 -3
- package/dist/saturation-slider.js.map +1 -1
- package/dist/saturation-slider.mjs +2 -2
- package/dist/use-saturation-slider.js +3 -3
- package/dist/use-saturation-slider.js.map +1 -1
- package/dist/use-saturation-slider.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-XCHWCHHP.mjs.map +0 -1
- /package/dist/{chunk-YU3KOEL7.mjs.map → chunk-AJTCPCFF.mjs.map} +0 -0
- /package/dist/{chunk-RW7HCRPR.mjs.map → chunk-ASZZSRFB.mjs.map} +0 -0
- /package/dist/{chunk-TED6IK5W.mjs.map → chunk-QWG3QE6A.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
ColorPicker
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-ASZZSRFB.mjs";
|
5
5
|
import "./chunk-Z2KAER2U.mjs";
|
6
6
|
import {
|
7
7
|
ColorSelector
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-QWG3QE6A.mjs";
|
9
9
|
import {
|
10
10
|
SaturationSlider
|
11
|
-
} from "./chunk-
|
12
|
-
import "./chunk-
|
11
|
+
} from "./chunk-AJTCPCFF.mjs";
|
12
|
+
import "./chunk-LEN56PPD.mjs";
|
13
13
|
import "./chunk-XSZZBWND.mjs";
|
14
14
|
import "./chunk-RJOBF4LI.mjs";
|
15
15
|
import "./chunk-6XIZXZXV.mjs";
|
@@ -56,7 +56,7 @@ var useSaturationSlider = ({
|
|
56
56
|
...props
|
57
57
|
}) => {
|
58
58
|
if (!focusThumbOnChange) props.isReadOnly = true;
|
59
|
-
|
59
|
+
const {
|
60
60
|
id,
|
61
61
|
name,
|
62
62
|
defaultValue = [0, 0, 1],
|
@@ -263,8 +263,8 @@ var useSaturationSlider = ({
|
|
263
263
|
style,
|
264
264
|
"aria-valuemax": 100,
|
265
265
|
"aria-valuemin": 0,
|
266
|
-
"aria-valuenow": s,
|
267
|
-
"aria-valuetext": `
|
266
|
+
"aria-valuenow": s * 100,
|
267
|
+
"aria-valuetext": `Saturation ${s * 100}%, Brightness ${v * 100}%`,
|
268
268
|
"data-active": (0, import_utils.dataAttr)(isDragging && focusThumbOnChange),
|
269
269
|
role: "slider",
|
270
270
|
tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/saturation-slider.tsx","../src/use-saturation-slider.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { UseSaturationSliderProps } from \"./use-saturation-slider\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { cx, replaceObject } from \"@yamada-ui/utils\"\nimport { useSaturationSlider } from \"./use-saturation-slider\"\n\ninterface SaturationSliderOptions {\n /**\n * The aspect ratio of the saturation slider.\n *\n * @default '16 / 9'\n */\n ratio?: Token<number>\n /**\n * Props for saturation slider inner element.\n */\n innerProps?: HTMLUIProps\n /**\n * Props for saturation slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for saturation slider thumb element.\n */\n thumbProps?: HTMLUIProps\n /**\n * Props for saturation slider track element.\n */\n trackProps?: HTMLUIProps\n}\n\nexport interface SaturationSliderProps\n extends ThemeProps<\"SaturationSlider\">,\n UseSaturationSliderProps,\n SaturationSliderOptions {}\n\n/**\n * `SaturationSlider` is a component used to allow the user to select a color saturation.\n *\n * @see Docs https://yamada-ui.com/components/forms/saturation-slider\n */\nexport const SaturationSlider = forwardRef<SaturationSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\n \"SaturationSlider\",\n props,\n )\n const {\n className,\n ratio = 16 / 9,\n innerProps,\n inputProps,\n thumbProps,\n trackProps,\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const {\n overlays,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n } = useSaturationSlider(computedProps)\n\n const css: CSSUIObject = {\n \"& > *\": {\n alignItems: \"center\",\n bottom: \"0\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: \"0\",\n position: \"absolute\",\n right: \"0\",\n top: \"0\",\n w: \"100%\",\n },\n position: \"relative\",\n _before: {\n content: `\"\"`,\n display: \"block\",\n h: 0,\n pb: replaceObject(ratio, (r) => `${(1 / r) * 100}%`),\n },\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-saturation-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.div\n className={cx(\"ui-saturation-slider__inner\", className)}\n __css={{ ...styles.inner }}\n {...getInnerProps(innerProps)}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-saturation-slider__overlay\"\n __css={{\n bottom: 0,\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-saturation-slider__track\"\n __css={{\n h: \"100%\",\n position: \"relative\",\n w: \"100%\",\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-saturation-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n </ui.div>\n )\n },\n)\n\nSaturationSlider.displayName = \"SaturationSlider\"\nSaturationSlider.__ui__ = \"SaturationSlider\"\n","import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n hsvTo,\n mergeRefs,\n roundNumberToStep,\n runIfFunc,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = ((value: Hsv) => HTMLUIProps) | HTMLUIProps\n\nconst defaultOverlays = (withShadow: boolean): Overlay[] => {\n let overlays: Overlay[] = [\n ([h]) => ({\n bg: `hsl(${h}, 100%, 50%)`,\n bgImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n }),\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface UseSaturationSliderOptions {\n /**\n * The base `id` to use for the saturation 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 initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * If `false`, the saturation slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * The value of the saturation slider.\n */\n value?: Hsv\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n}\n\nexport interface UseSaturationSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseSaturationSliderOptions,\n FormControlOptions {}\n\nexport const useSaturationSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseSaturationSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n defaultValue = [0, 0, 1],\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n step = 0.01,\n thumbColor,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd: onChangeEndProp,\n onChangeStart: onChangeStartProp,\n ...rest\n } = useFormControlProps(props)\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n disabled,\n readOnly,\n required,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n let [h, s, v] = value\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const overlays = useMemo(\n () => overlaysProp.map((propsOrFunc) => runIfFunc(propsOrFunc, [h, s, v])),\n [overlaysProp, h, s, v],\n )\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return []\n\n const { step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { bottom, height, left, width } =\n trackRef.current.getBoundingClientRect()\n const { clientX, clientY } = ev.touches?.[0] ?? ev\n\n let s = clampNumber((clientX - left) / width, 0, 1)\n let v = clampNumber((bottom - clientY) / height, 0, 1)\n\n if (step) {\n s = parseFloat(roundNumberToStep(s, 0, step))\n v = parseFloat(roundNumberToStep(v, 0, step))\n }\n\n return [s, v]\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | PointerEvent | TouchEvent) => {\n const { value } = latestRef.current\n const [nextS, nextV] = getValueFromPointer(ev)\n\n if (nextS == null || nextV == null) return\n\n const [, s, v] = value\n\n if (nextS !== s || nextV !== v) setValue(([h]) => [h, nextS, nextV])\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n ([s, v]: [number, number]) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue(([h]) => [h, s, v])\n },\n [latestRef, setValue],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => constrain([s, v - step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [latestRef, constrain, s, v, step],\n )\n\n usePanEvent(containerRef, {\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...containerProps,\n ...formControlProps,\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [containerProps, formControlProps],\n )\n\n const getInnerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n padding: `${w / 2}px`,\n }\n\n return {\n ...props,\n ref,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n }),\n [formControlProps, id, name, h, s, v, required, disabled, readOnly],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [formControlProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { height, width } = thumbSize ?? { height: 0, width: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n bottom: `calc(${y}% - ${height / 2}px)`,\n left: `calc(${x}% - ${width / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n \"aria-roledescription\": \"2D slider\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s,\n \"aria-valuetext\": `saturation ${s}, brightness ${v}`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbSize,\n s,\n v,\n thumbColor,\n h,\n formControlProps,\n isInteractive,\n focusThumbOnChange,\n isDragging,\n onKeyDown,\n rest,\n ],\n )\n\n return {\n overlays,\n value,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAKO;AACP,IAAAA,gBAAkC;;;ACVlC,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAWO;AACP,mBAAuD;AAKvD,IAAM,kBAAkB,CAAC,eAAmC;AAC1D,MAAI,WAAsB;AAAA,IACxB,CAAC,CAAC,C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","s","v","value","h","focusThumbOnChange","isInteractive","props","props"]}
|
1
|
+
{"version":3,"sources":["../src/saturation-slider.tsx","../src/use-saturation-slider.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { UseSaturationSliderProps } from \"./use-saturation-slider\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { cx, replaceObject } from \"@yamada-ui/utils\"\nimport { useSaturationSlider } from \"./use-saturation-slider\"\n\ninterface SaturationSliderOptions {\n /**\n * The aspect ratio of the saturation slider.\n *\n * @default '16 / 9'\n */\n ratio?: Token<number>\n /**\n * Props for saturation slider inner element.\n */\n innerProps?: HTMLUIProps\n /**\n * Props for saturation slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for saturation slider thumb element.\n */\n thumbProps?: HTMLUIProps\n /**\n * Props for saturation slider track element.\n */\n trackProps?: HTMLUIProps\n}\n\nexport interface SaturationSliderProps\n extends ThemeProps<\"SaturationSlider\">,\n UseSaturationSliderProps,\n SaturationSliderOptions {}\n\n/**\n * `SaturationSlider` is a component used to allow the user to select a color saturation.\n *\n * @see Docs https://yamada-ui.com/components/forms/saturation-slider\n */\nexport const SaturationSlider = forwardRef<SaturationSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\n \"SaturationSlider\",\n props,\n )\n const {\n className,\n ratio = 16 / 9,\n innerProps,\n inputProps,\n thumbProps,\n trackProps,\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const {\n overlays,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n } = useSaturationSlider(computedProps)\n\n const css: CSSUIObject = {\n \"& > *\": {\n alignItems: \"center\",\n bottom: \"0\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: \"0\",\n position: \"absolute\",\n right: \"0\",\n top: \"0\",\n w: \"100%\",\n },\n position: \"relative\",\n _before: {\n content: `\"\"`,\n display: \"block\",\n h: 0,\n pb: replaceObject(ratio, (r) => `${(1 / r) * 100}%`),\n },\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-saturation-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.div\n className={cx(\"ui-saturation-slider__inner\", className)}\n __css={{ ...styles.inner }}\n {...getInnerProps(innerProps)}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-saturation-slider__overlay\"\n __css={{\n bottom: 0,\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-saturation-slider__track\"\n __css={{\n h: \"100%\",\n position: \"relative\",\n w: \"100%\",\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-saturation-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n </ui.div>\n )\n },\n)\n\nSaturationSlider.displayName = \"SaturationSlider\"\nSaturationSlider.__ui__ = \"SaturationSlider\"\n","import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n hsvTo,\n mergeRefs,\n roundNumberToStep,\n runIfFunc,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = ((value: Hsv) => HTMLUIProps) | HTMLUIProps\n\nconst defaultOverlays = (withShadow: boolean): Overlay[] => {\n let overlays: Overlay[] = [\n ([h]) => ({\n bg: `hsl(${h}, 100%, 50%)`,\n bgImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n }),\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface UseSaturationSliderOptions {\n /**\n * The base `id` to use for the saturation 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 initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * If `false`, the saturation slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * The value of the saturation slider.\n */\n value?: Hsv\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n}\n\nexport interface UseSaturationSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseSaturationSliderOptions,\n FormControlOptions {}\n\nexport const useSaturationSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseSaturationSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n const {\n id,\n name,\n defaultValue = [0, 0, 1],\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n step = 0.01,\n thumbColor,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd: onChangeEndProp,\n onChangeStart: onChangeStartProp,\n ...rest\n } = useFormControlProps(props)\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n disabled,\n readOnly,\n required,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n let [h, s, v] = value\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const overlays = useMemo(\n () => overlaysProp.map((propsOrFunc) => runIfFunc(propsOrFunc, [h, s, v])),\n [overlaysProp, h, s, v],\n )\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return []\n\n const { step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { bottom, height, left, width } =\n trackRef.current.getBoundingClientRect()\n const { clientX, clientY } = ev.touches?.[0] ?? ev\n\n let s = clampNumber((clientX - left) / width, 0, 1)\n let v = clampNumber((bottom - clientY) / height, 0, 1)\n\n if (step) {\n s = parseFloat(roundNumberToStep(s, 0, step))\n v = parseFloat(roundNumberToStep(v, 0, step))\n }\n\n return [s, v]\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | PointerEvent | TouchEvent) => {\n const { value } = latestRef.current\n const [nextS, nextV] = getValueFromPointer(ev)\n\n if (nextS == null || nextV == null) return\n\n const [, s, v] = value\n\n if (nextS !== s || nextV !== v) setValue(([h]) => [h, nextS, nextV])\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n ([s, v]: [number, number]) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue(([h]) => [h, s, v])\n },\n [latestRef, setValue],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => constrain([s, v - step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [latestRef, constrain, s, v, step],\n )\n\n usePanEvent(containerRef, {\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...containerProps,\n ...formControlProps,\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [containerProps, formControlProps],\n )\n\n const getInnerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n padding: `${w / 2}px`,\n }\n\n return {\n ...props,\n ref,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n }),\n [formControlProps, id, name, h, s, v, required, disabled, readOnly],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [formControlProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { height, width } = thumbSize ?? { height: 0, width: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n bottom: `calc(${y}% - ${height / 2}px)`,\n left: `calc(${x}% - ${width / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n \"aria-roledescription\": \"2D slider\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\": `Saturation ${s * 100}%, Brightness ${v * 100}%`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbSize,\n s,\n v,\n thumbColor,\n h,\n formControlProps,\n isInteractive,\n focusThumbOnChange,\n isDragging,\n onKeyDown,\n rest,\n ],\n )\n\n return {\n overlays,\n value,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAKO;AACP,IAAAA,gBAAkC;;;ACVlC,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAWO;AACP,mBAAuD;AAKvD,IAAM,kBAAkB,CAAC,eAAmC;AAC1D,MAAI,WAAsB;AAAA,IACxB,CAAC,CAAC,CAAC,OAAO;AAAA,MACR,IAAI,OAAO,CAAC;AAAA,MACZ,SACE;AAAA,IACJ;AAAA,EACF;AAEA,MAAI;AACF,eAAW;AAAA,MACT,GAAG;AAAA,MACH;AAAA,QACE,WAAW;AAAA,MACb;AAAA,IACF;AAEF,SAAO;AACT;AAmEO,IAAM,sBAAsB,CAAC;AAAA,EAClC,qBAAqB;AAAA,EACrB,GAAG;AACL,MAAgC;AAC9B,MAAI,CAAC,mBAAoB,OAAM,aAAa;AAE5C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,eAAe,CAAC,GAAG,GAAG,CAAC;AAAA,IACvB,aAAa;AAAA,IACb,UAAU,eAAe,gBAAgB,UAAU;AAAA,IACnD,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,IACb,eAAe;AAAA,IACf,GAAG;AAAA,EACL,QAAI,yCAAoB,KAAK;AAC7B,QAAM;AAAA,IACJ;AAAA,MACE,iBAAiB;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA;AAAA,EACF,QAAI,0BAAY,MA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AGA;AAAA;AAAA,gBAVC;AAAA,cAWP,CACD;AAAA,cAED;AAAA,gBAAC,eAAG;AAAA,gBAAH;AAAA,kBACC,WAAU;AAAA,kBACV,OAAO;AAAA,oBACL,GAAG;AAAA,oBACH,UAAU;AAAA,oBACV,GAAG;AAAA,oBACH,GAAG,OAAO;AAAA,kBACZ;AAAA,kBACC,GAAG,cAAc,UAAU;AAAA,kBAE5B;AAAA,oBAAC,eAAG;AAAA,oBAAH;AAAA,sBACC,WAAU;AAAA,sBACV,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,sBACxB,GAAG,cAAc,UAAU;AAAA;AAAA,kBAC9B;AAAA;AAAA,cACF;AAAA;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,iBAAiB,cAAc;AAC/B,iBAAiB,SAAS;","names":["import_utils","step","s","v","value","h","focusThumbOnChange","isInteractive","props","props"]}
|
@@ -52,7 +52,7 @@ var useSaturationSlider = ({
|
|
52
52
|
...props
|
53
53
|
}) => {
|
54
54
|
if (!focusThumbOnChange) props.isReadOnly = true;
|
55
|
-
|
55
|
+
const {
|
56
56
|
id,
|
57
57
|
name,
|
58
58
|
defaultValue = [0, 0, 1],
|
@@ -259,8 +259,8 @@ var useSaturationSlider = ({
|
|
259
259
|
style,
|
260
260
|
"aria-valuemax": 100,
|
261
261
|
"aria-valuemin": 0,
|
262
|
-
"aria-valuenow": s,
|
263
|
-
"aria-valuetext": `
|
262
|
+
"aria-valuenow": s * 100,
|
263
|
+
"aria-valuetext": `Saturation ${s * 100}%, Brightness ${v * 100}%`,
|
264
264
|
"data-active": (0, import_utils.dataAttr)(isDragging && focusThumbOnChange),
|
265
265
|
role: "slider",
|
266
266
|
tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-saturation-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n hsvTo,\n mergeRefs,\n roundNumberToStep,\n runIfFunc,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = ((value: Hsv) => HTMLUIProps) | HTMLUIProps\n\nconst defaultOverlays = (withShadow: boolean): Overlay[] => {\n let overlays: Overlay[] = [\n ([h]) => ({\n bg: `hsl(${h}, 100%, 50%)`,\n bgImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n }),\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface UseSaturationSliderOptions {\n /**\n * The base `id` to use for the saturation 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 initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * If `false`, the saturation slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * The value of the saturation slider.\n */\n value?: Hsv\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n}\n\nexport interface UseSaturationSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseSaturationSliderOptions,\n FormControlOptions {}\n\nexport const useSaturationSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseSaturationSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n defaultValue = [0, 0, 1],\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n step = 0.01,\n thumbColor,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd: onChangeEndProp,\n onChangeStart: onChangeStartProp,\n ...rest\n } = useFormControlProps(props)\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n disabled,\n readOnly,\n required,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n let [h, s, v] = value\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const overlays = useMemo(\n () => overlaysProp.map((propsOrFunc) => runIfFunc(propsOrFunc, [h, s, v])),\n [overlaysProp, h, s, v],\n )\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return []\n\n const { step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { bottom, height, left, width } =\n trackRef.current.getBoundingClientRect()\n const { clientX, clientY } = ev.touches?.[0] ?? ev\n\n let s = clampNumber((clientX - left) / width, 0, 1)\n let v = clampNumber((bottom - clientY) / height, 0, 1)\n\n if (step) {\n s = parseFloat(roundNumberToStep(s, 0, step))\n v = parseFloat(roundNumberToStep(v, 0, step))\n }\n\n return [s, v]\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | PointerEvent | TouchEvent) => {\n const { value } = latestRef.current\n const [nextS, nextV] = getValueFromPointer(ev)\n\n if (nextS == null || nextV == null) return\n\n const [, s, v] = value\n\n if (nextS !== s || nextV !== v) setValue(([h]) => [h, nextS, nextV])\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n ([s, v]: [number, number]) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue(([h]) => [h, s, v])\n },\n [latestRef, setValue],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => constrain([s, v - step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [latestRef, constrain, s, v, step],\n )\n\n usePanEvent(containerRef, {\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...containerProps,\n ...formControlProps,\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [containerProps, formControlProps],\n )\n\n const getInnerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n padding: `${w / 2}px`,\n }\n\n return {\n ...props,\n ref,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n }),\n [formControlProps, id, name, h, s, v, required, disabled, readOnly],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [formControlProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { height, width } = thumbSize ?? { height: 0, width: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n bottom: `calc(${y}% - ${height / 2}px)`,\n left: `calc(${x}% - ${width / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n \"aria-roledescription\": \"2D slider\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s,\n \"aria-valuetext\": `saturation ${s}, brightness ${v}`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbSize,\n s,\n v,\n thumbColor,\n h,\n formControlProps,\n isInteractive,\n focusThumbOnChange,\n isDragging,\n onKeyDown,\n rest,\n ],\n )\n\n return {\n overlays,\n value,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAWO;AACP,mBAAuD;AAKvD,IAAM,kBAAkB,CAAC,eAAmC;AAC1D,MAAI,WAAsB;AAAA,IACxB,CAAC,CAAC,CAAC,OAAO;AAAA,MACR,IAAI,OAAO,CAAC;AAAA,MACZ,SACE;AAAA,IACJ;AAAA,EACF;AAEA,MAAI;AACF,eAAW;AAAA,MACT,GAAG;AAAA,MACH;AAAA,QACE,WAAW;AAAA,MACb;AAAA,IACF;AAEF,SAAO;AACT;AAmEO,IAAM,sBAAsB,CAAC;AAAA,EAClC,qBAAqB;AAAA,EACrB,GAAG;AACL,MAAgC;AAC9B,MAAI,CAAC,mBAAoB,OAAM,aAAa;AAE5C,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,eAAe,CAAC,GAAG,GAAG,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F;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["step","s","v","value","h","focusThumbOnChange","isInteractive","props"]}
|
1
|
+
{"version":3,"sources":["../src/use-saturation-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n hsvTo,\n mergeRefs,\n roundNumberToStep,\n runIfFunc,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = ((value: Hsv) => HTMLUIProps) | HTMLUIProps\n\nconst defaultOverlays = (withShadow: boolean): Overlay[] => {\n let overlays: Overlay[] = [\n ([h]) => ({\n bg: `hsl(${h}, 100%, 50%)`,\n bgImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n }),\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface UseSaturationSliderOptions {\n /**\n * The base `id` to use for the saturation 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 initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * If `false`, the saturation slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * The value of the saturation slider.\n */\n value?: Hsv\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n}\n\nexport interface UseSaturationSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseSaturationSliderOptions,\n FormControlOptions {}\n\nexport const useSaturationSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseSaturationSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n const {\n id,\n name,\n defaultValue = [0, 0, 1],\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n step = 0.01,\n thumbColor,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd: onChangeEndProp,\n onChangeStart: onChangeStartProp,\n ...rest\n } = useFormControlProps(props)\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n disabled,\n readOnly,\n required,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n let [h, s, v] = value\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const overlays = useMemo(\n () => overlaysProp.map((propsOrFunc) => runIfFunc(propsOrFunc, [h, s, v])),\n [overlaysProp, h, s, v],\n )\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return []\n\n const { step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { bottom, height, left, width } =\n trackRef.current.getBoundingClientRect()\n const { clientX, clientY } = ev.touches?.[0] ?? ev\n\n let s = clampNumber((clientX - left) / width, 0, 1)\n let v = clampNumber((bottom - clientY) / height, 0, 1)\n\n if (step) {\n s = parseFloat(roundNumberToStep(s, 0, step))\n v = parseFloat(roundNumberToStep(v, 0, step))\n }\n\n return [s, v]\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | PointerEvent | TouchEvent) => {\n const { value } = latestRef.current\n const [nextS, nextV] = getValueFromPointer(ev)\n\n if (nextS == null || nextV == null) return\n\n const [, s, v] = value\n\n if (nextS !== s || nextV !== v) setValue(([h]) => [h, nextS, nextV])\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n ([s, v]: [number, number]) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue(([h]) => [h, s, v])\n },\n [latestRef, setValue],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => constrain([s, v - step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [latestRef, constrain, s, v, step],\n )\n\n usePanEvent(containerRef, {\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...containerProps,\n ...formControlProps,\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [containerProps, formControlProps],\n )\n\n const getInnerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n padding: `${w / 2}px`,\n }\n\n return {\n ...props,\n ref,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n }),\n [formControlProps, id, name, h, s, v, required, disabled, readOnly],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [formControlProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { height, width } = thumbSize ?? { height: 0, width: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n bottom: `calc(${y}% - ${height / 2}px)`,\n left: `calc(${x}% - ${width / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n \"aria-roledescription\": \"2D slider\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s * 100,\n \"aria-valuetext\": `Saturation ${s * 100}%, Brightness ${v * 100}%`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbSize,\n s,\n v,\n thumbColor,\n h,\n formControlProps,\n isInteractive,\n focusThumbOnChange,\n isDragging,\n onKeyDown,\n rest,\n ],\n )\n\n return {\n overlays,\n value,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAWO;AACP,mBAAuD;AAKvD,IAAM,kBAAkB,CAAC,eAAmC;AAC1D,MAAI,WAAsB;AAAA,IACxB,CAAC,CAAC,CAAC,OAAO;AAAA,MACR,IAAI,OAAO,CAAC;AAAA,MACZ,SACE;AAAA,IACJ;AAAA,EACF;AAEA,MAAI;A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,YAAQ,yBAAWA,OAAM,QAAQ,KAAK,MAAM;AAAA,QAC5C,aAAS,yBAAWA,OAAM,SAAS,KAAK,OAAO;AAAA,QAC/C,eAAW,yBAAWA,OAAM,WAAW,SAAS;AAAA,MAClD;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["step","s","v","value","h","focusThumbOnChange","isInteractive","props"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/color-picker",
|
3
|
-
"version": "1.4.10-dev-
|
3
|
+
"version": "1.4.10-dev-20241117113320",
|
4
4
|
"description": "Yamada UI color picker component",
|
5
5
|
"keywords": [
|
6
6
|
"yamada",
|
@@ -36,12 +36,12 @@
|
|
36
36
|
"url": "https://github.com/yamada-ui/yamada-ui/issues"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@yamada-ui/button": "1.0.50-dev-
|
39
|
+
"@yamada-ui/button": "1.0.50-dev-20241117113320",
|
40
40
|
"@yamada-ui/core": "1.15.5",
|
41
41
|
"@yamada-ui/form-control": "2.1.7",
|
42
42
|
"@yamada-ui/icon": "1.1.12",
|
43
43
|
"@yamada-ui/input": "1.0.47",
|
44
|
-
"@yamada-ui/popover": "1.4.3-dev-
|
44
|
+
"@yamada-ui/popover": "1.4.3-dev-20241117113320",
|
45
45
|
"@yamada-ui/portal": "1.0.24",
|
46
46
|
"@yamada-ui/use-controllable-state": "1.0.23",
|
47
47
|
"@yamada-ui/use-disclosure": "1.1.0",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-saturation-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n hsvTo,\n mergeRefs,\n roundNumberToStep,\n runIfFunc,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = ((value: Hsv) => HTMLUIProps) | HTMLUIProps\n\nconst defaultOverlays = (withShadow: boolean): Overlay[] => {\n let overlays: Overlay[] = [\n ([h]) => ({\n bg: `hsl(${h}, 100%, 50%)`,\n bgImage:\n \"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)\",\n }),\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface UseSaturationSliderOptions {\n /**\n * The base `id` to use for the saturation 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 initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * If `false`, the saturation slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * The value of the saturation slider.\n */\n value?: Hsv\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n}\n\nexport interface UseSaturationSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseSaturationSliderOptions,\n FormControlOptions {}\n\nexport const useSaturationSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseSaturationSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n defaultValue = [0, 0, 1],\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n step = 0.01,\n thumbColor,\n value: valueProp,\n onChange: onChangeProp,\n onChangeEnd: onChangeEndProp,\n onChangeStart: onChangeStartProp,\n ...rest\n } = useFormControlProps(props)\n const [\n {\n \"aria-readonly\": _ariaReadonly,\n disabled,\n readOnly,\n required,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n let [h, s, v] = value\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const overlays = useMemo(\n () => overlaysProp.map((propsOrFunc) => runIfFunc(propsOrFunc, [h, s, v])),\n [overlaysProp, h, s, v],\n )\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return []\n\n const { step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { bottom, height, left, width } =\n trackRef.current.getBoundingClientRect()\n const { clientX, clientY } = ev.touches?.[0] ?? ev\n\n let s = clampNumber((clientX - left) / width, 0, 1)\n let v = clampNumber((bottom - clientY) / height, 0, 1)\n\n if (step) {\n s = parseFloat(roundNumberToStep(s, 0, step))\n v = parseFloat(roundNumberToStep(v, 0, step))\n }\n\n return [s, v]\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | PointerEvent | TouchEvent) => {\n const { value } = latestRef.current\n const [nextS, nextV] = getValueFromPointer(ev)\n\n if (nextS == null || nextV == null) return\n\n const [, s, v] = value\n\n if (nextS !== s || nextV !== v) setValue(([h]) => [h, nextS, nextV])\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n ([s, v]: [number, number]) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n s = clampNumber(s, 0, 1)\n v = clampNumber(v, 0, 1)\n\n setValue(([h]) => [h, s, v])\n },\n [latestRef, setValue],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => constrain([s, v - step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [latestRef, constrain, s, v, step],\n )\n\n usePanEvent(containerRef, {\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...containerProps,\n ...formControlProps,\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [containerProps, formControlProps],\n )\n\n const getInnerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n padding: `${w / 2}px`,\n }\n\n return {\n ...props,\n ref,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value: [h, s, v].toString(),\n }),\n [formControlProps, id, name, h, s, v, required, disabled, readOnly],\n )\n\n const getTrackProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [formControlProps],\n )\n\n const getThumbProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const { height, width } = thumbSize ?? { height: 0, width: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n bottom: `calc(${y}% - ${height / 2}px)`,\n left: `calc(${x}% - ${width / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n \"aria-roledescription\": \"2D slider\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...formControlProps,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": s,\n \"aria-valuetext\": `saturation ${s}, brightness ${v}`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbSize,\n s,\n v,\n thumbColor,\n h,\n formControlProps,\n isInteractive,\n focusThumbOnChange,\n isDragging,\n onKeyDown,\n rest,\n ],\n )\n\n return {\n overlays,\n value,\n getContainerProps,\n getInnerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;AAGA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,SAAS,QAAQ,gBAAgB;AAKvD,IAAM,kBAAkB,CAAC,eAAmC;AAC1D,MAAI,WAAsB;AAAA,IACxB,CAAC,CAAC,CAAC,OAAO;AAAA,MACR,IAAI,OAAO,CAAC;AAAA,MACZ,SACE;AAAA,IACJ;AAAA,EACF;AAEA,MAAI;AACF,eAAW;AAAA,MACT,GAAG;AAAA,MACH;AAAA,QACE,WAAW;AAAA,MACb;AAAA,IACF;AAEF,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A,MAClD;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["step","s","v","value","h","focusThumbOnChange","isInteractive","props"]}
|
File without changes
|
File without changes
|
File without changes
|