@yamada-ui/color-picker 2.0.0-next-20240513035416 → 2.0.0-next-20240516121223

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/dist/{chunk-L2ILNXB4.mjs → chunk-5QT7SRA4.mjs} +2 -2
  2. package/dist/{chunk-L2ILNXB4.mjs.map → chunk-5QT7SRA4.mjs.map} +1 -1
  3. package/dist/{chunk-ZUPKUHBV.mjs → chunk-C4ZOHCKU.mjs} +5 -5
  4. package/dist/{chunk-5CQI26IR.mjs → chunk-FUV4QZBE.mjs} +4 -4
  5. package/dist/{chunk-JFTUHZYL.mjs → chunk-JOX5PPY7.mjs} +2 -2
  6. package/dist/{chunk-CR3JRFXA.mjs → chunk-SBN7FEOE.mjs} +5 -5
  7. package/dist/chunk-SBN7FEOE.mjs.map +1 -0
  8. package/dist/{chunk-KCV32DAB.mjs → chunk-SDO53ZU7.mjs} +6 -11
  9. package/dist/chunk-SDO53ZU7.mjs.map +1 -0
  10. package/dist/{chunk-NMHU434U.mjs → chunk-SMXYADBA.mjs} +2 -2
  11. package/dist/{chunk-NGSPXJBL.mjs → chunk-Y6662BW7.mjs} +2 -2
  12. package/dist/{chunk-2PW2Z2XD.mjs → chunk-YXQQHV2S.mjs} +2 -2
  13. package/dist/color-picker.js +4 -4
  14. package/dist/color-picker.js.map +1 -1
  15. package/dist/color-picker.mjs +9 -9
  16. package/dist/color-selector-body.js.map +1 -1
  17. package/dist/color-selector-body.mjs +4 -4
  18. package/dist/color-selector-channels.js.map +1 -1
  19. package/dist/color-selector-channels.mjs +2 -2
  20. package/dist/color-selector-eye-dropper.js.map +1 -1
  21. package/dist/color-selector-eye-dropper.mjs +2 -2
  22. package/dist/color-selector-sliders.js.map +1 -1
  23. package/dist/color-selector-sliders.mjs +2 -2
  24. package/dist/color-selector-swatches.js.map +1 -1
  25. package/dist/color-selector-swatches.mjs +2 -2
  26. package/dist/color-selector.js +1 -1
  27. package/dist/color-selector.js.map +1 -1
  28. package/dist/color-selector.mjs +7 -7
  29. package/dist/index.js +4 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +9 -9
  32. package/dist/use-color-picker.js +2 -2
  33. package/dist/use-color-picker.js.map +1 -1
  34. package/dist/use-color-picker.mjs +1 -1
  35. package/dist/use-color-selector.js +1 -1
  36. package/dist/use-color-selector.js.map +1 -1
  37. package/dist/use-color-selector.mjs +1 -1
  38. package/package.json +4 -4
  39. package/dist/chunk-CR3JRFXA.mjs.map +0 -1
  40. package/dist/chunk-KCV32DAB.mjs.map +0 -1
  41. /package/dist/{chunk-ZUPKUHBV.mjs.map → chunk-C4ZOHCKU.mjs.map} +0 -0
  42. /package/dist/{chunk-5CQI26IR.mjs.map → chunk-FUV4QZBE.mjs.map} +0 -0
  43. /package/dist/{chunk-JFTUHZYL.mjs.map → chunk-JOX5PPY7.mjs.map} +0 -0
  44. /package/dist/{chunk-NMHU434U.mjs.map → chunk-SMXYADBA.mjs.map} +0 -0
  45. /package/dist/{chunk-NGSPXJBL.mjs.map → chunk-Y6662BW7.mjs.map} +0 -0
  46. /package/dist/{chunk-2PW2Z2XD.mjs.map → chunk-YXQQHV2S.mjs.map} +0 -0
@@ -1,21 +1,21 @@
1
1
  "use client"
2
2
  import {
3
3
  ColorPicker
4
- } from "./chunk-KCV32DAB.mjs";
5
- import "./chunk-CR3JRFXA.mjs";
6
- import "./chunk-ZUPKUHBV.mjs";
4
+ } from "./chunk-SDO53ZU7.mjs";
5
+ import "./chunk-SBN7FEOE.mjs";
6
+ import "./chunk-C4ZOHCKU.mjs";
7
7
  import "./chunk-RR6V37S5.mjs";
8
8
  import "./chunk-KKQ3MOXJ.mjs";
9
- import "./chunk-5CQI26IR.mjs";
10
- import "./chunk-2PW2Z2XD.mjs";
11
- import "./chunk-NMHU434U.mjs";
12
- import "./chunk-JFTUHZYL.mjs";
9
+ import "./chunk-FUV4QZBE.mjs";
10
+ import "./chunk-YXQQHV2S.mjs";
11
+ import "./chunk-SMXYADBA.mjs";
12
+ import "./chunk-JOX5PPY7.mjs";
13
13
  import "./chunk-K3QQKPFT.mjs";
14
14
  import "./chunk-YD5QBKEV.mjs";
15
15
  import "./chunk-R4DLOKLT.mjs";
16
- import "./chunk-NGSPXJBL.mjs";
16
+ import "./chunk-Y6662BW7.mjs";
17
17
  import "./chunk-UQWAM6TA.mjs";
18
- import "./chunk-L2ILNXB4.mjs";
18
+ import "./chunk-5QT7SRA4.mjs";
19
19
  export {
20
20
  ColorPicker
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-selector-body.tsx","../src/color-selector-eye-dropper.tsx","../src/use-color-selector.ts","../src/color-selector-sliders.tsx","../src/alpha-slider.tsx","../src/use-color-slider.ts","../src/hue-slider.tsx","../src/color-swatch.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { ColorSelectorEyeDropperProps } from \"./color-selector-eye-dropper\"\nimport { ColorSelectorEyeDropper } from \"./color-selector-eye-dropper\"\nimport type { ColorSelectorSlidersProps } from \"./color-selector-sliders\"\nimport { ColorSelectorSliders } from \"./color-selector-sliders\"\nimport { ColorSwatch } from \"./color-swatch\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorBodyOptions = {\n /**\n * If `true`, display the result component.\n *\n * @default true\n */\n withResult?: boolean\n /**\n * If `true` display the eye dropper component.\n *\n * @default true\n */\n withEyeDropper?: boolean\n /**\n * Ref for the eye dropper component.\n */\n eyeDropperRef?: ForwardedRef<HTMLButtonElement>\n /**\n * Props for the eye dropper component.\n */\n eyeDropperProps?: ColorSelectorEyeDropperProps\n}\n\nexport type ColorSelectorBodyProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorBodyOptions &\n Pick<\n ColorSelectorSlidersProps,\n \"hueSliderRef\" | \"hueSliderProps\" | \"alphaSliderRef\" | \"alphaSliderProps\"\n >\n\nexport const ColorSelectorBody = forwardRef<ColorSelectorBodyProps, \"div\">(\n (\n {\n className,\n withEyeDropper = true,\n withResult,\n eyeDropperRef,\n eyeDropperProps,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n const { value, eyeDropperSupported, styles } = useColorSelectorContext()\n\n const css: CSSUIObject = {\n display: \"flex\",\n w: \"100%\",\n ...styles.body,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__body\", className)}\n __css={css}\n {...rest}\n >\n <ColorSelectorSliders\n {...{\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n }}\n />\n\n {withEyeDropper && eyeDropperSupported ? (\n <ColorSelectorEyeDropper ref={eyeDropperRef} {...eyeDropperProps} />\n ) : null}\n\n {withResult ? (\n <ColorSwatch\n className=\"ui-color-selector__result\"\n color={value}\n __css={{ ...styles.result }}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n","import type { IconButtonProps } from \"@yamada-ui/button\"\nimport { IconButton } from \"@yamada-ui/button\"\nimport { forwardRef } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\nexport type ColorSelectorEyeDropperProps = IconButtonProps\n\nexport const ColorSelectorEyeDropper = forwardRef<\n ColorSelectorEyeDropperProps,\n \"button\"\n>(({ className, ...rest }, ref) => {\n const { getEyeDropperProps, readOnly, size, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n h: \"auto\",\n minW: \"auto\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.eyeDropper,\n }\n\n return (\n <IconButton\n className={cx(\"ui-color-selector__eye-dropper\", className)}\n variant=\"outline\"\n size={size}\n __css={css}\n {...getEyeDropperProps(rest, ref)}\n >\n <EyeDropperIcon className=\"ui-color-selector__eye-dropper-icon\" />\n </IconButton>\n )\n})\n\nexport const EyeDropperIcon: FC<IconProps> = ({ ...rest }) => {\n return (\n <Icon\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...rest}\n >\n <path d=\"m2 22 1-1h3l9-9\" />\n <path d=\"M3 21v-3l9-9\" />\n <path d=\"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z\" />\n </Icon>\n )\n}\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n","import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport { AlphaSlider } from \"./alpha-slider\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport { HueSlider } from \"./hue-slider\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorSlidersOptions = {\n /**\n * Ref for the hue slider component.\n */\n hueSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the hue slider component.\n */\n hueSliderProps?: Omit<HueSliderProps, \"value\" | \"defaultValue\">\n /**\n * Ref for the alpha slider component.\n */\n alphaSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the alpha slider component.\n */\n alphaSliderProps?: Omit<AlphaSliderProps, \"value\" | \"defaultValue\">\n}\n\nexport type ColorSelectorSlidersProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorSlidersOptions\n\nexport const ColorSelectorSliders = forwardRef<\n ColorSelectorSlidersProps,\n \"div\"\n>(\n (\n {\n className,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } =\n useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = {\n display: \"flex\",\n flexDirection: \"column\",\n ...styles.sliders,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__sliders\", className)}\n __css={css}\n {...rest}\n >\n <HueSlider\n size={size}\n className=\"ui-color-selector__hue-slider\"\n __css={{ ...styles.hueSlider }}\n {...getHueSliderProps(hueSliderProps, hueSliderRef)}\n />\n\n {withAlpha ? (\n <AlphaSlider\n size={size}\n className=\"ui-color-selector__alpha-slider\"\n __css={{ ...styles.alphaSlider }}\n {...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { alphaToHex, convertColor, cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n color: string,\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n {\n bgGradient: `linear(to-r, ${\n convertColor(color)(\"hex\") + alphaToHex(min)\n }, ${convertColor(color)(\"hex\") + alphaToHex(max)})`,\n },\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ntype AlphaSliderOptions = {\n /**\n * The color used for the slider.\n *\n * @default \"#ffffff\"\n */\n color?: string\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 1\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\nexport type AlphaSliderProps = ThemeProps<\"AlphaSlider\"> &\n Partial<Omit<UseColorSliderProps, \"color\">> &\n AlphaSliderOptions\n\n/**\n * `AlphaSlider` is a component used to allow the user to select color transparency.\n *\n * @see Docs https://yamada-ui.com/components/forms/alpha-slider\n */\nexport const AlphaSlider = forwardRef<AlphaSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"AlphaSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n color = \"#ffffff\",\n min = 0,\n max = 1,\n withShadow = true,\n overlays = defaultOverlays(color, min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({\n min,\n max,\n step: 0.01,\n thumbColor: \"transparent\",\n ...computedProps,\n })\n\n const css: CSSUIObject = {\n position: \"relative\",\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-alpha-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-alpha-slider__overlay\"\n __css={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-alpha-slider__track\"\n __css={{\n position: \"relative\",\n w: \"100%\",\n h: \"100%\",\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-alpha-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n )\n },\n)\n","import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\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\ntype HueSliderOptions = {\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 360\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\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 type HueSliderProps = ThemeProps<\"HueSlider\"> &\n Partial<UseColorSliderProps> &\n HueSliderOptions\n\nexport const HueSlider = forwardRef<HueSliderProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"HueSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n min = 0,\n max = 360,\n withShadow = true,\n overlays = defaultOverlays(min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({ min, max, 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 position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-hue-slider__track\"\n __css={{ position: \"relative\", w: \"100%\", h: \"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","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\n\nconst defaultOverlays = (\n background: string,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n { background },\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ntype ColorSwatchOptions = {\n /**\n * The color used for the swatch element.\n *\n * @default \"#ffffff00\"\n */\n color?: string\n /**\n * The overlay used for the swatch element.\n */\n overlays?: HTMLUIProps<\"div\">[]\n /**\n * If `true`, the swatch element has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * If `true`, the color swatch will be perfectly round. Else, it'll be slightly round.\n *\n * @default false\n */\n isRounded?: boolean\n}\n\nexport type ColorSwatchProps = Omit<HTMLUIProps<\"div\">, \"color\"> &\n ThemeProps<\"ColorSwatch\"> &\n ColorSwatchOptions\n\n/**\n * `ColorSwatch` is a component that displays color samples.\n *\n * @see Docs https://yamada-ui.com/components/data-display/color-swatch\n */\nexport const ColorSwatch = forwardRef<ColorSwatchProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"ColorSwatch\", props)\n const {\n className,\n color = \"#ffffff00\",\n withShadow = true,\n overlays = defaultOverlays(color, withShadow),\n isRounded,\n __css,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const css: CSSUIObject = {\n position: \"relative\",\n _before: {\n content: `\"\"`,\n display: \"block\",\n h: 0,\n pb: \"100%\",\n },\n \"& > *\": {\n overflow: \"hidden\",\n position: \"absolute\",\n top: \"0\",\n right: \"0\",\n bottom: \"0\",\n left: \"0\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n w: \"100%\",\n h: \"100%\",\n },\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-swatch\", className)}\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n __css={css}\n {...rest}\n >\n <ui.div {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}>\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n __css={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n {...props}\n />\n ))}\n </ui.div>\n </ui.div>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA+B;AAE/B,IAAAC,gBAAmB;;;ACDnB,oBAA2B;AAC3B,kBAA2B;AAG3B,kBAAqB;AACrB,IAAAC,gBAAmB;;;ACCnB,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAiEhD,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADrEG;AAtBC,IAAM,8BAA0B,wBAGrC,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AACjC,QAAM,EAAE,oBAAoB,UAAU,MAAM,OAAO,IACjD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,GAAG;AAAA,IACH,MAAM;AAAA,IACN,eAAe,WAAW,SAAS;AAAA,IACnC,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,kBAAG,kCAAkC,SAAS;AAAA,MACzD,SAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,MACN,GAAG,mBAAmB,MAAM,GAAG;AAAA,MAEhC,sDAAC,kBA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AE,OAAO,qBAAqB,OAAO,IAAI,wBAAwB;AAEvE,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT,GAAG;AAAA,MACH,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,gBAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,eAAW,kBAAG,2BAA2B,SAAS;AAAA,QAClD,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,gBACF;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA,UACF;AAAA,UAEC,kBAAkB,sBACjB,6CAAC,2BAAwB,KAAK,eAAgB,GAAG,iBAAiB,IAChE;AAAA,UAEH,aACC;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,OAAO;AAAA,cACP,OAAO,EAAE,GAAG,OAAO,OAAO;AAAA;AAAA,UAC5B,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["import_core","import_utils","import_utils","import_core","import_utils","import_core","import_utils","import_form_control","import_use_controllable_state","import_utils","import_react","min","max","step","value","focusThumbOnChange","isInteractive","props","import_jsx_runtime","props","import_core","import_utils","import_jsx_runtime","defaultOverlays","props","import_jsx_runtime","import_core","import_utils","import_jsx_runtime","defaultOverlays","props","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/color-selector-body.tsx","../src/color-selector-eye-dropper.tsx","../src/use-color-selector.ts","../src/color-selector-sliders.tsx","../src/alpha-slider.tsx","../src/use-color-slider.ts","../src/hue-slider.tsx","../src/color-swatch.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { ColorSelectorEyeDropperProps } from \"./color-selector-eye-dropper\"\nimport { ColorSelectorEyeDropper } from \"./color-selector-eye-dropper\"\nimport type { ColorSelectorSlidersProps } from \"./color-selector-sliders\"\nimport { ColorSelectorSliders } from \"./color-selector-sliders\"\nimport { ColorSwatch } from \"./color-swatch\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorBodyOptions = {\n /**\n * If `true`, display the result component.\n *\n * @default true\n */\n withResult?: boolean\n /**\n * If `true` display the eye dropper component.\n *\n * @default true\n */\n withEyeDropper?: boolean\n /**\n * Ref for the eye dropper component.\n */\n eyeDropperRef?: ForwardedRef<HTMLButtonElement>\n /**\n * Props for the eye dropper component.\n */\n eyeDropperProps?: ColorSelectorEyeDropperProps\n}\n\nexport type ColorSelectorBodyProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorBodyOptions &\n Pick<\n ColorSelectorSlidersProps,\n \"hueSliderRef\" | \"hueSliderProps\" | \"alphaSliderRef\" | \"alphaSliderProps\"\n >\n\nexport const ColorSelectorBody = forwardRef<ColorSelectorBodyProps, \"div\">(\n (\n {\n className,\n withEyeDropper = true,\n withResult,\n eyeDropperRef,\n eyeDropperProps,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n const { value, eyeDropperSupported, styles } = useColorSelectorContext()\n\n const css: CSSUIObject = {\n display: \"flex\",\n w: \"100%\",\n ...styles.body,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__body\", className)}\n __css={css}\n {...rest}\n >\n <ColorSelectorSliders\n {...{\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n }}\n />\n\n {withEyeDropper && eyeDropperSupported ? (\n <ColorSelectorEyeDropper ref={eyeDropperRef} {...eyeDropperProps} />\n ) : null}\n\n {withResult ? (\n <ColorSwatch\n className=\"ui-color-selector__result\"\n color={value}\n __css={{ ...styles.result }}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n","import type { IconButtonProps } from \"@yamada-ui/button\"\nimport { IconButton } from \"@yamada-ui/button\"\nimport { forwardRef } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\nexport type ColorSelectorEyeDropperProps = IconButtonProps\n\nexport const ColorSelectorEyeDropper = forwardRef<\n ColorSelectorEyeDropperProps,\n \"button\"\n>(({ className, ...rest }, ref) => {\n const { getEyeDropperProps, readOnly, size, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n h: \"auto\",\n minW: \"auto\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.eyeDropper,\n }\n\n return (\n <IconButton\n className={cx(\"ui-color-selector__eye-dropper\", className)}\n variant=\"outline\"\n size={size}\n __css={css}\n {...getEyeDropperProps(rest, ref)}\n >\n <EyeDropperIcon className=\"ui-color-selector__eye-dropper-icon\" />\n </IconButton>\n )\n})\n\nexport const EyeDropperIcon: FC<IconProps> = ({ ...rest }) => {\n return (\n <Icon\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...rest}\n >\n <path d=\"m2 22 1-1h3l9-9\" />\n <path d=\"M3 21v-3l9-9\" />\n <path d=\"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z\" />\n </Icon>\n )\n}\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `Select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n","import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport { AlphaSlider } from \"./alpha-slider\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport { HueSlider } from \"./hue-slider\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorSlidersOptions = {\n /**\n * Ref for the hue slider component.\n */\n hueSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the hue slider component.\n */\n hueSliderProps?: Omit<HueSliderProps, \"value\" | \"defaultValue\">\n /**\n * Ref for the alpha slider component.\n */\n alphaSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the alpha slider component.\n */\n alphaSliderProps?: Omit<AlphaSliderProps, \"value\" | \"defaultValue\">\n}\n\nexport type ColorSelectorSlidersProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorSlidersOptions\n\nexport const ColorSelectorSliders = forwardRef<\n ColorSelectorSlidersProps,\n \"div\"\n>(\n (\n {\n className,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } =\n useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = {\n display: \"flex\",\n flexDirection: \"column\",\n ...styles.sliders,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__sliders\", className)}\n __css={css}\n {...rest}\n >\n <HueSlider\n size={size}\n className=\"ui-color-selector__hue-slider\"\n __css={{ ...styles.hueSlider }}\n {...getHueSliderProps(hueSliderProps, hueSliderRef)}\n />\n\n {withAlpha ? (\n <AlphaSlider\n size={size}\n className=\"ui-color-selector__alpha-slider\"\n __css={{ ...styles.alphaSlider }}\n {...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { alphaToHex, convertColor, cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n color: string,\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n {\n bgGradient: `linear(to-r, ${\n convertColor(color)(\"hex\") + alphaToHex(min)\n }, ${convertColor(color)(\"hex\") + alphaToHex(max)})`,\n },\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ntype AlphaSliderOptions = {\n /**\n * The color used for the slider.\n *\n * @default \"#ffffff\"\n */\n color?: string\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 1\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 0.01\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\nexport type AlphaSliderProps = ThemeProps<\"AlphaSlider\"> &\n Partial<Omit<UseColorSliderProps, \"color\">> &\n AlphaSliderOptions\n\n/**\n * `AlphaSlider` is a component used to allow the user to select color transparency.\n *\n * @see Docs https://yamada-ui.com/components/forms/alpha-slider\n */\nexport const AlphaSlider = forwardRef<AlphaSliderProps, \"input\">(\n (props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"AlphaSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n color = \"#ffffff\",\n min = 0,\n max = 1,\n withShadow = true,\n overlays = defaultOverlays(color, min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({\n min,\n max,\n step: 0.01,\n thumbColor: \"transparent\",\n ...computedProps,\n })\n\n const css: CSSUIObject = {\n position: \"relative\",\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n className={cx(\"ui-alpha-slider\", className)}\n __css={css}\n {...getContainerProps()}\n >\n <ui.input {...getInputProps(inputProps, ref)} />\n\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n className=\"ui-alpha-slider__overlay\"\n __css={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-alpha-slider__track\"\n __css={{\n position: \"relative\",\n w: \"100%\",\n h: \"100%\",\n ...styles.track,\n }}\n {...getTrackProps(trackProps)}\n >\n <ui.div\n className=\"ui-alpha-slider__thumb\"\n __css={{ ...styles.thumb }}\n {...getThumbProps(thumbProps)}\n />\n </ui.div>\n </ui.div>\n )\n },\n)\n","import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { UseColorSliderProps } from \"./use-color-slider\"\nimport { useColorSlider } from \"./use-color-slider\"\n\nconst defaultOverlays = (\n min: number,\n max: number,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\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\ntype HueSliderOptions = {\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n *\n * @default 0\n */\n min?: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n *\n * @default 360\n */\n max?: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * If `true`, the slider has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * Props for slider input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for slider track element.\n */\n trackProps?: HTMLUIProps<\"div\">\n /**\n * Props for slider thumb element.\n */\n thumbProps?: HTMLUIProps<\"div\">\n /**\n * The overlay used for the slider.\n */\n overlays?: HTMLUIProps<\"div\">[]\n}\n\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 type HueSliderProps = ThemeProps<\"HueSlider\"> &\n Partial<UseColorSliderProps> &\n HueSliderOptions\n\nexport const HueSlider = forwardRef<HueSliderProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"HueSlider\", props)\n const {\n className,\n inputProps,\n trackProps,\n thumbProps,\n min = 0,\n max = 360,\n withShadow = true,\n overlays = defaultOverlays(min, max, withShadow),\n __css,\n ...computedProps\n } = omitThemeProps(mergedProps)\n const { getContainerProps, getTrackProps, getInputProps, getThumbProps } =\n useColorSlider({ min, max, 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 position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...props}\n />\n ))}\n\n <ui.div\n className=\"ui-hue-slider__track\"\n __css={{ position: \"relative\", w: \"100%\", h: \"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","import {\n ui,\n forwardRef,\n omitThemeProps,\n useMultiComponentStyle,\n} from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\n\nconst defaultOverlays = (\n background: string,\n withShadow: boolean,\n): HTMLUIProps<\"div\">[] => {\n let overlays: HTMLUIProps<\"div\">[] = [\n {\n bgImage:\n \"linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)\",\n bgSize: `8px 8px`,\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n var: [\n {\n __prefix: \"ui\",\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n __prefix: \"ui\",\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n { background },\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ntype ColorSwatchOptions = {\n /**\n * The color used for the swatch element.\n *\n * @default \"#ffffff00\"\n */\n color?: string\n /**\n * The overlay used for the swatch element.\n */\n overlays?: HTMLUIProps<\"div\">[]\n /**\n * If `true`, the swatch element has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n /**\n * If `true`, the color swatch will be perfectly round. Else, it'll be slightly round.\n *\n * @default false\n */\n isRounded?: boolean\n}\n\nexport type ColorSwatchProps = Omit<HTMLUIProps<\"div\">, \"color\"> &\n ThemeProps<\"ColorSwatch\"> &\n ColorSwatchOptions\n\n/**\n * `ColorSwatch` is a component that displays color samples.\n *\n * @see Docs https://yamada-ui.com/components/data-display/color-swatch\n */\nexport const ColorSwatch = forwardRef<ColorSwatchProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"ColorSwatch\", props)\n const {\n className,\n color = \"#ffffff00\",\n withShadow = true,\n overlays = defaultOverlays(color, withShadow),\n isRounded,\n __css,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const css: CSSUIObject = {\n position: \"relative\",\n _before: {\n content: `\"\"`,\n display: \"block\",\n h: 0,\n pb: \"100%\",\n },\n \"& > *\": {\n overflow: \"hidden\",\n position: \"absolute\",\n top: \"0\",\n right: \"0\",\n bottom: \"0\",\n left: \"0\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n w: \"100%\",\n h: \"100%\",\n },\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-swatch\", className)}\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n __css={css}\n {...rest}\n >\n <ui.div {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}>\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n __css={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n ...styles.overlay,\n }}\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n {...props}\n />\n ))}\n </ui.div>\n </ui.div>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA+B;AAE/B,IAAAC,gBAAmB;;;ACDnB,oBAA2B;AAC3B,kBAA2B;AAG3B,kBAAqB;AACrB,IAAAC,gBAAmB;;;ACCnB,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBA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AAI,CAACC,QAAO,UACpB;AAAA,QAAC,gBAAG;AAAA,QAAH;AAAA,UAEC,OAAO;AAAA,YACL,UAAU;AAAA,YACV,KAAK;AAAA,YACL,MAAM;AAAA,YACN,OAAO;AAAA,YACP,QAAQ;AAAA,YACR,GAAG,OAAO;AAAA,UACZ;AAAA,UACC,GAAI,YAAY,EAAE,SAAS,yBAAyB,IAAI,CAAC;AAAA,UACzD,GAAGA;AAAA;AAAA,QAVC;AAAA,MAWP,CACD,GACH;AAAA;AAAA,EACF;AAEJ,CAAC;;;APhFK,IAAAC,sBAAA;AAzBC,IAAM,wBAAoB;AAAA,EAC/B,CACE;AAAA,IACE;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,OAAO,qBAAqB,OAAO,IAAI,wBAAwB;AAEvE,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT,GAAG;AAAA,MACH,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,gBAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,eAAW,kBAAG,2BAA2B,SAAS;AAAA,QAClD,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,gBACF;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA;AAAA,UACF;AAAA,UAEC,kBAAkB,sBACjB,6CAAC,2BAAwB,KAAK,eAAgB,GAAG,iBAAiB,IAChE;AAAA,UAEH,aACC;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,OAAO;AAAA,cACP,OAAO,EAAE,GAAG,OAAO,OAAO;AAAA;AAAA,UAC5B,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["import_core","import_utils","import_utils","import_core","import_utils","import_core","import_utils","import_form_control","import_use_controllable_state","import_utils","import_react","min","max","step","value","focusThumbOnChange","isInteractive","props","import_jsx_runtime","props","import_core","import_utils","import_jsx_runtime","defaultOverlays","props","import_jsx_runtime","import_core","import_utils","import_jsx_runtime","defaultOverlays","props","import_jsx_runtime"]}
@@ -1,14 +1,14 @@
1
1
  "use client"
2
2
  import {
3
3
  ColorSelectorBody
4
- } from "./chunk-5CQI26IR.mjs";
5
- import "./chunk-NMHU434U.mjs";
6
- import "./chunk-JFTUHZYL.mjs";
4
+ } from "./chunk-FUV4QZBE.mjs";
5
+ import "./chunk-SMXYADBA.mjs";
6
+ import "./chunk-JOX5PPY7.mjs";
7
7
  import "./chunk-K3QQKPFT.mjs";
8
8
  import "./chunk-YD5QBKEV.mjs";
9
9
  import "./chunk-R4DLOKLT.mjs";
10
10
  import "./chunk-UQWAM6TA.mjs";
11
- import "./chunk-L2ILNXB4.mjs";
11
+ import "./chunk-5QT7SRA4.mjs";
12
12
  export {
13
13
  ColorSelectorBody
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-selector-channels.tsx","../src/use-color-selector.ts"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { Input } from \"@yamada-ui/input\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useId, type ReactNode } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorChannelsOptions = {\n /**\n * Props for the chancel component.\n */\n channelProps?: Omit<ColorSelectorChannelProps, \"channelLabel\">\n}\n\nexport type ColorSelectorChannelsProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorChannelsOptions\n\nexport const ColorSelectorChannels = forwardRef<\n ColorSelectorChannelsProps,\n \"div\"\n>(({ className, channelProps, ...rest }, ref) => {\n const { withAlpha, channels, getChannelProps, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n display: \"grid\",\n gridTemplateColumns: `repeat(${withAlpha ? \"4\" : \"3\"}, 1fr)`,\n ...styles.channels,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__channels\", className)}\n __css={css}\n {...rest}\n >\n {channels.map(({ label, space, value, min, max }) => (\n <ColorSelectorChannel\n key={label}\n channelLabel={label}\n {...getChannelProps({ ...channelProps, space, value, min, max })}\n />\n ))}\n </ui.div>\n )\n})\n\ntype ColorSelectorChannelOptions = {\n channelLabel?: ReactNode\n}\n\nexport type ColorSelectorChannelProps = Omit<\n InputProps,\n \"type\" | \"pattern\" | \"min\" | \"max\" | \"value\" | \"defaultValue\"\n> &\n ColorSelectorChannelOptions\n\nexport const ColorSelectorChannel = forwardRef<\n ColorSelectorChannelProps,\n \"input\"\n>(({ className, channelLabel, ...rest }, ref) => {\n const id = useId()\n let { size, disabled, readOnly, styles } = useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = { ...styles.channel }\n\n return (\n <ui.div className={cx(\"ui-color-selector__channel\", className)}>\n {channelLabel ? (\n <ui.label\n htmlFor={id}\n style={{ cursor: disabled ? \"not-allowed\" : undefined }}\n __css={{\n display: \"block\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.channelLabel,\n }}\n >\n {channelLabel}\n </ui.label>\n ) : null}\n\n <Input ref={ref} id={id} size={size} __css={css} {...rest} />\n </ui.div>\n )\n})\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAE/B,mBAAsB;AAEtB,IAAAA,gBAAmB;AACnB,IAAAC,gBAAsC;;;ACEtC,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAiEhD,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADhEK;AArBD,IAAM,4BAAwB,wBAGnC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,EAAE,WAAW,UAAU,iBAAiB,OAAO,IACnD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,qBAAqB,UAAU,YAAY,MAAM,GAAG;AAAA,IACpD,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC,eAAG;AAAA,IAAH;AAAA,MACC;AAAA,MACA,eAAW,kBAAG,+BAA+B,SAAS;AAAA,MACtD,OAAO;AAAA,MACN,GAAG;AAAA,MAEH,mBAAS,IAAI,CAAC,EAAE,OAAO,OAAO,OAAO,KAAK,IAAI,MAC7C;AAAA,QAAC;AAAA;AAAA,UAEC,cAAc;AAAA,UACb,GAAG,gBAAgB,EAAE,GAAG,cAAc,OAAO,OAAO,KAAK,IAAI,CAAC;AAAA;AAAA,QAF1D;AAAA,MAGP,CACD;AAAA;AAAA,EACH;AAEJ,CAAC;AAYM,IAAM,2BAAuB,wBAGlC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,SAAK,qBAAM;AACjB,MAAI,EAAE,MAAM,UAAU,UAAU,OAAO,IAAI,wBAAwB;AAEnE,MAAI,SAAS;AAAQ,WAAO;AAE5B,QAAM,MAAmB,EAAE,GAAG,OAAO,QAAQ;AAE7C,SACE,6CAAC,eAAG,KAAH,EAAO,eAAW,kBAAG,8BAA8B,SAAS,GAC1D;AAAA,mBACC;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,SAAS;AAAA,QACT,OAAO,EAAE,QAAQ,WAAW,gBAAgB,OAAU;AAAA,QACtD,OAAO;AAAA,UACL,SAAS;AAAA,UACT,eAAe,WAAW,SAAS;AAAA,UACnC,GAAG,OAAO;AAAA,QACZ;AAAA,QAEC;AAAA;AAAA,IACH,IACE;AAAA,IAEJ,4CAAC,sBAAM,KAAU,IAAQ,MAAY,OAAO,KAAM,GAAG,MAAM;AAAA,KAC7D;AAEJ,CAAC;","names":["import_utils","import_react"]}
1
+ {"version":3,"sources":["../src/color-selector-channels.tsx","../src/use-color-selector.ts"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { Input } from \"@yamada-ui/input\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { useId, type ReactNode } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorChannelsOptions = {\n /**\n * Props for the chancel component.\n */\n channelProps?: Omit<ColorSelectorChannelProps, \"channelLabel\">\n}\n\nexport type ColorSelectorChannelsProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorChannelsOptions\n\nexport const ColorSelectorChannels = forwardRef<\n ColorSelectorChannelsProps,\n \"div\"\n>(({ className, channelProps, ...rest }, ref) => {\n const { withAlpha, channels, getChannelProps, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n display: \"grid\",\n gridTemplateColumns: `repeat(${withAlpha ? \"4\" : \"3\"}, 1fr)`,\n ...styles.channels,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__channels\", className)}\n __css={css}\n {...rest}\n >\n {channels.map(({ label, space, value, min, max }) => (\n <ColorSelectorChannel\n key={label}\n channelLabel={label}\n {...getChannelProps({ ...channelProps, space, value, min, max })}\n />\n ))}\n </ui.div>\n )\n})\n\ntype ColorSelectorChannelOptions = {\n channelLabel?: ReactNode\n}\n\nexport type ColorSelectorChannelProps = Omit<\n InputProps,\n \"type\" | \"pattern\" | \"min\" | \"max\" | \"value\" | \"defaultValue\"\n> &\n ColorSelectorChannelOptions\n\nexport const ColorSelectorChannel = forwardRef<\n ColorSelectorChannelProps,\n \"input\"\n>(({ className, channelLabel, ...rest }, ref) => {\n const id = useId()\n let { size, disabled, readOnly, styles } = useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = { ...styles.channel }\n\n return (\n <ui.div className={cx(\"ui-color-selector__channel\", className)}>\n {channelLabel ? (\n <ui.label\n htmlFor={id}\n style={{ cursor: disabled ? \"not-allowed\" : undefined }}\n __css={{\n display: \"block\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.channelLabel,\n }}\n >\n {channelLabel}\n </ui.label>\n ) : null}\n\n <Input ref={ref} id={id} size={size} __css={css} {...rest} />\n </ui.div>\n )\n})\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `Select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAE/B,mBAAsB;AAEtB,IAAAA,gBAAmB;AACnB,IAAAC,gBAAsC;;;ACEtC,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAiEhD,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADhEK;AArBD,IAAM,4BAAwB,wBAGnC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,EAAE,WAAW,UAAU,iBAAiB,OAAO,IACnD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,qBAAqB,UAAU,YAAY,MAAM,GAAG;AAAA,IACpD,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC,eAAG;AAAA,IAAH;AAAA,MACC;AAAA,MACA,eAAW,kBAAG,+BAA+B,SAAS;AAAA,MACtD,OAAO;AAAA,MACN,GAAG;AAAA,MAEH,mBAAS,IAAI,CAAC,EAAE,OAAO,OAAO,OAAO,KAAK,IAAI,MAC7C;AAAA,QAAC;AAAA;AAAA,UAEC,cAAc;AAAA,UACb,GAAG,gBAAgB,EAAE,GAAG,cAAc,OAAO,OAAO,KAAK,IAAI,CAAC;AAAA;AAAA,QAF1D;AAAA,MAGP,CACD;AAAA;AAAA,EACH;AAEJ,CAAC;AAYM,IAAM,2BAAuB,wBAGlC,CAAC,EAAE,WAAW,cAAc,GAAG,KAAK,GAAG,QAAQ;AAC/C,QAAM,SAAK,qBAAM;AACjB,MAAI,EAAE,MAAM,UAAU,UAAU,OAAO,IAAI,wBAAwB;AAEnE,MAAI,SAAS;AAAQ,WAAO;AAE5B,QAAM,MAAmB,EAAE,GAAG,OAAO,QAAQ;AAE7C,SACE,6CAAC,eAAG,KAAH,EAAO,eAAW,kBAAG,8BAA8B,SAAS,GAC1D;AAAA,mBACC;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,SAAS;AAAA,QACT,OAAO,EAAE,QAAQ,WAAW,gBAAgB,OAAU;AAAA,QACtD,OAAO;AAAA,UACL,SAAS;AAAA,UACT,eAAe,WAAW,SAAS;AAAA,UACnC,GAAG,OAAO;AAAA,QACZ;AAAA,QAEC;AAAA;AAAA,IACH,IACE;AAAA,IAEJ,4CAAC,sBAAM,KAAU,IAAQ,MAAY,OAAO,KAAM,GAAG,MAAM;AAAA,KAC7D;AAEJ,CAAC;","names":["import_utils","import_react"]}
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  ColorSelectorChannel,
4
4
  ColorSelectorChannels
5
- } from "./chunk-2PW2Z2XD.mjs";
6
- import "./chunk-L2ILNXB4.mjs";
5
+ } from "./chunk-YXQQHV2S.mjs";
6
+ import "./chunk-5QT7SRA4.mjs";
7
7
  export {
8
8
  ColorSelectorChannel,
9
9
  ColorSelectorChannels
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-selector-eye-dropper.tsx","../src/use-color-selector.ts"],"sourcesContent":["import type { IconButtonProps } from \"@yamada-ui/button\"\nimport { IconButton } from \"@yamada-ui/button\"\nimport { forwardRef } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\nexport type ColorSelectorEyeDropperProps = IconButtonProps\n\nexport const ColorSelectorEyeDropper = forwardRef<\n ColorSelectorEyeDropperProps,\n \"button\"\n>(({ className, ...rest }, ref) => {\n const { getEyeDropperProps, readOnly, size, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n h: \"auto\",\n minW: \"auto\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.eyeDropper,\n }\n\n return (\n <IconButton\n className={cx(\"ui-color-selector__eye-dropper\", className)}\n variant=\"outline\"\n size={size}\n __css={css}\n {...getEyeDropperProps(rest, ref)}\n >\n <EyeDropperIcon className=\"ui-color-selector__eye-dropper-icon\" />\n </IconButton>\n )\n})\n\nexport const EyeDropperIcon: FC<IconProps> = ({ ...rest }) => {\n return (\n <Icon\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...rest}\n >\n <path d=\"m2 22 1-1h3l9-9\" />\n <path d=\"M3 21v-3l9-9\" />\n <path d=\"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z\" />\n </Icon>\n )\n}\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,kBAA2B;AAG3B,kBAAqB;AACrB,IAAAA,gBAAmB;;;ACCnB,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAiEhD,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADrEG;AAtBC,IAAM,8BAA0B,wBAGrC,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AACjC,QAAM,EAAE,oBAAoB,UAAU,MAAM,OAAO,IACjD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,GAAG;AAAA,IACH,MAAM;AAAA,IACN,eAAe,WAAW,SAAS;AAAA,IACnC,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,kBAAG,kCAAkC,SAAS;AAAA,MACzD,SAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,MACN,GAAG,mBAAmB,MAAM,GAAG;AAAA,MAEhC,sDAAC,kBAAe,WAAU,uCAAsC;AAAA;AAAA,EAClE;AAEJ,CAAC;AAEM,IAAM,iBAAgC,CAAC,EAAE,GAAG,KAAK,MAAM;AAC5D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACd,GAAG;AAAA,MAEJ;AAAA,oDAAC,UAAK,GAAE,mBAAkB;AAAA,QAC1B,4CAAC,UAAK,GAAE,gBAAe;AAAA,QACvB,4CAAC,UAAK,GAAE,gGAA+F;AAAA;AAAA;AAAA,EACzG;AAEJ;","names":["import_utils"]}
1
+ {"version":3,"sources":["../src/color-selector-eye-dropper.tsx","../src/use-color-selector.ts"],"sourcesContent":["import type { IconButtonProps } from \"@yamada-ui/button\"\nimport { IconButton } from \"@yamada-ui/button\"\nimport { forwardRef } from \"@yamada-ui/core\"\nimport type { CSSUIObject } from \"@yamada-ui/core\"\nimport type { IconProps } from \"@yamada-ui/icon\"\nimport { Icon } from \"@yamada-ui/icon\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\nexport type ColorSelectorEyeDropperProps = IconButtonProps\n\nexport const ColorSelectorEyeDropper = forwardRef<\n ColorSelectorEyeDropperProps,\n \"button\"\n>(({ className, ...rest }, ref) => {\n const { getEyeDropperProps, readOnly, size, styles } =\n useColorSelectorContext()\n\n const css: CSSUIObject = {\n h: \"auto\",\n minW: \"auto\",\n pointerEvents: readOnly ? \"none\" : undefined,\n ...styles.eyeDropper,\n }\n\n return (\n <IconButton\n className={cx(\"ui-color-selector__eye-dropper\", className)}\n variant=\"outline\"\n size={size}\n __css={css}\n {...getEyeDropperProps(rest, ref)}\n >\n <EyeDropperIcon className=\"ui-color-selector__eye-dropper-icon\" />\n </IconButton>\n )\n})\n\nexport const EyeDropperIcon: FC<IconProps> = ({ ...rest }) => {\n return (\n <Icon\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...rest}\n >\n <path d=\"m2 22 1-1h3l9-9\" />\n <path d=\"M3 21v-3l9-9\" />\n <path d=\"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z\" />\n </Icon>\n )\n}\n","import type {\n CSSUIObject,\n HTMLUIProps,\n UIPropGetter,\n ThemeProps,\n RequiredUIPropGetter,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n} from \"@yamada-ui/form-control\"\nimport type { InputProps } from \"@yamada-ui/input\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport type { ColorFormat, Dict, Merge } from \"@yamada-ui/utils\"\nimport {\n calcFormat,\n convertColor,\n createContext,\n handlerAll,\n hsvTo,\n isString,\n parseToHsv,\n useCallbackRef,\n useUpdateEffect,\n omitObject,\n parseToRgba,\n parseToHsla,\n rgbaTo,\n hslaTo,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\nimport { useCallback, useMemo, useRef, useState } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport type { SaturationSliderProps } from \"./saturation-slider\"\n\ntype Space = keyof Hsla | keyof Rgba\ntype Hsla = { h: number; s: number; l: number; a: number }\ntype Rgba = { r: number; g: number; b: number; a: number }\ntype Hsva = { h: number; s: number; v: number; a: number }\ntype Channel = {\n label: string\n space: Space\n value: number\n min: number\n max: number\n}\n\nconst convertHsla = (value: string, fallback?: string): Hsla => {\n let [h, s, l, a] = parseToHsla(value, fallback) ?? [0, 0, 1, 1]\n\n if (a > 1) a = 1\n\n return { h, s, l, a }\n}\n\nconst convertRgba = (value: string, fallback?: string): Rgba => {\n let [r, g, b, a] = parseToRgba(value, fallback) ?? [255, 255, 255, 1]\n\n if (r > 255) r = 255\n if (g > 255) g = 255\n if (b > 255) b = 255\n if (a > 1) a = 1\n\n return { r, g, b, a }\n}\n\nconst convertHsva = (value: string, fallback?: string): Hsva => {\n const [h, s, v, a] = parseToHsv(value, fallback)\n\n return { h, s, v, a }\n}\n\ntype ColorSelectorContext = {\n value: string\n onChange: (value: string | Partial<Hsva>) => void\n eyeDropperSupported: boolean\n withAlpha: boolean\n isInteractive: boolean\n disabled?: boolean\n readOnly?: boolean\n channels: Channel[]\n size?: ThemeProps<\"ColorSelector\">[\"size\"]\n getHueSliderProps: UIPropGetter<\"input\", HueSliderProps, HueSliderProps>\n getAlphaSliderProps: UIPropGetter<\"input\", AlphaSliderProps, AlphaSliderProps>\n getEyeDropperProps: UIPropGetter<\"button\">\n getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n >\n getSwatchProps: UIPropGetter<\"div\", ColorSwatchProps, ColorSwatchProps>\n styles: Record<string, CSSUIObject>\n}\n\nexport const [ColorSelectorProvider, useColorSelectorContext] =\n createContext<ColorSelectorContext>({\n name: \"ColorSelectorContext\",\n errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorSelector />\"`,\n })\n\ntype UseColorSelectorOptions = {\n /**\n * The base `id` to use for the color selector.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the color selector.\n */\n value?: string\n /**\n * The initial value of the color selector.\n */\n defaultValue?: string\n /**\n * The fallback value returned when color determination fails.\n */\n fallbackValue?: string\n /**\n * Function called whenever the color selector value changes.\n */\n onChange?: (value: string) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: string) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: string) => void\n /**\n * Color format. For example, `hex`, `rgba`, etc.\n *\n * @default \"hexa\"\n */\n format?: ColorFormat\n /**\n * Function called whenever the color swatch click.\n */\n onSwatchClick?: (value: string) => void\n}\n\nexport type UseColorSelectorBaseProps = UseColorSelectorOptions &\n FormControlOptions\n\nexport type UseColorSelectorProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> &\n UseColorSelectorBaseProps\n\nexport const useColorSelector = ({\n isInvalid,\n ...props\n}: UseColorSelectorProps) => {\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n fallbackValue,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n format,\n required,\n disabled,\n readOnly,\n onSwatchClick,\n ...rest\n } = useFormControlProps({ isInvalid, ...props })\n\n const onChangeStartRef = useCallbackRef(onChangeStartProp)\n const onChangeEndRef = useCallbackRef(onChangeEndProp)\n const { supported: eyeDropperSupported, onOpen } = useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? fallbackValue,\n onChange: onChangeProp,\n })\n const resolvedValue = value ?? \"#ffffff\"\n const timeoutId = useRef<any>(undefined)\n const formatRef = useRef<ColorFormat>(format ?? calcFormat(resolvedValue))\n const isDraggingRef = useRef<boolean>(false)\n const [parsedValue, setParsedValue] = useState<Hsva>(\n convertHsva(resolvedValue, fallbackValue),\n )\n const { h, s, v, a } = parsedValue\n const withAlpha = formatRef.current.endsWith(\"a\")\n const isInteractive = !(disabled || readOnly)\n\n const channels: Channel[] = useMemo(() => {\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = convertHsla(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"H\", space: \"h\", value: Math.round(h), min: 0, max: 360 },\n {\n label: \"S(%)\",\n space: \"s\",\n value: Math.round(s * 100),\n min: 0,\n max: 100,\n },\n {\n label: \"L(%)\",\n space: \"l\",\n value: Math.round(l * 100),\n min: 0,\n max: 100,\n },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n } else {\n const { r, g, b, a } = convertRgba(resolvedValue, fallbackValue)\n\n let channels: Channel[] = [\n { label: \"R\", space: \"r\", value: Math.round(r), min: 0, max: 255 },\n { label: \"G\", space: \"g\", value: Math.round(g), min: 0, max: 255 },\n { label: \"B\", space: \"b\", value: Math.round(b), min: 0, max: 255 },\n ]\n\n if (withAlpha) {\n channels = [\n ...channels,\n {\n label: \"A(%)\",\n space: \"a\",\n value: Math.round(a * 100),\n min: 0,\n max: 100,\n },\n ]\n }\n\n return channels\n }\n }, [resolvedValue, withAlpha, fallbackValue])\n\n const onChange = useCallback(\n (value: string | Partial<Hsva>) => {\n if (isString(value)) {\n setParsedValue(convertHsva(value, fallbackValue))\n } else {\n setParsedValue((prev) => ({ ...prev, ...value }))\n }\n },\n [fallbackValue],\n )\n\n const onChangeStart = useCallback(\n (value: Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n isDraggingRef.current = true\n\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) onChangeStartRef(nextValue)\n },\n [formatRef, onChangeStartRef, fallbackValue, parsedValue],\n )\n\n const onChangeEnd = useCallback(\n (value: string | Partial<Hsva>) => {\n window.clearTimeout(timeoutId.current)\n\n timeoutId.current = window.setTimeout(() => {\n isDraggingRef.current = false\n }, 200)\n\n let nextValue: string | undefined\n\n if (isString(value)) {\n nextValue = convertColor(value, fallbackValue)(formatRef.current)\n } else {\n const { h, s, v, a } = { ...parsedValue, ...value }\n\n nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n }\n\n if (nextValue) onChangeEndRef(nextValue)\n },\n [formatRef, onChangeEndRef, fallbackValue, parsedValue],\n )\n\n const onChannelChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>, space: Space) => {\n let n = Math.floor(parseFloat(ev.target.value))\n\n if (isNaN(n)) n = 0\n\n if ([\"s\", \"l\", \"a\"].includes(space)) n = n / 100\n\n let nextValue: string | undefined\n\n if (resolvedValue.startsWith(\"hsl\")) {\n const { h, s, l, a } = Object.assign(\n convertHsla(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = hslaTo([h, s, l, a], fallbackValue)(formatRef.current)\n } else {\n const { r, g, b, a } = Object.assign(\n convertRgba(resolvedValue, fallbackValue),\n { [space]: n },\n )\n\n nextValue = rgbaTo([r, g, b, a], fallbackValue)(formatRef.current)\n }\n\n if (!nextValue) return\n\n onChange(nextValue)\n onChangeEnd(nextValue)\n },\n [resolvedValue, onChange, onChangeEnd, formatRef, fallbackValue],\n )\n\n const onEyeDropperClick = useCallback(async () => {\n try {\n const { sRGBHex } = (await onOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onChange(sRGBHex)\n onChangeEnd(sRGBHex)\n } catch {}\n }, [onOpen, onChange, onChangeEnd])\n\n useUpdateEffect(() => {\n const nextValue = hsvTo([h, s, v, a], fallbackValue)(formatRef.current)\n\n if (nextValue) setValue(nextValue)\n }, [h, s, v, a])\n\n useUpdateEffect(() => {\n if (isDraggingRef.current) return\n\n if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue))\n }, [valueProp])\n\n useUpdateEffect(() => {\n if (!format || !value) return\n\n formatRef.current = format\n\n const nextValue = convertColor(value, fallbackValue)(format)\n\n if (nextValue) setValue(nextValue)\n }, [format])\n\n const getContainerProps: UIPropGetter = (props = {}, ref = null) => ({\n ...props,\n ref,\n ...omitObject(rest, [\"aria-readonly\"]),\n })\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value: resolvedValue,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, resolvedValue],\n )\n\n const getSaturationSliderProps: UIPropGetter<\n \"input\",\n SaturationSliderProps,\n SaturationSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: [h, s, v],\n onChange: handlerAll(props.onChange, ([, s, v]) => onChange({ s, v })),\n onChangeStart: handlerAll(props.onChangeStart, ([, s, v]) =>\n onChangeStart({ s, v }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, ([, s, v]) =>\n onChangeEnd({ s, v }),\n ),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n s,\n v,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getHueSliderProps: UIPropGetter<\n \"input\",\n HueSliderProps,\n HueSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: h,\n onChange: handlerAll(props.onChange, (h) => onChange({ h })),\n onChangeStart: handlerAll(props.onChangeStart, (h) =>\n onChangeStart({ h }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (h) => onChangeEnd({ h })),\n }),\n [\n required,\n disabled,\n readOnly,\n isInvalid,\n h,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getAlphaSliderProps: UIPropGetter<\n \"input\",\n AlphaSliderProps,\n AlphaSliderProps\n > = useCallback(\n (props = {}, ref = null) => ({\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n value: a,\n color: hsvTo([h, s, v, a], fallbackValue)(formatRef.current),\n onChange: handlerAll(props.onChange, (a) => onChange({ a })),\n onChangeStart: handlerAll(props.onChangeStart, (a) =>\n onChangeStart({ a }),\n ),\n onChangeEnd: handlerAll(props.onChangeEnd, (a) => onChangeEnd({ a })),\n }),\n [\n fallbackValue,\n required,\n disabled,\n readOnly,\n isInvalid,\n formatRef,\n h,\n s,\n v,\n a,\n onChange,\n onChangeStart,\n onChangeEnd,\n ],\n )\n\n const getChannelProps: RequiredUIPropGetter<\n \"input\",\n Merge<InputProps, { space: Space }>,\n InputProps\n > = useCallback(\n ({ space, ...props }, ref = null) => {\n return {\n required,\n disabled,\n readOnly,\n isInvalid,\n ...props,\n ref,\n type: \"number\",\n step: 1,\n onChange: handlerAll(props.onChange, (ev) =>\n onChannelChange(ev, space),\n ),\n } as Dict\n },\n [required, disabled, readOnly, isInvalid, onChannelChange],\n )\n\n const getEyeDropperProps: UIPropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n disabled,\n \"aria-label\": \"Pick a color\",\n ...props,\n ref,\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick],\n )\n\n const getSwatchProps: UIPropGetter<\n \"div\",\n ColorSwatchProps,\n ColorSwatchProps\n > = useCallback(\n ({ color, ...props } = {}, ref = null) => ({\n \"aria-label\": `Select ${color} as the color`,\n disabled,\n readOnly,\n ...props,\n ref,\n color,\n onClick: handlerAll(props.onClick, () => {\n if (!color) return\n\n onSwatchClick?.(color)\n onChange(color)\n onChangeEnd(color)\n }),\n }),\n [disabled, readOnly, onSwatchClick, onChange, onChangeEnd],\n )\n\n return {\n value: resolvedValue,\n onChange,\n eyeDropperSupported,\n withAlpha,\n isInteractive,\n disabled,\n readOnly,\n channels,\n getContainerProps,\n getInputProps,\n getSaturationSliderProps,\n getHueSliderProps,\n getAlphaSliderProps,\n getEyeDropperProps,\n getChannelProps,\n getSwatchProps,\n }\n}\n\nexport type UseColorSelectorReturn = ReturnType<typeof useColorSelector>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,kBAA2B;AAG3B,kBAAqB;AACrB,IAAAA,gBAAmB;;;ACCnB,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAiEhD,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;;;ADrEG;AAtBC,IAAM,8BAA0B,wBAGrC,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,QAAQ;AACjC,QAAM,EAAE,oBAAoB,UAAU,MAAM,OAAO,IACjD,wBAAwB;AAE1B,QAAM,MAAmB;AAAA,IACvB,GAAG;AAAA,IACH,MAAM;AAAA,IACN,eAAe,WAAW,SAAS;AAAA,IACnC,GAAG,OAAO;AAAA,EACZ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,kBAAG,kCAAkC,SAAS;AAAA,MACzD,SAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,MACN,GAAG,mBAAmB,MAAM,GAAG;AAAA,MAEhC,sDAAC,kBAAe,WAAU,uCAAsC;AAAA;AAAA,EAClE;AAEJ,CAAC;AAEM,IAAM,iBAAgC,CAAC,EAAE,GAAG,KAAK,MAAM;AAC5D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACd,GAAG;AAAA,MAEJ;AAAA,oDAAC,UAAK,GAAE,mBAAkB;AAAA,QAC1B,4CAAC,UAAK,GAAE,gBAAe;AAAA,QACvB,4CAAC,UAAK,GAAE,gGAA+F;AAAA;AAAA;AAAA,EACzG;AAEJ;","names":["import_utils"]}
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  ColorSelectorEyeDropper,
4
4
  EyeDropperIcon
5
- } from "./chunk-NMHU434U.mjs";
6
- import "./chunk-L2ILNXB4.mjs";
5
+ } from "./chunk-SMXYADBA.mjs";
6
+ import "./chunk-5QT7SRA4.mjs";
7
7
  export {
8
8
  ColorSelectorEyeDropper,
9
9
  EyeDropperIcon