@react-spectrum/button 3.13.0 → 3.14.1
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.
- package/dist/import.mjs +127 -112
- package/dist/main.css +1 -1
- package/dist/main.js +127 -112
- package/dist/main.js.map +1 -1
- package/dist/module.js +127 -112
- package/dist/module.js.map +1 -1
- package/package.json +15 -15
- package/src/Button.tsx +11 -11
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-spectrum/button",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.14.1",
|
4
4
|
"description": "Spectrum UI components in React",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "dist/main.js",
|
@@ -36,19 +36,19 @@
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@react-aria/button": "^3.8.
|
40
|
-
"@react-aria/focus": "^3.14.
|
41
|
-
"@react-aria/i18n": "^3.8.
|
42
|
-
"@react-aria/interactions": "^3.
|
43
|
-
"@react-aria/utils": "^3.
|
44
|
-
"@react-spectrum/progress": "^3.
|
45
|
-
"@react-spectrum/text": "^3.4.
|
46
|
-
"@react-spectrum/utils": "^3.
|
47
|
-
"@react-stately/toggle": "^3.6.
|
48
|
-
"@react-types/button": "^3.
|
49
|
-
"@react-types/progress": "^3.
|
50
|
-
"@react-types/shared": "^3.
|
51
|
-
"@spectrum-icons/ui": "^3.
|
39
|
+
"@react-aria/button": "^3.8.4",
|
40
|
+
"@react-aria/focus": "^3.14.3",
|
41
|
+
"@react-aria/i18n": "^3.8.4",
|
42
|
+
"@react-aria/interactions": "^3.19.1",
|
43
|
+
"@react-aria/utils": "^3.21.1",
|
44
|
+
"@react-spectrum/progress": "^3.7.1",
|
45
|
+
"@react-spectrum/text": "^3.4.7",
|
46
|
+
"@react-spectrum/utils": "^3.11.1",
|
47
|
+
"@react-stately/toggle": "^3.6.3",
|
48
|
+
"@react-types/button": "^3.9.0",
|
49
|
+
"@react-types/progress": "^3.5.0",
|
50
|
+
"@react-types/shared": "^3.21.0",
|
51
|
+
"@spectrum-icons/ui": "^3.6.1",
|
52
52
|
"@swc/helpers": "^0.5.0"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
@@ -62,5 +62,5 @@
|
|
62
62
|
"publishConfig": {
|
63
63
|
"access": "public"
|
64
64
|
},
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "3ecf62dcceea437cb12df1851636dd491bb6591c"
|
66
66
|
}
|
package/src/Button.tsx
CHANGED
@@ -34,8 +34,8 @@ import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
34
34
|
import {useProviderProps} from '@react-spectrum/provider';
|
35
35
|
|
36
36
|
function disablePendingProps(props) {
|
37
|
-
// Don't allow interaction while
|
38
|
-
if (props.
|
37
|
+
// Don't allow interaction while isPending is true
|
38
|
+
if (props.isPending) {
|
39
39
|
props.onPress = undefined;
|
40
40
|
props.onPressStart = undefined;
|
41
41
|
props.onPressEnd = undefined;
|
@@ -60,7 +60,7 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
|
|
60
60
|
style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',
|
61
61
|
staticColor,
|
62
62
|
isDisabled,
|
63
|
-
|
63
|
+
isPending,
|
64
64
|
autoFocus,
|
65
65
|
...otherProps
|
66
66
|
} = props;
|
@@ -76,20 +76,20 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
|
|
76
76
|
useEffect(() => {
|
77
77
|
let timeout: ReturnType<typeof setTimeout>;
|
78
78
|
|
79
|
-
if (
|
80
|
-
// Start timer when
|
79
|
+
if (isPending) {
|
80
|
+
// Start timer when isPending is set to true.
|
81
81
|
timeout = setTimeout(() => {
|
82
82
|
setIsProgressVisible(true);
|
83
83
|
}, 1000);
|
84
84
|
} else {
|
85
|
-
// Exit loading state when
|
85
|
+
// Exit loading state when isPending is set to false. */
|
86
86
|
setIsProgressVisible(false);
|
87
87
|
}
|
88
88
|
return () => {
|
89
|
-
// Clean up on unmount or when user removes
|
89
|
+
// Clean up on unmount or when user removes isPending prop before entering loading state.
|
90
90
|
clearTimeout(timeout);
|
91
91
|
};
|
92
|
-
}, [
|
92
|
+
}, [isPending]);
|
93
93
|
|
94
94
|
if (variant === 'cta') {
|
95
95
|
variant = 'accent';
|
@@ -107,8 +107,8 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
|
|
107
107
|
data-variant={variant}
|
108
108
|
data-style={style}
|
109
109
|
data-static-color={staticColor || undefined}
|
110
|
-
aria-disabled={
|
111
|
-
aria-live={
|
110
|
+
aria-disabled={isPending || undefined}
|
111
|
+
aria-live={isPending ? 'polite' : undefined}
|
112
112
|
className={
|
113
113
|
classNames(
|
114
114
|
styles,
|
@@ -138,7 +138,7 @@ function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>,
|
|
138
138
|
isIndeterminate
|
139
139
|
size="S"
|
140
140
|
UNSAFE_className={classNames(styles, 'spectrum-Button-circleLoader')}
|
141
|
-
|
141
|
+
staticColor={staticColor} />}
|
142
142
|
{typeof children === 'string'
|
143
143
|
? <Text>{children}</Text>
|
144
144
|
: children}
|