@react-spectrum/button 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/ActionButton.main.js +97 -0
- package/dist/ActionButton.main.js.map +1 -0
- package/dist/ActionButton.mjs +92 -0
- package/dist/ActionButton.module.js +92 -0
- package/dist/ActionButton.module.js.map +1 -0
- package/dist/Button.main.js +186 -0
- package/dist/Button.main.js.map +1 -0
- package/dist/Button.mjs +181 -0
- package/dist/Button.module.js +181 -0
- package/dist/Button.module.js.map +1 -0
- package/dist/ClearButton.main.js +75 -0
- package/dist/ClearButton.main.js.map +1 -0
- package/dist/ClearButton.mjs +70 -0
- package/dist/ClearButton.module.js +70 -0
- package/dist/ClearButton.module.js.map +1 -0
- package/dist/FieldButton.main.js +72 -0
- package/dist/FieldButton.main.js.map +1 -0
- package/dist/FieldButton.mjs +67 -0
- package/dist/FieldButton.module.js +67 -0
- package/dist/FieldButton.module.js.map +1 -0
- package/dist/LogicButton.main.js +70 -0
- package/dist/LogicButton.main.js.map +1 -0
- package/dist/LogicButton.mjs +65 -0
- package/dist/LogicButton.module.js +65 -0
- package/dist/LogicButton.module.js.map +1 -0
- package/dist/ToggleButton.main.js +90 -0
- package/dist/ToggleButton.main.js.map +1 -0
- package/dist/ToggleButton.mjs +85 -0
- package/dist/ToggleButton.module.js +85 -0
- package/dist/ToggleButton.module.js.map +1 -0
- package/dist/ar-AE.main.js +6 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +8 -0
- package/dist/ar-AE.module.js +8 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +6 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +8 -0
- package/dist/bg-BG.module.js +8 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/button_vars_css.main.js +122 -0
- package/dist/button_vars_css.main.js.map +1 -0
- package/dist/button_vars_css.mjs +124 -0
- package/dist/button_vars_css.module.js +124 -0
- package/dist/button_vars_css.module.js.map +1 -0
- package/dist/cs-CZ.main.js +6 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +8 -0
- package/dist/cs-CZ.module.js +8 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +6 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +8 -0
- package/dist/da-DK.module.js +8 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +6 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +8 -0
- package/dist/de-DE.module.js +8 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +6 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +8 -0
- package/dist/el-GR.module.js +8 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +6 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +8 -0
- package/dist/en-US.module.js +8 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +6 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +8 -0
- package/dist/es-ES.module.js +8 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +6 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +8 -0
- package/dist/et-EE.module.js +8 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +6 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +8 -0
- package/dist/fi-FI.module.js +8 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +6 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +8 -0
- package/dist/fr-FR.module.js +8 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +6 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +8 -0
- package/dist/he-IL.module.js +8 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +6 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +8 -0
- package/dist/hr-HR.module.js +8 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +6 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +8 -0
- package/dist/hu-HU.module.js +8 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +28 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +6 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +8 -0
- package/dist/it-IT.module.js +8 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +6 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +8 -0
- package/dist/ja-JP.module.js +8 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +6 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +8 -0
- package/dist/ko-KR.module.js +8 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +6 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +8 -0
- package/dist/lt-LT.module.js +8 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +6 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +8 -0
- package/dist/lv-LV.module.js +8 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +38 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +28 -0
- package/dist/module.js.map +1 -0
- package/dist/nb-NO.main.js +6 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +8 -0
- package/dist/nb-NO.module.js +8 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +6 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +8 -0
- package/dist/nl-NL.module.js +8 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +6 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +8 -0
- package/dist/pl-PL.module.js +8 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +6 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +8 -0
- package/dist/pt-BR.module.js +8 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +6 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +8 -0
- package/dist/pt-PT.module.js +8 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +6 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +8 -0
- package/dist/ro-RO.module.js +8 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +6 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +8 -0
- package/dist/ru-RU.module.js +8 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +6 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +8 -0
- package/dist/sk-SK.module.js +8 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +6 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +8 -0
- package/dist/sl-SI.module.js +8 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +6 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +8 -0
- package/dist/sr-SP.module.js +8 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +6 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +8 -0
- package/dist/sv-SE.module.js +8 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +6 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +8 -0
- package/dist/tr-TR.module.js +8 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/uk-UA.main.js +6 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +8 -0
- package/dist/uk-UA.module.js +8 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/vars.4fe44343.css +1645 -0
- package/dist/vars.4fe44343.css.map +1 -0
- package/dist/zh-CN.main.js +6 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +8 -0
- package/dist/zh-CN.module.js +8 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +6 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +8 -0
- package/dist/zh-TW.module.js +8 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +66 -0
- package/src/ActionButton.tsx +107 -0
- package/src/Button.tsx +210 -0
- package/src/ClearButton.tsx +81 -0
- package/src/FieldButton.tsx +84 -0
- package/src/LogicButton.tsx +67 -0
- package/src/ToggleButton.tsx +93 -0
- package/src/index.ts +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","sources":["packages/@adobe/spectrum-css-temp/components/button/vars.css"],"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\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"vars.4fe44343.css.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,WAAW,CAAC,wBAAG,CAAC;AACpC","sources":["packages/@react-spectrum/button/intl/zh-CN.json"],"sourcesContent":["{\n \"pending\": \"待处理\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
|
package/dist/zh-CN.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,wBAAG,CAAC;AACpC","sources":["packages/@react-spectrum/button/intl/zh-CN.json"],"sourcesContent":["{\n \"pending\": \"待处理\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,WAAW,CAAC,wBAAG,CAAC;AACpC","sources":["packages/@react-spectrum/button/intl/zh-TW.json"],"sourcesContent":["{\n \"pending\": \"待處理\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
|
package/dist/zh-TW.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,wBAAG,CAAC;AACpC","sources":["packages/@react-spectrum/button/intl/zh-TW.json"],"sourcesContent":["{\n \"pending\": \"待處理\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-spectrum/button",
|
|
3
|
+
"version": "3.0.0-nightly-641446f65-240905",
|
|
4
|
+
"description": "Spectrum UI components in React",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/types.d.ts",
|
|
14
|
+
"source": "src/index.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"*.css"
|
|
21
|
+
],
|
|
22
|
+
"targets": {
|
|
23
|
+
"main": {
|
|
24
|
+
"includeNodeModules": [
|
|
25
|
+
"@adobe/spectrum-css-temp"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"module": {
|
|
29
|
+
"includeNodeModules": [
|
|
30
|
+
"@adobe/spectrum-css-temp"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@react-aria/button": "^3.0.0-nightly-641446f65-240905",
|
|
40
|
+
"@react-aria/focus": "^3.0.0-nightly-641446f65-240905",
|
|
41
|
+
"@react-aria/i18n": "^3.0.0-nightly-641446f65-240905",
|
|
42
|
+
"@react-aria/interactions": "^3.0.0-nightly-641446f65-240905",
|
|
43
|
+
"@react-aria/utils": "^3.0.0-nightly-641446f65-240905",
|
|
44
|
+
"@react-spectrum/progress": "^3.0.0-nightly-641446f65-240905",
|
|
45
|
+
"@react-spectrum/text": "^3.0.0-nightly-641446f65-240905",
|
|
46
|
+
"@react-spectrum/utils": "^3.0.0-nightly-641446f65-240905",
|
|
47
|
+
"@react-stately/toggle": "^3.0.0-nightly-641446f65-240905",
|
|
48
|
+
"@react-types/button": "^3.0.0-nightly-641446f65-240905",
|
|
49
|
+
"@react-types/shared": "^3.0.0-nightly-641446f65-240905",
|
|
50
|
+
"@spectrum-icons/ui": "^3.0.0-nightly-641446f65-240905",
|
|
51
|
+
"@swc/helpers": "^0.5.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@adobe/spectrum-css-temp": "3.0.0-alpha.1",
|
|
55
|
+
"@react-spectrum/test-utils-internal": "3.0.0-alpha.1",
|
|
56
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@react-spectrum/provider": "^3.0.0-nightly-641446f65-240905",
|
|
60
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"stableVersion": "3.16.6"
|
|
66
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {classNames, ClearSlots, SlotProvider, useFocusableRef, useSlotProps, useStyleProps} from '@react-spectrum/utils';
|
|
14
|
+
import CornerTriangle from '@spectrum-icons/ui/CornerTriangle';
|
|
15
|
+
import {FocusableRef} from '@react-types/shared';
|
|
16
|
+
import {FocusRing} from '@react-aria/focus';
|
|
17
|
+
import {mergeProps} from '@react-aria/utils';
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import {SpectrumActionButtonProps} from '@react-types/button';
|
|
20
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
21
|
+
import {Text} from '@react-spectrum/text';
|
|
22
|
+
import {useButton} from '@react-aria/button';
|
|
23
|
+
import {useHover} from '@react-aria/interactions';
|
|
24
|
+
import {useProviderProps} from '@react-spectrum/provider';
|
|
25
|
+
|
|
26
|
+
function ActionButton(props: SpectrumActionButtonProps, ref: FocusableRef<HTMLButtonElement>) {
|
|
27
|
+
props = useProviderProps(props);
|
|
28
|
+
props = useSlotProps(props, 'actionButton');
|
|
29
|
+
let textProps = useSlotProps({UNSAFE_className: classNames(styles, 'spectrum-ActionButton-label')}, 'text');
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
isQuiet,
|
|
33
|
+
isDisabled,
|
|
34
|
+
staticColor,
|
|
35
|
+
children,
|
|
36
|
+
autoFocus,
|
|
37
|
+
// @ts-ignore (private)
|
|
38
|
+
holdAffordance,
|
|
39
|
+
// @ts-ignore (private)
|
|
40
|
+
hideButtonText,
|
|
41
|
+
...otherProps
|
|
42
|
+
} = props;
|
|
43
|
+
|
|
44
|
+
let domRef = useFocusableRef(ref);
|
|
45
|
+
let {buttonProps, isPressed} = useButton(props, domRef);
|
|
46
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
47
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
48
|
+
let isTextOnly = React.Children.toArray(props.children).every(c => !React.isValidElement(c));
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
|
|
52
|
+
<button
|
|
53
|
+
{...styleProps}
|
|
54
|
+
{...mergeProps(buttonProps, hoverProps)}
|
|
55
|
+
ref={domRef}
|
|
56
|
+
className={
|
|
57
|
+
classNames(
|
|
58
|
+
styles,
|
|
59
|
+
'spectrum-ActionButton',
|
|
60
|
+
{
|
|
61
|
+
'spectrum-ActionButton--quiet': isQuiet,
|
|
62
|
+
'spectrum-ActionButton--staticColor': !!staticColor,
|
|
63
|
+
'spectrum-ActionButton--staticWhite': staticColor === 'white',
|
|
64
|
+
'spectrum-ActionButton--staticBlack': staticColor === 'black',
|
|
65
|
+
'is-active': isPressed,
|
|
66
|
+
'is-disabled': isDisabled,
|
|
67
|
+
'is-hovered': isHovered
|
|
68
|
+
},
|
|
69
|
+
styleProps.className
|
|
70
|
+
)
|
|
71
|
+
}>
|
|
72
|
+
{holdAffordance &&
|
|
73
|
+
<CornerTriangle UNSAFE_className={classNames(styles, 'spectrum-ActionButton-hold')} />
|
|
74
|
+
}
|
|
75
|
+
<ClearSlots>
|
|
76
|
+
<SlotProvider
|
|
77
|
+
slots={{
|
|
78
|
+
icon: {
|
|
79
|
+
size: 'S',
|
|
80
|
+
UNSAFE_className: classNames(
|
|
81
|
+
styles,
|
|
82
|
+
'spectrum-Icon',
|
|
83
|
+
{
|
|
84
|
+
'spectrum-ActionGroup-itemIcon': hideButtonText
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
},
|
|
88
|
+
text: {
|
|
89
|
+
...textProps
|
|
90
|
+
}
|
|
91
|
+
}}>
|
|
92
|
+
{typeof children === 'string' || isTextOnly
|
|
93
|
+
? <Text>{children}</Text>
|
|
94
|
+
: children}
|
|
95
|
+
</SlotProvider>
|
|
96
|
+
</ClearSlots>
|
|
97
|
+
</button>
|
|
98
|
+
</FocusRing>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* ActionButtons allow users to perform an action.
|
|
104
|
+
* They’re used for similar, task-based options within a workflow, and are ideal for interfaces where buttons aren’t meant to draw a lot of attention.
|
|
105
|
+
*/
|
|
106
|
+
let _ActionButton = React.forwardRef(ActionButton);
|
|
107
|
+
export {_ActionButton as ActionButton};
|
package/src/Button.tsx
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
classNames,
|
|
15
|
+
SlotProvider,
|
|
16
|
+
useFocusableRef,
|
|
17
|
+
useHasChild,
|
|
18
|
+
useSlotProps,
|
|
19
|
+
useStyleProps
|
|
20
|
+
} from '@react-spectrum/utils';
|
|
21
|
+
import {FocusableRef} from '@react-types/shared';
|
|
22
|
+
import {FocusRing} from '@react-aria/focus';
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
import intlMessages from '../intl/*.json';
|
|
25
|
+
import {isAppleDevice, isFirefox, mergeProps, useId} from '@react-aria/utils';
|
|
26
|
+
import {ProgressCircle} from '@react-spectrum/progress';
|
|
27
|
+
import React, {ElementType, ReactElement, useEffect, useState} from 'react';
|
|
28
|
+
import {SpectrumButtonProps} from '@react-types/button';
|
|
29
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
30
|
+
import {Text} from '@react-spectrum/text';
|
|
31
|
+
import {useButton} from '@react-aria/button';
|
|
32
|
+
import {useFocus, useHover} from '@react-aria/interactions';
|
|
33
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
34
|
+
import {useProviderProps} from '@react-spectrum/provider';
|
|
35
|
+
|
|
36
|
+
function disablePendingProps(props) {
|
|
37
|
+
// Don't allow interaction while isPending is true
|
|
38
|
+
if (props.isPending) {
|
|
39
|
+
props.onPress = undefined;
|
|
40
|
+
props.onPressStart = undefined;
|
|
41
|
+
props.onPressEnd = undefined;
|
|
42
|
+
props.onPressChange = undefined;
|
|
43
|
+
props.onPressUp = undefined;
|
|
44
|
+
props.onKeyDown = undefined;
|
|
45
|
+
props.onKeyUp = undefined;
|
|
46
|
+
props.onClick = undefined;
|
|
47
|
+
props.href = undefined;
|
|
48
|
+
}
|
|
49
|
+
return props;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function Button<T extends ElementType = 'button'>(props: SpectrumButtonProps<T>, ref: FocusableRef<HTMLElement>) {
|
|
53
|
+
props = useProviderProps(props);
|
|
54
|
+
props = useSlotProps(props, 'button');
|
|
55
|
+
props = disablePendingProps(props);
|
|
56
|
+
let {
|
|
57
|
+
elementType: Element = 'button',
|
|
58
|
+
children,
|
|
59
|
+
variant,
|
|
60
|
+
style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',
|
|
61
|
+
staticColor,
|
|
62
|
+
isDisabled,
|
|
63
|
+
isPending,
|
|
64
|
+
autoFocus,
|
|
65
|
+
...otherProps
|
|
66
|
+
} = props;
|
|
67
|
+
let domRef = useFocusableRef(ref);
|
|
68
|
+
let {buttonProps, isPressed} = useButton(props, domRef);
|
|
69
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
70
|
+
let [isFocused, onFocusChange] = useState(false);
|
|
71
|
+
let {focusProps} = useFocus({onFocusChange, isDisabled});
|
|
72
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/button');
|
|
73
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
74
|
+
let hasLabel = useHasChild(`.${styles['spectrum-Button-label']}`, domRef);
|
|
75
|
+
let hasIcon = useHasChild(`.${styles['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] = useState(false);
|
|
79
|
+
let backupButtonId = useId();
|
|
80
|
+
let buttonId = buttonProps.id || backupButtonId;
|
|
81
|
+
let iconId = useId();
|
|
82
|
+
let textId = useId();
|
|
83
|
+
let spinnerId = useId();
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
87
|
+
|
|
88
|
+
if (isPending) {
|
|
89
|
+
// Start timer when isPending is set to true.
|
|
90
|
+
timeout = setTimeout(() => {
|
|
91
|
+
setIsProgressVisible(true);
|
|
92
|
+
}, 1000);
|
|
93
|
+
} else {
|
|
94
|
+
// Exit loading state when isPending is set to false. */
|
|
95
|
+
setIsProgressVisible(false);
|
|
96
|
+
}
|
|
97
|
+
return () => {
|
|
98
|
+
// Clean up on unmount or when user removes isPending prop before entering loading state.
|
|
99
|
+
clearTimeout(timeout);
|
|
100
|
+
};
|
|
101
|
+
}, [isPending]);
|
|
102
|
+
|
|
103
|
+
if (variant === 'cta') {
|
|
104
|
+
variant = 'accent';
|
|
105
|
+
} else if (variant === 'overBackground') {
|
|
106
|
+
variant = 'primary';
|
|
107
|
+
staticColor = 'white';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();
|
|
111
|
+
const isPendingAriaLiveLabelledby = hasAriaLabel ? (buttonProps['aria-labelledby']?.replace(buttonId, spinnerId) ?? spinnerId) : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();
|
|
112
|
+
|
|
113
|
+
let ariaLive: 'off' | 'polite' | 'assertive' = 'polite';
|
|
114
|
+
if (isAppleDevice() && (!hasAriaLabel || isFirefox())) {
|
|
115
|
+
ariaLive = 'off';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let isPendingProps = isPending ? {
|
|
119
|
+
onClick: (e) => {
|
|
120
|
+
if (e.currentTarget instanceof HTMLButtonElement) {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} : {
|
|
125
|
+
// no-op.
|
|
126
|
+
// Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.
|
|
127
|
+
onClick: () => {}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
|
|
132
|
+
<Element
|
|
133
|
+
{...styleProps}
|
|
134
|
+
{...mergeProps(buttonProps, hoverProps, focusProps, isPendingProps)}
|
|
135
|
+
id={buttonId}
|
|
136
|
+
ref={domRef}
|
|
137
|
+
data-variant={variant}
|
|
138
|
+
data-style={style}
|
|
139
|
+
data-static-color={staticColor || undefined}
|
|
140
|
+
aria-disabled={isPending ? 'true' : undefined}
|
|
141
|
+
aria-label={isPending ? isPendingAriaLiveLabel : buttonProps['aria-label']}
|
|
142
|
+
aria-labelledby={isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby']}
|
|
143
|
+
className={
|
|
144
|
+
classNames(
|
|
145
|
+
styles,
|
|
146
|
+
'spectrum-Button',
|
|
147
|
+
{
|
|
148
|
+
'spectrum-Button--iconOnly': hasIcon && !hasLabel,
|
|
149
|
+
'is-disabled': isDisabled || isProgressVisible,
|
|
150
|
+
'is-active': isPressed,
|
|
151
|
+
'is-hovered': isHovered,
|
|
152
|
+
'spectrum-Button--pending': isProgressVisible
|
|
153
|
+
},
|
|
154
|
+
styleProps.className
|
|
155
|
+
)
|
|
156
|
+
}>
|
|
157
|
+
<SlotProvider
|
|
158
|
+
slots={{
|
|
159
|
+
icon: {
|
|
160
|
+
id: iconId,
|
|
161
|
+
size: 'S',
|
|
162
|
+
UNSAFE_className: classNames(styles, 'spectrum-Icon')
|
|
163
|
+
},
|
|
164
|
+
text: {
|
|
165
|
+
id: textId,
|
|
166
|
+
UNSAFE_className: classNames(styles, 'spectrum-Button-label')
|
|
167
|
+
}
|
|
168
|
+
}}>
|
|
169
|
+
{typeof children === 'string'
|
|
170
|
+
? <Text>{children}</Text>
|
|
171
|
+
: children}
|
|
172
|
+
{isPending && (
|
|
173
|
+
<div
|
|
174
|
+
aria-hidden="true"
|
|
175
|
+
style={{visibility: isProgressVisible ? 'visible' : 'hidden'}}
|
|
176
|
+
className={classNames(styles, 'spectrum-Button-circleLoader')}>
|
|
177
|
+
<ProgressCircle
|
|
178
|
+
aria-label={isPendingAriaLiveLabel}
|
|
179
|
+
isIndeterminate
|
|
180
|
+
size="S"
|
|
181
|
+
staticColor={staticColor} />
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
{isPending &&
|
|
185
|
+
<>
|
|
186
|
+
<div aria-live={isFocused ? ariaLive : 'off'}>
|
|
187
|
+
{isProgressVisible &&
|
|
188
|
+
<div role="img" aria-labelledby={isPendingAriaLiveLabelledby} />
|
|
189
|
+
}
|
|
190
|
+
</div>
|
|
191
|
+
{/* Adding the element here with the same labels as the button itself causes aria-live to pick up the change in Safari.
|
|
192
|
+
Safari with VO unfortunately doesn't announce changes to *all* of its labels specifically for button
|
|
193
|
+
https://a11ysupport.io/tests/tech__html__button-name-change#assertion-aria-aria-label_attribute-convey_name_change-html-button_element-vo_macos-safari
|
|
194
|
+
The aria-live may cause extra announcements in other browsers. */}
|
|
195
|
+
<div id={spinnerId} role="img" aria-label={isPendingAriaLiveLabel} />
|
|
196
|
+
</>
|
|
197
|
+
}
|
|
198
|
+
</SlotProvider>
|
|
199
|
+
</Element>
|
|
200
|
+
</FocusRing>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Buttons allow users to perform an action or to navigate to another page.
|
|
206
|
+
* They have multiple styles for various needs, and are ideal for calling attention to
|
|
207
|
+
* where a user needs to do something in order to move forward in a flow.
|
|
208
|
+
*/
|
|
209
|
+
let _Button = React.forwardRef(Button) as <T extends ElementType = 'button'>(props: SpectrumButtonProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;
|
|
210
|
+
export {_Button as Button};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {AriaButtonElementTypeProps, ButtonProps} from '@react-types/button';
|
|
14
|
+
import {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
|
|
15
|
+
import CrossSmall from '@spectrum-icons/ui/CrossSmall';
|
|
16
|
+
import {DOMProps, FocusableRef, StyleProps} from '@react-types/shared';
|
|
17
|
+
import {FocusRing} from '@react-aria/focus';
|
|
18
|
+
import {mergeProps} from '@react-aria/utils';
|
|
19
|
+
import React, {ElementType} from 'react';
|
|
20
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
21
|
+
import {useButton} from '@react-aria/button';
|
|
22
|
+
import {useHover} from '@react-aria/interactions';
|
|
23
|
+
|
|
24
|
+
interface ClearButtonProps<T extends ElementType = 'button'> extends ButtonProps, AriaButtonElementTypeProps<T>, DOMProps, StyleProps {
|
|
25
|
+
focusClassName?: string,
|
|
26
|
+
variant?: 'overBackground',
|
|
27
|
+
excludeFromTabOrder?: boolean,
|
|
28
|
+
preventFocus?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ClearButton(props: ClearButtonProps, ref: FocusableRef<HTMLButtonElement>) {
|
|
32
|
+
let {
|
|
33
|
+
children = <CrossSmall UNSAFE_className={styles['spectrum-Icon']} />,
|
|
34
|
+
focusClassName,
|
|
35
|
+
variant,
|
|
36
|
+
autoFocus,
|
|
37
|
+
isDisabled,
|
|
38
|
+
preventFocus,
|
|
39
|
+
elementType = preventFocus ? 'div' : 'button' as ElementType,
|
|
40
|
+
...otherProps
|
|
41
|
+
} = props;
|
|
42
|
+
let domRef = useFocusableRef(ref);
|
|
43
|
+
let {buttonProps, isPressed} = useButton({...props, elementType}, domRef);
|
|
44
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
45
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
46
|
+
|
|
47
|
+
// For cases like the clear button in a search field, remove the tabIndex so
|
|
48
|
+
// iOS 14 with VoiceOver doesn't focus the button and hide the keyboard when
|
|
49
|
+
// moving the cursor over the clear button.
|
|
50
|
+
if (preventFocus) {
|
|
51
|
+
delete buttonProps.tabIndex;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let ElementType = elementType;
|
|
55
|
+
return (
|
|
56
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring', focusClassName)} autoFocus={autoFocus}>
|
|
57
|
+
<ElementType
|
|
58
|
+
{...styleProps}
|
|
59
|
+
{...mergeProps(buttonProps, hoverProps)}
|
|
60
|
+
ref={domRef}
|
|
61
|
+
className={
|
|
62
|
+
classNames(
|
|
63
|
+
styles,
|
|
64
|
+
'spectrum-ClearButton',
|
|
65
|
+
{
|
|
66
|
+
[`spectrum-ClearButton--${variant}`]: variant,
|
|
67
|
+
'is-disabled': isDisabled,
|
|
68
|
+
'is-active': isPressed,
|
|
69
|
+
'is-hovered': isHovered
|
|
70
|
+
},
|
|
71
|
+
styleProps.className
|
|
72
|
+
)
|
|
73
|
+
}>
|
|
74
|
+
{children}
|
|
75
|
+
</ElementType>
|
|
76
|
+
</FocusRing>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let _ClearButton = React.forwardRef(ClearButton);
|
|
81
|
+
export {_ClearButton as ClearButton};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {ButtonProps} from '@react-types/button';
|
|
14
|
+
import {classNames, SlotProvider, useFocusableRef, useSlotProps, useStyleProps} from '@react-spectrum/utils';
|
|
15
|
+
import {DOMProps, FocusableRef, RefObject, StyleProps} from '@react-types/shared';
|
|
16
|
+
import {FocusRing} from '@react-aria/focus';
|
|
17
|
+
import {mergeProps} from '@react-aria/utils';
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
20
|
+
import {useButton} from '@react-aria/button';
|
|
21
|
+
import {useHover} from '@react-aria/interactions';
|
|
22
|
+
|
|
23
|
+
interface FieldButtonProps extends ButtonProps, DOMProps, StyleProps {
|
|
24
|
+
isQuiet?: boolean,
|
|
25
|
+
isActive?: boolean,
|
|
26
|
+
validationState?: 'valid' | 'invalid',
|
|
27
|
+
isInvalid?: boolean,
|
|
28
|
+
focusRingClass?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// @private
|
|
32
|
+
function FieldButton(props: FieldButtonProps, ref: FocusableRef) {
|
|
33
|
+
props = useSlotProps(props, 'button');
|
|
34
|
+
let {
|
|
35
|
+
isQuiet,
|
|
36
|
+
isDisabled,
|
|
37
|
+
validationState,
|
|
38
|
+
isInvalid,
|
|
39
|
+
children,
|
|
40
|
+
autoFocus,
|
|
41
|
+
isActive,
|
|
42
|
+
focusRingClass,
|
|
43
|
+
...otherProps
|
|
44
|
+
} = props;
|
|
45
|
+
let domRef = useFocusableRef(ref) as RefObject<HTMLButtonElement | null>;
|
|
46
|
+
let {buttonProps, isPressed} = useButton(props, domRef);
|
|
47
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
48
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring', focusRingClass)} autoFocus={autoFocus}>
|
|
52
|
+
<button
|
|
53
|
+
{...mergeProps(buttonProps, hoverProps)}
|
|
54
|
+
ref={domRef}
|
|
55
|
+
className={
|
|
56
|
+
classNames(
|
|
57
|
+
styles,
|
|
58
|
+
'spectrum-FieldButton',
|
|
59
|
+
{
|
|
60
|
+
'spectrum-FieldButton--quiet': isQuiet,
|
|
61
|
+
'is-active': isActive || isPressed,
|
|
62
|
+
'is-disabled': isDisabled,
|
|
63
|
+
'spectrum-FieldButton--invalid': isInvalid || validationState === 'invalid',
|
|
64
|
+
'is-hovered': isHovered
|
|
65
|
+
},
|
|
66
|
+
styleProps.className
|
|
67
|
+
)
|
|
68
|
+
}>
|
|
69
|
+
<SlotProvider
|
|
70
|
+
slots={{
|
|
71
|
+
icon: {
|
|
72
|
+
size: 'S',
|
|
73
|
+
UNSAFE_className: classNames(styles, 'spectrum-Icon')
|
|
74
|
+
}
|
|
75
|
+
}}>
|
|
76
|
+
{children}
|
|
77
|
+
</SlotProvider>
|
|
78
|
+
</button>
|
|
79
|
+
</FocusRing>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let _FieldButton = React.forwardRef(FieldButton);
|
|
84
|
+
export {_FieldButton as FieldButton};
|