@yamada-ui/color-picker 2.0.0-next-20240614140233 → 2.0.0-next-20240615233332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/dist/alpha-slider.js +14 -25
  2. package/dist/alpha-slider.js.map +1 -1
  3. package/dist/alpha-slider.mjs +2 -2
  4. package/dist/{chunk-OTNMOPLH.mjs → chunk-27BXTC5D.mjs} +4 -4
  5. package/dist/{chunk-C7IY5KVP.mjs → chunk-2K4SHOHA.mjs} +2 -2
  6. package/dist/{chunk-DDHDVGOQ.mjs → chunk-7L64OYDQ.mjs} +2 -2
  7. package/dist/{chunk-UBSVLXYF.mjs → chunk-ABDJB4WV.mjs} +3 -4
  8. package/dist/{chunk-UBSVLXYF.mjs.map → chunk-ABDJB4WV.mjs.map} +1 -1
  9. package/dist/{chunk-KKQ3MOXJ.mjs → chunk-KKUDFHCJ.mjs} +15 -26
  10. package/dist/{chunk-KKQ3MOXJ.mjs.map → chunk-KKUDFHCJ.mjs.map} +1 -1
  11. package/dist/{chunk-HEBLEXJG.mjs → chunk-MPWT2DSW.mjs} +6 -6
  12. package/dist/{chunk-6CYIIW6Z.mjs → chunk-MXH5UN5E.mjs} +2 -2
  13. package/dist/{chunk-X7R6FWCD.mjs → chunk-PCXNTEF4.mjs} +2 -2
  14. package/dist/{chunk-SBN7FEOE.mjs → chunk-PVPQQB6L.mjs} +16 -31
  15. package/dist/{chunk-SBN7FEOE.mjs.map → chunk-PVPQQB6L.mjs.map} +1 -1
  16. package/dist/{chunk-YE3Z2X2L.mjs → chunk-RWVTJOMP.mjs} +4 -4
  17. package/dist/{chunk-5QT7SRA4.mjs → chunk-UZQ2UORY.mjs} +18 -35
  18. package/dist/{chunk-5QT7SRA4.mjs.map → chunk-UZQ2UORY.mjs.map} +1 -1
  19. package/dist/{chunk-R4DLOKLT.mjs → chunk-WRHKYN3W.mjs} +15 -26
  20. package/dist/{chunk-R4DLOKLT.mjs.map → chunk-WRHKYN3W.mjs.map} +1 -1
  21. package/dist/{chunk-NJEVZQVF.mjs → chunk-YPW3ZJM7.mjs} +5 -6
  22. package/dist/{chunk-NJEVZQVF.mjs.map → chunk-YPW3ZJM7.mjs.map} +1 -1
  23. package/dist/{chunk-LHNR2F5V.mjs → chunk-ZHZRZ3XZ.mjs} +2 -2
  24. package/dist/color-picker.js +62 -118
  25. package/dist/color-picker.js.map +1 -1
  26. package/dist/color-picker.mjs +14 -14
  27. package/dist/color-selector-body.js +15 -27
  28. package/dist/color-selector-body.js.map +1 -1
  29. package/dist/color-selector-body.mjs +7 -7
  30. package/dist/color-selector-channels.js +1 -2
  31. package/dist/color-selector-channels.js.map +1 -1
  32. package/dist/color-selector-channels.mjs +2 -2
  33. package/dist/color-selector-eye-dropper.mjs +2 -2
  34. package/dist/color-selector-sliders.js +15 -27
  35. package/dist/color-selector-sliders.js.map +1 -1
  36. package/dist/color-selector-sliders.mjs +5 -5
  37. package/dist/color-selector-swatches.mjs +2 -2
  38. package/dist/color-selector.js +47 -88
  39. package/dist/color-selector.js.map +1 -1
  40. package/dist/color-selector.mjs +12 -12
  41. package/dist/hue-slider.js +14 -25
  42. package/dist/hue-slider.js.map +1 -1
  43. package/dist/hue-slider.mjs +2 -2
  44. package/dist/index.js +62 -118
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +14 -14
  47. package/dist/saturation-slider.js +14 -25
  48. package/dist/saturation-slider.js.map +1 -1
  49. package/dist/saturation-slider.mjs +2 -2
  50. package/dist/use-color-picker.js +15 -30
  51. package/dist/use-color-picker.js.map +1 -1
  52. package/dist/use-color-picker.mjs +1 -1
  53. package/dist/use-color-selector.js +17 -34
  54. package/dist/use-color-selector.js.map +1 -1
  55. package/dist/use-color-selector.mjs +1 -1
  56. package/dist/use-color-slider.js +14 -25
  57. package/dist/use-color-slider.js.map +1 -1
  58. package/dist/use-color-slider.mjs +1 -1
  59. package/dist/use-saturation-slider.js +14 -25
  60. package/dist/use-saturation-slider.js.map +1 -1
  61. package/dist/use-saturation-slider.mjs +1 -1
  62. package/package.json +15 -15
  63. /package/dist/{chunk-OTNMOPLH.mjs.map → chunk-27BXTC5D.mjs.map} +0 -0
  64. /package/dist/{chunk-C7IY5KVP.mjs.map → chunk-2K4SHOHA.mjs.map} +0 -0
  65. /package/dist/{chunk-DDHDVGOQ.mjs.map → chunk-7L64OYDQ.mjs.map} +0 -0
  66. /package/dist/{chunk-HEBLEXJG.mjs.map → chunk-MPWT2DSW.mjs.map} +0 -0
  67. /package/dist/{chunk-6CYIIW6Z.mjs.map → chunk-MXH5UN5E.mjs.map} +0 -0
  68. /package/dist/{chunk-X7R6FWCD.mjs.map → chunk-PCXNTEF4.mjs.map} +0 -0
  69. /package/dist/{chunk-YE3Z2X2L.mjs.map → chunk-RWVTJOMP.mjs.map} +0 -0
  70. /package/dist/{chunk-LHNR2F5V.mjs.map → chunk-ZHZRZ3XZ.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-color-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB;AAAA,EACE;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;AAiEvC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,qBAAqB;AAAA,EACrB,GAAG;AACL,MAA2B;AACzB,MAAI,CAAC;AAAoB,UAAM,aAAa;AAE5C,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,IACf,aAAa;AAAA,IACb;AAAA,IACA;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d,IAAI,kCAAc,OAAO,KAAK;AAAA,QAC9B,GAAG,WAAW,MAAM,qBAAqB;AAAA,QACzC,GAAGA;AAAA,QACH,KAAK,UAAU,KAAK,QAAQ;AAAA,QAC5B,UAAU,iBAAiB,qBAAqB,IAAI;AAAA,QACpD,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,eAAe,SAAS,cAAc,kBAAkB;AAAA,QACxD,WAAW,WAAWA,OAAM,WAAW,SAAS;AAAA,QAChD,SAAS,WAAWA,OAAM,SAAS,KAAK,OAAO;AAAA,QAC/C,QAAQ,WAAWA,OAAM,QAAQ,KAAK,MAAM;AAAA,QAC5C;AAAA,MACF;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,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["min","max","step","value","focusThumbOnChange","isInteractive","props"]}
1
+ {"version":3,"sources":["../src/use-color-slider.ts"],"sourcesContent":["import type { CSSUIProps, HTMLUIProps, UIPropGetter } from \"@yamada-ui/core\"\nimport {\n useFormControlProps,\n type FormControlOptions,\n formControlProperties,\n getFormControlProperties,\n} from \"@yamada-ui/form-control\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { useLatestRef } from \"@yamada-ui/use-latest-ref\"\nimport { usePanEvent } from \"@yamada-ui/use-pan-event\"\nimport { useSize } from \"@yamada-ui/use-size\"\nimport {\n omitObject,\n dataAttr,\n handlerAll,\n mergeRefs,\n valueToPercent,\n clampNumber,\n useCallbackRef,\n roundNumberToStep,\n useUpdateEffect,\n percentToValue,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { CSSProperties, KeyboardEvent, KeyboardEventHandler } from \"react\"\nimport { useCallback, useRef, useState } from \"react\"\n\ntype UseColorSliderOptions = {\n /**\n * The base `id` to use for the slider.\n */\n id?: string\n /**\n * The name attribute of the hidden `input` field.\n * This is particularly useful in forms.\n */\n name?: string\n /**\n * The value of the slider.\n */\n value?: number\n /**\n * The initial value of the slider.\n */\n defaultValue?: number\n /**\n * The minimum allowed value of the slider. Cannot be greater than max.\n */\n min: number\n /**\n * The maximum allowed value of the slider. Cannot be less than min.\n */\n max: number\n /**\n * The step in which increments or decrements have to be made.\n *\n * @default 1\n */\n step?: number\n /**\n * Function called whenever the slider value changes.\n */\n onChange?: (value: number) => void\n /**\n * Function called when the user starts selecting a new value.\n */\n onChangeStart?: (value: number) => void\n /**\n * Function called when the user is done selecting a new value.\n */\n onChangeEnd?: (value: number) => void\n /**\n * If `false`, the slider handle will not capture focus when value changes.\n *\n * @default true\n */\n focusThumbOnChange?: boolean\n /**\n * The CSS `background` property. Used in `background` of thumb element.\n */\n thumbColor?: CSSUIProps[\"bg\"]\n}\n\nexport type UseColorSliderProps = Omit<\n HTMLUIProps<\"div\">,\n \"defaultValue\" | \"onChange\"\n> &\n UseColorSliderOptions &\n FormControlOptions\n\nexport const useColorSlider = ({\n focusThumbOnChange = true,\n ...props\n}: UseColorSliderProps) => {\n if (!focusThumbOnChange) props.isReadOnly = true\n\n let {\n id,\n name,\n value: valueProp,\n defaultValue,\n min = 0,\n max,\n step = 1,\n onChange: onChangeProp,\n onChangeStart: onChangeStartProp,\n onChangeEnd: onChangeEndProp,\n thumbColor,\n required,\n disabled,\n readOnly,\n ...rest\n } = useFormControlProps(props)\n\n const onChangeStart = useCallbackRef(onChangeStartProp)\n const onChangeEnd = useCallbackRef(onChangeEndProp)\n\n const [computedValue, setValue] = useControllableState({\n value: valueProp,\n defaultValue: defaultValue ?? min + (max - min) / 2,\n onChange: onChangeProp,\n })\n const value = clampNumber(computedValue, min, max)\n const thumbPercent = valueToPercent(value, min, max)\n const [isDragging, setDragging] = useState(false)\n const isInteractive = !(disabled || readOnly)\n\n const oneStep = step || (max - min) / 100\n const tenStep = (max - min) / 10\n\n const containerRef = useRef<HTMLElement>(null)\n const trackRef = useRef<HTMLElement>(null)\n const thumbRef = useRef<HTMLElement>(null)\n const latestRef = useLatestRef({\n value,\n min,\n max,\n step,\n isInteractive,\n eventSource: null as \"pointer\" | \"keyboard\" | null,\n focusThumbOnChange,\n })\n\n const thumbSize = useSize(thumbRef)\n\n const getValueFromPointer = useCallback(\n (ev: any) => {\n if (!trackRef.current) return\n\n const { min, max, step } = latestRef.current\n\n latestRef.current.eventSource = \"pointer\"\n\n const { left, width } = trackRef.current.getBoundingClientRect()\n const { clientX } = ev.touches?.[0] ?? ev\n\n let percent = (clientX - left) / width\n\n let nextValue = percentToValue(percent, min, max)\n\n if (step) nextValue = parseFloat(roundNumberToStep(nextValue, min, step))\n\n nextValue = clampNumber(nextValue, min, max)\n\n return nextValue\n },\n [latestRef],\n )\n\n const setValueFromPointer = (ev: MouseEvent | TouchEvent | PointerEvent) => {\n const { value } = latestRef.current\n const nextValue = getValueFromPointer(ev)\n\n if (nextValue != null && nextValue !== value) setValue(nextValue)\n }\n\n const focusThumb = useCallback(() => {\n const { focusThumbOnChange } = latestRef.current\n\n if (focusThumbOnChange) setTimeout(() => thumbRef.current?.focus())\n }, [latestRef])\n\n const constrain = useCallback(\n (value: number) => {\n const { isInteractive, min, max } = latestRef.current\n\n if (!isInteractive) return\n\n value = parseFloat(roundNumberToStep(value, min, oneStep))\n value = clampNumber(value, min, max)\n\n setValue(value)\n },\n [setValue, latestRef, oneStep],\n )\n\n const stepUp = useCallback(\n (step = oneStep) => constrain(value + step),\n [constrain, value, oneStep],\n )\n\n const stepDown = useCallback(\n (step = oneStep) => constrain(value - step),\n [constrain, value, oneStep],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n const { min, max } = latestRef.current\n\n const actions: Record<string, KeyboardEventHandler> = {\n ArrowRight: () => stepUp(),\n ArrowUp: () => stepUp(),\n ArrowLeft: () => stepDown(),\n ArrowDown: () => stepDown(),\n PageUp: () => stepUp(tenStep),\n PageDown: () => stepDown(tenStep),\n Home: () => constrain(min),\n End: () => constrain(max),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n ev.stopPropagation()\n\n action(ev)\n\n latestRef.current.eventSource = \"keyboard\"\n },\n [constrain, latestRef, stepDown, stepUp, tenStep],\n )\n\n usePanEvent(containerRef, {\n onSessionStart: (ev) => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(true)\n focusThumb()\n setValueFromPointer(ev)\n onChangeStart(value)\n },\n onSessionEnd: () => {\n const { isInteractive, value } = latestRef.current\n\n if (!isInteractive) return\n\n setDragging(false)\n onChangeEnd(value)\n },\n onMove: (ev) => {\n const { isInteractive } = latestRef.current\n\n if (!isInteractive) return\n\n setValueFromPointer(ev)\n },\n })\n\n useUpdateEffect(() => {\n const { eventSource, value } = latestRef.current\n\n if (eventSource === \"keyboard\") onChangeEnd(value)\n }, [value, onChangeEnd])\n\n const getContainerProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n ...rest.style,\n paddingInline: `${w / 2}px`,\n }\n\n return {\n ...props,\n ...omitObject(rest, [\"aria-readonly\"]),\n ref: mergeRefs(ref, containerRef),\n tabIndex: -1,\n style,\n }\n },\n [rest, thumbSize],\n )\n\n const getInputProps: UIPropGetter<\"input\"> = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(rest, formControlProperties),\n ...props,\n id,\n ref,\n type: \"hidden\",\n name,\n value,\n required,\n disabled,\n readOnly,\n }),\n [disabled, id, name, readOnly, required, rest, value],\n )\n\n const getTrackProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => ({\n ...pickObject(\n rest,\n getFormControlProperties({ omit: [\"aria-readonly\"] }),\n ),\n ...props,\n ref: mergeRefs(ref, trackRef),\n }),\n [rest],\n )\n\n const getThumbProps: UIPropGetter = useCallback(\n (props = {}, ref = null) => {\n const n = thumbPercent\n const { width: w } = thumbSize ?? { width: 0 }\n\n const style: CSSProperties = {\n ...props.style,\n position: \"absolute\",\n userSelect: \"none\",\n touchAction: \"none\",\n left: `calc(${n}% - ${w / 2}px)`,\n }\n\n return {\n \"aria-label\": \"Slider thumb\",\n bg: thumbColor ?? `hsl(${value}, 100%, 50%)`,\n ...pickObject(rest, formControlProperties),\n ...props,\n ref: mergeRefs(ref, thumbRef),\n tabIndex: isInteractive && focusThumbOnChange ? 0 : undefined,\n role: \"slider\",\n \"aria-valuenow\": value,\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"data-active\": dataAttr(isDragging && focusThumbOnChange),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onFocus: handlerAll(props.onFocus, rest.onFocus),\n onBlur: handlerAll(props.onBlur, rest.onBlur),\n style,\n }\n },\n [\n thumbColor,\n focusThumbOnChange,\n isDragging,\n isInteractive,\n min,\n max,\n onKeyDown,\n rest,\n thumbPercent,\n thumbSize,\n value,\n ],\n )\n\n return {\n value,\n getContainerProps,\n getTrackProps,\n getInputProps,\n getThumbProps,\n }\n}\n\nexport type UseColorSliderReturn = ReturnType<typeof useColorSlider>\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB;AAAA,EACE;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;AAiEvC,IAAM,iBAAiB,CAAC;AAAA,EAC7B,qBAAqB;AAAA,EACrB,GAAG;AACL,MAA2B;AACzB,MAAI,CAAC,mBAAoB,OAAM,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AAuB;AAAA,QAC3B,GAAGA,OAAM;AAAA,QACT,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,aAAa;AAAA,QACb,MAAM,QAAQ,CAAC,OAAO,IAAI,CAAC;AAAA,MAC7B;AAEA,aAAO;AAAA,QACL,cAAc;AAAA,QACd,IAAI,kCAAc,OAAO,KAAK;AAAA,QAC9B,GAAG,WAAW,MAAM,qBAAqB;AAAA,QACzC,GAAGA;AAAA,QACH,KAAK,UAAU,KAAK,QAAQ;AAAA,QAC5B,UAAU,iBAAiB,qBAAqB,IAAI;AAAA,QACpD,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,eAAe,SAAS,cAAc,kBAAkB;AAAA,QACxD,WAAW,WAAWA,OAAM,WAAW,SAAS;AAAA,QAChD,SAAS,WAAWA,OAAM,SAAS,KAAK,OAAO;AAAA,QAC/C,QAAQ,WAAWA,OAAM,QAAQ,KAAK,MAAM;AAAA,QAC5C;AAAA,MACF;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,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["min","max","step","value","focusThumbOnChange","isInteractive","props"]}
@@ -1,13 +1,13 @@
1
1
  "use client"
2
2
  import {
3
3
  HueSlider
4
- } from "./chunk-DDHDVGOQ.mjs";
4
+ } from "./chunk-7L64OYDQ.mjs";
5
5
  import {
6
6
  AlphaSlider
7
- } from "./chunk-LHNR2F5V.mjs";
7
+ } from "./chunk-ZHZRZ3XZ.mjs";
8
8
  import {
9
9
  useColorSelectorContext
10
- } from "./chunk-5QT7SRA4.mjs";
10
+ } from "./chunk-UZQ2UORY.mjs";
11
11
 
12
12
  // src/color-selector-sliders.tsx
13
13
  import { forwardRef, ui } from "@yamada-ui/core";
@@ -23,8 +23,7 @@ var ColorSelectorSliders = forwardRef(
23
23
  ...rest
24
24
  }, ref) => {
25
25
  let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorSelectorContext();
26
- if (size === "full")
27
- size = "lg";
26
+ if (size === "full") size = "lg";
28
27
  const css = {
29
28
  ...styles.sliders
30
29
  };
@@ -63,4 +62,4 @@ var ColorSelectorSliders = forwardRef(
63
62
  export {
64
63
  ColorSelectorSliders
65
64
  };
66
- //# sourceMappingURL=chunk-NJEVZQVF.mjs.map
65
+ //# sourceMappingURL=chunk-YPW3ZJM7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/color-selector-sliders.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport { AlphaSlider } from \"./alpha-slider\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport { HueSlider } from \"./hue-slider\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorSlidersOptions = {\n /**\n * Ref for the hue slider component.\n */\n hueSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the hue slider component.\n */\n hueSliderProps?: Omit<HueSliderProps, \"value\" | \"defaultValue\">\n /**\n * Ref for the alpha slider component.\n */\n alphaSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the alpha slider component.\n */\n alphaSliderProps?: Omit<AlphaSliderProps, \"value\" | \"defaultValue\">\n}\n\nexport type ColorSelectorSlidersProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorSlidersOptions\n\nexport const ColorSelectorSliders = forwardRef<\n ColorSelectorSlidersProps,\n \"div\"\n>(\n (\n {\n className,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } =\n useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = {\n ...styles.sliders,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__sliders\", className)}\n __css={css}\n {...rest}\n >\n <HueSlider\n size={size}\n className=\"ui-color-selector__hue-slider\"\n __css={{ ...styles.hueSlider }}\n {...getHueSliderProps(hueSliderProps, hueSliderRef)}\n />\n\n {withAlpha ? (\n <AlphaSlider\n size={size}\n className=\"ui-color-selector__alpha-slider\"\n __css={{ ...styles.alphaSlider }}\n {...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,YAAY,UAAU;AAE/B,SAAS,UAAU;AAuDb,SAME,KANF;AAzBC,IAAM,uBAAuB;AAAA,EAIlC,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,EAAE,MAAM,WAAW,mBAAmB,qBAAqB,OAAO,IACpE,wBAAwB;AAE1B,QAAI,SAAS;AAAQ,aAAO;AAE5B,UAAM,MAAmB;AAAA,MACvB,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAW,GAAG,8BAA8B,SAAS;AAAA,QACrD,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,UAAU;AAAA,cAC5B,GAAG,kBAAkB,gBAAgB,YAAY;AAAA;AAAA,UACpD;AAAA,UAEC,YACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,YAAY;AAAA,cAC9B,GAAG,oBAAoB,kBAAkB,cAAc;AAAA;AAAA,UAC1D,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/color-selector-sliders.tsx"],"sourcesContent":["import { forwardRef, ui } from \"@yamada-ui/core\"\nimport type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport type { ForwardedRef } from \"react\"\nimport type { AlphaSliderProps } from \"./alpha-slider\"\nimport { AlphaSlider } from \"./alpha-slider\"\nimport type { HueSliderProps } from \"./hue-slider\"\nimport { HueSlider } from \"./hue-slider\"\nimport { useColorSelectorContext } from \"./use-color-selector\"\n\ntype ColorSelectorSlidersOptions = {\n /**\n * Ref for the hue slider component.\n */\n hueSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the hue slider component.\n */\n hueSliderProps?: Omit<HueSliderProps, \"value\" | \"defaultValue\">\n /**\n * Ref for the alpha slider component.\n */\n alphaSliderRef?: ForwardedRef<HTMLInputElement>\n /**\n * Props for the alpha slider component.\n */\n alphaSliderProps?: Omit<AlphaSliderProps, \"value\" | \"defaultValue\">\n}\n\nexport type ColorSelectorSlidersProps = Omit<HTMLUIProps<\"div\">, \"children\"> &\n ColorSelectorSlidersOptions\n\nexport const ColorSelectorSliders = forwardRef<\n ColorSelectorSlidersProps,\n \"div\"\n>(\n (\n {\n className,\n hueSliderRef,\n hueSliderProps,\n alphaSliderRef,\n alphaSliderProps,\n ...rest\n },\n ref,\n ) => {\n let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } =\n useColorSelectorContext()\n\n if (size === \"full\") size = \"lg\"\n\n const css: CSSUIObject = {\n ...styles.sliders,\n }\n\n return (\n <ui.div\n ref={ref}\n className={cx(\"ui-color-selector__sliders\", className)}\n __css={css}\n {...rest}\n >\n <HueSlider\n size={size}\n className=\"ui-color-selector__hue-slider\"\n __css={{ ...styles.hueSlider }}\n {...getHueSliderProps(hueSliderProps, hueSliderRef)}\n />\n\n {withAlpha ? (\n <AlphaSlider\n size={size}\n className=\"ui-color-selector__alpha-slider\"\n __css={{ ...styles.alphaSlider }}\n {...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)}\n />\n ) : null}\n </ui.div>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,YAAY,UAAU;AAE/B,SAAS,UAAU;AAuDb,SAME,KANF;AAzBC,IAAM,uBAAuB;AAAA,EAIlC,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,QAAI,EAAE,MAAM,WAAW,mBAAmB,qBAAqB,OAAO,IACpE,wBAAwB;AAE1B,QAAI,SAAS,OAAQ,QAAO;AAE5B,UAAM,MAAmB;AAAA,MACvB,GAAG,OAAO;AAAA,IACZ;AAEA,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,WAAW,GAAG,8BAA8B,SAAS;AAAA,QACrD,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,UAAU;AAAA,cAC5B,GAAG,kBAAkB,gBAAgB,YAAY;AAAA;AAAA,UACpD;AAAA,UAEC,YACC;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,WAAU;AAAA,cACV,OAAO,EAAE,GAAG,OAAO,YAAY;AAAA,cAC9B,GAAG,oBAAoB,kBAAkB,cAAc;AAAA;AAAA,UAC1D,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useColorSlider
4
- } from "./chunk-R4DLOKLT.mjs";
4
+ } from "./chunk-WRHKYN3W.mjs";
5
5
 
6
6
  // src/alpha-slider.tsx
7
7
  import {
@@ -119,4 +119,4 @@ var AlphaSlider = forwardRef(
119
119
  export {
120
120
  AlphaSlider
121
121
  };
122
- //# sourceMappingURL=chunk-LHNR2F5V.mjs.map
122
+ //# sourceMappingURL=chunk-ZHZRZ3XZ.mjs.map
@@ -53,21 +53,16 @@ var import_react = require("react");
53
53
  var convertHsla = (value, fallback) => {
54
54
  var _a;
55
55
  let [h, s, l, a] = (_a = (0, import_utils.parseToHsla)(value, fallback)) != null ? _a : [0, 0, 1, 1];
56
- if (a > 1)
57
- a = 1;
56
+ if (a > 1) a = 1;
58
57
  return { h, s, l, a };
59
58
  };
60
59
  var convertRgba = (value, fallback) => {
61
60
  var _a;
62
61
  let [r, g, b, a] = (_a = (0, import_utils.parseToRgba)(value, fallback)) != null ? _a : [255, 255, 255, 1];
63
- if (r > 255)
64
- r = 255;
65
- if (g > 255)
66
- g = 255;
67
- if (b > 255)
68
- b = 255;
69
- if (a > 1)
70
- a = 1;
62
+ if (r > 255) r = 255;
63
+ if (g > 255) g = 255;
64
+ if (b > 255) b = 255;
65
+ if (a > 1) a = 1;
71
66
  return { r, g, b, a };
72
67
  };
73
68
  var convertHsva = (value, fallback) => {
@@ -187,8 +182,7 @@ var useColorSelector = ({
187
182
  isDraggingRef.current = true;
188
183
  const { h: h2, s: s2, v: v2, a: a2 } = { ...parsedValue, ...value2 };
189
184
  const nextValue = (0, import_utils.hsvTo)([h2, s2, v2, a2], fallbackValue)(formatRef.current);
190
- if (nextValue)
191
- onChangeStartRef(nextValue);
185
+ if (nextValue) onChangeStartRef(nextValue);
192
186
  },
193
187
  [formatRef, onChangeStartRef, fallbackValue, parsedValue]
194
188
  );
@@ -205,18 +199,15 @@ var useColorSelector = ({
205
199
  const { h: h2, s: s2, v: v2, a: a2 } = { ...parsedValue, ...value2 };
206
200
  nextValue = (0, import_utils.hsvTo)([h2, s2, v2, a2], fallbackValue)(formatRef.current);
207
201
  }
208
- if (nextValue)
209
- onChangeEndRef(nextValue);
202
+ if (nextValue) onChangeEndRef(nextValue);
210
203
  },
211
204
  [formatRef, onChangeEndRef, fallbackValue, parsedValue]
212
205
  );
213
206
  const onChannelChange = (0, import_react.useCallback)(
214
207
  (ev, space) => {
215
208
  let n = Math.floor(parseFloat(ev.target.value));
216
- if (isNaN(n))
217
- n = 0;
218
- if (["s", "l", "a"].includes(space))
219
- n = n / 100;
209
+ if (isNaN(n)) n = 0;
210
+ if (["s", "l", "a"].includes(space)) n = n / 100;
220
211
  let nextValue;
221
212
  if (resolvedValue.startsWith("hsl")) {
222
213
  const { h: h2, s: s2, l, a: a2 } = Object.assign(
@@ -231,8 +222,7 @@ var useColorSelector = ({
231
222
  );
232
223
  nextValue = (0, import_utils.rgbaTo)([r, g, b, a2], fallbackValue)(formatRef.current);
233
224
  }
234
- if (!nextValue)
235
- return;
225
+ if (!nextValue) return;
236
226
  onChange(nextValue);
237
227
  onChangeEnd(nextValue);
238
228
  },
@@ -242,8 +232,7 @@ var useColorSelector = ({
242
232
  var _a;
243
233
  try {
244
234
  const { sRGBHex } = (_a = await onOpen()) != null ? _a : {};
245
- if (!sRGBHex)
246
- return;
235
+ if (!sRGBHex) return;
247
236
  onChange(sRGBHex);
248
237
  onChangeEnd(sRGBHex);
249
238
  } catch {
@@ -251,22 +240,17 @@ var useColorSelector = ({
251
240
  }, [onOpen, onChange, onChangeEnd]);
252
241
  (0, import_utils.useUpdateEffect)(() => {
253
242
  const nextValue = (0, import_utils.hsvTo)([h, s, v, a], fallbackValue)(formatRef.current);
254
- if (nextValue)
255
- setValue(nextValue);
243
+ if (nextValue) setValue(nextValue);
256
244
  }, [h, s, v, a]);
257
245
  (0, import_utils.useUpdateEffect)(() => {
258
- if (isDraggingRef.current)
259
- return;
260
- if (valueProp)
261
- setParsedValue(convertHsva(valueProp, fallbackValue));
246
+ if (isDraggingRef.current) return;
247
+ if (valueProp) setParsedValue(convertHsva(valueProp, fallbackValue));
262
248
  }, [valueProp]);
263
249
  (0, import_utils.useUpdateEffect)(() => {
264
- if (!format || !value)
265
- return;
250
+ if (!format || !value) return;
266
251
  formatRef.current = format;
267
252
  const nextValue = (0, import_utils.convertColor)(value, fallbackValue)(format);
268
- if (nextValue)
269
- setValue(nextValue);
253
+ if (nextValue) setValue(nextValue);
270
254
  }, [format]);
271
255
  const getContainerProps = (props2 = {}, ref = null) => ({
272
256
  ...props2,
@@ -418,8 +402,7 @@ var useColorSelector = ({
418
402
  ref,
419
403
  color,
420
404
  onClick: (0, import_utils.handlerAll)(props2.onClick, () => {
421
- if (!color)
422
- return;
405
+ if (!color) return;
423
406
  onSwatchClick == null ? void 0 : onSwatchClick(color);
424
407
  onChange(color);
425
408
  onChangeEnd(color);
@@ -507,8 +490,7 @@ var useColorSlider = ({
507
490
  focusThumbOnChange = true,
508
491
  ...props
509
492
  }) => {
510
- if (!focusThumbOnChange)
511
- props.isReadOnly = true;
493
+ if (!focusThumbOnChange) props.isReadOnly = true;
512
494
  let {
513
495
  id,
514
496
  name,
@@ -555,16 +537,14 @@ var useColorSlider = ({
555
537
  const getValueFromPointer = (0, import_react2.useCallback)(
556
538
  (ev) => {
557
539
  var _a, _b;
558
- if (!trackRef.current)
559
- return;
540
+ if (!trackRef.current) return;
560
541
  const { min: min2, max: max2, step: step2 } = latestRef.current;
561
542
  latestRef.current.eventSource = "pointer";
562
543
  const { left, width } = trackRef.current.getBoundingClientRect();
563
544
  const { clientX } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
564
545
  let percent = (clientX - left) / width;
565
546
  let nextValue = (0, import_utils3.percentToValue)(percent, min2, max2);
566
- if (step2)
567
- nextValue = parseFloat((0, import_utils3.roundNumberToStep)(nextValue, min2, step2));
547
+ if (step2) nextValue = parseFloat((0, import_utils3.roundNumberToStep)(nextValue, min2, step2));
568
548
  nextValue = (0, import_utils3.clampNumber)(nextValue, min2, max2);
569
549
  return nextValue;
570
550
  },
@@ -573,22 +553,19 @@ var useColorSlider = ({
573
553
  const setValueFromPointer = (ev) => {
574
554
  const { value: value2 } = latestRef.current;
575
555
  const nextValue = getValueFromPointer(ev);
576
- if (nextValue != null && nextValue !== value2)
577
- setValue(nextValue);
556
+ if (nextValue != null && nextValue !== value2) setValue(nextValue);
578
557
  };
579
558
  const focusThumb = (0, import_react2.useCallback)(() => {
580
559
  const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
581
- if (focusThumbOnChange2)
582
- setTimeout(() => {
583
- var _a;
584
- return (_a = thumbRef.current) == null ? void 0 : _a.focus();
585
- });
560
+ if (focusThumbOnChange2) setTimeout(() => {
561
+ var _a;
562
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
563
+ });
586
564
  }, [latestRef]);
587
565
  const constrain = (0, import_react2.useCallback)(
588
566
  (value2) => {
589
567
  const { isInteractive: isInteractive2, min: min2, max: max2 } = latestRef.current;
590
- if (!isInteractive2)
591
- return;
568
+ if (!isInteractive2) return;
592
569
  value2 = parseFloat((0, import_utils3.roundNumberToStep)(value2, min2, oneStep));
593
570
  value2 = (0, import_utils3.clampNumber)(value2, min2, max2);
594
571
  setValue(value2);
@@ -617,8 +594,7 @@ var useColorSlider = ({
617
594
  End: () => constrain(max2)
618
595
  };
619
596
  const action = actions[ev.key];
620
- if (!action)
621
- return;
597
+ if (!action) return;
622
598
  ev.preventDefault();
623
599
  ev.stopPropagation();
624
600
  action(ev);
@@ -629,8 +605,7 @@ var useColorSlider = ({
629
605
  (0, import_use_pan_event.usePanEvent)(containerRef, {
630
606
  onSessionStart: (ev) => {
631
607
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
632
- if (!isInteractive2)
633
- return;
608
+ if (!isInteractive2) return;
634
609
  setDragging(true);
635
610
  focusThumb();
636
611
  setValueFromPointer(ev);
@@ -638,22 +613,19 @@ var useColorSlider = ({
638
613
  },
639
614
  onSessionEnd: () => {
640
615
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
641
- if (!isInteractive2)
642
- return;
616
+ if (!isInteractive2) return;
643
617
  setDragging(false);
644
618
  onChangeEnd(value2);
645
619
  },
646
620
  onMove: (ev) => {
647
621
  const { isInteractive: isInteractive2 } = latestRef.current;
648
- if (!isInteractive2)
649
- return;
622
+ if (!isInteractive2) return;
650
623
  setValueFromPointer(ev);
651
624
  }
652
625
  });
653
626
  (0, import_utils3.useUpdateEffect)(() => {
654
627
  const { eventSource, value: value2 } = latestRef.current;
655
- if (eventSource === "keyboard")
656
- onChangeEnd(value2);
628
+ if (eventSource === "keyboard") onChangeEnd(value2);
657
629
  }, [value, onChangeEnd]);
658
630
  const getContainerProps = (0, import_react2.useCallback)(
659
631
  (props2 = {}, ref = null) => {
@@ -949,8 +921,7 @@ var ColorSelectorSliders = (0, import_core4.forwardRef)(
949
921
  ...rest
950
922
  }, ref) => {
951
923
  let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorSelectorContext();
952
- if (size === "full")
953
- size = "lg";
924
+ if (size === "full") size = "lg";
954
925
  const css = {
955
926
  ...styles.sliders
956
927
  };
@@ -1146,8 +1117,7 @@ var ColorSelectorChannels = (0, import_core7.forwardRef)(({ className, channelPr
1146
1117
  var ColorSelectorChannel = (0, import_core7.forwardRef)(({ className, channelLabel, ...rest }, ref) => {
1147
1118
  const id = (0, import_react3.useId)();
1148
1119
  let { size, disabled, readOnly, styles } = useColorSelectorContext();
1149
- if (size === "full")
1150
- size = "lg";
1120
+ if (size === "full") size = "lg";
1151
1121
  const css = { ...styles.channel };
1152
1122
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { className: (0, import_utils9.cx)("ui-color-selector__channel", className), children: [
1153
1123
  channelLabel ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -1254,8 +1224,7 @@ var useSaturationSlider = ({
1254
1224
  focusThumbOnChange = true,
1255
1225
  ...props
1256
1226
  }) => {
1257
- if (!focusThumbOnChange)
1258
- props.isReadOnly = true;
1227
+ if (!focusThumbOnChange) props.isReadOnly = true;
1259
1228
  let {
1260
1229
  id,
1261
1230
  name,
@@ -1303,8 +1272,7 @@ var useSaturationSlider = ({
1303
1272
  const getValueFromPointer = (0, import_react4.useCallback)(
1304
1273
  (ev) => {
1305
1274
  var _a, _b;
1306
- if (!trackRef.current)
1307
- return [];
1275
+ if (!trackRef.current) return [];
1308
1276
  const { step: step2 } = latestRef.current;
1309
1277
  latestRef.current.eventSource = "pointer";
1310
1278
  const { bottom, left, height, width } = trackRef.current.getBoundingClientRect();
@@ -1322,25 +1290,21 @@ var useSaturationSlider = ({
1322
1290
  const setValueFromPointer = (ev) => {
1323
1291
  const { value: value2 } = latestRef.current;
1324
1292
  const [nextS, nextV] = getValueFromPointer(ev);
1325
- if (nextS == null || nextV == null)
1326
- return;
1293
+ if (nextS == null || nextV == null) return;
1327
1294
  const [, s2, v2] = value2;
1328
- if (nextS !== s2 || nextV !== v2)
1329
- setValue(([h2]) => [h2, nextS, nextV]);
1295
+ if (nextS !== s2 || nextV !== v2) setValue(([h2]) => [h2, nextS, nextV]);
1330
1296
  };
1331
1297
  const focusThumb = (0, import_react4.useCallback)(() => {
1332
1298
  const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
1333
- if (focusThumbOnChange2)
1334
- setTimeout(() => {
1335
- var _a;
1336
- return (_a = thumbRef.current) == null ? void 0 : _a.focus();
1337
- });
1299
+ if (focusThumbOnChange2) setTimeout(() => {
1300
+ var _a;
1301
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
1302
+ });
1338
1303
  }, [latestRef]);
1339
1304
  const constrain = (0, import_react4.useCallback)(
1340
1305
  ([s2, v2]) => {
1341
1306
  const { isInteractive: isInteractive2 } = latestRef.current;
1342
- if (!isInteractive2)
1343
- return;
1307
+ if (!isInteractive2) return;
1344
1308
  s2 = (0, import_utils11.clampNumber)(s2, 0, 1);
1345
1309
  v2 = (0, import_utils11.clampNumber)(v2, 0, 1);
1346
1310
  setValue(([h2]) => [h2, s2, v2]);
@@ -1356,8 +1320,7 @@ var useSaturationSlider = ({
1356
1320
  ArrowDown: () => constrain([s, v - step])
1357
1321
  };
1358
1322
  const action = actions[ev.key];
1359
- if (!action)
1360
- return;
1323
+ if (!action) return;
1361
1324
  ev.preventDefault();
1362
1325
  ev.stopPropagation();
1363
1326
  action(ev);
@@ -1368,8 +1331,7 @@ var useSaturationSlider = ({
1368
1331
  (0, import_use_pan_event2.usePanEvent)(containerRef, {
1369
1332
  onSessionStart: (ev) => {
1370
1333
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
1371
- if (!isInteractive2)
1372
- return;
1334
+ if (!isInteractive2) return;
1373
1335
  setDragging(true);
1374
1336
  focusThumb();
1375
1337
  setValueFromPointer(ev);
@@ -1377,22 +1339,19 @@ var useSaturationSlider = ({
1377
1339
  },
1378
1340
  onSessionEnd: () => {
1379
1341
  const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
1380
- if (!isInteractive2)
1381
- return;
1342
+ if (!isInteractive2) return;
1382
1343
  setDragging(false);
1383
1344
  onChangeEnd(value2);
1384
1345
  },
1385
1346
  onMove: (ev) => {
1386
1347
  const { isInteractive: isInteractive2 } = latestRef.current;
1387
- if (!isInteractive2)
1388
- return;
1348
+ if (!isInteractive2) return;
1389
1349
  setValueFromPointer(ev);
1390
1350
  }
1391
1351
  });
1392
1352
  (0, import_utils11.useUpdateEffect)(() => {
1393
1353
  const { eventSource, value: value2 } = latestRef.current;
1394
- if (eventSource === "keyboard")
1395
- onChangeEnd(value2);
1354
+ if (eventSource === "keyboard") onChangeEnd(value2);
1396
1355
  }, [value, onChangeEnd]);
1397
1356
  const getContainerProps = (0, import_react4.useCallback)(
1398
1357
  (props2 = {}, ref = null) => ({
@@ -1783,13 +1742,11 @@ var useColorPicker = ({
1783
1742
  });
1784
1743
  const isColorSelectorFull = colorSelectorSize === "full";
1785
1744
  const onOpen = (0, import_react5.useCallback)(() => {
1786
- if (disabled || readOnly)
1787
- return;
1745
+ if (disabled || readOnly) return;
1788
1746
  onInternalOpen();
1789
1747
  }, [onInternalOpen, disabled, readOnly]);
1790
1748
  const onClose = (0, import_react5.useCallback)(() => {
1791
- if (!isOpen)
1792
- return;
1749
+ if (!isOpen) return;
1793
1750
  const next = (0, import_utils14.convertColor)(value, fallbackValue)(formatRef.current);
1794
1751
  setValue((prev) => !next || prev === next ? prev : next);
1795
1752
  setInputValue(formatInput(next != null ? next : ""));
@@ -1805,14 +1762,12 @@ var useColorPicker = ({
1805
1762
  fallbackValue
1806
1763
  ]);
1807
1764
  const onContainerClick = (0, import_react5.useCallback)(() => {
1808
- if (isOpen)
1809
- return;
1765
+ if (isOpen) return;
1810
1766
  onOpen();
1811
1767
  }, [isOpen, onOpen]);
1812
1768
  const onInputFocus = (0, import_react5.useCallback)(() => {
1813
1769
  isInputFocused.current = true;
1814
- if (isOpen)
1815
- return;
1770
+ if (isOpen) return;
1816
1771
  onOpen();
1817
1772
  }, [isOpen, onOpen]);
1818
1773
  const onInputBlur = (0, import_react5.useCallback)(() => {
@@ -1821,29 +1776,23 @@ var useColorPicker = ({
1821
1776
  const onContainerBlur = (0, import_react5.useCallback)(
1822
1777
  (ev) => {
1823
1778
  const relatedTarget = (0, import_utils14.getEventRelatedTarget)(ev);
1824
- if ((0, import_utils14.isContains)(containerRef.current, relatedTarget))
1825
- return;
1826
- if (!closeOnBlur)
1827
- return;
1828
- if (isOpen)
1829
- onClose();
1779
+ if ((0, import_utils14.isContains)(containerRef.current, relatedTarget)) return;
1780
+ if (!closeOnBlur) return;
1781
+ if (isOpen) onClose();
1830
1782
  },
1831
1783
  [closeOnBlur, isOpen, onClose]
1832
1784
  );
1833
1785
  const onInputKeyDown = (0, import_react5.useCallback)(
1834
1786
  (ev) => {
1835
- if (ev.key === " ")
1836
- ev.key = ev.code;
1837
- if (disabled || readOnly)
1838
- return;
1787
+ if (ev.key === " ") ev.key = ev.code;
1788
+ if (disabled || readOnly) return;
1839
1789
  const actions = {
1840
1790
  Space: !isOpen ? onOpen : void 0,
1841
1791
  Enter: !isOpen ? onOpen : void 0,
1842
1792
  Escape: closeOnEsc ? onClose : void 0
1843
1793
  };
1844
1794
  const action = actions[ev.key];
1845
- if (!action)
1846
- return;
1795
+ if (!action) return;
1847
1796
  ev.preventDefault();
1848
1797
  ev.stopPropagation();
1849
1798
  action();
@@ -1862,8 +1811,7 @@ var useColorPicker = ({
1862
1811
  (value2) => {
1863
1812
  setValue(value2);
1864
1813
  setTimeout(() => {
1865
- if (!isInputFocused.current)
1866
- setInputValue(formatInput(value2));
1814
+ if (!isInputFocused.current) setInputValue(formatInput(value2));
1867
1815
  });
1868
1816
  },
1869
1817
  [setValue, formatInput]
@@ -1875,8 +1823,7 @@ var useColorPicker = ({
1875
1823
  ev.stopPropagation();
1876
1824
  try {
1877
1825
  const { sRGBHex } = (_a2 = await onEyeDropperOpen()) != null ? _a2 : {};
1878
- if (!sRGBHex)
1879
- return;
1826
+ if (!sRGBHex) return;
1880
1827
  onColorSelectorChange(sRGBHex);
1881
1828
  onChangeEnd == null ? void 0 : onChangeEnd(sRGBHex);
1882
1829
  } catch {
@@ -1890,18 +1837,15 @@ var useColorPicker = ({
1890
1837
  enabled: isOpen && closeOnBlur
1891
1838
  });
1892
1839
  (0, import_utils14.useUpdateEffect)(() => {
1893
- if (!format || !value)
1894
- return;
1840
+ if (!format || !value) return;
1895
1841
  formatRef.current = format;
1896
1842
  const nextValue = (0, import_utils14.convertColor)(value, fallbackValue)(format);
1897
- if (!nextValue)
1898
- return;
1843
+ if (!nextValue) return;
1899
1844
  setInputValue(formatInput(nextValue));
1900
1845
  setValue(nextValue);
1901
1846
  }, [format]);
1902
1847
  (0, import_utils14.useUpdateEffect)(() => {
1903
- if (isInputFocused.current || !valueProp)
1904
- return;
1848
+ if (isInputFocused.current || !valueProp) return;
1905
1849
  setInputValue(formatInput(valueProp));
1906
1850
  }, [valueProp]);
1907
1851
  const getPopoverProps = (0, import_react5.useCallback)(