@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
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
1
  "use client"
2
2
  import {
3
3
  ColorPicker
4
- } from "./chunk-KCV32DAB.mjs";
5
- import "./chunk-CR3JRFXA.mjs";
4
+ } from "./chunk-SDO53ZU7.mjs";
5
+ import "./chunk-SBN7FEOE.mjs";
6
6
  import {
7
7
  ColorSelector
8
- } from "./chunk-ZUPKUHBV.mjs";
8
+ } from "./chunk-C4ZOHCKU.mjs";
9
9
  import {
10
10
  SaturationSlider
11
11
  } from "./chunk-RR6V37S5.mjs";
12
12
  import "./chunk-KKQ3MOXJ.mjs";
13
- import "./chunk-5CQI26IR.mjs";
14
- import "./chunk-2PW2Z2XD.mjs";
15
- import "./chunk-NMHU434U.mjs";
16
- import "./chunk-JFTUHZYL.mjs";
13
+ import "./chunk-FUV4QZBE.mjs";
14
+ import "./chunk-YXQQHV2S.mjs";
15
+ import "./chunk-SMXYADBA.mjs";
16
+ import "./chunk-JOX5PPY7.mjs";
17
17
  import {
18
18
  HueSlider
19
19
  } from "./chunk-K3QQKPFT.mjs";
@@ -21,11 +21,11 @@ import {
21
21
  AlphaSlider
22
22
  } from "./chunk-YD5QBKEV.mjs";
23
23
  import "./chunk-R4DLOKLT.mjs";
24
- import "./chunk-NGSPXJBL.mjs";
24
+ import "./chunk-Y6662BW7.mjs";
25
25
  import {
26
26
  ColorSwatch
27
27
  } from "./chunk-UQWAM6TA.mjs";
28
- import "./chunk-L2ILNXB4.mjs";
28
+ import "./chunk-5QT7SRA4.mjs";
29
29
  export {
30
30
  AlphaSlider,
31
31
  ColorPicker,
@@ -74,9 +74,9 @@ var useColorPicker = ({
74
74
  }) => {
75
75
  var _a;
76
76
  rest = (0, import_form_control.useFormControlProps)(rest);
77
- const formControlProps = (0, import_utils.pickObject)(
77
+ const { "aria-readonly": _ariaReadonly, ...formControlProps } = (0, import_utils.pickObject)(
78
78
  rest,
79
- (0, import_form_control.getFormControlProperties)({ omit: ["aria-readonly"] })
79
+ import_form_control.formControlProperties
80
80
  );
81
81
  const { disabled, readOnly } = formControlProps;
82
82
  const [containerProps, inputProps] = (0, import_utils.splitObject)(
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import { layoutStyleProperties } from \"@yamada-ui/core\"\nimport type {\n UIPropGetter,\n CSSUIObject,\n ThemeProps,\n HTMLUIProps,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { popoverProperties, type PopoverProps } from \"@yamada-ui/popover\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport { useOutsideClick } from \"@yamada-ui/use-outside-click\"\nimport type { ColorFormat, Dict } from \"@yamada-ui/utils\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n pickObject,\n splitObject,\n omitObject,\n getEventRelatedTarget,\n isContains,\n convertColor,\n calcFormat,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ntype ColorPickerContext = { value: string; styles: Record<string, CSSUIObject> }\n\nexport const [ColorPickerProvider, useColorPickerContext] =\n createContext<ColorPickerContext>({\n name: \"ColorPickerContext\",\n errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorPicker />\"`,\n })\n\ntype UseColorPickerOptions = {\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport type UseColorPickerProps = Omit<\n HTMLUIProps<\"input\">,\n \"size\" | \"offset\" | \"value\" | \"defaultValue\" | \"onChange\" | \"children\"\n> &\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\"> &\n Omit<\n PopoverProps,\n | \"initialFocusRef\"\n | \"closeOnButton\"\n | \"trigger\"\n | \"autoFocus\"\n | \"restoreFocus\"\n | \"openDelay\"\n | \"closeDelay\"\n | \"children\"\n > &\n Pick<\n ColorSelectorProps,\n | \"withPicker\"\n | \"withChannel\"\n | \"swatchesLabel\"\n | \"swatches\"\n | \"swatchesColumns\"\n > &\n UseColorPickerOptions\n\nexport const useColorPicker = ({\n value: valueProp,\n defaultValue,\n fallbackValue,\n defaultColor,\n onChange: onChangeProp,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n formatInput = (value) => value,\n closeOnBlur = true,\n closeOnEsc = true,\n placement = \"bottom-start\",\n duration = 0.2,\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n allowInput = true,\n closeOnSelectSwatch,\n format,\n swatchesLabel,\n swatches,\n swatchesColumns,\n withPicker,\n withChannel,\n withResult = false,\n withColorSelectorEyeDropper = false,\n colorSelectorVariant,\n colorSelectorSize,\n colorSelectorColorScheme,\n ...rest\n}: UseColorPickerProps) => {\n rest = useFormControlProps(rest)\n\n const formControlProps = pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n )\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject<Dict, string>(\n omitObject(rest, [...popoverProperties]),\n layoutStyleProperties,\n )\n\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\n onChange: onChangeProp,\n })\n const formatRef = useRef<ColorFormat>(\n format ?? calcFormat(value ?? defaultColor ?? \"\"),\n )\n const isInputFocused = useRef<boolean>(false)\n const [inputValue, setInputValue] = useState<string>(value ?? \"\")\n const {\n isOpen,\n onOpen: onInternalOpen,\n onClose: onInternalClose,\n } = useDisclosure({\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n })\n const isColorSelectorFull = colorSelectorSize === \"full\"\n\n const onOpen = useCallback(() => {\n if (disabled || readOnly) return\n\n onInternalOpen()\n }, [onInternalOpen, disabled, readOnly])\n\n const onClose = useCallback(() => {\n if (!isOpen) return\n\n const next = convertColor(value, fallbackValue)(formatRef.current)\n\n setValue((prev) => (!next || prev === next ? prev : next))\n setInputValue(formatInput(next ?? \"\"))\n\n onInternalClose()\n }, [\n formatRef,\n isOpen,\n setValue,\n onInternalClose,\n value,\n formatInput,\n setInputValue,\n fallbackValue,\n ])\n\n const onContainerClick = useCallback(() => {\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputFocus = useCallback(() => {\n isInputFocused.current = true\n\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputBlur = useCallback(() => {\n isInputFocused.current = false\n }, [])\n\n const onContainerBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n\n if (isContains(containerRef.current, relatedTarget)) return\n\n if (!closeOnBlur) return\n\n if (isOpen) onClose()\n },\n [closeOnBlur, isOpen, onClose],\n )\n\n const onInputKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === \" \") ev.key = ev.code\n\n if (disabled || readOnly) return\n\n const actions: Record<string, Function | undefined> = {\n Space: !isOpen ? onOpen : undefined,\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n action()\n },\n [disabled, readOnly, isOpen, onOpen, closeOnEsc, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const value = ev.target.value\n\n setInputValue(formatInput(value))\n setValue(value)\n },\n [setInputValue, formatInput, setValue],\n )\n\n const onColorSelectorChange = useCallback(\n (value: string) => {\n setValue(value)\n\n setTimeout(() => {\n if (!isInputFocused.current) setInputValue(formatInput(value))\n })\n },\n [setValue, formatInput],\n )\n\n const onEyeDropperClick = useCallback(\n async (ev: MouseEvent<HTMLButtonElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n try {\n const { sRGBHex } = (await onEyeDropperOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onColorSelectorChange(sRGBHex)\n onChangeEnd?.(sRGBHex)\n } catch {}\n },\n [onEyeDropperOpen, onColorSelectorChange, onChangeEnd],\n )\n\n useOutsideClick({\n ref: containerRef,\n handler: onClose,\n enabled: isOpen && closeOnBlur,\n })\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) return\n\n setInputValue(formatInput(nextValue))\n setValue(nextValue)\n }, [format])\n\n useUpdateEffect(() => {\n if (isInputFocused.current || !valueProp) return\n\n setInputValue(formatInput(valueProp))\n }, [valueProp])\n\n const getPopoverProps = useCallback(\n (props?: PopoverProps): PopoverProps => ({\n matchWidth: isColorSelectorFull,\n ...rest,\n ...props,\n isOpen,\n onOpen,\n onClose,\n placement,\n duration,\n trigger: \"never\",\n closeOnButton: false,\n }),\n [isColorSelectorFull, duration, onClose, onOpen, placement, rest, isOpen],\n )\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onClick: handlerAll(props.onClick, rest.onClick, onContainerClick),\n onBlur: handlerAll(props.onBlur, rest.onBlur, onContainerBlur),\n }),\n [containerProps, formControlProps, onContainerBlur, onContainerClick, rest],\n )\n\n const getFieldProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(fieldRef, ref),\n tabIndex: !allowInput ? -1 : 0,\n ...inputProps,\n ...props,\n style: {\n ...props.style,\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n },\n value: inputValue,\n \"data-active\": dataAttr(isOpen),\n \"aria-expanded\": dataAttr(isOpen),\n onFocus: handlerAll(props.onFocus, rest.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onInputKeyDown),\n onChange: handlerAll(props.onChange, onInputChange),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n }),\n [\n allowInput,\n inputProps,\n inputValue,\n isOpen,\n rest,\n onInputFocus,\n onInputKeyDown,\n onInputChange,\n onInputBlur,\n ],\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 style: { ...props.style, pointerEvents: readOnly ? \"none\" : undefined },\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick, readOnly],\n )\n\n const getSelectorProps = useCallback(\n (props?: ColorSelectorProps): ColorSelectorProps => ({\n ...formControlProps,\n ...props,\n value,\n defaultValue: defaultColor,\n fallbackValue,\n onChange: onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\n format: formatRef.current,\n withPicker,\n withChannel,\n withResult,\n withEyeDropper: withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n variant: colorSelectorVariant,\n size: colorSelectorSize,\n colorScheme: colorSelectorColorScheme,\n }),\n [\n formControlProps,\n value,\n fallbackValue,\n defaultColor,\n onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n onClose,\n closeOnSelectSwatch,\n formatRef,\n withPicker,\n withChannel,\n withResult,\n withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n ],\n )\n\n return {\n value,\n eyeDropperSupported,\n allowInput,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n getSelectorProps,\n getEyeDropperProps,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsC;AAOtC,0BAGO;AACP,qBAAqD;AACrD,oCAAqC;AACrC,4BAA8B;AAC9B,6BAA8B;AAC9B,+BAAgC;AAEhC,mBAaO;AAEP,mBAA8C;AAQvC,IAAM,CAAC,qBAAqB,qBAAqB,QACtD,4BAAkC;AAAA,EAChC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA6EI,IAAM,iBAAiB,CAAC;AAAA,EAC7B,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC,UAAU;AAAA,EACzB,cAAc;AAAA,EACd,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,8BAA8B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA2B;AAzJ3B;AA0JE,aAAO,yCAAoB,IAAI;AAE/B,QAAM,uBAAmB;AAAA,IACvB;AAAA,QACA,8CAAyB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;AAAA,EACtD;AACA,QAAM,EAAE,UAAU,SAAS,IAAI;AAC/B,QAAM,CAAC,gBAAgB,UAAU,QAAI;AAAA,QACnC,yBAAW,MAAM,CAAC,GAAG,gCAAiB,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,QAAM,mBAAe,qBAAuB,IAAI;AAChD,QAAM,eAAW,qBAAyB,IAAI;AAE9C,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nD,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,mBAAe;AAAA,QACb;AAAA,QACA,sBAAsB,UAAU;AAAA,MAClC;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["value","_a"]}
1
+ {"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import { layoutStyleProperties } from \"@yamada-ui/core\"\nimport type {\n UIPropGetter,\n CSSUIObject,\n ThemeProps,\n HTMLUIProps,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport { popoverProperties, type PopoverProps } from \"@yamada-ui/popover\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport { useOutsideClick } from \"@yamada-ui/use-outside-click\"\nimport type { ColorFormat, Dict } from \"@yamada-ui/utils\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n pickObject,\n splitObject,\n omitObject,\n getEventRelatedTarget,\n isContains,\n convertColor,\n calcFormat,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ntype ColorPickerContext = { value: string; styles: Record<string, CSSUIObject> }\n\nexport const [ColorPickerProvider, useColorPickerContext] =\n createContext<ColorPickerContext>({\n name: \"ColorPickerContext\",\n errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorPicker />\"`,\n })\n\ntype UseColorPickerOptions = {\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport type UseColorPickerProps = Omit<\n HTMLUIProps<\"input\">,\n \"size\" | \"offset\" | \"value\" | \"defaultValue\" | \"onChange\" | \"children\"\n> &\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\"> &\n Omit<\n PopoverProps,\n | \"initialFocusRef\"\n | \"closeOnButton\"\n | \"trigger\"\n | \"autoFocus\"\n | \"restoreFocus\"\n | \"openDelay\"\n | \"closeDelay\"\n | \"children\"\n > &\n Pick<\n ColorSelectorProps,\n | \"withPicker\"\n | \"withChannel\"\n | \"swatchesLabel\"\n | \"swatches\"\n | \"swatchesColumns\"\n > &\n UseColorPickerOptions\n\nexport const useColorPicker = ({\n value: valueProp,\n defaultValue,\n fallbackValue,\n defaultColor,\n onChange: onChangeProp,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n formatInput = (value) => value,\n closeOnBlur = true,\n closeOnEsc = true,\n placement = \"bottom-start\",\n duration = 0.2,\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n allowInput = true,\n closeOnSelectSwatch,\n format,\n swatchesLabel,\n swatches,\n swatchesColumns,\n withPicker,\n withChannel,\n withResult = false,\n withColorSelectorEyeDropper = false,\n colorSelectorVariant,\n colorSelectorSize,\n colorSelectorColorScheme,\n ...rest\n}: UseColorPickerProps) => {\n rest = useFormControlProps(rest)\n\n const { \"aria-readonly\": _ariaReadonly, ...formControlProps } = pickObject(\n rest,\n formControlProperties,\n )\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject<Dict, string>(\n omitObject(rest, [...popoverProperties]),\n layoutStyleProperties,\n )\n\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\n onChange: onChangeProp,\n })\n const formatRef = useRef<ColorFormat>(\n format ?? calcFormat(value ?? defaultColor ?? \"\"),\n )\n const isInputFocused = useRef<boolean>(false)\n const [inputValue, setInputValue] = useState<string>(value ?? \"\")\n const {\n isOpen,\n onOpen: onInternalOpen,\n onClose: onInternalClose,\n } = useDisclosure({\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n })\n const isColorSelectorFull = colorSelectorSize === \"full\"\n\n const onOpen = useCallback(() => {\n if (disabled || readOnly) return\n\n onInternalOpen()\n }, [onInternalOpen, disabled, readOnly])\n\n const onClose = useCallback(() => {\n if (!isOpen) return\n\n const next = convertColor(value, fallbackValue)(formatRef.current)\n\n setValue((prev) => (!next || prev === next ? prev : next))\n setInputValue(formatInput(next ?? \"\"))\n\n onInternalClose()\n }, [\n formatRef,\n isOpen,\n setValue,\n onInternalClose,\n value,\n formatInput,\n setInputValue,\n fallbackValue,\n ])\n\n const onContainerClick = useCallback(() => {\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputFocus = useCallback(() => {\n isInputFocused.current = true\n\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputBlur = useCallback(() => {\n isInputFocused.current = false\n }, [])\n\n const onContainerBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n\n if (isContains(containerRef.current, relatedTarget)) return\n\n if (!closeOnBlur) return\n\n if (isOpen) onClose()\n },\n [closeOnBlur, isOpen, onClose],\n )\n\n const onInputKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === \" \") ev.key = ev.code\n\n if (disabled || readOnly) return\n\n const actions: Record<string, Function | undefined> = {\n Space: !isOpen ? onOpen : undefined,\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n action()\n },\n [disabled, readOnly, isOpen, onOpen, closeOnEsc, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const value = ev.target.value\n\n setInputValue(formatInput(value))\n setValue(value)\n },\n [setInputValue, formatInput, setValue],\n )\n\n const onColorSelectorChange = useCallback(\n (value: string) => {\n setValue(value)\n\n setTimeout(() => {\n if (!isInputFocused.current) setInputValue(formatInput(value))\n })\n },\n [setValue, formatInput],\n )\n\n const onEyeDropperClick = useCallback(\n async (ev: MouseEvent<HTMLButtonElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n try {\n const { sRGBHex } = (await onEyeDropperOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onColorSelectorChange(sRGBHex)\n onChangeEnd?.(sRGBHex)\n } catch {}\n },\n [onEyeDropperOpen, onColorSelectorChange, onChangeEnd],\n )\n\n useOutsideClick({\n ref: containerRef,\n handler: onClose,\n enabled: isOpen && closeOnBlur,\n })\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) return\n\n setInputValue(formatInput(nextValue))\n setValue(nextValue)\n }, [format])\n\n useUpdateEffect(() => {\n if (isInputFocused.current || !valueProp) return\n\n setInputValue(formatInput(valueProp))\n }, [valueProp])\n\n const getPopoverProps = useCallback(\n (props?: PopoverProps): PopoverProps => ({\n matchWidth: isColorSelectorFull,\n ...rest,\n ...props,\n isOpen,\n onOpen,\n onClose,\n placement,\n duration,\n trigger: \"never\",\n closeOnButton: false,\n }),\n [isColorSelectorFull, duration, onClose, onOpen, placement, rest, isOpen],\n )\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onClick: handlerAll(props.onClick, rest.onClick, onContainerClick),\n onBlur: handlerAll(props.onBlur, rest.onBlur, onContainerBlur),\n }),\n [containerProps, formControlProps, onContainerBlur, onContainerClick, rest],\n )\n\n const getFieldProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(fieldRef, ref),\n tabIndex: !allowInput ? -1 : 0,\n ...inputProps,\n ...props,\n style: {\n ...props.style,\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n },\n value: inputValue,\n \"data-active\": dataAttr(isOpen),\n \"aria-expanded\": dataAttr(isOpen),\n onFocus: handlerAll(props.onFocus, rest.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onInputKeyDown),\n onChange: handlerAll(props.onChange, onInputChange),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n }),\n [\n allowInput,\n inputProps,\n inputValue,\n isOpen,\n rest,\n onInputFocus,\n onInputKeyDown,\n onInputChange,\n onInputBlur,\n ],\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 style: { ...props.style, pointerEvents: readOnly ? \"none\" : undefined },\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick, readOnly],\n )\n\n const getSelectorProps = useCallback(\n (props?: ColorSelectorProps): ColorSelectorProps => ({\n ...formControlProps,\n ...props,\n value,\n defaultValue: defaultColor,\n fallbackValue,\n onChange: onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\n format: formatRef.current,\n withPicker,\n withChannel,\n withResult,\n withEyeDropper: withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n variant: colorSelectorVariant,\n size: colorSelectorSize,\n colorScheme: colorSelectorColorScheme,\n }),\n [\n formControlProps,\n value,\n fallbackValue,\n defaultColor,\n onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n onClose,\n closeOnSelectSwatch,\n formatRef,\n withPicker,\n withChannel,\n withResult,\n withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n ],\n )\n\n return {\n value,\n eyeDropperSupported,\n allowInput,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n getSelectorProps,\n getEyeDropperProps,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<type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AAA,MACV;AAAA,MACA;AAAA,MACA,mBAAe;AAAA,QACb;AAAA,QACA,sBAAsB,UAAU;AAAA,MAClC;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["value","_a"]}
@@ -3,7 +3,7 @@ import {
3
3
  ColorPickerProvider,
4
4
  useColorPicker,
5
5
  useColorPickerContext
6
- } from "./chunk-CR3JRFXA.mjs";
6
+ } from "./chunk-SBN7FEOE.mjs";
7
7
  export {
8
8
  ColorPickerProvider,
9
9
  useColorPicker,
@@ -392,7 +392,7 @@ var useColorSelector = ({
392
392
  );
393
393
  const getSwatchProps = (0, import_react.useCallback)(
394
394
  ({ color, ...props2 } = {}, ref = null) => ({
395
- "aria-label": `select ${color} as the color`,
395
+ "aria-label": `Select ${color} as the color`,
396
396
  disabled,
397
397
  readOnly,
398
398
  ...props2,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-color-selector.ts"],"sourcesContent":["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;AAOA,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAkBvD,IAAM,cAAc,CAAC,OAAe,aAA4B;AApDhE;AAqDE,MAAI,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,mCAAY,OAAO,QAAQ,MAA3B,YAAgC,CAAC,GAAG,GAAG,GAAG,CAAC;AAE9D,MAAI,IAAI;AAAG,QAAI;AAEf,SAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AACtB;AAEA,IAAM,cAAc,CAAC,OAAe,aAA4B;AA5DhE;AA6DE,MAAI,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,mCAAY,OAAO,QAAQ,MAA3B,YAAgC,CAAC,KAAK,KAAK,KAAK,CAAC;AAEpE,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAG,QAAI;AAEf,SAAO,EAAE,GAA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BAAiB;AAAA,IACtD;AAAA,IACA,CAAC,UAAU,iBAAiB;AAAA,EAC9B;AAEA,QAAM,qBAIF;AAAA,IACF,CAAC,EAAE,OAAO,GAAGA,OAAM,IAAI,CAAC,GAAG,MAAM,UAAU;AAAA,MACzC,cAAc,UAAU,KAAK;AAAA,MAC7B;AAAA,MACA;AAAA,MACA,GAAGA;AAAA,MACH;AAAA,MACA;AAAA,MACA,aAAS,yBAAWA,OAAM,SAAS,MAAM;AACvC,YAAI,CAAC;AAAO;AAEZ,uDAAgB;AAChB,iBAAS,KAAK;AACd,oBAAY,KAAK;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU,eAAe,UAAU,WAAW;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["h","s","a","channels","value","v","props"]}
1
+ {"version":3,"sources":["../src/use-color-selector.ts"],"sourcesContent":["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;AAOA,0BAIO;AAEP,oCAAqC;AACrC,6BAA8B;AAE9B,mBAgBO;AAEP,mBAAuD;AAkBvD,IAAM,cAAc,CAAC,OAAe,aAA4B;AApDhE;AAqDE,MAAI,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,mCAAY,OAAO,QAAQ,MAA3B,YAAgC,CAAC,GAAG,GAAG,GAAG,CAAC;AAE9D,MAAI,IAAI;AAAG,QAAI;AAEf,SAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AACtB;AAEA,IAAM,cAAc,CAAC,OAAe,aAA4B;AA5DhE;AA6DE,MAAI,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,mCAAY,OAAO,QAAQ,MAA3B,YAAgC,CAAC,KAAK,KAAK,KAAK,CAAC;AAEpE,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAK,QAAI;AACjB,MAAI,IAAI;AAAG,QAAI;AAEf,SAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AACtB;AAEA,IAAM,cAAc,CAAC,OAAe,aAA4B;AAC9D,QAAM,CAAC,GAAG,GAAG,GAAG,CAAC,QAAI,yBAAW,OAAO,QAAQ;AAE/C,SAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AACtB;AAwBO,IAAM,CAAC,uBAAuB,uBAAuB,QAC1D,4BAAoC;AAAA,EAClC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAyDI,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,MAA6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K;AACd,oBAAY,KAAK;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU,eAAe,UAAU,WAAW;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["h","s","a","channels","value","v","props"]}
@@ -3,7 +3,7 @@ import {
3
3
  ColorSelectorProvider,
4
4
  useColorSelector,
5
5
  useColorSelectorContext
6
- } from "./chunk-L2ILNXB4.mjs";
6
+ } from "./chunk-5QT7SRA4.mjs";
7
7
  export {
8
8
  ColorSelectorProvider,
9
9
  useColorSelector,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/color-picker",
3
- "version": "2.0.0-next-20240513035416",
3
+ "version": "2.0.0-next-20240516121223",
4
4
  "description": "Yamada UI color picker component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -38,17 +38,17 @@
38
38
  "dependencies": {
39
39
  "@yamada-ui/button": "1.0.28",
40
40
  "@yamada-ui/core": "1.6.7",
41
- "@yamada-ui/form-control": "1.0.28",
41
+ "@yamada-ui/form-control": "1.1.0",
42
42
  "@yamada-ui/use-disclosure": "1.0.13",
43
43
  "@yamada-ui/icon": "1.0.25",
44
- "@yamada-ui/input": "1.0.29-next-20240513035416",
44
+ "@yamada-ui/input": "1.0.30-next-20240516121223",
45
45
  "@yamada-ui/popover": "1.1.2",
46
46
  "@yamada-ui/portal": "1.0.14",
47
47
  "@yamada-ui/use-controllable-state": "1.0.13",
48
48
  "@yamada-ui/use-eye-dropper": "^1.0.10",
49
49
  "@yamada-ui/use-latest-ref": "^1.0.1",
50
50
  "@yamada-ui/use-outside-click": "1.0.13",
51
- "@yamada-ui/use-pan-event": "^1.0.14",
51
+ "@yamada-ui/use-pan-event": "^1.0.15-next-20240516121223",
52
52
  "@yamada-ui/use-size": "^1.0.13",
53
53
  "@yamada-ui/utils": "1.2.0"
54
54
  },
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import { layoutStyleProperties } from \"@yamada-ui/core\"\nimport type {\n UIPropGetter,\n CSSUIObject,\n ThemeProps,\n HTMLUIProps,\n} from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { popoverProperties, type PopoverProps } from \"@yamada-ui/popover\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { useEyeDropper } from \"@yamada-ui/use-eye-dropper\"\nimport { useOutsideClick } from \"@yamada-ui/use-outside-click\"\nimport type { ColorFormat, Dict } from \"@yamada-ui/utils\"\nimport {\n createContext,\n dataAttr,\n handlerAll,\n mergeRefs,\n pickObject,\n splitObject,\n omitObject,\n getEventRelatedTarget,\n isContains,\n convertColor,\n calcFormat,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ntype ColorPickerContext = { value: string; styles: Record<string, CSSUIObject> }\n\nexport const [ColorPickerProvider, useColorPickerContext] =\n createContext<ColorPickerContext>({\n name: \"ColorPickerContext\",\n errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in \"<ColorPicker />\"`,\n })\n\ntype UseColorPickerOptions = {\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport type UseColorPickerProps = Omit<\n HTMLUIProps<\"input\">,\n \"size\" | \"offset\" | \"value\" | \"defaultValue\" | \"onChange\" | \"children\"\n> &\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\"> &\n Omit<\n PopoverProps,\n | \"initialFocusRef\"\n | \"closeOnButton\"\n | \"trigger\"\n | \"autoFocus\"\n | \"restoreFocus\"\n | \"openDelay\"\n | \"closeDelay\"\n | \"children\"\n > &\n Pick<\n ColorSelectorProps,\n | \"withPicker\"\n | \"withChannel\"\n | \"swatchesLabel\"\n | \"swatches\"\n | \"swatchesColumns\"\n > &\n UseColorPickerOptions\n\nexport const useColorPicker = ({\n value: valueProp,\n defaultValue,\n fallbackValue,\n defaultColor,\n onChange: onChangeProp,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n formatInput = (value) => value,\n closeOnBlur = true,\n closeOnEsc = true,\n placement = \"bottom-start\",\n duration = 0.2,\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n allowInput = true,\n closeOnSelectSwatch,\n format,\n swatchesLabel,\n swatches,\n swatchesColumns,\n withPicker,\n withChannel,\n withResult = false,\n withColorSelectorEyeDropper = false,\n colorSelectorVariant,\n colorSelectorSize,\n colorSelectorColorScheme,\n ...rest\n}: UseColorPickerProps) => {\n rest = useFormControlProps(rest)\n\n const formControlProps = pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n )\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject<Dict, string>(\n omitObject(rest, [...popoverProperties]),\n layoutStyleProperties,\n )\n\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n value: valueProp,\n defaultValue,\n onChange: onChangeProp,\n })\n const formatRef = useRef<ColorFormat>(\n format ?? calcFormat(value ?? defaultColor ?? \"\"),\n )\n const isInputFocused = useRef<boolean>(false)\n const [inputValue, setInputValue] = useState<string>(value ?? \"\")\n const {\n isOpen,\n onOpen: onInternalOpen,\n onClose: onInternalClose,\n } = useDisclosure({\n isOpen: isOpenProp,\n defaultIsOpen,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n })\n const isColorSelectorFull = colorSelectorSize === \"full\"\n\n const onOpen = useCallback(() => {\n if (disabled || readOnly) return\n\n onInternalOpen()\n }, [onInternalOpen, disabled, readOnly])\n\n const onClose = useCallback(() => {\n if (!isOpen) return\n\n const next = convertColor(value, fallbackValue)(formatRef.current)\n\n setValue((prev) => (!next || prev === next ? prev : next))\n setInputValue(formatInput(next ?? \"\"))\n\n onInternalClose()\n }, [\n formatRef,\n isOpen,\n setValue,\n onInternalClose,\n value,\n formatInput,\n setInputValue,\n fallbackValue,\n ])\n\n const onContainerClick = useCallback(() => {\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputFocus = useCallback(() => {\n isInputFocused.current = true\n\n if (isOpen) return\n\n onOpen()\n }, [isOpen, onOpen])\n\n const onInputBlur = useCallback(() => {\n isInputFocused.current = false\n }, [])\n\n const onContainerBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n\n if (isContains(containerRef.current, relatedTarget)) return\n\n if (!closeOnBlur) return\n\n if (isOpen) onClose()\n },\n [closeOnBlur, isOpen, onClose],\n )\n\n const onInputKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === \" \") ev.key = ev.code\n\n if (disabled || readOnly) return\n\n const actions: Record<string, Function | undefined> = {\n Space: !isOpen ? onOpen : undefined,\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n action()\n },\n [disabled, readOnly, isOpen, onOpen, closeOnEsc, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const value = ev.target.value\n\n setInputValue(formatInput(value))\n setValue(value)\n },\n [setInputValue, formatInput, setValue],\n )\n\n const onColorSelectorChange = useCallback(\n (value: string) => {\n setValue(value)\n\n setTimeout(() => {\n if (!isInputFocused.current) setInputValue(formatInput(value))\n })\n },\n [setValue, formatInput],\n )\n\n const onEyeDropperClick = useCallback(\n async (ev: MouseEvent<HTMLButtonElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n try {\n const { sRGBHex } = (await onEyeDropperOpen()) ?? {}\n\n if (!sRGBHex) return\n\n onColorSelectorChange(sRGBHex)\n onChangeEnd?.(sRGBHex)\n } catch {}\n },\n [onEyeDropperOpen, onColorSelectorChange, onChangeEnd],\n )\n\n useOutsideClick({\n ref: containerRef,\n handler: onClose,\n enabled: isOpen && closeOnBlur,\n })\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) return\n\n setInputValue(formatInput(nextValue))\n setValue(nextValue)\n }, [format])\n\n useUpdateEffect(() => {\n if (isInputFocused.current || !valueProp) return\n\n setInputValue(formatInput(valueProp))\n }, [valueProp])\n\n const getPopoverProps = useCallback(\n (props?: PopoverProps): PopoverProps => ({\n matchWidth: isColorSelectorFull,\n ...rest,\n ...props,\n isOpen,\n onOpen,\n onClose,\n placement,\n duration,\n trigger: \"never\",\n closeOnButton: false,\n }),\n [isColorSelectorFull, duration, onClose, onOpen, placement, rest, isOpen],\n )\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onClick: handlerAll(props.onClick, rest.onClick, onContainerClick),\n onBlur: handlerAll(props.onBlur, rest.onBlur, onContainerBlur),\n }),\n [containerProps, formControlProps, onContainerBlur, onContainerClick, rest],\n )\n\n const getFieldProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(fieldRef, ref),\n tabIndex: !allowInput ? -1 : 0,\n ...inputProps,\n ...props,\n style: {\n ...props.style,\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n },\n value: inputValue,\n \"data-active\": dataAttr(isOpen),\n \"aria-expanded\": dataAttr(isOpen),\n onFocus: handlerAll(props.onFocus, rest.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onInputKeyDown),\n onChange: handlerAll(props.onChange, onInputChange),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n }),\n [\n allowInput,\n inputProps,\n inputValue,\n isOpen,\n rest,\n onInputFocus,\n onInputKeyDown,\n onInputChange,\n onInputBlur,\n ],\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 style: { ...props.style, pointerEvents: readOnly ? \"none\" : undefined },\n onClick: handlerAll(props.onClick, onEyeDropperClick),\n }),\n [disabled, onEyeDropperClick, readOnly],\n )\n\n const getSelectorProps = useCallback(\n (props?: ColorSelectorProps): ColorSelectorProps => ({\n ...formControlProps,\n ...props,\n value,\n defaultValue: defaultColor,\n fallbackValue,\n onChange: onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\n format: formatRef.current,\n withPicker,\n withChannel,\n withResult,\n withEyeDropper: withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n variant: colorSelectorVariant,\n size: colorSelectorSize,\n colorScheme: colorSelectorColorScheme,\n }),\n [\n formControlProps,\n value,\n fallbackValue,\n defaultColor,\n onColorSelectorChange,\n onChangeStart,\n onChangeEnd,\n onSwatchClick,\n onClose,\n closeOnSelectSwatch,\n formatRef,\n withPicker,\n withChannel,\n withResult,\n withColorSelectorEyeDropper,\n swatchesLabel,\n swatches,\n swatchesColumns,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n ],\n )\n\n return {\n value,\n eyeDropperSupported,\n allowInput,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n getSelectorProps,\n getEyeDropperProps,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;AAAA,SAAS,6BAA6B;AAOtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAA4C;AACrD,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,QAAQ,gBAAgB;AAQvC,IAAM,CAAC,qBAAqB,qBAAqB,IACtD,cAAkC;AAAA,EAChC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA6EI,IAAM,iBAAiB,CAAC;AAAA,EAC7B,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA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A,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["value","_a"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/color-picker.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useMultiComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { Portal, type PortalProps } from \"@yamada-ui/portal\"\nimport {\n cx,\n getValidChildren,\n isValidElement,\n omitObject,\n} from \"@yamada-ui/utils\"\nimport { cloneElement } from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport { ColorSelector } from \"./color-selector\"\nimport { EyeDropperIcon } from \"./color-selector-eye-dropper\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport { ColorSwatch } from \"./color-swatch\"\nimport type { UseColorPickerProps } from \"./use-color-picker\"\nimport {\n ColorPickerProvider,\n useColorPicker,\n useColorPickerContext,\n} from \"./use-color-picker\"\n\ntype ColorPickerOptions = {\n /**\n * If `true`, display the color swatch component.\n *\n * @default true\n */\n withSwatch?: boolean\n /**\n * If `true`, display the eye dropper component.\n *\n * @default true\n */\n withEyeDropper?: boolean\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: string\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: string\n /**\n * Props for color picker container element.\n */\n containerProps?: Omit<HTMLUIProps<\"div\">, \"children\">\n /**\n * Props for color picker element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props for color swatch component.\n */\n swatchProps?: ColorPickerSwatchProps\n /**\n * Props for color eye dropper component.\n */\n eyeDropperProps?: ColorPickerEyeDropperProps\n /**\n * Props to be forwarded to the portal component.\n *\n * @default '{ isDisabled: true }'\n */\n portalProps?: Omit<PortalProps, \"children\">\n}\n\nexport type ColorPickerProps = ThemeProps<\"ColorPicker\"> &\n UseColorPickerProps &\n ColorPickerOptions &\n Pick<\n ColorSelectorProps,\n | \"saturationSliderRef\"\n | \"saturationSliderProps\"\n | \"swatchesProps\"\n | \"hueSliderRef\"\n | \"hueSliderProps\"\n | \"alphaSliderRef\"\n | \"alphaSliderProps\"\n | \"channelsProps\"\n | \"channelProps\"\n | \"children\"\n >\n\n/**\n * `ColorPicker` is a component used by the user to select a color or enter an arbitrary color value.\n *\n * @see Docs https://yamada-ui.com/components/forms/color-picker\n */\nexport const ColorPicker = forwardRef<ColorPickerProps, \"input\">(\n ({ withSwatch = true, ...props }, ref) => {\n const [styles, mergedProps] = useMultiComponentStyle(\"ColorPicker\", {\n withSwatch,\n ...props,\n })\n let {\n className,\n children,\n withEyeDropper = true,\n color,\n h,\n height,\n minH,\n minHeight,\n containerProps,\n inputProps,\n swatchProps,\n eyeDropperProps,\n saturationSliderRef,\n saturationSliderProps,\n swatchesProps,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n channelsProps,\n channelProps,\n portalProps = { isDisabled: true },\n ...computedProps\n } = omitThemeProps(omitObject(mergedProps, [\"withSwatch\"]))\n const {\n allowInput,\n eyeDropperSupported,\n getPopoverProps,\n getContainerProps,\n getFieldProps,\n getSelectorProps,\n getEyeDropperProps,\n ...rest\n } = useColorPicker(computedProps)\n\n h ??= height\n minH ??= minHeight\n\n const css: CSSUIObject = {\n w: \"100%\",\n h: \"fit-content\",\n color,\n ...styles.container,\n }\n\n return (\n <ColorPickerProvider value={{ styles, ...rest }}>\n <Popover {...getPopoverProps()}>\n <ui.div\n className={cx(\"ui-color-picker\", className)}\n __css={css}\n {...getContainerProps(containerProps)}\n >\n <ui.div\n className=\"ui-color-picker__inner\"\n __css={{\n position: \"relative\",\n cursor: !allowInput ? \"pointer\" : undefined,\n ...styles.inner,\n }}\n >\n {withSwatch ? <ColorPickerSwatch {...swatchProps} /> : null}\n\n <PopoverTrigger>\n <ColorPickerField\n h={h}\n minH={minH}\n {...getFieldProps(inputProps, ref)}\n />\n </PopoverTrigger>\n\n {eyeDropperSupported && withEyeDropper ? (\n <ColorPickerEyeDropper\n {...getEyeDropperProps(eyeDropperProps)}\n />\n ) : null}\n </ui.div>\n\n <Portal {...portalProps}>\n <PopoverContent\n className=\"ui-color-picker__popover\"\n __css={{ ...styles.list }}\n >\n <ColorSelector\n className=\"ui-color-picker__picker\"\n {...getSelectorProps({\n saturationSliderRef,\n saturationSliderProps,\n swatchesProps,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n channelsProps,\n channelProps,\n })}\n >\n {children}\n </ColorSelector>\n </PopoverContent>\n </Portal>\n </ui.div>\n </Popover>\n </ColorPickerProvider>\n )\n },\n)\n\ntype ColorPickerFieldProps = HTMLUIProps<\"input\">\n\nconst ColorPickerField = forwardRef<ColorPickerFieldProps, \"input\">(\n ({ className, h, minH, ...rest }, ref) => {\n const { styles } = useColorPickerContext()\n\n const css: CSSUIObject = {\n ps: \"2rem\",\n pe: \"2rem\",\n h,\n minH,\n display: \"flex\",\n alignItems: \"center\",\n ...styles.field,\n }\n\n return (\n <ui.input\n ref={ref}\n className={cx(\"ui-color-picker__field\", className)}\n __css={css}\n {...rest}\n />\n )\n },\n)\n\ntype ColorPickerSwatchProps = ColorSwatchProps\n\nconst ColorPickerSwatch = forwardRef<ColorPickerSwatchProps, \"div\">(\n ({ className, ...rest }, ref) => {\n const { value, styles } = useColorPickerContext()\n\n const css: CSSUIObject = {\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n zIndex: 2,\n ...styles.swatch,\n }\n\n return (\n <ColorSwatch\n ref={ref}\n className={cx(\"ui-color-picker__swatch\", className)}\n __css={css}\n color={value}\n isRounded\n {...rest}\n />\n )\n },\n)\n\ntype ColorPickerEyeDropperProps = HTMLUIProps<\"button\">\n\nconst ColorPickerEyeDropper = forwardRef<ColorPickerEyeDropperProps, \"button\">(\n ({ className, children, ...rest }, ref) => {\n const { styles } = useColorPickerContext()\n\n const css: CSSUIObject = {\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 1,\n ...styles.eyeDropper,\n }\n\n const validChildren = getValidChildren(children)\n\n const cloneChildren = validChildren.map((child) =>\n cloneElement(child, {\n focusable: false,\n \"aria-hidden\": true,\n style: {\n maxWidth: \"1em\",\n maxHeight: \"1em\",\n color: \"currentColor\",\n },\n }),\n )\n\n return (\n <ui.button\n ref={ref}\n className={cx(\"ui-color-picker__eye-dropper\", className)}\n __css={css}\n {...rest}\n >\n {isValidElement(children) ? (\n cloneChildren\n ) : (\n <EyeDropperIcon className=\"ui-color-picker__eye-dropper-icon\" />\n )}\n </ui.button>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,cAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AA4IjB,SAQgB,KARhB;AA5DL,IAAM,cAAc;AAAA,EACzB,CAAC,EAAE,aAAa,MAAM,GAAG,MAAM,GAAG,QAAQ;AACxC,UAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,eAAe;AAAA,MAClE;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AACD,QAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;A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