@react-spectrum/button 3.0.0-nightly-641446f65-240905

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 (228) hide show
  1. package/README.md +3 -0
  2. package/dist/ActionButton.main.js +97 -0
  3. package/dist/ActionButton.main.js.map +1 -0
  4. package/dist/ActionButton.mjs +92 -0
  5. package/dist/ActionButton.module.js +92 -0
  6. package/dist/ActionButton.module.js.map +1 -0
  7. package/dist/Button.main.js +186 -0
  8. package/dist/Button.main.js.map +1 -0
  9. package/dist/Button.mjs +181 -0
  10. package/dist/Button.module.js +181 -0
  11. package/dist/Button.module.js.map +1 -0
  12. package/dist/ClearButton.main.js +75 -0
  13. package/dist/ClearButton.main.js.map +1 -0
  14. package/dist/ClearButton.mjs +70 -0
  15. package/dist/ClearButton.module.js +70 -0
  16. package/dist/ClearButton.module.js.map +1 -0
  17. package/dist/FieldButton.main.js +72 -0
  18. package/dist/FieldButton.main.js.map +1 -0
  19. package/dist/FieldButton.mjs +67 -0
  20. package/dist/FieldButton.module.js +67 -0
  21. package/dist/FieldButton.module.js.map +1 -0
  22. package/dist/LogicButton.main.js +70 -0
  23. package/dist/LogicButton.main.js.map +1 -0
  24. package/dist/LogicButton.mjs +65 -0
  25. package/dist/LogicButton.module.js +65 -0
  26. package/dist/LogicButton.module.js.map +1 -0
  27. package/dist/ToggleButton.main.js +90 -0
  28. package/dist/ToggleButton.main.js.map +1 -0
  29. package/dist/ToggleButton.mjs +85 -0
  30. package/dist/ToggleButton.module.js +85 -0
  31. package/dist/ToggleButton.module.js.map +1 -0
  32. package/dist/ar-AE.main.js +6 -0
  33. package/dist/ar-AE.main.js.map +1 -0
  34. package/dist/ar-AE.mjs +8 -0
  35. package/dist/ar-AE.module.js +8 -0
  36. package/dist/ar-AE.module.js.map +1 -0
  37. package/dist/bg-BG.main.js +6 -0
  38. package/dist/bg-BG.main.js.map +1 -0
  39. package/dist/bg-BG.mjs +8 -0
  40. package/dist/bg-BG.module.js +8 -0
  41. package/dist/bg-BG.module.js.map +1 -0
  42. package/dist/button_vars_css.main.js +122 -0
  43. package/dist/button_vars_css.main.js.map +1 -0
  44. package/dist/button_vars_css.mjs +124 -0
  45. package/dist/button_vars_css.module.js +124 -0
  46. package/dist/button_vars_css.module.js.map +1 -0
  47. package/dist/cs-CZ.main.js +6 -0
  48. package/dist/cs-CZ.main.js.map +1 -0
  49. package/dist/cs-CZ.mjs +8 -0
  50. package/dist/cs-CZ.module.js +8 -0
  51. package/dist/cs-CZ.module.js.map +1 -0
  52. package/dist/da-DK.main.js +6 -0
  53. package/dist/da-DK.main.js.map +1 -0
  54. package/dist/da-DK.mjs +8 -0
  55. package/dist/da-DK.module.js +8 -0
  56. package/dist/da-DK.module.js.map +1 -0
  57. package/dist/de-DE.main.js +6 -0
  58. package/dist/de-DE.main.js.map +1 -0
  59. package/dist/de-DE.mjs +8 -0
  60. package/dist/de-DE.module.js +8 -0
  61. package/dist/de-DE.module.js.map +1 -0
  62. package/dist/el-GR.main.js +6 -0
  63. package/dist/el-GR.main.js.map +1 -0
  64. package/dist/el-GR.mjs +8 -0
  65. package/dist/el-GR.module.js +8 -0
  66. package/dist/el-GR.module.js.map +1 -0
  67. package/dist/en-US.main.js +6 -0
  68. package/dist/en-US.main.js.map +1 -0
  69. package/dist/en-US.mjs +8 -0
  70. package/dist/en-US.module.js +8 -0
  71. package/dist/en-US.module.js.map +1 -0
  72. package/dist/es-ES.main.js +6 -0
  73. package/dist/es-ES.main.js.map +1 -0
  74. package/dist/es-ES.mjs +8 -0
  75. package/dist/es-ES.module.js +8 -0
  76. package/dist/es-ES.module.js.map +1 -0
  77. package/dist/et-EE.main.js +6 -0
  78. package/dist/et-EE.main.js.map +1 -0
  79. package/dist/et-EE.mjs +8 -0
  80. package/dist/et-EE.module.js +8 -0
  81. package/dist/et-EE.module.js.map +1 -0
  82. package/dist/fi-FI.main.js +6 -0
  83. package/dist/fi-FI.main.js.map +1 -0
  84. package/dist/fi-FI.mjs +8 -0
  85. package/dist/fi-FI.module.js +8 -0
  86. package/dist/fi-FI.module.js.map +1 -0
  87. package/dist/fr-FR.main.js +6 -0
  88. package/dist/fr-FR.main.js.map +1 -0
  89. package/dist/fr-FR.mjs +8 -0
  90. package/dist/fr-FR.module.js +8 -0
  91. package/dist/fr-FR.module.js.map +1 -0
  92. package/dist/he-IL.main.js +6 -0
  93. package/dist/he-IL.main.js.map +1 -0
  94. package/dist/he-IL.mjs +8 -0
  95. package/dist/he-IL.module.js +8 -0
  96. package/dist/he-IL.module.js.map +1 -0
  97. package/dist/hr-HR.main.js +6 -0
  98. package/dist/hr-HR.main.js.map +1 -0
  99. package/dist/hr-HR.mjs +8 -0
  100. package/dist/hr-HR.module.js +8 -0
  101. package/dist/hr-HR.module.js.map +1 -0
  102. package/dist/hu-HU.main.js +6 -0
  103. package/dist/hu-HU.main.js.map +1 -0
  104. package/dist/hu-HU.mjs +8 -0
  105. package/dist/hu-HU.module.js +8 -0
  106. package/dist/hu-HU.module.js.map +1 -0
  107. package/dist/import.mjs +28 -0
  108. package/dist/intlStrings.main.js +108 -0
  109. package/dist/intlStrings.main.js.map +1 -0
  110. package/dist/intlStrings.mjs +110 -0
  111. package/dist/intlStrings.module.js +110 -0
  112. package/dist/intlStrings.module.js.map +1 -0
  113. package/dist/it-IT.main.js +6 -0
  114. package/dist/it-IT.main.js.map +1 -0
  115. package/dist/it-IT.mjs +8 -0
  116. package/dist/it-IT.module.js +8 -0
  117. package/dist/it-IT.module.js.map +1 -0
  118. package/dist/ja-JP.main.js +6 -0
  119. package/dist/ja-JP.main.js.map +1 -0
  120. package/dist/ja-JP.mjs +8 -0
  121. package/dist/ja-JP.module.js +8 -0
  122. package/dist/ja-JP.module.js.map +1 -0
  123. package/dist/ko-KR.main.js +6 -0
  124. package/dist/ko-KR.main.js.map +1 -0
  125. package/dist/ko-KR.mjs +8 -0
  126. package/dist/ko-KR.module.js +8 -0
  127. package/dist/ko-KR.module.js.map +1 -0
  128. package/dist/lt-LT.main.js +6 -0
  129. package/dist/lt-LT.main.js.map +1 -0
  130. package/dist/lt-LT.mjs +8 -0
  131. package/dist/lt-LT.module.js +8 -0
  132. package/dist/lt-LT.module.js.map +1 -0
  133. package/dist/lv-LV.main.js +6 -0
  134. package/dist/lv-LV.main.js.map +1 -0
  135. package/dist/lv-LV.mjs +8 -0
  136. package/dist/lv-LV.module.js +8 -0
  137. package/dist/lv-LV.module.js.map +1 -0
  138. package/dist/main.js +38 -0
  139. package/dist/main.js.map +1 -0
  140. package/dist/module.js +28 -0
  141. package/dist/module.js.map +1 -0
  142. package/dist/nb-NO.main.js +6 -0
  143. package/dist/nb-NO.main.js.map +1 -0
  144. package/dist/nb-NO.mjs +8 -0
  145. package/dist/nb-NO.module.js +8 -0
  146. package/dist/nb-NO.module.js.map +1 -0
  147. package/dist/nl-NL.main.js +6 -0
  148. package/dist/nl-NL.main.js.map +1 -0
  149. package/dist/nl-NL.mjs +8 -0
  150. package/dist/nl-NL.module.js +8 -0
  151. package/dist/nl-NL.module.js.map +1 -0
  152. package/dist/pl-PL.main.js +6 -0
  153. package/dist/pl-PL.main.js.map +1 -0
  154. package/dist/pl-PL.mjs +8 -0
  155. package/dist/pl-PL.module.js +8 -0
  156. package/dist/pl-PL.module.js.map +1 -0
  157. package/dist/pt-BR.main.js +6 -0
  158. package/dist/pt-BR.main.js.map +1 -0
  159. package/dist/pt-BR.mjs +8 -0
  160. package/dist/pt-BR.module.js +8 -0
  161. package/dist/pt-BR.module.js.map +1 -0
  162. package/dist/pt-PT.main.js +6 -0
  163. package/dist/pt-PT.main.js.map +1 -0
  164. package/dist/pt-PT.mjs +8 -0
  165. package/dist/pt-PT.module.js +8 -0
  166. package/dist/pt-PT.module.js.map +1 -0
  167. package/dist/ro-RO.main.js +6 -0
  168. package/dist/ro-RO.main.js.map +1 -0
  169. package/dist/ro-RO.mjs +8 -0
  170. package/dist/ro-RO.module.js +8 -0
  171. package/dist/ro-RO.module.js.map +1 -0
  172. package/dist/ru-RU.main.js +6 -0
  173. package/dist/ru-RU.main.js.map +1 -0
  174. package/dist/ru-RU.mjs +8 -0
  175. package/dist/ru-RU.module.js +8 -0
  176. package/dist/ru-RU.module.js.map +1 -0
  177. package/dist/sk-SK.main.js +6 -0
  178. package/dist/sk-SK.main.js.map +1 -0
  179. package/dist/sk-SK.mjs +8 -0
  180. package/dist/sk-SK.module.js +8 -0
  181. package/dist/sk-SK.module.js.map +1 -0
  182. package/dist/sl-SI.main.js +6 -0
  183. package/dist/sl-SI.main.js.map +1 -0
  184. package/dist/sl-SI.mjs +8 -0
  185. package/dist/sl-SI.module.js +8 -0
  186. package/dist/sl-SI.module.js.map +1 -0
  187. package/dist/sr-SP.main.js +6 -0
  188. package/dist/sr-SP.main.js.map +1 -0
  189. package/dist/sr-SP.mjs +8 -0
  190. package/dist/sr-SP.module.js +8 -0
  191. package/dist/sr-SP.module.js.map +1 -0
  192. package/dist/sv-SE.main.js +6 -0
  193. package/dist/sv-SE.main.js.map +1 -0
  194. package/dist/sv-SE.mjs +8 -0
  195. package/dist/sv-SE.module.js +8 -0
  196. package/dist/sv-SE.module.js.map +1 -0
  197. package/dist/tr-TR.main.js +6 -0
  198. package/dist/tr-TR.main.js.map +1 -0
  199. package/dist/tr-TR.mjs +8 -0
  200. package/dist/tr-TR.module.js +8 -0
  201. package/dist/tr-TR.module.js.map +1 -0
  202. package/dist/types.d.ts +43 -0
  203. package/dist/types.d.ts.map +1 -0
  204. package/dist/uk-UA.main.js +6 -0
  205. package/dist/uk-UA.main.js.map +1 -0
  206. package/dist/uk-UA.mjs +8 -0
  207. package/dist/uk-UA.module.js +8 -0
  208. package/dist/uk-UA.module.js.map +1 -0
  209. package/dist/vars.4fe44343.css +1645 -0
  210. package/dist/vars.4fe44343.css.map +1 -0
  211. package/dist/zh-CN.main.js +6 -0
  212. package/dist/zh-CN.main.js.map +1 -0
  213. package/dist/zh-CN.mjs +8 -0
  214. package/dist/zh-CN.module.js +8 -0
  215. package/dist/zh-CN.module.js.map +1 -0
  216. package/dist/zh-TW.main.js +6 -0
  217. package/dist/zh-TW.main.js.map +1 -0
  218. package/dist/zh-TW.mjs +8 -0
  219. package/dist/zh-TW.module.js +8 -0
  220. package/dist/zh-TW.module.js.map +1 -0
  221. package/package.json +66 -0
  222. package/src/ActionButton.tsx +107 -0
  223. package/src/Button.tsx +210 -0
  224. package/src/ClearButton.tsx +81 -0
  225. package/src/FieldButton.tsx +84 -0
  226. package/src/LogicButton.tsx +67 -0
  227. package/src/ToggleButton.tsx +93 -0
  228. package/src/index.ts +19 -0
@@ -0,0 +1,67 @@
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, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
14
+ import {FocusableRef} from '@react-types/shared';
15
+ import {FocusRing} from '@react-aria/focus';
16
+ import {mergeProps} from '@react-aria/utils';
17
+ import React from 'react';
18
+ import {SpectrumLogicButtonProps} from '@react-types/button';
19
+ import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
20
+ import {useButton} from '@react-aria/button';
21
+ import {useHover} from '@react-aria/interactions';
22
+ import {useProviderProps} from '@react-spectrum/provider';
23
+
24
+ function LogicButton(props: SpectrumLogicButtonProps, ref: FocusableRef<HTMLButtonElement>) {
25
+ props = useProviderProps(props);
26
+ let {
27
+ variant,
28
+ children,
29
+ isDisabled,
30
+ autoFocus,
31
+ ...otherProps
32
+ } = props;
33
+ let domRef = useFocusableRef(ref);
34
+ let {buttonProps, isPressed} = useButton(props, domRef);
35
+ let {hoverProps, isHovered} = useHover({isDisabled});
36
+ let {styleProps} = useStyleProps(otherProps);
37
+
38
+ return (
39
+ <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
40
+ <button
41
+ {...styleProps}
42
+ {...mergeProps(buttonProps, hoverProps)}
43
+ ref={domRef}
44
+ className={
45
+ classNames(
46
+ styles,
47
+ 'spectrum-LogicButton',
48
+ {
49
+ [`spectrum-LogicButton--${variant}`]: variant,
50
+ 'is-disabled': isDisabled,
51
+ 'is-active': isPressed,
52
+ 'is-hovered': isHovered
53
+ },
54
+ styleProps.className
55
+ )
56
+ }>
57
+ <span className={classNames(styles, 'spectrum-Button-label')}>{children}</span>
58
+ </button>
59
+ </FocusRing>
60
+ );
61
+ }
62
+
63
+ /**
64
+ * A LogicButton displays an operator within a boolean logic sequence.
65
+ */
66
+ let _LogicButton = React.forwardRef(LogicButton);
67
+ export {_LogicButton as LogicButton};
@@ -0,0 +1,93 @@
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 {FocusableRef} from '@react-types/shared';
15
+ import {FocusRing} from '@react-aria/focus';
16
+ import {mergeProps} from '@react-aria/utils';
17
+ import React from 'react';
18
+ import {SpectrumToggleButtonProps} from '@react-types/button';
19
+ import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
20
+ import {Text} from '@react-spectrum/text';
21
+ import {useHover} from '@react-aria/interactions';
22
+ import {useProviderProps} from '@react-spectrum/provider';
23
+ import {useToggleButton} from '@react-aria/button';
24
+ import {useToggleState} from '@react-stately/toggle';
25
+
26
+ function ToggleButton(props: SpectrumToggleButtonProps, ref: FocusableRef<HTMLButtonElement>) {
27
+ props = useProviderProps(props);
28
+ let {
29
+ isQuiet,
30
+ isDisabled,
31
+ isEmphasized,
32
+ staticColor,
33
+ children,
34
+ autoFocus,
35
+ ...otherProps
36
+ } = props;
37
+
38
+ let domRef = useFocusableRef(ref);
39
+ let state = useToggleState(props);
40
+ let {buttonProps, isPressed} = useToggleButton(props, state, domRef);
41
+ let {hoverProps, isHovered} = useHover({isDisabled});
42
+ let {styleProps} = useStyleProps(otherProps);
43
+ let isTextOnly = React.Children.toArray(props.children).every(c => !React.isValidElement(c));
44
+
45
+ return (
46
+ <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
47
+ <button
48
+ {...styleProps}
49
+ {...mergeProps(buttonProps, hoverProps)}
50
+ ref={domRef}
51
+ className={
52
+ classNames(
53
+ styles,
54
+ 'spectrum-ActionButton',
55
+ {
56
+ 'spectrum-ActionButton--quiet': isQuiet,
57
+ 'spectrum-ActionButton--emphasized': isEmphasized,
58
+ 'spectrum-ActionButton--staticColor': !!staticColor,
59
+ 'spectrum-ActionButton--staticWhite': staticColor === 'white',
60
+ 'spectrum-ActionButton--staticBlack': staticColor === 'black',
61
+ 'is-active': isPressed,
62
+ 'is-disabled': isDisabled,
63
+ 'is-hovered': isHovered,
64
+ 'is-selected': state.isSelected
65
+ },
66
+ styleProps.className
67
+ )
68
+ }>
69
+ <SlotProvider
70
+ slots={{
71
+ icon: {
72
+ size: 'S',
73
+ UNSAFE_className: classNames(styles, 'spectrum-Icon')
74
+ },
75
+ text: {
76
+ UNSAFE_className: classNames(styles, 'spectrum-ActionButton-label')
77
+ }
78
+ }}>
79
+ {typeof children === 'string' || isTextOnly
80
+ ? <Text>{children}</Text>
81
+ : children}
82
+ </SlotProvider>
83
+ </button>
84
+ </FocusRing>
85
+ );
86
+ }
87
+
88
+ /**
89
+ * ToggleButtons allow users to toggle a selection on or off, for example
90
+ * switching between two states or modes.
91
+ */
92
+ let _ToggleButton = React.forwardRef(ToggleButton);
93
+ export {_ToggleButton as ToggleButton};
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
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
+ /// <reference types="css-module-types" />
13
+ export {Button} from './Button';
14
+ export {ActionButton} from './ActionButton';
15
+ export {FieldButton} from './FieldButton';
16
+ export {LogicButton} from './LogicButton';
17
+ export {ClearButton} from './ClearButton';
18
+ export {ToggleButton} from './ToggleButton';
19
+ export type {SpectrumActionButtonProps, SpectrumButtonProps, SpectrumLogicButtonProps, SpectrumToggleButtonProps} from '@react-types/button';