@react-spectrum/button 3.17.7 → 3.18.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 (228) hide show
  1. package/dist/import.mjs +7 -7
  2. package/dist/main.js +12 -12
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +7 -7
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +10 -0
  7. package/package.json +12 -35
  8. package/src/index.ts +11 -7
  9. package/dist/ActionButton.main.js +0 -93
  10. package/dist/ActionButton.main.js.map +0 -1
  11. package/dist/ActionButton.mjs +0 -88
  12. package/dist/ActionButton.module.js +0 -88
  13. package/dist/ActionButton.module.js.map +0 -1
  14. package/dist/Button.main.js +0 -181
  15. package/dist/Button.main.js.map +0 -1
  16. package/dist/Button.mjs +0 -176
  17. package/dist/Button.module.js +0 -176
  18. package/dist/Button.module.js.map +0 -1
  19. package/dist/ClearButton.main.js +0 -75
  20. package/dist/ClearButton.main.js.map +0 -1
  21. package/dist/ClearButton.mjs +0 -70
  22. package/dist/ClearButton.module.js +0 -70
  23. package/dist/ClearButton.module.js.map +0 -1
  24. package/dist/FieldButton.main.js +0 -70
  25. package/dist/FieldButton.main.js.map +0 -1
  26. package/dist/FieldButton.mjs +0 -65
  27. package/dist/FieldButton.module.js +0 -65
  28. package/dist/FieldButton.module.js.map +0 -1
  29. package/dist/LogicButton.main.js +0 -67
  30. package/dist/LogicButton.main.js.map +0 -1
  31. package/dist/LogicButton.mjs +0 -62
  32. package/dist/LogicButton.module.js +0 -62
  33. package/dist/LogicButton.module.js.map +0 -1
  34. package/dist/ToggleButton.main.js +0 -86
  35. package/dist/ToggleButton.main.js.map +0 -1
  36. package/dist/ToggleButton.mjs +0 -81
  37. package/dist/ToggleButton.module.js +0 -81
  38. package/dist/ToggleButton.module.js.map +0 -1
  39. package/dist/ar-AE.main.js +0 -6
  40. package/dist/ar-AE.main.js.map +0 -1
  41. package/dist/ar-AE.mjs +0 -8
  42. package/dist/ar-AE.module.js +0 -8
  43. package/dist/ar-AE.module.js.map +0 -1
  44. package/dist/bg-BG.main.js +0 -6
  45. package/dist/bg-BG.main.js.map +0 -1
  46. package/dist/bg-BG.mjs +0 -8
  47. package/dist/bg-BG.module.js +0 -8
  48. package/dist/bg-BG.module.js.map +0 -1
  49. package/dist/button.c18453ac.css +0 -1669
  50. package/dist/button.c18453ac.css.map +0 -1
  51. package/dist/button_vars_css.main.js +0 -125
  52. package/dist/button_vars_css.main.js.map +0 -1
  53. package/dist/button_vars_css.mjs +0 -127
  54. package/dist/button_vars_css.module.js +0 -127
  55. package/dist/button_vars_css.module.js.map +0 -1
  56. package/dist/cs-CZ.main.js +0 -6
  57. package/dist/cs-CZ.main.js.map +0 -1
  58. package/dist/cs-CZ.mjs +0 -8
  59. package/dist/cs-CZ.module.js +0 -8
  60. package/dist/cs-CZ.module.js.map +0 -1
  61. package/dist/da-DK.main.js +0 -6
  62. package/dist/da-DK.main.js.map +0 -1
  63. package/dist/da-DK.mjs +0 -8
  64. package/dist/da-DK.module.js +0 -8
  65. package/dist/da-DK.module.js.map +0 -1
  66. package/dist/de-DE.main.js +0 -6
  67. package/dist/de-DE.main.js.map +0 -1
  68. package/dist/de-DE.mjs +0 -8
  69. package/dist/de-DE.module.js +0 -8
  70. package/dist/de-DE.module.js.map +0 -1
  71. package/dist/el-GR.main.js +0 -6
  72. package/dist/el-GR.main.js.map +0 -1
  73. package/dist/el-GR.mjs +0 -8
  74. package/dist/el-GR.module.js +0 -8
  75. package/dist/el-GR.module.js.map +0 -1
  76. package/dist/en-US.main.js +0 -6
  77. package/dist/en-US.main.js.map +0 -1
  78. package/dist/en-US.mjs +0 -8
  79. package/dist/en-US.module.js +0 -8
  80. package/dist/en-US.module.js.map +0 -1
  81. package/dist/es-ES.main.js +0 -6
  82. package/dist/es-ES.main.js.map +0 -1
  83. package/dist/es-ES.mjs +0 -8
  84. package/dist/es-ES.module.js +0 -8
  85. package/dist/es-ES.module.js.map +0 -1
  86. package/dist/et-EE.main.js +0 -6
  87. package/dist/et-EE.main.js.map +0 -1
  88. package/dist/et-EE.mjs +0 -8
  89. package/dist/et-EE.module.js +0 -8
  90. package/dist/et-EE.module.js.map +0 -1
  91. package/dist/fi-FI.main.js +0 -6
  92. package/dist/fi-FI.main.js.map +0 -1
  93. package/dist/fi-FI.mjs +0 -8
  94. package/dist/fi-FI.module.js +0 -8
  95. package/dist/fi-FI.module.js.map +0 -1
  96. package/dist/fr-FR.main.js +0 -6
  97. package/dist/fr-FR.main.js.map +0 -1
  98. package/dist/fr-FR.mjs +0 -8
  99. package/dist/fr-FR.module.js +0 -8
  100. package/dist/fr-FR.module.js.map +0 -1
  101. package/dist/he-IL.main.js +0 -6
  102. package/dist/he-IL.main.js.map +0 -1
  103. package/dist/he-IL.mjs +0 -8
  104. package/dist/he-IL.module.js +0 -8
  105. package/dist/he-IL.module.js.map +0 -1
  106. package/dist/hr-HR.main.js +0 -6
  107. package/dist/hr-HR.main.js.map +0 -1
  108. package/dist/hr-HR.mjs +0 -8
  109. package/dist/hr-HR.module.js +0 -8
  110. package/dist/hr-HR.module.js.map +0 -1
  111. package/dist/hu-HU.main.js +0 -6
  112. package/dist/hu-HU.main.js.map +0 -1
  113. package/dist/hu-HU.mjs +0 -8
  114. package/dist/hu-HU.module.js +0 -8
  115. package/dist/hu-HU.module.js.map +0 -1
  116. package/dist/intlStrings.main.js +0 -108
  117. package/dist/intlStrings.main.js.map +0 -1
  118. package/dist/intlStrings.mjs +0 -110
  119. package/dist/intlStrings.module.js +0 -110
  120. package/dist/intlStrings.module.js.map +0 -1
  121. package/dist/it-IT.main.js +0 -6
  122. package/dist/it-IT.main.js.map +0 -1
  123. package/dist/it-IT.mjs +0 -8
  124. package/dist/it-IT.module.js +0 -8
  125. package/dist/it-IT.module.js.map +0 -1
  126. package/dist/ja-JP.main.js +0 -6
  127. package/dist/ja-JP.main.js.map +0 -1
  128. package/dist/ja-JP.mjs +0 -8
  129. package/dist/ja-JP.module.js +0 -8
  130. package/dist/ja-JP.module.js.map +0 -1
  131. package/dist/ko-KR.main.js +0 -6
  132. package/dist/ko-KR.main.js.map +0 -1
  133. package/dist/ko-KR.mjs +0 -8
  134. package/dist/ko-KR.module.js +0 -8
  135. package/dist/ko-KR.module.js.map +0 -1
  136. package/dist/lt-LT.main.js +0 -6
  137. package/dist/lt-LT.main.js.map +0 -1
  138. package/dist/lt-LT.mjs +0 -8
  139. package/dist/lt-LT.module.js +0 -8
  140. package/dist/lt-LT.module.js.map +0 -1
  141. package/dist/lv-LV.main.js +0 -6
  142. package/dist/lv-LV.main.js.map +0 -1
  143. package/dist/lv-LV.mjs +0 -8
  144. package/dist/lv-LV.module.js +0 -8
  145. package/dist/lv-LV.module.js.map +0 -1
  146. package/dist/nb-NO.main.js +0 -6
  147. package/dist/nb-NO.main.js.map +0 -1
  148. package/dist/nb-NO.mjs +0 -8
  149. package/dist/nb-NO.module.js +0 -8
  150. package/dist/nb-NO.module.js.map +0 -1
  151. package/dist/nl-NL.main.js +0 -6
  152. package/dist/nl-NL.main.js.map +0 -1
  153. package/dist/nl-NL.mjs +0 -8
  154. package/dist/nl-NL.module.js +0 -8
  155. package/dist/nl-NL.module.js.map +0 -1
  156. package/dist/pl-PL.main.js +0 -6
  157. package/dist/pl-PL.main.js.map +0 -1
  158. package/dist/pl-PL.mjs +0 -8
  159. package/dist/pl-PL.module.js +0 -8
  160. package/dist/pl-PL.module.js.map +0 -1
  161. package/dist/pt-BR.main.js +0 -6
  162. package/dist/pt-BR.main.js.map +0 -1
  163. package/dist/pt-BR.mjs +0 -8
  164. package/dist/pt-BR.module.js +0 -8
  165. package/dist/pt-BR.module.js.map +0 -1
  166. package/dist/pt-PT.main.js +0 -6
  167. package/dist/pt-PT.main.js.map +0 -1
  168. package/dist/pt-PT.mjs +0 -8
  169. package/dist/pt-PT.module.js +0 -8
  170. package/dist/pt-PT.module.js.map +0 -1
  171. package/dist/ro-RO.main.js +0 -6
  172. package/dist/ro-RO.main.js.map +0 -1
  173. package/dist/ro-RO.mjs +0 -8
  174. package/dist/ro-RO.module.js +0 -8
  175. package/dist/ro-RO.module.js.map +0 -1
  176. package/dist/ru-RU.main.js +0 -6
  177. package/dist/ru-RU.main.js.map +0 -1
  178. package/dist/ru-RU.mjs +0 -8
  179. package/dist/ru-RU.module.js +0 -8
  180. package/dist/ru-RU.module.js.map +0 -1
  181. package/dist/sk-SK.main.js +0 -6
  182. package/dist/sk-SK.main.js.map +0 -1
  183. package/dist/sk-SK.mjs +0 -8
  184. package/dist/sk-SK.module.js +0 -8
  185. package/dist/sk-SK.module.js.map +0 -1
  186. package/dist/sl-SI.main.js +0 -6
  187. package/dist/sl-SI.main.js.map +0 -1
  188. package/dist/sl-SI.mjs +0 -8
  189. package/dist/sl-SI.module.js +0 -8
  190. package/dist/sl-SI.module.js.map +0 -1
  191. package/dist/sr-SP.main.js +0 -6
  192. package/dist/sr-SP.main.js.map +0 -1
  193. package/dist/sr-SP.mjs +0 -8
  194. package/dist/sr-SP.module.js +0 -8
  195. package/dist/sr-SP.module.js.map +0 -1
  196. package/dist/sv-SE.main.js +0 -6
  197. package/dist/sv-SE.main.js.map +0 -1
  198. package/dist/sv-SE.mjs +0 -8
  199. package/dist/sv-SE.module.js +0 -8
  200. package/dist/sv-SE.module.js.map +0 -1
  201. package/dist/tr-TR.main.js +0 -6
  202. package/dist/tr-TR.main.js.map +0 -1
  203. package/dist/tr-TR.mjs +0 -8
  204. package/dist/tr-TR.module.js +0 -8
  205. package/dist/tr-TR.module.js.map +0 -1
  206. package/dist/types.d.ts +0 -44
  207. package/dist/types.d.ts.map +0 -1
  208. package/dist/uk-UA.main.js +0 -6
  209. package/dist/uk-UA.main.js.map +0 -1
  210. package/dist/uk-UA.mjs +0 -8
  211. package/dist/uk-UA.module.js +0 -8
  212. package/dist/uk-UA.module.js.map +0 -1
  213. package/dist/zh-CN.main.js +0 -6
  214. package/dist/zh-CN.main.js.map +0 -1
  215. package/dist/zh-CN.mjs +0 -8
  216. package/dist/zh-CN.module.js +0 -8
  217. package/dist/zh-CN.module.js.map +0 -1
  218. package/dist/zh-TW.main.js +0 -6
  219. package/dist/zh-TW.main.js.map +0 -1
  220. package/dist/zh-TW.mjs +0 -8
  221. package/dist/zh-TW.module.js +0 -8
  222. package/dist/zh-TW.module.js.map +0 -1
  223. package/src/ActionButton.tsx +0 -104
  224. package/src/Button.tsx +0 -207
  225. package/src/ClearButton.tsx +0 -81
  226. package/src/FieldButton.tsx +0 -81
  227. package/src/LogicButton.tsx +0 -64
  228. package/src/ToggleButton.tsx +0 -90
@@ -1,181 +0,0 @@
1
- var $b2da92ebd9a2bc00$exports = require("./intlStrings.main.js");
2
- require("./button.c18453ac.css");
3
- var $afc5a4514aca2340$exports = require("./button_vars_css.main.js");
4
- var $hN0b7$reactspectrumutils = require("@react-spectrum/utils");
5
- var $hN0b7$reactariafocus = require("@react-aria/focus");
6
- var $hN0b7$reactariautils = require("@react-aria/utils");
7
- var $hN0b7$reactspectrumprogress = require("@react-spectrum/progress");
8
- var $hN0b7$react = require("react");
9
- var $hN0b7$reactspectrumtext = require("@react-spectrum/text");
10
- var $hN0b7$reactariabutton = require("@react-aria/button");
11
- var $hN0b7$reactariainteractions = require("@react-aria/interactions");
12
- var $hN0b7$reactariai18n = require("@react-aria/i18n");
13
- var $hN0b7$reactspectrumprovider = require("@react-spectrum/provider");
14
-
15
-
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
18
- }
19
-
20
- function $parcel$export(e, n, v, s) {
21
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
- }
23
-
24
- $parcel$export(module.exports, "Button", () => $842a195ed1671b15$export$353f5b6fc5456de1);
25
- /*
26
- * Copyright 2020 Adobe. All rights reserved.
27
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
- * you may not use this file except in compliance with the License. You may obtain a copy
29
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
- *
31
- * Unless required by applicable law or agreed to in writing, software distributed under
32
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
- * OF ANY KIND, either express or implied. See the License for the specific language
34
- * governing permissions and limitations under the License.
35
- */
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
- function $842a195ed1671b15$var$disablePendingProps(props) {
48
- // Don't allow interaction while isPending is true
49
- if (props.isPending) {
50
- props.onPress = undefined;
51
- props.onPressStart = undefined;
52
- props.onPressEnd = undefined;
53
- props.onPressChange = undefined;
54
- props.onPressUp = undefined;
55
- props.onKeyDown = undefined;
56
- props.onKeyUp = undefined;
57
- props.onClick = undefined;
58
- props.href = undefined;
59
- }
60
- return props;
61
- }
62
- const $842a195ed1671b15$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).forwardRef(function Button(props, ref) {
63
- var _buttonProps_arialabelledby;
64
- props = (0, $hN0b7$reactspectrumprovider.useProviderProps)(props);
65
- props = (0, $hN0b7$reactspectrumutils.useSlotProps)(props, 'button');
66
- props = $842a195ed1671b15$var$disablePendingProps(props);
67
- let { elementType: Element = 'button', children: children, variant: variant, style: style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline', staticColor: staticColor, isDisabled: isDisabled, isPending: isPending, autoFocus: autoFocus, ...otherProps } = props;
68
- let domRef = (0, $hN0b7$reactspectrumutils.useFocusableRef)(ref);
69
- let { buttonProps: buttonProps, isPressed: isPressed } = (0, $hN0b7$reactariabutton.useButton)(props, domRef);
70
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $hN0b7$reactariainteractions.useHover)({
71
- isDisabled: isDisabled
72
- });
73
- let [isFocused, onFocusChange] = (0, $hN0b7$react.useState)(false);
74
- let { focusProps: focusProps } = (0, $hN0b7$reactariainteractions.useFocus)({
75
- onFocusChange: onFocusChange,
76
- isDisabled: isDisabled
77
- });
78
- let stringFormatter = (0, $hN0b7$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($b2da92ebd9a2bc00$exports))), '@react-spectrum/button');
79
- let { styleProps: styleProps } = (0, $hN0b7$reactspectrumutils.useStyleProps)(otherProps);
80
- let hasLabel = (0, $hN0b7$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($afc5a4514aca2340$exports)))['spectrum-Button-label']}`, domRef);
81
- let hasIcon = (0, $hN0b7$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($afc5a4514aca2340$exports)))['spectrum-Icon']}`, domRef);
82
- // an aria label will block children and their labels from being read, this is undesirable for pending state
83
- let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];
84
- let [isProgressVisible, setIsProgressVisible] = (0, $hN0b7$react.useState)(false);
85
- let backupButtonId = (0, $hN0b7$reactariautils.useId)();
86
- let buttonId = buttonProps.id || backupButtonId;
87
- let iconId = (0, $hN0b7$reactariautils.useId)();
88
- let textId = (0, $hN0b7$reactariautils.useId)();
89
- let spinnerId = (0, $hN0b7$reactariautils.useId)();
90
- (0, $hN0b7$react.useEffect)(()=>{
91
- let timeout;
92
- if (isPending) // Start timer when isPending is set to true.
93
- timeout = setTimeout(()=>{
94
- setIsProgressVisible(true);
95
- }, 1000);
96
- else // Exit loading state when isPending is set to false. */
97
- setIsProgressVisible(false);
98
- return ()=>{
99
- // Clean up on unmount or when user removes isPending prop before entering loading state.
100
- clearTimeout(timeout);
101
- };
102
- }, [
103
- isPending
104
- ]);
105
- if (variant === 'cta') variant = 'accent';
106
- else if (variant === 'overBackground') {
107
- variant = 'primary';
108
- staticColor = 'white';
109
- }
110
- const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();
111
- var _buttonProps_arialabelledby_replace;
112
- const isPendingAriaLiveLabelledby = hasAriaLabel ? (_buttonProps_arialabelledby_replace = (_buttonProps_arialabelledby = buttonProps['aria-labelledby']) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, spinnerId)) !== null && _buttonProps_arialabelledby_replace !== void 0 ? _buttonProps_arialabelledby_replace : spinnerId : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();
113
- let ariaLive = 'polite';
114
- if ((0, $hN0b7$reactariautils.isAppleDevice)() && (!hasAriaLabel || (0, $hN0b7$reactariautils.isFirefox)())) ariaLive = 'off';
115
- let isPendingProps = isPending ? {
116
- onClick: (e)=>{
117
- if (e.currentTarget instanceof HTMLButtonElement) e.preventDefault();
118
- }
119
- } : {
120
- // no-op.
121
- // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.
122
- onClick: ()=>{}
123
- };
124
- return /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactariafocus.FocusRing), {
125
- focusRingClass: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), 'focus-ring'),
126
- autoFocus: autoFocus
127
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement(Element, {
128
- ...styleProps,
129
- ...(0, $hN0b7$reactariautils.mergeProps)(buttonProps, hoverProps, focusProps, isPendingProps),
130
- id: buttonId,
131
- ref: domRef,
132
- "data-variant": variant,
133
- "data-style": style,
134
- "data-static-color": staticColor || undefined,
135
- "aria-disabled": isPending ? 'true' : undefined,
136
- "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps['aria-label'],
137
- "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby'],
138
- className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), 'spectrum-Button', {
139
- 'spectrum-Button--iconOnly': hasIcon && !hasLabel,
140
- 'is-disabled': isDisabled || isProgressVisible,
141
- 'is-active': isPressed,
142
- 'is-hovered': isHovered,
143
- 'spectrum-Button--pending': isProgressVisible
144
- }, styleProps.className)
145
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumutils.SlotProvider), {
146
- slots: {
147
- icon: {
148
- id: iconId,
149
- size: 'S',
150
- UNSAFE_className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), 'spectrum-Icon')
151
- },
152
- text: {
153
- id: textId,
154
- UNSAFE_className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), 'spectrum-Button-label')
155
- }
156
- }
157
- }, typeof children === 'string' ? /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumtext.Text), null, children) : children, isPending && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
158
- "aria-hidden": "true",
159
- style: {
160
- visibility: isProgressVisible ? 'visible' : 'hidden'
161
- },
162
- className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), 'spectrum-Button-circleLoader')
163
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumprogress.ProgressCircle), {
164
- "aria-label": isPendingAriaLiveLabel,
165
- isIndeterminate: true,
166
- size: "S",
167
- staticColor: staticColor
168
- })), isPending && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, ($parcel$interopDefault($hN0b7$react))).Fragment, null, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
169
- "aria-live": isFocused ? ariaLive : 'off'
170
- }, isProgressVisible && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
171
- role: "img",
172
- "aria-labelledby": isPendingAriaLiveLabelledby
173
- })), /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
174
- id: spinnerId,
175
- role: "img",
176
- "aria-label": isPendingAriaLiveLabel
177
- })))));
178
- });
179
-
180
-
181
- //# sour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ACC,eAAY;QACZ,OAAO;YAAC,YAAY,oBAAoB,YAAY;QAAQ;QAC5D,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBAC9B,0DAAC,CAAA,GAAA,2CAAa;QACZ,cAAY;QACZ,iBAAA;QACA,MAAK;QACL,aAAa;SAGlB,2BACC,oIACE,0DAAC;QAAI,aAAW,YAAY,WAAW;OACpC,mCACC,0DAAC;QAAI,MAAK;QAAM,mBAAiB;uBAOrC,0DAAC;QAAI,IAAI;QAAW,MAAK;QAAM,cAAY;;AAOzD","sources":["packages/@react-spectrum/button/src/Button.tsx"],"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 {\n classNames,\n SlotProvider,\n useFocusableRef,\n useHasChild,\n useSlotProps,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAppleDevice, isFirefox, mergeProps, useId} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ElementType, ReactElement, useEffect, useState} from 'react';\nimport {SpectrumButtonProps} from '@react-types/button';\nimport styles from '@adobe/spectrum-css-temp/components/button/vars.css';\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useFocus, useHover} from '@react-aria/interactions';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nfunction disablePendingProps(props) {\n // Don't allow interaction while isPending is true\n if (props.isPending) {\n props.onPress = undefined;\n props.onPressStart = undefined;\n props.onPressEnd = undefined;\n props.onPressChange = undefined;\n props.onPressUp = undefined;\n props.onKeyDown = undefined;\n props.onKeyUp = undefined;\n props.onClick = undefined;\n props.href = undefined;\n }\n return props;\n}\n\n/**\n * Buttons allow users to perform an action or to navigate to another page.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nexport const Button = React.forwardRef(function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n props = useSlotProps(props, 'button');\n props = disablePendingProps(props);\n let {\n elementType: Element = 'button',\n children,\n variant,\n style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',\n staticColor,\n isDisabled,\n isPending,\n autoFocus,\n ...otherProps\n } = props;\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton(props, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let [isFocused, onFocusChange] = useState(false);\n let {focusProps} = useFocus({onFocusChange, isDisabled});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/button');\n let {styleProps} = useStyleProps(otherProps);\n let hasLabel = useHasChild(`.${styles['spectrum-Button-label']}`, domRef);\n let hasIcon = useHasChild(`.${styles['spectrum-Icon']}`, domRef);\n // an aria label will block children and their labels from being read, this is undesirable for pending state\n let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n let backupButtonId = useId();\n let buttonId = buttonProps.id || backupButtonId;\n let iconId = useId();\n let textId = useId();\n let spinnerId = useId();\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n if (variant === 'cta') {\n variant = 'accent';\n } else if (variant === 'overBackground') {\n variant = 'primary';\n staticColor = 'white';\n }\n\n const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();\n const isPendingAriaLiveLabelledby = hasAriaLabel ? (buttonProps['aria-labelledby']?.replace(buttonId, spinnerId) ?? spinnerId) : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();\n\n let ariaLive: 'off' | 'polite' | 'assertive' = 'polite';\n if (isAppleDevice() && (!hasAriaLabel || isFirefox())) {\n ariaLive = 'off';\n }\n\n let isPendingProps = isPending ? {\n onClick: (e) => {\n if (e.currentTarget instanceof HTMLButtonElement) {\n e.preventDefault();\n }\n }\n } : {\n // no-op. \n // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.\n onClick: () => {}\n };\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <Element\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps, focusProps, isPendingProps)}\n id={buttonId}\n ref={domRef}\n data-variant={variant}\n data-style={style}\n data-static-color={staticColor || undefined}\n aria-disabled={isPending ? 'true' : undefined}\n aria-label={isPending ? isPendingAriaLiveLabel : buttonProps['aria-label']}\n aria-labelledby={isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby']}\n className={\n classNames(\n styles,\n 'spectrum-Button',\n {\n 'spectrum-Button--iconOnly': hasIcon && !hasLabel,\n 'is-disabled': isDisabled || isProgressVisible,\n 'is-active': isPressed,\n 'is-hovered': isHovered,\n 'spectrum-Button--pending': isProgressVisible\n },\n styleProps.className\n )\n }>\n <SlotProvider\n slots={{\n icon: {\n id: iconId,\n size: 'S',\n UNSAFE_className: classNames(styles, 'spectrum-Icon')\n },\n text: {\n id: textId,\n UNSAFE_className: classNames(styles, 'spectrum-Button-label')\n }\n }}>\n {typeof children === 'string'\n ? <Text>{children}</Text>\n : children}\n {isPending && (\n <div\n aria-hidden=\"true\"\n style={{visibility: isProgressVisible ? 'visible' : 'hidden'}}\n className={classNames(styles, 'spectrum-Button-circleLoader')}>\n <ProgressCircle\n aria-label={isPendingAriaLiveLabel}\n isIndeterminate\n size=\"S\"\n staticColor={staticColor} />\n </div>\n )}\n {isPending &&\n <>\n <div aria-live={isFocused ? ariaLive : 'off'}>\n {isProgressVisible &&\n <div role=\"img\" aria-labelledby={isPendingAriaLiveLabelledby} />\n }\n </div>\n {/* Adding the element here with the same labels as the button itself causes aria-live to pick up the change in Safari.\n Safari with VO unfortunately doesn't announce changes to *all* of its labels specifically for button\n https://a11ysupport.io/tests/tech__html__button-name-change#assertion-aria-aria-label_attribute-convey_name_change-html-button_element-vo_macos-safari\n The aria-live may cause extra announcements in other browsers. */}\n <div id={spinnerId} role=\"img\" aria-label={isPendingAriaLiveLabel} />\n </>\n }\n </SlotProvider>\n </Element>\n </FocusRing>\n );\n}) as <T extends ElementType = 'button'>(props: SpectrumButtonProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;\n"],"names":[],"version":3,"file":"Button.main.js.map"}
package/dist/Button.mjs DELETED
@@ -1,176 +0,0 @@
1
- import $l1zrX$intlStringsmodulejs from "./intlStrings.mjs";
2
- import "./button.c18453ac.css";
3
- import $l1zrX$button_vars_cssmodulejs from "./button_vars_css.mjs";
4
- import {useSlotProps as $l1zrX$useSlotProps, useFocusableRef as $l1zrX$useFocusableRef, useStyleProps as $l1zrX$useStyleProps, useHasChild as $l1zrX$useHasChild, classNames as $l1zrX$classNames, SlotProvider as $l1zrX$SlotProvider} from "@react-spectrum/utils";
5
- import {FocusRing as $l1zrX$FocusRing} from "@react-aria/focus";
6
- import {useId as $l1zrX$useId, isAppleDevice as $l1zrX$isAppleDevice, isFirefox as $l1zrX$isFirefox, mergeProps as $l1zrX$mergeProps} from "@react-aria/utils";
7
- import {ProgressCircle as $l1zrX$ProgressCircle} from "@react-spectrum/progress";
8
- import $l1zrX$react, {useState as $l1zrX$useState, useEffect as $l1zrX$useEffect} from "react";
9
- import {Text as $l1zrX$Text} from "@react-spectrum/text";
10
- import {useButton as $l1zrX$useButton} from "@react-aria/button";
11
- import {useHover as $l1zrX$useHover, useFocus as $l1zrX$useFocus} from "@react-aria/interactions";
12
- import {useLocalizedStringFormatter as $l1zrX$useLocalizedStringFormatter} from "@react-aria/i18n";
13
- import {useProviderProps as $l1zrX$useProviderProps} from "@react-spectrum/provider";
14
-
15
-
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
18
- }
19
- /*
20
- * Copyright 2020 Adobe. All rights reserved.
21
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License. You may obtain a copy
23
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
- *
25
- * Unless required by applicable law or agreed to in writing, software distributed under
26
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
- * OF ANY KIND, either express or implied. See the License for the specific language
28
- * governing permissions and limitations under the License.
29
- */
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- function $b865a6f0049e2d66$var$disablePendingProps(props) {
42
- // Don't allow interaction while isPending is true
43
- if (props.isPending) {
44
- props.onPress = undefined;
45
- props.onPressStart = undefined;
46
- props.onPressEnd = undefined;
47
- props.onPressChange = undefined;
48
- props.onPressUp = undefined;
49
- props.onKeyDown = undefined;
50
- props.onKeyUp = undefined;
51
- props.onClick = undefined;
52
- props.href = undefined;
53
- }
54
- return props;
55
- }
56
- const $b865a6f0049e2d66$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, $l1zrX$react).forwardRef(function Button(props, ref) {
57
- var _buttonProps_arialabelledby;
58
- props = (0, $l1zrX$useProviderProps)(props);
59
- props = (0, $l1zrX$useSlotProps)(props, 'button');
60
- props = $b865a6f0049e2d66$var$disablePendingProps(props);
61
- let { elementType: Element = 'button', children: children, variant: variant, style: style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline', staticColor: staticColor, isDisabled: isDisabled, isPending: isPending, autoFocus: autoFocus, ...otherProps } = props;
62
- let domRef = (0, $l1zrX$useFocusableRef)(ref);
63
- let { buttonProps: buttonProps, isPressed: isPressed } = (0, $l1zrX$useButton)(props, domRef);
64
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $l1zrX$useHover)({
65
- isDisabled: isDisabled
66
- });
67
- let [isFocused, onFocusChange] = (0, $l1zrX$useState)(false);
68
- let { focusProps: focusProps } = (0, $l1zrX$useFocus)({
69
- onFocusChange: onFocusChange,
70
- isDisabled: isDisabled
71
- });
72
- let stringFormatter = (0, $l1zrX$useLocalizedStringFormatter)((0, ($parcel$interopDefault($l1zrX$intlStringsmodulejs))), '@react-spectrum/button');
73
- let { styleProps: styleProps } = (0, $l1zrX$useStyleProps)(otherProps);
74
- let hasLabel = (0, $l1zrX$useHasChild)(`.${(0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs)))['spectrum-Button-label']}`, domRef);
75
- let hasIcon = (0, $l1zrX$useHasChild)(`.${(0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs)))['spectrum-Icon']}`, domRef);
76
- // an aria label will block children and their labels from being read, this is undesirable for pending state
77
- let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];
78
- let [isProgressVisible, setIsProgressVisible] = (0, $l1zrX$useState)(false);
79
- let backupButtonId = (0, $l1zrX$useId)();
80
- let buttonId = buttonProps.id || backupButtonId;
81
- let iconId = (0, $l1zrX$useId)();
82
- let textId = (0, $l1zrX$useId)();
83
- let spinnerId = (0, $l1zrX$useId)();
84
- (0, $l1zrX$useEffect)(()=>{
85
- let timeout;
86
- if (isPending) // Start timer when isPending is set to true.
87
- timeout = setTimeout(()=>{
88
- setIsProgressVisible(true);
89
- }, 1000);
90
- else // Exit loading state when isPending is set to false. */
91
- setIsProgressVisible(false);
92
- return ()=>{
93
- // Clean up on unmount or when user removes isPending prop before entering loading state.
94
- clearTimeout(timeout);
95
- };
96
- }, [
97
- isPending
98
- ]);
99
- if (variant === 'cta') variant = 'accent';
100
- else if (variant === 'overBackground') {
101
- variant = 'primary';
102
- staticColor = 'white';
103
- }
104
- const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();
105
- var _buttonProps_arialabelledby_replace;
106
- const isPendingAriaLiveLabelledby = hasAriaLabel ? (_buttonProps_arialabelledby_replace = (_buttonProps_arialabelledby = buttonProps['aria-labelledby']) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, spinnerId)) !== null && _buttonProps_arialabelledby_replace !== void 0 ? _buttonProps_arialabelledby_replace : spinnerId : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();
107
- let ariaLive = 'polite';
108
- if ((0, $l1zrX$isAppleDevice)() && (!hasAriaLabel || (0, $l1zrX$isFirefox)())) ariaLive = 'off';
109
- let isPendingProps = isPending ? {
110
- onClick: (e)=>{
111
- if (e.currentTarget instanceof HTMLButtonElement) e.preventDefault();
112
- }
113
- } : {
114
- // no-op.
115
- // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.
116
- onClick: ()=>{}
117
- };
118
- return /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$FocusRing), {
119
- focusRingClass: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'focus-ring'),
120
- autoFocus: autoFocus
121
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement(Element, {
122
- ...styleProps,
123
- ...(0, $l1zrX$mergeProps)(buttonProps, hoverProps, focusProps, isPendingProps),
124
- id: buttonId,
125
- ref: domRef,
126
- "data-variant": variant,
127
- "data-style": style,
128
- "data-static-color": staticColor || undefined,
129
- "aria-disabled": isPending ? 'true' : undefined,
130
- "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps['aria-label'],
131
- "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby'],
132
- className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button', {
133
- 'spectrum-Button--iconOnly': hasIcon && !hasLabel,
134
- 'is-disabled': isDisabled || isProgressVisible,
135
- 'is-active': isPressed,
136
- 'is-hovered': isHovered,
137
- 'spectrum-Button--pending': isProgressVisible
138
- }, styleProps.className)
139
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$SlotProvider), {
140
- slots: {
141
- icon: {
142
- id: iconId,
143
- size: 'S',
144
- UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Icon')
145
- },
146
- text: {
147
- id: textId,
148
- UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button-label')
149
- }
150
- }
151
- }, typeof children === 'string' ? /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
152
- "aria-hidden": "true",
153
- style: {
154
- visibility: isProgressVisible ? 'visible' : 'hidden'
155
- },
156
- className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button-circleLoader')
157
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$ProgressCircle), {
158
- "aria-label": isPendingAriaLiveLabel,
159
- isIndeterminate: true,
160
- size: "S",
161
- staticColor: staticColor
162
- })), isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$react).Fragment, null, /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
163
- "aria-live": isFocused ? ariaLive : 'off'
164
- }, isProgressVisible && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
165
- role: "img",
166
- "aria-labelledby": isPendingAriaLiveLabelledby
167
- })), /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
168
- id: spinnerId,
169
- role: "img",
170
- "aria-label": isPendingAriaLiveLabel
171
- })))));
172
- });
173
-
174
-
175
- export {$b865a6f0049e2d66$export$353f5b6fc5456de1 as Button};
176
- //# sourceMappingURL=Button.module.js.map
@@ -1,176 +0,0 @@
1
- import $l1zrX$intlStringsmodulejs from "./intlStrings.module.js";
2
- import "./button.c18453ac.css";
3
- import $l1zrX$button_vars_cssmodulejs from "./button_vars_css.module.js";
4
- import {useSlotProps as $l1zrX$useSlotProps, useFocusableRef as $l1zrX$useFocusableRef, useStyleProps as $l1zrX$useStyleProps, useHasChild as $l1zrX$useHasChild, classNames as $l1zrX$classNames, SlotProvider as $l1zrX$SlotProvider} from "@react-spectrum/utils";
5
- import {FocusRing as $l1zrX$FocusRing} from "@react-aria/focus";
6
- import {useId as $l1zrX$useId, isAppleDevice as $l1zrX$isAppleDevice, isFirefox as $l1zrX$isFirefox, mergeProps as $l1zrX$mergeProps} from "@react-aria/utils";
7
- import {ProgressCircle as $l1zrX$ProgressCircle} from "@react-spectrum/progress";
8
- import $l1zrX$react, {useState as $l1zrX$useState, useEffect as $l1zrX$useEffect} from "react";
9
- import {Text as $l1zrX$Text} from "@react-spectrum/text";
10
- import {useButton as $l1zrX$useButton} from "@react-aria/button";
11
- import {useHover as $l1zrX$useHover, useFocus as $l1zrX$useFocus} from "@react-aria/interactions";
12
- import {useLocalizedStringFormatter as $l1zrX$useLocalizedStringFormatter} from "@react-aria/i18n";
13
- import {useProviderProps as $l1zrX$useProviderProps} from "@react-spectrum/provider";
14
-
15
-
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
18
- }
19
- /*
20
- * Copyright 2020 Adobe. All rights reserved.
21
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License. You may obtain a copy
23
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
- *
25
- * Unless required by applicable law or agreed to in writing, software distributed under
26
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
- * OF ANY KIND, either express or implied. See the License for the specific language
28
- * governing permissions and limitations under the License.
29
- */
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- function $b865a6f0049e2d66$var$disablePendingProps(props) {
42
- // Don't allow interaction while isPending is true
43
- if (props.isPending) {
44
- props.onPress = undefined;
45
- props.onPressStart = undefined;
46
- props.onPressEnd = undefined;
47
- props.onPressChange = undefined;
48
- props.onPressUp = undefined;
49
- props.onKeyDown = undefined;
50
- props.onKeyUp = undefined;
51
- props.onClick = undefined;
52
- props.href = undefined;
53
- }
54
- return props;
55
- }
56
- const $b865a6f0049e2d66$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, $l1zrX$react).forwardRef(function Button(props, ref) {
57
- var _buttonProps_arialabelledby;
58
- props = (0, $l1zrX$useProviderProps)(props);
59
- props = (0, $l1zrX$useSlotProps)(props, 'button');
60
- props = $b865a6f0049e2d66$var$disablePendingProps(props);
61
- let { elementType: Element = 'button', children: children, variant: variant, style: style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline', staticColor: staticColor, isDisabled: isDisabled, isPending: isPending, autoFocus: autoFocus, ...otherProps } = props;
62
- let domRef = (0, $l1zrX$useFocusableRef)(ref);
63
- let { buttonProps: buttonProps, isPressed: isPressed } = (0, $l1zrX$useButton)(props, domRef);
64
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $l1zrX$useHover)({
65
- isDisabled: isDisabled
66
- });
67
- let [isFocused, onFocusChange] = (0, $l1zrX$useState)(false);
68
- let { focusProps: focusProps } = (0, $l1zrX$useFocus)({
69
- onFocusChange: onFocusChange,
70
- isDisabled: isDisabled
71
- });
72
- let stringFormatter = (0, $l1zrX$useLocalizedStringFormatter)((0, ($parcel$interopDefault($l1zrX$intlStringsmodulejs))), '@react-spectrum/button');
73
- let { styleProps: styleProps } = (0, $l1zrX$useStyleProps)(otherProps);
74
- let hasLabel = (0, $l1zrX$useHasChild)(`.${(0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs)))['spectrum-Button-label']}`, domRef);
75
- let hasIcon = (0, $l1zrX$useHasChild)(`.${(0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs)))['spectrum-Icon']}`, domRef);
76
- // an aria label will block children and their labels from being read, this is undesirable for pending state
77
- let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];
78
- let [isProgressVisible, setIsProgressVisible] = (0, $l1zrX$useState)(false);
79
- let backupButtonId = (0, $l1zrX$useId)();
80
- let buttonId = buttonProps.id || backupButtonId;
81
- let iconId = (0, $l1zrX$useId)();
82
- let textId = (0, $l1zrX$useId)();
83
- let spinnerId = (0, $l1zrX$useId)();
84
- (0, $l1zrX$useEffect)(()=>{
85
- let timeout;
86
- if (isPending) // Start timer when isPending is set to true.
87
- timeout = setTimeout(()=>{
88
- setIsProgressVisible(true);
89
- }, 1000);
90
- else // Exit loading state when isPending is set to false. */
91
- setIsProgressVisible(false);
92
- return ()=>{
93
- // Clean up on unmount or when user removes isPending prop before entering loading state.
94
- clearTimeout(timeout);
95
- };
96
- }, [
97
- isPending
98
- ]);
99
- if (variant === 'cta') variant = 'accent';
100
- else if (variant === 'overBackground') {
101
- variant = 'primary';
102
- staticColor = 'white';
103
- }
104
- const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();
105
- var _buttonProps_arialabelledby_replace;
106
- const isPendingAriaLiveLabelledby = hasAriaLabel ? (_buttonProps_arialabelledby_replace = (_buttonProps_arialabelledby = buttonProps['aria-labelledby']) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, spinnerId)) !== null && _buttonProps_arialabelledby_replace !== void 0 ? _buttonProps_arialabelledby_replace : spinnerId : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();
107
- let ariaLive = 'polite';
108
- if ((0, $l1zrX$isAppleDevice)() && (!hasAriaLabel || (0, $l1zrX$isFirefox)())) ariaLive = 'off';
109
- let isPendingProps = isPending ? {
110
- onClick: (e)=>{
111
- if (e.currentTarget instanceof HTMLButtonElement) e.preventDefault();
112
- }
113
- } : {
114
- // no-op.
115
- // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.
116
- onClick: ()=>{}
117
- };
118
- return /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$FocusRing), {
119
- focusRingClass: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'focus-ring'),
120
- autoFocus: autoFocus
121
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement(Element, {
122
- ...styleProps,
123
- ...(0, $l1zrX$mergeProps)(buttonProps, hoverProps, focusProps, isPendingProps),
124
- id: buttonId,
125
- ref: domRef,
126
- "data-variant": variant,
127
- "data-style": style,
128
- "data-static-color": staticColor || undefined,
129
- "aria-disabled": isPending ? 'true' : undefined,
130
- "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps['aria-label'],
131
- "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby'],
132
- className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button', {
133
- 'spectrum-Button--iconOnly': hasIcon && !hasLabel,
134
- 'is-disabled': isDisabled || isProgressVisible,
135
- 'is-active': isPressed,
136
- 'is-hovered': isHovered,
137
- 'spectrum-Button--pending': isProgressVisible
138
- }, styleProps.className)
139
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$SlotProvider), {
140
- slots: {
141
- icon: {
142
- id: iconId,
143
- size: 'S',
144
- UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Icon')
145
- },
146
- text: {
147
- id: textId,
148
- UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button-label')
149
- }
150
- }
151
- }, typeof children === 'string' ? /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
152
- "aria-hidden": "true",
153
- style: {
154
- visibility: isProgressVisible ? 'visible' : 'hidden'
155
- },
156
- className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), 'spectrum-Button-circleLoader')
157
- }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$ProgressCircle), {
158
- "aria-label": isPendingAriaLiveLabel,
159
- isIndeterminate: true,
160
- size: "S",
161
- staticColor: staticColor
162
- })), isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$react).Fragment, null, /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
163
- "aria-live": isFocused ? ariaLive : 'off'
164
- }, isProgressVisible && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
165
- role: "img",
166
- "aria-labelledby": isPendingAriaLiveLabelledby
167
- })), /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
168
- id: spinnerId,
169
- role: "img",
170
- "aria-label": isPendingAriaLiveLabel
171
- })))));
172
- });
173
-
174
-
175
- export {$b865a6f0049e2d66$export$353f5b6fc5456de1 as Button};
176
- //# sourceMappingURL=Button.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AAyBD,SAAS,0CAAoB,KAAK;IAChC,kDAAkD;IAClD,IAAI,MAAM,SAAS,EAAE;QACnB,MAAM,OAAO,GAAG;QAChB,MAAM,YAAY,GAAG;QACrB,MAAM,UAAU,GAAG;QACnB,MAAM,aAAa,GAAG;QACtB,MAAM,SAAS,GAAG;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I,IAAI;QAAW,MAAK;QAAM,cAAY;;AAOzD","sources":["packages/@react-spectrum/button/src/Button.tsx"],"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 {\n classNames,\n SlotProvider,\n useFocusableRef,\n useHasChild,\n useSlotProps,\n useStyleProps\n} from '@react-spectrum/utils';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAppleDevice, isFirefox, mergeProps, useId} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ElementType, ReactElement, useEffect, useState} from 'react';\nimport {SpectrumButtonProps} from '@react-types/button';\nimport styles from '@adobe/spectrum-css-temp/components/button/vars.css';\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useFocus, useHover} from '@react-aria/interactions';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nfunction disablePendingProps(props) {\n // Don't allow interaction while isPending is true\n if (props.isPending) {\n props.onPress = undefined;\n props.onPressStart = undefined;\n props.onPressEnd = undefined;\n props.onPressChange = undefined;\n props.onPressUp = undefined;\n props.onKeyDown = undefined;\n props.onKeyUp = undefined;\n props.onClick = undefined;\n props.href = undefined;\n }\n return props;\n}\n\n/**\n * Buttons allow users to perform an action or to navigate to another page.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nexport const Button = React.forwardRef(function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n props = useSlotProps(props, 'button');\n props = disablePendingProps(props);\n let {\n elementType: Element = 'button',\n children,\n variant,\n style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',\n staticColor,\n isDisabled,\n isPending,\n autoFocus,\n ...otherProps\n } = props;\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton(props, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let [isFocused, onFocusChange] = useState(false);\n let {focusProps} = useFocus({onFocusChange, isDisabled});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/button');\n let {styleProps} = useStyleProps(otherProps);\n let hasLabel = useHasChild(`.${styles['spectrum-Button-label']}`, domRef);\n let hasIcon = useHasChild(`.${styles['spectrum-Icon']}`, domRef);\n // an aria label will block children and their labels from being read, this is undesirable for pending state\n let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n let backupButtonId = useId();\n let buttonId = buttonProps.id || backupButtonId;\n let iconId = useId();\n let textId = useId();\n let spinnerId = useId();\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n if (variant === 'cta') {\n variant = 'accent';\n } else if (variant === 'overBackground') {\n variant = 'primary';\n staticColor = 'white';\n }\n\n const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();\n const isPendingAriaLiveLabelledby = hasAriaLabel ? (buttonProps['aria-labelledby']?.replace(buttonId, spinnerId) ?? spinnerId) : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();\n\n let ariaLive: 'off' | 'polite' | 'assertive' = 'polite';\n if (isAppleDevice() && (!hasAriaLabel || isFirefox())) {\n ariaLive = 'off';\n }\n\n let isPendingProps = isPending ? {\n onClick: (e) => {\n if (e.currentTarget instanceof HTMLButtonElement) {\n e.preventDefault();\n }\n }\n } : {\n // no-op. \n // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.\n onClick: () => {}\n };\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <Element\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps, focusProps, isPendingProps)}\n id={buttonId}\n ref={domRef}\n data-variant={variant}\n data-style={style}\n data-static-color={staticColor || undefined}\n aria-disabled={isPending ? 'true' : undefined}\n aria-label={isPending ? isPendingAriaLiveLabel : buttonProps['aria-label']}\n aria-labelledby={isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby']}\n className={\n classNames(\n styles,\n 'spectrum-Button',\n {\n 'spectrum-Button--iconOnly': hasIcon && !hasLabel,\n 'is-disabled': isDisabled || isProgressVisible,\n 'is-active': isPressed,\n 'is-hovered': isHovered,\n 'spectrum-Button--pending': isProgressVisible\n },\n styleProps.className\n )\n }>\n <SlotProvider\n slots={{\n icon: {\n id: iconId,\n size: 'S',\n UNSAFE_className: classNames(styles, 'spectrum-Icon')\n },\n text: {\n id: textId,\n UNSAFE_className: classNames(styles, 'spectrum-Button-label')\n }\n }}>\n {typeof children === 'string'\n ? <Text>{children}</Text>\n : children}\n {isPending && (\n <div\n aria-hidden=\"true\"\n style={{visibility: isProgressVisible ? 'visible' : 'hidden'}}\n className={classNames(styles, 'spectrum-Button-circleLoader')}>\n <ProgressCircle\n aria-label={isPendingAriaLiveLabel}\n isIndeterminate\n size=\"S\"\n staticColor={staticColor} />\n </div>\n )}\n {isPending &&\n <>\n <div aria-live={isFocused ? ariaLive : 'off'}>\n {isProgressVisible &&\n <div role=\"img\" aria-labelledby={isPendingAriaLiveLabelledby} />\n }\n </div>\n {/* Adding the element here with the same labels as the button itself causes aria-live to pick up the change in Safari.\n Safari with VO unfortunately doesn't announce changes to *all* of its labels specifically for button\n https://a11ysupport.io/tests/tech__html__button-name-change#assertion-aria-aria-label_attribute-convey_name_change-html-button_element-vo_macos-safari\n The aria-live may cause extra announcements in other browsers. */}\n <div id={spinnerId} role=\"img\" aria-label={isPendingAriaLiveLabel} />\n </>\n }\n </SlotProvider>\n </Element>\n </FocusRing>\n );\n}) as <T extends ElementType = 'button'>(props: SpectrumButtonProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;\n"],"names":[],"version":3,"file":"Button.module.js.map"}