@yamada-ui/color-picker 1.4.8 → 1.4.9-dev-20241109080944

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/dist/alpha-slider.d.mts +1 -1
  2. package/dist/alpha-slider.d.ts +1 -1
  3. package/dist/alpha-slider.js +98 -45
  4. package/dist/alpha-slider.js.map +1 -1
  5. package/dist/alpha-slider.mjs +2 -2
  6. package/dist/{chunk-XL5VWGU4.mjs → chunk-FP3X3PED.mjs} +78 -43
  7. package/dist/chunk-FP3X3PED.mjs.map +1 -0
  8. package/dist/{chunk-CZCTI6T2.mjs → chunk-HJMXAALX.mjs} +2 -2
  9. package/dist/{chunk-62A7F566.mjs → chunk-HPP26MVU.mjs} +3 -3
  10. package/dist/{chunk-CAVDEKGO.mjs → chunk-LJHUX2RB.mjs} +2 -2
  11. package/dist/{chunk-APTJWP7T.mjs → chunk-OJVCLBAG.mjs} +2 -2
  12. package/dist/{chunk-F5EYME2W.mjs → chunk-SGAM4TJL.mjs} +26 -7
  13. package/dist/chunk-SGAM4TJL.mjs.map +1 -0
  14. package/dist/chunk-WZEWATJ3.mjs +139 -0
  15. package/dist/chunk-WZEWATJ3.mjs.map +1 -0
  16. package/dist/color-picker.js +170 -80
  17. package/dist/color-picker.js.map +1 -1
  18. package/dist/color-picker.mjs +7 -7
  19. package/dist/color-selector-body.js +170 -80
  20. package/dist/color-selector-body.js.map +1 -1
  21. package/dist/color-selector-body.mjs +5 -5
  22. package/dist/color-selector-sliders.js +170 -80
  23. package/dist/color-selector-sliders.js.map +1 -1
  24. package/dist/color-selector-sliders.mjs +4 -4
  25. package/dist/color-selector.js +170 -80
  26. package/dist/color-selector.js.map +1 -1
  27. package/dist/color-selector.mjs +6 -6
  28. package/dist/hue-slider.d.mts +1 -1
  29. package/dist/hue-slider.d.ts +1 -1
  30. package/dist/hue-slider.js +95 -40
  31. package/dist/hue-slider.js.map +1 -1
  32. package/dist/hue-slider.mjs +2 -2
  33. package/dist/index.js +170 -80
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +7 -7
  36. package/dist/use-color-slider.d.mts +7 -1
  37. package/dist/use-color-slider.d.ts +7 -1
  38. package/dist/use-color-slider.js +25 -5
  39. package/dist/use-color-slider.js.map +1 -1
  40. package/dist/use-color-slider.mjs +3 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-7NWT5PKE.mjs +0 -102
  43. package/dist/chunk-7NWT5PKE.mjs.map +0 -1
  44. package/dist/chunk-F5EYME2W.mjs.map +0 -1
  45. package/dist/chunk-XL5VWGU4.mjs.map +0 -1
  46. /package/dist/{chunk-CZCTI6T2.mjs.map → chunk-HJMXAALX.mjs.map} +0 -0
  47. /package/dist/{chunk-62A7F566.mjs.map → chunk-HPP26MVU.mjs.map} +0 -0
  48. /package/dist/{chunk-CAVDEKGO.mjs.map → chunk-LJHUX2RB.mjs.map} +0 -0
  49. /package/dist/{chunk-APTJWP7T.mjs.map → chunk-OJVCLBAG.mjs.map} +0 -0
@@ -31,6 +31,7 @@ var useColorSlider = ({
31
31
  id,
32
32
  name,
33
33
  style: styleProp,
34
+ channel = "hue",
34
35
  defaultValue,
35
36
  max,
36
37
  min = 0,
@@ -247,6 +248,7 @@ var useColorSlider = ({
247
248
  "aria-valuemax": max,
248
249
  "aria-valuemin": min,
249
250
  "aria-valuenow": value,
251
+ "aria-valuetext": getAriaValueText(channel, value),
250
252
  "data-active": dataAttr(isDragging && focusThumbOnChange),
251
253
  role: "slider",
252
254
  tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
@@ -262,14 +264,15 @@ var useColorSlider = ({
262
264
  value,
263
265
  formControlProps,
264
266
  ariaReadonly,
265
- isInteractive,
266
- focusThumbOnChange,
267
- min,
268
267
  max,
268
+ min,
269
+ channel,
269
270
  isDragging,
270
- onKeyDown,
271
+ focusThumbOnChange,
272
+ isInteractive,
273
+ onBlurProp,
271
274
  onFocusProp,
272
- onBlurProp
275
+ onKeyDown
273
276
  ]
274
277
  );
275
278
  return {
@@ -280,8 +283,24 @@ var useColorSlider = ({
280
283
  getTrackProps
281
284
  };
282
285
  };
286
+ var getAriaValueText = (channel, value) => {
287
+ if (channel === "hue") {
288
+ return `${value}\xB0, ${getColorName(value)}`;
289
+ } else {
290
+ return `${value * 100}%`;
291
+ }
292
+ };
293
+ var getColorName = (hue) => {
294
+ if (hue < 30 || hue >= 330) return "Red";
295
+ if (hue < 90) return "Yellow";
296
+ if (hue < 150) return "Green";
297
+ if (hue < 210) return "Cyan";
298
+ if (hue < 270) return "Blue";
299
+ return "Magenta";
300
+ };
283
301
 
284
302
  export {
285
- useColorSlider
303
+ useColorSlider,
304
+ getAriaValueText
286
305
  };
287
- //# sourceMappingURL=chunk-F5EYME2W.mjs.map
306
+ //# sourceMappingURL=chunk-SGAM4TJL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-color-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 mergeRefs,\n percentToValue,\n roundNumberToStep,\n splitObject,\n useCallbackRef,\n useUpdateEffect,\n valueToPercent,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype ColorSliderChannel = \"alpha\" | \"hue\"\n\ninterface UseColorSliderOptions {\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The channel of the slider.\n */\n channel?: ColorSliderChannel\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\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 step in which increments or decrements have to be made.\n *\n * @default 1\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 slider.\n */\n value?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n}\n\nexport interface UseColorSliderProps\n extends Omit<HTMLUIProps, \"defaultValue\" | \"onChange\">,\n UseColorSliderOptions,\n FormControlOptions {}\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n const {\n id,\n name,\n style: styleProp,\n channel = \"hue\",\n defaultValue,\n max,\n min = 0,\n step = 1,\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 onBlur: onBlurProp,\n onFocus: onFocusProp,\n ...formControlProps\n },\n containerProps,\n ] = splitObject(rest, formControlProperties)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n defaultValue: defaultValue ?? min + (max - min) / 2,\n value: valueProp,\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 eventSource: null as \"keyboard\" | \"pointer\" | null,\n focusThumbOnChange,\n isInteractive,\n max,\n min,\n step,\n value,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { max, min, 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 | PointerEvent | TouchEvent) => {\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, max, min } = 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 { max, min } = latestRef.current\n\n const actions: { [key: string]: KeyboardEventHandler } = {\n ArrowDown: () => stepDown(),\n ArrowLeft: () => stepDown(),\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n End: () => constrain(max),\n Home: () => constrain(min),\n PageDown: () => stepDown(tenStep),\n PageUp: () => stepUp(tenStep),\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 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 const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...styleProp,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...formControlProps,\n ...containerProps,\n ref: mergeRefs(ref, containerRef),\n style,\n tabIndex: -1,\n }\n },\n [containerProps, formControlProps, styleProp, thumbSize],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...formControlProps,\n \"aria-readonly\": ariaReadonly,\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n disabled,\n readOnly,\n required,\n value,\n }),\n [\n ariaReadonly,\n disabled,\n formControlProps,\n id,\n name,\n readOnly,\n required,\n value,\n ],\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 n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n left: `calc(${n}% - ${w / 2}px)`,\n position: \"absolute\",\n touchAction: \"none\",\n userSelect: \"none\",\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...formControlProps,\n \"aria-readonly\": ariaReadonly,\n ...props,\n ref: mergeRefs(ref, thumbRef),\n style,\n \"aria-valuemax\": max,\n \"aria-valuemin\": min,\n \"aria-valuenow\": value,\n \"aria-valuetext\": getAriaValueText(channel, value),\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n role: \"slider\",\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n onBlur: handlerAll(props.onBlur, onBlurProp),\n onFocus: handlerAll(props.onFocus, onFocusProp),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }\n },\n [\n thumbPercent,\n thumbSize,\n thumbColor,\n value,\n formControlProps,\n ariaReadonly,\n max,\n min,\n channel,\n isDragging,\n focusThumbOnChange,\n isInteractive,\n onBlurProp,\n onFocusProp,\n onKeyDown,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getInputProps,\n getThumbProps,\n getTrackProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n\nexport const getAriaValueText = (\n channel: ColorSliderChannel,\n value: number,\n) => {\n if (channel === \"hue\") {\n return `${value}°, ${getColorName(value)}`\n } else {\n return `${value * 100}%`\n }\n}\n\nconst getColorName = (hue: number): string => {\n if (hue < 30 || hue >= 330) return \"Red\"\n if (hue < 90) return \"Yellow\"\n if (hue < 150) return \"Green\"\n if (hue < 210) return \"Cyan\"\n if (hue < 270) return \"Blue\"\n return \"Magenta\"\n}\n"],"mappings":";;;AAGA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;A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,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,EACF;AACF;AAIO,IAAM,mBAAmB,CAC9B,SACA,UACG;AACH,MAAI,YAAY,OAAO;AACrB,WAAO,GAAG,KAAK,SAAM,aAAa,KAAK,CAAC;AAAA,EAC1C,OAAO;AACL,WAAO,GAAG,QAAQ,GAAG;AAAA,EACvB;AACF;AAEA,IAAM,eAAe,CAAC,QAAwB;AAC5C,MAAI,MAAM,MAAM,OAAO,IAAK,QAAO;AACnC,MAAI,MAAM,GAAI,QAAO;AACrB,MAAI,MAAM,IAAK,QAAO;AACtB,MAAI,MAAM,IAAK,QAAO;AACtB,MAAI,MAAM,IAAK,QAAO;AACtB,SAAO;AACT;","names":["max","min","step","value","focusThumbOnChange","isInteractive","props"]}
@@ -0,0 +1,139 @@
1
+ "use client"
2
+ import {
3
+ useColorSlider
4
+ } from "./chunk-SGAM4TJL.mjs";
5
+
6
+ // src/hue-slider.tsx
7
+ import {
8
+ forwardRef,
9
+ omitThemeProps,
10
+ ui,
11
+ useComponentMultiStyle
12
+ } from "@yamada-ui/core";
13
+ import { createContext, cx } from "@yamada-ui/utils";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var [HueSliderProvider, useHueSlider] = createContext({
16
+ name: "SliderContext",
17
+ errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<HueSlider />" `
18
+ });
19
+ var defaultOverlays = (min, max, withShadow) => {
20
+ let overlays = [
21
+ {
22
+ bgGradient: `linear(to-r, ${[...Array(7)].map(
23
+ (_, index) => `hsl(${Math.round(min + (max - min) / 6 * index)}, 100%, 50%)`
24
+ ).join(", ")})`
25
+ }
26
+ ];
27
+ if (withShadow)
28
+ overlays = [
29
+ ...overlays,
30
+ {
31
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
32
+ }
33
+ ];
34
+ return overlays;
35
+ };
36
+ var HueSlider = forwardRef((props, ref) => {
37
+ const [styles, mergedProps] = useComponentMultiStyle("HueSlider", props);
38
+ const {
39
+ className,
40
+ max = 360,
41
+ min = 0,
42
+ withShadow = true,
43
+ overlays = defaultOverlays(min, max, withShadow),
44
+ inputProps,
45
+ thumbProps,
46
+ trackProps,
47
+ __css,
48
+ ...computedProps
49
+ } = omitThemeProps(mergedProps);
50
+ const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps, channel: "hue" });
51
+ const css = {
52
+ position: "relative",
53
+ ...styles.container,
54
+ ...__css
55
+ };
56
+ return /* @__PURE__ */ jsx(HueSliderProvider, { value: { styles }, children: /* @__PURE__ */ jsxs(
57
+ ui.div,
58
+ {
59
+ className: cx("ui-hue-slider", className),
60
+ __css: css,
61
+ ...getContainerProps(),
62
+ children: [
63
+ /* @__PURE__ */ jsx(ui.input, { ...getInputProps(inputProps, ref) }),
64
+ overlays.map((props2, index) => /* @__PURE__ */ jsx(HueSliderOverlay, { ...props2 }, index)),
65
+ /* @__PURE__ */ jsx(HueSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ jsx(HueSliderThumb, { ...getThumbProps(thumbProps) }) })
66
+ ]
67
+ }
68
+ ) });
69
+ });
70
+ HueSlider.displayName = "HueSlider";
71
+ HueSlider.__ui__ = "HueSlider";
72
+ var HueSliderOverlay = forwardRef(
73
+ ({ className, ...rest }, ref) => {
74
+ const { styles } = useHueSlider();
75
+ const css = {
76
+ bottom: 0,
77
+ left: 0,
78
+ position: "absolute",
79
+ right: 0,
80
+ top: 0,
81
+ ...styles.overlay
82
+ };
83
+ return /* @__PURE__ */ jsx(
84
+ ui.div,
85
+ {
86
+ ref,
87
+ className: cx("ui-hue-slider__overlay", className),
88
+ __css: css,
89
+ ...rest
90
+ }
91
+ );
92
+ }
93
+ );
94
+ HueSliderOverlay.displayName = "HueSliderOverlay";
95
+ HueSliderOverlay.__ui__ = "HueSliderOverlay";
96
+ var HueSliderTrack = forwardRef(
97
+ ({ className, ...rest }, ref) => {
98
+ const { styles } = useHueSlider();
99
+ const css = {
100
+ h: "100%",
101
+ position: "relative",
102
+ w: "100%",
103
+ ...styles.track
104
+ };
105
+ return /* @__PURE__ */ jsx(
106
+ ui.div,
107
+ {
108
+ ref,
109
+ className: cx("ui-hue-slider__track", className),
110
+ __css: css,
111
+ ...rest
112
+ }
113
+ );
114
+ }
115
+ );
116
+ HueSliderTrack.displayName = "HueSliderTrack";
117
+ HueSliderTrack.__ui__ = "HueSliderTrack";
118
+ var HueSliderThumb = forwardRef(
119
+ ({ className, ...rest }, ref) => {
120
+ const { styles } = useHueSlider();
121
+ const css = { ...styles.thumb };
122
+ return /* @__PURE__ */ jsx(
123
+ ui.div,
124
+ {
125
+ ref,
126
+ className: cx("ui-hue-slider__thumb", className),
127
+ __css: css,
128
+ ...rest
129
+ }
130
+ );
131
+ }
132
+ );
133
+ HueSliderThumb.displayName = "HueSliderThumb";
134
+ HueSliderThumb.__ui__ = "HueSliderThumb";
135
+
136
+ export {
137
+ HueSlider
138
+ };
139
+ //# sourceMappingURL=chunk-WZEWATJ3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hue-slider.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { createContext, cx } from \"@yamada-ui/utils\"\nimport { useColorSlider } from \"./use-color-slider\"\n\ninterface HueSliderContext {\n styles: { [key: string]: CSSUIObject | undefined }\n}\n\nconst [HueSliderProvider, useHueSlider] = createContext<HueSliderContext>({\n name: \"SliderContext\",\n errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in \"<HueSlider />\" `,\n})\n\nconst defaultOverlays = (\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps[] => {\n let overlays: HTMLUIProps[] = [\n {\n bgGradient: `linear(to-r, ${[...Array(7)]\n .map(\n (_, index) =>\n `hsl(${Math.round(min + ((max - min) / 6) * index)}, 100%, 50%)`,\n )\n .join(\", \")})`,\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 HueSliderOptions {\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 360\n */\n max?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps[]\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\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 thumb element.\n */\n thumbProps?: HTMLUIProps\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps\n}\n\nexport interface HueSliderProps\n extends ThemeProps<\"HueSlider\">,\n Partial<Omit<UseColorSliderProps, \"channel\">>,\n HueSliderOptions {}\n\n/**\n * `HueSlider` is a component used to allow the user to select a color hue.\n *\n * @see Docs https://yamada-ui.com/components/forms/hue-slider\n */\nexport const HueSlider = forwardRef<HueSliderProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"HueSlider\", props)\n const {\n className,\n max = 360,\n min = 0,\n withShadow = true,\n overlays = defaultOverlays(min, max, withShadow),\n inputProps,\n thumbProps,\n trackProps,\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getInputProps, getThumbProps, getTrackProps } =\n useColorSlider({ max, min, step: 1, ...computedProps, channel: \"hue\" })\n\n const css: CSSUIObject = {\n position: \"relative\",\n ...styles.container,\n ...__css,\n }\n\n return (\n <HueSliderProvider value={{ styles }}>\n <ui.div\n className={cx(\"ui-hue-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <HueSliderOverlay key={index} {...props} />\n ))}\n\n <HueSliderTrack {...getTrackProps(trackProps)}>\n <HueSliderThumb {...getThumbProps(thumbProps)} />\n </HueSliderTrack>\n </ui.div>\n </HueSliderProvider>\n )\n})\n\nHueSlider.displayName = \"HueSlider\"\nHueSlider.__ui__ = \"HueSlider\"\n\ninterface HueSliderOverlayProps extends HTMLUIProps {}\n\nconst HueSliderOverlay = forwardRef<HueSliderOverlayProps, \"div\">(\n ({ className, ...rest }, ref) => {\n const { styles } = useHueSlider()\n\n const css: CSSUIObject = {\n bottom: 0,\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n ...styles.overlay,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-hue-slider__overlay\", className)}\n __css={css}\n {...rest}\n />\n )\n },\n)\n\nHueSliderOverlay.displayName = \"HueSliderOverlay\"\nHueSliderOverlay.__ui__ = \"HueSliderOverlay\"\n\ninterface HueSliderTrackProps extends HTMLUIProps {}\n\nconst HueSliderTrack = forwardRef<HueSliderTrackProps, \"div\">(\n ({ className, ...rest }, ref) => {\n const { styles } = useHueSlider()\n\n const css: CSSUIObject = {\n h: \"100%\",\n position: \"relative\",\n w: \"100%\",\n ...styles.track,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-hue-slider__track\", className)}\n __css={css}\n {...rest}\n />\n )\n },\n)\n\nHueSliderTrack.displayName = \"HueSliderTrack\"\nHueSliderTrack.__ui__ = \"HueSliderTrack\"\n\ninterface HueSliderThumbProps extends HTMLUIProps {}\n\nconst HueSliderThumb = forwardRef<HueSliderThumbProps, \"div\">(\n ({ className, ...rest }, ref) => {\n const { styles } = useHueSlider()\n\n const css: CSSUIObject = { ...styles.thumb }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-hue-slider__thumb\", className)}\n __css={css}\n {...rest}\n />\n )\n },\n)\n\nHueSliderThumb.displayName = \"HueSliderThumb\"\nHueSliderThumb.__ui__ = \"HueSliderThumb\"\n"],"mappings":";;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe,UAAU;AAqH5B,SAKE,KALF;AA9GN,IAAM,CAAC,mBAAmB,YAAY,IAAI,cAAgC;AAAA,EACxE,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAED,IAAM,kBAAkB,CACtB,KACA,KACA,eACkB;AAClB,MAAI,WAA0B;AAAA,IAC5B;AAAA,MACE,YAAY,gBAAgB,CAAC,GAAG,MAAM,CAAC,CAAC,EACrC;AAAA,QACC,CAAC,GAAG,UACF,OAAO,KAAK,MAAM,OAAQ,MAAM,OAAO,IAAK,KAAK,CAAC;AAAA,MACtD,EACC,KAAK,IAAI,CAAC;AAAA,IACf;AAAA,EACF;AAEA,MAAI;AACF,eAAW;AAAA,MACT,GAAG;AAAA,MACH;AAAA,QACE,WAAW;AAAA,MACb;AAAA,IACF;AAEF,SAAO;AACT;AAuDO,IAAM,YAAY,WAAoC,CAAC,OAAO,QAAQ;AAC3E,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,aAAa,KAAK;AACvE,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,WAAW,gBAAgB,KAAK,KAAK,UAAU;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAC9B,QAAM,EAAE,mBAAmB,eAAe,eAAe,cAAc,IACrE,eAAe,EAAE,KAAK,KAAK,MAAM,GAAG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H,UAAU;AAAA,MACV,GAAG;AAAA,MACH,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAW,GAAG,wBAAwB,SAAS;AAAA,QAC/C,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAIxB,IAAM,iBAAiB;AAAA,EACrB,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AAC/B,UAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,UAAM,MAAmB,EAAE,GAAG,OAAO,MAAM;AAE3C,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAW,GAAG,wBAAwB,SAAS;AAAA,QAC/C,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;","names":["props"]}
@@ -524,6 +524,7 @@ var useColorSlider = ({
524
524
  id,
525
525
  name,
526
526
  style: styleProp,
527
+ channel = "hue",
527
528
  defaultValue,
528
529
  max,
529
530
  min = 0,
@@ -740,6 +741,7 @@ var useColorSlider = ({
740
741
  "aria-valuemax": max,
741
742
  "aria-valuemin": min,
742
743
  "aria-valuenow": value,
744
+ "aria-valuetext": getAriaValueText(channel, value),
743
745
  "data-active": (0, import_utils3.dataAttr)(isDragging && focusThumbOnChange),
744
746
  role: "slider",
745
747
  tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
@@ -755,14 +757,15 @@ var useColorSlider = ({
755
757
  value,
756
758
  formControlProps,
757
759
  ariaReadonly,
758
- isInteractive,
759
- focusThumbOnChange,
760
- min,
761
760
  max,
761
+ min,
762
+ channel,
762
763
  isDragging,
763
- onKeyDown,
764
+ focusThumbOnChange,
765
+ isInteractive,
766
+ onBlurProp,
764
767
  onFocusProp,
765
- onBlurProp
768
+ onKeyDown
766
769
  ]
767
770
  );
768
771
  return {
@@ -773,9 +776,30 @@ var useColorSlider = ({
773
776
  getTrackProps
774
777
  };
775
778
  };
779
+ var getAriaValueText = (channel, value) => {
780
+ if (channel === "hue") {
781
+ return `${value}\xB0, ${getColorName(value)}`;
782
+ } else {
783
+ return `${value * 100}%`;
784
+ }
785
+ };
786
+ var getColorName = (hue) => {
787
+ if (hue < 30 || hue >= 330) return "Red";
788
+ if (hue < 90) return "Yellow";
789
+ if (hue < 150) return "Green";
790
+ if (hue < 210) return "Cyan";
791
+ if (hue < 270) return "Blue";
792
+ return "Magenta";
793
+ };
776
794
 
777
795
  // src/alpha-slider.tsx
778
796
  var import_jsx_runtime2 = require("react/jsx-runtime");
797
+ var [AlphaSliderProvider, useAlphaSlider] = (0, import_utils4.createContext)(
798
+ {
799
+ name: "SliderContext",
800
+ errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<AlphaSlider />" `
801
+ }
802
+ );
779
803
  var defaultOverlays = (color, min, max, withShadow) => {
780
804
  let overlays = [
781
805
  {
@@ -829,14 +853,15 @@ var AlphaSlider = (0, import_core2.forwardRef)(
829
853
  min,
830
854
  step: 0.01,
831
855
  thumbColor: "transparent",
832
- ...computedProps
856
+ ...computedProps,
857
+ channel: "alpha"
833
858
  });
834
859
  const css = {
835
860
  position: "relative",
836
861
  ...styles.container,
837
862
  ...__css
838
863
  };
839
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
864
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
840
865
  import_core2.ui.div,
841
866
  {
842
867
  className: (0, import_utils4.cx)("ui-alpha-slider", className),
@@ -844,55 +869,87 @@ var AlphaSlider = (0, import_core2.forwardRef)(
844
869
  ...getContainerProps(),
845
870
  children: [
846
871
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.input, { ...getInputProps(inputProps, ref) }),
847
- overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
848
- import_core2.ui.div,
849
- {
850
- className: "ui-alpha-slider__overlay",
851
- __css: {
852
- bottom: 0,
853
- left: 0,
854
- position: "absolute",
855
- right: 0,
856
- top: 0,
857
- ...styles.overlay
858
- },
859
- ...props2
860
- },
861
- index
862
- )),
863
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
864
- import_core2.ui.div,
865
- {
866
- className: "ui-alpha-slider__track",
867
- __css: {
868
- h: "100%",
869
- position: "relative",
870
- w: "100%",
871
- ...styles.track
872
- },
873
- ...getTrackProps(trackProps),
874
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
875
- import_core2.ui.div,
876
- {
877
- className: "ui-alpha-slider__thumb",
878
- __css: { ...styles.thumb },
879
- ...getThumbProps(thumbProps)
880
- }
881
- )
882
- }
883
- )
872
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderOverlay, { ...props2 }, index)),
873
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlphaSliderThumb, { ...getThumbProps(thumbProps) }) })
884
874
  ]
885
875
  }
886
- );
876
+ ) });
887
877
  }
888
878
  );
889
879
  AlphaSlider.displayName = "AlphaSlider";
890
880
  AlphaSlider.__ui__ = "AlphaSlider";
881
+ var AlphaSliderOverlay = (0, import_core2.forwardRef)(
882
+ ({ className, ...rest }, ref) => {
883
+ const { styles } = useAlphaSlider();
884
+ const css = {
885
+ bottom: 0,
886
+ left: 0,
887
+ position: "absolute",
888
+ right: 0,
889
+ top: 0,
890
+ ...styles.overlay
891
+ };
892
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
893
+ import_core2.ui.div,
894
+ {
895
+ ref,
896
+ className: (0, import_utils4.cx)("ui-alpha-slider__overlay", className),
897
+ __css: css,
898
+ ...rest
899
+ }
900
+ );
901
+ }
902
+ );
903
+ AlphaSliderOverlay.displayName = "AlphaSliderOverlay";
904
+ AlphaSliderOverlay.__ui__ = "AlphaSliderOverlay";
905
+ var AlphaSliderTrack = (0, import_core2.forwardRef)(
906
+ ({ className, ...rest }, ref) => {
907
+ const { styles } = useAlphaSlider();
908
+ const css = {
909
+ h: "100%",
910
+ position: "relative",
911
+ w: "100%",
912
+ ...styles.track
913
+ };
914
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
915
+ import_core2.ui.div,
916
+ {
917
+ ref,
918
+ className: (0, import_utils4.cx)("ui-alpha-slider__track", className),
919
+ __css: css,
920
+ ...rest
921
+ }
922
+ );
923
+ }
924
+ );
925
+ AlphaSliderTrack.displayName = "AlphaSliderTrack";
926
+ AlphaSliderTrack.__ui__ = "AlphaSliderTrack";
927
+ var AlphaSliderThumb = (0, import_core2.forwardRef)(
928
+ ({ className, ...rest }, ref) => {
929
+ const { styles } = useAlphaSlider();
930
+ const css = { ...styles.thumb };
931
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
932
+ import_core2.ui.div,
933
+ {
934
+ ref,
935
+ className: (0, import_utils4.cx)("ui-alpha-slider__thumb", className),
936
+ __css: css,
937
+ ...rest
938
+ }
939
+ );
940
+ }
941
+ );
942
+ AlphaSliderThumb.displayName = "AlphaSliderThumb";
943
+ AlphaSliderThumb.__ui__ = "AlphaSliderThumb";
891
944
 
892
945
  // src/hue-slider.tsx
893
946
  var import_core3 = require("@yamada-ui/core");
894
947
  var import_utils5 = require("@yamada-ui/utils");
895
948
  var import_jsx_runtime3 = require("react/jsx-runtime");
949
+ var [HueSliderProvider, useHueSlider] = (0, import_utils5.createContext)({
950
+ name: "SliderContext",
951
+ errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<HueSlider />" `
952
+ });
896
953
  var defaultOverlays2 = (min, max, withShadow) => {
897
954
  let overlays = [
898
955
  {
@@ -924,13 +981,13 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
924
981
  __css,
925
982
  ...computedProps
926
983
  } = (0, import_core3.omitThemeProps)(mergedProps);
927
- const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps });
984
+ const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps, channel: "hue" });
928
985
  const css = {
929
986
  position: "relative",
930
987
  ...styles.container,
931
988
  ...__css
932
989
  };
933
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
990
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
934
991
  import_core3.ui.div,
935
992
  {
936
993
  className: (0, import_utils5.cx)("ui-hue-slider", className),
@@ -938,44 +995,77 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
938
995
  ...getContainerProps(),
939
996
  children: [
940
997
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.input, { ...getInputProps(inputProps, ref) }),
941
- overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
942
- import_core3.ui.div,
943
- {
944
- className: "ui-hue-slider__overlay",
945
- __css: {
946
- bottom: 0,
947
- left: 0,
948
- position: "absolute",
949
- right: 0,
950
- top: 0,
951
- ...styles.overlay
952
- },
953
- ...props2
954
- },
955
- index
956
- )),
957
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
958
- import_core3.ui.div,
959
- {
960
- className: "ui-hue-slider__track",
961
- __css: { h: "100%", position: "relative", w: "100%", ...styles.track },
962
- ...getTrackProps(trackProps),
963
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
964
- import_core3.ui.div,
965
- {
966
- className: "ui-hue-slider__thumb",
967
- __css: { ...styles.thumb },
968
- ...getThumbProps(thumbProps)
969
- }
970
- )
971
- }
972
- )
998
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderOverlay, { ...props2 }, index)),
999
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderThumb, { ...getThumbProps(thumbProps) }) })
973
1000
  ]
974
1001
  }
975
- );
1002
+ ) });
976
1003
  });
977
1004
  HueSlider.displayName = "HueSlider";
978
1005
  HueSlider.__ui__ = "HueSlider";
1006
+ var HueSliderOverlay = (0, import_core3.forwardRef)(
1007
+ ({ className, ...rest }, ref) => {
1008
+ const { styles } = useHueSlider();
1009
+ const css = {
1010
+ bottom: 0,
1011
+ left: 0,
1012
+ position: "absolute",
1013
+ right: 0,
1014
+ top: 0,
1015
+ ...styles.overlay
1016
+ };
1017
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1018
+ import_core3.ui.div,
1019
+ {
1020
+ ref,
1021
+ className: (0, import_utils5.cx)("ui-hue-slider__overlay", className),
1022
+ __css: css,
1023
+ ...rest
1024
+ }
1025
+ );
1026
+ }
1027
+ );
1028
+ HueSliderOverlay.displayName = "HueSliderOverlay";
1029
+ HueSliderOverlay.__ui__ = "HueSliderOverlay";
1030
+ var HueSliderTrack = (0, import_core3.forwardRef)(
1031
+ ({ className, ...rest }, ref) => {
1032
+ const { styles } = useHueSlider();
1033
+ const css = {
1034
+ h: "100%",
1035
+ position: "relative",
1036
+ w: "100%",
1037
+ ...styles.track
1038
+ };
1039
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1040
+ import_core3.ui.div,
1041
+ {
1042
+ ref,
1043
+ className: (0, import_utils5.cx)("ui-hue-slider__track", className),
1044
+ __css: css,
1045
+ ...rest
1046
+ }
1047
+ );
1048
+ }
1049
+ );
1050
+ HueSliderTrack.displayName = "HueSliderTrack";
1051
+ HueSliderTrack.__ui__ = "HueSliderTrack";
1052
+ var HueSliderThumb = (0, import_core3.forwardRef)(
1053
+ ({ className, ...rest }, ref) => {
1054
+ const { styles } = useHueSlider();
1055
+ const css = { ...styles.thumb };
1056
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1057
+ import_core3.ui.div,
1058
+ {
1059
+ ref,
1060
+ className: (0, import_utils5.cx)("ui-hue-slider__thumb", className),
1061
+ __css: css,
1062
+ ...rest
1063
+ }
1064
+ );
1065
+ }
1066
+ );
1067
+ HueSliderThumb.displayName = "HueSliderThumb";
1068
+ HueSliderThumb.__ui__ = "HueSliderThumb";
979
1069
 
980
1070
  // src/color-selector-sliders.tsx
981
1071
  var import_jsx_runtime4 = require("react/jsx-runtime");