@yamada-ui/color-picker 1.4.10-dev-20241119122307 → 1.4.10-dev-20241119150031
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-OPWYRBSP.mjs → chunk-3DDU22W6.mjs} +3 -2
- package/dist/chunk-3DDU22W6.mjs.map +1 -0
- package/dist/{chunk-QWG3QE6A.mjs → chunk-DDNDRQKD.mjs} +3 -3
- package/dist/{chunk-ASZZSRFB.mjs → chunk-KXJGUNXF.mjs} +5 -6
- package/dist/chunk-KXJGUNXF.mjs.map +1 -0
- package/dist/{chunk-NNVWH4IX.mjs → chunk-OL3O7L3O.mjs} +2 -2
- package/dist/{chunk-Z2KAER2U.mjs → chunk-T4JTAQXV.mjs} +7 -12
- package/dist/chunk-T4JTAQXV.mjs.map +1 -0
- package/dist/{chunk-XSZZBWND.mjs → chunk-ZW72SK4V.mjs} +2 -2
- package/dist/color-picker.js +7 -12
- package/dist/color-picker.js.map +1 -1
- package/dist/color-picker.mjs +6 -6
- package/dist/color-selector-body.js +1 -0
- package/dist/color-selector-body.js.map +1 -1
- package/dist/color-selector-body.mjs +2 -2
- package/dist/color-selector-swatches.js +1 -0
- package/dist/color-selector-swatches.js.map +1 -1
- package/dist/color-selector-swatches.mjs +2 -2
- package/dist/color-selector.js +1 -0
- package/dist/color-selector.js.map +1 -1
- package/dist/color-selector.mjs +4 -4
- package/dist/color-swatch.js +1 -0
- package/dist/color-swatch.js.map +1 -1
- package/dist/color-swatch.mjs +1 -1
- package/dist/index.js +7 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/use-color-picker.d.mts +0 -1
- package/dist/use-color-picker.d.ts +0 -1
- package/dist/use-color-picker.js +5 -10
- package/dist/use-color-picker.js.map +1 -1
- package/dist/use-color-picker.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-ASZZSRFB.mjs.map +0 -1
- package/dist/chunk-OPWYRBSP.mjs.map +0 -1
- package/dist/chunk-Z2KAER2U.mjs.map +0 -1
- /package/dist/{chunk-QWG3QE6A.mjs.map → chunk-DDNDRQKD.mjs.map} +0 -0
- /package/dist/{chunk-NNVWH4IX.mjs.map → chunk-OL3O7L3O.mjs.map} +0 -0
- /package/dist/{chunk-XSZZBWND.mjs.map → chunk-ZW72SK4V.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
ColorPicker
|
4
|
-
} from "./chunk-
|
5
|
-
import "./chunk-
|
4
|
+
} from "./chunk-KXJGUNXF.mjs";
|
5
|
+
import "./chunk-T4JTAQXV.mjs";
|
6
6
|
import {
|
7
7
|
ColorSelector
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-DDNDRQKD.mjs";
|
9
9
|
import {
|
10
10
|
SaturationSlider
|
11
11
|
} from "./chunk-AJTCPCFF.mjs";
|
12
12
|
import "./chunk-LEN56PPD.mjs";
|
13
|
-
import "./chunk-
|
13
|
+
import "./chunk-ZW72SK4V.mjs";
|
14
14
|
import "./chunk-RJOBF4LI.mjs";
|
15
15
|
import "./chunk-6XIZXZXV.mjs";
|
16
16
|
import "./chunk-UKR7WWUY.mjs";
|
@@ -21,10 +21,10 @@ import {
|
|
21
21
|
AlphaSlider
|
22
22
|
} from "./chunk-FP3X3PED.mjs";
|
23
23
|
import "./chunk-SGAM4TJL.mjs";
|
24
|
-
import "./chunk-
|
24
|
+
import "./chunk-OL3O7L3O.mjs";
|
25
25
|
import {
|
26
26
|
ColorSwatch
|
27
|
-
} from "./chunk-
|
27
|
+
} from "./chunk-3DDU22W6.mjs";
|
28
28
|
import "./chunk-C7UAG4TH.mjs";
|
29
29
|
export {
|
30
30
|
AlphaSlider,
|
@@ -80,7 +80,6 @@ interface UseColorPickerOptions {
|
|
80
80
|
interface UseColorPickerProps extends Omit<HTMLUIProps<"input">, "animation" | "children" | "defaultValue" | "offset" | "onChange" | "size" | "value">, Omit<UseColorSelectorBaseProps, "id" | "name">, ComboBoxProps, Pick<ColorSelectorProps, "swatches" | "swatchesColumns" | "swatchesLabel" | "withChannel" | "withPicker">, UseColorPickerOptions {
|
81
81
|
}
|
82
82
|
declare const useColorPicker: (props: UseColorPickerProps) => {
|
83
|
-
id: string;
|
84
83
|
allowInput: boolean;
|
85
84
|
eyeDropperSupported: boolean;
|
86
85
|
value: string;
|
@@ -80,7 +80,6 @@ interface UseColorPickerOptions {
|
|
80
80
|
interface UseColorPickerProps extends Omit<HTMLUIProps<"input">, "animation" | "children" | "defaultValue" | "offset" | "onChange" | "size" | "value">, Omit<UseColorSelectorBaseProps, "id" | "name">, ComboBoxProps, Pick<ColorSelectorProps, "swatches" | "swatchesColumns" | "swatchesLabel" | "withChannel" | "withPicker">, UseColorPickerOptions {
|
81
81
|
}
|
82
82
|
declare const useColorPicker: (props: UseColorPickerProps) => {
|
83
|
-
id: string;
|
84
83
|
allowInput: boolean;
|
85
84
|
eyeDropperSupported: boolean;
|
86
85
|
value: string;
|
package/dist/use-color-picker.js
CHANGED
@@ -40,8 +40,7 @@ var [ColorPickerProvider, useColorPickerContext] = (0, import_utils.createContex
|
|
40
40
|
errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorPicker />"`
|
41
41
|
});
|
42
42
|
var useColorPicker = (props) => {
|
43
|
-
|
44
|
-
id,
|
43
|
+
const {
|
45
44
|
allowInput = true,
|
46
45
|
animation,
|
47
46
|
boundary,
|
@@ -121,8 +120,6 @@ var useColorPicker = (props) => {
|
|
121
120
|
onClose: onCloseProp,
|
122
121
|
onOpen: onOpenProp
|
123
122
|
});
|
124
|
-
const uuid = (0, import_react.useId)();
|
125
|
-
id != null ? id : id = uuid;
|
126
123
|
const onOpen = (0, import_react.useCallback)(() => {
|
127
124
|
if (disabled || readOnly) return;
|
128
125
|
onInternalOpen();
|
@@ -299,10 +296,11 @@ var useColorPicker = (props) => {
|
|
299
296
|
);
|
300
297
|
const getFieldProps = (0, import_react.useCallback)(
|
301
298
|
(props2 = {}, ref = null) => ({
|
302
|
-
"aria-
|
299
|
+
"aria-haspopup": "dialog",
|
303
300
|
"data-active": (0, import_utils.dataAttr)(isOpen),
|
304
301
|
"data-not-allowed": (0, import_utils.dataAttr)(!readOnly && !disabled && !allowInput),
|
305
|
-
|
302
|
+
role: "combobox",
|
303
|
+
tabIndex: -1,
|
306
304
|
...formControlProps,
|
307
305
|
...props2,
|
308
306
|
ref: (0, import_utils.mergeRefs)(fieldRef, ref),
|
@@ -331,8 +329,7 @@ var useColorPicker = (props) => {
|
|
331
329
|
...disabled || !allowInput ? { pointerEvents: "none" } : {}
|
332
330
|
};
|
333
331
|
return {
|
334
|
-
"
|
335
|
-
role: "combobox",
|
332
|
+
autoComplete: "off",
|
336
333
|
tabIndex: !allowInput ? -1 : 0,
|
337
334
|
...formControlProps,
|
338
335
|
...inputProps,
|
@@ -344,7 +341,6 @@ var useColorPicker = (props) => {
|
|
344
341
|
};
|
345
342
|
},
|
346
343
|
[
|
347
|
-
id,
|
348
344
|
inputProps,
|
349
345
|
allowInput,
|
350
346
|
disabled,
|
@@ -415,7 +411,6 @@ var useColorPicker = (props) => {
|
|
415
411
|
]
|
416
412
|
);
|
417
413
|
return {
|
418
|
-
id,
|
419
414
|
allowInput,
|
420
415
|
eyeDropperSupported,
|
421
416
|
value,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n PropGetter,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { ComboBoxProps, PopoverProps } from \"@yamada-ui/popover\"\nimport type { ColorFormat } from \"@yamada-ui/utils\"\nimport type {\n ChangeEvent,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\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 {\n calcFormat,\n convertColor,\n createContext,\n dataAttr,\n getEventRelatedTarget,\n handlerAll,\n isContains,\n mergeRefs,\n pickObject,\n splitObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef, useState } from \"react\"\n\nconst defaultFormatInput = (value: string) => value\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ninterface ColorPickerContext {\n styles: { [key: string]: CSSUIObject | undefined }\n value: string\n}\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\ninterface UseColorPickerOptions {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport interface UseColorPickerProps\n extends Omit<\n HTMLUIProps<\"input\">,\n | \"animation\"\n | \"children\"\n | \"defaultValue\"\n | \"offset\"\n | \"onChange\"\n | \"size\"\n | \"value\"\n >,\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\">,\n ComboBoxProps,\n Pick<\n ColorSelectorProps,\n | \"swatches\"\n | \"swatchesColumns\"\n | \"swatchesLabel\"\n | \"withChannel\"\n | \"withPicker\"\n >,\n UseColorPickerOptions {}\n\nexport const useColorPicker = (props: UseColorPickerProps) => {\n let {\n id,\n allowInput = true,\n animation,\n boundary,\n closeDelay,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnSelectSwatch,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n defaultColor,\n defaultIsOpen,\n defaultValue,\n duration = 0.2,\n eventListeners,\n fallbackValue,\n flip,\n format,\n formatInput = defaultFormatInput,\n gutter,\n isLazy,\n isOpen: isOpenProp,\n lazyBehavior,\n matchWidth = colorSelectorSize === \"full\",\n modifiers,\n offset,\n openDelay,\n placement = \"bottom-start\",\n preventOverflow,\n strategy,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value: valueProp,\n withChannel,\n withColorSelectorEyeDropper = false,\n withPicker,\n withResult = false,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n onClick,\n onClose: onCloseProp,\n onKeyDown,\n onOpen: onOpenProp,\n onSwatchClick,\n ...rest\n } = useFormControlProps(props)\n const {\n \"aria-readonly\": _ariaReadonly,\n onBlur,\n onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties)\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\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 onClose: onInternalClose,\n onOpen: onInternalOpen,\n } = useDisclosure({\n defaultIsOpen,\n isOpen: isOpenProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const uuid = useId()\n\n id ??= uuid\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: { [key: string]: Function | undefined } = {\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n Space: !isOpen ? onOpen : 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 enabled: isOpen && closeOnBlur,\n handler: onClose,\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 animation,\n boundary,\n closeDelay,\n closeOnBlur,\n duration,\n eventListeners,\n flip,\n gutter,\n isLazy,\n lazyBehavior,\n matchWidth,\n modifiers,\n offset,\n openDelay,\n placement,\n preventOverflow,\n strategy,\n ...props,\n closeOnButton: false,\n isOpen,\n trigger: \"never\",\n onClose,\n onOpen,\n }),\n [\n closeOnBlur,\n openDelay,\n closeDelay,\n isLazy,\n lazyBehavior,\n animation,\n duration,\n offset,\n gutter,\n preventOverflow,\n flip,\n matchWidth,\n boundary,\n eventListeners,\n strategy,\n placement,\n modifiers,\n isOpen,\n onOpen,\n onClose,\n ],\n )\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onBlur: handlerAll(props.onBlur, onBlur, onContainerBlur),\n onClick: handlerAll(props.onClick, onClick, onContainerClick),\n }),\n [\n containerProps,\n formControlProps,\n onBlur,\n onClick,\n onContainerBlur,\n onContainerClick,\n ],\n )\n\n const getFieldProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n \"aria-expanded\": dataAttr(isOpen),\n \"data-active\": dataAttr(isOpen),\n \"data-not-allowed\": dataAttr(!readOnly && !disabled && !allowInput),\n tabIndex: !allowInput ? -1 : 0,\n ...formControlProps,\n ...props,\n ref: mergeRefs(fieldRef, ref),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n onFocus: handlerAll(props.onFocus, onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown, onInputKeyDown),\n }),\n [\n allowInput,\n formControlProps,\n isOpen,\n readOnly,\n disabled,\n onInputBlur,\n onFocus,\n onInputFocus,\n onKeyDown,\n onInputKeyDown,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n ...props.style,\n ...inputProps.style,\n ...(disabled || !allowInput ? { pointerEvents: \"none\" } : {}),\n }\n\n return {\n \"aria-controls\": id,\n role: \"combobox\",\n tabIndex: !allowInput ? -1 : 0,\n ...formControlProps,\n ...inputProps,\n ...props,\n ref,\n style,\n value: inputValue,\n onChange: handlerAll(props.onChange, onInputChange),\n }\n },\n [\n id,\n inputProps,\n allowInput,\n disabled,\n formControlProps,\n inputValue,\n onInputChange,\n ],\n )\n\n const getEyeDropperProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n \"aria-label\": \"Pick a color\",\n disabled,\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: PropGetter<ColorSelectorProps> = useCallback(\n (props) => ({\n ...formControlProps,\n ...props,\n colorScheme: colorSelectorColorScheme,\n size: colorSelectorSize,\n variant: colorSelectorVariant,\n defaultValue: defaultColor,\n fallbackValue,\n format: formatRef.current,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value,\n withChannel,\n withEyeDropper: withColorSelectorEyeDropper,\n withPicker,\n withResult,\n onChange: onColorSelectorChange,\n onChangeEnd,\n onChangeStart,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\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 id,\n allowInput,\n eyeDropperSupported,\n value,\n getContainerProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getPopoverProps,\n getSelectorProps,\n onClose,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAAsC;AACtC,0BAGO;AACP,oCAAqC;AACrC,4BAA8B;AAC9B,6BAA8B;AAC9B,+BAAgC;AAChC,mBAYO;AACP,mBAAqD;AAErD,IAAM,qBAAqB,CAAC,UAAkB;AASvC,IAAM,CAAC,qBAAqB,qBAAqB,QACtD,4BAAkC;AAAA,EAChC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA0EI,IAAM,iBAAiB,CAAC,UAA+B;AAC5D,MAAI;AAAA,IACF;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;A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AAM,yBAA2C;AAAA,IAC/C,CAACA,SAAQ,CAAC,GAAG,MAAM,UAAU;AAAA,MAC3B,cAAc;AAAA,MACd;AAAA,MACA,GAAGA;AAAA,MACH;AAAA,MACA,OAAO,EAAE,GAAGA,OAAM,OAAO,eAAe,WAAW,SAAS,OAAU;AAAA,MACtE,aAAS,yBAAWA,OAAM,SAAS,iBAAiB;AAAA,IACtD;AAAA,IACA,CAAC,UAAU,mBAAmB,QAAQ;AAAA,EACxC;AAEA,QAAM,uBAAmD;AAAA,IACvD,CAACA,YAAW;AAAA,MACV,GAAG;AAAA,MACH,GAAGA;AAAA,MACH,aAAa;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,cAAc;AAAA,MACd;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,mBAAe;AAAA,QACb;AAAA,QACA,sBAAsB,UAAU;AAAA,MAClC;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,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["value","props"]}
|
1
|
+
{"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n PropGetter,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { ComboBoxProps, PopoverProps } from \"@yamada-ui/popover\"\nimport type { ColorFormat } from \"@yamada-ui/utils\"\nimport type {\n ChangeEvent,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\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 {\n calcFormat,\n convertColor,\n createContext,\n dataAttr,\n getEventRelatedTarget,\n handlerAll,\n isContains,\n mergeRefs,\n pickObject,\n splitObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useRef, useState } from \"react\"\n\nconst defaultFormatInput = (value: string) => value\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ninterface ColorPickerContext {\n styles: { [key: string]: CSSUIObject | undefined }\n value: string\n}\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\ninterface UseColorPickerOptions {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport interface UseColorPickerProps\n extends Omit<\n HTMLUIProps<\"input\">,\n | \"animation\"\n | \"children\"\n | \"defaultValue\"\n | \"offset\"\n | \"onChange\"\n | \"size\"\n | \"value\"\n >,\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\">,\n ComboBoxProps,\n Pick<\n ColorSelectorProps,\n | \"swatches\"\n | \"swatchesColumns\"\n | \"swatchesLabel\"\n | \"withChannel\"\n | \"withPicker\"\n >,\n UseColorPickerOptions {}\n\nexport const useColorPicker = (props: UseColorPickerProps) => {\n const {\n allowInput = true,\n animation,\n boundary,\n closeDelay,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnSelectSwatch,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n defaultColor,\n defaultIsOpen,\n defaultValue,\n duration = 0.2,\n eventListeners,\n fallbackValue,\n flip,\n format,\n formatInput = defaultFormatInput,\n gutter,\n isLazy,\n isOpen: isOpenProp,\n lazyBehavior,\n matchWidth = colorSelectorSize === \"full\",\n modifiers,\n offset,\n openDelay,\n placement = \"bottom-start\",\n preventOverflow,\n strategy,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value: valueProp,\n withChannel,\n withColorSelectorEyeDropper = false,\n withPicker,\n withResult = false,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n onClick,\n onClose: onCloseProp,\n onKeyDown,\n onOpen: onOpenProp,\n onSwatchClick,\n ...rest\n } = useFormControlProps(props)\n const {\n \"aria-readonly\": _ariaReadonly,\n onBlur,\n onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties)\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\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 onClose: onInternalClose,\n onOpen: onInternalOpen,\n } = useDisclosure({\n defaultIsOpen,\n isOpen: isOpenProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\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: { [key: string]: Function | undefined } = {\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n Space: !isOpen ? onOpen : 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 enabled: isOpen && closeOnBlur,\n handler: onClose,\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 animation,\n boundary,\n closeDelay,\n closeOnBlur,\n duration,\n eventListeners,\n flip,\n gutter,\n isLazy,\n lazyBehavior,\n matchWidth,\n modifiers,\n offset,\n openDelay,\n placement,\n preventOverflow,\n strategy,\n ...props,\n closeOnButton: false,\n isOpen,\n trigger: \"never\",\n onClose,\n onOpen,\n }),\n [\n closeOnBlur,\n openDelay,\n closeDelay,\n isLazy,\n lazyBehavior,\n animation,\n duration,\n offset,\n gutter,\n preventOverflow,\n flip,\n matchWidth,\n boundary,\n eventListeners,\n strategy,\n placement,\n modifiers,\n isOpen,\n onOpen,\n onClose,\n ],\n )\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onBlur: handlerAll(props.onBlur, onBlur, onContainerBlur),\n onClick: handlerAll(props.onClick, onClick, onContainerClick),\n }),\n [\n containerProps,\n formControlProps,\n onBlur,\n onClick,\n onContainerBlur,\n onContainerClick,\n ],\n )\n\n const getFieldProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n \"aria-haspopup\": \"dialog\",\n \"data-active\": dataAttr(isOpen),\n \"data-not-allowed\": dataAttr(!readOnly && !disabled && !allowInput),\n role: \"combobox\",\n tabIndex: -1,\n ...formControlProps,\n ...props,\n ref: mergeRefs(fieldRef, ref),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n onFocus: handlerAll(props.onFocus, onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown, onInputKeyDown),\n }),\n [\n allowInput,\n formControlProps,\n isOpen,\n readOnly,\n disabled,\n onInputBlur,\n onFocus,\n onInputFocus,\n onKeyDown,\n onInputKeyDown,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n ...props.style,\n ...inputProps.style,\n ...(disabled || !allowInput ? { pointerEvents: \"none\" } : {}),\n }\n\n return {\n autoComplete: \"off\",\n tabIndex: !allowInput ? -1 : 0,\n ...formControlProps,\n ...inputProps,\n ...props,\n ref,\n style,\n value: inputValue,\n onChange: handlerAll(props.onChange, onInputChange),\n }\n },\n [\n inputProps,\n allowInput,\n disabled,\n formControlProps,\n inputValue,\n onInputChange,\n ],\n )\n\n const getEyeDropperProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n \"aria-label\": \"Pick a color\",\n disabled,\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: PropGetter<ColorSelectorProps> = useCallback(\n (props) => ({\n ...formControlProps,\n ...props,\n colorScheme: colorSelectorColorScheme,\n size: colorSelectorSize,\n variant: colorSelectorVariant,\n defaultValue: defaultColor,\n fallbackValue,\n format: formatRef.current,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value,\n withChannel,\n withEyeDropper: withColorSelectorEyeDropper,\n withPicker,\n withResult,\n onChange: onColorSelectorChange,\n onChangeEnd,\n onChangeStart,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\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 allowInput,\n eyeDropperSupported,\n value,\n getContainerProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getPopoverProps,\n getSelectorProps,\n onClose,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAAsC;AACtC,0BAGO;AACP,oCAAqC;AACrC,4BAA8B;AAC9B,6BAA8B;AAC9B,+BAAgC;AAChC,mBAYO;AACP,mBAA8C;AAE9C,IAAM,qBAAqB,CAAC,UAAkB;AASvC,IAAM,CAAC,qBAAqB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;AACF;","names":["value","props"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/color-picker",
|
3
|
-
"version": "1.4.10-dev-
|
3
|
+
"version": "1.4.10-dev-20241119150031",
|
4
4
|
"description": "Yamada UI color picker component",
|
5
5
|
"keywords": [
|
6
6
|
"yamada",
|
@@ -36,12 +36,12 @@
|
|
36
36
|
"url": "https://github.com/yamada-ui/yamada-ui/issues"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@yamada-ui/button": "1.0.50-dev-
|
39
|
+
"@yamada-ui/button": "1.0.50-dev-20241119150031",
|
40
40
|
"@yamada-ui/core": "1.15.5",
|
41
41
|
"@yamada-ui/form-control": "2.1.7",
|
42
|
-
"@yamada-ui/icon": "1.1.13-dev-
|
42
|
+
"@yamada-ui/icon": "1.1.13-dev-20241119150031",
|
43
43
|
"@yamada-ui/input": "1.0.47",
|
44
|
-
"@yamada-ui/popover": "1.4.3-dev-
|
44
|
+
"@yamada-ui/popover": "1.4.3-dev-20241119150031",
|
45
45
|
"@yamada-ui/portal": "1.0.24",
|
46
46
|
"@yamada-ui/use-controllable-state": "1.0.23",
|
47
47
|
"@yamada-ui/use-disclosure": "1.1.0",
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/color-picker.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { PortalProps } from \"@yamada-ui/portal\"\nimport type { FC, ReactNode, RefAttributes } from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { ColorSwatchProps } from \"./color-swatch\"\nimport type { UseColorPickerProps } from \"./use-color-picker\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { Portal } from \"@yamada-ui/portal\"\nimport {\n cx,\n getValidChildren,\n isValidElement,\n mergeRefs,\n runIfFunc,\n} from \"@yamada-ui/utils\"\nimport { cloneElement } from \"react\"\nimport { ColorSelector } from \"./color-selector\"\nimport { EyeDropperIcon } from \"./color-selector-eye-dropper\"\nimport { ColorSwatch } from \"./color-swatch\"\nimport {\n ColorPickerProvider,\n useColorPicker,\n useColorPickerContext,\n} from \"./use-color-picker\"\n\ninterface ColorPickerOptions {\n children?: FC<{ value: string; onClose: () => void }> | ReactNode\n /**\n * The border color when the input is invalid.\n */\n errorBorderColor?: string\n /**\n * The border color when the input is focused.\n */\n focusBorderColor?: string\n /**\n * If `true`, display the eye dropper component.\n *\n * @default true\n */\n withEyeDropper?: boolean\n /**\n * If `true`, display the color swatch component.\n *\n * @default true\n */\n withSwatch?: boolean\n /**\n * Props for color picker container element.\n */\n containerProps?: Omit<HTMLUIProps, \"children\">\n /**\n * Props for color eye dropper component.\n */\n eyeDropperProps?: ColorPickerEyeDropperProps\n /**\n * Props for color picker field element.\n */\n fieldProps?: Omit<ColorPickerFieldProps, \"children\" | \"inputProps\">\n /**\n * Props for color picker input element.\n */\n inputProps?: HTMLUIProps<\"input\">\n /**\n * Props to be forwarded to the portal component.\n *\n * @default '{ isDisabled: true }'\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for color swatch component.\n */\n swatchProps?: ColorPickerSwatchProps\n}\n\nexport interface ColorPickerProps\n extends ThemeProps<\"ColorPicker\">,\n UseColorPickerProps,\n ColorPickerOptions,\n Pick<\n ColorSelectorProps,\n | \"alphaSliderProps\"\n | \"alphaSliderRef\"\n | \"channelProps\"\n | \"channelsProps\"\n | \"hueSliderProps\"\n | \"hueSliderRef\"\n | \"saturationSliderProps\"\n | \"saturationSliderRef\"\n | \"swatchesProps\"\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] = useComponentMultiStyle(\"ColorPicker\", {\n withSwatch,\n ...props,\n })\n let {\n className,\n alphaSliderRef,\n children,\n color,\n h,\n height,\n hueSliderRef,\n minH,\n minHeight,\n saturationSliderRef,\n withEyeDropper = true,\n alphaSliderProps,\n channelProps,\n channelsProps,\n containerProps,\n eyeDropperProps,\n fieldProps,\n hueSliderProps,\n inputProps,\n portalProps = { isDisabled: true },\n saturationSliderProps,\n swatchesProps,\n swatchProps,\n ...computedProps\n } = omitThemeProps(mergedProps, [\"withSwatch\"])\n const {\n id,\n eyeDropperSupported,\n value,\n getContainerProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getPopoverProps,\n getSelectorProps,\n onClose,\n ...rest\n } = useColorPicker(computedProps)\n\n h ??= height\n minH ??= minHeight\n\n const css: CSSUIObject = {\n color,\n h: \"fit-content\",\n w: \"100%\",\n ...styles.container,\n }\n\n return (\n <ColorPickerProvider value={{ styles, value, ...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 ...styles.inner,\n }}\n >\n {withSwatch ? <ColorPickerSwatch {...swatchProps} /> : null}\n\n <ColorPickerField\n h={h}\n minH={minH}\n {...getFieldProps(fieldProps, ref)}\n inputProps={getInputProps(inputProps)}\n />\n\n {eyeDropperSupported && withEyeDropper ? (\n <ColorPickerEyeDropper\n {...getEyeDropperProps(eyeDropperProps)}\n />\n ) : null}\n </ui.div>\n\n <Portal {...portalProps}>\n <PopoverContent\n id={id}\n className=\"ui-color-picker__content\"\n __css={{ ...styles.content }}\n >\n <ColorSelector\n className=\"ui-color-picker__picker\"\n {...getSelectorProps({\n alphaSliderRef,\n hueSliderRef,\n saturationSliderRef,\n alphaSliderProps,\n channelProps,\n channelsProps,\n hueSliderProps,\n saturationSliderProps,\n swatchesProps,\n })}\n >\n {runIfFunc(children, { value, onClose })}\n </ColorSelector>\n </PopoverContent>\n </Portal>\n </ui.div>\n </Popover>\n </ColorPickerProvider>\n )\n },\n)\n\nColorPicker.displayName = \"ColorPicker\"\nColorPicker.__ui__ = \"ColorPicker\"\n\ninterface ColorPickerFieldOptions {\n inputProps?: HTMLUIProps<\"input\"> & RefAttributes<HTMLInputElement>\n}\n\ninterface ColorPickerFieldProps extends HTMLUIProps, ColorPickerFieldOptions {}\n\nconst ColorPickerField = forwardRef<ColorPickerFieldProps, \"input\">(\n ({ className, h, minH, inputProps, ...rest }, ref) => {\n const { styles } = useColorPickerContext()\n const { ref: inputRef, ...computedInputProps } = inputProps ?? {}\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n h,\n minH,\n pe: \"2rem\",\n ps: \"2rem\",\n ...styles.field,\n }\n\n return (\n <PopoverTrigger>\n <ui.div\n className={cx(\"ui-color-picker__field\", className)}\n __css={css}\n {...rest}\n >\n <ui.input\n ref={mergeRefs(ref, inputRef)}\n className=\"ui-color-picker-picker__field__input\"\n display=\"inline-block\"\n w=\"100%\"\n {...computedInputProps}\n />\n </ui.div>\n </PopoverTrigger>\n )\n },\n)\n\nColorPickerField.displayName = \"ColorPickerField\"\nColorPickerField.__ui__ = \"ColorPickerField\"\n\ninterface ColorPickerSwatchProps extends ColorSwatchProps {}\n\nconst ColorPickerSwatch = forwardRef<ColorPickerSwatchProps, \"div\">(\n ({ className, ...rest }, ref) => {\n const { styles, value } = useColorPickerContext()\n\n const css: CSSUIObject = {\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n zIndex: 1,\n ...styles.swatch,\n }\n\n return (\n <ColorSwatch\n ref={ref}\n className={cx(\"ui-color-picker__swatch\", className)}\n color={value}\n isRounded\n __css={css}\n {...rest}\n />\n )\n },\n)\n\nColorPickerSwatch.displayName = \"ColorPickerSwatch\"\nColorPickerSwatch.__ui__ = \"ColorPickerSwatch\"\n\ninterface ColorPickerEyeDropperProps extends HTMLUIProps<\"button\"> {}\n\nconst ColorPickerEyeDropper = forwardRef<ColorPickerEyeDropperProps, \"button\">(\n ({ className, children, ...rest }, ref) => {\n const { styles } = useColorPickerContext()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"inline-flex\",\n justifyContent: \"center\",\n position: \"absolute\",\n top: \"50%\",\n transform: \"translateY(-50%)\",\n zIndex: 1,\n ...styles.eyeDropper,\n }\n\n const validChildren = getValidChildren(children)\n\n const cloneChildren = validChildren.map((child) =>\n cloneElement(child, {\n style: {\n color: \"currentColor\",\n maxHeight: \"1em\",\n maxWidth: \"1em\",\n },\n \"aria-hidden\": true,\n focusable: false,\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\nColorPickerEyeDropper.displayName = \"ColorPickerEyeDropper\"\nColorPickerEyeDropper.__ui__ = \"ColorPickerEyeDropper\"\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAkJjB,SAOgB,KAPhB;AAhEL,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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AA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EnE;AAAA,EAEJ;AACF;AAEA,sBAAsB,cAAc;AACpC,sBAAsB,SAAS;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/color-swatch.tsx"],"sourcesContent":["import type {\n CSSUIObject,\n CSSUIProps,\n HTMLUIProps,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\n\nconst defaultOverlays = (\n background: CSSUIProps[\"color\"],\n withShadow: boolean,\n): HTMLUIProps[] => {\n let overlays: HTMLUIProps[] = [\n {\n bgImage:\n \"linear-gradient(45deg, $checkers 25%, transparent 25%), linear-gradient(-45deg, $checkers 25%, transparent 25%), linear-gradient(45deg, transparent 75%, $checkers 75%), linear-gradient(-45deg, $body 75%, $checkers 75%)\",\n bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,\n bgSize: `8px 8px`,\n vars: [\n {\n name: \"checkers\",\n token: \"colors\",\n value: [\"blackAlpha.300\", \"whiteAlpha.300\"],\n },\n {\n name: \"body\",\n token: \"colors\",\n value: [\"whiteAlpha.500\", \"blackAlpha.500\"],\n },\n ],\n },\n { background },\n ]\n\n if (withShadow)\n overlays = [\n ...overlays,\n {\n boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`,\n },\n ]\n\n return overlays\n}\n\ninterface ColorSwatchOptions {\n /**\n * The color used for the swatch element.\n *\n * @default \"#ffffff00\"\n */\n color?: CSSUIProps[\"color\"]\n /**\n * If `true`, the color swatch will be perfectly round. Else, it'll be slightly round.\n *\n * @default false\n */\n isRounded?: boolean\n /**\n * The overlay used for the swatch element.\n */\n overlays?: HTMLUIProps[]\n /**\n * If `true`, the swatch element has an inner `box-shadow`.\n *\n * @default true\n */\n withShadow?: boolean\n}\n\nexport interface ColorSwatchProps\n extends Omit<HTMLUIProps, \"color\">,\n ThemeProps<\"ColorSwatch\">,\n ColorSwatchOptions {}\n\n/**\n * `ColorSwatch` is a component that displays color samples.\n *\n * @see Docs https://yamada-ui.com/components/data-display/color-swatch\n */\nexport const ColorSwatch = forwardRef<ColorSwatchProps, \"div\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"ColorSwatch\", props)\n const {\n className,\n color = \"#ffffff00\",\n isRounded,\n withShadow = true,\n overlays = defaultOverlays(color, withShadow),\n __css,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const css: CSSUIObject = {\n \"& > *\": {\n alignItems: \"center\",\n bottom: \"0\",\n display: \"flex\",\n h: \"100%\",\n justifyContent: \"center\",\n left: \"0\",\n overflow: \"hidden\",\n position: \"absolute\",\n right: \"0\",\n top: \"0\",\n w: \"100%\",\n },\n position: \"relative\",\n _before: {\n content: `\"\"`,\n display: \"block\",\n h: 0,\n pb: \"100%\",\n },\n ...styles.container,\n ...__css,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-swatch\", className)}\n aria-roledescription=\"color swatch\"\n role=\"img\"\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n __css={css}\n {...rest}\n >\n <ui.div {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}>\n {overlays.map((props, index) => (\n <ui.div\n key={index}\n __css={{\n bottom: 0,\n left: 0,\n position: \"absolute\",\n right: 0,\n top: 0,\n ...styles.overlay,\n }}\n {...(isRounded ? { rounded: \"fallback(full, 9999px)\" } : {})}\n {...props}\n />\n ))}\n </ui.div>\n </ui.div>\n )\n})\n\nColorSwatch.displayName = \"ColorSwatch\"\nColorSwatch.__ui__ = \"ColorSwatch\"\n"],"mappings":";;;AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AA2HT;AAzHV,IAAM,kBAAkB,CACtB,YACA,eACkB;AAClB,MAAI,WAA0B;AAAA,IAC5B;AAAA,MACE,SACE;AAAA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EAAE,SAAS,yBAAyB,IAAI,CAAC;AAAA,MAC1D,OAAO;AAAA,MACN,GAAG;AAAA,MAEJ,8BAAC,GAAG,KAAH,EAAQ,GAAI,YAAY,EAAE,SAAS,yBAAyB,IAAI,CAAC,GAC/D,mBAAS,IAAI,CAACA,QAAO,UACpB;AAAA,QAAC,GAAG;AAAA,QAAH;AAAA,UAEC,OAAO;AAAA,YACL,QAAQ;AAAA,YACR,MAAM;AAAA,YACN,UAAU;AAAA,YACV,OAAO;AAAA,YACP,KAAK;AAAA,YACL,GAAG,OAAO;AAAA,UACZ;AAAA,UACC,GAAI,YAAY,EAAE,SAAS,yBAAyB,IAAI,CAAC;AAAA,UACzD,GAAGA;AAAA;AAAA,QAVC;AAAA,MAWP,CACD,GACH;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,YAAY,cAAc;AAC1B,YAAY,SAAS;","names":["props"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/use-color-picker.ts"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n PropGetter,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { ComboBoxProps, PopoverProps } from \"@yamada-ui/popover\"\nimport type { ColorFormat } from \"@yamada-ui/utils\"\nimport type {\n ChangeEvent,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} from \"react\"\nimport type { ColorSelectorProps } from \"./color-selector\"\nimport type { UseColorSelectorBaseProps } from \"./use-color-selector\"\nimport { layoutStyleProperties } from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\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 {\n calcFormat,\n convertColor,\n createContext,\n dataAttr,\n getEventRelatedTarget,\n handlerAll,\n isContains,\n mergeRefs,\n pickObject,\n splitObject,\n useUpdateEffect,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useId, useRef, useState } from \"react\"\n\nconst defaultFormatInput = (value: string) => value\n\ntype ColorSelectorThemeProps = ThemeProps<\"ColorSelector\">\n\ninterface ColorPickerContext {\n styles: { [key: string]: CSSUIObject | undefined }\n value: string\n}\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\ninterface UseColorPickerOptions {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, the color swatch will be closed when value is selected.\n */\n closeOnSelectSwatch?: boolean\n /**\n * ColorScheme for the color selector component.\n */\n colorSelectorColorScheme?: ColorSelectorThemeProps[\"colorScheme\"]\n /**\n * Size for the color selector component.\n */\n colorSelectorSize?: ColorSelectorThemeProps[\"size\"]\n /**\n * Variant for the color selector component.\n */\n colorSelectorVariant?: ColorSelectorThemeProps[\"variant\"]\n /**\n * The initial value of the color selector.\n */\n defaultColor?: string\n /**\n * A callback function to format the input entered.\n */\n formatInput?: (value: string) => string\n /**\n * If `true` display the eye dropper component.\n *\n * @default false\n */\n withColorSelectorEyeDropper?: boolean\n /**\n * If `true`, display the result component.\n *\n * @default false\n */\n withResult?: boolean\n /**\n * Props for color selector component.\n */\n colorSelectorProps?: ColorSelectorProps\n}\n\nexport interface UseColorPickerProps\n extends Omit<\n HTMLUIProps<\"input\">,\n | \"animation\"\n | \"children\"\n | \"defaultValue\"\n | \"offset\"\n | \"onChange\"\n | \"size\"\n | \"value\"\n >,\n Omit<UseColorSelectorBaseProps, \"id\" | \"name\">,\n ComboBoxProps,\n Pick<\n ColorSelectorProps,\n | \"swatches\"\n | \"swatchesColumns\"\n | \"swatchesLabel\"\n | \"withChannel\"\n | \"withPicker\"\n >,\n UseColorPickerOptions {}\n\nexport const useColorPicker = (props: UseColorPickerProps) => {\n let {\n id,\n allowInput = true,\n animation,\n boundary,\n closeDelay,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnSelectSwatch,\n colorSelectorColorScheme,\n colorSelectorSize,\n colorSelectorVariant,\n defaultColor,\n defaultIsOpen,\n defaultValue,\n duration = 0.2,\n eventListeners,\n fallbackValue,\n flip,\n format,\n formatInput = defaultFormatInput,\n gutter,\n isLazy,\n isOpen: isOpenProp,\n lazyBehavior,\n matchWidth = colorSelectorSize === \"full\",\n modifiers,\n offset,\n openDelay,\n placement = \"bottom-start\",\n preventOverflow,\n strategy,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value: valueProp,\n withChannel,\n withColorSelectorEyeDropper = false,\n withPicker,\n withResult = false,\n onChange: onChangeProp,\n onChangeEnd,\n onChangeStart,\n onClick,\n onClose: onCloseProp,\n onKeyDown,\n onOpen: onOpenProp,\n onSwatchClick,\n ...rest\n } = useFormControlProps(props)\n const {\n \"aria-readonly\": _ariaReadonly,\n onBlur,\n onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const { disabled, readOnly } = formControlProps\n const [containerProps, inputProps] = splitObject(rest, layoutStyleProperties)\n const containerRef = useRef<HTMLDivElement>(null)\n const fieldRef = useRef<HTMLInputElement>(null)\n const { supported: eyeDropperSupported, onOpen: onEyeDropperOpen } =\n useEyeDropper()\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\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 onClose: onInternalClose,\n onOpen: onInternalOpen,\n } = useDisclosure({\n defaultIsOpen,\n isOpen: isOpenProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const uuid = useId()\n\n id ??= uuid\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: { [key: string]: Function | undefined } = {\n Enter: !isOpen ? onOpen : undefined,\n Escape: closeOnEsc ? onClose : undefined,\n Space: !isOpen ? onOpen : 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 enabled: isOpen && closeOnBlur,\n handler: onClose,\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 animation,\n boundary,\n closeDelay,\n closeOnBlur,\n duration,\n eventListeners,\n flip,\n gutter,\n isLazy,\n lazyBehavior,\n matchWidth,\n modifiers,\n offset,\n openDelay,\n placement,\n preventOverflow,\n strategy,\n ...props,\n closeOnButton: false,\n isOpen,\n trigger: \"never\",\n onClose,\n onOpen,\n }),\n [\n closeOnBlur,\n openDelay,\n closeDelay,\n isLazy,\n lazyBehavior,\n animation,\n duration,\n offset,\n gutter,\n preventOverflow,\n flip,\n matchWidth,\n boundary,\n eventListeners,\n strategy,\n placement,\n modifiers,\n isOpen,\n onOpen,\n onClose,\n ],\n )\n\n const getContainerProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n ref: mergeRefs(containerRef, ref),\n ...containerProps,\n ...props,\n ...formControlProps,\n onBlur: handlerAll(props.onBlur, onBlur, onContainerBlur),\n onClick: handlerAll(props.onClick, onClick, onContainerClick),\n }),\n [\n containerProps,\n formControlProps,\n onBlur,\n onClick,\n onContainerBlur,\n onContainerClick,\n ],\n )\n\n const getFieldProps: PropGetter = useCallback(\n (props = {}, ref = null) => ({\n \"aria-expanded\": dataAttr(isOpen),\n \"data-active\": dataAttr(isOpen),\n \"data-not-allowed\": dataAttr(!readOnly && !disabled && !allowInput),\n tabIndex: !allowInput ? -1 : 0,\n ...formControlProps,\n ...props,\n ref: mergeRefs(fieldRef, ref),\n onBlur: handlerAll(props.onFocus, onInputBlur),\n onFocus: handlerAll(props.onFocus, onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown, onInputKeyDown),\n }),\n [\n allowInput,\n formControlProps,\n isOpen,\n readOnly,\n disabled,\n onInputBlur,\n onFocus,\n onInputFocus,\n onKeyDown,\n onInputKeyDown,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => {\n const style: CSSProperties = {\n ...props.style,\n ...inputProps.style,\n ...(disabled || !allowInput ? { pointerEvents: \"none\" } : {}),\n }\n\n return {\n \"aria-controls\": id,\n role: \"combobox\",\n tabIndex: !allowInput ? -1 : 0,\n ...formControlProps,\n ...inputProps,\n ...props,\n ref,\n style,\n value: inputValue,\n onChange: handlerAll(props.onChange, onInputChange),\n }\n },\n [\n id,\n inputProps,\n allowInput,\n disabled,\n formControlProps,\n inputValue,\n onInputChange,\n ],\n )\n\n const getEyeDropperProps: PropGetter<\"button\"> = useCallback(\n (props = {}, ref = null) => ({\n \"aria-label\": \"Pick a color\",\n disabled,\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: PropGetter<ColorSelectorProps> = useCallback(\n (props) => ({\n ...formControlProps,\n ...props,\n colorScheme: colorSelectorColorScheme,\n size: colorSelectorSize,\n variant: colorSelectorVariant,\n defaultValue: defaultColor,\n fallbackValue,\n format: formatRef.current,\n swatches,\n swatchesColumns,\n swatchesLabel,\n value,\n withChannel,\n withEyeDropper: withColorSelectorEyeDropper,\n withPicker,\n withResult,\n onChange: onColorSelectorChange,\n onChangeEnd,\n onChangeStart,\n onSwatchClick: handlerAll(\n onSwatchClick,\n closeOnSelectSwatch ? onClose : undefined,\n ),\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 id,\n allowInput,\n eyeDropperSupported,\n value,\n getContainerProps,\n getEyeDropperProps,\n getFieldProps,\n getInputProps,\n getPopoverProps,\n getSelectorProps,\n onClose,\n }\n}\n\nexport type UseColorPickerReturn = ReturnType<typeof useColorPicker>\n"],"mappings":";;;AAiBA,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,OAAO,QAAQ,gBAAgB;AAErD,IAAM,qBAAqB,CAAC,UAAkB;AASvC,IAAM,CAAC,qBAAqB,qBAAqB,IACtD,cAAkC;AAAA,EAChC,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AA0EI,IAAM,iBAAiB,CAAC,UAA+B;AAC5D,MAAI;AAAA,IACF;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA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,EAAE,GAAGA,OAAM,OAAO,eAAe,WAAW,SAAS,OAAU;AAAA,MACtE,SAAS,WAAWA,OAAM,SAAS,iBAAiB;AAAA,IACtD;AAAA,IACA,CAAC,UAAU,mBAAmB,QAAQ;AAAA,EACxC;AAEA,QAAM,mBAAmD;AAAA,IACvD,CAACA,YAAW;AAAA,MACV,GAAG;AAAA,MACH,GAAGA;AAAA,MACH,aAAa;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,cAAc;AAAA,MACd;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACb;AAAA,QACA,sBAAsB,UAAU;AAAA,MAClC;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,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["value","props"]}
|
File without changes
|
File without changes
|
File without changes
|