@react-spectrum/button 3.16.1 → 3.16.3

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 (222) hide show
  1. package/dist/ActionButton.main.js +97 -0
  2. package/dist/ActionButton.main.js.map +1 -0
  3. package/dist/ActionButton.mjs +92 -0
  4. package/dist/ActionButton.module.js +92 -0
  5. package/dist/ActionButton.module.js.map +1 -0
  6. package/dist/Button.main.js +177 -0
  7. package/dist/Button.main.js.map +1 -0
  8. package/dist/Button.mjs +172 -0
  9. package/dist/Button.module.js +172 -0
  10. package/dist/Button.module.js.map +1 -0
  11. package/dist/ClearButton.main.js +75 -0
  12. package/dist/ClearButton.main.js.map +1 -0
  13. package/dist/ClearButton.mjs +70 -0
  14. package/dist/ClearButton.module.js +70 -0
  15. package/dist/ClearButton.module.js.map +1 -0
  16. package/dist/FieldButton.main.js +72 -0
  17. package/dist/FieldButton.main.js.map +1 -0
  18. package/dist/FieldButton.mjs +67 -0
  19. package/dist/FieldButton.module.js +67 -0
  20. package/dist/FieldButton.module.js.map +1 -0
  21. package/dist/LogicButton.main.js +70 -0
  22. package/dist/LogicButton.main.js.map +1 -0
  23. package/dist/LogicButton.mjs +65 -0
  24. package/dist/LogicButton.module.js +65 -0
  25. package/dist/LogicButton.module.js.map +1 -0
  26. package/dist/ToggleButton.main.js +90 -0
  27. package/dist/ToggleButton.main.js.map +1 -0
  28. package/dist/ToggleButton.mjs +85 -0
  29. package/dist/ToggleButton.module.js +85 -0
  30. package/dist/ToggleButton.module.js.map +1 -0
  31. package/dist/ar-AE.main.js +6 -0
  32. package/dist/ar-AE.main.js.map +1 -0
  33. package/dist/ar-AE.mjs +8 -0
  34. package/dist/ar-AE.module.js +8 -0
  35. package/dist/ar-AE.module.js.map +1 -0
  36. package/dist/bg-BG.main.js +6 -0
  37. package/dist/bg-BG.main.js.map +1 -0
  38. package/dist/bg-BG.mjs +8 -0
  39. package/dist/bg-BG.module.js +8 -0
  40. package/dist/bg-BG.module.js.map +1 -0
  41. package/dist/button_vars_css.main.js +122 -0
  42. package/dist/button_vars_css.main.js.map +1 -0
  43. package/dist/button_vars_css.mjs +124 -0
  44. package/dist/button_vars_css.module.js +124 -0
  45. package/dist/button_vars_css.module.js.map +1 -0
  46. package/dist/cs-CZ.main.js +6 -0
  47. package/dist/cs-CZ.main.js.map +1 -0
  48. package/dist/cs-CZ.mjs +8 -0
  49. package/dist/cs-CZ.module.js +8 -0
  50. package/dist/cs-CZ.module.js.map +1 -0
  51. package/dist/da-DK.main.js +6 -0
  52. package/dist/da-DK.main.js.map +1 -0
  53. package/dist/da-DK.mjs +8 -0
  54. package/dist/da-DK.module.js +8 -0
  55. package/dist/da-DK.module.js.map +1 -0
  56. package/dist/de-DE.main.js +6 -0
  57. package/dist/de-DE.main.js.map +1 -0
  58. package/dist/de-DE.mjs +8 -0
  59. package/dist/de-DE.module.js +8 -0
  60. package/dist/de-DE.module.js.map +1 -0
  61. package/dist/el-GR.main.js +6 -0
  62. package/dist/el-GR.main.js.map +1 -0
  63. package/dist/el-GR.mjs +8 -0
  64. package/dist/el-GR.module.js +8 -0
  65. package/dist/el-GR.module.js.map +1 -0
  66. package/dist/en-US.main.js +6 -0
  67. package/dist/en-US.main.js.map +1 -0
  68. package/dist/en-US.mjs +8 -0
  69. package/dist/en-US.module.js +8 -0
  70. package/dist/en-US.module.js.map +1 -0
  71. package/dist/es-ES.main.js +6 -0
  72. package/dist/es-ES.main.js.map +1 -0
  73. package/dist/es-ES.mjs +8 -0
  74. package/dist/es-ES.module.js +8 -0
  75. package/dist/es-ES.module.js.map +1 -0
  76. package/dist/et-EE.main.js +6 -0
  77. package/dist/et-EE.main.js.map +1 -0
  78. package/dist/et-EE.mjs +8 -0
  79. package/dist/et-EE.module.js +8 -0
  80. package/dist/et-EE.module.js.map +1 -0
  81. package/dist/fi-FI.main.js +6 -0
  82. package/dist/fi-FI.main.js.map +1 -0
  83. package/dist/fi-FI.mjs +8 -0
  84. package/dist/fi-FI.module.js +8 -0
  85. package/dist/fi-FI.module.js.map +1 -0
  86. package/dist/fr-FR.main.js +6 -0
  87. package/dist/fr-FR.main.js.map +1 -0
  88. package/dist/fr-FR.mjs +8 -0
  89. package/dist/fr-FR.module.js +8 -0
  90. package/dist/fr-FR.module.js.map +1 -0
  91. package/dist/he-IL.main.js +6 -0
  92. package/dist/he-IL.main.js.map +1 -0
  93. package/dist/he-IL.mjs +8 -0
  94. package/dist/he-IL.module.js +8 -0
  95. package/dist/he-IL.module.js.map +1 -0
  96. package/dist/hr-HR.main.js +6 -0
  97. package/dist/hr-HR.main.js.map +1 -0
  98. package/dist/hr-HR.mjs +8 -0
  99. package/dist/hr-HR.module.js +8 -0
  100. package/dist/hr-HR.module.js.map +1 -0
  101. package/dist/hu-HU.main.js +6 -0
  102. package/dist/hu-HU.main.js.map +1 -0
  103. package/dist/hu-HU.mjs +8 -0
  104. package/dist/hu-HU.module.js +8 -0
  105. package/dist/hu-HU.module.js.map +1 -0
  106. package/dist/import.mjs +6 -814
  107. package/dist/intlStrings.main.js +108 -0
  108. package/dist/intlStrings.main.js.map +1 -0
  109. package/dist/intlStrings.mjs +110 -0
  110. package/dist/intlStrings.module.js +110 -0
  111. package/dist/intlStrings.module.js.map +1 -0
  112. package/dist/it-IT.main.js +6 -0
  113. package/dist/it-IT.main.js.map +1 -0
  114. package/dist/it-IT.mjs +8 -0
  115. package/dist/it-IT.module.js +8 -0
  116. package/dist/it-IT.module.js.map +1 -0
  117. package/dist/ja-JP.main.js +6 -0
  118. package/dist/ja-JP.main.js.map +1 -0
  119. package/dist/ja-JP.mjs +8 -0
  120. package/dist/ja-JP.module.js +8 -0
  121. package/dist/ja-JP.module.js.map +1 -0
  122. package/dist/ko-KR.main.js +6 -0
  123. package/dist/ko-KR.main.js.map +1 -0
  124. package/dist/ko-KR.mjs +8 -0
  125. package/dist/ko-KR.module.js +8 -0
  126. package/dist/ko-KR.module.js.map +1 -0
  127. package/dist/lt-LT.main.js +6 -0
  128. package/dist/lt-LT.main.js.map +1 -0
  129. package/dist/lt-LT.mjs +8 -0
  130. package/dist/lt-LT.module.js +8 -0
  131. package/dist/lt-LT.module.js.map +1 -0
  132. package/dist/lv-LV.main.js +6 -0
  133. package/dist/lv-LV.main.js.map +1 -0
  134. package/dist/lv-LV.mjs +8 -0
  135. package/dist/lv-LV.module.js +8 -0
  136. package/dist/lv-LV.module.js.map +1 -0
  137. package/dist/main.js +12 -816
  138. package/dist/main.js.map +1 -1
  139. package/dist/module.js +6 -814
  140. package/dist/module.js.map +1 -1
  141. package/dist/nb-NO.main.js +6 -0
  142. package/dist/nb-NO.main.js.map +1 -0
  143. package/dist/nb-NO.mjs +8 -0
  144. package/dist/nb-NO.module.js +8 -0
  145. package/dist/nb-NO.module.js.map +1 -0
  146. package/dist/nl-NL.main.js +6 -0
  147. package/dist/nl-NL.main.js.map +1 -0
  148. package/dist/nl-NL.mjs +8 -0
  149. package/dist/nl-NL.module.js +8 -0
  150. package/dist/nl-NL.module.js.map +1 -0
  151. package/dist/pl-PL.main.js +6 -0
  152. package/dist/pl-PL.main.js.map +1 -0
  153. package/dist/pl-PL.mjs +8 -0
  154. package/dist/pl-PL.module.js +8 -0
  155. package/dist/pl-PL.module.js.map +1 -0
  156. package/dist/pt-BR.main.js +6 -0
  157. package/dist/pt-BR.main.js.map +1 -0
  158. package/dist/pt-BR.mjs +8 -0
  159. package/dist/pt-BR.module.js +8 -0
  160. package/dist/pt-BR.module.js.map +1 -0
  161. package/dist/pt-PT.main.js +6 -0
  162. package/dist/pt-PT.main.js.map +1 -0
  163. package/dist/pt-PT.mjs +8 -0
  164. package/dist/pt-PT.module.js +8 -0
  165. package/dist/pt-PT.module.js.map +1 -0
  166. package/dist/ro-RO.main.js +6 -0
  167. package/dist/ro-RO.main.js.map +1 -0
  168. package/dist/ro-RO.mjs +8 -0
  169. package/dist/ro-RO.module.js +8 -0
  170. package/dist/ro-RO.module.js.map +1 -0
  171. package/dist/ru-RU.main.js +6 -0
  172. package/dist/ru-RU.main.js.map +1 -0
  173. package/dist/ru-RU.mjs +8 -0
  174. package/dist/ru-RU.module.js +8 -0
  175. package/dist/ru-RU.module.js.map +1 -0
  176. package/dist/sk-SK.main.js +6 -0
  177. package/dist/sk-SK.main.js.map +1 -0
  178. package/dist/sk-SK.mjs +8 -0
  179. package/dist/sk-SK.module.js +8 -0
  180. package/dist/sk-SK.module.js.map +1 -0
  181. package/dist/sl-SI.main.js +6 -0
  182. package/dist/sl-SI.main.js.map +1 -0
  183. package/dist/sl-SI.mjs +8 -0
  184. package/dist/sl-SI.module.js +8 -0
  185. package/dist/sl-SI.module.js.map +1 -0
  186. package/dist/sr-SP.main.js +6 -0
  187. package/dist/sr-SP.main.js.map +1 -0
  188. package/dist/sr-SP.mjs +8 -0
  189. package/dist/sr-SP.module.js +8 -0
  190. package/dist/sr-SP.module.js.map +1 -0
  191. package/dist/sv-SE.main.js +6 -0
  192. package/dist/sv-SE.main.js.map +1 -0
  193. package/dist/sv-SE.mjs +8 -0
  194. package/dist/sv-SE.module.js +8 -0
  195. package/dist/sv-SE.module.js.map +1 -0
  196. package/dist/tr-TR.main.js +6 -0
  197. package/dist/tr-TR.main.js.map +1 -0
  198. package/dist/tr-TR.mjs +8 -0
  199. package/dist/tr-TR.module.js +8 -0
  200. package/dist/tr-TR.module.js.map +1 -0
  201. package/dist/types.d.ts +6 -6
  202. package/dist/types.d.ts.map +1 -1
  203. package/dist/uk-UA.main.js +6 -0
  204. package/dist/uk-UA.main.js.map +1 -0
  205. package/dist/uk-UA.mjs +8 -0
  206. package/dist/uk-UA.module.js +8 -0
  207. package/dist/uk-UA.module.js.map +1 -0
  208. package/dist/vars.4fe44343.css +1645 -0
  209. package/dist/vars.4fe44343.css.map +1 -0
  210. package/dist/zh-CN.main.js +6 -0
  211. package/dist/zh-CN.main.js.map +1 -0
  212. package/dist/zh-CN.mjs +8 -0
  213. package/dist/zh-CN.module.js +8 -0
  214. package/dist/zh-CN.module.js.map +1 -0
  215. package/dist/zh-TW.main.js +6 -0
  216. package/dist/zh-TW.main.js.map +1 -0
  217. package/dist/zh-TW.mjs +8 -0
  218. package/dist/zh-TW.module.js +8 -0
  219. package/dist/zh-TW.module.js.map +1 -0
  220. package/package.json +15 -15
  221. package/src/ActionButton.tsx +27 -15
  222. package/dist/main.css +0 -1
@@ -0,0 +1,172 @@
1
+ import $l1zrX$intlStringsmodulejs from "./intlStrings.mjs";
2
+ import "./vars.4fe44343.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
+ function $b865a6f0049e2d66$var$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
+ return /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$FocusRing), {
110
+ focusRingClass: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "focus-ring"),
111
+ autoFocus: autoFocus
112
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement(Element, {
113
+ ...styleProps,
114
+ ...(0, $l1zrX$mergeProps)(buttonProps, hoverProps, focusProps),
115
+ id: buttonId,
116
+ ref: domRef,
117
+ "data-variant": variant,
118
+ "data-style": style,
119
+ "data-static-color": staticColor || undefined,
120
+ "aria-disabled": isPending ? "true" : undefined,
121
+ "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps["aria-label"],
122
+ "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps["aria-labelledby"],
123
+ className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button", {
124
+ "spectrum-Button--iconOnly": hasIcon && !hasLabel,
125
+ "is-disabled": isDisabled || isProgressVisible,
126
+ "is-active": isPressed,
127
+ "is-hovered": isHovered,
128
+ "spectrum-Button--pending": isProgressVisible
129
+ }, styleProps.className)
130
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$SlotProvider), {
131
+ slots: {
132
+ icon: {
133
+ id: iconId,
134
+ size: "S",
135
+ UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Icon")
136
+ },
137
+ text: {
138
+ id: textId,
139
+ UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button-label")
140
+ }
141
+ }
142
+ }, typeof children === "string" ? /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
143
+ "aria-hidden": "true",
144
+ style: {
145
+ visibility: isProgressVisible ? "visible" : "hidden"
146
+ },
147
+ className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button-circleLoader")
148
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$ProgressCircle), {
149
+ "aria-label": isPendingAriaLiveLabel,
150
+ isIndeterminate: true,
151
+ size: "S",
152
+ staticColor: staticColor
153
+ })), isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$react).Fragment, null, /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
154
+ "aria-live": isFocused ? ariaLive : "off"
155
+ }, isProgressVisible && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
156
+ role: "img",
157
+ "aria-labelledby": isPendingAriaLiveLabelledby
158
+ })), /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
159
+ id: spinnerId,
160
+ role: "img",
161
+ "aria-label": isPendingAriaLiveLabel
162
+ })))));
163
+ }
164
+ /**
165
+ * Buttons allow users to perform an action or to navigate to another page.
166
+ * They have multiple styles for various needs, and are ideal for calling attention to
167
+ * where a user needs to do something in order to move forward in a flow.
168
+ */ let $b865a6f0049e2d66$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, $l1zrX$react).forwardRef($b865a6f0049e2d66$var$Button);
169
+
170
+
171
+ export {$b865a6f0049e2d66$export$353f5b6fc5456de1 as Button};
172
+ //# sourceMappingURL=Button.mjs.map
@@ -0,0 +1,172 @@
1
+ import $l1zrX$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import "./vars.4fe44343.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
+ function $b865a6f0049e2d66$var$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
+ return /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$FocusRing), {
110
+ focusRingClass: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "focus-ring"),
111
+ autoFocus: autoFocus
112
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement(Element, {
113
+ ...styleProps,
114
+ ...(0, $l1zrX$mergeProps)(buttonProps, hoverProps, focusProps),
115
+ id: buttonId,
116
+ ref: domRef,
117
+ "data-variant": variant,
118
+ "data-style": style,
119
+ "data-static-color": staticColor || undefined,
120
+ "aria-disabled": isPending ? "true" : undefined,
121
+ "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps["aria-label"],
122
+ "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps["aria-labelledby"],
123
+ className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button", {
124
+ "spectrum-Button--iconOnly": hasIcon && !hasLabel,
125
+ "is-disabled": isDisabled || isProgressVisible,
126
+ "is-active": isPressed,
127
+ "is-hovered": isHovered,
128
+ "spectrum-Button--pending": isProgressVisible
129
+ }, styleProps.className)
130
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$SlotProvider), {
131
+ slots: {
132
+ icon: {
133
+ id: iconId,
134
+ size: "S",
135
+ UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Icon")
136
+ },
137
+ text: {
138
+ id: textId,
139
+ UNSAFE_className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button-label")
140
+ }
141
+ }
142
+ }, typeof children === "string" ? /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
143
+ "aria-hidden": "true",
144
+ style: {
145
+ visibility: isProgressVisible ? "visible" : "hidden"
146
+ },
147
+ className: (0, $l1zrX$classNames)((0, ($parcel$interopDefault($l1zrX$button_vars_cssmodulejs))), "spectrum-Button-circleLoader")
148
+ }, /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$ProgressCircle), {
149
+ "aria-label": isPendingAriaLiveLabel,
150
+ isIndeterminate: true,
151
+ size: "S",
152
+ staticColor: staticColor
153
+ })), isPending && /*#__PURE__*/ (0, $l1zrX$react).createElement((0, $l1zrX$react).Fragment, null, /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
154
+ "aria-live": isFocused ? ariaLive : "off"
155
+ }, isProgressVisible && /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
156
+ role: "img",
157
+ "aria-labelledby": isPendingAriaLiveLabelledby
158
+ })), /*#__PURE__*/ (0, $l1zrX$react).createElement("div", {
159
+ id: spinnerId,
160
+ role: "img",
161
+ "aria-label": isPendingAriaLiveLabel
162
+ })))));
163
+ }
164
+ /**
165
+ * Buttons allow users to perform an action or to navigate to another page.
166
+ * They have multiple styles for various needs, and are ideal for calling attention to
167
+ * where a user needs to do something in order to move forward in a flow.
168
+ */ let $b865a6f0049e2d66$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, $l1zrX$react).forwardRef($b865a6f0049e2d66$var$Button);
169
+
170
+
171
+ export {$b865a6f0049e2d66$export$353f5b6fc5456de1 as Button};
172
+ //# sourceMappingURL=Button.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"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","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\nfunction 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 return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <Element\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps, focusProps)}\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}\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 */\nlet _Button = React.forwardRef(Button) as <T extends ElementType = 'button'>(props: SpectrumButtonProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;\nexport {_Button as Button};\n"],"names":[],"version":3,"file":"Button.module.js.map"}
@@ -0,0 +1,75 @@
1
+ require("./vars.4fe44343.css");
2
+ var $afc5a4514aca2340$exports = require("./button_vars_css.main.js");
3
+ var $3cv9y$reactspectrumutils = require("@react-spectrum/utils");
4
+ var $3cv9y$spectrumiconsuiCrossSmall = require("@spectrum-icons/ui/CrossSmall");
5
+ var $3cv9y$reactariafocus = require("@react-aria/focus");
6
+ var $3cv9y$reactariautils = require("@react-aria/utils");
7
+ var $3cv9y$react = require("react");
8
+ var $3cv9y$reactariabutton = require("@react-aria/button");
9
+ var $3cv9y$reactariainteractions = require("@react-aria/interactions");
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+
16
+ function $parcel$export(e, n, v, s) {
17
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
18
+ }
19
+
20
+ $parcel$export(module.exports, "ClearButton", () => $9c84a434f1c9da63$export$13ec83e50bf04290);
21
+ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ function $9c84a434f1c9da63$var$ClearButton(props, ref) {
40
+ let { children: children = /*#__PURE__*/ (0, ($parcel$interopDefault($3cv9y$react))).createElement((0, ($parcel$interopDefault($3cv9y$spectrumiconsuiCrossSmall))), {
41
+ UNSAFE_className: (0, ($parcel$interopDefault($afc5a4514aca2340$exports)))["spectrum-Icon"]
42
+ }), focusClassName: focusClassName, variant: variant, autoFocus: autoFocus, isDisabled: isDisabled, preventFocus: preventFocus, elementType: elementType = preventFocus ? "div" : "button", ...otherProps } = props;
43
+ let domRef = (0, $3cv9y$reactspectrumutils.useFocusableRef)(ref);
44
+ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $3cv9y$reactariabutton.useButton)({
45
+ ...props,
46
+ elementType: elementType
47
+ }, domRef);
48
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $3cv9y$reactariainteractions.useHover)({
49
+ isDisabled: isDisabled
50
+ });
51
+ let { styleProps: styleProps } = (0, $3cv9y$reactspectrumutils.useStyleProps)(otherProps);
52
+ // For cases like the clear button in a search field, remove the tabIndex so
53
+ // iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when
54
+ // moving the cursor over the clear button.
55
+ if (preventFocus) delete buttonProps.tabIndex;
56
+ let ElementType = elementType;
57
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($3cv9y$react))).createElement((0, $3cv9y$reactariafocus.FocusRing), {
58
+ focusRingClass: (0, $3cv9y$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "focus-ring", focusClassName),
59
+ autoFocus: autoFocus
60
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($3cv9y$react))).createElement(ElementType, {
61
+ ...styleProps,
62
+ ...(0, $3cv9y$reactariautils.mergeProps)(buttonProps, hoverProps),
63
+ ref: domRef,
64
+ className: (0, $3cv9y$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-ClearButton", {
65
+ [`spectrum-ClearButton--${variant}`]: variant,
66
+ "is-disabled": isDisabled,
67
+ "is-active": isPressed,
68
+ "is-hovered": isHovered
69
+ }, styleProps.className)
70
+ }, children));
71
+ }
72
+ let $9c84a434f1c9da63$export$13ec83e50bf04290 = /*#__PURE__*/ (0, ($parcel$interopDefault($3cv9y$react))).forwardRef($9c84a434f1c9da63$var$ClearButton);
73
+
74
+
75
+ //# sourceMappingURL=ClearButton.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAoBD,SAAS,kCAAY,KAAuB,EAAE,GAAoC;IAChF,IAAI,YACF,yBAAW,0DAAC,CAAA,GAAA,0DAAS;QAAE,kBAAkB,CAAA,GAAA,mDAAK,CAAC,CAAC,gBAAgB;wBAChE,cAAc,WACd,OAAO,aACP,SAAS,cACT,UAAU,gBACV,YAAY,eACZ,cAAc,eAAe,QAAQ,UACrC,GAAG,YACJ,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,yCAAc,EAAE;IAC7B,IAAI,eAAC,WAAW,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gCAAQ,EAAE;QAAC,GAAG,KAAK;qBAAE;IAAW,GAAG;IAClE,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBAAC;IAAU;IAClD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IAEjC,4EAA4E;IAC5E,4EAA4E;IAC5E,2CAA2C;IAC3C,IAAI,cACF,OAAO,YAAY,QAAQ;IAG7B,IAAI,cAAc;IAClB,qBACE,0DAAC,CAAA,GAAA,+BAAQ;QAAE,gBAAgB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG,cAAc;QAAiB,WAAW;qBACtF,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,CAAA,GAAA,gCAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL,wBACA;YACE,CAAC,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,EAAE;YACtC,eAAe;YACf,aAAa;YACb,cAAc;QAChB,GACA,WAAW,SAAS;OAGvB;AAIT;AAEA,IAAI,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/button/src/ClearButton.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 {AriaButtonElementTypeProps, ButtonProps} from '@react-types/button';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport CrossSmall from '@spectrum-icons/ui/CrossSmall';\nimport {DOMProps, FocusableRef, StyleProps} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {ElementType} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/button/vars.css';\nimport {useButton} from '@react-aria/button';\nimport {useHover} from '@react-aria/interactions';\n\ninterface ClearButtonProps<T extends ElementType = 'button'> extends ButtonProps, AriaButtonElementTypeProps<T>, DOMProps, StyleProps {\n focusClassName?: string,\n variant?: 'overBackground',\n excludeFromTabOrder?: boolean,\n preventFocus?: boolean\n}\n\nfunction ClearButton(props: ClearButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n let {\n children = <CrossSmall UNSAFE_className={styles['spectrum-Icon']} />,\n focusClassName,\n variant,\n autoFocus,\n isDisabled,\n preventFocus,\n elementType = preventFocus ? 'div' : 'button' as ElementType,\n ...otherProps\n } = props;\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton({...props, elementType}, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let {styleProps} = useStyleProps(otherProps);\n\n // For cases like the clear button in a search field, remove the tabIndex so\n // iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when\n // moving the cursor over the clear button.\n if (preventFocus) {\n delete buttonProps.tabIndex;\n }\n\n let ElementType = elementType;\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring', focusClassName)} autoFocus={autoFocus}>\n <ElementType\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps)}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ClearButton',\n {\n [`spectrum-ClearButton--${variant}`]: variant,\n 'is-disabled': isDisabled,\n 'is-active': isPressed,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n {children}\n </ElementType>\n </FocusRing>\n );\n}\n\nlet _ClearButton = React.forwardRef(ClearButton);\nexport {_ClearButton as ClearButton};\n"],"names":[],"version":3,"file":"ClearButton.main.js.map"}
@@ -0,0 +1,70 @@
1
+ import "./vars.4fe44343.css";
2
+ import $d0kJV$button_vars_cssmodulejs from "./button_vars_css.mjs";
3
+ import {useFocusableRef as $d0kJV$useFocusableRef, useStyleProps as $d0kJV$useStyleProps, classNames as $d0kJV$classNames} from "@react-spectrum/utils";
4
+ import $d0kJV$spectrumiconsuiCrossSmall from "@spectrum-icons/ui/CrossSmall";
5
+ import {FocusRing as $d0kJV$FocusRing} from "@react-aria/focus";
6
+ import {mergeProps as $d0kJV$mergeProps} from "@react-aria/utils";
7
+ import $d0kJV$react from "react";
8
+ import {useButton as $d0kJV$useButton} from "@react-aria/button";
9
+ import {useHover as $d0kJV$useHover} from "@react-aria/interactions";
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ function $dd24e555a16de2ae$var$ClearButton(props, ref) {
34
+ let { children: children = /*#__PURE__*/ (0, $d0kJV$react).createElement((0, $d0kJV$spectrumiconsuiCrossSmall), {
35
+ UNSAFE_className: (0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs)))["spectrum-Icon"]
36
+ }), focusClassName: focusClassName, variant: variant, autoFocus: autoFocus, isDisabled: isDisabled, preventFocus: preventFocus, elementType: elementType = preventFocus ? "div" : "button", ...otherProps } = props;
37
+ let domRef = (0, $d0kJV$useFocusableRef)(ref);
38
+ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $d0kJV$useButton)({
39
+ ...props,
40
+ elementType: elementType
41
+ }, domRef);
42
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $d0kJV$useHover)({
43
+ isDisabled: isDisabled
44
+ });
45
+ let { styleProps: styleProps } = (0, $d0kJV$useStyleProps)(otherProps);
46
+ // For cases like the clear button in a search field, remove the tabIndex so
47
+ // iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when
48
+ // moving the cursor over the clear button.
49
+ if (preventFocus) delete buttonProps.tabIndex;
50
+ let ElementType = elementType;
51
+ return /*#__PURE__*/ (0, $d0kJV$react).createElement((0, $d0kJV$FocusRing), {
52
+ focusRingClass: (0, $d0kJV$classNames)((0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs))), "focus-ring", focusClassName),
53
+ autoFocus: autoFocus
54
+ }, /*#__PURE__*/ (0, $d0kJV$react).createElement(ElementType, {
55
+ ...styleProps,
56
+ ...(0, $d0kJV$mergeProps)(buttonProps, hoverProps),
57
+ ref: domRef,
58
+ className: (0, $d0kJV$classNames)((0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs))), "spectrum-ClearButton", {
59
+ [`spectrum-ClearButton--${variant}`]: variant,
60
+ "is-disabled": isDisabled,
61
+ "is-active": isPressed,
62
+ "is-hovered": isHovered
63
+ }, styleProps.className)
64
+ }, children));
65
+ }
66
+ let $dd24e555a16de2ae$export$13ec83e50bf04290 = /*#__PURE__*/ (0, $d0kJV$react).forwardRef($dd24e555a16de2ae$var$ClearButton);
67
+
68
+
69
+ export {$dd24e555a16de2ae$export$13ec83e50bf04290 as ClearButton};
70
+ //# sourceMappingURL=ClearButton.mjs.map
@@ -0,0 +1,70 @@
1
+ import "./vars.4fe44343.css";
2
+ import $d0kJV$button_vars_cssmodulejs from "./button_vars_css.module.js";
3
+ import {useFocusableRef as $d0kJV$useFocusableRef, useStyleProps as $d0kJV$useStyleProps, classNames as $d0kJV$classNames} from "@react-spectrum/utils";
4
+ import $d0kJV$spectrumiconsuiCrossSmall from "@spectrum-icons/ui/CrossSmall";
5
+ import {FocusRing as $d0kJV$FocusRing} from "@react-aria/focus";
6
+ import {mergeProps as $d0kJV$mergeProps} from "@react-aria/utils";
7
+ import $d0kJV$react from "react";
8
+ import {useButton as $d0kJV$useButton} from "@react-aria/button";
9
+ import {useHover as $d0kJV$useHover} from "@react-aria/interactions";
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ function $dd24e555a16de2ae$var$ClearButton(props, ref) {
34
+ let { children: children = /*#__PURE__*/ (0, $d0kJV$react).createElement((0, $d0kJV$spectrumiconsuiCrossSmall), {
35
+ UNSAFE_className: (0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs)))["spectrum-Icon"]
36
+ }), focusClassName: focusClassName, variant: variant, autoFocus: autoFocus, isDisabled: isDisabled, preventFocus: preventFocus, elementType: elementType = preventFocus ? "div" : "button", ...otherProps } = props;
37
+ let domRef = (0, $d0kJV$useFocusableRef)(ref);
38
+ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $d0kJV$useButton)({
39
+ ...props,
40
+ elementType: elementType
41
+ }, domRef);
42
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $d0kJV$useHover)({
43
+ isDisabled: isDisabled
44
+ });
45
+ let { styleProps: styleProps } = (0, $d0kJV$useStyleProps)(otherProps);
46
+ // For cases like the clear button in a search field, remove the tabIndex so
47
+ // iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when
48
+ // moving the cursor over the clear button.
49
+ if (preventFocus) delete buttonProps.tabIndex;
50
+ let ElementType = elementType;
51
+ return /*#__PURE__*/ (0, $d0kJV$react).createElement((0, $d0kJV$FocusRing), {
52
+ focusRingClass: (0, $d0kJV$classNames)((0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs))), "focus-ring", focusClassName),
53
+ autoFocus: autoFocus
54
+ }, /*#__PURE__*/ (0, $d0kJV$react).createElement(ElementType, {
55
+ ...styleProps,
56
+ ...(0, $d0kJV$mergeProps)(buttonProps, hoverProps),
57
+ ref: domRef,
58
+ className: (0, $d0kJV$classNames)((0, ($parcel$interopDefault($d0kJV$button_vars_cssmodulejs))), "spectrum-ClearButton", {
59
+ [`spectrum-ClearButton--${variant}`]: variant,
60
+ "is-disabled": isDisabled,
61
+ "is-active": isPressed,
62
+ "is-hovered": isHovered
63
+ }, styleProps.className)
64
+ }, children));
65
+ }
66
+ let $dd24e555a16de2ae$export$13ec83e50bf04290 = /*#__PURE__*/ (0, $d0kJV$react).forwardRef($dd24e555a16de2ae$var$ClearButton);
67
+
68
+
69
+ export {$dd24e555a16de2ae$export$13ec83e50bf04290 as ClearButton};
70
+ //# sourceMappingURL=ClearButton.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAoBD,SAAS,kCAAY,KAAuB,EAAE,GAAoC;IAChF,IAAI,YACF,yBAAW,gCAAC,CAAA,GAAA,gCAAS;QAAE,kBAAkB,CAAA,GAAA,wDAAK,CAAC,CAAC,gBAAgB;wBAChE,cAAc,WACd,OAAO,aACP,SAAS,cACT,UAAU,gBACV,YAAY,eACZ,cAAc,eAAe,QAAQ,UACrC,GAAG,YACJ,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,sBAAc,EAAE;IAC7B,IAAI,eAAC,WAAW,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;qBAAE;IAAW,GAAG;IAClE,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBAAC;IAAU;IAClD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IAEjC,4EAA4E;IAC5E,4EAA4E;IAC5E,2CAA2C;IAC3C,IAAI,cACF,OAAO,YAAY,QAAQ;IAG7B,IAAI,cAAc;IAClB,qBACE,gCAAC,CAAA,GAAA,gBAAQ;QAAE,gBAAgB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,wDAAK,GAAG,cAAc;QAAiB,WAAW;qBACtF,gCAAC;QACE,GAAG,UAAU;QACb,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,wDAAK,GACL,wBACA;YACE,CAAC,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,EAAE;YACtC,eAAe;YACf,aAAa;YACb,cAAc;QAChB,GACA,WAAW,SAAS;OAGvB;AAIT;AAEA,IAAI,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/button/src/ClearButton.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 {AriaButtonElementTypeProps, ButtonProps} from '@react-types/button';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport CrossSmall from '@spectrum-icons/ui/CrossSmall';\nimport {DOMProps, FocusableRef, StyleProps} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {ElementType} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/button/vars.css';\nimport {useButton} from '@react-aria/button';\nimport {useHover} from '@react-aria/interactions';\n\ninterface ClearButtonProps<T extends ElementType = 'button'> extends ButtonProps, AriaButtonElementTypeProps<T>, DOMProps, StyleProps {\n focusClassName?: string,\n variant?: 'overBackground',\n excludeFromTabOrder?: boolean,\n preventFocus?: boolean\n}\n\nfunction ClearButton(props: ClearButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n let {\n children = <CrossSmall UNSAFE_className={styles['spectrum-Icon']} />,\n focusClassName,\n variant,\n autoFocus,\n isDisabled,\n preventFocus,\n elementType = preventFocus ? 'div' : 'button' as ElementType,\n ...otherProps\n } = props;\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton({...props, elementType}, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let {styleProps} = useStyleProps(otherProps);\n\n // For cases like the clear button in a search field, remove the tabIndex so\n // iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when\n // moving the cursor over the clear button.\n if (preventFocus) {\n delete buttonProps.tabIndex;\n }\n\n let ElementType = elementType;\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring', focusClassName)} autoFocus={autoFocus}>\n <ElementType\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps)}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ClearButton',\n {\n [`spectrum-ClearButton--${variant}`]: variant,\n 'is-disabled': isDisabled,\n 'is-active': isPressed,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n {children}\n </ElementType>\n </FocusRing>\n );\n}\n\nlet _ClearButton = React.forwardRef(ClearButton);\nexport {_ClearButton as ClearButton};\n"],"names":[],"version":3,"file":"ClearButton.module.js.map"}