@react-stately/color 3.5.4-nightly.4569 → 3.5.4-nightly.4582

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/Color.main.js +37 -34
  2. package/dist/Color.main.js.map +1 -1
  3. package/dist/Color.mjs +37 -35
  4. package/dist/Color.module.js +37 -35
  5. package/dist/Color.module.js.map +1 -1
  6. package/dist/import.mjs +6 -2
  7. package/dist/main.js +7 -0
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.js +6 -2
  10. package/dist/module.js.map +1 -1
  11. package/dist/types.d.ts +33 -1
  12. package/dist/types.d.ts.map +1 -1
  13. package/dist/useColorAreaState.main.js +6 -2
  14. package/dist/useColorAreaState.main.js.map +1 -1
  15. package/dist/useColorAreaState.mjs +7 -3
  16. package/dist/useColorAreaState.module.js +7 -3
  17. package/dist/useColorAreaState.module.js.map +1 -1
  18. package/dist/useColorChannelFieldState.main.js +48 -0
  19. package/dist/useColorChannelFieldState.main.js.map +1 -0
  20. package/dist/useColorChannelFieldState.mjs +43 -0
  21. package/dist/useColorChannelFieldState.module.js +43 -0
  22. package/dist/useColorChannelFieldState.module.js.map +1 -0
  23. package/dist/useColorPickerState.main.js +27 -0
  24. package/dist/useColorPickerState.main.js.map +1 -0
  25. package/dist/useColorPickerState.mjs +22 -0
  26. package/dist/useColorPickerState.module.js +22 -0
  27. package/dist/useColorPickerState.module.js.map +1 -0
  28. package/dist/useColorSliderState.main.js +10 -3
  29. package/dist/useColorSliderState.main.js.map +1 -1
  30. package/dist/useColorSliderState.mjs +10 -3
  31. package/dist/useColorSliderState.module.js +10 -3
  32. package/dist/useColorSliderState.module.js.map +1 -1
  33. package/dist/useColorWheelState.main.js +9 -2
  34. package/dist/useColorWheelState.main.js.map +1 -1
  35. package/dist/useColorWheelState.mjs +10 -3
  36. package/dist/useColorWheelState.module.js +10 -3
  37. package/dist/useColorWheelState.module.js.map +1 -1
  38. package/package.json +11 -9
  39. package/src/Color.ts +55 -38
  40. package/src/index.ts +5 -1
  41. package/src/useColorAreaState.ts +3 -1
  42. package/src/useColorChannelFieldState.ts +49 -0
  43. package/src/useColorPickerState.ts +27 -0
  44. package/src/useColorSliderState.ts +9 -4
  45. package/src/useColorWheelState.ts +12 -4
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0DD,MAAM,sCAAgB,CAAA,GAAA,oCAAS,EAAE;AAK1B,SAAS,0CAAkB,KAAqB;IACrD,IAAI,SACF,KAAK,gBACL,YAAY,YACZ,QAAQ,YACR,QAAQ,YACR,QAAQ,eACR,WAAW,EACZ,GAAG;IAEJ,IAAI,CAAC,SAAS,CAAC,cACb,eAAe;IAGjB,IAAI,CAAC,OAAO,cAAc,GAAG,CAAA,GAAA,2CAAiB,EAAE,SAAS,CAAA,GAAA,wCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,wCAAa,EAAE,eAAe;IAC9H,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;IACtB,IAAI,WAAW,CAAC;QACd,SAAS,OAAO,GAAG;QACnB,cAAc;IAChB;IAEA,IAAI,WAAW,CAAA,GAAA,oBAAM,EAAE,IACrB,MAAM,iBAAiB,CAAC;sBAAC;sBAAU;QAAQ,IAC3C;QAAC;QAAO;QAAU;KAAS;IAG7B,IAAI,gBAAgB,MAAM,eAAe,CAAC,SAAS,QAAQ;IAC3D,IAAI,gBAAgB,MAAM,eAAe,CAAC,SAAS,QAAQ;IAC3D,IAAI,EAAC,UAAU,SAAS,EAAE,UAAU,SAAS,EAAE,MAAM,KAAK,EAAE,UAAU,SAAS,EAAC,GAAG;IACnF,IAAI,EAAC,UAAU,SAAS,EAAE,UAAU,SAAS,EAAE,MAAM,KAAK,EAAE,UAAU,SAAS,EAAC,GAAG;IAEnF,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IACzC,IAAI,gBAAgB,CAAA,GAAA,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SAAS,SAAQ,IAAM,CAAA,YAAY,SAAQ;YACxD,OAAO;mBAAC;mBAAG;YAAC;QACd;QACA,YAAW,QAAQ;YACjB,UAAU,SAAS,WAAW,YAAY,YAAY,CAAA,GAAA,wCAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACjH;QACA,YAAW,QAAQ;YACjB,UAAU,SAAS,WAAW,YAAY,YAAY,CAAA,GAAA,wCAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACjH;QACA,YAAW,QAAQ;YACjB,UAAU,CAAA,GAAA,wCAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACrE;QACA,YAAW,QAAQ;YACjB,UAAU,CAAA,GAAA,wCAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACrE;QACA,aAAY,UAAU;YACpB,IAAI,cAAc,cAAc,OAAO;YACvC,cAAc,OAAO,GAAG;YAExB,IAAI,eAAe,CAAC,cAAc,aAChC,YAAY,SAAS,OAAO;YAG9B,YAAY;QACd;oBACA;QACA;YACE,OAAO,MAAM,gBAAgB,CAAC,SAAS;QACzC;IACF;AACF","sources":["packages/@react-stately/color/src/useColorAreaState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep, useControlledState} from '@react-stately/utils';\nimport {Color, ColorAreaProps, ColorChannel} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {useMemo, useRef, useState} from 'react';\n\nexport interface ColorAreaState {\n /** The current color value displayed by the color area. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n\n /** The current value of the horizontal axis channel displayed by the color area. */\n xValue: number,\n /** Sets the value for the horizontal axis channel displayed by the color area, and triggers `onChange`. */\n setXValue(value: number): void,\n\n /** The current value of the vertical axis channel displayed by the color area. */\n yValue: number,\n /** Sets the value for the vertical axis channel displayed by the color area, and triggers `onChange`. */\n setYValue(value: number): void,\n\n /** Sets the x and y channels of the current color value based on a percentage of the width and height of the color area, and triggers `onChange`. */\n setColorFromPoint(x: number, y: number): void,\n /** Returns the coordinates of the thumb relative to the upper left corner of the color area as a percentage. */\n getThumbPosition(): {x: number, y: number},\n\n /** Increments the value of the horizontal axis channel by the channel step or page amount. */\n incrementX(stepSize?: number): void,\n /** Decrements the value of the horizontal axis channel by the channel step or page amount. */\n decrementX(stepSize?: number): void,\n\n /** Increments the value of the vertical axis channel by the channel step or page amount. */\n incrementY(stepSize?: number): void,\n /** Decrements the value of the vertical axis channel by the channel step or page amount. */\n decrementY(stepSize?: number): void,\n\n /** Whether the color area is currently being dragged. */\n readonly isDragging: boolean,\n /** Sets whether the color area is being dragged. */\n setDragging(value: boolean): void,\n\n /** Returns the xChannel, yChannel and zChannel names based on the color value. */\n channels: {xChannel: ColorChannel, yChannel: ColorChannel, zChannel: ColorChannel},\n /** The step value of the xChannel, used when incrementing and decrementing. */\n xChannelStep: number,\n /** The step value of the yChannel, used when incrementing and decrementing. */\n yChannelStep: number,\n /** The page step value of the xChannel, used when incrementing and decrementing. */\n xChannelPageStep: number,\n /** The page step value of the yChannel, used when incrementing and decrementing. */\n yChannelPageStep: number,\n\n /** Returns the color that should be displayed in the color area thumb instead of `value`. */\n getDisplayColor(): Color\n}\n\nconst DEFAULT_COLOR = parseColor('#ffffff');\n/**\n * Provides state management for a color area component.\n * Color area allows users to adjust two channels of an HSL, HSB or RGB color value against a two-dimensional gradient background.\n */\nexport function useColorAreaState(props: ColorAreaProps): ColorAreaState {\n let {\n value,\n defaultValue,\n xChannel,\n yChannel,\n onChange,\n onChangeEnd\n } = props;\n\n if (!value && !defaultValue) {\n defaultValue = DEFAULT_COLOR;\n }\n\n let [color, setColorState] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let valueRef = useRef(color);\n let setColor = (color: Color) => {\n valueRef.current = color;\n setColorState(color);\n };\n\n let channels = useMemo(() =>\n color.getColorSpaceAxes({xChannel, yChannel}),\n [color, xChannel, yChannel]\n );\n\n let xChannelRange = color.getChannelRange(channels.xChannel);\n let yChannelRange = color.getChannelRange(channels.yChannel);\n let {minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX} = xChannelRange;\n let {minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY} = yChannelRange;\n\n let [isDragging, setDragging] = useState(false);\n let isDraggingRef = useRef(false);\n\n let xValue = color.getChannelValue(channels.xChannel);\n let yValue = color.getChannelValue(channels.yChannel);\n let setXValue = (v: number) => {\n if (v === xValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.xChannel, v);\n setColor(newColor);\n };\n let setYValue = (v: number) => {\n if (v === yValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.yChannel, v);\n setColor(newColor);\n };\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n xValue,\n setXValue,\n yValue,\n setYValue,\n setColorFromPoint(x: number, y: number) {\n let newXValue = minValueX + clamp(x, 0, 1) * (maxValueX - minValueX);\n let newYValue = minValueY + (1 - clamp(y, 0, 1)) * (maxValueY - minValueY);\n let newColor:Color;\n if (newXValue !== xValue) {\n // Round new value to multiple of step, clamp value between min and max\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);\n newColor = color.withChannelValue(channels.xChannel, newXValue);\n }\n if (newYValue !== yValue) {\n // Round new value to multiple of step, clamp value between min and max\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);\n }\n if (newColor) {\n setColor(newColor);\n }\n },\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX);\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);\n return {x, y};\n },\n incrementX(stepSize) {\n setXValue(xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));\n },\n incrementY(stepSize) {\n setYValue(yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));\n },\n decrementX(stepSize) {\n setXValue(snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));\n },\n decrementY(stepSize) {\n setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));\n },\n setDragging(isDragging) {\n let wasDragging = isDraggingRef.current;\n isDraggingRef.current = isDragging;\n\n if (onChangeEnd && !isDragging && wasDragging) {\n onChangeEnd(valueRef.current);\n }\n\n setDragging(isDragging);\n },\n isDragging,\n getDisplayColor() {\n return color.withChannelValue('alpha', 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorAreaState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0DD,MAAM,sCAAgB,CAAA,GAAA,oCAAS,EAAE;AAK1B,SAAS,0CAAkB,KAAqB;IACrD,IAAI,SACF,KAAK,gBACL,YAAY,cACZ,UAAU,YACV,QAAQ,YACR,QAAQ,YACR,QAAQ,eACR,WAAW,EACZ,GAAG;IAEJ,IAAI,CAAC,SAAS,CAAC,cACb,eAAe;IAGjB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,2CAAiB,EAAE,SAAS,CAAA,GAAA,wCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,wCAAa,EAAE,eAAe;IACnI,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAM,cAAc,aAAa,WAAW,QAAQ,CAAC,cAAc,YAAY;QAAC;QAAY;K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AY;QACd;oBACA;QACA;YACE,OAAO,MAAM,gBAAgB,CAAC,SAAS;QACzC;IACF;AACF","sources":["packages/@react-stately/color/src/useColorAreaState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep, useControlledState} from '@react-stately/utils';\nimport {Color, ColorAreaProps, ColorChannel} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {useMemo, useRef, useState} from 'react';\n\nexport interface ColorAreaState {\n /** The current color value displayed by the color area. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n\n /** The current value of the horizontal axis channel displayed by the color area. */\n xValue: number,\n /** Sets the value for the horizontal axis channel displayed by the color area, and triggers `onChange`. */\n setXValue(value: number): void,\n\n /** The current value of the vertical axis channel displayed by the color area. */\n yValue: number,\n /** Sets the value for the vertical axis channel displayed by the color area, and triggers `onChange`. */\n setYValue(value: number): void,\n\n /** Sets the x and y channels of the current color value based on a percentage of the width and height of the color area, and triggers `onChange`. */\n setColorFromPoint(x: number, y: number): void,\n /** Returns the coordinates of the thumb relative to the upper left corner of the color area as a percentage. */\n getThumbPosition(): {x: number, y: number},\n\n /** Increments the value of the horizontal axis channel by the channel step or page amount. */\n incrementX(stepSize?: number): void,\n /** Decrements the value of the horizontal axis channel by the channel step or page amount. */\n decrementX(stepSize?: number): void,\n\n /** Increments the value of the vertical axis channel by the channel step or page amount. */\n incrementY(stepSize?: number): void,\n /** Decrements the value of the vertical axis channel by the channel step or page amount. */\n decrementY(stepSize?: number): void,\n\n /** Whether the color area is currently being dragged. */\n readonly isDragging: boolean,\n /** Sets whether the color area is being dragged. */\n setDragging(value: boolean): void,\n\n /** Returns the xChannel, yChannel and zChannel names based on the color value. */\n channels: {xChannel: ColorChannel, yChannel: ColorChannel, zChannel: ColorChannel},\n /** The step value of the xChannel, used when incrementing and decrementing. */\n xChannelStep: number,\n /** The step value of the yChannel, used when incrementing and decrementing. */\n yChannelStep: number,\n /** The page step value of the xChannel, used when incrementing and decrementing. */\n xChannelPageStep: number,\n /** The page step value of the yChannel, used when incrementing and decrementing. */\n yChannelPageStep: number,\n\n /** Returns the color that should be displayed in the color area thumb instead of `value`. */\n getDisplayColor(): Color\n}\n\nconst DEFAULT_COLOR = parseColor('#ffffff');\n/**\n * Provides state management for a color area component.\n * Color area allows users to adjust two channels of an HSL, HSB or RGB color value against a two-dimensional gradient background.\n */\nexport function useColorAreaState(props: ColorAreaProps): ColorAreaState {\n let {\n value,\n defaultValue,\n colorSpace,\n xChannel,\n yChannel,\n onChange,\n onChangeEnd\n } = props;\n\n if (!value && !defaultValue) {\n defaultValue = DEFAULT_COLOR;\n }\n\n let [colorValue, setColorState] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let valueRef = useRef(color);\n let setColor = (color: Color) => {\n valueRef.current = color;\n setColorState(color);\n };\n\n let channels = useMemo(() =>\n color.getColorSpaceAxes({xChannel, yChannel}),\n [color, xChannel, yChannel]\n );\n\n let xChannelRange = color.getChannelRange(channels.xChannel);\n let yChannelRange = color.getChannelRange(channels.yChannel);\n let {minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX} = xChannelRange;\n let {minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY} = yChannelRange;\n\n let [isDragging, setDragging] = useState(false);\n let isDraggingRef = useRef(false);\n\n let xValue = color.getChannelValue(channels.xChannel);\n let yValue = color.getChannelValue(channels.yChannel);\n let setXValue = (v: number) => {\n if (v === xValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.xChannel, v);\n setColor(newColor);\n };\n let setYValue = (v: number) => {\n if (v === yValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.yChannel, v);\n setColor(newColor);\n };\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n xValue,\n setXValue,\n yValue,\n setYValue,\n setColorFromPoint(x: number, y: number) {\n let newXValue = minValueX + clamp(x, 0, 1) * (maxValueX - minValueX);\n let newYValue = minValueY + (1 - clamp(y, 0, 1)) * (maxValueY - minValueY);\n let newColor:Color;\n if (newXValue !== xValue) {\n // Round new value to multiple of step, clamp value between min and max\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);\n newColor = color.withChannelValue(channels.xChannel, newXValue);\n }\n if (newYValue !== yValue) {\n // Round new value to multiple of step, clamp value between min and max\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);\n }\n if (newColor) {\n setColor(newColor);\n }\n },\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX);\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);\n return {x, y};\n },\n incrementX(stepSize) {\n setXValue(xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));\n },\n incrementY(stepSize) {\n setYValue(yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));\n },\n decrementX(stepSize) {\n setXValue(snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));\n },\n decrementY(stepSize) {\n setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));\n },\n setDragging(isDragging) {\n let wasDragging = isDraggingRef.current;\n isDraggingRef.current = isDragging;\n\n if (onChangeEnd && !isDragging && wasDragging) {\n onChangeEnd(valueRef.current);\n }\n\n setDragging(isDragging);\n },\n isDragging,\n getDisplayColor() {\n return color.withChannelValue('alpha', 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorAreaState.main.js.map"}
@@ -1,6 +1,6 @@
1
1
  import {normalizeColor as $799cddbef784668f$export$4cde5df63f53f473, parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.mjs";
2
2
  import {useControlledState as $5ShDH$useControlledState, clamp as $5ShDH$clamp, snapValueToStep as $5ShDH$snapValueToStep} from "@react-stately/utils";
3
- import {useRef as $5ShDH$useRef, useMemo as $5ShDH$useMemo, useState as $5ShDH$useState} from "react";
3
+ import {useMemo as $5ShDH$useMemo, useRef as $5ShDH$useRef, useState as $5ShDH$useState} from "react";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,9 +17,13 @@ import {useRef as $5ShDH$useRef, useMemo as $5ShDH$useMemo, useState as $5ShDH$u
17
17
 
18
18
  const $6e14a98a7f67141d$var$DEFAULT_COLOR = (0, $799cddbef784668f$export$6e865ea70d7724f)("#ffffff");
19
19
  function $6e14a98a7f67141d$export$6df7f0e2cabc7eef(props) {
20
- let { value: value, defaultValue: defaultValue, xChannel: xChannel, yChannel: yChannel, onChange: onChange, onChangeEnd: onChangeEnd } = props;
20
+ let { value: value, defaultValue: defaultValue, colorSpace: colorSpace, xChannel: xChannel, yChannel: yChannel, onChange: onChange, onChangeEnd: onChangeEnd } = props;
21
21
  if (!value && !defaultValue) defaultValue = $6e14a98a7f67141d$var$DEFAULT_COLOR;
22
- let [color, setColorState] = (0, $5ShDH$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
22
+ let [colorValue, setColorState] = (0, $5ShDH$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
23
+ let color = (0, $5ShDH$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
24
+ colorValue,
25
+ colorSpace
26
+ ]);
23
27
  let valueRef = (0, $5ShDH$useRef)(color);
24
28
  let setColor = (color)=>{
25
29
  valueRef.current = color;
@@ -1,6 +1,6 @@
1
1
  import {normalizeColor as $799cddbef784668f$export$4cde5df63f53f473, parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.module.js";
2
2
  import {useControlledState as $5ShDH$useControlledState, clamp as $5ShDH$clamp, snapValueToStep as $5ShDH$snapValueToStep} from "@react-stately/utils";
3
- import {useRef as $5ShDH$useRef, useMemo as $5ShDH$useMemo, useState as $5ShDH$useState} from "react";
3
+ import {useMemo as $5ShDH$useMemo, useRef as $5ShDH$useRef, useState as $5ShDH$useState} from "react";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,9 +17,13 @@ import {useRef as $5ShDH$useRef, useMemo as $5ShDH$useMemo, useState as $5ShDH$u
17
17
 
18
18
  const $6e14a98a7f67141d$var$DEFAULT_COLOR = (0, $799cddbef784668f$export$6e865ea70d7724f)("#ffffff");
19
19
  function $6e14a98a7f67141d$export$6df7f0e2cabc7eef(props) {
20
- let { value: value, defaultValue: defaultValue, xChannel: xChannel, yChannel: yChannel, onChange: onChange, onChangeEnd: onChangeEnd } = props;
20
+ let { value: value, defaultValue: defaultValue, colorSpace: colorSpace, xChannel: xChannel, yChannel: yChannel, onChange: onChange, onChangeEnd: onChangeEnd } = props;
21
21
  if (!value && !defaultValue) defaultValue = $6e14a98a7f67141d$var$DEFAULT_COLOR;
22
- let [color, setColorState] = (0, $5ShDH$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
22
+ let [colorValue, setColorState] = (0, $5ShDH$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
23
+ let color = (0, $5ShDH$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
24
+ colorValue,
25
+ colorSpace
26
+ ]);
23
27
  let valueRef = (0, $5ShDH$useRef)(color);
24
28
  let setColor = (color)=>{
25
29
  valueRef.current = color;
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0DD,MAAM,sCAAgB,CAAA,GAAA,wCAAS,EAAE;AAK1B,SAAS,0CAAkB,KAAqB;IACrD,IAAI,SACF,KAAK,gBACL,YAAY,YACZ,QAAQ,YACR,QAAQ,YACR,QAAQ,eACR,WAAW,EACZ,GAAG;IAEJ,IAAI,CAAC,SAAS,CAAC,cACb,eAAe;IAGjB,IAAI,CAAC,OAAO,cAAc,GAAG,CAAA,GAAA,yBAAiB,EAAE,SAAS,CAAA,GAAA,yCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,yCAAa,EAAE,eAAe;IAC9H,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;IACtB,IAAI,WAAW,CAAC;QACd,SAAS,OAAO,GAAG;QACnB,cAAc;IAChB;IAEA,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IACrB,MAAM,iBAAiB,CAAC;sBAAC;sBAAU;QAAQ,IAC3C;QAAC;QAAO;QAAU;KAAS;IAG7B,IAAI,gBAAgB,MAAM,eAAe,CAAC,SAAS,QAAQ;IAC3D,IAAI,gBAAgB,MAAM,eAAe,CAAC,SAAS,QAAQ;IAC3D,IAAI,EAAC,UAAU,SAAS,EAAE,UAAU,SAAS,EAAE,MAAM,KAAK,EAAE,UAAU,SAAS,EAAC,GAAG;IACnF,IAAI,EAAC,UAAU,SAAS,EAAE,UAAU,SAAS,EAAE,MAAM,KAAK,EAAE,UAAU,SAAS,EAAC,GAAG;IAEnF,IA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CAAA,SAAS,SAAQ,IAAM,CAAA,YAAY,SAAQ;YACpD,IAAI,IAAI,IAAI,AAAC,CAAA,SAAS,SAAQ,IAAM,CAAA,YAAY,SAAQ;YACxD,OAAO;mBAAC;mBAAG;YAAC;QACd;QACA,YAAW,QAAQ;YACjB,UAAU,SAAS,WAAW,YAAY,YAAY,CAAA,GAAA,sBAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACjH;QACA,YAAW,QAAQ;YACjB,UAAU,SAAS,WAAW,YAAY,YAAY,CAAA,GAAA,sBAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACjH;QACA,YAAW,QAAQ;YACjB,UAAU,CAAA,GAAA,sBAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACrE;QACA,YAAW,QAAQ;YACjB,UAAU,CAAA,GAAA,sBAAc,EAAE,SAAS,UAAU,WAAW,WAAW;QACrE;QACA,aAAY,UAAU;YACpB,IAAI,cAAc,cAAc,OAAO;YACvC,cAAc,OAAO,GAAG;YAExB,IAAI,eAAe,CAAC,cAAc,aAChC,YAAY,SAAS,OAAO;YAG9B,YAAY;QACd;oBACA;QACA;YACE,OAAO,MAAM,gBAAgB,CAAC,SAAS;QACzC;IACF;AACF","sources":["packages/@react-stately/color/src/useColorAreaState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep, useControlledState} from '@react-stately/utils';\nimport {Color, ColorAreaProps, ColorChannel} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {useMemo, useRef, useState} from 'react';\n\nexport interface ColorAreaState {\n /** The current color value displayed by the color area. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n\n /** The current value of the horizontal axis channel displayed by the color area. */\n xValue: number,\n /** Sets the value for the horizontal axis channel displayed by the color area, and triggers `onChange`. */\n setXValue(value: number): void,\n\n /** The current value of the vertical axis channel displayed by the color area. */\n yValue: number,\n /** Sets the value for the vertical axis channel displayed by the color area, and triggers `onChange`. */\n setYValue(value: number): void,\n\n /** Sets the x and y channels of the current color value based on a percentage of the width and height of the color area, and triggers `onChange`. */\n setColorFromPoint(x: number, y: number): void,\n /** Returns the coordinates of the thumb relative to the upper left corner of the color area as a percentage. */\n getThumbPosition(): {x: number, y: number},\n\n /** Increments the value of the horizontal axis channel by the channel step or page amount. */\n incrementX(stepSize?: number): void,\n /** Decrements the value of the horizontal axis channel by the channel step or page amount. */\n decrementX(stepSize?: number): void,\n\n /** Increments the value of the vertical axis channel by the channel step or page amount. */\n incrementY(stepSize?: number): void,\n /** Decrements the value of the vertical axis channel by the channel step or page amount. */\n decrementY(stepSize?: number): void,\n\n /** Whether the color area is currently being dragged. */\n readonly isDragging: boolean,\n /** Sets whether the color area is being dragged. */\n setDragging(value: boolean): void,\n\n /** Returns the xChannel, yChannel and zChannel names based on the color value. */\n channels: {xChannel: ColorChannel, yChannel: ColorChannel, zChannel: ColorChannel},\n /** The step value of the xChannel, used when incrementing and decrementing. */\n xChannelStep: number,\n /** The step value of the yChannel, used when incrementing and decrementing. */\n yChannelStep: number,\n /** The page step value of the xChannel, used when incrementing and decrementing. */\n xChannelPageStep: number,\n /** The page step value of the yChannel, used when incrementing and decrementing. */\n yChannelPageStep: number,\n\n /** Returns the color that should be displayed in the color area thumb instead of `value`. */\n getDisplayColor(): Color\n}\n\nconst DEFAULT_COLOR = parseColor('#ffffff');\n/**\n * Provides state management for a color area component.\n * Color area allows users to adjust two channels of an HSL, HSB or RGB color value against a two-dimensional gradient background.\n */\nexport function useColorAreaState(props: ColorAreaProps): ColorAreaState {\n let {\n value,\n defaultValue,\n xChannel,\n yChannel,\n onChange,\n onChangeEnd\n } = props;\n\n if (!value && !defaultValue) {\n defaultValue = DEFAULT_COLOR;\n }\n\n let [color, setColorState] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let valueRef = useRef(color);\n let setColor = (color: Color) => {\n valueRef.current = color;\n setColorState(color);\n };\n\n let channels = useMemo(() =>\n color.getColorSpaceAxes({xChannel, yChannel}),\n [color, xChannel, yChannel]\n );\n\n let xChannelRange = color.getChannelRange(channels.xChannel);\n let yChannelRange = color.getChannelRange(channels.yChannel);\n let {minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX} = xChannelRange;\n let {minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY} = yChannelRange;\n\n let [isDragging, setDragging] = useState(false);\n let isDraggingRef = useRef(false);\n\n let xValue = color.getChannelValue(channels.xChannel);\n let yValue = color.getChannelValue(channels.yChannel);\n let setXValue = (v: number) => {\n if (v === xValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.xChannel, v);\n setColor(newColor);\n };\n let setYValue = (v: number) => {\n if (v === yValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.yChannel, v);\n setColor(newColor);\n };\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n xValue,\n setXValue,\n yValue,\n setYValue,\n setColorFromPoint(x: number, y: number) {\n let newXValue = minValueX + clamp(x, 0, 1) * (maxValueX - minValueX);\n let newYValue = minValueY + (1 - clamp(y, 0, 1)) * (maxValueY - minValueY);\n let newColor:Color;\n if (newXValue !== xValue) {\n // Round new value to multiple of step, clamp value between min and max\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);\n newColor = color.withChannelValue(channels.xChannel, newXValue);\n }\n if (newYValue !== yValue) {\n // Round new value to multiple of step, clamp value between min and max\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);\n }\n if (newColor) {\n setColor(newColor);\n }\n },\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX);\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);\n return {x, y};\n },\n incrementX(stepSize) {\n setXValue(xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));\n },\n incrementY(stepSize) {\n setYValue(yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));\n },\n decrementX(stepSize) {\n setXValue(snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));\n },\n decrementY(stepSize) {\n setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));\n },\n setDragging(isDragging) {\n let wasDragging = isDraggingRef.current;\n isDraggingRef.current = isDragging;\n\n if (onChangeEnd && !isDragging && wasDragging) {\n onChangeEnd(valueRef.current);\n }\n\n setDragging(isDragging);\n },\n isDragging,\n getDisplayColor() {\n return color.withChannelValue('alpha', 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorAreaState.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0DD,MAAM,sCAAgB,CAAA,GAAA,wCAAS,EAAE;AAK1B,SAAS,0CAAkB,KAAqB;IACrD,IAAI,SACF,KAAK,gBACL,YAAY,cACZ,UAAU,YACV,QAAQ,YACR,QAAQ,YACR,QAAQ,eACR,WAAW,EACZ,GAAG;IAEJ,IAAI,CAAC,SAAS,CAAC,cACb,eAAe;IAGjB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,yBAAiB,EAAE,SAAS,CAAA,GAAA,yCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,yCAAa,EAAE,eAAe;IACnI,IAAI,QAAQ,CAAA,GAAA,cA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;YAExB,IAAI,eAAe,CAAC,cAAc,aAChC,YAAY,SAAS,OAAO;YAG9B,YAAY;QACd;oBACA;QACA;YACE,OAAO,MAAM,gBAAgB,CAAC,SAAS;QACzC;IACF;AACF","sources":["packages/@react-stately/color/src/useColorAreaState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, snapValueToStep, useControlledState} from '@react-stately/utils';\nimport {Color, ColorAreaProps, ColorChannel} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {useMemo, useRef, useState} from 'react';\n\nexport interface ColorAreaState {\n /** The current color value displayed by the color area. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n\n /** The current value of the horizontal axis channel displayed by the color area. */\n xValue: number,\n /** Sets the value for the horizontal axis channel displayed by the color area, and triggers `onChange`. */\n setXValue(value: number): void,\n\n /** The current value of the vertical axis channel displayed by the color area. */\n yValue: number,\n /** Sets the value for the vertical axis channel displayed by the color area, and triggers `onChange`. */\n setYValue(value: number): void,\n\n /** Sets the x and y channels of the current color value based on a percentage of the width and height of the color area, and triggers `onChange`. */\n setColorFromPoint(x: number, y: number): void,\n /** Returns the coordinates of the thumb relative to the upper left corner of the color area as a percentage. */\n getThumbPosition(): {x: number, y: number},\n\n /** Increments the value of the horizontal axis channel by the channel step or page amount. */\n incrementX(stepSize?: number): void,\n /** Decrements the value of the horizontal axis channel by the channel step or page amount. */\n decrementX(stepSize?: number): void,\n\n /** Increments the value of the vertical axis channel by the channel step or page amount. */\n incrementY(stepSize?: number): void,\n /** Decrements the value of the vertical axis channel by the channel step or page amount. */\n decrementY(stepSize?: number): void,\n\n /** Whether the color area is currently being dragged. */\n readonly isDragging: boolean,\n /** Sets whether the color area is being dragged. */\n setDragging(value: boolean): void,\n\n /** Returns the xChannel, yChannel and zChannel names based on the color value. */\n channels: {xChannel: ColorChannel, yChannel: ColorChannel, zChannel: ColorChannel},\n /** The step value of the xChannel, used when incrementing and decrementing. */\n xChannelStep: number,\n /** The step value of the yChannel, used when incrementing and decrementing. */\n yChannelStep: number,\n /** The page step value of the xChannel, used when incrementing and decrementing. */\n xChannelPageStep: number,\n /** The page step value of the yChannel, used when incrementing and decrementing. */\n yChannelPageStep: number,\n\n /** Returns the color that should be displayed in the color area thumb instead of `value`. */\n getDisplayColor(): Color\n}\n\nconst DEFAULT_COLOR = parseColor('#ffffff');\n/**\n * Provides state management for a color area component.\n * Color area allows users to adjust two channels of an HSL, HSB or RGB color value against a two-dimensional gradient background.\n */\nexport function useColorAreaState(props: ColorAreaProps): ColorAreaState {\n let {\n value,\n defaultValue,\n colorSpace,\n xChannel,\n yChannel,\n onChange,\n onChangeEnd\n } = props;\n\n if (!value && !defaultValue) {\n defaultValue = DEFAULT_COLOR;\n }\n\n let [colorValue, setColorState] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let valueRef = useRef(color);\n let setColor = (color: Color) => {\n valueRef.current = color;\n setColorState(color);\n };\n\n let channels = useMemo(() =>\n color.getColorSpaceAxes({xChannel, yChannel}),\n [color, xChannel, yChannel]\n );\n\n let xChannelRange = color.getChannelRange(channels.xChannel);\n let yChannelRange = color.getChannelRange(channels.yChannel);\n let {minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX} = xChannelRange;\n let {minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY} = yChannelRange;\n\n let [isDragging, setDragging] = useState(false);\n let isDraggingRef = useRef(false);\n\n let xValue = color.getChannelValue(channels.xChannel);\n let yValue = color.getChannelValue(channels.yChannel);\n let setXValue = (v: number) => {\n if (v === xValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.xChannel, v);\n setColor(newColor);\n };\n let setYValue = (v: number) => {\n if (v === yValue) {\n return;\n }\n let newColor = color.withChannelValue(channels.yChannel, v);\n setColor(newColor);\n };\n\n return {\n channels,\n xChannelStep: stepX,\n yChannelStep: stepY,\n xChannelPageStep: pageSizeX,\n yChannelPageStep: pageSizeY,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n xValue,\n setXValue,\n yValue,\n setYValue,\n setColorFromPoint(x: number, y: number) {\n let newXValue = minValueX + clamp(x, 0, 1) * (maxValueX - minValueX);\n let newYValue = minValueY + (1 - clamp(y, 0, 1)) * (maxValueY - minValueY);\n let newColor:Color;\n if (newXValue !== xValue) {\n // Round new value to multiple of step, clamp value between min and max\n newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);\n newColor = color.withChannelValue(channels.xChannel, newXValue);\n }\n if (newYValue !== yValue) {\n // Round new value to multiple of step, clamp value between min and max\n newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);\n newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);\n }\n if (newColor) {\n setColor(newColor);\n }\n },\n getThumbPosition() {\n let x = (xValue - minValueX) / (maxValueX - minValueX);\n let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);\n return {x, y};\n },\n incrementX(stepSize) {\n setXValue(xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));\n },\n incrementY(stepSize) {\n setYValue(yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));\n },\n decrementX(stepSize) {\n setXValue(snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));\n },\n decrementY(stepSize) {\n setYValue(snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));\n },\n setDragging(isDragging) {\n let wasDragging = isDraggingRef.current;\n isDraggingRef.current = isDragging;\n\n if (onChangeEnd && !isDragging && wasDragging) {\n onChangeEnd(valueRef.current);\n }\n\n setDragging(isDragging);\n },\n isDragging,\n getDisplayColor() {\n return color.withChannelValue('alpha', 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorAreaState.module.js.map"}
@@ -0,0 +1,48 @@
1
+ var $f8b3be23ba4462b1$exports = require("./useColor.main.js");
2
+ var $8s2vy$reactstatelynumberfield = require("@react-stately/numberfield");
3
+ var $8s2vy$reactstatelyutils = require("@react-stately/utils");
4
+ var $8s2vy$react = require("react");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useColorChannelFieldState", () => $9f9c35e37074b99b$export$b9fc0d69c9190c4a);
12
+
13
+
14
+
15
+
16
+ function $9f9c35e37074b99b$export$b9fc0d69c9190c4a(props) {
17
+ let { channel: channel, colorSpace: colorSpace, locale: locale } = props;
18
+ let initialValue = (0, $f8b3be23ba4462b1$exports.useColor)(props.value);
19
+ let initialDefaultValue = (0, $f8b3be23ba4462b1$exports.useColor)(props.defaultValue || "#0000");
20
+ let [colorValue, setColor] = (0, $8s2vy$reactstatelyutils.useControlledState)(initialValue || undefined, initialDefaultValue, props.onChange);
21
+ let color = (0, $8s2vy$react.useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
22
+ colorValue,
23
+ colorSpace
24
+ ]);
25
+ let value = color.getChannelValue(channel);
26
+ let range = color.getChannelRange(channel);
27
+ let formatOptions = (0, $8s2vy$react.useMemo)(()=>color.getChannelFormatOptions(channel), [
28
+ color,
29
+ channel
30
+ ]);
31
+ let multiplier = formatOptions.style === "percent" && range.maxValue === 100 ? 100 : 1;
32
+ let numberFieldState = (0, $8s2vy$reactstatelynumberfield.useNumberFieldState)({
33
+ locale: locale,
34
+ value: value / multiplier,
35
+ onChange: (v)=>setColor(color.withChannelValue(channel, v * multiplier)),
36
+ minValue: range.minValue / multiplier,
37
+ maxValue: range.maxValue / multiplier,
38
+ step: range.step / multiplier,
39
+ formatOptions: formatOptions
40
+ });
41
+ return {
42
+ ...numberFieldState,
43
+ colorValue: color
44
+ };
45
+ }
46
+
47
+
48
+ //# sourceMappingURL=useColorChannelFieldState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAuBO,SAAS,0CAA0B,KAAoC;IAC5E,IAAI,WAAC,OAAO,cAAE,UAAU,UAAE,MAAM,EAAC,GAAG;IACpC,IAAI,eAAe,CAAA,GAAA,kCAAO,EAAE,MAAM,KAAK;IACvC,IAAI,sBAAsB,CAAA,GAAA,kCAAO,EAAE,MAAM,YAAY,IAAI;IACzD,IAAI,CAAC,YAAY,SAAS,GAAG,CAAA,GAAA,2CAAiB,EAAE,gBAAgB,WAAW,qBAAqB,MAAM,QAAQ;IAC9G,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAM,cAAc,aAAa,WAAW,QAAQ,CAAC,cAAc,YAAY;QAAC;QAAY;KAAW;IAC3H,IAAI,QAAQ,MAAM,eAAe,CAAC;IAClC,IAAI,QAAQ,MAAM,eAAe,CAAC;IAClC,IAAI,gBAAgB,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,uBAAuB,CAAC,UAAU;QAAC;QAAO;KAAQ;IAC1F,IAAI,aAAa,cAAc,KAAK,KAAK,aAAa,MAAM,QAAQ,KAAK,MAAM,MAAM;IAErF,IAAI,mBAAmB,CAAA,GAAA,kDAAkB,EAAE;gBACzC;QACA,OAAO,QAAQ;QACf,UAAU,CAAC,IAAM,SAAS,MAAM,gBAAgB,CAAC,SAAS,IAAI;QAC9D,UAAU,MAAM,QAAQ,GAAG;QAC3B,UAAU,MAAM,QAAQ,GAAG;QAC3B,MAAM,MAAM,IAAI,GAAG;uBACnB;IACF;IAEA,OAAO;QACL,GAAG,gBAAgB;QACnB,YAAY;IACd;AACF","sources":["packages/@react-stately/color/src/useColorChannelFieldState.ts"],"sourcesContent":["import {Color, ColorChannel, ColorFieldProps, ColorSpace} from '@react-types/color';\nimport {NumberFieldState, useNumberFieldState} from '@react-stately/numberfield';\nimport {useColor} from './useColor';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface ColorChannelFieldProps extends ColorFieldProps {\n colorSpace?: ColorSpace,\n channel: ColorChannel\n}\n\nexport interface ColorChannelFieldStateOptions extends ColorChannelFieldProps {\n locale: string\n}\n\nexport interface ColorChannelFieldState extends NumberFieldState {\n colorValue: Color\n}\n\n/**\n * Provides state management for a color channel field, allowing users to edit the\n * value of an individual color channel.\n */\nexport function useColorChannelFieldState(props: ColorChannelFieldStateOptions): ColorChannelFieldState {\n let {channel, colorSpace, locale} = props;\n let initialValue = useColor(props.value);\n let initialDefaultValue = useColor(props.defaultValue || '#0000')!;\n let [colorValue, setColor] = useControlledState(initialValue || undefined, initialDefaultValue, props.onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let value = color.getChannelValue(channel);\n let range = color.getChannelRange(channel);\n let formatOptions = useMemo(() => color.getChannelFormatOptions(channel), [color, channel]);\n let multiplier = formatOptions.style === 'percent' && range.maxValue === 100 ? 100 : 1;\n\n let numberFieldState = useNumberFieldState({\n locale,\n value: value / multiplier,\n onChange: (v) => setColor(color.withChannelValue(channel, v * multiplier)),\n minValue: range.minValue / multiplier,\n maxValue: range.maxValue / multiplier,\n step: range.step / multiplier,\n formatOptions\n });\n\n return {\n ...numberFieldState,\n colorValue: color\n };\n}\n"],"names":[],"version":3,"file":"useColorChannelFieldState.main.js.map"}
@@ -0,0 +1,43 @@
1
+ import {useColor as $aa90ad8b2b1d015f$export$5aadd9c0606af5c2} from "./useColor.mjs";
2
+ import {useNumberFieldState as $52OvP$useNumberFieldState} from "@react-stately/numberfield";
3
+ import {useControlledState as $52OvP$useControlledState} from "@react-stately/utils";
4
+ import {useMemo as $52OvP$useMemo} from "react";
5
+
6
+
7
+
8
+
9
+
10
+ function $31a863bb88e75dd6$export$b9fc0d69c9190c4a(props) {
11
+ let { channel: channel, colorSpace: colorSpace, locale: locale } = props;
12
+ let initialValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.value);
13
+ let initialDefaultValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.defaultValue || "#0000");
14
+ let [colorValue, setColor] = (0, $52OvP$useControlledState)(initialValue || undefined, initialDefaultValue, props.onChange);
15
+ let color = (0, $52OvP$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
16
+ colorValue,
17
+ colorSpace
18
+ ]);
19
+ let value = color.getChannelValue(channel);
20
+ let range = color.getChannelRange(channel);
21
+ let formatOptions = (0, $52OvP$useMemo)(()=>color.getChannelFormatOptions(channel), [
22
+ color,
23
+ channel
24
+ ]);
25
+ let multiplier = formatOptions.style === "percent" && range.maxValue === 100 ? 100 : 1;
26
+ let numberFieldState = (0, $52OvP$useNumberFieldState)({
27
+ locale: locale,
28
+ value: value / multiplier,
29
+ onChange: (v)=>setColor(color.withChannelValue(channel, v * multiplier)),
30
+ minValue: range.minValue / multiplier,
31
+ maxValue: range.maxValue / multiplier,
32
+ step: range.step / multiplier,
33
+ formatOptions: formatOptions
34
+ });
35
+ return {
36
+ ...numberFieldState,
37
+ colorValue: color
38
+ };
39
+ }
40
+
41
+
42
+ export {$31a863bb88e75dd6$export$b9fc0d69c9190c4a as useColorChannelFieldState};
43
+ //# sourceMappingURL=useColorChannelFieldState.mjs.map
@@ -0,0 +1,43 @@
1
+ import {useColor as $aa90ad8b2b1d015f$export$5aadd9c0606af5c2} from "./useColor.module.js";
2
+ import {useNumberFieldState as $52OvP$useNumberFieldState} from "@react-stately/numberfield";
3
+ import {useControlledState as $52OvP$useControlledState} from "@react-stately/utils";
4
+ import {useMemo as $52OvP$useMemo} from "react";
5
+
6
+
7
+
8
+
9
+
10
+ function $31a863bb88e75dd6$export$b9fc0d69c9190c4a(props) {
11
+ let { channel: channel, colorSpace: colorSpace, locale: locale } = props;
12
+ let initialValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.value);
13
+ let initialDefaultValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.defaultValue || "#0000");
14
+ let [colorValue, setColor] = (0, $52OvP$useControlledState)(initialValue || undefined, initialDefaultValue, props.onChange);
15
+ let color = (0, $52OvP$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
16
+ colorValue,
17
+ colorSpace
18
+ ]);
19
+ let value = color.getChannelValue(channel);
20
+ let range = color.getChannelRange(channel);
21
+ let formatOptions = (0, $52OvP$useMemo)(()=>color.getChannelFormatOptions(channel), [
22
+ color,
23
+ channel
24
+ ]);
25
+ let multiplier = formatOptions.style === "percent" && range.maxValue === 100 ? 100 : 1;
26
+ let numberFieldState = (0, $52OvP$useNumberFieldState)({
27
+ locale: locale,
28
+ value: value / multiplier,
29
+ onChange: (v)=>setColor(color.withChannelValue(channel, v * multiplier)),
30
+ minValue: range.minValue / multiplier,
31
+ maxValue: range.maxValue / multiplier,
32
+ step: range.step / multiplier,
33
+ formatOptions: formatOptions
34
+ });
35
+ return {
36
+ ...numberFieldState,
37
+ colorValue: color
38
+ };
39
+ }
40
+
41
+
42
+ export {$31a863bb88e75dd6$export$b9fc0d69c9190c4a as useColorChannelFieldState};
43
+ //# sourceMappingURL=useColorChannelFieldState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAuBO,SAAS,0CAA0B,KAAoC;IAC5E,IAAI,WAAC,OAAO,cAAE,UAAU,UAAE,MAAM,EAAC,GAAG;IACpC,IAAI,eAAe,CAAA,GAAA,yCAAO,EAAE,MAAM,KAAK;IACvC,IAAI,sBAAsB,CAAA,GAAA,yCAAO,EAAE,MAAM,YAAY,IAAI;IACzD,IAAI,CAAC,YAAY,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,gBAAgB,WAAW,qBAAqB,MAAM,QAAQ;IAC9G,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAM,cAAc,aAAa,WAAW,QAAQ,CAAC,cAAc,YAAY;QAAC;QAAY;KAAW;IAC3H,IAAI,QAAQ,MAAM,eAAe,CAAC;IAClC,IAAI,QAAQ,MAAM,eAAe,CAAC;IAClC,IAAI,gBAAgB,CAAA,GAAA,cAAM,EAAE,IAAM,MAAM,uBAAuB,CAAC,UAAU;QAAC;QAAO;KAAQ;IAC1F,IAAI,aAAa,cAAc,KAAK,KAAK,aAAa,MAAM,QAAQ,KAAK,MAAM,MAAM;IAErF,IAAI,mBAAmB,CAAA,GAAA,0BAAkB,EAAE;gBACzC;QACA,OAAO,QAAQ;QACf,UAAU,CAAC,IAAM,SAAS,MAAM,gBAAgB,CAAC,SAAS,IAAI;QAC9D,UAAU,MAAM,QAAQ,GAAG;QAC3B,UAAU,MAAM,QAAQ,GAAG;QAC3B,MAAM,MAAM,IAAI,GAAG;uBACnB;IACF;IAEA,OAAO;QACL,GAAG,gBAAgB;QACnB,YAAY;IACd;AACF","sources":["packages/@react-stately/color/src/useColorChannelFieldState.ts"],"sourcesContent":["import {Color, ColorChannel, ColorFieldProps, ColorSpace} from '@react-types/color';\nimport {NumberFieldState, useNumberFieldState} from '@react-stately/numberfield';\nimport {useColor} from './useColor';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface ColorChannelFieldProps extends ColorFieldProps {\n colorSpace?: ColorSpace,\n channel: ColorChannel\n}\n\nexport interface ColorChannelFieldStateOptions extends ColorChannelFieldProps {\n locale: string\n}\n\nexport interface ColorChannelFieldState extends NumberFieldState {\n colorValue: Color\n}\n\n/**\n * Provides state management for a color channel field, allowing users to edit the\n * value of an individual color channel.\n */\nexport function useColorChannelFieldState(props: ColorChannelFieldStateOptions): ColorChannelFieldState {\n let {channel, colorSpace, locale} = props;\n let initialValue = useColor(props.value);\n let initialDefaultValue = useColor(props.defaultValue || '#0000')!;\n let [colorValue, setColor] = useControlledState(initialValue || undefined, initialDefaultValue, props.onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let value = color.getChannelValue(channel);\n let range = color.getChannelRange(channel);\n let formatOptions = useMemo(() => color.getChannelFormatOptions(channel), [color, channel]);\n let multiplier = formatOptions.style === 'percent' && range.maxValue === 100 ? 100 : 1;\n\n let numberFieldState = useNumberFieldState({\n locale,\n value: value / multiplier,\n onChange: (v) => setColor(color.withChannelValue(channel, v * multiplier)),\n minValue: range.minValue / multiplier,\n maxValue: range.maxValue / multiplier,\n step: range.step / multiplier,\n formatOptions\n });\n\n return {\n ...numberFieldState,\n colorValue: color\n };\n}\n"],"names":[],"version":3,"file":"useColorChannelFieldState.module.js.map"}
@@ -0,0 +1,27 @@
1
+ var $83fe1a57d631223b$exports = require("./Color.main.js");
2
+ var $f8b3be23ba4462b1$exports = require("./useColor.main.js");
3
+ var $1Pz5H$reactstatelyutils = require("@react-stately/utils");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useColorPickerState", () => $f31788ea48a5c383$export$dc6b73b623f8645f);
11
+
12
+
13
+
14
+ function $f31788ea48a5c383$export$dc6b73b623f8645f(props) {
15
+ let value = (0, $f8b3be23ba4462b1$exports.useColor)(props.value);
16
+ let defaultValue = (0, $f8b3be23ba4462b1$exports.useColor)(props.defaultValue || "#0000");
17
+ let [color, setColor] = (0, $1Pz5H$reactstatelyutils.useControlledState)(value || undefined, defaultValue, props.onChange);
18
+ return {
19
+ color: color,
20
+ setColor (color) {
21
+ setColor(color || (0, $83fe1a57d631223b$exports.parseColor)("#0000"));
22
+ }
23
+ };
24
+ }
25
+
26
+
27
+ //# sourceMappingURL=useColorPickerState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAeO,SAAS,0CAAoB,KAAuB;IACzD,IAAI,QAAQ,CAAA,GAAA,kCAAO,EAAE,MAAM,KAAK;IAChC,IAAI,eAAe,CAAA,GAAA,kCAAO,EAAE,MAAM,YAAY,IAAI;IAClD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,2CAAiB,EAAE,SAAS,WAAW,cAAc,MAAM,QAAQ;IAE3F,OAAO;eACL;QACA,UAAS,KAAK;YACZ,SAAS,SAAS,CAAA,GAAA,oCAAS,EAAE;QAC/B;IACF;AACF","sources":["packages/@react-stately/color/src/useColorPickerState.ts"],"sourcesContent":["import {Color} from '@react-types/color';\nimport {parseColor} from './Color';\nimport {useColor} from './useColor';\nimport {useControlledState} from '@react-stately/utils';\nimport {ValueBase} from '@react-types/shared';\n\nexport interface ColorPickerProps extends ValueBase<string | Color | null, Color> {}\n\nexport interface ColorPickerState {\n /** The current color value of the color picker. */\n color: Color,\n /** Sets the current color value of the color picker. */\n setColor(color: Color | null): void\n}\n\nexport function useColorPickerState(props: ColorPickerProps): ColorPickerState {\n let value = useColor(props.value);\n let defaultValue = useColor(props.defaultValue || '#0000')!;\n let [color, setColor] = useControlledState(value || undefined, defaultValue, props.onChange);\n \n return {\n color,\n setColor(color) {\n setColor(color || parseColor('#0000'));\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorPickerState.main.js.map"}
@@ -0,0 +1,22 @@
1
+ import {parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.mjs";
2
+ import {useColor as $aa90ad8b2b1d015f$export$5aadd9c0606af5c2} from "./useColor.mjs";
3
+ import {useControlledState as $5GESt$useControlledState} from "@react-stately/utils";
4
+
5
+
6
+
7
+
8
+ function $309d2b7669014898$export$dc6b73b623f8645f(props) {
9
+ let value = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.value);
10
+ let defaultValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.defaultValue || "#0000");
11
+ let [color, setColor] = (0, $5GESt$useControlledState)(value || undefined, defaultValue, props.onChange);
12
+ return {
13
+ color: color,
14
+ setColor (color) {
15
+ setColor(color || (0, $799cddbef784668f$export$6e865ea70d7724f)("#0000"));
16
+ }
17
+ };
18
+ }
19
+
20
+
21
+ export {$309d2b7669014898$export$dc6b73b623f8645f as useColorPickerState};
22
+ //# sourceMappingURL=useColorPickerState.mjs.map
@@ -0,0 +1,22 @@
1
+ import {parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.module.js";
2
+ import {useColor as $aa90ad8b2b1d015f$export$5aadd9c0606af5c2} from "./useColor.module.js";
3
+ import {useControlledState as $5GESt$useControlledState} from "@react-stately/utils";
4
+
5
+
6
+
7
+
8
+ function $309d2b7669014898$export$dc6b73b623f8645f(props) {
9
+ let value = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.value);
10
+ let defaultValue = (0, $aa90ad8b2b1d015f$export$5aadd9c0606af5c2)(props.defaultValue || "#0000");
11
+ let [color, setColor] = (0, $5GESt$useControlledState)(value || undefined, defaultValue, props.onChange);
12
+ return {
13
+ color: color,
14
+ setColor (color) {
15
+ setColor(color || (0, $799cddbef784668f$export$6e865ea70d7724f)("#0000"));
16
+ }
17
+ };
18
+ }
19
+
20
+
21
+ export {$309d2b7669014898$export$dc6b73b623f8645f as useColorPickerState};
22
+ //# sourceMappingURL=useColorPickerState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAeO,SAAS,0CAAoB,KAAuB;IACzD,IAAI,QAAQ,CAAA,GAAA,yCAAO,EAAE,MAAM,KAAK;IAChC,IAAI,eAAe,CAAA,GAAA,yCAAO,EAAE,MAAM,YAAY,IAAI;IAClD,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,SAAS,WAAW,cAAc,MAAM,QAAQ;IAE3F,OAAO;eACL;QACA,UAAS,KAAK;YACZ,SAAS,SAAS,CAAA,GAAA,wCAAS,EAAE;QAC/B;IACF;AACF","sources":["packages/@react-stately/color/src/useColorPickerState.ts"],"sourcesContent":["import {Color} from '@react-types/color';\nimport {parseColor} from './Color';\nimport {useColor} from './useColor';\nimport {useControlledState} from '@react-stately/utils';\nimport {ValueBase} from '@react-types/shared';\n\nexport interface ColorPickerProps extends ValueBase<string | Color | null, Color> {}\n\nexport interface ColorPickerState {\n /** The current color value of the color picker. */\n color: Color,\n /** Sets the current color value of the color picker. */\n setColor(color: Color | null): void\n}\n\nexport function useColorPickerState(props: ColorPickerProps): ColorPickerState {\n let value = useColor(props.value);\n let defaultValue = useColor(props.defaultValue || '#0000')!;\n let [color, setColor] = useControlledState(value || undefined, defaultValue, props.onChange);\n \n return {\n color,\n setColor(color) {\n setColor(color || parseColor('#0000'));\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorPickerState.module.js.map"}
@@ -1,6 +1,7 @@
1
1
  var $83fe1a57d631223b$exports = require("./Color.main.js");
2
2
  var $93tpS$reactstatelyslider = require("@react-stately/slider");
3
3
  var $93tpS$reactstatelyutils = require("@react-stately/utils");
4
+ var $93tpS$react = require("react");
4
5
 
5
6
 
6
7
  function $parcel$export(e, n, v, s) {
@@ -21,10 +22,15 @@ $parcel$export(module.exports, "useColorSliderState", () => $5386a492cfd3234c$ex
21
22
  */
22
23
 
23
24
 
25
+
24
26
  function $5386a492cfd3234c$export$57bc203e1c9c6d44(props) {
25
- let { channel: channel, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
27
+ let { channel: channel, colorSpace: colorSpace, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
26
28
  if (value == null && defaultValue == null) throw new Error("useColorSliderState requires a value or defaultValue");
27
- let [color, setColor] = (0, $93tpS$reactstatelyutils.useControlledState)(value && (0, $83fe1a57d631223b$exports.normalizeColor)(value), defaultValue && (0, $83fe1a57d631223b$exports.normalizeColor)(defaultValue), onChange);
29
+ let [colorValue, setColor] = (0, $93tpS$reactstatelyutils.useControlledState)(value && (0, $83fe1a57d631223b$exports.normalizeColor)(value), defaultValue && (0, $83fe1a57d631223b$exports.normalizeColor)(defaultValue), onChange);
30
+ let color = (0, $93tpS$react.useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
31
+ colorValue,
32
+ colorSpace
33
+ ]);
28
34
  let sliderState = (0, $93tpS$reactstatelyslider.useSliderState)({
29
35
  ...color.getChannelRange(channel),
30
36
  ...otherProps,
@@ -67,7 +73,8 @@ function $5386a492cfd3234c$export$57bc203e1c9c6d44(props) {
67
73
  return color.formatChannelValue(channel, locale);
68
74
  },
69
75
  step: step,
70
- pageSize: pageSize
76
+ pageSize: pageSize,
77
+ isDragging: sliderState.isThumbDragging(0)
71
78
  };
72
79
  }
73
80
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAoB,KAA8B;IAChE,IAAI,WAAC,OAAO,SAAE,KAAK,gBAAE,YAAY,YAAE,QAAQ,UAAE,MAAM,EAAE,GAAG,YAAW,GAAG;IACtE,IAAI,SAAS,QAAQ,gBAAgB,MACnC,MAAM,IAAI,MAAM;IAGlB,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,2CAAiB,EAAE,SAAS,CAAA,GAAA,wCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,wCAAa,EAAE,eAAe;IACzH,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,MAAM,eAAe,CAAC,QAAQ;QACjC,GAAG,UAAU;QACb,8FAA8F;QAC9F,iBAAiB;QACjB,OAAO,MAAM,eAAe,CAAC;QAC7B,UAAS,CAAC;YACR,SAAS,MAAM,gBAAgB,CAAC,SAAS;QAC3C;QACA,aAAY,CAAC;YACX,mGAAmG;YACnG,IAAI,MAAM,WAAW,EACnB,MAAM,WAAW,CAAC,MAAM,gBAAgB,CAAC,SAAS;QAEtD;IACF;IAEA,IAAI,QAAC,IAAI,YAAE,QAAQ,EAAC,GAAG,MAAM,eAAe,CAAC;IAC7C,OAAO;QACL,GAAG,WAAW;QACd,OAAO;QACP,UAAS,KAAK;YACZ,SAAS,CAAA,GAAA,wCAAa,EAAE;QAC1B;QACA;YACE,OAAQ;gBACN,KAAK;oBACH,OAAO,CAAA,GAAA,oCAAS,EAAE,CAAC,IAAI,EAAE,MAAM,eAAe,CAAC,OAAO,YAAY,CAAC;gBACrE,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;oBACH,OAAO,MAAM,gBAAgB,CAAC,SAAS;gBACzC,KAAK;oBACH,OAAO;gBAET;oBACE,MAAM,IAAI,MAAM,4BAA4B;YAChD;QACF;QACA;YACE,OAAO,MAAM,kBAAkB,CAAC,SAAS;QAC3C;cACA;kBACA;IACF;AACF","sources":["packages/@react-stately/color/src/useColorSliderState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Color, ColorSliderProps} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {SliderState, useSliderState} from '@react-stately/slider';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ColorSliderState extends SliderState {\n /** The current color value represented by the color slider. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n /** Returns the color that should be displayed in the slider instead of `value` or the optional parameter. */\n getDisplayColor(): Color\n}\n\n\nexport interface ColorSliderStateOptions extends ColorSliderProps {\n /** The locale to use for formatting the color channel value. */\n locale: string\n}\n\n/**\n * Provides state management for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSliderState(props: ColorSliderStateOptions): ColorSliderState {\n let {channel, value, defaultValue, onChange, locale, ...otherProps} = props;\n if (value == null && defaultValue == null) {\n throw new Error('useColorSliderState requires a value or defaultValue');\n }\n\n let [color, setColor] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let sliderState = useSliderState({\n ...color.getChannelRange(channel),\n ...otherProps,\n // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.\n numberFormatter: null,\n value: color.getChannelValue(channel),\n onChange(v) {\n setColor(color.withChannelValue(channel, v));\n },\n onChangeEnd(v) {\n // onChange will have already been called with the right value, this is just to trigger onChangeEnd\n if (props.onChangeEnd) {\n props.onChangeEnd(color.withChannelValue(channel, v));\n }\n }\n });\n\n let {step, pageSize} = color.getChannelRange(channel);\n return {\n ...sliderState,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n getDisplayColor() {\n switch (channel) {\n case 'hue':\n return parseColor(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);\n case 'lightness':\n case 'brightness':\n case 'saturation':\n case 'red':\n case 'green':\n case 'blue':\n return color.withChannelValue('alpha', 1);\n case 'alpha': {\n return color;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n },\n getThumbValueLabel() {\n return color.formatChannelValue(channel, locale);\n },\n step,\n pageSize\n };\n}\n"],"names":[],"version":3,"file":"useColorSliderState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA6BM,SAAS,0CAAoB,KAA8B;IAChE,IAAI,WAAC,OAAO,cAAE,UAAU,SAAE,KAAK,gBAAE,YAAY,YAAE,QAAQ,UAAE,MAAM,EAAE,GAAG,YAAW,GAAG;IAClF,IAAI,SAAS,QAAQ,g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State.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Color, ColorSliderProps} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {SliderState, useSliderState} from '@react-stately/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface ColorSliderState extends SliderState {\n /** The current color value represented by the color slider. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n /** Returns the color that should be displayed in the slider instead of `value` or the optional parameter. */\n getDisplayColor(): Color,\n /** Whether the color slider is currently being dragged. */\n readonly isDragging: boolean\n}\n\n\nexport interface ColorSliderStateOptions extends ColorSliderProps {\n /** The locale to use for formatting the color channel value. */\n locale: string\n}\n\n/**\n * Provides state management for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSliderState(props: ColorSliderStateOptions): ColorSliderState {\n let {channel, colorSpace, value, defaultValue, onChange, locale, ...otherProps} = props;\n if (value == null && defaultValue == null) {\n throw new Error('useColorSliderState requires a value or defaultValue');\n }\n\n let [colorValue, setColor] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let sliderState = useSliderState({\n ...color.getChannelRange(channel),\n ...otherProps,\n // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.\n numberFormatter: null,\n value: color.getChannelValue(channel),\n onChange(v) {\n setColor(color.withChannelValue(channel, v));\n },\n onChangeEnd(v) {\n // onChange will have already been called with the right value, this is just to trigger onChangeEnd\n if (props.onChangeEnd) {\n props.onChangeEnd(color.withChannelValue(channel, v));\n }\n }\n });\n\n let {step, pageSize} = color.getChannelRange(channel);\n return {\n ...sliderState,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n getDisplayColor() {\n switch (channel) {\n case 'hue':\n return parseColor(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);\n case 'lightness':\n case 'brightness':\n case 'saturation':\n case 'red':\n case 'green':\n case 'blue':\n return color.withChannelValue('alpha', 1);\n case 'alpha': {\n return color;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n },\n getThumbValueLabel() {\n return color.formatChannelValue(channel, locale);\n },\n step,\n pageSize,\n isDragging: sliderState.isThumbDragging(0)\n };\n}\n"],"names":[],"version":3,"file":"useColorSliderState.main.js.map"}
@@ -1,6 +1,7 @@
1
1
  import {normalizeColor as $799cddbef784668f$export$4cde5df63f53f473, parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.mjs";
2
2
  import {useSliderState as $1Eavr$useSliderState} from "@react-stately/slider";
3
3
  import {useControlledState as $1Eavr$useControlledState} from "@react-stately/utils";
4
+ import {useMemo as $1Eavr$useMemo} from "react";
4
5
 
5
6
  /*
6
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,10 +16,15 @@ import {useControlledState as $1Eavr$useControlledState} from "@react-stately/ut
15
16
  */
16
17
 
17
18
 
19
+
18
20
  function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
19
- let { channel: channel, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
21
+ let { channel: channel, colorSpace: colorSpace, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
20
22
  if (value == null && defaultValue == null) throw new Error("useColorSliderState requires a value or defaultValue");
21
- let [color, setColor] = (0, $1Eavr$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
23
+ let [colorValue, setColor] = (0, $1Eavr$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
24
+ let color = (0, $1Eavr$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
25
+ colorValue,
26
+ colorSpace
27
+ ]);
22
28
  let sliderState = (0, $1Eavr$useSliderState)({
23
29
  ...color.getChannelRange(channel),
24
30
  ...otherProps,
@@ -61,7 +67,8 @@ function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
61
67
  return color.formatChannelValue(channel, locale);
62
68
  },
63
69
  step: step,
64
- pageSize: pageSize
70
+ pageSize: pageSize,
71
+ isDragging: sliderState.isThumbDragging(0)
65
72
  };
66
73
  }
67
74
 
@@ -1,6 +1,7 @@
1
1
  import {normalizeColor as $799cddbef784668f$export$4cde5df63f53f473, parseColor as $799cddbef784668f$export$6e865ea70d7724f} from "./Color.module.js";
2
2
  import {useSliderState as $1Eavr$useSliderState} from "@react-stately/slider";
3
3
  import {useControlledState as $1Eavr$useControlledState} from "@react-stately/utils";
4
+ import {useMemo as $1Eavr$useMemo} from "react";
4
5
 
5
6
  /*
6
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,10 +16,15 @@ import {useControlledState as $1Eavr$useControlledState} from "@react-stately/ut
15
16
  */
16
17
 
17
18
 
19
+
18
20
  function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
19
- let { channel: channel, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
21
+ let { channel: channel, colorSpace: colorSpace, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
20
22
  if (value == null && defaultValue == null) throw new Error("useColorSliderState requires a value or defaultValue");
21
- let [color, setColor] = (0, $1Eavr$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
23
+ let [colorValue, setColor] = (0, $1Eavr$useControlledState)(value && (0, $799cddbef784668f$export$4cde5df63f53f473)(value), defaultValue && (0, $799cddbef784668f$export$4cde5df63f53f473)(defaultValue), onChange);
24
+ let color = (0, $1Eavr$useMemo)(()=>colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
25
+ colorValue,
26
+ colorSpace
27
+ ]);
22
28
  let sliderState = (0, $1Eavr$useSliderState)({
23
29
  ...color.getChannelRange(channel),
24
30
  ...otherProps,
@@ -61,7 +67,8 @@ function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
61
67
  return color.formatChannelValue(channel, locale);
62
68
  },
63
69
  step: step,
64
- pageSize: pageSize
70
+ pageSize: pageSize,
71
+ isDragging: sliderState.isThumbDragging(0)
65
72
  };
66
73
  }
67
74
 
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAoB,KAA8B;IAChE,IAAI,WAAC,OAAO,SAAE,KAAK,gBAAE,YAAY,YAAE,QAAQ,UAAE,MAAM,EAAE,GAAG,YAAW,GAAG;IACtE,IAAI,SAAS,QAAQ,gBAAgB,MACnC,MAAM,IAAI,MAAM;IAGlB,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yBAAiB,EAAE,SAAS,CAAA,GAAA,yCAAa,EAAE,QAAQ,gBAAgB,CAAA,GAAA,yCAAa,EAAE,eAAe;IACzH,IAAI,cAAc,CAAA,GAAA,qBAAa,EAAE;QAC/B,GAAG,MAAM,eAAe,CAAC,QAAQ;QACjC,GAAG,UAAU;QACb,8FAA8F;QAC9F,iBAAiB;QACjB,OAAO,MAAM,eAAe,CAAC;QAC7B,UAAS,CAAC;YACR,SAAS,MAAM,gBAAgB,CAAC,SAAS;QAC3C;QACA,aAAY,CAAC;YACX,mGAAmG;YACnG,IAAI,MAAM,WAAW,EACnB,MAAM,WAAW,CAAC,MAAM,gBAAgB,CAAC,SAAS;QAEtD;IACF;IAEA,IAAI,QAAC,IAAI,YAAE,QAAQ,EAAC,GAAG,MAAM,eAAe,CAAC;IAC7C,OAAO;QACL,GAAG,WAAW;QACd,OAAO;QACP,UAAS,KAAK;YACZ,SAAS,CAAA,GAAA,yCAAa,EAAE;QAC1B;QACA;YACE,OAAQ;gBACN,KAAK;oBACH,OAAO,CAAA,GAAA,wCAAS,EAAE,CAAC,IAAI,EAAE,MAAM,eAAe,CAAC,OAAO,YAAY,CAAC;gBACrE,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;oBACH,OAAO,MAAM,gBAAgB,CAAC,SAAS;gBACzC,KAAK;oBACH,OAAO;gBAET;oBACE,MAAM,IAAI,MAAM,4BAA4B;YAChD;QACF;QACA;YACE,OAAO,MAAM,kBAAkB,CAAC,SAAS;QAC3C;cACA;kBACA;IACF;AACF","sources":["packages/@react-stately/color/src/useColorSliderState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Color, ColorSliderProps} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {SliderState, useSliderState} from '@react-stately/slider';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ColorSliderState extends SliderState {\n /** The current color value represented by the color slider. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n /** Returns the color that should be displayed in the slider instead of `value` or the optional parameter. */\n getDisplayColor(): Color\n}\n\n\nexport interface ColorSliderStateOptions extends ColorSliderProps {\n /** The locale to use for formatting the color channel value. */\n locale: string\n}\n\n/**\n * Provides state management for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSliderState(props: ColorSliderStateOptions): ColorSliderState {\n let {channel, value, defaultValue, onChange, locale, ...otherProps} = props;\n if (value == null && defaultValue == null) {\n throw new Error('useColorSliderState requires a value or defaultValue');\n }\n\n let [color, setColor] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let sliderState = useSliderState({\n ...color.getChannelRange(channel),\n ...otherProps,\n // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.\n numberFormatter: null,\n value: color.getChannelValue(channel),\n onChange(v) {\n setColor(color.withChannelValue(channel, v));\n },\n onChangeEnd(v) {\n // onChange will have already been called with the right value, this is just to trigger onChangeEnd\n if (props.onChangeEnd) {\n props.onChangeEnd(color.withChannelValue(channel, v));\n }\n }\n });\n\n let {step, pageSize} = color.getChannelRange(channel);\n return {\n ...sliderState,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n getDisplayColor() {\n switch (channel) {\n case 'hue':\n return parseColor(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);\n case 'lightness':\n case 'brightness':\n case 'saturation':\n case 'red':\n case 'green':\n case 'blue':\n return color.withChannelValue('alpha', 1);\n case 'alpha': {\n return color;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n },\n getThumbValueLabel() {\n return color.formatChannelValue(channel, locale);\n },\n step,\n pageSize\n };\n}\n"],"names":[],"version":3,"file":"useColorSliderState.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA6BM,SAAS,0CAAoB,KAA8B;IAChE,IAAI,WAAC,OAAO,cAAE,UAAU,SAAE,KAAK,gBAAE,YAAY,YAAE,QAAQ,UAAE,MAAM,EAAE,GAAG,YAAW,GAAG;IAClF,IAAI,SAAS,QAAQ,gBAAgB,MACnC,MAAM,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\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Color, ColorSliderProps} from '@react-types/color';\nimport {normalizeColor, parseColor} from './Color';\nimport {SliderState, useSliderState} from '@react-stately/slider';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo} from 'react';\n\nexport interface ColorSliderState extends SliderState {\n /** The current color value represented by the color slider. */\n readonly value: Color,\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue(value: string | Color): void,\n /** Returns the color that should be displayed in the slider instead of `value` or the optional parameter. */\n getDisplayColor(): Color,\n /** Whether the color slider is currently being dragged. */\n readonly isDragging: boolean\n}\n\n\nexport interface ColorSliderStateOptions extends ColorSliderProps {\n /** The locale to use for formatting the color channel value. */\n locale: string\n}\n\n/**\n * Provides state management for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSliderState(props: ColorSliderStateOptions): ColorSliderState {\n let {channel, colorSpace, value, defaultValue, onChange, locale, ...otherProps} = props;\n if (value == null && defaultValue == null) {\n throw new Error('useColorSliderState requires a value or defaultValue');\n }\n\n let [colorValue, setColor] = useControlledState(value && normalizeColor(value), defaultValue && normalizeColor(defaultValue), onChange);\n let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [colorValue, colorSpace]);\n let sliderState = useSliderState({\n ...color.getChannelRange(channel),\n ...otherProps,\n // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.\n numberFormatter: null,\n value: color.getChannelValue(channel),\n onChange(v) {\n setColor(color.withChannelValue(channel, v));\n },\n onChangeEnd(v) {\n // onChange will have already been called with the right value, this is just to trigger onChangeEnd\n if (props.onChangeEnd) {\n props.onChangeEnd(color.withChannelValue(channel, v));\n }\n }\n });\n\n let {step, pageSize} = color.getChannelRange(channel);\n return {\n ...sliderState,\n value: color,\n setValue(value) {\n setColor(normalizeColor(value));\n },\n getDisplayColor() {\n switch (channel) {\n case 'hue':\n return parseColor(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);\n case 'lightness':\n case 'brightness':\n case 'saturation':\n case 'red':\n case 'green':\n case 'blue':\n return color.withChannelValue('alpha', 1);\n case 'alpha': {\n return color;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n },\n getThumbValueLabel() {\n return color.formatChannelValue(channel, locale);\n },\n step,\n pageSize,\n isDragging: sliderState.isThumbDragging(0)\n };\n}\n"],"names":[],"version":3,"file":"useColorSliderState.module.js.map"}
@@ -56,7 +56,13 @@ function $9d7d8736d45f74b8$var$cartesianToAngle(x, y, radius) {
56
56
  function $9d7d8736d45f74b8$export$f4301076d9336137(props) {
57
57
  let { defaultValue: defaultValue, onChange: onChange, onChangeEnd: onChangeEnd } = props;
58
58
  if (!props.value && !defaultValue) defaultValue = $9d7d8736d45f74b8$var$DEFAULT_COLOR;
59
- let [value, setValueState] = (0, $5Frb2$reactstatelyutils.useControlledState)((0, $83fe1a57d631223b$exports.normalizeColor)(props.value), (0, $83fe1a57d631223b$exports.normalizeColor)(defaultValue), onChange);
59
+ let [stateValue, setValueState] = (0, $5Frb2$reactstatelyutils.useControlledState)((0, $83fe1a57d631223b$exports.normalizeColor)(props.value), (0, $83fe1a57d631223b$exports.normalizeColor)(defaultValue), onChange);
60
+ let value = (0, $5Frb2$react.useMemo)(()=>{
61
+ let colorSpace = stateValue.getColorSpace();
62
+ return colorSpace === "hsl" || colorSpace === "hsb" ? stateValue : stateValue.toFormat("hsl");
63
+ }, [
64
+ stateValue
65
+ ]);
60
66
  let valueRef = (0, $5Frb2$react.useRef)(value);
61
67
  let setValue = (value)=>{
62
68
  valueRef.current = value;
@@ -115,7 +121,8 @@ function $9d7d8736d45f74b8$export$f4301076d9336137(props) {
115
121
  isDragging: isDragging,
116
122
  getDisplayColor () {
117
123
  return value.toFormat("hsl").withChannelValue("saturation", 100).withChannelValue("lightness", 50).withChannelValue("alpha", 1);
118
- }
124
+ },
125
+ isDisabled: props.isDisabled || false
119
126
  };
120
127
  }
121
128