@yamada-ui/color-picker 1.4.8-dev-20241105102243 → 1.4.9-dev-20241109080944
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/alpha-slider.d.mts +1 -1
- package/dist/alpha-slider.d.ts +1 -1
- package/dist/alpha-slider.js +98 -45
- package/dist/alpha-slider.js.map +1 -1
- package/dist/alpha-slider.mjs +2 -2
- package/dist/{chunk-XL5VWGU4.mjs → chunk-FP3X3PED.mjs} +78 -43
- package/dist/chunk-FP3X3PED.mjs.map +1 -0
- package/dist/{chunk-CZCTI6T2.mjs → chunk-HJMXAALX.mjs} +2 -2
- package/dist/{chunk-62A7F566.mjs → chunk-HPP26MVU.mjs} +3 -3
- package/dist/{chunk-CAVDEKGO.mjs → chunk-LJHUX2RB.mjs} +2 -2
- package/dist/{chunk-APTJWP7T.mjs → chunk-OJVCLBAG.mjs} +2 -2
- package/dist/{chunk-F5EYME2W.mjs → chunk-SGAM4TJL.mjs} +26 -7
- package/dist/chunk-SGAM4TJL.mjs.map +1 -0
- package/dist/chunk-WZEWATJ3.mjs +139 -0
- package/dist/chunk-WZEWATJ3.mjs.map +1 -0
- package/dist/color-picker.js +170 -80
- package/dist/color-picker.js.map +1 -1
- package/dist/color-picker.mjs +7 -7
- package/dist/color-selector-body.js +170 -80
- package/dist/color-selector-body.js.map +1 -1
- package/dist/color-selector-body.mjs +5 -5
- package/dist/color-selector-sliders.js +170 -80
- package/dist/color-selector-sliders.js.map +1 -1
- package/dist/color-selector-sliders.mjs +4 -4
- package/dist/color-selector.js +170 -80
- package/dist/color-selector.js.map +1 -1
- package/dist/color-selector.mjs +6 -6
- package/dist/hue-slider.d.mts +1 -1
- package/dist/hue-slider.d.ts +1 -1
- package/dist/hue-slider.js +95 -40
- package/dist/hue-slider.js.map +1 -1
- package/dist/hue-slider.mjs +2 -2
- package/dist/index.js +170 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/use-color-slider.d.mts +7 -1
- package/dist/use-color-slider.d.ts +7 -1
- package/dist/use-color-slider.js +25 -5
- package/dist/use-color-slider.js.map +1 -1
- package/dist/use-color-slider.mjs +3 -1
- package/package.json +2 -2
- package/dist/chunk-7NWT5PKE.mjs +0 -102
- package/dist/chunk-7NWT5PKE.mjs.map +0 -1
- package/dist/chunk-F5EYME2W.mjs.map +0 -1
- package/dist/chunk-XL5VWGU4.mjs.map +0 -1
- /package/dist/{chunk-CZCTI6T2.mjs.map → chunk-HJMXAALX.mjs.map} +0 -0
- /package/dist/{chunk-62A7F566.mjs.map → chunk-HPP26MVU.mjs.map} +0 -0
- /package/dist/{chunk-CAVDEKGO.mjs.map → chunk-LJHUX2RB.mjs.map} +0 -0
- /package/dist/{chunk-APTJWP7T.mjs.map → chunk-OJVCLBAG.mjs.map} +0 -0
package/dist/hue-slider.js
CHANGED
@@ -44,6 +44,7 @@ var useColorSlider = ({
|
|
44
44
|
id,
|
45
45
|
name,
|
46
46
|
style: styleProp,
|
47
|
+
channel = "hue",
|
47
48
|
defaultValue,
|
48
49
|
max,
|
49
50
|
min = 0,
|
@@ -260,6 +261,7 @@ var useColorSlider = ({
|
|
260
261
|
"aria-valuemax": max,
|
261
262
|
"aria-valuemin": min,
|
262
263
|
"aria-valuenow": value,
|
264
|
+
"aria-valuetext": getAriaValueText(channel, value),
|
263
265
|
"data-active": (0, import_utils.dataAttr)(isDragging && focusThumbOnChange),
|
264
266
|
role: "slider",
|
265
267
|
tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
|
@@ -275,14 +277,15 @@ var useColorSlider = ({
|
|
275
277
|
value,
|
276
278
|
formControlProps,
|
277
279
|
ariaReadonly,
|
278
|
-
isInteractive,
|
279
|
-
focusThumbOnChange,
|
280
|
-
min,
|
281
280
|
max,
|
281
|
+
min,
|
282
|
+
channel,
|
282
283
|
isDragging,
|
283
|
-
|
284
|
+
focusThumbOnChange,
|
285
|
+
isInteractive,
|
286
|
+
onBlurProp,
|
284
287
|
onFocusProp,
|
285
|
-
|
288
|
+
onKeyDown
|
286
289
|
]
|
287
290
|
);
|
288
291
|
return {
|
@@ -293,9 +296,28 @@ var useColorSlider = ({
|
|
293
296
|
getTrackProps
|
294
297
|
};
|
295
298
|
};
|
299
|
+
var getAriaValueText = (channel, value) => {
|
300
|
+
if (channel === "hue") {
|
301
|
+
return `${value}\xB0, ${getColorName(value)}`;
|
302
|
+
} else {
|
303
|
+
return `${value * 100}%`;
|
304
|
+
}
|
305
|
+
};
|
306
|
+
var getColorName = (hue) => {
|
307
|
+
if (hue < 30 || hue >= 330) return "Red";
|
308
|
+
if (hue < 90) return "Yellow";
|
309
|
+
if (hue < 150) return "Green";
|
310
|
+
if (hue < 210) return "Cyan";
|
311
|
+
if (hue < 270) return "Blue";
|
312
|
+
return "Magenta";
|
313
|
+
};
|
296
314
|
|
297
315
|
// src/hue-slider.tsx
|
298
316
|
var import_jsx_runtime = require("react/jsx-runtime");
|
317
|
+
var [HueSliderProvider, useHueSlider] = (0, import_utils2.createContext)({
|
318
|
+
name: "SliderContext",
|
319
|
+
errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<HueSlider />" `
|
320
|
+
});
|
299
321
|
var defaultOverlays = (min, max, withShadow) => {
|
300
322
|
let overlays = [
|
301
323
|
{
|
@@ -327,13 +349,13 @@ var HueSlider = (0, import_core.forwardRef)((props, ref) => {
|
|
327
349
|
__css,
|
328
350
|
...computedProps
|
329
351
|
} = (0, import_core.omitThemeProps)(mergedProps);
|
330
|
-
const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps });
|
352
|
+
const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps, channel: "hue" });
|
331
353
|
const css = {
|
332
354
|
position: "relative",
|
333
355
|
...styles.container,
|
334
356
|
...__css
|
335
357
|
};
|
336
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HueSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
337
359
|
import_core.ui.div,
|
338
360
|
{
|
339
361
|
className: (0, import_utils2.cx)("ui-hue-slider", className),
|
@@ -341,44 +363,77 @@ var HueSlider = (0, import_core.forwardRef)((props, ref) => {
|
|
341
363
|
...getContainerProps(),
|
342
364
|
children: [
|
343
365
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.input, { ...getInputProps(inputProps, ref) }),
|
344
|
-
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
345
|
-
|
346
|
-
{
|
347
|
-
className: "ui-hue-slider__overlay",
|
348
|
-
__css: {
|
349
|
-
bottom: 0,
|
350
|
-
left: 0,
|
351
|
-
position: "absolute",
|
352
|
-
right: 0,
|
353
|
-
top: 0,
|
354
|
-
...styles.overlay
|
355
|
-
},
|
356
|
-
...props2
|
357
|
-
},
|
358
|
-
index
|
359
|
-
)),
|
360
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
361
|
-
import_core.ui.div,
|
362
|
-
{
|
363
|
-
className: "ui-hue-slider__track",
|
364
|
-
__css: { h: "100%", position: "relative", w: "100%", ...styles.track },
|
365
|
-
...getTrackProps(trackProps),
|
366
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
367
|
-
import_core.ui.div,
|
368
|
-
{
|
369
|
-
className: "ui-hue-slider__thumb",
|
370
|
-
__css: { ...styles.thumb },
|
371
|
-
...getThumbProps(thumbProps)
|
372
|
-
}
|
373
|
-
)
|
374
|
-
}
|
375
|
-
)
|
366
|
+
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HueSliderOverlay, { ...props2 }, index)),
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HueSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HueSliderThumb, { ...getThumbProps(thumbProps) }) })
|
376
368
|
]
|
377
369
|
}
|
378
|
-
);
|
370
|
+
) });
|
379
371
|
});
|
380
372
|
HueSlider.displayName = "HueSlider";
|
381
373
|
HueSlider.__ui__ = "HueSlider";
|
374
|
+
var HueSliderOverlay = (0, import_core.forwardRef)(
|
375
|
+
({ className, ...rest }, ref) => {
|
376
|
+
const { styles } = useHueSlider();
|
377
|
+
const css = {
|
378
|
+
bottom: 0,
|
379
|
+
left: 0,
|
380
|
+
position: "absolute",
|
381
|
+
right: 0,
|
382
|
+
top: 0,
|
383
|
+
...styles.overlay
|
384
|
+
};
|
385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
386
|
+
import_core.ui.div,
|
387
|
+
{
|
388
|
+
ref,
|
389
|
+
className: (0, import_utils2.cx)("ui-hue-slider__overlay", className),
|
390
|
+
__css: css,
|
391
|
+
...rest
|
392
|
+
}
|
393
|
+
);
|
394
|
+
}
|
395
|
+
);
|
396
|
+
HueSliderOverlay.displayName = "HueSliderOverlay";
|
397
|
+
HueSliderOverlay.__ui__ = "HueSliderOverlay";
|
398
|
+
var HueSliderTrack = (0, import_core.forwardRef)(
|
399
|
+
({ className, ...rest }, ref) => {
|
400
|
+
const { styles } = useHueSlider();
|
401
|
+
const css = {
|
402
|
+
h: "100%",
|
403
|
+
position: "relative",
|
404
|
+
w: "100%",
|
405
|
+
...styles.track
|
406
|
+
};
|
407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
408
|
+
import_core.ui.div,
|
409
|
+
{
|
410
|
+
ref,
|
411
|
+
className: (0, import_utils2.cx)("ui-hue-slider__track", className),
|
412
|
+
__css: css,
|
413
|
+
...rest
|
414
|
+
}
|
415
|
+
);
|
416
|
+
}
|
417
|
+
);
|
418
|
+
HueSliderTrack.displayName = "HueSliderTrack";
|
419
|
+
HueSliderTrack.__ui__ = "HueSliderTrack";
|
420
|
+
var HueSliderThumb = (0, import_core.forwardRef)(
|
421
|
+
({ className, ...rest }, ref) => {
|
422
|
+
const { styles } = useHueSlider();
|
423
|
+
const css = { ...styles.thumb };
|
424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
425
|
+
import_core.ui.div,
|
426
|
+
{
|
427
|
+
ref,
|
428
|
+
className: (0, import_utils2.cx)("ui-hue-slider__thumb", className),
|
429
|
+
__css: css,
|
430
|
+
...rest
|
431
|
+
}
|
432
|
+
);
|
433
|
+
}
|
434
|
+
);
|
435
|
+
HueSliderThumb.displayName = "HueSliderThumb";
|
436
|
+
HueSliderThumb.__ui__ = "HueSliderThumb";
|
382
437
|
// Annotate the CommonJS export names for ESM import in node:
|
383
438
|
0 && (module.exports = {
|
384
439
|
HueSlider
|
package/dist/hue-slider.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/hue-slider.tsx","../src/use-color-slider.ts"],"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 { cx } from \"@yamada-ui/utils\"\nimport { useColorSlider } from \"./use-color-slider\"\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<UseColorSliderProps>,\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 })\n\n const css: CSSUIObject = {\n position: \"relative\",\n ...styles.container,\n ...__css,\n }\n\n return (\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 <ui.div\n key={index}\n className=\"ui-hue-slider__overlay\"\n __css={{\n bottom: 0,\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-hue-slider__track\"\n __css={{ h: \"100%\", position: \"relative\", w: \"100%\", ...styles.track }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-hue-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n )\n})\n\nHueSlider.displayName = \"HueSlider\"\nHueSlider.__ui__ = \"HueSlider\"\n","import type { CSSUIProps, HTMLUIProps, PropGetter } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n clampNumber,\n dataAttr,\n handlerAll,\n 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\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 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 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 \"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 isInteractive,\n focusThumbOnChange,\n min,\n max,\n isDragging,\n onKeyDown,\n onFocusProp,\n onBlurProp,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAKO;AACP,IAAAA,gBAAmB;;;ACLnB,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAwB;AACxB,mBAWO;AACP,mBAA8C;AA+DvC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,qBAAqB;AAAA,EACrB,GAAG;AACL,MAA2B;AACzB,MAAI,CAAC,mBAAoB,OAAM,aAAa;AAE5C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,IACb,eAAe;AAAA,IACf,GAAG;AAAA,EACL,QAAI,yCAAoB,KAAK;AAC7B,QAAM;AAAA,IACJ;AAAA,MACE,iBAAiB;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,GAAG;AAAA,IACL;AAAA,IACA;AAAA,EACF,QAAI,0BAAY,MAAM,yCAAqB;AAE3C,QAAM,oBAAgB,6BAAe,iBAAiB;AACtD,QAAM,kBAAc,6BAAe,eAAe;AAElD,QAAM,CAAC,eAAe,QAAQ,QAAI,oDAAqB;AAAA,IACrD,cAAc,sCAAgB,OAAO,MAAM,OAAO;AAAA,IAClD,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,YAAQ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C;AAExD,QAAM,MAAmB;AAAA,IACvB,UAAU;AAAA,IACV,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,EACL;AAEA,SACE;AAAA,IAAC,eAAG;AAAA,IAAH;AAAA,MACC,eAAW,kBAAG,iBAAiB,SAAS;AAAA,MACxC,OAAO;AAAA,MACN,GAAG,kBAAkB;AAAA,MAEtB;AAAA,oDAAC,eAAG,OAAH,EAAU,GAAG,cAAc,YAAY,GAAG,GAAG;AAAA,QAE7C,SAAS,IAAI,CAACC,QAAO,UACpB;AAAA,UAAC,eAAG;AAAA,UAAH;AAAA,YAEC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,QAAQ;AAAA,cACR,MAAM;AAAA,cACN,UAAU;AAAA,cACV,OAAO;AAAA,cACP,KAAK;AAAA,cACL,GAAG,OAAO;AAAA,YACZ;AAAA,YACC,GAAGA;AAAA;AAAA,UAVC;AAAA,QAWP,CACD;AAAA,QAED;AAAA,UAAC,eAAG;AAAA,UAAH;AAAA,YACC,WAAU;AAAA,YACV,OAAO,EAAE,GAAG,QAAQ,UAAU,YAAY,GAAG,QAAQ,GAAG,OAAO,MAAM;AAAA,YACpE,GAAG,cAAc,UAAU;AAAA,YAE5B;AAAA,cAAC,eAAG;AAAA,cAAH;AAAA,gBACC,WAAU;AAAA,gBACV,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,gBACxB,GAAG,cAAc,UAAU;AAAA;AAAA,YAC9B;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,UAAU,cAAc;AACxB,UAAU,SAAS;","names":["import_utils","max","min","step","value","focusThumbOnChange","isInteractive","props","props"]}
|
1
|
+
{"version":3,"sources":["../src/hue-slider.tsx","../src/use-color-slider.ts"],"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","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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAKO;AACP,IAAAA,gBAAkC;;;ACLlC,0BAGO;AACP,oCAAqC;AACrC,4BAA6B;AAC7B,2BAA4B;AAC5B,sBAAw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AAK,GAAG,QAAQ;AAC/B,UAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,UAAM,MAAmB;AAAA,MACvB,GAAG;AAAA,MACH,UAAU;AAAA,MACV,GAAG;AAAA,MACH,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,eAAW,kBAAG,wBAAwB,SAAS;AAAA,QAC/C,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;AAIxB,IAAM,qBAAiB;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,eAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,eAAW,kBAAG,wBAAwB,SAAS;AAAA,QAC/C,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;","names":["import_utils","max","min","step","value","focusThumbOnChange","isInteractive","props","props"]}
|
package/dist/hue-slider.mjs
CHANGED
package/dist/index.js
CHANGED
@@ -51,6 +51,7 @@ var useColorSlider = ({
|
|
51
51
|
id,
|
52
52
|
name,
|
53
53
|
style: styleProp,
|
54
|
+
channel = "hue",
|
54
55
|
defaultValue,
|
55
56
|
max,
|
56
57
|
min = 0,
|
@@ -267,6 +268,7 @@ var useColorSlider = ({
|
|
267
268
|
"aria-valuemax": max,
|
268
269
|
"aria-valuemin": min,
|
269
270
|
"aria-valuenow": value,
|
271
|
+
"aria-valuetext": getAriaValueText(channel, value),
|
270
272
|
"data-active": (0, import_utils.dataAttr)(isDragging && focusThumbOnChange),
|
271
273
|
role: "slider",
|
272
274
|
tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
|
@@ -282,14 +284,15 @@ var useColorSlider = ({
|
|
282
284
|
value,
|
283
285
|
formControlProps,
|
284
286
|
ariaReadonly,
|
285
|
-
isInteractive,
|
286
|
-
focusThumbOnChange,
|
287
|
-
min,
|
288
287
|
max,
|
288
|
+
min,
|
289
|
+
channel,
|
289
290
|
isDragging,
|
290
|
-
|
291
|
+
focusThumbOnChange,
|
292
|
+
isInteractive,
|
293
|
+
onBlurProp,
|
291
294
|
onFocusProp,
|
292
|
-
|
295
|
+
onKeyDown
|
293
296
|
]
|
294
297
|
);
|
295
298
|
return {
|
@@ -300,9 +303,30 @@ var useColorSlider = ({
|
|
300
303
|
getTrackProps
|
301
304
|
};
|
302
305
|
};
|
306
|
+
var getAriaValueText = (channel, value) => {
|
307
|
+
if (channel === "hue") {
|
308
|
+
return `${value}\xB0, ${getColorName(value)}`;
|
309
|
+
} else {
|
310
|
+
return `${value * 100}%`;
|
311
|
+
}
|
312
|
+
};
|
313
|
+
var getColorName = (hue) => {
|
314
|
+
if (hue < 30 || hue >= 330) return "Red";
|
315
|
+
if (hue < 90) return "Yellow";
|
316
|
+
if (hue < 150) return "Green";
|
317
|
+
if (hue < 210) return "Cyan";
|
318
|
+
if (hue < 270) return "Blue";
|
319
|
+
return "Magenta";
|
320
|
+
};
|
303
321
|
|
304
322
|
// src/alpha-slider.tsx
|
305
323
|
var import_jsx_runtime = require("react/jsx-runtime");
|
324
|
+
var [AlphaSliderProvider, useAlphaSlider] = (0, import_utils2.createContext)(
|
325
|
+
{
|
326
|
+
name: "SliderContext",
|
327
|
+
errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<AlphaSlider />" `
|
328
|
+
}
|
329
|
+
);
|
306
330
|
var defaultOverlays = (color, min, max, withShadow) => {
|
307
331
|
let overlays = [
|
308
332
|
{
|
@@ -356,14 +380,15 @@ var AlphaSlider = (0, import_core.forwardRef)(
|
|
356
380
|
min,
|
357
381
|
step: 0.01,
|
358
382
|
thumbColor: "transparent",
|
359
|
-
...computedProps
|
383
|
+
...computedProps,
|
384
|
+
channel: "alpha"
|
360
385
|
});
|
361
386
|
const css = {
|
362
387
|
position: "relative",
|
363
388
|
...styles.container,
|
364
389
|
...__css
|
365
390
|
};
|
366
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlphaSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
367
392
|
import_core.ui.div,
|
368
393
|
{
|
369
394
|
className: (0, import_utils2.cx)("ui-alpha-slider", className),
|
@@ -371,50 +396,78 @@ var AlphaSlider = (0, import_core.forwardRef)(
|
|
371
396
|
...getContainerProps(),
|
372
397
|
children: [
|
373
398
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.input, { ...getInputProps(inputProps, ref) }),
|
374
|
-
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
375
|
-
|
376
|
-
{
|
377
|
-
className: "ui-alpha-slider__overlay",
|
378
|
-
__css: {
|
379
|
-
bottom: 0,
|
380
|
-
left: 0,
|
381
|
-
position: "absolute",
|
382
|
-
right: 0,
|
383
|
-
top: 0,
|
384
|
-
...styles.overlay
|
385
|
-
},
|
386
|
-
...props2
|
387
|
-
},
|
388
|
-
index
|
389
|
-
)),
|
390
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
391
|
-
import_core.ui.div,
|
392
|
-
{
|
393
|
-
className: "ui-alpha-slider__track",
|
394
|
-
__css: {
|
395
|
-
h: "100%",
|
396
|
-
position: "relative",
|
397
|
-
w: "100%",
|
398
|
-
...styles.track
|
399
|
-
},
|
400
|
-
...getTrackProps(trackProps),
|
401
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
402
|
-
import_core.ui.div,
|
403
|
-
{
|
404
|
-
className: "ui-alpha-slider__thumb",
|
405
|
-
__css: { ...styles.thumb },
|
406
|
-
...getThumbProps(thumbProps)
|
407
|
-
}
|
408
|
-
)
|
409
|
-
}
|
410
|
-
)
|
399
|
+
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlphaSliderOverlay, { ...props2 }, index)),
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlphaSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlphaSliderThumb, { ...getThumbProps(thumbProps) }) })
|
411
401
|
]
|
412
402
|
}
|
413
|
-
);
|
403
|
+
) });
|
414
404
|
}
|
415
405
|
);
|
416
406
|
AlphaSlider.displayName = "AlphaSlider";
|
417
407
|
AlphaSlider.__ui__ = "AlphaSlider";
|
408
|
+
var AlphaSliderOverlay = (0, import_core.forwardRef)(
|
409
|
+
({ className, ...rest }, ref) => {
|
410
|
+
const { styles } = useAlphaSlider();
|
411
|
+
const css = {
|
412
|
+
bottom: 0,
|
413
|
+
left: 0,
|
414
|
+
position: "absolute",
|
415
|
+
right: 0,
|
416
|
+
top: 0,
|
417
|
+
...styles.overlay
|
418
|
+
};
|
419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
420
|
+
import_core.ui.div,
|
421
|
+
{
|
422
|
+
ref,
|
423
|
+
className: (0, import_utils2.cx)("ui-alpha-slider__overlay", className),
|
424
|
+
__css: css,
|
425
|
+
...rest
|
426
|
+
}
|
427
|
+
);
|
428
|
+
}
|
429
|
+
);
|
430
|
+
AlphaSliderOverlay.displayName = "AlphaSliderOverlay";
|
431
|
+
AlphaSliderOverlay.__ui__ = "AlphaSliderOverlay";
|
432
|
+
var AlphaSliderTrack = (0, import_core.forwardRef)(
|
433
|
+
({ className, ...rest }, ref) => {
|
434
|
+
const { styles } = useAlphaSlider();
|
435
|
+
const css = {
|
436
|
+
h: "100%",
|
437
|
+
position: "relative",
|
438
|
+
w: "100%",
|
439
|
+
...styles.track
|
440
|
+
};
|
441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
442
|
+
import_core.ui.div,
|
443
|
+
{
|
444
|
+
ref,
|
445
|
+
className: (0, import_utils2.cx)("ui-alpha-slider__track", className),
|
446
|
+
__css: css,
|
447
|
+
...rest
|
448
|
+
}
|
449
|
+
);
|
450
|
+
}
|
451
|
+
);
|
452
|
+
AlphaSliderTrack.displayName = "AlphaSliderTrack";
|
453
|
+
AlphaSliderTrack.__ui__ = "AlphaSliderTrack";
|
454
|
+
var AlphaSliderThumb = (0, import_core.forwardRef)(
|
455
|
+
({ className, ...rest }, ref) => {
|
456
|
+
const { styles } = useAlphaSlider();
|
457
|
+
const css = { ...styles.thumb };
|
458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
459
|
+
import_core.ui.div,
|
460
|
+
{
|
461
|
+
ref,
|
462
|
+
className: (0, import_utils2.cx)("ui-alpha-slider__thumb", className),
|
463
|
+
__css: css,
|
464
|
+
...rest
|
465
|
+
}
|
466
|
+
);
|
467
|
+
}
|
468
|
+
);
|
469
|
+
AlphaSliderThumb.displayName = "AlphaSliderThumb";
|
470
|
+
AlphaSliderThumb.__ui__ = "AlphaSliderThumb";
|
418
471
|
|
419
472
|
// src/color-picker.tsx
|
420
473
|
var import_core12 = require("@yamada-ui/core");
|
@@ -900,6 +953,10 @@ var import_utils6 = require("@yamada-ui/utils");
|
|
900
953
|
var import_core3 = require("@yamada-ui/core");
|
901
954
|
var import_utils5 = require("@yamada-ui/utils");
|
902
955
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
956
|
+
var [HueSliderProvider, useHueSlider] = (0, import_utils5.createContext)({
|
957
|
+
name: "SliderContext",
|
958
|
+
errorMessage: `useSliderContext returned is 'undefined'. Seems you forgot to wrap the components in "<HueSlider />" `
|
959
|
+
});
|
903
960
|
var defaultOverlays2 = (min, max, withShadow) => {
|
904
961
|
let overlays = [
|
905
962
|
{
|
@@ -931,13 +988,13 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
|
|
931
988
|
__css,
|
932
989
|
...computedProps
|
933
990
|
} = (0, import_core3.omitThemeProps)(mergedProps);
|
934
|
-
const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps });
|
991
|
+
const { getContainerProps, getInputProps, getThumbProps, getTrackProps } = useColorSlider({ max, min, step: 1, ...computedProps, channel: "hue" });
|
935
992
|
const css = {
|
936
993
|
position: "relative",
|
937
994
|
...styles.container,
|
938
995
|
...__css
|
939
996
|
};
|
940
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
941
998
|
import_core3.ui.div,
|
942
999
|
{
|
943
1000
|
className: (0, import_utils5.cx)("ui-hue-slider", className),
|
@@ -945,44 +1002,77 @@ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
|
|
945
1002
|
...getContainerProps(),
|
946
1003
|
children: [
|
947
1004
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.input, { ...getInputProps(inputProps, ref) }),
|
948
|
-
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
949
|
-
|
950
|
-
{
|
951
|
-
className: "ui-hue-slider__overlay",
|
952
|
-
__css: {
|
953
|
-
bottom: 0,
|
954
|
-
left: 0,
|
955
|
-
position: "absolute",
|
956
|
-
right: 0,
|
957
|
-
top: 0,
|
958
|
-
...styles.overlay
|
959
|
-
},
|
960
|
-
...props2
|
961
|
-
},
|
962
|
-
index
|
963
|
-
)),
|
964
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
965
|
-
import_core3.ui.div,
|
966
|
-
{
|
967
|
-
className: "ui-hue-slider__track",
|
968
|
-
__css: { h: "100%", position: "relative", w: "100%", ...styles.track },
|
969
|
-
...getTrackProps(trackProps),
|
970
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
971
|
-
import_core3.ui.div,
|
972
|
-
{
|
973
|
-
className: "ui-hue-slider__thumb",
|
974
|
-
__css: { ...styles.thumb },
|
975
|
-
...getThumbProps(thumbProps)
|
976
|
-
}
|
977
|
-
)
|
978
|
-
}
|
979
|
-
)
|
1005
|
+
overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderOverlay, { ...props2 }, index)),
|
1006
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderTrack, { ...getTrackProps(trackProps), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HueSliderThumb, { ...getThumbProps(thumbProps) }) })
|
980
1007
|
]
|
981
1008
|
}
|
982
|
-
);
|
1009
|
+
) });
|
983
1010
|
});
|
984
1011
|
HueSlider.displayName = "HueSlider";
|
985
1012
|
HueSlider.__ui__ = "HueSlider";
|
1013
|
+
var HueSliderOverlay = (0, import_core3.forwardRef)(
|
1014
|
+
({ className, ...rest }, ref) => {
|
1015
|
+
const { styles } = useHueSlider();
|
1016
|
+
const css = {
|
1017
|
+
bottom: 0,
|
1018
|
+
left: 0,
|
1019
|
+
position: "absolute",
|
1020
|
+
right: 0,
|
1021
|
+
top: 0,
|
1022
|
+
...styles.overlay
|
1023
|
+
};
|
1024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
1025
|
+
import_core3.ui.div,
|
1026
|
+
{
|
1027
|
+
ref,
|
1028
|
+
className: (0, import_utils5.cx)("ui-hue-slider__overlay", className),
|
1029
|
+
__css: css,
|
1030
|
+
...rest
|
1031
|
+
}
|
1032
|
+
);
|
1033
|
+
}
|
1034
|
+
);
|
1035
|
+
HueSliderOverlay.displayName = "HueSliderOverlay";
|
1036
|
+
HueSliderOverlay.__ui__ = "HueSliderOverlay";
|
1037
|
+
var HueSliderTrack = (0, import_core3.forwardRef)(
|
1038
|
+
({ className, ...rest }, ref) => {
|
1039
|
+
const { styles } = useHueSlider();
|
1040
|
+
const css = {
|
1041
|
+
h: "100%",
|
1042
|
+
position: "relative",
|
1043
|
+
w: "100%",
|
1044
|
+
...styles.track
|
1045
|
+
};
|
1046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
1047
|
+
import_core3.ui.div,
|
1048
|
+
{
|
1049
|
+
ref,
|
1050
|
+
className: (0, import_utils5.cx)("ui-hue-slider__track", className),
|
1051
|
+
__css: css,
|
1052
|
+
...rest
|
1053
|
+
}
|
1054
|
+
);
|
1055
|
+
}
|
1056
|
+
);
|
1057
|
+
HueSliderTrack.displayName = "HueSliderTrack";
|
1058
|
+
HueSliderTrack.__ui__ = "HueSliderTrack";
|
1059
|
+
var HueSliderThumb = (0, import_core3.forwardRef)(
|
1060
|
+
({ className, ...rest }, ref) => {
|
1061
|
+
const { styles } = useHueSlider();
|
1062
|
+
const css = { ...styles.thumb };
|
1063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
1064
|
+
import_core3.ui.div,
|
1065
|
+
{
|
1066
|
+
ref,
|
1067
|
+
className: (0, import_utils5.cx)("ui-hue-slider__thumb", className),
|
1068
|
+
__css: css,
|
1069
|
+
...rest
|
1070
|
+
}
|
1071
|
+
);
|
1072
|
+
}
|
1073
|
+
);
|
1074
|
+
HueSliderThumb.displayName = "HueSliderThumb";
|
1075
|
+
HueSliderThumb.__ui__ = "HueSliderThumb";
|
986
1076
|
|
987
1077
|
// src/color-selector-sliders.tsx
|
988
1078
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|