@react-aria/color 3.0.0-nightly.4567 → 3.0.0-nightly.4578

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 (221) hide show
  1. package/dist/ar-AE.main.js +3 -1
  2. package/dist/ar-AE.main.js.map +1 -1
  3. package/dist/ar-AE.mjs +3 -1
  4. package/dist/ar-AE.module.js +3 -1
  5. package/dist/ar-AE.module.js.map +1 -1
  6. package/dist/bg-BG.main.js +3 -1
  7. package/dist/bg-BG.main.js.map +1 -1
  8. package/dist/bg-BG.mjs +3 -1
  9. package/dist/bg-BG.module.js +3 -1
  10. package/dist/bg-BG.module.js.map +1 -1
  11. package/dist/cs-CZ.main.js +3 -1
  12. package/dist/cs-CZ.main.js.map +1 -1
  13. package/dist/cs-CZ.mjs +3 -1
  14. package/dist/cs-CZ.module.js +3 -1
  15. package/dist/cs-CZ.module.js.map +1 -1
  16. package/dist/da-DK.main.js +3 -1
  17. package/dist/da-DK.main.js.map +1 -1
  18. package/dist/da-DK.mjs +3 -1
  19. package/dist/da-DK.module.js +3 -1
  20. package/dist/da-DK.module.js.map +1 -1
  21. package/dist/de-DE.main.js +3 -1
  22. package/dist/de-DE.main.js.map +1 -1
  23. package/dist/de-DE.mjs +3 -1
  24. package/dist/de-DE.module.js +3 -1
  25. package/dist/de-DE.module.js.map +1 -1
  26. package/dist/el-GR.main.js +3 -1
  27. package/dist/el-GR.main.js.map +1 -1
  28. package/dist/el-GR.mjs +3 -1
  29. package/dist/el-GR.module.js +3 -1
  30. package/dist/el-GR.module.js.map +1 -1
  31. package/dist/en-US.main.js +3 -1
  32. package/dist/en-US.main.js.map +1 -1
  33. package/dist/en-US.mjs +3 -1
  34. package/dist/en-US.module.js +3 -1
  35. package/dist/en-US.module.js.map +1 -1
  36. package/dist/es-ES.main.js +3 -1
  37. package/dist/es-ES.main.js.map +1 -1
  38. package/dist/es-ES.mjs +3 -1
  39. package/dist/es-ES.module.js +3 -1
  40. package/dist/es-ES.module.js.map +1 -1
  41. package/dist/et-EE.main.js +3 -1
  42. package/dist/et-EE.main.js.map +1 -1
  43. package/dist/et-EE.mjs +3 -1
  44. package/dist/et-EE.module.js +3 -1
  45. package/dist/et-EE.module.js.map +1 -1
  46. package/dist/fi-FI.main.js +3 -1
  47. package/dist/fi-FI.main.js.map +1 -1
  48. package/dist/fi-FI.mjs +3 -1
  49. package/dist/fi-FI.module.js +3 -1
  50. package/dist/fi-FI.module.js.map +1 -1
  51. package/dist/fr-FR.main.js +3 -1
  52. package/dist/fr-FR.main.js.map +1 -1
  53. package/dist/fr-FR.mjs +3 -1
  54. package/dist/fr-FR.module.js +3 -1
  55. package/dist/fr-FR.module.js.map +1 -1
  56. package/dist/he-IL.main.js +3 -1
  57. package/dist/he-IL.main.js.map +1 -1
  58. package/dist/he-IL.mjs +3 -1
  59. package/dist/he-IL.module.js +3 -1
  60. package/dist/he-IL.module.js.map +1 -1
  61. package/dist/hr-HR.main.js +3 -1
  62. package/dist/hr-HR.main.js.map +1 -1
  63. package/dist/hr-HR.mjs +3 -1
  64. package/dist/hr-HR.module.js +3 -1
  65. package/dist/hr-HR.module.js.map +1 -1
  66. package/dist/hu-HU.main.js +3 -1
  67. package/dist/hu-HU.main.js.map +1 -1
  68. package/dist/hu-HU.mjs +3 -1
  69. package/dist/hu-HU.module.js +3 -1
  70. package/dist/hu-HU.module.js.map +1 -1
  71. package/dist/import.mjs +5 -1
  72. package/dist/it-IT.main.js +3 -1
  73. package/dist/it-IT.main.js.map +1 -1
  74. package/dist/it-IT.mjs +3 -1
  75. package/dist/it-IT.module.js +3 -1
  76. package/dist/it-IT.module.js.map +1 -1
  77. package/dist/ja-JP.main.js +3 -1
  78. package/dist/ja-JP.main.js.map +1 -1
  79. package/dist/ja-JP.mjs +3 -1
  80. package/dist/ja-JP.module.js +3 -1
  81. package/dist/ja-JP.module.js.map +1 -1
  82. package/dist/ko-KR.main.js +3 -1
  83. package/dist/ko-KR.main.js.map +1 -1
  84. package/dist/ko-KR.mjs +3 -1
  85. package/dist/ko-KR.module.js +3 -1
  86. package/dist/ko-KR.module.js.map +1 -1
  87. package/dist/lt-LT.main.js +3 -1
  88. package/dist/lt-LT.main.js.map +1 -1
  89. package/dist/lt-LT.mjs +3 -1
  90. package/dist/lt-LT.module.js +3 -1
  91. package/dist/lt-LT.module.js.map +1 -1
  92. package/dist/lv-LV.main.js +3 -1
  93. package/dist/lv-LV.main.js.map +1 -1
  94. package/dist/lv-LV.mjs +3 -1
  95. package/dist/lv-LV.module.js +3 -1
  96. package/dist/lv-LV.module.js.map +1 -1
  97. package/dist/main.js +6 -0
  98. package/dist/main.js.map +1 -1
  99. package/dist/module.js +5 -1
  100. package/dist/module.js.map +1 -1
  101. package/dist/nb-NO.main.js +3 -1
  102. package/dist/nb-NO.main.js.map +1 -1
  103. package/dist/nb-NO.mjs +3 -1
  104. package/dist/nb-NO.module.js +3 -1
  105. package/dist/nb-NO.module.js.map +1 -1
  106. package/dist/nl-NL.main.js +3 -1
  107. package/dist/nl-NL.main.js.map +1 -1
  108. package/dist/nl-NL.mjs +3 -1
  109. package/dist/nl-NL.module.js +3 -1
  110. package/dist/nl-NL.module.js.map +1 -1
  111. package/dist/pl-PL.main.js +3 -1
  112. package/dist/pl-PL.main.js.map +1 -1
  113. package/dist/pl-PL.mjs +3 -1
  114. package/dist/pl-PL.module.js +3 -1
  115. package/dist/pl-PL.module.js.map +1 -1
  116. package/dist/pt-BR.main.js +3 -1
  117. package/dist/pt-BR.main.js.map +1 -1
  118. package/dist/pt-BR.mjs +3 -1
  119. package/dist/pt-BR.module.js +3 -1
  120. package/dist/pt-BR.module.js.map +1 -1
  121. package/dist/pt-PT.main.js +3 -1
  122. package/dist/pt-PT.main.js.map +1 -1
  123. package/dist/pt-PT.mjs +3 -1
  124. package/dist/pt-PT.module.js +3 -1
  125. package/dist/pt-PT.module.js.map +1 -1
  126. package/dist/ro-RO.main.js +3 -1
  127. package/dist/ro-RO.main.js.map +1 -1
  128. package/dist/ro-RO.mjs +3 -1
  129. package/dist/ro-RO.module.js +3 -1
  130. package/dist/ro-RO.module.js.map +1 -1
  131. package/dist/ru-RU.main.js +3 -1
  132. package/dist/ru-RU.main.js.map +1 -1
  133. package/dist/ru-RU.mjs +3 -1
  134. package/dist/ru-RU.module.js +3 -1
  135. package/dist/ru-RU.module.js.map +1 -1
  136. package/dist/sk-SK.main.js +3 -1
  137. package/dist/sk-SK.main.js.map +1 -1
  138. package/dist/sk-SK.mjs +3 -1
  139. package/dist/sk-SK.module.js +3 -1
  140. package/dist/sk-SK.module.js.map +1 -1
  141. package/dist/sl-SI.main.js +3 -1
  142. package/dist/sl-SI.main.js.map +1 -1
  143. package/dist/sl-SI.mjs +3 -1
  144. package/dist/sl-SI.module.js +3 -1
  145. package/dist/sl-SI.module.js.map +1 -1
  146. package/dist/sr-SP.main.js +3 -1
  147. package/dist/sr-SP.main.js.map +1 -1
  148. package/dist/sr-SP.mjs +3 -1
  149. package/dist/sr-SP.module.js +3 -1
  150. package/dist/sr-SP.module.js.map +1 -1
  151. package/dist/sv-SE.main.js +3 -1
  152. package/dist/sv-SE.main.js.map +1 -1
  153. package/dist/sv-SE.mjs +3 -1
  154. package/dist/sv-SE.module.js +3 -1
  155. package/dist/sv-SE.module.js.map +1 -1
  156. package/dist/tr-TR.main.js +3 -1
  157. package/dist/tr-TR.main.js.map +1 -1
  158. package/dist/tr-TR.mjs +3 -1
  159. package/dist/tr-TR.module.js +3 -1
  160. package/dist/tr-TR.module.js.map +1 -1
  161. package/dist/types.d.ts +41 -7
  162. package/dist/types.d.ts.map +1 -1
  163. package/dist/uk-UA.main.js +3 -1
  164. package/dist/uk-UA.main.js.map +1 -1
  165. package/dist/uk-UA.mjs +3 -1
  166. package/dist/uk-UA.module.js +3 -1
  167. package/dist/uk-UA.module.js.map +1 -1
  168. package/dist/useColorArea.main.js +7 -7
  169. package/dist/useColorArea.main.js.map +1 -1
  170. package/dist/useColorArea.mjs +7 -7
  171. package/dist/useColorArea.module.js +7 -7
  172. package/dist/useColorArea.module.js.map +1 -1
  173. package/dist/useColorAreaGradient.main.js +65 -171
  174. package/dist/useColorAreaGradient.main.js.map +1 -1
  175. package/dist/useColorAreaGradient.mjs +65 -171
  176. package/dist/useColorAreaGradient.module.js +65 -171
  177. package/dist/useColorAreaGradient.module.js.map +1 -1
  178. package/dist/useColorChannelField.main.js +36 -0
  179. package/dist/useColorChannelField.main.js.map +1 -0
  180. package/dist/useColorChannelField.mjs +31 -0
  181. package/dist/useColorChannelField.module.js +31 -0
  182. package/dist/useColorChannelField.module.js.map +1 -0
  183. package/dist/useColorField.main.js +3 -2
  184. package/dist/useColorField.main.js.map +1 -1
  185. package/dist/useColorField.mjs +3 -2
  186. package/dist/useColorField.module.js +3 -2
  187. package/dist/useColorField.module.js.map +1 -1
  188. package/dist/useColorSlider.main.js +29 -2
  189. package/dist/useColorSlider.main.js.map +1 -1
  190. package/dist/useColorSlider.mjs +29 -2
  191. package/dist/useColorSlider.module.js +29 -2
  192. package/dist/useColorSlider.module.js.map +1 -1
  193. package/dist/useColorSwatch.main.js +67 -0
  194. package/dist/useColorSwatch.main.js.map +1 -0
  195. package/dist/useColorSwatch.mjs +62 -0
  196. package/dist/useColorSwatch.module.js +62 -0
  197. package/dist/useColorSwatch.module.js.map +1 -0
  198. package/dist/useColorWheel.main.js +18 -4
  199. package/dist/useColorWheel.main.js.map +1 -1
  200. package/dist/useColorWheel.mjs +18 -4
  201. package/dist/useColorWheel.module.js +18 -4
  202. package/dist/useColorWheel.module.js.map +1 -1
  203. package/dist/zh-CN.main.js +3 -1
  204. package/dist/zh-CN.main.js.map +1 -1
  205. package/dist/zh-CN.mjs +3 -1
  206. package/dist/zh-CN.module.js +3 -1
  207. package/dist/zh-CN.module.js.map +1 -1
  208. package/dist/zh-TW.main.js +3 -1
  209. package/dist/zh-TW.main.js.map +1 -1
  210. package/dist/zh-TW.mjs +3 -1
  211. package/dist/zh-TW.module.js +3 -1
  212. package/dist/zh-TW.module.js.map +1 -1
  213. package/package.json +14 -13
  214. package/src/index.ts +4 -0
  215. package/src/useColorArea.ts +6 -9
  216. package/src/useColorAreaGradient.ts +66 -189
  217. package/src/useColorChannelField.ts +37 -0
  218. package/src/useColorField.ts +18 -14
  219. package/src/useColorSlider.ts +21 -3
  220. package/src/useColorSwatch.ts +74 -0
  221. package/src/useColorWheel.ts +18 -4
@@ -1 +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,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAElC,oEAAoE;IACpE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,EACzD,YAAY,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS;IAGlD,gDAAgD;IAChD,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,gCAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,cAAc;IAAS,GAAG,OAAO;IAC9G,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAa,EAAE;QAC5C,OAAO;qBACP;QACA,YAAY,MAAM,UAAU;cAC5B;kBACA;kBACA;IACF,GAAG;IAEH,IAAI,QAAQ,MAAM,eAAe;IACjC,IAAI,qBAAqB;QACvB,IAAI;QACJ,IAAI,gBAAgB,YAClB,KAAK;aACA,IAAI,cAAc,OACvB,KAAK;aAEL,KAAK;QAEP,OAAQ;YACN,KAAK;gBACH,OAAO,CAAC,mBAAmB,EAAE,GAAG,mJAAmJ,CAAC;YACtL,KAAK;gBAAa;oBAChB,oFAAoF;oBACpF,mDAAmD;o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AAU;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"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,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,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAElC,oEAAoE;IACpE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,EACzD,YAAY,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS;IAGlD,gDAAgD;IAChD,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,gCAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,cAAc;IAAS,GAAG,OAAO;IAC9G,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAa,EAAE;QAC5C,OAAO;qBACP;QACA,YAAY,MAAM,UAAU;cAC5B;kBACA;kBACA;IACF,GAAG;IAEH,IAAI,QAAQ,MAAM,eAAe;IACjC,IAAI,qBAAqB;QACvB,IAAI;QACJ,IAAI,gBAAgB,YAClB,KAAK;aACA,IAAI,cAAc,OACvB,KAAK;aAEL,KAAK;QAEP,OAAQ;YACN,KAAK;gBAAO;oBACV,IAAI,QAAQ;wBAAC;wBAAG;wBAAI;wBAAK;wBAAK;wBAAK;wBAAK;qBAAI,CAAC,GAAG,CAAC,CAAA,MAAO,MAAM,gBAAgB,CAAC,OAAO,KAAK,QAAQ,CAAC,QAAQ,IAAI,CAAC;oBAC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gB,EAAE;QAC5C,OAAO;YACL,SAAS;YACT,OAAO;YACP,QAAQ;YACR,eAAe;QACjB;IACF;IAEA,OAAO;QACL,YAAY;YACV,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,WAAW;YACrC,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;gBAC7B,YAAY;YACd;QACF;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,oBAAoB,KAAK;YAC9B;QACF;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';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\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 let stops = [0, 60, 120, 180, 240, 300, 360].map(hue => value.withChannelValue('hue', hue).toString('css')).join(', ');\n return `linear-gradient(to ${to}, ${stops})`;\n }\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 let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\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 ...inputProps,\n style: {\n ...inputProps.style,\n ...visuallyHiddenProps.style\n }\n },\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"}
@@ -1,6 +1,7 @@
1
1
  import {mergeProps as $6WsjB$mergeProps} from "@react-aria/utils";
2
2
  import {useLocale as $6WsjB$useLocale} from "@react-aria/i18n";
3
3
  import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb} from "@react-aria/slider";
4
+ import {useVisuallyHidden as $6WsjB$useVisuallyHidden} from "@react-aria/visually-hidden";
4
5
 
5
6
  /*
6
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,6 +16,7 @@ import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb}
15
16
  */
16
17
 
17
18
 
19
+
18
20
  function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
19
21
  let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
20
22
  let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
@@ -41,7 +43,18 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
41
43
  else to = "left";
42
44
  switch(channel){
43
45
  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%)`;
46
+ {
47
+ let stops = [
48
+ 0,
49
+ 60,
50
+ 120,
51
+ 180,
52
+ 240,
53
+ 300,
54
+ 360
55
+ ].map((hue)=>value.withChannelValue("hue", hue).toString("css")).join(", ");
56
+ return `linear-gradient(to ${to}, ${stops})`;
57
+ }
45
58
  case "lightness":
46
59
  {
47
60
  // We have to add an extra color stop in the middle so that the hue shows up at all.
@@ -73,6 +86,14 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
73
86
  };
74
87
  if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
75
88
  else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
89
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $6WsjB$useVisuallyHidden)({
90
+ style: {
91
+ opacity: "0.0001",
92
+ width: "100%",
93
+ height: "100%",
94
+ pointerEvents: "none"
95
+ }
96
+ });
76
97
  return {
77
98
  trackProps: {
78
99
  ...(0, $6WsjB$mergeProps)(groupProps, trackProps),
@@ -82,7 +103,13 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
82
103
  background: generateBackground()
83
104
  }
84
105
  },
85
- inputProps: inputProps,
106
+ inputProps: {
107
+ ...inputProps,
108
+ style: {
109
+ ...inputProps.style,
110
+ ...visuallyHiddenProps.style
111
+ }
112
+ },
86
113
  thumbProps: {
87
114
  ...thumbProps,
88
115
  style: {
@@ -1,6 +1,7 @@
1
1
  import {mergeProps as $6WsjB$mergeProps} from "@react-aria/utils";
2
2
  import {useLocale as $6WsjB$useLocale} from "@react-aria/i18n";
3
3
  import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb} from "@react-aria/slider";
4
+ import {useVisuallyHidden as $6WsjB$useVisuallyHidden} from "@react-aria/visually-hidden";
4
5
 
5
6
  /*
6
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,6 +16,7 @@ import {useSlider as $6WsjB$useSlider, useSliderThumb as $6WsjB$useSliderThumb}
15
16
  */
16
17
 
17
18
 
19
+
18
20
  function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
19
21
  let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
20
22
  let { locale: locale, direction: direction } = (0, $6WsjB$useLocale)();
@@ -41,7 +43,18 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
41
43
  else to = "left";
42
44
  switch(channel){
43
45
  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%)`;
46
+ {
47
+ let stops = [
48
+ 0,
49
+ 60,
50
+ 120,
51
+ 180,
52
+ 240,
53
+ 300,
54
+ 360
55
+ ].map((hue)=>value.withChannelValue("hue", hue).toString("css")).join(", ");
56
+ return `linear-gradient(to ${to}, ${stops})`;
57
+ }
45
58
  case "lightness":
46
59
  {
47
60
  // We have to add an extra color stop in the middle so that the hue shows up at all.
@@ -73,6 +86,14 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
73
86
  };
74
87
  if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
75
88
  else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
89
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $6WsjB$useVisuallyHidden)({
90
+ style: {
91
+ opacity: "0.0001",
92
+ width: "100%",
93
+ height: "100%",
94
+ pointerEvents: "none"
95
+ }
96
+ });
76
97
  return {
77
98
  trackProps: {
78
99
  ...(0, $6WsjB$mergeProps)(groupProps, trackProps),
@@ -82,7 +103,13 @@ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
82
103
  background: generateBackground()
83
104
  }
84
105
  },
85
- inputProps: inputProps,
106
+ inputProps: {
107
+ ...inputProps,
108
+ style: {
109
+ ...inputProps.style,
110
+ ...visuallyHiddenProps.style
111
+ }
112
+ },
86
113
  thumbProps: {
87
114
  ...thumbProps,
88
115
  style: {
@@ -1 +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,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAElC,oEAAoE;IACpE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,EACzD,YAAY,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS;IAGlD,gDAAgD;IAChD,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,cAAc;IAAS,GAAG,OAAO;IAC9G,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAC5C,OAAO;qBACP;QACA,YAAY,MAAM,UAAU;cAC5B;kBACA;kBACA;IACF,GAAG;IAEH,IAAI,QAAQ,MAAM,eAAe;IACjC,IAAI,qBAAqB;QACvB,IAAI;QACJ,IAAI,gBAAgB,YAClB,KAAK;aACA,IAAI,cAAc,OACvB,KAAK;aAEL,KAAK;QAEP,OAAQ;YACN,KAAK;gBACH,OAAO,CAAC,mBA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AW,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"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmCM,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,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAElC,oEAAoE;IACpE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,kBAAkB,EACzD,YAAY,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS;IAGlD,gDAAgD;IAChD,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,cAAc;IAAS,GAAG,OAAO;IAC9G,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAC5C,OAAO;qBACP;QACA,YAAY,MAAM,UAAU;cAC5B;kBACA;kBACA;IACF,GAAG;IAEH,IAAI,QAAQ,MAAM,eAAe;IACjC,IAAI,qBAAqB;QACvB,IAAI;QACJ,IAAI,gBAAgB,YAClB,KAAK;aACA,IAAI,cAAc,OACvB,KAAK;aAEL,KAAK;QAEP,OAAQ;YACN,KAAK;gBAAO;oBACV,IAAI,QAAQ;wBAAC;wBAAG;wBAAI;wBAAK;wBAAK;wBAAK;wBAAK;qBAAI,CAAC,GAAG,CAAC,CAA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CAAC,QAAQ,CAAC;IAGnE,IAAI,uBAAC,mBAAmB,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC5C,OAAO;YACL,SAAS;YACT,OAAO;YACP,QAAQ;YACR,eAAe;QACjB;IACF;IAEA,OAAO;QACL,YAAY;YACV,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;YACrC,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,0BAA0B;gBAC7B,YAAY;YACd;QACF;QACA,YAAY;YACV,GAAG,UAAU;YACb,OAAO;gBACL,GAAG,WAAW,KAAK;gBACnB,GAAG,oBAAoB,KAAK;YAC9B;QACF;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';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\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 let stops = [0, 60, 120, 180, 240, 300, 360].map(hue => value.withChannelValue('hue', hue).toString('css')).join(', ');\n return `linear-gradient(to ${to}, ${stops})`;\n }\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 let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\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 ...inputProps,\n style: {\n ...inputProps.style,\n ...visuallyHiddenProps.style\n }\n },\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,67 @@
1
+ var $4a33e168940636d5$exports = require("./intlStrings.main.js");
2
+ var $gp2Sz$reactariautils = require("@react-aria/utils");
3
+ var $gp2Sz$react = require("react");
4
+ var $gp2Sz$reactstatelycolor = require("@react-stately/color");
5
+ var $gp2Sz$reactariai18n = require("@react-aria/i18n");
6
+
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+
12
+ function $parcel$export(e, n, v, s) {
13
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
+ }
15
+
16
+ $parcel$export(module.exports, "useColorSwatch", () => $7c947b33be1ec2a6$export$9060ae606178d849);
17
+ /*
18
+ * Copyright 2024 Adobe. All rights reserved.
19
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License. You may obtain a copy
21
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software distributed under
24
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
25
+ * OF ANY KIND, either express or implied. See the License for the specific language
26
+ * governing permissions and limitations under the License.
27
+ */
28
+
29
+
30
+
31
+
32
+ function $7c947b33be1ec2a6$export$9060ae606178d849(props) {
33
+ let { color: value, colorName: colorName } = props;
34
+ let nonNullValue = value || "#fff0";
35
+ let color = (0, $gp2Sz$react.useMemo)(()=>typeof nonNullValue === "string" ? (0, $gp2Sz$reactstatelycolor.parseColor)(nonNullValue) : nonNullValue, [
36
+ nonNullValue
37
+ ]);
38
+ let { locale: locale } = (0, $gp2Sz$reactariai18n.useLocale)();
39
+ let DOMProps = (0, $gp2Sz$reactariautils.filterDOMProps)(props, {
40
+ labelable: true
41
+ });
42
+ let stringFormatter = (0, $gp2Sz$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4a33e168940636d5$exports))), "@react-aria/color");
43
+ let id = (0, $gp2Sz$reactariautils.useId)(props.id);
44
+ if (!colorName) colorName = color.getChannelValue("alpha") === 0 ? stringFormatter.format("transparent") : color.getColorName(locale);
45
+ return {
46
+ colorSwatchProps: {
47
+ ...DOMProps,
48
+ role: "img",
49
+ "aria-roledescription": stringFormatter.format("colorSwatch"),
50
+ "aria-label": [
51
+ colorName,
52
+ props["aria-label"] || ""
53
+ ].filter(Boolean).join(", "),
54
+ "aria-labelledby": props["aria-labelledby"] ? `${id} ${props["aria-labelledby"]}` : undefined,
55
+ id: id,
56
+ style: {
57
+ backgroundColor: color.toString("css"),
58
+ // @ts-ignore
59
+ forcedColorAdjust: "none"
60
+ }
61
+ },
62
+ color: color || null
63
+ };
64
+ }
65
+
66
+
67
+ //# sourceMappingURL=useColorSwatch.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAM,OAAO,iBAAiB,WAAW,CAAA,GAAA,mCAAS,EAAE,gBAAgB,cAAc;QAAC;KAAa;IACpH,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,8BAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,2BAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YAAY,MAAM,eAAe,CAAC,aAAa,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,MAAM,YAAY,CAAC;IAGhH,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/@react-aria/color/src/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from '@react-types/color';\nimport {filterDOMProps, useId} from '@react-aria/utils';\nimport {HTMLAttributes, useMemo} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {parseColor} from '@react-stately/color';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color | null,\n /** \n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>,\n /** The parsed color value of the swatch. */\n color: Color\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(() => typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue, [nonNullValue]);\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName = color.getChannelValue('alpha') === 0 ? stringFormatter.format('transparent') : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.main.js.map"}
@@ -0,0 +1,62 @@
1
+ import $kMaRF$intlStringsmodulejs from "./intlStrings.mjs";
2
+ import {filterDOMProps as $kMaRF$filterDOMProps, useId as $kMaRF$useId} from "@react-aria/utils";
3
+ import {useMemo as $kMaRF$useMemo} from "react";
4
+ import {parseColor as $kMaRF$parseColor} from "@react-stately/color";
5
+ import {useLocale as $kMaRF$useLocale, useLocalizedStringFormatter as $kMaRF$useLocalizedStringFormatter} from "@react-aria/i18n";
6
+
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+ /*
12
+ * Copyright 2024 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
+
25
+
26
+ function $2993fcad7650b98d$export$9060ae606178d849(props) {
27
+ let { color: value, colorName: colorName } = props;
28
+ let nonNullValue = value || "#fff0";
29
+ let color = (0, $kMaRF$useMemo)(()=>typeof nonNullValue === "string" ? (0, $kMaRF$parseColor)(nonNullValue) : nonNullValue, [
30
+ nonNullValue
31
+ ]);
32
+ let { locale: locale } = (0, $kMaRF$useLocale)();
33
+ let DOMProps = (0, $kMaRF$filterDOMProps)(props, {
34
+ labelable: true
35
+ });
36
+ let stringFormatter = (0, $kMaRF$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kMaRF$intlStringsmodulejs))), "@react-aria/color");
37
+ let id = (0, $kMaRF$useId)(props.id);
38
+ if (!colorName) colorName = color.getChannelValue("alpha") === 0 ? stringFormatter.format("transparent") : color.getColorName(locale);
39
+ return {
40
+ colorSwatchProps: {
41
+ ...DOMProps,
42
+ role: "img",
43
+ "aria-roledescription": stringFormatter.format("colorSwatch"),
44
+ "aria-label": [
45
+ colorName,
46
+ props["aria-label"] || ""
47
+ ].filter(Boolean).join(", "),
48
+ "aria-labelledby": props["aria-labelledby"] ? `${id} ${props["aria-labelledby"]}` : undefined,
49
+ id: id,
50
+ style: {
51
+ backgroundColor: color.toString("css"),
52
+ // @ts-ignore
53
+ forcedColorAdjust: "none"
54
+ }
55
+ },
56
+ color: color || null
57
+ };
58
+ }
59
+
60
+
61
+ export {$2993fcad7650b98d$export$9060ae606178d849 as useColorSwatch};
62
+ //# sourceMappingURL=useColorSwatch.mjs.map
@@ -0,0 +1,62 @@
1
+ import $kMaRF$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import {filterDOMProps as $kMaRF$filterDOMProps, useId as $kMaRF$useId} from "@react-aria/utils";
3
+ import {useMemo as $kMaRF$useMemo} from "react";
4
+ import {parseColor as $kMaRF$parseColor} from "@react-stately/color";
5
+ import {useLocale as $kMaRF$useLocale, useLocalizedStringFormatter as $kMaRF$useLocalizedStringFormatter} from "@react-aria/i18n";
6
+
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+ /*
12
+ * Copyright 2024 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
+
25
+
26
+ function $2993fcad7650b98d$export$9060ae606178d849(props) {
27
+ let { color: value, colorName: colorName } = props;
28
+ let nonNullValue = value || "#fff0";
29
+ let color = (0, $kMaRF$useMemo)(()=>typeof nonNullValue === "string" ? (0, $kMaRF$parseColor)(nonNullValue) : nonNullValue, [
30
+ nonNullValue
31
+ ]);
32
+ let { locale: locale } = (0, $kMaRF$useLocale)();
33
+ let DOMProps = (0, $kMaRF$filterDOMProps)(props, {
34
+ labelable: true
35
+ });
36
+ let stringFormatter = (0, $kMaRF$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kMaRF$intlStringsmodulejs))), "@react-aria/color");
37
+ let id = (0, $kMaRF$useId)(props.id);
38
+ if (!colorName) colorName = color.getChannelValue("alpha") === 0 ? stringFormatter.format("transparent") : color.getColorName(locale);
39
+ return {
40
+ colorSwatchProps: {
41
+ ...DOMProps,
42
+ role: "img",
43
+ "aria-roledescription": stringFormatter.format("colorSwatch"),
44
+ "aria-label": [
45
+ colorName,
46
+ props["aria-label"] || ""
47
+ ].filter(Boolean).join(", "),
48
+ "aria-labelledby": props["aria-labelledby"] ? `${id} ${props["aria-labelledby"]}` : undefined,
49
+ id: id,
50
+ style: {
51
+ backgroundColor: color.toString("css"),
52
+ // @ts-ignore
53
+ forcedColorAdjust: "none"
54
+ }
55
+ },
56
+ color: color || null
57
+ };
58
+ }
59
+
60
+
61
+ export {$2993fcad7650b98d$export$9060ae606178d849 as useColorSwatch};
62
+ //# sourceMappingURL=useColorSwatch.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAM,OAAO,iBAAiB,WAAW,CAAA,GAAA,iBAAS,EAAE,gBAAgB,cAAc;QAAC;KAAa;IACpH,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,gBAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,YAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YAAY,MAAM,eAAe,CAAC,aAAa,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,MAAM,YAAY,CAAC;IAGhH,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/@react-aria/color/src/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from '@react-types/color';\nimport {filterDOMProps, useId} from '@react-aria/utils';\nimport {HTMLAttributes, useMemo} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {parseColor} from '@react-stately/color';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color | null,\n /** \n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>,\n /** The parsed color value of the swatch. */\n color: Color\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(() => typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue, [nonNullValue]);\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName = color.getChannelValue('alpha') === 0 ? stringFormatter.format('transparent') : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.module.js.map"}
@@ -2,6 +2,7 @@ var $iWAp3$reactariautils = require("@react-aria/utils");
2
2
  var $iWAp3$react = require("react");
3
3
  var $iWAp3$reactariainteractions = require("@react-aria/interactions");
4
4
  var $iWAp3$reactariai18n = require("@react-aria/i18n");
5
+ var $iWAp3$reactariavisuallyhidden = require("@react-aria/visually-hidden");
5
6
 
6
7
 
7
8
  function $parcel$export(e, n, v, s) {
@@ -23,6 +24,7 @@ $parcel$export(module.exports, "useColorWheel", () => $1d29bf243d4a9a53$export$9
23
24
 
24
25
 
25
26
 
27
+
26
28
  function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
27
29
  let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
28
30
  let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $iWAp3$reactariautils.useGlobalListeners)();
@@ -195,6 +197,14 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
195
197
  let forcedColorAdjustNoneStyle = {
196
198
  forcedColorAdjust: "none"
197
199
  };
200
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $iWAp3$reactariavisuallyhidden.useVisuallyHidden)({
201
+ style: {
202
+ opacity: "0.0001",
203
+ width: "100%",
204
+ height: "100%",
205
+ pointerEvents: "none"
206
+ }
207
+ });
198
208
  return {
199
209
  trackProps: {
200
210
  ...trackInteractions,
@@ -229,9 +239,9 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
229
239
  ...thumbInteractions,
230
240
  style: {
231
241
  position: "absolute",
232
- left: "50%",
233
- top: "50%",
234
- transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
242
+ left: outerRadius + x,
243
+ top: outerRadius + y,
244
+ transform: "translate(-50%, -50%)",
235
245
  touchAction: "none",
236
246
  ...forcedColorAdjustNoneStyle
237
247
  }
@@ -247,7 +257,11 @@ function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
247
257
  name: name,
248
258
  onChange: (e)=>{
249
259
  state.setHue(parseFloat(e.target.value));
250
- }
260
+ },
261
+ style: visuallyHiddenProps.style,
262
+ "aria-errormessage": props["aria-errormessage"],
263
+ "aria-describedby": props["aria-describedby"],
264
+ "aria-details": props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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"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,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,QAAQ;oBAC9B;Y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;gBACtI,GAAG,0BAA0B;YAC/B;QACF;QACA,YAAY;YACV,GAAG,iBAAiB;YACpB,OAAO;gBACL,UAAU;gBACV,MAAM,cAAc;gBACpB,KAAK,cAAc;gBACnB,WAAW;gBACX,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;YACA,OAAO,oBAAoB,KAAK;YAChC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;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';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\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 let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\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: outerRadius + x,\n top: outerRadius + y,\n transform: 'translate(-50%, -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 style: visuallyHiddenProps.style,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\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"}
@@ -2,6 +2,7 @@ import {useGlobalListeners as $hcgPp$useGlobalListeners, focusWithoutScrolling a
2
2
  import {useCallback as $hcgPp$useCallback, useRef as $hcgPp$useRef} from "react";
3
3
  import {useKeyboard as $hcgPp$useKeyboard, useMove as $hcgPp$useMove} from "@react-aria/interactions";
4
4
  import {useLocale as $hcgPp$useLocale} from "@react-aria/i18n";
5
+ import {useVisuallyHidden as $hcgPp$useVisuallyHidden} from "@react-aria/visually-hidden";
5
6
 
6
7
  /*
7
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,6 +18,7 @@ import {useLocale as $hcgPp$useLocale} from "@react-aria/i18n";
17
18
 
18
19
 
19
20
 
21
+
20
22
  function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
21
23
  let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
22
24
  let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $hcgPp$useGlobalListeners)();
@@ -189,6 +191,14 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
189
191
  let forcedColorAdjustNoneStyle = {
190
192
  forcedColorAdjust: "none"
191
193
  };
194
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $hcgPp$useVisuallyHidden)({
195
+ style: {
196
+ opacity: "0.0001",
197
+ width: "100%",
198
+ height: "100%",
199
+ pointerEvents: "none"
200
+ }
201
+ });
192
202
  return {
193
203
  trackProps: {
194
204
  ...trackInteractions,
@@ -223,9 +233,9 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
223
233
  ...thumbInteractions,
224
234
  style: {
225
235
  position: "absolute",
226
- left: "50%",
227
- top: "50%",
228
- transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
236
+ left: outerRadius + x,
237
+ top: outerRadius + y,
238
+ transform: "translate(-50%, -50%)",
229
239
  touchAction: "none",
230
240
  ...forcedColorAdjustNoneStyle
231
241
  }
@@ -241,7 +251,11 @@ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
241
251
  name: name,
242
252
  onChange: (e)=>{
243
253
  state.setHue(parseFloat(e.target.value));
244
- }
254
+ },
255
+ style: visuallyHiddenProps.style,
256
+ "aria-errormessage": props["aria-errormessage"],
257
+ "aria-describedby": props["aria-describedby"],
258
+ "aria-details": props["aria-details"]
245
259
  })
246
260
  };
247
261
  }