@react-aria/color 3.0.0-nightly.4552 → 3.0.0-nightly.4558

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 (70) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +4 -1144
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +8 -1148
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +4 -1144
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useColorArea.main.js +404 -0
  44. package/dist/useColorArea.main.js.map +1 -0
  45. package/dist/useColorArea.mjs +399 -0
  46. package/dist/useColorArea.module.js +399 -0
  47. package/dist/useColorArea.module.js.map +1 -0
  48. package/dist/useColorAreaGradient.main.js +229 -0
  49. package/dist/useColorAreaGradient.main.js.map +1 -0
  50. package/dist/useColorAreaGradient.mjs +224 -0
  51. package/dist/useColorAreaGradient.module.js +224 -0
  52. package/dist/useColorAreaGradient.module.js.map +1 -0
  53. package/dist/useColorField.main.js +97 -0
  54. package/dist/useColorField.main.js.map +1 -0
  55. package/dist/useColorField.mjs +92 -0
  56. package/dist/useColorField.module.js +92 -0
  57. package/dist/useColorField.module.js.map +1 -0
  58. package/dist/useColorSlider.main.js +105 -0
  59. package/dist/useColorSlider.main.js.map +1 -0
  60. package/dist/useColorSlider.mjs +100 -0
  61. package/dist/useColorSlider.module.js +100 -0
  62. package/dist/useColorSlider.module.js.map +1 -0
  63. package/dist/useColorWheel.main.js +260 -0
  64. package/dist/useColorWheel.main.js.map +1 -0
  65. package/dist/useColorWheel.mjs +255 -0
  66. package/dist/useColorWheel.module.js +255 -0
  67. package/dist/useColorWheel.module.js.map +1 -0
  68. package/dist/zh-CN.mjs +1 -1
  69. package/dist/zh-TW.mjs +1 -1
  70. package/package.json +13 -13
@@ -0,0 +1,105 @@
1
+ var $edxco$reactariautils = require("@react-aria/utils");
2
+ var $edxco$reactariai18n = require("@react-aria/i18n");
3
+ var $edxco$reactariaslider = require("@react-aria/slider");
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, "useColorSlider", () => $afbb9647440a7f5b$export$106b7a4e66508f66);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
25
+ let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
26
+ let { locale: locale, direction: direction } = (0, $edxco$reactariai18n.useLocale)();
27
+ // Provide a default aria-label if there is no other label provided.
28
+ if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
29
+ // @ts-ignore - ignore unused incompatible props
30
+ let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $edxco$reactariaslider.useSlider)({
31
+ ...props,
32
+ "aria-label": ariaLabel
33
+ }, state, trackRef);
34
+ let { inputProps: inputProps, thumbProps: thumbProps } = (0, $edxco$reactariaslider.useSliderThumb)({
35
+ index: 0,
36
+ orientation: orientation,
37
+ isDisabled: props.isDisabled,
38
+ name: name,
39
+ trackRef: trackRef,
40
+ inputRef: inputRef
41
+ }, state);
42
+ let value = state.getDisplayColor();
43
+ let generateBackground = ()=>{
44
+ let to;
45
+ if (orientation === "vertical") to = "top";
46
+ else if (direction === "ltr") to = "right";
47
+ else to = "left";
48
+ switch(channel){
49
+ case "hue":
50
+ return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
51
+ case "lightness":
52
+ {
53
+ // We have to add an extra color stop in the middle so that the hue shows up at all.
54
+ // Otherwise it will always just be black to white.
55
+ let min = state.getThumbMinValue(0);
56
+ let max = state.getThumbMaxValue(0);
57
+ let start = value.withChannelValue(channel, min).toString("css");
58
+ let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
59
+ let end = value.withChannelValue(channel, max).toString("css");
60
+ return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
61
+ }
62
+ case "saturation":
63
+ case "brightness":
64
+ case "red":
65
+ case "green":
66
+ case "blue":
67
+ case "alpha":
68
+ {
69
+ let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
70
+ let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
71
+ return `linear-gradient(to ${to}, ${start}, ${end})`;
72
+ }
73
+ default:
74
+ throw new Error("Unknown color channel: " + channel);
75
+ }
76
+ };
77
+ let forcedColorAdjustNoneStyle = {
78
+ forcedColorAdjust: "none"
79
+ };
80
+ if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
81
+ else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
82
+ return {
83
+ trackProps: {
84
+ ...(0, $edxco$reactariautils.mergeProps)(groupProps, trackProps),
85
+ style: {
86
+ ...trackProps.style,
87
+ ...forcedColorAdjustNoneStyle,
88
+ background: generateBackground()
89
+ }
90
+ },
91
+ inputProps: inputProps,
92
+ thumbProps: {
93
+ ...thumbProps,
94
+ style: {
95
+ ...thumbProps.style,
96
+ ...forcedColorAdjustNoneStyle
97
+ }
98
+ },
99
+ labelProps: labelProps,
100
+ outputProps: outputProps
101
+ };
102
+ }
103
+
104
+
105
+ //# sourceMappingURL=useColorSlider.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,cAAc,SAAS,QAAE,IAAI,EAAC,GAAG;IAEhF,IAAI,UAAC,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AAK;YACL,KAAK;gBAAS;oBACZ,IAAI,QAAQ,MAAM,gBAAgB,CAAC,SAAS,MAAM,gBAAgB,CAAC,IAAI,QAAQ,CAAC;oBAChF,IAAI,MAAM,MAAM,gBAAgB,CAAC,SAAS,MAAM,gBAAgB,CAAC,IAAI,QAAQ,CAAC;oBAC9E,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;gBACtD;YACA;gBACE,MAAM,IAAI,MAAM,4BAA4B;QAChD;IACF;IAEA,IAAI,6BAA6B;QAAC,mBAAmB;IAAM;IAE3D,IAAI,YAAY,OACd,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,UAAU,CAAC,QAAQ,CAAC;SAC1D,IAAI,YAAY,SACrB,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC;IAGnE,OAAO;QACL,YAAY;YACV,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,WAAW;YACrC,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;gBAC7B,YAAY;YACd;QACF;oBACA;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;YAC/B;QACF;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/color/src/useColorSlider.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 {AriaColorSliderProps} from '@react-types/color';\nimport {ColorSliderState} from '@react-stately/color';\nimport {DOMAttributes} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSlider, useSliderThumb} from '@react-aria/slider';\n\nexport interface AriaColorSliderOptions extends AriaColorSliderProps {\n /** A ref for the track element. */\n trackRef: RefObject<Element>,\n /** A ref for the input element. */\n inputRef: RefObject<HTMLInputElement>\n}\n\nexport interface ColorSliderAria {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the output element, displaying the value of the color slider. */\n outputProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSlider(props: AriaColorSliderOptions, state: ColorSliderState): ColorSliderAria {\n let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name} = props;\n\n let {locale, direction} = useLocale();\n\n // Provide a default aria-label if there is no other label provided.\n if (!props.label && !ariaLabel && !props['aria-labelledby']) {\n ariaLabel = state.value.getChannelName(channel, locale);\n }\n\n // @ts-ignore - ignore unused incompatible props\n let {groupProps, trackProps, labelProps, outputProps} = useSlider({...props, 'aria-label': ariaLabel}, state, trackRef);\n let {inputProps, thumbProps} = useSliderThumb({\n index: 0,\n orientation,\n isDisabled: props.isDisabled,\n name,\n trackRef,\n inputRef\n }, state);\n\n let value = state.getDisplayColor();\n let generateBackground = () => {\n let to: string;\n if (orientation === 'vertical') {\n to = 'top';\n } else if (direction === 'ltr') {\n to = 'right';\n } else {\n to = 'left';\n }\n switch (channel) {\n case 'hue':\n return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;\n case 'lightness': {\n // We have to add an extra color stop in the middle so that the hue shows up at all.\n // Otherwise it will always just be black to white.\n let min = state.getThumbMinValue(0);\n let max = state.getThumbMaxValue(0);\n let start = value.withChannelValue(channel, min).toString('css');\n let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');\n let end = value.withChannelValue(channel, max).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;\n }\n case 'saturation':\n case 'brightness':\n case 'red':\n case 'green':\n case 'blue':\n case 'alpha': {\n let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');\n let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${end})`;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n };\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n if (channel === 'hue') {\n inputProps['aria-valuetext'] += `, ${value.getHueName(locale)}`;\n } else if (channel !== 'alpha') {\n inputProps['aria-valuetext'] += `, ${value.getColorName(locale)}`;\n }\n\n return {\n trackProps: {\n ...mergeProps(groupProps, trackProps),\n style: {\n ...trackProps.style,\n ...forcedColorAdjustNoneStyle,\n background: generateBackground()\n }\n },\n inputProps,\n thumbProps: {\n ...thumbProps,\n style: {\n ...thumbProps.style,\n ...forcedColorAdjustNoneStyle\n }\n },\n labelProps,\n outputProps\n };\n}\n"],"names":[],"version":3,"file":"useColorSlider.main.js.map"}
@@ -0,0 +1,100 @@
1
+ import {mergeProps as $6WsjB$mergeProps} from "@react-aria/utils";
2
+ import {useLocale as $6WsjB$useLocale} from "@react-aria/i18n";
3
+ import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb} from "@react-aria/slider";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
19
+ let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
20
+ let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
21
+ // Provide a default aria-label if there is no other label provided.
22
+ if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
23
+ // @ts-ignore - ignore unused incompatible props
24
+ let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $6WsjB$useSlider)({
25
+ ...props,
26
+ "aria-label": ariaLabel
27
+ }, state, trackRef);
28
+ let { inputProps: inputProps, thumbProps: thumbProps } = (0, $6WsjB$useSliderThumb)({
29
+ index: 0,
30
+ orientation: orientation,
31
+ isDisabled: props.isDisabled,
32
+ name: name,
33
+ trackRef: trackRef,
34
+ inputRef: inputRef
35
+ }, state);
36
+ let value = state.getDisplayColor();
37
+ let generateBackground = ()=>{
38
+ let to;
39
+ if (orientation === "vertical") to = "top";
40
+ else if (direction === "ltr") to = "right";
41
+ else to = "left";
42
+ switch(channel){
43
+ case "hue":
44
+ return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
45
+ case "lightness":
46
+ {
47
+ // We have to add an extra color stop in the middle so that the hue shows up at all.
48
+ // Otherwise it will always just be black to white.
49
+ let min = state.getThumbMinValue(0);
50
+ let max = state.getThumbMaxValue(0);
51
+ let start = value.withChannelValue(channel, min).toString("css");
52
+ let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
53
+ let end = value.withChannelValue(channel, max).toString("css");
54
+ return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
55
+ }
56
+ case "saturation":
57
+ case "brightness":
58
+ case "red":
59
+ case "green":
60
+ case "blue":
61
+ case "alpha":
62
+ {
63
+ let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
64
+ let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
65
+ return `linear-gradient(to ${to}, ${start}, ${end})`;
66
+ }
67
+ default:
68
+ throw new Error("Unknown color channel: " + channel);
69
+ }
70
+ };
71
+ let forcedColorAdjustNoneStyle = {
72
+ forcedColorAdjust: "none"
73
+ };
74
+ if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
75
+ else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
76
+ return {
77
+ trackProps: {
78
+ ...(0, $6WsjB$mergeProps)(groupProps, trackProps),
79
+ style: {
80
+ ...trackProps.style,
81
+ ...forcedColorAdjustNoneStyle,
82
+ background: generateBackground()
83
+ }
84
+ },
85
+ inputProps: inputProps,
86
+ thumbProps: {
87
+ ...thumbProps,
88
+ style: {
89
+ ...thumbProps.style,
90
+ ...forcedColorAdjustNoneStyle
91
+ }
92
+ },
93
+ labelProps: labelProps,
94
+ outputProps: outputProps
95
+ };
96
+ }
97
+
98
+
99
+ export {$40af666d6c251e36$export$106b7a4e66508f66 as useColorSlider};
100
+ //# sourceMappingURL=useColorSlider.mjs.map
@@ -0,0 +1,100 @@
1
+ import {mergeProps as $6WsjB$mergeProps} from "@react-aria/utils";
2
+ import {useLocale as $6WsjB$useLocale} from "@react-aria/i18n";
3
+ import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb} from "@react-aria/slider";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
19
+ let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
20
+ let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
21
+ // Provide a default aria-label if there is no other label provided.
22
+ if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
23
+ // @ts-ignore - ignore unused incompatible props
24
+ let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $6WsjB$useSlider)({
25
+ ...props,
26
+ "aria-label": ariaLabel
27
+ }, state, trackRef);
28
+ let { inputProps: inputProps, thumbProps: thumbProps } = (0, $6WsjB$useSliderThumb)({
29
+ index: 0,
30
+ orientation: orientation,
31
+ isDisabled: props.isDisabled,
32
+ name: name,
33
+ trackRef: trackRef,
34
+ inputRef: inputRef
35
+ }, state);
36
+ let value = state.getDisplayColor();
37
+ let generateBackground = ()=>{
38
+ let to;
39
+ if (orientation === "vertical") to = "top";
40
+ else if (direction === "ltr") to = "right";
41
+ else to = "left";
42
+ switch(channel){
43
+ case "hue":
44
+ return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
45
+ case "lightness":
46
+ {
47
+ // We have to add an extra color stop in the middle so that the hue shows up at all.
48
+ // Otherwise it will always just be black to white.
49
+ let min = state.getThumbMinValue(0);
50
+ let max = state.getThumbMaxValue(0);
51
+ let start = value.withChannelValue(channel, min).toString("css");
52
+ let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
53
+ let end = value.withChannelValue(channel, max).toString("css");
54
+ return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
55
+ }
56
+ case "saturation":
57
+ case "brightness":
58
+ case "red":
59
+ case "green":
60
+ case "blue":
61
+ case "alpha":
62
+ {
63
+ let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
64
+ let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
65
+ return `linear-gradient(to ${to}, ${start}, ${end})`;
66
+ }
67
+ default:
68
+ throw new Error("Unknown color channel: " + channel);
69
+ }
70
+ };
71
+ let forcedColorAdjustNoneStyle = {
72
+ forcedColorAdjust: "none"
73
+ };
74
+ if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
75
+ else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
76
+ return {
77
+ trackProps: {
78
+ ...(0, $6WsjB$mergeProps)(groupProps, trackProps),
79
+ style: {
80
+ ...trackProps.style,
81
+ ...forcedColorAdjustNoneStyle,
82
+ background: generateBackground()
83
+ }
84
+ },
85
+ inputProps: inputProps,
86
+ thumbProps: {
87
+ ...thumbProps,
88
+ style: {
89
+ ...thumbProps.style,
90
+ ...forcedColorAdjustNoneStyle
91
+ }
92
+ },
93
+ labelProps: labelProps,
94
+ outputProps: outputProps
95
+ };
96
+ }
97
+
98
+
99
+ export {$40af666d6c251e36$export$106b7a4e66508f66 as useColorSlider};
100
+ //# sourceMappingURL=useColorSlider.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAe,KAA6B,EAAE,KAAuB;IACnF,IAAI,YAAC,QAAQ,YAAE,QAAQ,eAAE,WAAW,WAAE,OAAO,EAAE,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BACjE;YACA,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;gBAAS;oBACZ,IAAI,QAAQ,MAAM,gBAAgB,CAAC,SAAS,MAAM,gBAAgB,CAAC,IAAI,QAAQ,CAAC;oBAChF,IAAI,MAAM,MAAM,gBAAgB,CAAC,SAAS,MAAM,gBAAgB,CAAC,IAAI,QAAQ,CAAC;oBAC9E,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;gBACtD;YACA;gBACE,MAAM,IAAI,MAAM,4BAA4B;QAChD;IACF;IAEA,IAAI,6BAA6B;QAAC,mBAAmB;IAAM;IAE3D,IAAI,YAAY,OACd,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,UAAU,CAAC,QAAQ,CAAC;SAC1D,IAAI,YAAY,SACrB,UAAU,CAAC,iBAAiB,IAAI,CAAC,EAAE,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC;IAGnE,OAAO;QACL,YAAY;YACV,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;YACrC,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;gBAC7B,YAAY;YACd;QACF;oBACA;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;YAC/B;QACF;oBACA;qBACA;IACF;AACF","sources":["packages/@react-aria/color/src/useColorSlider.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 {AriaColorSliderProps} from '@react-types/color';\nimport {ColorSliderState} from '@react-stately/color';\nimport {DOMAttributes} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useSlider, useSliderThumb} from '@react-aria/slider';\n\nexport interface AriaColorSliderOptions extends AriaColorSliderProps {\n /** A ref for the track element. */\n trackRef: RefObject<Element>,\n /** A ref for the input element. */\n inputRef: RefObject<HTMLInputElement>\n}\n\nexport interface ColorSliderAria {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the output element, displaying the value of the color slider. */\n outputProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\nexport function useColorSlider(props: AriaColorSliderOptions, state: ColorSliderState): ColorSliderAria {\n let {trackRef, inputRef, orientation, channel, 'aria-label': ariaLabel, name} = props;\n\n let {locale, direction} = useLocale();\n\n // Provide a default aria-label if there is no other label provided.\n if (!props.label && !ariaLabel && !props['aria-labelledby']) {\n ariaLabel = state.value.getChannelName(channel, locale);\n }\n\n // @ts-ignore - ignore unused incompatible props\n let {groupProps, trackProps, labelProps, outputProps} = useSlider({...props, 'aria-label': ariaLabel}, state, trackRef);\n let {inputProps, thumbProps} = useSliderThumb({\n index: 0,\n orientation,\n isDisabled: props.isDisabled,\n name,\n trackRef,\n inputRef\n }, state);\n\n let value = state.getDisplayColor();\n let generateBackground = () => {\n let to: string;\n if (orientation === 'vertical') {\n to = 'top';\n } else if (direction === 'ltr') {\n to = 'right';\n } else {\n to = 'left';\n }\n switch (channel) {\n case 'hue':\n return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;\n case 'lightness': {\n // We have to add an extra color stop in the middle so that the hue shows up at all.\n // Otherwise it will always just be black to white.\n let min = state.getThumbMinValue(0);\n let max = state.getThumbMaxValue(0);\n let start = value.withChannelValue(channel, min).toString('css');\n let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');\n let end = value.withChannelValue(channel, max).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;\n }\n case 'saturation':\n case 'brightness':\n case 'red':\n case 'green':\n case 'blue':\n case 'alpha': {\n let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');\n let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');\n return `linear-gradient(to ${to}, ${start}, ${end})`;\n }\n default:\n throw new Error('Unknown color channel: ' + channel);\n }\n };\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n if (channel === 'hue') {\n inputProps['aria-valuetext'] += `, ${value.getHueName(locale)}`;\n } else if (channel !== 'alpha') {\n inputProps['aria-valuetext'] += `, ${value.getColorName(locale)}`;\n }\n\n return {\n trackProps: {\n ...mergeProps(groupProps, trackProps),\n style: {\n ...trackProps.style,\n ...forcedColorAdjustNoneStyle,\n background: generateBackground()\n }\n },\n inputProps,\n thumbProps: {\n ...thumbProps,\n style: {\n ...thumbProps.style,\n ...forcedColorAdjustNoneStyle\n }\n },\n labelProps,\n outputProps\n };\n}\n"],"names":[],"version":3,"file":"useColorSlider.module.js.map"}
@@ -0,0 +1,260 @@
1
+ var $iWAp3$reactariautils = require("@react-aria/utils");
2
+ var $iWAp3$react = require("react");
3
+ var $iWAp3$reactariainteractions = require("@react-aria/interactions");
4
+ var $iWAp3$reactariai18n = require("@react-aria/i18n");
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, "useColorWheel", () => $1d29bf243d4a9a53$export$9064ff4e44b3729a);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
27
+ let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
28
+ let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $iWAp3$reactariautils.useGlobalListeners)();
29
+ let thumbRadius = (innerRadius + outerRadius) / 2;
30
+ let focusInput = (0, $iWAp3$react.useCallback)(()=>{
31
+ if (inputRef.current) (0, $iWAp3$reactariautils.focusWithoutScrolling)(inputRef.current);
32
+ }, [
33
+ inputRef
34
+ ]);
35
+ (0, $iWAp3$reactariautils.useFormReset)(inputRef, state.hue, state.setHue);
36
+ let currentPosition = (0, $iWAp3$react.useRef)(null);
37
+ let { keyboardProps: keyboardProps } = (0, $iWAp3$reactariainteractions.useKeyboard)({
38
+ onKeyDown (e) {
39
+ // these are the cases that useMove doesn't handle
40
+ if (!/^(PageUp|PageDown)$/.test(e.key)) {
41
+ e.continuePropagation();
42
+ return;
43
+ }
44
+ // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
45
+ e.preventDefault();
46
+ // remember to set this and unset it so that onChangeEnd is fired
47
+ state.setDragging(true);
48
+ switch(e.key){
49
+ case "PageUp":
50
+ e.preventDefault();
51
+ state.increment(state.pageStep);
52
+ break;
53
+ case "PageDown":
54
+ e.preventDefault();
55
+ state.decrement(state.pageStep);
56
+ break;
57
+ }
58
+ state.setDragging(false);
59
+ }
60
+ });
61
+ let moveHandler = {
62
+ onMoveStart () {
63
+ currentPosition.current = null;
64
+ state.setDragging(true);
65
+ },
66
+ onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
67
+ if (currentPosition.current == null) currentPosition.current = state.getThumbPosition(thumbRadius);
68
+ currentPosition.current.x += deltaX;
69
+ currentPosition.current.y += deltaY;
70
+ if (pointerType === "keyboard") {
71
+ if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? state.pageStep : state.step);
72
+ else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? state.pageStep : state.step);
73
+ } else state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
74
+ },
75
+ onMoveEnd () {
76
+ isOnTrack.current = false;
77
+ state.setDragging(false);
78
+ focusInput();
79
+ }
80
+ };
81
+ let { moveProps: movePropsThumb } = (0, $iWAp3$reactariainteractions.useMove)(moveHandler);
82
+ let currentPointer = (0, $iWAp3$react.useRef)(undefined);
83
+ let isOnTrack = (0, $iWAp3$react.useRef)(false);
84
+ let { moveProps: movePropsContainer } = (0, $iWAp3$reactariainteractions.useMove)({
85
+ onMoveStart () {
86
+ if (isOnTrack.current) moveHandler.onMoveStart();
87
+ },
88
+ onMove (e) {
89
+ if (isOnTrack.current) moveHandler.onMove(e);
90
+ },
91
+ onMoveEnd () {
92
+ if (isOnTrack.current) moveHandler.onMoveEnd();
93
+ }
94
+ });
95
+ let onThumbDown = (id)=>{
96
+ if (!state.isDragging) {
97
+ currentPointer.current = id;
98
+ focusInput();
99
+ state.setDragging(true);
100
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
101
+ else {
102
+ addGlobalListener(window, "mouseup", onThumbUp, false);
103
+ addGlobalListener(window, "touchend", onThumbUp, false);
104
+ }
105
+ }
106
+ };
107
+ let onThumbUp = (e)=>{
108
+ var _e_changedTouches;
109
+ var _e_pointerId;
110
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
111
+ if (id === currentPointer.current) {
112
+ focusInput();
113
+ state.setDragging(false);
114
+ currentPointer.current = undefined;
115
+ isOnTrack.current = false;
116
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
117
+ else {
118
+ removeGlobalListener(window, "mouseup", onThumbUp, false);
119
+ removeGlobalListener(window, "touchend", onThumbUp, false);
120
+ }
121
+ }
122
+ };
123
+ let onTrackDown = (track, id, pageX, pageY)=>{
124
+ let rect = track.getBoundingClientRect();
125
+ let x = pageX - rect.x - rect.width / 2;
126
+ let y = pageY - rect.y - rect.height / 2;
127
+ let radius = Math.sqrt(x * x + y * y);
128
+ if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
129
+ isOnTrack.current = true;
130
+ currentPointer.current = id;
131
+ state.setHueFromPoint(x, y, radius);
132
+ focusInput();
133
+ state.setDragging(true);
134
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onTrackUp, false);
135
+ else {
136
+ addGlobalListener(window, "mouseup", onTrackUp, false);
137
+ addGlobalListener(window, "touchend", onTrackUp, false);
138
+ }
139
+ }
140
+ };
141
+ let onTrackUp = (e)=>{
142
+ var _e_changedTouches;
143
+ var _e_pointerId;
144
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
145
+ if (isOnTrack.current && id === currentPointer.current) {
146
+ isOnTrack.current = false;
147
+ currentPointer.current = undefined;
148
+ state.setDragging(false);
149
+ focusInput();
150
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onTrackUp, false);
151
+ else {
152
+ removeGlobalListener(window, "mouseup", onTrackUp, false);
153
+ removeGlobalListener(window, "touchend", onTrackUp, false);
154
+ }
155
+ }
156
+ };
157
+ let trackInteractions = isDisabled ? {} : (0, $iWAp3$reactariautils.mergeProps)({
158
+ ...typeof PointerEvent !== "undefined" ? {
159
+ onPointerDown: (e)=>{
160
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
161
+ onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
162
+ }
163
+ } : {
164
+ onMouseDown: (e)=>{
165
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
166
+ onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
167
+ },
168
+ onTouchStart: (e)=>{
169
+ onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
170
+ }
171
+ }
172
+ }, movePropsContainer);
173
+ let thumbInteractions = isDisabled ? {} : (0, $iWAp3$reactariautils.mergeProps)({
174
+ onMouseDown: (e)=>{
175
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
176
+ onThumbDown(undefined);
177
+ },
178
+ onPointerDown: (e)=>{
179
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
180
+ onThumbDown(e.pointerId);
181
+ },
182
+ onTouchStart: (e)=>{
183
+ onThumbDown(e.changedTouches[0].identifier);
184
+ }
185
+ }, keyboardProps, movePropsThumb);
186
+ let { x: x, y: y } = state.getThumbPosition(thumbRadius);
187
+ // Provide a default aria-label if none is given
188
+ let { locale: locale } = (0, $iWAp3$reactariai18n.useLocale)();
189
+ if (ariaLabel == null && props["aria-labelledby"] == null) ariaLabel = state.value.getChannelName("hue", locale);
190
+ let inputLabellingProps = (0, $iWAp3$reactariautils.useLabels)({
191
+ ...props,
192
+ "aria-label": ariaLabel
193
+ });
194
+ let { minValue: minValue, maxValue: maxValue, step: step } = state.value.getChannelRange("hue");
195
+ let forcedColorAdjustNoneStyle = {
196
+ forcedColorAdjust: "none"
197
+ };
198
+ return {
199
+ trackProps: {
200
+ ...trackInteractions,
201
+ style: {
202
+ position: "relative",
203
+ touchAction: "none",
204
+ width: outerRadius * 2,
205
+ height: outerRadius * 2,
206
+ background: `
207
+ conic-gradient(
208
+ from 90deg,
209
+ hsl(0, 100%, 50%),
210
+ hsl(30, 100%, 50%),
211
+ hsl(60, 100%, 50%),
212
+ hsl(90, 100%, 50%),
213
+ hsl(120, 100%, 50%),
214
+ hsl(150, 100%, 50%),
215
+ hsl(180, 100%, 50%),
216
+ hsl(210, 100%, 50%),
217
+ hsl(240, 100%, 50%),
218
+ hsl(270, 100%, 50%),
219
+ hsl(300, 100%, 50%),
220
+ hsl(330, 100%, 50%),
221
+ hsl(360, 100%, 50%)
222
+ )
223
+ `,
224
+ clipPath: `path(evenodd, "${$1d29bf243d4a9a53$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$1d29bf243d4a9a53$var$circlePath(outerRadius, outerRadius, innerRadius)}")`,
225
+ ...forcedColorAdjustNoneStyle
226
+ }
227
+ },
228
+ thumbProps: {
229
+ ...thumbInteractions,
230
+ style: {
231
+ position: "absolute",
232
+ left: "50%",
233
+ top: "50%",
234
+ transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
235
+ touchAction: "none",
236
+ ...forcedColorAdjustNoneStyle
237
+ }
238
+ },
239
+ inputProps: (0, $iWAp3$reactariautils.mergeProps)(inputLabellingProps, {
240
+ type: "range",
241
+ min: String(minValue),
242
+ max: String(maxValue),
243
+ step: String(step),
244
+ "aria-valuetext": `${state.value.formatChannelValue("hue", locale)}, ${state.value.getHueName(locale)}`,
245
+ disabled: isDisabled,
246
+ value: `${state.value.getChannelValue("hue")}`,
247
+ name: name,
248
+ onChange: (e)=>{
249
+ state.setHue(parseFloat(e.target.value));
250
+ }
251
+ })
252
+ };
253
+ }
254
+ // Creates an SVG path string for a circle.
255
+ function $1d29bf243d4a9a53$var$circlePath(cx, cy, r) {
256
+ return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;
257
+ }
258
+
259
+
260
+ //# sourceMappingURL=useColorWheel.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA8BM,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,QAAqC;IACvH,IAAI,cACF,UAAU,eACV,WAAW,eACX,WAAW,EACX,cAAc,SAAS,QACvB,IAAI,EACL,GAAG;IAEJ,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,cAAc,AAAC,CAAA,cAAc,WAAU,IAAK;IAEhD,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,2CAAoB,EAAE,SAAS,OAAO;IAE1C,GAAG;QAAC;KAAS;IAEb,CAAA,GAAA,kCAAW,EAAE,UAAU,MAAM,GAAG,EAAE,MAAM,MAAM;IAE9C,IAAI,kBAAkB,CAAA,GAAA,mBAAK,EAAiC;IAE5D,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,wCAAU,EAAE;QAChC,WAAU,CAAC;YACT,kDAAkD;YAClD,IAAI,CAAC,sBAAsB,IAAI,CAAC,EAAE,GAAG,GAAG;gBACtC,EAAE,mBAAmB;gBACrB;YACF;YACA,4FAA4F;YAC5F,EAAE,cAAc;YAChB,iEAAiE;YACjE,MAAM,WAAW,CAAC;YAClB,OAAQ,EAAE,GAAG;gBACX,KAAK;oBACH,EAAE,cAAc;oBAChB,MAAM,SAAS,CAAC,MAAM,QAAQ;oBAC9B;gBACF,KAAK;oBACH,EAAE,cAAc;oBAChB,MAAM,SAAS,CAAC,MAAM,QAA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AW,CAAC,eAAe,EAAE,EAAE,gBAAgB,EAAE,EAAE,UAAU,CAAC;gBAC9D,aAAa;gBACb,GAAG,0BAA0B;YAC/B;QACF;QACA,YAAY,CAAA,GAAA,gCAAS,EACnB,qBACA;YACE,MAAM;YACN,KAAK,OAAO;YACZ,KAAK,OAAO;YACZ,MAAM,OAAO;YACb,kBAAkB,CAAC,EAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,QAAQ,EAAE,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;YACvG,UAAU;YACV,OAAO,CAAC,EAAE,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC;kBAC9C;YACA,UAAU,CAAC;gBACT,MAAM,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK;YACxC;QACF;IAEJ;AACF;AAEA,2CAA2C;AAC3C,SAAS,iCAAW,EAAU,EAAE,EAAU,EAAE,CAAS;IACnD,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;AAC1G","sources":["packages/@react-aria/color/src/useColorWheel.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 {AriaColorWheelProps} from '@react-types/color';\nimport {ColorWheelState} from '@react-stately/color';\nimport {DOMAttributes} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\nimport React, {ChangeEvent, InputHTMLAttributes, RefObject, useCallback, useRef} from 'react';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaColorWheelOptions extends AriaColorWheelProps {\n /** The outer radius of the color wheel. */\n outerRadius: number,\n /** The inner radius of the color wheel. */\n innerRadius: number\n}\n\nexport interface ColorWheelAria {\n /** Props for the track element. */\n trackProps: DOMAttributes,\n /** Props for the thumb element. */\n thumbProps: DOMAttributes,\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color wheel component.\n * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.\n */\nexport function useColorWheel(props: AriaColorWheelOptions, state: ColorWheelState, inputRef: RefObject<HTMLInputElement>): ColorWheelAria {\n let {\n isDisabled,\n innerRadius,\n outerRadius,\n 'aria-label': ariaLabel,\n name\n } = props;\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let thumbRadius = (innerRadius + outerRadius) / 2;\n\n let focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n useFormReset(inputRef, state.hue, state.setHue);\n\n let currentPosition = useRef<{x: number, y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n switch (e.key) {\n case 'PageUp':\n e.preventDefault();\n state.increment(state.pageStep);\n break;\n case 'PageDown':\n e.preventDefault();\n state.decrement(state.pageStep);\n break;\n }\n state.setDragging(false);\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n if (currentPosition.current == null) {\n currentPosition.current = state.getThumbPosition(thumbRadius);\n }\n currentPosition.current.x += deltaX;\n currentPosition.current.y += deltaY;\n if (pointerType === 'keyboard') {\n if (deltaX > 0 || deltaY < 0) {\n state.increment(shiftKey ? state.pageStep : state.step);\n } else if (deltaX < 0 || deltaY > 0) {\n state.decrement(shiftKey ? state.pageStep : state.step);\n }\n } else {\n state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);\n }\n },\n onMoveEnd() {\n isOnTrack.current = false;\n state.setDragging(false);\n focusInput();\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnTrack = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnTrack.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnTrack.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnTrack.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnTrack.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onTrackDown = (track: Element, id: number | null | undefined, pageX: number, pageY: number) => {\n let rect = track.getBoundingClientRect();\n let x = pageX - rect.x - rect.width / 2;\n let y = pageY - rect.y - rect.height / 2;\n let radius = Math.sqrt(x * x + y * y);\n if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {\n isOnTrack.current = true;\n currentPointer.current = id;\n state.setHueFromPoint(x, y, radius);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onTrackUp, false);\n addGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let onTrackUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnTrack.current && id === currentPointer.current) {\n isOnTrack.current = false;\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onTrackUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onTrackUp, false);\n removeGlobalListener(window, 'touchend', onTrackUp, false);\n }\n }\n };\n\n let trackInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }} : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n }, keyboardProps, movePropsThumb);\n let {x, y} = state.getThumbPosition(thumbRadius);\n\n // Provide a default aria-label if none is given\n let {locale} = useLocale();\n if (ariaLabel == null && props['aria-labelledby'] == null) {\n ariaLabel = state.value.getChannelName('hue', locale);\n }\n\n let inputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n });\n\n let {minValue, maxValue, step} = state.value.getChannelRange('hue');\n\n let forcedColorAdjustNoneStyle = {\n forcedColorAdjust: 'none'\n };\n\n return {\n trackProps: {\n ...trackInteractions,\n style: {\n position: 'relative',\n touchAction: 'none',\n width: outerRadius * 2,\n height: outerRadius * 2,\n background: `\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n `,\n clipPath: `path(evenodd, \"${circlePath(outerRadius, outerRadius, outerRadius)} ${circlePath(outerRadius, outerRadius, innerRadius)}\")`,\n ...forcedColorAdjustNoneStyle\n }\n },\n thumbProps: {\n ...thumbInteractions,\n style: {\n position: 'absolute',\n left: '50%',\n top: '50%',\n transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n },\n inputProps: mergeProps(\n inputLabellingProps,\n {\n type: 'range',\n min: String(minValue),\n max: String(maxValue),\n step: String(step),\n 'aria-valuetext': `${state.value.formatChannelValue('hue', locale)}, ${state.value.getHueName(locale)}`,\n disabled: isDisabled,\n value: `${state.value.getChannelValue('hue')}`,\n name,\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setHue(parseFloat(e.target.value));\n }\n }\n )\n };\n}\n\n// Creates an SVG path string for a circle.\nfunction circlePath(cx: number, cy: number, r: number) {\n return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;\n}\n"],"names":[],"version":3,"file":"useColorWheel.main.js.map"}