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

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  import {
8
8
  ColorSelector
9
9
  } from "./chunk-ZUPKUHBV.mjs";
@@ -23,12 +23,7 @@ import {
23
23
  } from "@yamada-ui/core";
24
24
  import { Popover, PopoverContent, PopoverTrigger } from "@yamada-ui/popover";
25
25
  import { Portal } from "@yamada-ui/portal";
26
- import {
27
- cx,
28
- getValidChildren,
29
- isValidElement,
30
- omitObject
31
- } from "@yamada-ui/utils";
26
+ import { cx, getValidChildren, isValidElement } from "@yamada-ui/utils";
32
27
  import { cloneElement } from "react";
33
28
  import { jsx, jsxs } from "react/jsx-runtime";
34
29
  var ColorPicker = forwardRef(
@@ -61,7 +56,7 @@ var ColorPicker = forwardRef(
61
56
  channelProps,
62
57
  portalProps = { isDisabled: true },
63
58
  ...computedProps
64
- } = omitThemeProps(omitObject(mergedProps, ["withSwatch"]));
59
+ } = omitThemeProps(mergedProps, ["withSwatch"]);
65
60
  const {
66
61
  allowInput,
67
62
  eyeDropperSupported,
@@ -232,4 +227,4 @@ var ColorPickerEyeDropper = forwardRef(
232
227
  export {
233
228
  ColorPicker
234
229
  };
235
- //# sourceMappingURL=chunk-KCV32DAB.mjs.map
230
+ //# sourceMappingURL=chunk-ONIOGROX.mjs.map
@@ -0,0 +1 @@
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 { cx, getValidChildren, isValidElement } 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(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,SAAS,IAAI,kBAAkB,sBAAsB;AACrD,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;AAAA,MACA;AAAA,MACA,cAAc,EAAE,YAAY,KAAK;AAAA,MACjC,GAAG;AAAA,IACL,IAAI,eAAe,aAAa,CAAC,YAAY,CAAC;AAC9C,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI,eAAe,aAAa;AAEhC,wBAAM;AACN,iCAAS;AAET,UAAM,MAAmB;AAAA,MACvB,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,GAAG,OAAO;AAAA,IACZ;AAEA,WACE,oBAAC,uBAAoB,OAAO,EAAE,QAAQ,GAAG,KAAK,GAC5C,8BAAC,WAAS,GAAG,gBAAgB,GAC3B;AAAA,MAAC,GAAG;A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C;AAAA,QACA,WAAW,GAAG,gCAAgC,SAAS;AAAA,QACvD,OAAO;AAAA,QACN,GAAG;AAAA,QAEH,yBAAe,QAAQ,IACtB,gBAEA,oBAAC,kBAAe,WAAU,qCAAoC;AAAA;AAAA,IAElE;AAAA,EAEJ;AACF;","names":[]}
@@ -3,8 +3,8 @@
3
3
  // src/use-color-picker.ts
4
4
  import { layoutStyleProperties } from "@yamada-ui/core";
5
5
  import {
6
- useFormControlProps,
7
- getFormControlProperties
6
+ formControlProperties,
7
+ useFormControlProps
8
8
  } from "@yamada-ui/form-control";
9
9
  import { popoverProperties } from "@yamada-ui/popover";
10
10
  import { useControllableState } from "@yamada-ui/use-controllable-state";
@@ -65,9 +65,9 @@ var useColorPicker = ({
65
65
  }) => {
66
66
  var _a;
67
67
  rest = useFormControlProps(rest);
68
- const formControlProps = pickObject(
68
+ const { "aria-readonly": _ariaReadonly, ...formControlProps } = pickObject(
69
69
  rest,
70
- getFormControlProperties({ omit: ["aria-readonly"] })
70
+ formControlProperties
71
71
  );
72
72
  const { disabled, readOnly } = formControlProps;
73
73
  const [containerProps, inputProps] = splitObject(
@@ -354,4 +354,4 @@ export {
354
354
  useColorPickerContext,
355
355
  useColorPicker
356
356
  };
357
- //# sourceMappingURL=chunk-CR3JRFXA.mjs.map
357
+ //# sourceMappingURL=chunk-SBN7FEOE.mjs.map
@@ -0,0 +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 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<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,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,SAAO,oBAAoB,IAAI;AAE/B,QAAM,EAAE,iBAAiB,eAAe,GAAG,iBAAiB,IAAI;AAAA,IAC9D;AAAA,IACA;AAAA,EACF;AACA,QAAM,EAAE,UAAU,SAA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,MACtE,SAAS,WAAW,MAAM,SAAS,iBAAiB;AAAA,IACtD;AAAA,IACA,CAAC,UAAU,mBAAmB,QAAQ;AAAA,EACxC;AAEA,QAAM,mBAAmB;AAAA,IACvB,CAAC,WAAoD;AAAA,MACnD,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,eAAe;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"]}
@@ -1809,9 +1809,9 @@ var useColorPicker = ({
1809
1809
  }) => {
1810
1810
  var _a;
1811
1811
  rest = (0, import_form_control4.useFormControlProps)(rest);
1812
- const formControlProps = (0, import_utils14.pickObject)(
1812
+ const { "aria-readonly": _ariaReadonly, ...formControlProps } = (0, import_utils14.pickObject)(
1813
1813
  rest,
1814
- (0, import_form_control4.getFormControlProperties)({ omit: ["aria-readonly"] })
1814
+ import_form_control4.formControlProperties
1815
1815
  );
1816
1816
  const { disabled, readOnly } = formControlProps;
1817
1817
  const [containerProps, inputProps] = (0, import_utils14.splitObject)(
@@ -2125,7 +2125,7 @@ var ColorPicker = (0, import_core12.forwardRef)(
2125
2125
  channelProps,
2126
2126
  portalProps = { isDisabled: true },
2127
2127
  ...computedProps
2128
- } = (0, import_core12.omitThemeProps)((0, import_utils15.omitObject)(mergedProps, ["withSwatch"]));
2128
+ } = (0, import_core12.omitThemeProps)(mergedProps, ["withSwatch"]);
2129
2129
  const {
2130
2130
  allowInput,
2131
2131
  eyeDropperSupported,