@yamada-ui/color-picker 2.0.0-next-20240614140233 → 2.0.0-next-20240615233332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/dist/alpha-slider.js +14 -25
  2. package/dist/alpha-slider.js.map +1 -1
  3. package/dist/alpha-slider.mjs +2 -2
  4. package/dist/{chunk-OTNMOPLH.mjs → chunk-27BXTC5D.mjs} +4 -4
  5. package/dist/{chunk-C7IY5KVP.mjs → chunk-2K4SHOHA.mjs} +2 -2
  6. package/dist/{chunk-DDHDVGOQ.mjs → chunk-7L64OYDQ.mjs} +2 -2
  7. package/dist/{chunk-UBSVLXYF.mjs → chunk-ABDJB4WV.mjs} +3 -4
  8. package/dist/{chunk-UBSVLXYF.mjs.map → chunk-ABDJB4WV.mjs.map} +1 -1
  9. package/dist/{chunk-KKQ3MOXJ.mjs → chunk-KKUDFHCJ.mjs} +15 -26
  10. package/dist/{chunk-KKQ3MOXJ.mjs.map → chunk-KKUDFHCJ.mjs.map} +1 -1
  11. package/dist/{chunk-HEBLEXJG.mjs → chunk-MPWT2DSW.mjs} +6 -6
  12. package/dist/{chunk-6CYIIW6Z.mjs → chunk-MXH5UN5E.mjs} +2 -2
  13. package/dist/{chunk-X7R6FWCD.mjs → chunk-PCXNTEF4.mjs} +2 -2
  14. package/dist/{chunk-SBN7FEOE.mjs → chunk-PVPQQB6L.mjs} +16 -31
  15. package/dist/{chunk-SBN7FEOE.mjs.map → chunk-PVPQQB6L.mjs.map} +1 -1
  16. package/dist/{chunk-YE3Z2X2L.mjs → chunk-RWVTJOMP.mjs} +4 -4
  17. package/dist/{chunk-5QT7SRA4.mjs → chunk-UZQ2UORY.mjs} +18 -35
  18. package/dist/{chunk-5QT7SRA4.mjs.map → chunk-UZQ2UORY.mjs.map} +1 -1
  19. package/dist/{chunk-R4DLOKLT.mjs → chunk-WRHKYN3W.mjs} +15 -26
  20. package/dist/{chunk-R4DLOKLT.mjs.map → chunk-WRHKYN3W.mjs.map} +1 -1
  21. package/dist/{chunk-NJEVZQVF.mjs → chunk-YPW3ZJM7.mjs} +5 -6
  22. package/dist/{chunk-NJEVZQVF.mjs.map → chunk-YPW3ZJM7.mjs.map} +1 -1
  23. package/dist/{chunk-LHNR2F5V.mjs → chunk-ZHZRZ3XZ.mjs} +2 -2
  24. package/dist/color-picker.js +62 -118
  25. package/dist/color-picker.js.map +1 -1
  26. package/dist/color-picker.mjs +14 -14
  27. package/dist/color-selector-body.js +15 -27
  28. package/dist/color-selector-body.js.map +1 -1
  29. package/dist/color-selector-body.mjs +7 -7
  30. package/dist/color-selector-channels.js +1 -2
  31. package/dist/color-selector-channels.js.map +1 -1
  32. package/dist/color-selector-channels.mjs +2 -2
  33. package/dist/color-selector-eye-dropper.mjs +2 -2
  34. package/dist/color-selector-sliders.js +15 -27
  35. package/dist/color-selector-sliders.js.map +1 -1
  36. package/dist/color-selector-sliders.mjs +5 -5
  37. package/dist/color-selector-swatches.mjs +2 -2
  38. package/dist/color-selector.js +47 -88
  39. package/dist/color-selector.js.map +1 -1
  40. package/dist/color-selector.mjs +12 -12
  41. package/dist/hue-slider.js +14 -25
  42. package/dist/hue-slider.js.map +1 -1
  43. package/dist/hue-slider.mjs +2 -2
  44. package/dist/index.js +62 -118
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +14 -14
  47. package/dist/saturation-slider.js +14 -25
  48. package/dist/saturation-slider.js.map +1 -1
  49. package/dist/saturation-slider.mjs +2 -2
  50. package/dist/use-color-picker.js +15 -30
  51. package/dist/use-color-picker.js.map +1 -1
  52. package/dist/use-color-picker.mjs +1 -1
  53. package/dist/use-color-selector.js +17 -34
  54. package/dist/use-color-selector.js.map +1 -1
  55. package/dist/use-color-selector.mjs +1 -1
  56. package/dist/use-color-slider.js +14 -25
  57. package/dist/use-color-slider.js.map +1 -1
  58. package/dist/use-color-slider.mjs +1 -1
  59. package/dist/use-saturation-slider.js +14 -25
  60. package/dist/use-saturation-slider.js.map +1 -1
  61. package/dist/use-saturation-slider.mjs +1 -1
  62. package/package.json +15 -15
  63. /package/dist/{chunk-OTNMOPLH.mjs.map → chunk-27BXTC5D.mjs.map} +0 -0
  64. /package/dist/{chunk-C7IY5KVP.mjs.map → chunk-2K4SHOHA.mjs.map} +0 -0
  65. /package/dist/{chunk-DDHDVGOQ.mjs.map → chunk-7L64OYDQ.mjs.map} +0 -0
  66. /package/dist/{chunk-HEBLEXJG.mjs.map → chunk-MPWT2DSW.mjs.map} +0 -0
  67. /package/dist/{chunk-6CYIIW6Z.mjs.map → chunk-MXH5UN5E.mjs.map} +0 -0
  68. /package/dist/{chunk-X7R6FWCD.mjs.map → chunk-PCXNTEF4.mjs.map} +0 -0
  69. /package/dist/{chunk-YE3Z2X2L.mjs.map → chunk-RWVTJOMP.mjs.map} +0 -0
  70. /package/dist/{chunk-LHNR2F5V.mjs.map → chunk-ZHZRZ3XZ.mjs.map} +0 -0
@@ -39,8 +39,7 @@ var useColorSlider = ({
39
39
  focusThumbOnChange = true,
40
40
  ...props
41
41
  }) => {
42
- if (!focusThumbOnChange)
43
- props.isReadOnly = true;
42
+ if (!focusThumbOnChange) props.isReadOnly = true;
44
43
  let {
45
44
  id,
46
45
  name,
@@ -87,16 +86,14 @@ var useColorSlider = ({
87
86
  const getValueFromPointer = (0, import_react.useCallback)(
88
87
  (ev) => {
89
88
  var _a, _b;
90
- if (!trackRef.current)
91
- return;
89
+ if (!trackRef.current) return;
92
90
  const { min: min2, max: max2, step: step2 } = latestRef.current;
93
91
  latestRef.current.eventSource = "pointer";
94
92
  const { left, width } = trackRef.current.getBoundingClientRect();
95
93
  const { clientX } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
96
94
  let percent = (clientX - left) / width;
97
95
  let nextValue = (0, import_utils.percentToValue)(percent, min2, max2);
98
- if (step2)
99
- nextValue = parseFloat((0, import_utils.roundNumberToStep)(nextValue, min2, step2));
96
+ if (step2) nextValue = parseFloat((0, import_utils.roundNumberToStep)(nextValue, min2, step2));
100
97
  nextValue = (0, import_utils.clampNumber)(nextValue, min2, max2);
101
98
  return nextValue;
102
99
  },
@@ -105,22 +102,19 @@ var useColorSlider = ({
105
102
  const setValueFromPointer = (ev) => {
106
103
  const { value: value2 } = latestRef.current;
107
104
  const nextValue = getValueFromPointer(ev);
108
- if (nextValue != null && nextValue !== value2)
109
- setValue(nextValue);
105
+ if (nextValue != null && nextValue !== value2) setValue(nextValue);
110
106
  };
111
107
  const focusThumb = (0, import_react.useCallback)(() => {
112
108
  const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
113
- if (focusThumbOnChange2)
114
- setTimeout(() => {
115
- var _a;
116
- return (_a = thumbRef.current) == null ? void 0 : _a.focus();
117
- });
109
+ if (focusThumbOnChange2) setTimeout(() => {
110
+ var _a;
111
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
112
+ });
118
113
  }, [latestRef]);
119
114
  const constrain = (0, import_react.useCallback)(
120
115
  (value2) => {
121
116
  const { isInteractive: isInteractive2, min: min2, max: max2 } = latestRef.current;
122
- if (!isInteractive2)
123
- return;
117
+ if (!isInteractive2) return;
124
118
  value2 = parseFloat((0, import_utils.roundNumberToStep)(value2, min2, oneStep));
125
119
  value2 = (0, import_utils.clampNumber)(value2, min2, max2);
126
120
  setValue(value2);
@@ -149,8 +143,7 @@ var useColorSlider = ({
149
143
  End: () => constrain(max2)
150
144
  };
151
145
  const action = actions[ev.key];
152
- if (!action)
153
- return;
146
+ if (!action) return;
154
147
  ev.preventDefault();
155
148
  ev.stopPropagation();
156
149
  action(ev);
@@ -161,8 +154,7 @@ var useColorSlider = ({
161
154
  (0, import_use_pan_event.usePanEvent)(containerRef, {
162
155
  onSessionStart: (ev) => {
163
156
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
164
- if (!isInteractive2)
165
- return;
157
+ if (!isInteractive2) return;
166
158
  setDragging(true);
167
159
  focusThumb();
168
160
  setValueFromPointer(ev);
@@ -170,22 +162,19 @@ var useColorSlider = ({
170
162
  },
171
163
  onSessionEnd: () => {
172
164
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
173
- if (!isInteractive2)
174
- return;
165
+ if (!isInteractive2) return;
175
166
  setDragging(false);
176
167
  onChangeEnd(value2);
177
168
  },
178
169
  onMove: (ev) => {
179
170
  const { isInteractive: isInteractive2 } = latestRef.current;
180
- if (!isInteractive2)
181
- return;
171
+ if (!isInteractive2) return;
182
172
  setValueFromPointer(ev);
183
173
  }
184
174
  });
185
175
  (0, import_utils.useUpdateEffect)(() => {
186
176
  const { eventSource, value: value2 } = latestRef.current;
187
- if (eventSource === "keyboard")
188
- onChangeEnd(value2);
177
+ if (eventSource === "keyboard") onChangeEnd(value2);
189
178
  }, [value, onChangeEnd]);
190
179
  const getContainerProps = (0, import_react.useCallback)(
191
180
  (props2 = {}, ref = null) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/alpha-slider.tsx","../src/use-color-slider.ts"],"sourcesContent":["import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { alphaToHex, convertColor, cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n color: string,\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n {\n bgGradient: `linear(to-r, ${\n convertColor(color)(\"hex\") + alphaToHex(min)\n }, ${convertColor(color)(\"hex\") + alphaToHex(max)})`,\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\ntype AlphaSliderOptions = {\n /**\n * The color used for the slider.\n *\n * @default \"#ffffff\"\n */\n color?: string\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 maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 1\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\nexport type AlphaSliderProps = ThemeProps<\"AlphaSlider\"> &\n Partial<Omit<UseColorSliderProps, \"color\">> &\n AlphaSliderOptions\n\n/**\n * `AlphaSlider` is a component used to allow the user to select color transparency.\n *\n * @see Docs https://yamada-ui.com/components/forms/alpha-slider\n */\nexport const AlphaSlider = forwardRef<AlphaSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"AlphaSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n color = \"#ffffff\",\n min = 0,\n max = 1,\n withShadow = true,\n overlays = defaultOverlays(color, min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({\n min,\n max,\n step: 0.01,\n thumbColor: \"transparent\",\n ...computedProps,\n })\n\n const css: CSSUIObject = {\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-alpha-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-alpha-slider__overlay\"\n __css={{\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-alpha-slider__track\"\n __css={{\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-alpha-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n )\n },\n)\n","import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\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 omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\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 value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\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 (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\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 [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\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 onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\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: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAKO;AAEP,IAAAA,gBAA6C;;;ACN7C,0BAKO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAYO;AAEP,mBAA8C;AAiEvC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,qBAAqB;AAAA,EACrB,GAAG;AACL,MAA2B;AACzB,MAAI,CAAC;AAAoB,UAAM,aAAa;AAE5C,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,IACf,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,QAAI,yCAAoB,KAAK;AAE7B,QAAM,oBAAgB,6BAAe,iBAAiB;AACtD,QAAM,kBAAc,6BAAe,eAAe;AAElD,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,MAAM;AAAA,kBACxB,GAAG,cAAc,UAAU;AAAA;AAAA,cAC9B;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;","names":["import_utils","min","max","step","value","focusThumbOnChange","isInteractive","props","props"]}
1
+ {"version":3,"sources":["../src/alpha-slider.tsx","../src/use-color-slider.ts"],"sourcesContent":["import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { alphaToHex, convertColor, cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n color: string,\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n {\n bgGradient: `linear(to-r, ${\n convertColor(color)(\"hex\") + alphaToHex(min)\n }, ${convertColor(color)(\"hex\") + alphaToHex(max)})`,\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\ntype AlphaSliderOptions = {\n /**\n * The color used for the slider.\n *\n * @default \"#ffffff\"\n */\n color?: string\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 maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 1\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\nexport type AlphaSliderProps = ThemeProps<\"AlphaSlider\"> &\n Partial<Omit<UseColorSliderProps, \"color\">> &\n AlphaSliderOptions\n\n/**\n * `AlphaSlider` is a component used to allow the user to select color transparency.\n *\n * @see Docs https://yamada-ui.com/components/forms/alpha-slider\n */\nexport const AlphaSlider = forwardRef<AlphaSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"AlphaSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n color = \"#ffffff\",\n min = 0,\n max = 1,\n withShadow = true,\n overlays = defaultOverlays(color, min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({\n min,\n max,\n step: 0.01,\n thumbColor: \"transparent\",\n ...computedProps,\n })\n\n const css: CSSUIObject = {\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-alpha-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-alpha-slider__overlay\"\n __css={{\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-alpha-slider__track\"\n __css={{\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-alpha-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n )\n },\n)\n","import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\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 omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\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 value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\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 (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\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 [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\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 onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\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: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAKO;AAEP,IAAAA,gBAA6C;;;ACN7C,0BAKO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAYO;AAEP,mBAA8C;AAiEvC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,qBAAqB;AAAA,EACrB,GAAG;AACL,MAA2B;AACzB,MAAI,CAAC,mBAAoB,OAAM,aAAa;AAE5C,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,IACf,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,QAAI,yCAAoB,KAAK;AAE7B,QAAM,oBAAgB,6BAAe,iBAAiB;AACtD,QAAM,kBAAc,6BAAe,eAAe;AAElD,QAAM,CAAC,eAAe,QAAQ,QAAI,oDAAqB;AAAA,IACrD,OAAO;AAAA,IACP,cAAc,sCAAgB,OAAO,MAAM,OAAO;AAAA,IAClD,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,YAAQ,0BAAY,eAAe,KAAK,GAAG;AACjD,QAAM,mBAAe,6BAAe,OAAO,KAAK,GAAG;AACnD,QAAM,CAAC,YAAY,WAAW,QAAI,uBAAS,KAAK;AAChD,QAAM,gBAAgB,EAAE,YAAY;AAEpC,QAAM,UAAU,SAAS,MAAM,OA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,GAAG;AAAA,IACL,QAAI,4BAAe,WAAW;AAC9B,UAAM,EAAE,mBAAmB,eAAe,eAAe,cAAc,IACrE,eAAe;AAAA,MACb;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,GAAG;AAAA,IACL,CAAC;AAEH,UAAM,MAAmB;AAAA,MACvB,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,IACL;AAEA,WACE;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,eAAW,kBAAG,mBAAmB,SAAS;AAAA,QAC1C,OAAO;AAAA,QACN,GAAG,kBAAkB;AAAA,QAEtB;AAAA,sDAAC,eAAG,OAAH,EAAU,GAAG,cAAc,YAAY,GAAG,GAAG;AAAA,UAE7C,SAAS,IAAI,CAACC,QAAO,UACpB;AAAA,YAAC,eAAG;AAAA,YAAH;AAAA,cAEC,WAAU;AAAA,cACV,OAAO;AAAA,gBACL,GAAG,OAAO;AAAA,cACZ;AAAA,cACC,GAAGA;AAAA;AAAA,YALC;AAAA,UAMP,CACD;AAAA,UAED;AAAA,YAAC,eAAG;AAAA,YAAH;AAAA,cACC,WAAU;AAAA,cACV,OAAO;AAAA,gBACL,GAAG,OAAO;AAAA,cACZ;AAAA,cACC,GAAG,cAAc,UAAU;AAAA,cAE5B;AAAA,gBAAC,eAAG;AAAA,gBAAH;AAAA,kBACC,WAAU;AAAA,kBACV,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,kBACxB,GAAG,cAAc,UAAU;AAAA;AAAA,cAC9B;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;","names":["import_utils","min","max","step","value","focusThumbOnChange","isInteractive","props","props"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  AlphaSlider
4
- } from "./chunk-LHNR2F5V.mjs";
5
- import "./chunk-R4DLOKLT.mjs";
4
+ } from "./chunk-ZHZRZ3XZ.mjs";
5
+ import "./chunk-WRHKYN3W.mjs";
6
6
  export {
7
7
  AlphaSlider
8
8
  };
@@ -3,13 +3,13 @@ import {
3
3
  ColorPickerProvider,
4
4
  useColorPicker,
5
5
  useColorPickerContext
6
- } from "./chunk-SBN7FEOE.mjs";
6
+ } from "./chunk-PVPQQB6L.mjs";
7
7
  import {
8
8
  ColorSelector
9
- } from "./chunk-HEBLEXJG.mjs";
9
+ } from "./chunk-MPWT2DSW.mjs";
10
10
  import {
11
11
  EyeDropperIcon
12
- } from "./chunk-6CYIIW6Z.mjs";
12
+ } from "./chunk-MXH5UN5E.mjs";
13
13
  import {
14
14
  ColorSwatch
15
15
  } from "./chunk-WHGFYZII.mjs";
@@ -209,4 +209,4 @@ var ColorPickerEyeDropper = forwardRef(
209
209
  export {
210
210
  ColorPicker
211
211
  };
212
- //# sourceMappingURL=chunk-OTNMOPLH.mjs.map
212
+ //# sourceMappingURL=chunk-27BXTC5D.mjs.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-WHGFYZII.mjs";
5
5
  import {
6
6
  useColorSelectorContext
7
- } from "./chunk-5QT7SRA4.mjs";
7
+ } from "./chunk-UZQ2UORY.mjs";
8
8
 
9
9
  // src/color-selector-swatches.tsx
10
10
  import { forwardRef, ui } from "@yamada-ui/core";
@@ -65,4 +65,4 @@ var ColorSelectorSwatches = forwardRef(
65
65
  export {
66
66
  ColorSelectorSwatches
67
67
  };
68
- //# sourceMappingURL=chunk-C7IY5KVP.mjs.map
68
+ //# sourceMappingURL=chunk-2K4SHOHA.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useColorSlider
4
- } from "./chunk-R4DLOKLT.mjs";
4
+ } from "./chunk-WRHKYN3W.mjs";
5
5
 
6
6
  // src/hue-slider.tsx
7
7
  import {
@@ -91,4 +91,4 @@ var HueSlider = forwardRef((props, ref) => {
91
91
  export {
92
92
  HueSlider
93
93
  };
94
- //# sourceMappingURL=chunk-DDHDVGOQ.mjs.map
94
+ //# sourceMappingURL=chunk-7L64OYDQ.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useColorSelectorContext
4
- } from "./chunk-5QT7SRA4.mjs";
4
+ } from "./chunk-UZQ2UORY.mjs";
5
5
 
6
6
  // src/color-selector-channels.tsx
7
7
  import { forwardRef, ui } from "@yamada-ui/core";
@@ -36,8 +36,7 @@ var ColorSelectorChannels = forwardRef(({ className, channelProps, ...rest }, re
36
36
  var ColorSelectorChannel = forwardRef(({ className, channelLabel, ...rest }, ref) => {
37
37
  const id = useId();
38
38
  let { size, disabled, readOnly, styles } = useColorSelectorContext();
39
- if (size === "full")
40
- size = "lg";
39
+ if (size === "full") size = "lg";
41
40
  const css = { ...styles.channel };
42
41
  return /* @__PURE__ */ jsxs(ui.div, { className: cx("ui-color-selector__channel", className), children: [
43
42
  channelLabel ? /* @__PURE__ */ jsx(
@@ -60,4 +59,4 @@ export {
60
59
  ColorSelectorChannels,
61
60
  ColorSelectorChannel
62
61
  };
63
- //# sourceMappingURL=chunk-UBSVLXYF.mjs.map
62
+ //# sourceMappingURL=chunk-ABDJB4WV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-selector-channels.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { Input } from \"@yamada-ui/input\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useId, type ReactNode } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorChannelsOptions = {\n /**\n * Props for the chancel component.\n */\n channelProps?: Omit<ColorSelectorChannelProps, \"channelLabel\">\n}\n\nexport type ColorSelectorChannelsProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorChannelsOptions\n\nexport const ColorSelectorChannels = forwardRef<\n ColorSelectorChannelsProps,\n \"div\"\n>(({ className, channelProps, ...rest }, ref) => {\n const { withAlpha, channels, getChannelProps, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n gridTemplateColumns: `repeat(${withAlpha ? \"4\" : \"3\"}, 1fr)`,\n ...styles.channels,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__channels\", className)}\n __css={css}\n {...rest}\n >\n {channels.map(({ label, space, value, min, max }) => (\n <ColorSelectorChannel\n key={label}\n channelLabel={label}\n {...getChannelProps({ ...channelProps, space, value, min, max })}\n />\n ))}\n </ui.div>\n )\n})\n\ntype ColorSelectorChannelOptions = {\n channelLabel?: ReactNode\n}\n\nexport type ColorSelectorChannelProps = Omit<\n InputProps,\n \"type\" | \"pattern\" | \"min\" | \"max\" | \"value\" | \"defaultValue\"\n> &\n ColorSelectorChannelOptions\n\nexport const ColorSelectorChannel = forwardRef<\n ColorSelectorChannelProps,\n \"input\"\n>(({ className, channelLabel, ...rest }, ref) => {\n const id = useId()\n let { size, disabled, readOnly, styles } = useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = { ...styles.channel }\n\n return (\n <ui.div className={cx(\"ui-color-selector__channel\", className)}>\n {channelLabel ? (\n <ui.label\n htmlFor={id}\n style={{ cursor: disabled ? \"not-allowed\" : undefined }}\n __css={{\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.channelLabel,\n }}\n >\n {channelLabel}\n </ui.label>\n ) : null}\n\n <Input ref={ref} id={id} size={size} __css={css} {...rest} />\n </ui.div>\n )\n})\n"],"mappings":";;;;;;AAAA,SAAS,YAAY,UAAU;AAE/B,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,aAA6B;AAiC9B,cAgCJ,YAhCI;AApBD,IAAM,wBAAwB,WAGnC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,EAAE,WAAW,UAAU,iBAAiB,OAAO,IACnD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,qBAAqB,UAAU,YAAY,MAAM,GAAG;AAAA,IACpD,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC,GAAG;AAAA,IAAH;AAAA,MACC;AAAA,MACA,WAAW,GAAG,+BAA+B,SAAS;AAAA,MACtD,OAAO;AAAA,MACN,GAAG;AAAA,MAEH,mBAAS,IAAI,CAAC,EAAE,OAAO,OAAO,OAAO,KAAK,IAAI,MAC7C;AAAA,QAAC;AAAA;AAAA,UAEC,cAAc;AAAA,UACb,GAAG,gBAAgB,EAAE,GAAG,cAAc,OAAO,OAAO,KAAK,IAAI,CAAC;AAAA;AAAA,QAF1D;AAAA,MAGP,CACD;AAAA;AAAA,EACH;AAEJ,CAAC;AAYM,IAAM,uBAAuB,WAGlC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,KAAK,MAAM;AACjB,MAAI,EAAE,MAAM,UAAU,UAAU,OAAO,IAAI,wBAAwB;AAEnE,MAAI,SAAS;AAAQ,WAAO;AAE5B,QAAM,MAAmB,EAAE,GAAG,OAAO,QAAQ;AAE7C,SACE,qBAAC,GAAG,KAAH,EAAO,WAAW,GAAG,8BAA8B,SAAS,GAC1D;AAAA,mBACC;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,SAAS;AAAA,QACT,OAAO,EAAE,QAAQ,WAAW,gBAAgB,OAAU;AAAA,QACtD,OAAO;AAAA,UACL,eAAe,WAAW,SAAS;AAAA,UACnC,GAAG,OAAO;AAAA,QACZ;AAAA,QAEC;AAAA;AAAA,IACH,IACE;AAAA,IAEJ,oBAAC,SAAM,KAAU,IAAQ,MAAY,OAAO,KAAM,GAAG,MAAM;AAAA,KAC7D;AAEJ,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/color-selector-channels.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { Input } from \"@yamada-ui/input\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useId, type ReactNode } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorChannelsOptions = {\n /**\n * Props for the chancel component.\n */\n channelProps?: Omit<ColorSelectorChannelProps, \"channelLabel\">\n}\n\nexport type ColorSelectorChannelsProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorChannelsOptions\n\nexport const ColorSelectorChannels = forwardRef<\n ColorSelectorChannelsProps,\n \"div\"\n>(({ className, channelProps, ...rest }, ref) => {\n const { withAlpha, channels, getChannelProps, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n gridTemplateColumns: `repeat(${withAlpha ? \"4\" : \"3\"}, 1fr)`,\n ...styles.channels,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__channels\", className)}\n __css={css}\n {...rest}\n >\n {channels.map(({ label, space, value, min, max }) => (\n <ColorSelectorChannel\n key={label}\n channelLabel={label}\n {...getChannelProps({ ...channelProps, space, value, min, max })}\n />\n ))}\n </ui.div>\n )\n})\n\ntype ColorSelectorChannelOptions = {\n channelLabel?: ReactNode\n}\n\nexport type ColorSelectorChannelProps = Omit<\n InputProps,\n \"type\" | \"pattern\" | \"min\" | \"max\" | \"value\" | \"defaultValue\"\n> &\n ColorSelectorChannelOptions\n\nexport const ColorSelectorChannel = forwardRef<\n ColorSelectorChannelProps,\n \"input\"\n>(({ className, channelLabel, ...rest }, ref) => {\n const id = useId()\n let { size, disabled, readOnly, styles } = useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = { ...styles.channel }\n\n return (\n <ui.div className={cx(\"ui-color-selector__channel\", className)}>\n {channelLabel ? (\n <ui.label\n htmlFor={id}\n style={{ cursor: disabled ? \"not-allowed\" : undefined }}\n __css={{\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.channelLabel,\n }}\n >\n {channelLabel}\n </ui.label>\n ) : null}\n\n <Input ref={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WAAW,SAAS;AAAA,UACnC,GAAG,OAAO;AAAA,QACZ;AAAA,QAEC;AAAA;AAAA,IACH,IACE;AAAA,IAEJ,oBAAC,SAAM,KAAU,IAAQ,MAAY,OAAO,KAAM,GAAG,MAAM;AAAA,KAC7D;AAEJ,CAAC;","names":[]}
@@ -44,8 +44,7 @@ var useSaturationSlider = ({
44
44
  focusThumbOnChange = true,
45
45
  ...props
46
46
  }) => {
47
- if (!focusThumbOnChange)
48
- props.isReadOnly = true;
47
+ if (!focusThumbOnChange) props.isReadOnly = true;
49
48
  let {
50
49
  id,
51
50
  name,
@@ -93,8 +92,7 @@ var useSaturationSlider = ({
93
92
  const getValueFromPointer = useCallback(
94
93
  (ev) => {
95
94
  var _a, _b;
96
- if (!trackRef.current)
97
- return [];
95
+ if (!trackRef.current) return [];
98
96
  const { step: step2 } = latestRef.current;
99
97
  latestRef.current.eventSource = "pointer";
100
98
  const { bottom, left, height, width } = trackRef.current.getBoundingClientRect();
@@ -112,25 +110,21 @@ var useSaturationSlider = ({
112
110
  const setValueFromPointer = (ev) => {
113
111
  const { value: value2 } = latestRef.current;
114
112
  const [nextS, nextV] = getValueFromPointer(ev);
115
- if (nextS == null || nextV == null)
116
- return;
113
+ if (nextS == null || nextV == null) return;
117
114
  const [, s2, v2] = value2;
118
- if (nextS !== s2 || nextV !== v2)
119
- setValue(([h2]) => [h2, nextS, nextV]);
115
+ if (nextS !== s2 || nextV !== v2) setValue(([h2]) => [h2, nextS, nextV]);
120
116
  };
121
117
  const focusThumb = useCallback(() => {
122
118
  const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
123
- if (focusThumbOnChange2)
124
- setTimeout(() => {
125
- var _a;
126
- return (_a = thumbRef.current) == null ? void 0 : _a.focus();
127
- });
119
+ if (focusThumbOnChange2) setTimeout(() => {
120
+ var _a;
121
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
122
+ });
128
123
  }, [latestRef]);
129
124
  const constrain = useCallback(
130
125
  ([s2, v2]) => {
131
126
  const { isInteractive: isInteractive2 } = latestRef.current;
132
- if (!isInteractive2)
133
- return;
127
+ if (!isInteractive2) return;
134
128
  s2 = clampNumber(s2, 0, 1);
135
129
  v2 = clampNumber(v2, 0, 1);
136
130
  setValue(([h2]) => [h2, s2, v2]);
@@ -146,8 +140,7 @@ var useSaturationSlider = ({
146
140
  ArrowDown: () => constrain([s, v - step])
147
141
  };
148
142
  const action = actions[ev.key];
149
- if (!action)
150
- return;
143
+ if (!action) return;
151
144
  ev.preventDefault();
152
145
  ev.stopPropagation();
153
146
  action(ev);
@@ -158,8 +151,7 @@ var useSaturationSlider = ({
158
151
  usePanEvent(containerRef, {
159
152
  onSessionStart: (ev) => {
160
153
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
161
- if (!isInteractive2)
162
- return;
154
+ if (!isInteractive2) return;
163
155
  setDragging(true);
164
156
  focusThumb();
165
157
  setValueFromPointer(ev);
@@ -167,22 +159,19 @@ var useSaturationSlider = ({
167
159
  },
168
160
  onSessionEnd: () => {
169
161
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
170
- if (!isInteractive2)
171
- return;
162
+ if (!isInteractive2) return;
172
163
  setDragging(false);
173
164
  onChangeEnd(value2);
174
165
  },
175
166
  onMove: (ev) => {
176
167
  const { isInteractive: isInteractive2 } = latestRef.current;
177
- if (!isInteractive2)
178
- return;
168
+ if (!isInteractive2) return;
179
169
  setValueFromPointer(ev);
180
170
  }
181
171
  });
182
172
  useUpdateEffect(() => {
183
173
  const { eventSource, value: value2 } = latestRef.current;
184
- if (eventSource === "keyboard")
185
- onChangeEnd(value2);
174
+ if (eventSource === "keyboard") onChangeEnd(value2);
186
175
  }, [value, onChangeEnd]);
187
176
  const getContainerProps = useCallback(
188
177
  (props2 = {}, ref = null) => ({
@@ -294,4 +283,4 @@ var useSaturationSlider = ({
294
283
  export {
295
284
  useSaturationSlider
296
285
  };
297
- //# sourceMappingURL=chunk-KKQ3MOXJ.mjs.map
286
+ //# sourceMappingURL=chunk-KKUDFHCJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-saturation-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\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 omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n useCallbackRef,\n runIfFunc,\n clampNumber,\n hsvTo,\n roundNumberToStep,\n pickObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = HTMLUIProps<\"div\"> | ((value: Hsv) => HTMLUIProps<\"div\">)\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\ntype 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 value of the saturation slider.\n */\n value?: Hsv\n /**\n * The initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\n}\n\nexport type UseSaturationSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\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 value: valueProp,\n defaultValue = [0, 0, 1],\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n step = 0.01,\n thumbColor,\n required,\n disabled,\n readOnly,\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\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 value,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\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, left, height, 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 | TouchEvent | PointerEvent) => {\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: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowDown: () => 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 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 onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\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: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [rest],\n )\n\n const getInnerProps: UIPropGetter = 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: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: [h, s, v].toString(),\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, h, s, v],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width, height } = thumbSize ?? { width: 0, height: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${x}% - ${width / 2}px)`,\n bottom: `calc(${y}% - ${height / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": s,\n \"aria-valuemin\": 0,\n \"aria-valuemax\": 100,\n \"aria-valuetext\": `saturation ${s}, brightness ${v}`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n h,\n s,\n v,\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n onKeyDown,\n rest,\n thumbSize,\n ],\n )\n\n return {\n value,\n overlays,\n getContainerProps,\n getInnerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EAEA;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,EACA;AAAA,OACK;AAEP,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,e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AQ,WAAWA,OAAM,QAAQ,KAAK,MAAM;AAAA,QAC5C;AAAA,MACF;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,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"]}
1
+ {"version":3,"sources":["../src/use-saturation-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\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 omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n useCallbackRef,\n runIfFunc,\n clampNumber,\n hsvTo,\n roundNumberToStep,\n pickObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\n\nexport type Hsv = [number, number, number]\ntype Overlay = HTMLUIProps<\"div\"> | ((value: Hsv) => HTMLUIProps<\"div\">)\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\ntype 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 value of the saturation slider.\n */\n value?: Hsv\n /**\n * The initial value of the saturation slider.\n *\n * @default \"[0, 0, 1]\"\n */\n defaultValue?: Hsv\n /**\n * Function called whenever the saturation slider value changes.\n */\n onChange?: (value: Hsv) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: Hsv) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: Hsv) => void\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\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 CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * The overlay used for the saturation slider.\n */\n overlays?: Overlay[]\n}\n\nexport type UseSaturationSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\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 value: valueProp,\n defaultValue = [0, 0, 1],\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n step = 0.01,\n thumbColor,\n required,\n disabled,\n readOnly,\n withShadow = true,\n overlays: overlaysProp = defaultOverlays(withShadow),\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\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 value,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\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, left, height, 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 | TouchEvent | PointerEvent) => {\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: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => constrain([s + step, v]),\n ArrowUp: () => constrain([s, v + step]),\n ArrowLeft: () => constrain([s - step, v]),\n ArrowDown: () => 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 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 onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\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: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n }),\n [rest],\n )\n\n const getInnerProps: UIPropGetter = 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: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: [h, s, v].toString(),\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, h, s, v],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width, height } = thumbSize ?? { width: 0, height: 0 }\n const x = s * 100\n const y = v * 100\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${x}% - ${width / 2}px)`,\n bottom: `calc(${y}% - ${height / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Saturation and brightness thumb\",\n bg: thumbColor ?? hsvTo([h, s, v])(),\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": s,\n \"aria-valuemin\": 0,\n \"aria-valuemax\": 100,\n \"aria-valuetext\": `saturation ${s}, brightness ${v}`,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n h,\n s,\n v,\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n onKeyDown,\n rest,\n thumbSize,\n ],\n )\n\n return {\n value,\n overlays,\n getContainerProps,\n getInnerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseSaturationSliderReturn = ReturnType<typeof useSaturationSlider>\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;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;AAAA,QAC5B,UAAU,iBAAiB,qBAAqB,IAAI;AAAA,QACpD,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,kBAAkB,cAAc,CAAC,gBAAgB,CAAC;AAAA,QAClD,eAAe,SAAS,cAAc,kBAAkB;AAAA,QACxD,WAAW,WAAWA,OAAM,WAAW,SAAS;AAAA,QAChD,SAAS,WAAWA,OAAM,SAAS,KAAK,OAAO;AAAA,QAC/C,QAAQ,WAAWA,OAAM,QAAQ,KAAK,MAAM;AAAA,QAC5C;AAAA,MACF;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,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"]}
@@ -1,20 +1,20 @@
1
1
  "use client"
2
2
  import {
3
3
  SaturationSlider
4
- } from "./chunk-X7R6FWCD.mjs";
4
+ } from "./chunk-PCXNTEF4.mjs";
5
5
  import {
6
6
  ColorSelectorBody
7
- } from "./chunk-YE3Z2X2L.mjs";
7
+ } from "./chunk-RWVTJOMP.mjs";
8
8
  import {
9
9
  ColorSelectorChannels
10
- } from "./chunk-UBSVLXYF.mjs";
10
+ } from "./chunk-ABDJB4WV.mjs";
11
11
  import {
12
12
  ColorSelectorSwatches
13
- } from "./chunk-C7IY5KVP.mjs";
13
+ } from "./chunk-2K4SHOHA.mjs";
14
14
  import {
15
15
  ColorSelectorProvider,
16
16
  useColorSelector
17
- } from "./chunk-5QT7SRA4.mjs";
17
+ } from "./chunk-UZQ2UORY.mjs";
18
18
 
19
19
  // src/color-selector.tsx
20
20
  import {
@@ -125,4 +125,4 @@ var ColorSelector = forwardRef(
125
125
  export {
126
126
  ColorSelector
127
127
  };
128
- //# sourceMappingURL=chunk-HEBLEXJG.mjs.map
128
+ //# sourceMappingURL=chunk-MPWT2DSW.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useColorSelectorContext
4
- } from "./chunk-5QT7SRA4.mjs";
4
+ } from "./chunk-UZQ2UORY.mjs";
5
5
 
6
6
  // src/color-selector-eye-dropper.tsx
7
7
  import { IconButton } from "@yamada-ui/button";
@@ -51,4 +51,4 @@ export {
51
51
  ColorSelectorEyeDropper,
52
52
  EyeDropperIcon
53
53
  };
54
- //# sourceMappingURL=chunk-6CYIIW6Z.mjs.map
54
+ //# sourceMappingURL=chunk-MXH5UN5E.mjs.map
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useSaturationSlider
4
- } from "./chunk-KKQ3MOXJ.mjs";
4
+ } from "./chunk-KKUDFHCJ.mjs";
5
5
 
6
6
  // src/saturation-slider.tsx
7
7
  import {
@@ -113,4 +113,4 @@ var SaturationSlider = forwardRef(
113
113
  export {
114
114
  SaturationSlider
115
115
  };
116
- //# sourceMappingURL=chunk-X7R6FWCD.mjs.map
116
+ //# sourceMappingURL=chunk-PCXNTEF4.mjs.map