@yamada-ui/color-picker 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/alpha-slider.d.mts +62 -0
  4. package/dist/alpha-slider.d.ts +62 -0
  5. package/dist/alpha-slider.js +438 -0
  6. package/dist/alpha-slider.mjs +8 -0
  7. package/dist/chunk-3EO2XBIZ.mjs +54 -0
  8. package/dist/chunk-3KASGDAY.mjs +122 -0
  9. package/dist/chunk-3N443XSV.mjs +105 -0
  10. package/dist/chunk-73BVTMII.mjs +73 -0
  11. package/dist/chunk-7QGCTVDG.mjs +66 -0
  12. package/dist/chunk-DTB2Z3IJ.mjs +278 -0
  13. package/dist/chunk-EMWFECJD.mjs +123 -0
  14. package/dist/chunk-HNVFOSAM.mjs +210 -0
  15. package/dist/chunk-KJS52X4M.mjs +330 -0
  16. package/dist/chunk-MAHWFXUG.mjs +294 -0
  17. package/dist/chunk-N2GG5L7Q.mjs +39 -0
  18. package/dist/chunk-NR2XCTSD.mjs +430 -0
  19. package/dist/chunk-PTTNJPGJ.mjs +98 -0
  20. package/dist/chunk-PVWIBTBL.mjs +67 -0
  21. package/dist/chunk-TFQ62YSQ.mjs +68 -0
  22. package/dist/chunk-U6OJ4TDG.mjs +127 -0
  23. package/dist/color-input.d.mts +79 -0
  24. package/dist/color-input.d.ts +79 -0
  25. package/dist/color-input.js +2283 -0
  26. package/dist/color-input.mjs +21 -0
  27. package/dist/color-picker-body.d.mts +38 -0
  28. package/dist/color-picker-body.d.ts +38 -0
  29. package/dist/color-picker-body.js +794 -0
  30. package/dist/color-picker-body.mjs +14 -0
  31. package/dist/color-picker-channels.d.mts +20 -0
  32. package/dist/color-picker-channels.d.ts +20 -0
  33. package/dist/color-picker-channels.js +101 -0
  34. package/dist/color-picker-channels.mjs +10 -0
  35. package/dist/color-picker-eye-dropper.d.mts +10 -0
  36. package/dist/color-picker-eye-dropper.d.ts +10 -0
  37. package/dist/color-picker-eye-dropper.js +88 -0
  38. package/dist/color-picker-eye-dropper.mjs +10 -0
  39. package/dist/color-picker-sliders.d.mts +30 -0
  40. package/dist/color-picker-sliders.d.ts +30 -0
  41. package/dist/color-picker-sliders.js +590 -0
  42. package/dist/color-picker-sliders.mjs +11 -0
  43. package/dist/color-picker-swatches.d.mts +34 -0
  44. package/dist/color-picker-swatches.d.ts +34 -0
  45. package/dist/color-picker-swatches.js +195 -0
  46. package/dist/color-picker-swatches.mjs +9 -0
  47. package/dist/color-picker.d.mts +59 -0
  48. package/dist/color-picker.d.ts +59 -0
  49. package/dist/color-picker.js +1790 -0
  50. package/dist/color-picker.mjs +19 -0
  51. package/dist/color-swatch.d.mts +36 -0
  52. package/dist/color-swatch.d.ts +36 -0
  53. package/dist/color-swatch.js +124 -0
  54. package/dist/color-swatch.mjs +6 -0
  55. package/dist/hue-slider.d.mts +56 -0
  56. package/dist/hue-slider.d.ts +56 -0
  57. package/dist/hue-slider.js +409 -0
  58. package/dist/hue-slider.mjs +8 -0
  59. package/dist/index.d.mts +23 -0
  60. package/dist/index.d.ts +23 -0
  61. package/dist/index.js +2295 -0
  62. package/dist/index.mjs +36 -0
  63. package/dist/saturation-slider.d.mts +33 -0
  64. package/dist/saturation-slider.d.ts +33 -0
  65. package/dist/saturation-slider.js +414 -0
  66. package/dist/saturation-slider.mjs +7 -0
  67. package/dist/use-color-input.d.mts +90 -0
  68. package/dist/use-color-input.d.ts +90 -0
  69. package/dist/use-color-input.js +340 -0
  70. package/dist/use-color-input.mjs +10 -0
  71. package/dist/use-color-picker.d.mts +131 -0
  72. package/dist/use-color-picker.d.ts +131 -0
  73. package/dist/use-color-picker.js +472 -0
  74. package/dist/use-color-picker.mjs +11 -0
  75. package/dist/use-color-slider.d.mts +69 -0
  76. package/dist/use-color-slider.d.ts +69 -0
  77. package/dist/use-color-slider.js +321 -0
  78. package/dist/use-color-slider.mjs +7 -0
  79. package/dist/use-saturation-slider.d.mts +77 -0
  80. package/dist/use-saturation-slider.d.ts +77 -0
  81. package/dist/use-saturation-slider.js +302 -0
  82. package/dist/use-saturation-slider.mjs +6 -0
  83. package/package.json +88 -0
@@ -0,0 +1,122 @@
1
+ import {
2
+ useSaturationSlider
3
+ } from "./chunk-MAHWFXUG.mjs";
4
+
5
+ // src/saturation-slider.tsx
6
+ import {
7
+ ui,
8
+ forwardRef,
9
+ useMultiComponentStyle,
10
+ omitThemeProps
11
+ } from "@yamada-ui/core";
12
+ import { cx, replaceObject } from "@yamada-ui/utils";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ var SaturationSlider = forwardRef(
15
+ (props, ref) => {
16
+ const [styles, mergedProps] = useMultiComponentStyle(
17
+ "SaturationSlider",
18
+ props
19
+ );
20
+ const {
21
+ className,
22
+ ratio = 16 / 9,
23
+ innerProps,
24
+ inputProps,
25
+ trackProps,
26
+ thumbProps,
27
+ __css,
28
+ ...computedProps
29
+ } = omitThemeProps(mergedProps);
30
+ const {
31
+ overlays,
32
+ getContainerProps,
33
+ getInnerProps,
34
+ getTrackProps,
35
+ getInputProps,
36
+ getThumbProps
37
+ } = useSaturationSlider(computedProps);
38
+ const css = {
39
+ position: "relative",
40
+ _before: {
41
+ content: `""`,
42
+ display: "block",
43
+ h: 0,
44
+ pb: replaceObject(ratio, (r) => `${1 / r * 100}%`)
45
+ },
46
+ "& > *": {
47
+ position: "absolute",
48
+ top: "0",
49
+ right: "0",
50
+ bottom: "0",
51
+ left: "0",
52
+ display: "flex",
53
+ justifyContent: "center",
54
+ alignItems: "center",
55
+ w: "100%",
56
+ h: "100%"
57
+ },
58
+ ...styles.container,
59
+ ...__css
60
+ };
61
+ return /* @__PURE__ */ jsx(
62
+ ui.div,
63
+ {
64
+ className: cx("ui-saturation-slider", className),
65
+ __css: css,
66
+ ...getContainerProps(),
67
+ children: /* @__PURE__ */ jsxs(
68
+ ui.div,
69
+ {
70
+ className: cx("ui-saturation-slider__inner", className),
71
+ __css: { ...styles.inner },
72
+ ...getInnerProps(innerProps),
73
+ children: [
74
+ /* @__PURE__ */ jsx(ui.input, { ...getInputProps(inputProps, ref) }),
75
+ overlays.map((props2, index) => /* @__PURE__ */ jsx(
76
+ ui.div,
77
+ {
78
+ className: "ui-saturation-slider__overlay",
79
+ __css: {
80
+ position: "absolute",
81
+ top: 0,
82
+ left: 0,
83
+ right: 0,
84
+ bottom: 0,
85
+ ...styles.overlay
86
+ },
87
+ ...props2
88
+ },
89
+ index
90
+ )),
91
+ /* @__PURE__ */ jsx(
92
+ ui.div,
93
+ {
94
+ className: "ui-saturation-slider__track",
95
+ __css: {
96
+ position: "relative",
97
+ w: "full",
98
+ h: "full",
99
+ ...styles.track
100
+ },
101
+ ...getTrackProps(trackProps),
102
+ children: /* @__PURE__ */ jsx(
103
+ ui.div,
104
+ {
105
+ className: "ui-saturation-slider__thumb",
106
+ __css: { ...styles.thumb },
107
+ ...getThumbProps(thumbProps)
108
+ }
109
+ )
110
+ }
111
+ )
112
+ ]
113
+ }
114
+ )
115
+ }
116
+ );
117
+ }
118
+ );
119
+
120
+ export {
121
+ SaturationSlider
122
+ };
@@ -0,0 +1,105 @@
1
+ // src/color-swatch.tsx
2
+ import {
3
+ ui,
4
+ forwardRef,
5
+ omitThemeProps,
6
+ useMultiComponentStyle
7
+ } from "@yamada-ui/core";
8
+ import { cx } from "@yamada-ui/utils";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var defaultOverlays = (background, withShadow) => {
11
+ let overlays = [
12
+ {
13
+ bgImage: "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%)",
14
+ bgSize: `8px 8px`,
15
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
16
+ var: [
17
+ {
18
+ name: "checkers",
19
+ token: "colors",
20
+ value: ["blackAlpha.300", "whiteAlpha.300"]
21
+ },
22
+ {
23
+ name: "body",
24
+ token: "colors",
25
+ value: ["whiteAlpha.500", "blackAlpha.500"]
26
+ }
27
+ ]
28
+ },
29
+ { background }
30
+ ];
31
+ if (withShadow)
32
+ overlays = [
33
+ ...overlays,
34
+ {
35
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
36
+ }
37
+ ];
38
+ return overlays;
39
+ };
40
+ var ColorSwatch = forwardRef((props, ref) => {
41
+ const [styles, mergedProps] = useMultiComponentStyle("ColorSwatch", props);
42
+ const {
43
+ className,
44
+ color = "#ffffff00",
45
+ withShadow = true,
46
+ overlays = defaultOverlays(color, withShadow),
47
+ isRounded,
48
+ __css,
49
+ ...rest
50
+ } = omitThemeProps(mergedProps);
51
+ const css = {
52
+ position: "relative",
53
+ _before: {
54
+ content: `""`,
55
+ display: "block",
56
+ h: 0,
57
+ pb: "100%"
58
+ },
59
+ "& > *": {
60
+ overflow: "hidden",
61
+ position: "absolute",
62
+ top: "0",
63
+ right: "0",
64
+ bottom: "0",
65
+ left: "0",
66
+ display: "flex",
67
+ justifyContent: "center",
68
+ alignItems: "center",
69
+ w: "100%",
70
+ h: "100%"
71
+ },
72
+ ...styles.container,
73
+ ...__css
74
+ };
75
+ return /* @__PURE__ */ jsx(
76
+ ui.div,
77
+ {
78
+ ref,
79
+ className: cx("ui-color-swatch", className),
80
+ ...isRounded ? { rounded: "full" } : {},
81
+ __css: css,
82
+ ...rest,
83
+ children: /* @__PURE__ */ jsx(ui.div, { ...isRounded ? { rounded: "full" } : {}, children: overlays.map((props2, index) => /* @__PURE__ */ jsx(
84
+ ui.div,
85
+ {
86
+ __css: {
87
+ position: "absolute",
88
+ top: 0,
89
+ left: 0,
90
+ right: 0,
91
+ bottom: 0,
92
+ ...styles.overlay
93
+ },
94
+ ...isRounded ? { rounded: "full" } : {},
95
+ ...props2
96
+ },
97
+ index
98
+ )) })
99
+ }
100
+ );
101
+ });
102
+
103
+ export {
104
+ ColorSwatch
105
+ };
@@ -0,0 +1,73 @@
1
+ import {
2
+ ColorPickerEyeDropper
3
+ } from "./chunk-3EO2XBIZ.mjs";
4
+ import {
5
+ ColorPickerSliders
6
+ } from "./chunk-7QGCTVDG.mjs";
7
+ import {
8
+ ColorSwatch
9
+ } from "./chunk-3N443XSV.mjs";
10
+ import {
11
+ useColorPickerContext
12
+ } from "./chunk-NR2XCTSD.mjs";
13
+
14
+ // src/color-picker-body.tsx
15
+ import { forwardRef, ui } from "@yamada-ui/core";
16
+ import { cx } from "@yamada-ui/utils";
17
+ import { jsx, jsxs } from "react/jsx-runtime";
18
+ var ColorPickerBody = forwardRef(
19
+ ({
20
+ className,
21
+ withEyeDropper = true,
22
+ withResult,
23
+ eyeDropperRef,
24
+ eyeDropperProps,
25
+ hueSliderRef,
26
+ hueSliderProps,
27
+ alphaSliderRef,
28
+ alphaSliderProps,
29
+ ...rest
30
+ }, ref) => {
31
+ const { value, eyeDropperSupported, styles } = useColorPickerContext();
32
+ const css = {
33
+ display: "flex",
34
+ w: "full",
35
+ ...styles.body
36
+ };
37
+ return /* @__PURE__ */ jsxs(
38
+ ui.div,
39
+ {
40
+ ref,
41
+ className: cx("ui-color-picker__body", className),
42
+ __css: css,
43
+ ...rest,
44
+ children: [
45
+ /* @__PURE__ */ jsx(
46
+ ColorPickerSliders,
47
+ {
48
+ ...{
49
+ hueSliderRef,
50
+ hueSliderProps,
51
+ alphaSliderRef,
52
+ alphaSliderProps
53
+ }
54
+ }
55
+ ),
56
+ withEyeDropper && eyeDropperSupported ? /* @__PURE__ */ jsx(ColorPickerEyeDropper, { ref: eyeDropperRef, ...eyeDropperProps }) : null,
57
+ withResult ? /* @__PURE__ */ jsx(
58
+ ColorSwatch,
59
+ {
60
+ className: "ui-color-picker__result",
61
+ color: value,
62
+ __css: { ...styles.result }
63
+ }
64
+ ) : null
65
+ ]
66
+ }
67
+ );
68
+ }
69
+ );
70
+
71
+ export {
72
+ ColorPickerBody
73
+ };
@@ -0,0 +1,66 @@
1
+ import {
2
+ HueSlider
3
+ } from "./chunk-PTTNJPGJ.mjs";
4
+ import {
5
+ AlphaSlider
6
+ } from "./chunk-U6OJ4TDG.mjs";
7
+ import {
8
+ useColorPickerContext
9
+ } from "./chunk-NR2XCTSD.mjs";
10
+
11
+ // src/color-picker-sliders.tsx
12
+ import { forwardRef, ui } from "@yamada-ui/core";
13
+ import { cx } from "@yamada-ui/utils";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var ColorPickerSliders = forwardRef(
16
+ ({
17
+ className,
18
+ hueSliderRef,
19
+ hueSliderProps,
20
+ alphaSliderRef,
21
+ alphaSliderProps,
22
+ ...rest
23
+ }, ref) => {
24
+ let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorPickerContext();
25
+ if (size === "full")
26
+ size = "lg";
27
+ const css = {
28
+ display: "flex",
29
+ flexDirection: "column",
30
+ ...styles.sliders
31
+ };
32
+ return /* @__PURE__ */ jsxs(
33
+ ui.div,
34
+ {
35
+ ref,
36
+ className: cx("ui-color-picker__sliders", className),
37
+ __css: css,
38
+ ...rest,
39
+ children: [
40
+ /* @__PURE__ */ jsx(
41
+ HueSlider,
42
+ {
43
+ size,
44
+ className: "ui-color-picker__hue-slider",
45
+ __css: { ...styles.hueSlider },
46
+ ...getHueSliderProps(hueSliderProps, hueSliderRef)
47
+ }
48
+ ),
49
+ withAlpha ? /* @__PURE__ */ jsx(
50
+ AlphaSlider,
51
+ {
52
+ size,
53
+ className: "ui-color-picker__alpha-slider",
54
+ __css: { ...styles.alphaSlider },
55
+ ...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)
56
+ }
57
+ ) : null
58
+ ]
59
+ }
60
+ );
61
+ }
62
+ );
63
+
64
+ export {
65
+ ColorPickerSliders
66
+ };
@@ -0,0 +1,278 @@
1
+ import {
2
+ pickObject
3
+ } from "./chunk-N2GG5L7Q.mjs";
4
+
5
+ // src/use-color-slider.ts
6
+ import {
7
+ useFormControlProps,
8
+ formControlProperties,
9
+ getFormControlProperties
10
+ } from "@yamada-ui/form-control";
11
+ import { useControllableState } from "@yamada-ui/use-controllable-state";
12
+ import { useLatestRef } from "@yamada-ui/use-latest-ref";
13
+ import { usePanEvent } from "@yamada-ui/use-pan-event";
14
+ import { useSize } from "@yamada-ui/use-size";
15
+ import {
16
+ omitObject,
17
+ dataAttr,
18
+ handlerAll,
19
+ mergeRefs,
20
+ valueToPercent,
21
+ clampNumber,
22
+ useCallbackRef,
23
+ roundNumberToStep,
24
+ useUpdateEffect,
25
+ percentToValue
26
+ } from "@yamada-ui/utils";
27
+ import { useCallback, useRef, useState } from "react";
28
+ var useColorSlider = ({
29
+ focusThumbOnChange = true,
30
+ ...props
31
+ }) => {
32
+ if (!focusThumbOnChange)
33
+ props.isReadOnly = true;
34
+ let {
35
+ id,
36
+ name,
37
+ value: valueProp,
38
+ defaultValue,
39
+ min = 0,
40
+ max,
41
+ step = 1,
42
+ onChange: onChangeProp,
43
+ onChangeStart: onChangeStartProp,
44
+ onChangeEnd: onChangeEndProp,
45
+ thumbColor,
46
+ required,
47
+ disabled,
48
+ readOnly,
49
+ ...rest
50
+ } = useFormControlProps(props);
51
+ const onChangeStart = useCallbackRef(onChangeStartProp);
52
+ const onChangeEnd = useCallbackRef(onChangeEndProp);
53
+ const [computedValue, setValue] = useControllableState({
54
+ value: valueProp,
55
+ defaultValue: defaultValue != null ? defaultValue : min + (max - min) / 2,
56
+ onChange: onChangeProp
57
+ });
58
+ const value = clampNumber(computedValue, min, max);
59
+ const thumbPercent = valueToPercent(value, min, max);
60
+ const [isDragging, setDragging] = useState(false);
61
+ const isInteractive = !(disabled || readOnly);
62
+ const oneStep = step || (max - min) / 100;
63
+ const tenStep = (max - min) / 10;
64
+ const containerRef = useRef(null);
65
+ const trackRef = useRef(null);
66
+ const thumbRef = useRef(null);
67
+ const latestRef = useLatestRef({
68
+ value,
69
+ min,
70
+ max,
71
+ step,
72
+ isInteractive,
73
+ eventSource: null,
74
+ focusThumbOnChange
75
+ });
76
+ const thumbSize = useSize(thumbRef);
77
+ const getValueFromPointer = useCallback(
78
+ (ev) => {
79
+ var _a, _b;
80
+ if (!trackRef.current)
81
+ return;
82
+ const { min: min2, max: max2, step: step2 } = latestRef.current;
83
+ latestRef.current.eventSource = "pointer";
84
+ const { left, width } = trackRef.current.getBoundingClientRect();
85
+ const { clientX } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
86
+ let percent = (clientX - left) / width;
87
+ let nextValue = percentToValue(percent, min2, max2);
88
+ if (step2)
89
+ nextValue = parseFloat(roundNumberToStep(nextValue, min2, step2));
90
+ nextValue = clampNumber(nextValue, min2, max2);
91
+ return nextValue;
92
+ },
93
+ [latestRef]
94
+ );
95
+ const setValueFromPointer = (ev) => {
96
+ const { value: value2 } = latestRef.current;
97
+ const nextValue = getValueFromPointer(ev);
98
+ if (nextValue != null && nextValue !== value2)
99
+ setValue(nextValue);
100
+ };
101
+ const focusThumb = useCallback(() => {
102
+ const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
103
+ if (focusThumbOnChange2)
104
+ setTimeout(() => {
105
+ var _a;
106
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
107
+ });
108
+ }, [latestRef]);
109
+ const constrain = useCallback(
110
+ (value2) => {
111
+ const { isInteractive: isInteractive2, min: min2, max: max2 } = latestRef.current;
112
+ if (!isInteractive2)
113
+ return;
114
+ value2 = parseFloat(roundNumberToStep(value2, min2, oneStep));
115
+ value2 = clampNumber(value2, min2, max2);
116
+ setValue(value2);
117
+ },
118
+ [setValue, latestRef, oneStep]
119
+ );
120
+ const stepUp = useCallback(
121
+ (step2 = oneStep) => constrain(value + step2),
122
+ [constrain, value, oneStep]
123
+ );
124
+ const stepDown = useCallback(
125
+ (step2 = oneStep) => constrain(value - step2),
126
+ [constrain, value, oneStep]
127
+ );
128
+ const onKeyDown = useCallback(
129
+ (ev) => {
130
+ const { min: min2, max: max2 } = latestRef.current;
131
+ const actions = {
132
+ ArrowRight: () => stepUp(),
133
+ ArrowUp: () => stepUp(),
134
+ ArrowLeft: () => stepDown(),
135
+ ArrowDown: () => stepDown(),
136
+ PageUp: () => stepUp(tenStep),
137
+ PageDown: () => stepDown(tenStep),
138
+ Home: () => constrain(min2),
139
+ End: () => constrain(max2)
140
+ };
141
+ const action = actions[ev.key];
142
+ if (!action)
143
+ return;
144
+ ev.preventDefault();
145
+ ev.stopPropagation();
146
+ action(ev);
147
+ latestRef.current.eventSource = "keyboard";
148
+ },
149
+ [constrain, latestRef, stepDown, stepUp, tenStep]
150
+ );
151
+ usePanEvent(containerRef, {
152
+ onSessionStart: (ev) => {
153
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
154
+ if (!isInteractive2)
155
+ return;
156
+ setDragging(true);
157
+ focusThumb();
158
+ setValueFromPointer(ev);
159
+ onChangeStart(value2);
160
+ },
161
+ onSessionEnd: () => {
162
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
163
+ if (!isInteractive2)
164
+ return;
165
+ setDragging(false);
166
+ onChangeEnd(value2);
167
+ },
168
+ onMove: (ev) => {
169
+ const { isInteractive: isInteractive2 } = latestRef.current;
170
+ if (!isInteractive2)
171
+ return;
172
+ setValueFromPointer(ev);
173
+ }
174
+ });
175
+ useUpdateEffect(() => {
176
+ const { eventSource, value: value2 } = latestRef.current;
177
+ if (eventSource === "keyboard")
178
+ onChangeEnd(value2);
179
+ }, [value, onChangeEnd]);
180
+ const getContainerProps = useCallback(
181
+ (props2 = {}, ref = null) => {
182
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
183
+ const style = {
184
+ ...props2.style,
185
+ ...rest.style,
186
+ paddingInline: `${w / 2}px`
187
+ };
188
+ return {
189
+ ...props2,
190
+ ...omitObject(rest, ["aria-readonly"]),
191
+ ref: mergeRefs(ref, containerRef),
192
+ tabIndex: -1,
193
+ style
194
+ };
195
+ },
196
+ [rest, thumbSize]
197
+ );
198
+ const getInputProps = useCallback(
199
+ (props2 = {}, ref = null) => ({
200
+ ...pickObject(rest, formControlProperties),
201
+ ...props2,
202
+ id,
203
+ ref,
204
+ type: "hidden",
205
+ name,
206
+ value,
207
+ required,
208
+ disabled,
209
+ readOnly
210
+ }),
211
+ [disabled, id, name, readOnly, required, rest, value]
212
+ );
213
+ const getTrackProps = useCallback(
214
+ (props2 = {}, ref = null) => ({
215
+ ...pickObject(
216
+ rest,
217
+ getFormControlProperties({ omit: ["aria-readonly"] })
218
+ ),
219
+ ...props2,
220
+ ref: mergeRefs(ref, trackRef)
221
+ }),
222
+ [rest]
223
+ );
224
+ const getThumbProps = useCallback(
225
+ (props2 = {}, ref = null) => {
226
+ const n = thumbPercent;
227
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
228
+ const style = {
229
+ ...props2.style,
230
+ position: "absolute",
231
+ userSelect: "none",
232
+ touchAction: "none",
233
+ left: `calc(${n}% - ${w / 2}px)`
234
+ };
235
+ return {
236
+ "aria-label": "Slider thumb",
237
+ bg: thumbColor != null ? thumbColor : `hsl(${value}, 100%, 50%)`,
238
+ ...pickObject(rest, formControlProperties),
239
+ ...props2,
240
+ ref: mergeRefs(ref, thumbRef),
241
+ tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
242
+ role: "slider",
243
+ "aria-valuenow": value,
244
+ "aria-valuemin": min,
245
+ "aria-valuemax": max,
246
+ "data-active": dataAttr(isDragging && focusThumbOnChange),
247
+ onKeyDown: handlerAll(props2.onKeyDown, onKeyDown),
248
+ onFocus: handlerAll(props2.onFocus, rest.onFocus),
249
+ onBlur: handlerAll(props2.onBlur, rest.onBlur),
250
+ style
251
+ };
252
+ },
253
+ [
254
+ thumbColor,
255
+ focusThumbOnChange,
256
+ isDragging,
257
+ isInteractive,
258
+ min,
259
+ max,
260
+ onKeyDown,
261
+ rest,
262
+ thumbPercent,
263
+ thumbSize,
264
+ value
265
+ ]
266
+ );
267
+ return {
268
+ value,
269
+ getContainerProps,
270
+ getTrackProps,
271
+ getInputProps,
272
+ getThumbProps
273
+ };
274
+ };
275
+
276
+ export {
277
+ useColorSlider
278
+ };