@react-spectrum/color 3.1.7 → 3.2.0

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 (290) hide show
  1. package/dist/import.mjs +9 -11
  2. package/dist/main.js +18 -20
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +9 -11
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +16 -0
  7. package/package.json +14 -41
  8. package/src/index.ts +17 -15
  9. package/dist/ColorArea.main.js +0 -95
  10. package/dist/ColorArea.main.js.map +0 -1
  11. package/dist/ColorArea.mjs +0 -90
  12. package/dist/ColorArea.module.js +0 -90
  13. package/dist/ColorArea.module.js.map +0 -1
  14. package/dist/ColorEditor.main.js +0 -113
  15. package/dist/ColorEditor.main.js.map +0 -1
  16. package/dist/ColorEditor.mjs +0 -108
  17. package/dist/ColorEditor.module.js +0 -108
  18. package/dist/ColorEditor.module.js.map +0 -1
  19. package/dist/ColorField.main.js +0 -105
  20. package/dist/ColorField.main.js.map +0 -1
  21. package/dist/ColorField.mjs +0 -100
  22. package/dist/ColorField.module.js +0 -100
  23. package/dist/ColorField.module.js.map +0 -1
  24. package/dist/ColorPicker.main.js +0 -123
  25. package/dist/ColorPicker.main.js.map +0 -1
  26. package/dist/ColorPicker.mjs +0 -114
  27. package/dist/ColorPicker.module.js +0 -114
  28. package/dist/ColorPicker.module.js.map +0 -1
  29. package/dist/ColorSlider.main.js +0 -126
  30. package/dist/ColorSlider.main.js.map +0 -1
  31. package/dist/ColorSlider.mjs +0 -121
  32. package/dist/ColorSlider.module.js +0 -121
  33. package/dist/ColorSlider.module.js.map +0 -1
  34. package/dist/ColorSwatch.main.js +0 -91
  35. package/dist/ColorSwatch.main.js.map +0 -1
  36. package/dist/ColorSwatch.mjs +0 -81
  37. package/dist/ColorSwatch.module.js +0 -81
  38. package/dist/ColorSwatch.module.js.map +0 -1
  39. package/dist/ColorSwatchPicker.main.js +0 -112
  40. package/dist/ColorSwatchPicker.main.js.map +0 -1
  41. package/dist/ColorSwatchPicker.mjs +0 -103
  42. package/dist/ColorSwatchPicker.module.js +0 -103
  43. package/dist/ColorSwatchPicker.module.js.map +0 -1
  44. package/dist/ColorThumb.main.js +0 -146
  45. package/dist/ColorThumb.main.js.map +0 -1
  46. package/dist/ColorThumb.mjs +0 -141
  47. package/dist/ColorThumb.module.js +0 -141
  48. package/dist/ColorThumb.module.js.map +0 -1
  49. package/dist/ColorWheel.main.js +0 -114
  50. package/dist/ColorWheel.main.js.map +0 -1
  51. package/dist/ColorWheel.mjs +0 -109
  52. package/dist/ColorWheel.module.js +0 -109
  53. package/dist/ColorWheel.module.js.map +0 -1
  54. package/dist/ar-AE.main.js +0 -10
  55. package/dist/ar-AE.main.js.map +0 -1
  56. package/dist/ar-AE.mjs +0 -12
  57. package/dist/ar-AE.module.js +0 -12
  58. package/dist/ar-AE.module.js.map +0 -1
  59. package/dist/bg-BG.main.js +0 -10
  60. package/dist/bg-BG.main.js.map +0 -1
  61. package/dist/bg-BG.mjs +0 -12
  62. package/dist/bg-BG.module.js +0 -12
  63. package/dist/bg-BG.module.js.map +0 -1
  64. package/dist/color.0da417e8.css +0 -93
  65. package/dist/color.0da417e8.css.map +0 -1
  66. package/dist/color.4034864f.css +0 -120
  67. package/dist/color.4034864f.css.map +0 -1
  68. package/dist/color.51750948.css +0 -356
  69. package/dist/color.51750948.css.map +0 -1
  70. package/dist/color.6dfdb0cd.css +0 -260
  71. package/dist/color.6dfdb0cd.css.map +0 -1
  72. package/dist/color.85d29c28.css +0 -12
  73. package/dist/color.85d29c28.css.map +0 -1
  74. package/dist/color.8e3b650f.css +0 -93
  75. package/dist/color.8e3b650f.css.map +0 -1
  76. package/dist/color.a5310285.css +0 -206
  77. package/dist/color.a5310285.css.map +0 -1
  78. package/dist/color.decac5a6.css +0 -20
  79. package/dist/color.decac5a6.css.map +0 -1
  80. package/dist/color.f801bfa3.css +0 -75
  81. package/dist/color.f801bfa3.css.map +0 -1
  82. package/dist/color.ff589589.css +0 -41
  83. package/dist/color.ff589589.css.map +0 -1
  84. package/dist/colorarea_vars_css.main.js +0 -29
  85. package/dist/colorarea_vars_css.main.js.map +0 -1
  86. package/dist/colorarea_vars_css.mjs +0 -31
  87. package/dist/colorarea_vars_css.module.js +0 -31
  88. package/dist/colorarea_vars_css.module.js.map +0 -1
  89. package/dist/colorfield_css.main.js +0 -11
  90. package/dist/colorfield_css.main.js.map +0 -1
  91. package/dist/colorfield_css.mjs +0 -13
  92. package/dist/colorfield_css.module.js +0 -13
  93. package/dist/colorfield_css.module.js.map +0 -1
  94. package/dist/colorhandle_vars_css.main.js +0 -26
  95. package/dist/colorhandle_vars_css.main.js.map +0 -1
  96. package/dist/colorhandle_vars_css.mjs +0 -28
  97. package/dist/colorhandle_vars_css.module.js +0 -28
  98. package/dist/colorhandle_vars_css.module.js.map +0 -1
  99. package/dist/colorloupe_vars_css.main.js +0 -23
  100. package/dist/colorloupe_vars_css.main.js.map +0 -1
  101. package/dist/colorloupe_vars_css.mjs +0 -25
  102. package/dist/colorloupe_vars_css.module.js +0 -25
  103. package/dist/colorloupe_vars_css.module.js.map +0 -1
  104. package/dist/colorslider_vars_css.main.js +0 -53
  105. package/dist/colorslider_vars_css.main.js.map +0 -1
  106. package/dist/colorslider_vars_css.mjs +0 -55
  107. package/dist/colorslider_vars_css.module.js +0 -55
  108. package/dist/colorslider_vars_css.module.js.map +0 -1
  109. package/dist/colorwheel_vars_css.main.js +0 -35
  110. package/dist/colorwheel_vars_css.main.js.map +0 -1
  111. package/dist/colorwheel_vars_css.mjs +0 -37
  112. package/dist/colorwheel_vars_css.module.js +0 -37
  113. package/dist/colorwheel_vars_css.module.js.map +0 -1
  114. package/dist/cs-CZ.main.js +0 -10
  115. package/dist/cs-CZ.main.js.map +0 -1
  116. package/dist/cs-CZ.mjs +0 -12
  117. package/dist/cs-CZ.module.js +0 -12
  118. package/dist/cs-CZ.module.js.map +0 -1
  119. package/dist/da-DK.main.js +0 -10
  120. package/dist/da-DK.main.js.map +0 -1
  121. package/dist/da-DK.mjs +0 -12
  122. package/dist/da-DK.module.js +0 -12
  123. package/dist/da-DK.module.js.map +0 -1
  124. package/dist/de-DE.main.js +0 -10
  125. package/dist/de-DE.main.js.map +0 -1
  126. package/dist/de-DE.mjs +0 -12
  127. package/dist/de-DE.module.js +0 -12
  128. package/dist/de-DE.module.js.map +0 -1
  129. package/dist/el-GR.main.js +0 -10
  130. package/dist/el-GR.main.js.map +0 -1
  131. package/dist/el-GR.mjs +0 -12
  132. package/dist/el-GR.module.js +0 -12
  133. package/dist/el-GR.module.js.map +0 -1
  134. package/dist/en-US.main.js +0 -10
  135. package/dist/en-US.main.js.map +0 -1
  136. package/dist/en-US.mjs +0 -12
  137. package/dist/en-US.module.js +0 -12
  138. package/dist/en-US.module.js.map +0 -1
  139. package/dist/es-ES.main.js +0 -10
  140. package/dist/es-ES.main.js.map +0 -1
  141. package/dist/es-ES.mjs +0 -12
  142. package/dist/es-ES.module.js +0 -12
  143. package/dist/es-ES.module.js.map +0 -1
  144. package/dist/et-EE.main.js +0 -10
  145. package/dist/et-EE.main.js.map +0 -1
  146. package/dist/et-EE.mjs +0 -12
  147. package/dist/et-EE.module.js +0 -12
  148. package/dist/et-EE.module.js.map +0 -1
  149. package/dist/fi-FI.main.js +0 -10
  150. package/dist/fi-FI.main.js.map +0 -1
  151. package/dist/fi-FI.mjs +0 -12
  152. package/dist/fi-FI.module.js +0 -12
  153. package/dist/fi-FI.module.js.map +0 -1
  154. package/dist/fr-FR.main.js +0 -10
  155. package/dist/fr-FR.main.js.map +0 -1
  156. package/dist/fr-FR.mjs +0 -12
  157. package/dist/fr-FR.module.js +0 -12
  158. package/dist/fr-FR.module.js.map +0 -1
  159. package/dist/he-IL.main.js +0 -10
  160. package/dist/he-IL.main.js.map +0 -1
  161. package/dist/he-IL.mjs +0 -12
  162. package/dist/he-IL.module.js +0 -12
  163. package/dist/he-IL.module.js.map +0 -1
  164. package/dist/hr-HR.main.js +0 -10
  165. package/dist/hr-HR.main.js.map +0 -1
  166. package/dist/hr-HR.mjs +0 -12
  167. package/dist/hr-HR.module.js +0 -12
  168. package/dist/hr-HR.module.js.map +0 -1
  169. package/dist/hu-HU.main.js +0 -10
  170. package/dist/hu-HU.main.js.map +0 -1
  171. package/dist/hu-HU.mjs +0 -12
  172. package/dist/hu-HU.module.js +0 -12
  173. package/dist/hu-HU.module.js.map +0 -1
  174. package/dist/intlStrings.main.js +0 -108
  175. package/dist/intlStrings.main.js.map +0 -1
  176. package/dist/intlStrings.mjs +0 -110
  177. package/dist/intlStrings.module.js +0 -110
  178. package/dist/intlStrings.module.js.map +0 -1
  179. package/dist/it-IT.main.js +0 -10
  180. package/dist/it-IT.main.js.map +0 -1
  181. package/dist/it-IT.mjs +0 -12
  182. package/dist/it-IT.module.js +0 -12
  183. package/dist/it-IT.module.js.map +0 -1
  184. package/dist/ja-JP.main.js +0 -10
  185. package/dist/ja-JP.main.js.map +0 -1
  186. package/dist/ja-JP.mjs +0 -12
  187. package/dist/ja-JP.module.js +0 -12
  188. package/dist/ja-JP.module.js.map +0 -1
  189. package/dist/ko-KR.main.js +0 -10
  190. package/dist/ko-KR.main.js.map +0 -1
  191. package/dist/ko-KR.mjs +0 -12
  192. package/dist/ko-KR.module.js +0 -12
  193. package/dist/ko-KR.module.js.map +0 -1
  194. package/dist/lt-LT.main.js +0 -10
  195. package/dist/lt-LT.main.js.map +0 -1
  196. package/dist/lt-LT.mjs +0 -12
  197. package/dist/lt-LT.module.js +0 -12
  198. package/dist/lt-LT.module.js.map +0 -1
  199. package/dist/lv-LV.main.js +0 -10
  200. package/dist/lv-LV.main.js.map +0 -1
  201. package/dist/lv-LV.mjs +0 -12
  202. package/dist/lv-LV.module.js +0 -12
  203. package/dist/lv-LV.module.js.map +0 -1
  204. package/dist/nb-NO.main.js +0 -10
  205. package/dist/nb-NO.main.js.map +0 -1
  206. package/dist/nb-NO.mjs +0 -12
  207. package/dist/nb-NO.module.js +0 -12
  208. package/dist/nb-NO.module.js.map +0 -1
  209. package/dist/nl-NL.main.js +0 -10
  210. package/dist/nl-NL.main.js.map +0 -1
  211. package/dist/nl-NL.mjs +0 -12
  212. package/dist/nl-NL.module.js +0 -12
  213. package/dist/nl-NL.module.js.map +0 -1
  214. package/dist/pl-PL.main.js +0 -10
  215. package/dist/pl-PL.main.js.map +0 -1
  216. package/dist/pl-PL.mjs +0 -12
  217. package/dist/pl-PL.module.js +0 -12
  218. package/dist/pl-PL.module.js.map +0 -1
  219. package/dist/pt-BR.main.js +0 -10
  220. package/dist/pt-BR.main.js.map +0 -1
  221. package/dist/pt-BR.mjs +0 -12
  222. package/dist/pt-BR.module.js +0 -12
  223. package/dist/pt-BR.module.js.map +0 -1
  224. package/dist/pt-PT.main.js +0 -10
  225. package/dist/pt-PT.main.js.map +0 -1
  226. package/dist/pt-PT.mjs +0 -12
  227. package/dist/pt-PT.module.js +0 -12
  228. package/dist/pt-PT.module.js.map +0 -1
  229. package/dist/ro-RO.main.js +0 -10
  230. package/dist/ro-RO.main.js.map +0 -1
  231. package/dist/ro-RO.mjs +0 -12
  232. package/dist/ro-RO.module.js +0 -12
  233. package/dist/ro-RO.module.js.map +0 -1
  234. package/dist/ru-RU.main.js +0 -10
  235. package/dist/ru-RU.main.js.map +0 -1
  236. package/dist/ru-RU.mjs +0 -12
  237. package/dist/ru-RU.module.js +0 -12
  238. package/dist/ru-RU.module.js.map +0 -1
  239. package/dist/sk-SK.main.js +0 -10
  240. package/dist/sk-SK.main.js.map +0 -1
  241. package/dist/sk-SK.mjs +0 -12
  242. package/dist/sk-SK.module.js +0 -12
  243. package/dist/sk-SK.module.js.map +0 -1
  244. package/dist/sl-SI.main.js +0 -10
  245. package/dist/sl-SI.main.js.map +0 -1
  246. package/dist/sl-SI.mjs +0 -12
  247. package/dist/sl-SI.module.js +0 -12
  248. package/dist/sl-SI.module.js.map +0 -1
  249. package/dist/sr-SP.main.js +0 -10
  250. package/dist/sr-SP.main.js.map +0 -1
  251. package/dist/sr-SP.mjs +0 -12
  252. package/dist/sr-SP.module.js +0 -12
  253. package/dist/sr-SP.module.js.map +0 -1
  254. package/dist/sv-SE.main.js +0 -10
  255. package/dist/sv-SE.main.js.map +0 -1
  256. package/dist/sv-SE.mjs +0 -12
  257. package/dist/sv-SE.module.js +0 -12
  258. package/dist/sv-SE.module.js.map +0 -1
  259. package/dist/tr-TR.main.js +0 -10
  260. package/dist/tr-TR.main.js.map +0 -1
  261. package/dist/tr-TR.mjs +0 -12
  262. package/dist/tr-TR.module.js +0 -12
  263. package/dist/tr-TR.module.js.map +0 -1
  264. package/dist/types.d.ts +0 -96
  265. package/dist/types.d.ts.map +0 -1
  266. package/dist/uk-UA.main.js +0 -10
  267. package/dist/uk-UA.main.js.map +0 -1
  268. package/dist/uk-UA.mjs +0 -12
  269. package/dist/uk-UA.module.js +0 -12
  270. package/dist/uk-UA.module.js.map +0 -1
  271. package/dist/zh-CN.main.js +0 -10
  272. package/dist/zh-CN.main.js.map +0 -1
  273. package/dist/zh-CN.mjs +0 -12
  274. package/dist/zh-CN.module.js +0 -12
  275. package/dist/zh-CN.module.js.map +0 -1
  276. package/dist/zh-TW.main.js +0 -10
  277. package/dist/zh-TW.main.js.map +0 -1
  278. package/dist/zh-TW.mjs +0 -12
  279. package/dist/zh-TW.module.js +0 -12
  280. package/dist/zh-TW.module.js.map +0 -1
  281. package/src/ColorArea.tsx +0 -87
  282. package/src/ColorEditor.tsx +0 -60
  283. package/src/ColorField.tsx +0 -111
  284. package/src/ColorPicker.tsx +0 -120
  285. package/src/ColorSlider.tsx +0 -142
  286. package/src/ColorSwatch.tsx +0 -99
  287. package/src/ColorSwatchPicker.tsx +0 -115
  288. package/src/ColorThumb.tsx +0 -114
  289. package/src/ColorWheel.tsx +0 -110
  290. package/src/colorfield.css +0 -18
@@ -1,12 +0,0 @@
1
- var $c6270153671dc8fc$exports = {};
2
- $c6270153671dc8fc$exports = {
3
- "colorFormat": `\u{984F}\u{8272}\u{683C}\u{5F0F}`,
4
- "hex": `Hex`,
5
- "hsb": `HSB`,
6
- "hsl": `HSL`,
7
- "rgb": `RGB`
8
- };
9
-
10
-
11
- export {$c6270153671dc8fc$exports as default};
12
- //# sourceMappingURL=zh-TW.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,eAAe,CAAC,gCAAI,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC;IACZ,OAAO,CAAC,GAAG,CAAC;IACZ,OAAO,CAAC,GAAG,CAAC;IACZ,OAAO,CAAC,GAAG,CAAC;AACd","sources":["packages/@react-spectrum/color/intl/zh-TW.json"],"sourcesContent":["{\n \"colorFormat\": \"顏色格式\",\n \"hex\": \"Hex\",\n \"hsb\": \"HSB\",\n \"hsl\": \"HSL\",\n \"rgb\": \"RGB\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
package/src/ColorArea.tsx DELETED
@@ -1,87 +0,0 @@
1
- /*
2
- * Copyright 2021 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {classNames, dimensionValue, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
14
- import {ColorAreaContext, useContextProps} from 'react-aria-components';
15
- import {ColorThumb} from './ColorThumb';
16
- import {FocusableRef} from '@react-types/shared';
17
- import {mergeProps} from '@react-aria/utils';
18
- import React, {ReactElement, useRef} from 'react';
19
- import {SpectrumColorAreaProps} from '@react-types/color';
20
- import styles from '@adobe/spectrum-css-temp/components/colorarea/vars.css';
21
- import {useColorArea} from '@react-aria/color';
22
- import {useColorAreaState} from '@react-stately/color';
23
- import {useFocusRing} from '@react-aria/focus';
24
- import {useProviderProps} from '@react-spectrum/provider';
25
-
26
- /**
27
- * ColorArea allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.
28
- */
29
- export const ColorArea = React.forwardRef(function ColorArea(props: SpectrumColorAreaProps, ref: FocusableRef<HTMLDivElement>) {
30
- props = useProviderProps(props);
31
- let inputXRef = useRef(null);
32
- let inputYRef = useRef(null);
33
- let containerRef = useFocusableRef(ref, inputXRef);
34
- [props, containerRef] = useContextProps(props, containerRef, ColorAreaContext);
35
-
36
- let {isDisabled} = props;
37
- let size = props.size && dimensionValue(props.size);
38
- let {styleProps} = useStyleProps(props);
39
-
40
-
41
- let state = useColorAreaState(props);
42
-
43
- let {
44
- colorAreaProps,
45
- xInputProps,
46
- yInputProps,
47
- thumbProps
48
- } = useColorArea({...props, inputXRef, inputYRef, containerRef}, state);
49
- let {focusProps, isFocusVisible} = useFocusRing();
50
-
51
- return (
52
- <div
53
- {...colorAreaProps}
54
- className={
55
- classNames(
56
- styles,
57
- 'spectrum-ColorArea',
58
- {
59
- 'is-disabled': isDisabled
60
- },
61
- styleProps.className
62
- )
63
- }
64
- ref={containerRef}
65
- style={{
66
- ...(isDisabled ? {} : colorAreaProps.style),
67
- ...styleProps.style,
68
- // Workaround around https://github.com/adobe/spectrum-css/issues/1032
69
- width: size,
70
- height: size
71
- }}>
72
- <ColorThumb
73
- value={state.getDisplayColor()}
74
- isFocused={isFocusVisible}
75
- isDisabled={isDisabled}
76
- isDragging={state.isDragging}
77
- containerRef={containerRef}
78
- className={classNames(styles, 'spectrum-ColorArea-handle')}
79
- {...thumbProps}>
80
- <div role="presentation">
81
- <input className={classNames(styles, 'spectrum-ColorArea-slider')} {...mergeProps(xInputProps, focusProps)} ref={inputXRef} />
82
- <input className={classNames(styles, 'spectrum-ColorArea-slider')} {...mergeProps(yInputProps, focusProps)} ref={inputYRef} />
83
- </div>
84
- </ColorThumb>
85
- </div>
86
- );
87
- }) as (props: SpectrumColorAreaProps & {ref?: FocusableRef<HTMLDivElement>}) => ReactElement;
@@ -1,60 +0,0 @@
1
- import {ColorArea} from './ColorArea';
2
- import {ColorField} from './ColorField';
3
- import {ColorSlider} from './ColorSlider';
4
- import {ColorSpace} from '@react-types/color';
5
- import {DOMRef} from '@react-types/shared';
6
- import {getColorChannels} from '@react-stately/color';
7
- // @ts-ignore
8
- import intlMessages from '../intl/*.json';
9
- import {Item, Picker} from '@react-spectrum/picker';
10
- import React, {CSSProperties, useState} from 'react';
11
- import {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};
12
- import {useDOMRef} from '@react-spectrum/utils';
13
- import {useLocalizedStringFormatter} from '@react-aria/i18n';
14
-
15
- export interface SpectrumColorEditorProps {
16
- /** Whether to hide the alpha channel color slider and color field. */
17
- hideAlphaChannel?: boolean
18
- }
19
-
20
- /**
21
- * ColorEditor provides a default UI for editing colors within a ColorPicker.
22
- */
23
- export const ColorEditor = React.forwardRef(function ColorEditor(props: SpectrumColorEditorProps, ref: DOMRef<HTMLDivElement>) {
24
- let [format, setFormat] = useState<ColorSpace | 'hex'>('hex');
25
- let domRef = useDOMRef(ref);
26
- let formatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/color');
27
-
28
- return (
29
- <div className={style({display: 'flex', flexDirection: 'column', gap: 4})()} ref={domRef}>
30
- <div className={style({display: 'flex', gap: 4})()}>
31
- <ColorArea colorSpace="hsb" xChannel="saturation" yChannel="brightness" />
32
- <ColorSlider colorSpace="hsb" channel="hue" orientation="vertical" />
33
- {!props.hideAlphaChannel &&
34
- <ColorSlider channel="alpha" orientation="vertical" />
35
- }
36
- </div>
37
- <div className={style({display: 'flex', gap: 4})()}>
38
- <Picker
39
- aria-label={formatter.format('colorFormat')}
40
- isQuiet
41
- width="size-700"
42
- menuWidth="size-1000"
43
- selectedKey={format}
44
- onSelectionChange={f => setFormat(f as typeof format)}>
45
- <Item key="hex">{formatter.format('hex')}</Item>
46
- <Item key="rgb">{formatter.format('rgb')}</Item>
47
- <Item key="hsl">{formatter.format('hsl')}</Item>
48
- <Item key="hsb">{formatter.format('hsb')}</Item>
49
- </Picker>
50
- {format === 'hex'
51
- ? <ColorField isQuiet width="size-1000" aria-label={formatter.format('hex')} />
52
- : getColorChannels(format).map(channel => (
53
- <ColorField key={channel} colorSpace={format} channel={channel} isQuiet width="size-400" flex UNSAFE_style={{'--spectrum-textfield-min-width': 0} as CSSProperties} />
54
- ))}
55
- {!props.hideAlphaChannel &&
56
- <ColorField channel="alpha" isQuiet width="size-400" flex UNSAFE_style={{'--spectrum-textfield-min-width': 0} as CSSProperties} />}
57
- </div>
58
- </div>
59
- );
60
- });
@@ -1,111 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {classNames} from '@react-spectrum/utils';
14
- import {ColorChannel, SpectrumColorFieldProps} from '@react-types/color';
15
- import {ColorFieldContext, useContextProps} from 'react-aria-components';
16
- import React, {Ref, useEffect, useRef} from 'react';
17
- import styles from './colorfield.css';
18
- import {TextFieldBase} from '@react-spectrum/textfield';
19
- import {TextFieldRef} from '@react-types/textfield';
20
- import {useColorChannelField, useColorField} from '@react-aria/color';
21
- import {useColorChannelFieldState, useColorFieldState} from '@react-stately/color';
22
- import {useFormProps} from '@react-spectrum/form';
23
- import {useLocale} from '@react-aria/i18n';
24
- import {useProviderProps} from '@react-spectrum/provider';
25
-
26
- /**
27
- * A color field allows users to edit a hex color or individual color channel value.
28
- */
29
- export const ColorField = React.forwardRef(function ColorField(props: SpectrumColorFieldProps, ref: Ref<TextFieldRef>) {
30
- props = useProviderProps(props);
31
- props = useFormProps(props);
32
- [props] = useContextProps(props, null, ColorFieldContext);
33
-
34
- let hasWarned = useRef(false);
35
- useEffect(() => {
36
- if (props.placeholder && !hasWarned.current && process.env.NODE_ENV !== 'production') {
37
- console.warn('Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/ColorField.html#help-text');
38
- hasWarned.current = true;
39
- }
40
- }, [props.placeholder]);
41
-
42
- if (props.channel) {
43
- return <ColorChannelField {...props} channel={props.channel} forwardedRef={ref} />;
44
- } else {
45
- return <HexColorField {...props} forwardedRef={ref} />;
46
- }
47
- });
48
-
49
- interface ColorChannelFieldProps extends Omit<SpectrumColorFieldProps, 'channel'> {
50
- channel: ColorChannel,
51
- forwardedRef: Ref<TextFieldRef>
52
- }
53
-
54
- function ColorChannelField(props: ColorChannelFieldProps) {
55
- let {
56
- // These disabled props are handled by the state hook
57
- value, // eslint-disable-line @typescript-eslint/no-unused-vars
58
- defaultValue, // eslint-disable-line @typescript-eslint/no-unused-vars
59
- onChange, // eslint-disable-line @typescript-eslint/no-unused-vars
60
- validate, // eslint-disable-line @typescript-eslint/no-unused-vars
61
- forwardedRef,
62
- ...otherProps
63
- } = props;
64
- let {locale} = useLocale();
65
- let state = useColorChannelFieldState({
66
- ...props,
67
- locale
68
- });
69
-
70
- let inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);
71
- let result = useColorChannelField(otherProps, state, inputRef);
72
-
73
- return (
74
- <>
75
- <TextFieldBase
76
- {...otherProps}
77
- ref={forwardedRef}
78
- inputRef={inputRef}
79
- {...result}
80
- inputClassName={classNames(styles, 'react-spectrum-ColorField-input')} />
81
- {props.name && <input type="hidden" name={props.name} form={props.form} value={isNaN(state.numberValue) ? '' : state.numberValue} />}
82
- </>
83
- );
84
- }
85
-
86
- interface HexColorFieldProps extends SpectrumColorFieldProps {
87
- forwardedRef: Ref<TextFieldRef>
88
- }
89
-
90
- function HexColorField(props: HexColorFieldProps) {
91
- let {
92
- // These disabled props are handled by the state hook
93
- value, // eslint-disable-line @typescript-eslint/no-unused-vars
94
- defaultValue, // eslint-disable-line @typescript-eslint/no-unused-vars
95
- onChange, // eslint-disable-line @typescript-eslint/no-unused-vars
96
- forwardedRef,
97
- ...otherProps
98
- } = props;
99
- let state = useColorFieldState(props);
100
- let inputRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);
101
- let result = useColorField(otherProps, state, inputRef);
102
-
103
- return (
104
- <TextFieldBase
105
- {...otherProps}
106
- ref={forwardedRef}
107
- inputRef={inputRef}
108
- {...result}
109
- inputClassName={classNames(styles, 'react-spectrum-ColorField-input')} />
110
- );
111
- }
@@ -1,120 +0,0 @@
1
- /*
2
- * Copyright 2024 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {ColorPicker as AriaColorPicker, Button, Color} from 'react-aria-components';
14
- import {AriaLabelingProps, FocusableRef, ValueBase} from '@react-types/shared';
15
- import {ColorSwatch} from './ColorSwatch';
16
- import {Content} from '@react-spectrum/view';
17
- import {Dialog, DialogTrigger} from '@react-spectrum/dialog';
18
- import React, {ReactNode, useRef} from 'react';
19
- import {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};
20
- import {unwrapDOMRef, useFocusableRef} from '@react-spectrum/utils';
21
- import {useId} from '@react-aria/utils';
22
-
23
- export interface SpectrumColorPickerProps extends ValueBase<string | Color, Color>, AriaLabelingProps {
24
- /** A visual label for the color picker. */
25
- label?: ReactNode,
26
- /** The contents of the color picker popover, e.g. `<ColorEditor />`. */
27
- children?: ReactNode,
28
- /**
29
- * The size of the color swatch.
30
- * @default "M"
31
- */
32
- size?: 'XS' | 'S' | 'M' | 'L',
33
- /**
34
- * The corner rounding of the color swatch.
35
- * @default "default"
36
- */
37
- rounding?: 'default' | 'none' | 'full'
38
- }
39
-
40
- /**
41
- * A ColorPicker combines a swatch with a customizable popover for editing a color.
42
- */
43
- export const ColorPicker = React.forwardRef(function ColorPicker(props: SpectrumColorPickerProps, ref: FocusableRef<HTMLButtonElement>) {
44
- let swatchRef = useRef(null);
45
- let domRef = useFocusableRef(ref);
46
- let labelId = useId();
47
- return (
48
- <AriaColorPicker {...props}>
49
- <DialogTrigger type="popover" mobileType="tray" targetRef={unwrapDOMRef(swatchRef)}>
50
- <Button
51
- ref={domRef}
52
- className={style({
53
- backgroundColor: 'transparent',
54
- borderStyle: 'none',
55
- padding: 0,
56
- display: 'flex',
57
- alignItems: 'center',
58
- gap: 'text-to-control',
59
- outlineStyle: 'none',
60
- fontFamily: 'sans',
61
- color: 'body',
62
- fontSize: {
63
- size: {
64
- XS: 'xs',
65
- S: 'sm',
66
- M: 'base',
67
- L: 'lg'
68
- }
69
- }
70
- })({size: props.size || 'M'})}>
71
- {({isFocusVisible}) => (
72
- <>
73
- <div
74
- className={style({
75
- outlineStyle: {
76
- default: 'none',
77
- isFocusVisible: 'solid'
78
- },
79
- outlineColor: 'focus-ring',
80
- outlineWidth: 2,
81
- outlineOffset: 2,
82
- borderRadius: 'default'
83
- })({isFocusVisible})}>
84
- <ColorSwatch
85
- ref={swatchRef}
86
- color={props.value}
87
- size={props.size}
88
- rounding={props.rounding}
89
- aria-label={props['aria-label']}
90
- aria-labelledby={props['aria-labelledby']}
91
- aria-describedby={props['aria-describedby']}
92
- aria-details={props['aria-details']} />
93
- </div>
94
- {props.label &&
95
- <span id={labelId}>{props.label}</span>
96
- }
97
- </>
98
- )}
99
- </Button>
100
- <Dialog
101
- aria-labelledby={props.label ? labelId : props['aria-labelledby']}
102
- aria-label={props['aria-label']}
103
- UNSAFE_style={{
104
- width: 'fit-content',
105
- minWidth: 0,
106
- margin: '0 auto' // Center within tray.
107
- }}>
108
- <Content
109
- UNSAFE_style={{
110
- position: 'relative',
111
- margin: 'calc(var(--spectrum-dialog-padding) * -1)',
112
- padding: 'var(--spectrum-global-dimension-size-200)'
113
- }}>
114
- {props.children}
115
- </Content>
116
- </Dialog>
117
- </DialogTrigger>
118
- </AriaColorPicker>
119
- );
120
- });
@@ -1,142 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {classNames, SlotProvider, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
14
- import {ColorSliderContext, useContextProps} from 'react-aria-components';
15
- import {ColorThumb} from './ColorThumb';
16
- import {FocusableRef} from '@react-types/shared';
17
- import {Label} from '@react-spectrum/label';
18
- import React, {useRef, useState} from 'react';
19
- import {SpectrumColorSliderProps} from '@react-types/color';
20
- import styles from '@adobe/spectrum-css-temp/components/colorslider/vars.css';
21
- import {useColorSlider} from '@react-aria/color';
22
- import {useColorSliderState} from '@react-stately/color';
23
- import {useFocus, useFocusVisible} from '@react-aria/interactions';
24
- import {useLocale} from '@react-aria/i18n';
25
- import {useProviderProps} from '@react-spectrum/provider';
26
-
27
- /**
28
- * ColorSliders allow users to adjust an individual channel of a color value.
29
- */
30
- export const ColorSlider = React.forwardRef(function ColorSlider(props: SpectrumColorSliderProps, ref: FocusableRef<HTMLDivElement>) {
31
- props = useProviderProps(props);
32
- let inputRef = useRef(null);
33
- let trackRef = useRef(null);
34
- let domRef = useFocusableRef(ref, inputRef);
35
- [props, domRef] = useContextProps(props, domRef, ColorSliderContext);
36
-
37
- let {
38
- isDisabled,
39
- channel,
40
- orientation,
41
- label,
42
- showValueLabel,
43
- 'aria-label': ariaLabel
44
- } = props;
45
- let vertical = orientation === 'vertical';
46
-
47
- let {styleProps} = useStyleProps(props);
48
- let {locale} = useLocale();
49
-
50
- let state = useColorSliderState({...props, locale});
51
-
52
- // If vertical and a label is provided, use it as an aria-label instead.
53
- if (vertical && label) {
54
- ariaLabel = ariaLabel || (typeof label === 'string' ? label : undefined);
55
- label = null;
56
- }
57
-
58
- // If no external label, aria-label or aria-labelledby is provided,
59
- // default to displaying the localized channel value.
60
- // Specifically check if label is undefined. If label is `null` then display no visible label.
61
- // A default aria-label is provided by useColorSlider in that case.
62
- if (label === undefined && !ariaLabel && !props['aria-labelledby'] && !vertical) {
63
- label = state.value.getChannelName(channel, locale);
64
- }
65
-
66
- // Show the value label by default if there is a visible label
67
- if (showValueLabel == null) {
68
- showValueLabel = !!label;
69
- }
70
-
71
- let {inputProps, thumbProps, trackProps, labelProps, outputProps} = useColorSlider({
72
- ...props,
73
- label,
74
- 'aria-label': ariaLabel,
75
- trackRef,
76
- inputRef
77
- }, state);
78
-
79
- let {isFocusVisible} = useFocusVisible();
80
- let [isFocused, setIsFocused] = useState(false);
81
- let {focusProps} = useFocus({
82
- isDisabled,
83
- onFocusChange: setIsFocused
84
- });
85
-
86
- return (
87
- <div
88
- ref={domRef}
89
- {...styleProps}
90
- className={classNames(
91
- styles,
92
- {
93
- 'spectrum-ColorSlider-container--horizontal': !vertical,
94
- 'spectrum-ColorSlider-container--vertical': vertical
95
- },
96
- styleProps.className
97
- )}>
98
- {label &&
99
- <div className={classNames(styles, 'spectrum-ColorSlider-labelContainer')}>
100
- <Label {...labelProps}>{label}</Label>
101
- {props.contextualHelp &&
102
- <SlotProvider
103
- slots={{
104
- actionButton: {
105
- UNSAFE_className: classNames(styles, 'spectrum-ColorSlider-contextualHelp')
106
- }
107
- }}>
108
- {props.contextualHelp}
109
- </SlotProvider>
110
- }
111
- {showValueLabel && (
112
- <Label elementType="span" UNSAFE_className={classNames(styles, 'spectrum-ColorSlider-valueLabel')}>
113
- <output {...outputProps}>{state.value.formatChannelValue(channel, locale)}</output>
114
- </Label>
115
- )}
116
- </div>
117
- }
118
- <div
119
- {...trackProps}
120
- ref={trackRef}
121
- className={classNames(
122
- styles,
123
- 'spectrum-ColorSlider', {
124
- 'is-disabled': isDisabled,
125
- 'spectrum-ColorSlider--vertical': vertical
126
- }
127
- )
128
- }>
129
- <ColorThumb
130
- value={state.getDisplayColor()}
131
- isFocused={isFocused && isFocusVisible}
132
- isDisabled={isDisabled}
133
- isDragging={state.isThumbDragging(0)}
134
- containerRef={trackRef}
135
- className={classNames(styles, 'spectrum-ColorSlider-handle')}
136
- {...thumbProps}>
137
- <input {...inputProps} {...focusProps} ref={inputRef} className={classNames(styles, 'spectrum-ColorSlider-slider')} />
138
- </ColorThumb>
139
- </div>
140
- </div>
141
- );
142
- });
@@ -1,99 +0,0 @@
1
- /*
2
- * Copyright 2024 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {AriaColorSwatchProps, useColorSwatch} from '@react-aria/color';
14
- import {Color} from '@react-types/color';
15
- import {ColorSwatchContext, useContextProps} from 'react-aria-components';
16
- import {DOMRef, StyleProps} from '@react-types/shared';
17
- import React, {createContext, forwardRef, JSX, ReactElement, useContext} from 'react';
18
- import {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};
19
- import {useDOMRef, useStyleProps} from '@react-spectrum/utils';
20
-
21
- export interface SpectrumColorSwatchProps extends AriaColorSwatchProps, StyleProps {
22
- /**
23
- * The size of the ColorSwatch.
24
- * @default "M"
25
- */
26
- size?: 'XS' | 'S' | 'M' | 'L',
27
- /**
28
- * The corner rounding of the ColorSwatch.
29
- * @default "default"
30
- */
31
- rounding?: 'default' | 'none' | 'full'
32
- }
33
-
34
- interface SpectrumColorSwatchContextValue extends Pick<SpectrumColorSwatchProps, 'size' | 'rounding'> {
35
- useWrapper: (swatch: ReactElement, color: Color, rounding: SpectrumColorSwatchProps['rounding']) => JSX.Element
36
- }
37
-
38
- export const SpectrumColorSwatchContext = createContext<SpectrumColorSwatchContextValue | null>(null);
39
-
40
- /**
41
- * A ColorSwatch displays a preview of a selected color.
42
- */
43
- export const ColorSwatch = forwardRef(function ColorSwatch(props: SpectrumColorSwatchProps, ref: DOMRef<HTMLDivElement>): JSX.Element {
44
- let domRef = useDOMRef(ref);
45
- [props, domRef] = useContextProps(props, domRef, ColorSwatchContext);
46
- let {colorSwatchProps, color} = useColorSwatch(props);
47
- let {styleProps} = useStyleProps(props);
48
- let ctx = useContext(SpectrumColorSwatchContext);
49
- let {
50
- size = ctx?.size || 'M',
51
- rounding = ctx?.rounding || 'default'
52
- } = props;
53
-
54
- let swatch = (
55
- <div
56
- {...colorSwatchProps}
57
- {...styleProps}
58
- ref={domRef}
59
- style={{
60
- ...styleProps.style,
61
- // TODO: should there be a distinction between transparent and no value (e.g. null)?
62
- background: color.getChannelValue('alpha') > 0
63
- ? `linear-gradient(${color}, ${color}), repeating-conic-gradient(#e6e6e6 0% 25%, white 0% 50%) 0% 50% / 16px 16px`
64
- // Red slash to indicate there is no selected color.
65
- : 'linear-gradient(to bottom right, transparent calc(50% - 2px), var(--spectrum-red-900) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)) no-repeat'
66
- }}
67
- className={styleProps.className + style({
68
- size: {
69
- size: {
70
- XS: 4,
71
- S: 6,
72
- M: 8,
73
- L: 10
74
- }
75
- },
76
- borderRadius: {
77
- rounding: {
78
- default: 'default',
79
- none: 'none',
80
- full: 'full'
81
- }
82
- },
83
- // Trick to create a partially transparent color from a variable.
84
- // Ideally we'd use relative color syntax for this but it's not in Firefox yet.
85
- borderColor: '[color-mix(in srgb, var(--spectrum-gray-900), transparent 49%)]',
86
- borderWidth: 1,
87
- borderStyle: 'solid',
88
- boxSizing: 'border-box',
89
- forcedColorAdjust: 'none'
90
- })({size, rounding})} />
91
- );
92
-
93
- // ColorSwatchPicker needs to wrap the swatch in a ListBoxItem.
94
- if (ctx) {
95
- return ctx.useWrapper(swatch, color, rounding);
96
- }
97
-
98
- return swatch;
99
- });