@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.
- 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 +177 -0
- package/dist/Button.main.js.map +1 -0
- package/dist/Button.mjs +172 -0
- package/dist/Button.module.js +172 -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 +6 -814
- 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 +12 -816
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -814
- package/dist/module.js.map +1 -1
- 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 +6 -6
- package/dist/types.d.ts.map +1 -1
- 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 +15 -15
- package/src/ActionButton.tsx +27 -15
- package/dist/main.css +0 -1
@@ -0,0 +1,97 @@
|
|
1
|
+
require("./vars.4fe44343.css");
|
2
|
+
var $afc5a4514aca2340$exports = require("./button_vars_css.main.js");
|
3
|
+
var $9HF4v$reactspectrumutils = require("@react-spectrum/utils");
|
4
|
+
var $9HF4v$spectrumiconsuiCornerTriangle = require("@spectrum-icons/ui/CornerTriangle");
|
5
|
+
var $9HF4v$reactariafocus = require("@react-aria/focus");
|
6
|
+
var $9HF4v$reactariautils = require("@react-aria/utils");
|
7
|
+
var $9HF4v$react = require("react");
|
8
|
+
var $9HF4v$reactspectrumtext = require("@react-spectrum/text");
|
9
|
+
var $9HF4v$reactariabutton = require("@react-aria/button");
|
10
|
+
var $9HF4v$reactariainteractions = require("@react-aria/interactions");
|
11
|
+
var $9HF4v$reactspectrumprovider = require("@react-spectrum/provider");
|
12
|
+
|
13
|
+
|
14
|
+
function $parcel$interopDefault(a) {
|
15
|
+
return a && a.__esModule ? a.default : a;
|
16
|
+
}
|
17
|
+
|
18
|
+
function $parcel$export(e, n, v, s) {
|
19
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
20
|
+
}
|
21
|
+
|
22
|
+
$parcel$export(module.exports, "ActionButton", () => $65dbde0e8e7aba71$export$cfc7921d29ef7b80);
|
23
|
+
/*
|
24
|
+
* Copyright 2020 Adobe. All rights reserved.
|
25
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
26
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
27
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
28
|
+
*
|
29
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
30
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
31
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
32
|
+
* governing permissions and limitations under the License.
|
33
|
+
*/
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
function $65dbde0e8e7aba71$var$ActionButton(props, ref) {
|
44
|
+
props = (0, $9HF4v$reactspectrumprovider.useProviderProps)(props);
|
45
|
+
props = (0, $9HF4v$reactspectrumutils.useSlotProps)(props, "actionButton");
|
46
|
+
let textProps = (0, $9HF4v$reactspectrumutils.useSlotProps)({
|
47
|
+
UNSAFE_className: (0, $9HF4v$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-ActionButton-label")
|
48
|
+
}, "text");
|
49
|
+
let { isQuiet: isQuiet, isDisabled: isDisabled, staticColor: staticColor, children: children, autoFocus: autoFocus, holdAffordance: // @ts-ignore (private)
|
50
|
+
holdAffordance, hideButtonText: // @ts-ignore (private)
|
51
|
+
hideButtonText, ...otherProps } = props;
|
52
|
+
let domRef = (0, $9HF4v$reactspectrumutils.useFocusableRef)(ref);
|
53
|
+
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $9HF4v$reactariabutton.useButton)(props, domRef);
|
54
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $9HF4v$reactariainteractions.useHover)({
|
55
|
+
isDisabled: isDisabled
|
56
|
+
});
|
57
|
+
let { styleProps: styleProps } = (0, $9HF4v$reactspectrumutils.useStyleProps)(otherProps);
|
58
|
+
let isTextOnly = (0, ($parcel$interopDefault($9HF4v$react))).Children.toArray(props.children).every((c)=>!/*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).isValidElement(c));
|
59
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement((0, $9HF4v$reactariafocus.FocusRing), {
|
60
|
+
focusRingClass: (0, $9HF4v$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "focus-ring"),
|
61
|
+
autoFocus: autoFocus
|
62
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement("button", {
|
63
|
+
...styleProps,
|
64
|
+
...(0, $9HF4v$reactariautils.mergeProps)(buttonProps, hoverProps),
|
65
|
+
ref: domRef,
|
66
|
+
className: (0, $9HF4v$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-ActionButton", {
|
67
|
+
"spectrum-ActionButton--quiet": isQuiet,
|
68
|
+
"spectrum-ActionButton--staticColor": !!staticColor,
|
69
|
+
"spectrum-ActionButton--staticWhite": staticColor === "white",
|
70
|
+
"spectrum-ActionButton--staticBlack": staticColor === "black",
|
71
|
+
"is-active": isPressed,
|
72
|
+
"is-disabled": isDisabled,
|
73
|
+
"is-hovered": isHovered
|
74
|
+
}, styleProps.className)
|
75
|
+
}, holdAffordance && /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement((0, ($parcel$interopDefault($9HF4v$spectrumiconsuiCornerTriangle))), {
|
76
|
+
UNSAFE_className: (0, $9HF4v$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-ActionButton-hold")
|
77
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement((0, $9HF4v$reactspectrumutils.ClearSlots), null, /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement((0, $9HF4v$reactspectrumutils.SlotProvider), {
|
78
|
+
slots: {
|
79
|
+
icon: {
|
80
|
+
size: "S",
|
81
|
+
UNSAFE_className: (0, $9HF4v$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-Icon", {
|
82
|
+
"spectrum-ActionGroup-itemIcon": hideButtonText
|
83
|
+
})
|
84
|
+
},
|
85
|
+
text: {
|
86
|
+
...textProps
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}, typeof children === "string" || isTextOnly ? /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).createElement((0, $9HF4v$reactspectrumtext.Text), null, children) : children))));
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* ActionButtons allow users to perform an action.
|
93
|
+
* 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.
|
94
|
+
*/ let $65dbde0e8e7aba71$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, ($parcel$interopDefault($9HF4v$react))).forwardRef($65dbde0e8e7aba71$var$ActionButton);
|
95
|
+
|
96
|
+
|
97
|
+
//# sourceMappingURL=ActionButton.main.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA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;OAGvB,gCACC,0DAAC,CAAA,GAAA,8DAAa;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;sBAEvD,0DAAC,CAAA,GAAA,oCAAS,uBACR,0DAAC,CAAA,GAAA,sCAAW;QACV,OAAO;YACL,MAAM;gBACJ,MAAM;gBACN,kBAAkB,CAAA,GAAA,oCAAS,EACzB,CAAA,GAAA,mDAAK,GACL,iBACA;oBACE,iCAAiC;gBACnC;YAEJ;YACA,MAAM;gBACJ,GAAG,SAAS;YACd;QACF;OACC,OAAO,aAAa,YAAY,2BAC7B,0DAAC,CAAA,GAAA,6BAAG,SAAG,YACP;AAMhB;AAEA;;;CAGC,GACD,IAAI,0DAAgB,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/button/src/ActionButton.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 {classNames, ClearSlots, SlotProvider, useFocusableRef, useSlotProps, useStyleProps} from '@react-spectrum/utils';\nimport CornerTriangle from '@spectrum-icons/ui/CornerTriangle';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React from 'react';\nimport {SpectrumActionButtonProps} 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 {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nfunction ActionButton(props: SpectrumActionButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n props = useProviderProps(props);\n props = useSlotProps(props, 'actionButton');\n let textProps = useSlotProps({UNSAFE_className: classNames(styles, 'spectrum-ActionButton-label')}, 'text');\n\n let {\n isQuiet,\n isDisabled,\n staticColor,\n children,\n autoFocus,\n // @ts-ignore (private)\n holdAffordance,\n // @ts-ignore (private)\n hideButtonText,\n ...otherProps\n } = props;\n\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton(props, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let {styleProps} = useStyleProps(otherProps);\n let isTextOnly = React.Children.toArray(props.children).every(c => !React.isValidElement(c));\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <button\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps)}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ActionButton',\n {\n 'spectrum-ActionButton--quiet': isQuiet,\n 'spectrum-ActionButton--staticColor': !!staticColor,\n 'spectrum-ActionButton--staticWhite': staticColor === 'white',\n 'spectrum-ActionButton--staticBlack': staticColor === 'black',\n 'is-active': isPressed,\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n {holdAffordance &&\n <CornerTriangle UNSAFE_className={classNames(styles, 'spectrum-ActionButton-hold')} />\n }\n <ClearSlots>\n <SlotProvider\n slots={{\n icon: {\n size: 'S',\n UNSAFE_className: classNames(\n styles,\n 'spectrum-Icon',\n {\n 'spectrum-ActionGroup-itemIcon': hideButtonText\n }\n )\n },\n text: {\n ...textProps\n }\n }}>\n {typeof children === 'string' || isTextOnly\n ? <Text>{children}</Text>\n : children}\n </SlotProvider>\n </ClearSlots>\n </button>\n </FocusRing>\n );\n}\n\n/**\n * ActionButtons allow users to perform an action.\n * 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.\n */\nlet _ActionButton = React.forwardRef(ActionButton);\nexport {_ActionButton as ActionButton};\n"],"names":[],"version":3,"file":"ActionButton.main.js.map"}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import "./vars.4fe44343.css";
|
2
|
+
import $kfV1G$button_vars_cssmodulejs from "./button_vars_css.mjs";
|
3
|
+
import {useSlotProps as $kfV1G$useSlotProps, classNames as $kfV1G$classNames, useFocusableRef as $kfV1G$useFocusableRef, useStyleProps as $kfV1G$useStyleProps, ClearSlots as $kfV1G$ClearSlots, SlotProvider as $kfV1G$SlotProvider} from "@react-spectrum/utils";
|
4
|
+
import $kfV1G$spectrumiconsuiCornerTriangle from "@spectrum-icons/ui/CornerTriangle";
|
5
|
+
import {FocusRing as $kfV1G$FocusRing} from "@react-aria/focus";
|
6
|
+
import {mergeProps as $kfV1G$mergeProps} from "@react-aria/utils";
|
7
|
+
import $kfV1G$react from "react";
|
8
|
+
import {Text as $kfV1G$Text} from "@react-spectrum/text";
|
9
|
+
import {useButton as $kfV1G$useButton} from "@react-aria/button";
|
10
|
+
import {useHover as $kfV1G$useHover} from "@react-aria/interactions";
|
11
|
+
import {useProviderProps as $kfV1G$useProviderProps} from "@react-spectrum/provider";
|
12
|
+
|
13
|
+
|
14
|
+
function $parcel$interopDefault(a) {
|
15
|
+
return a && a.__esModule ? a.default : a;
|
16
|
+
}
|
17
|
+
/*
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
22
|
+
*
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
26
|
+
* governing permissions and limitations under the License.
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
function $042ad0b3a4a55b33$var$ActionButton(props, ref) {
|
38
|
+
props = (0, $kfV1G$useProviderProps)(props);
|
39
|
+
props = (0, $kfV1G$useSlotProps)(props, "actionButton");
|
40
|
+
let textProps = (0, $kfV1G$useSlotProps)({
|
41
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton-label")
|
42
|
+
}, "text");
|
43
|
+
let { isQuiet: isQuiet, isDisabled: isDisabled, staticColor: staticColor, children: children, autoFocus: autoFocus, holdAffordance: // @ts-ignore (private)
|
44
|
+
holdAffordance, hideButtonText: // @ts-ignore (private)
|
45
|
+
hideButtonText, ...otherProps } = props;
|
46
|
+
let domRef = (0, $kfV1G$useFocusableRef)(ref);
|
47
|
+
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $kfV1G$useButton)(props, domRef);
|
48
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $kfV1G$useHover)({
|
49
|
+
isDisabled: isDisabled
|
50
|
+
});
|
51
|
+
let { styleProps: styleProps } = (0, $kfV1G$useStyleProps)(otherProps);
|
52
|
+
let isTextOnly = (0, $kfV1G$react).Children.toArray(props.children).every((c)=>!/*#__PURE__*/ (0, $kfV1G$react).isValidElement(c));
|
53
|
+
return /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$FocusRing), {
|
54
|
+
focusRingClass: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "focus-ring"),
|
55
|
+
autoFocus: autoFocus
|
56
|
+
}, /*#__PURE__*/ (0, $kfV1G$react).createElement("button", {
|
57
|
+
...styleProps,
|
58
|
+
...(0, $kfV1G$mergeProps)(buttonProps, hoverProps),
|
59
|
+
ref: domRef,
|
60
|
+
className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton", {
|
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
|
+
}, styleProps.className)
|
69
|
+
}, holdAffordance && /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$spectrumiconsuiCornerTriangle), {
|
70
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton-hold")
|
71
|
+
}), /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$ClearSlots), null, /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$SlotProvider), {
|
72
|
+
slots: {
|
73
|
+
icon: {
|
74
|
+
size: "S",
|
75
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-Icon", {
|
76
|
+
"spectrum-ActionGroup-itemIcon": hideButtonText
|
77
|
+
})
|
78
|
+
},
|
79
|
+
text: {
|
80
|
+
...textProps
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}, typeof children === "string" || isTextOnly ? /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$Text), null, children) : children))));
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* ActionButtons allow users to perform an action.
|
87
|
+
* 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.
|
88
|
+
*/ let $042ad0b3a4a55b33$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $kfV1G$react).forwardRef($042ad0b3a4a55b33$var$ActionButton);
|
89
|
+
|
90
|
+
|
91
|
+
export {$042ad0b3a4a55b33$export$cfc7921d29ef7b80 as ActionButton};
|
92
|
+
//# sourceMappingURL=ActionButton.mjs.map
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import "./vars.4fe44343.css";
|
2
|
+
import $kfV1G$button_vars_cssmodulejs from "./button_vars_css.module.js";
|
3
|
+
import {useSlotProps as $kfV1G$useSlotProps, classNames as $kfV1G$classNames, useFocusableRef as $kfV1G$useFocusableRef, useStyleProps as $kfV1G$useStyleProps, ClearSlots as $kfV1G$ClearSlots, SlotProvider as $kfV1G$SlotProvider} from "@react-spectrum/utils";
|
4
|
+
import $kfV1G$spectrumiconsuiCornerTriangle from "@spectrum-icons/ui/CornerTriangle";
|
5
|
+
import {FocusRing as $kfV1G$FocusRing} from "@react-aria/focus";
|
6
|
+
import {mergeProps as $kfV1G$mergeProps} from "@react-aria/utils";
|
7
|
+
import $kfV1G$react from "react";
|
8
|
+
import {Text as $kfV1G$Text} from "@react-spectrum/text";
|
9
|
+
import {useButton as $kfV1G$useButton} from "@react-aria/button";
|
10
|
+
import {useHover as $kfV1G$useHover} from "@react-aria/interactions";
|
11
|
+
import {useProviderProps as $kfV1G$useProviderProps} from "@react-spectrum/provider";
|
12
|
+
|
13
|
+
|
14
|
+
function $parcel$interopDefault(a) {
|
15
|
+
return a && a.__esModule ? a.default : a;
|
16
|
+
}
|
17
|
+
/*
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
22
|
+
*
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
26
|
+
* governing permissions and limitations under the License.
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
function $042ad0b3a4a55b33$var$ActionButton(props, ref) {
|
38
|
+
props = (0, $kfV1G$useProviderProps)(props);
|
39
|
+
props = (0, $kfV1G$useSlotProps)(props, "actionButton");
|
40
|
+
let textProps = (0, $kfV1G$useSlotProps)({
|
41
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton-label")
|
42
|
+
}, "text");
|
43
|
+
let { isQuiet: isQuiet, isDisabled: isDisabled, staticColor: staticColor, children: children, autoFocus: autoFocus, holdAffordance: // @ts-ignore (private)
|
44
|
+
holdAffordance, hideButtonText: // @ts-ignore (private)
|
45
|
+
hideButtonText, ...otherProps } = props;
|
46
|
+
let domRef = (0, $kfV1G$useFocusableRef)(ref);
|
47
|
+
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $kfV1G$useButton)(props, domRef);
|
48
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $kfV1G$useHover)({
|
49
|
+
isDisabled: isDisabled
|
50
|
+
});
|
51
|
+
let { styleProps: styleProps } = (0, $kfV1G$useStyleProps)(otherProps);
|
52
|
+
let isTextOnly = (0, $kfV1G$react).Children.toArray(props.children).every((c)=>!/*#__PURE__*/ (0, $kfV1G$react).isValidElement(c));
|
53
|
+
return /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$FocusRing), {
|
54
|
+
focusRingClass: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "focus-ring"),
|
55
|
+
autoFocus: autoFocus
|
56
|
+
}, /*#__PURE__*/ (0, $kfV1G$react).createElement("button", {
|
57
|
+
...styleProps,
|
58
|
+
...(0, $kfV1G$mergeProps)(buttonProps, hoverProps),
|
59
|
+
ref: domRef,
|
60
|
+
className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton", {
|
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
|
+
}, styleProps.className)
|
69
|
+
}, holdAffordance && /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$spectrumiconsuiCornerTriangle), {
|
70
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-ActionButton-hold")
|
71
|
+
}), /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$ClearSlots), null, /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$SlotProvider), {
|
72
|
+
slots: {
|
73
|
+
icon: {
|
74
|
+
size: "S",
|
75
|
+
UNSAFE_className: (0, $kfV1G$classNames)((0, ($parcel$interopDefault($kfV1G$button_vars_cssmodulejs))), "spectrum-Icon", {
|
76
|
+
"spectrum-ActionGroup-itemIcon": hideButtonText
|
77
|
+
})
|
78
|
+
},
|
79
|
+
text: {
|
80
|
+
...textProps
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}, typeof children === "string" || isTextOnly ? /*#__PURE__*/ (0, $kfV1G$react).createElement((0, $kfV1G$Text), null, children) : children))));
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* ActionButtons allow users to perform an action.
|
87
|
+
* 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.
|
88
|
+
*/ let $042ad0b3a4a55b33$export$cfc7921d29ef7b80 = /*#__PURE__*/ (0, $kfV1G$react).forwardRef($042ad0b3a4a55b33$var$ActionButton);
|
89
|
+
|
90
|
+
|
91
|
+
export {$042ad0b3a4a55b33$export$cfc7921d29ef7b80 as ActionButton};
|
92
|
+
//# sourceMappingURL=ActionButton.module.js.map
|
@@ -0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gB;YACtD,sCAAsC,gBAAgB;YACtD,aAAa;YACb,eAAe;YACf,cAAc;QAChB,GACA,WAAW,SAAS;OAGvB,gCACC,gCAAC,CAAA,GAAA,oCAAa;QAAE,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,wDAAK,GAAG;sBAEvD,gCAAC,CAAA,GAAA,iBAAS,uBACR,gCAAC,CAAA,GAAA,mBAAW;QACV,OAAO;YACL,MAAM;gBACJ,MAAM;gBACN,kBAAkB,CAAA,GAAA,iBAAS,EACzB,CAAA,GAAA,wDAAK,GACL,iBACA;oBACE,iCAAiC;gBACnC;YAEJ;YACA,MAAM;gBACJ,GAAG,SAAS;YACd;QACF;OACC,OAAO,aAAa,YAAY,2BAC7B,gCAAC,CAAA,GAAA,WAAG,SAAG,YACP;AAMhB;AAEA;;;CAGC,GACD,IAAI,0DAAgB,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/button/src/ActionButton.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 {classNames, ClearSlots, SlotProvider, useFocusableRef, useSlotProps, useStyleProps} from '@react-spectrum/utils';\nimport CornerTriangle from '@spectrum-icons/ui/CornerTriangle';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React from 'react';\nimport {SpectrumActionButtonProps} 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 {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\n\nfunction ActionButton(props: SpectrumActionButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n props = useProviderProps(props);\n props = useSlotProps(props, 'actionButton');\n let textProps = useSlotProps({UNSAFE_className: classNames(styles, 'spectrum-ActionButton-label')}, 'text');\n\n let {\n isQuiet,\n isDisabled,\n staticColor,\n children,\n autoFocus,\n // @ts-ignore (private)\n holdAffordance,\n // @ts-ignore (private)\n hideButtonText,\n ...otherProps\n } = props;\n\n let domRef = useFocusableRef(ref);\n let {buttonProps, isPressed} = useButton(props, domRef);\n let {hoverProps, isHovered} = useHover({isDisabled});\n let {styleProps} = useStyleProps(otherProps);\n let isTextOnly = React.Children.toArray(props.children).every(c => !React.isValidElement(c));\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <button\n {...styleProps}\n {...mergeProps(buttonProps, hoverProps)}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-ActionButton',\n {\n 'spectrum-ActionButton--quiet': isQuiet,\n 'spectrum-ActionButton--staticColor': !!staticColor,\n 'spectrum-ActionButton--staticWhite': staticColor === 'white',\n 'spectrum-ActionButton--staticBlack': staticColor === 'black',\n 'is-active': isPressed,\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n {holdAffordance &&\n <CornerTriangle UNSAFE_className={classNames(styles, 'spectrum-ActionButton-hold')} />\n }\n <ClearSlots>\n <SlotProvider\n slots={{\n icon: {\n size: 'S',\n UNSAFE_className: classNames(\n styles,\n 'spectrum-Icon',\n {\n 'spectrum-ActionGroup-itemIcon': hideButtonText\n }\n )\n },\n text: {\n ...textProps\n }\n }}>\n {typeof children === 'string' || isTextOnly\n ? <Text>{children}</Text>\n : children}\n </SlotProvider>\n </ClearSlots>\n </button>\n </FocusRing>\n );\n}\n\n/**\n * ActionButtons allow users to perform an action.\n * 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.\n */\nlet _ActionButton = React.forwardRef(ActionButton);\nexport {_ActionButton as ActionButton};\n"],"names":[],"version":3,"file":"ActionButton.module.js.map"}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
var $b2da92ebd9a2bc00$exports = require("./intlStrings.main.js");
|
2
|
+
require("./vars.4fe44343.css");
|
3
|
+
var $afc5a4514aca2340$exports = require("./button_vars_css.main.js");
|
4
|
+
var $hN0b7$reactspectrumutils = require("@react-spectrum/utils");
|
5
|
+
var $hN0b7$reactariafocus = require("@react-aria/focus");
|
6
|
+
var $hN0b7$reactariautils = require("@react-aria/utils");
|
7
|
+
var $hN0b7$reactspectrumprogress = require("@react-spectrum/progress");
|
8
|
+
var $hN0b7$react = require("react");
|
9
|
+
var $hN0b7$reactspectrumtext = require("@react-spectrum/text");
|
10
|
+
var $hN0b7$reactariabutton = require("@react-aria/button");
|
11
|
+
var $hN0b7$reactariainteractions = require("@react-aria/interactions");
|
12
|
+
var $hN0b7$reactariai18n = require("@react-aria/i18n");
|
13
|
+
var $hN0b7$reactspectrumprovider = require("@react-spectrum/provider");
|
14
|
+
|
15
|
+
|
16
|
+
function $parcel$interopDefault(a) {
|
17
|
+
return a && a.__esModule ? a.default : a;
|
18
|
+
}
|
19
|
+
|
20
|
+
function $parcel$export(e, n, v, s) {
|
21
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
22
|
+
}
|
23
|
+
|
24
|
+
$parcel$export(module.exports, "Button", () => $842a195ed1671b15$export$353f5b6fc5456de1);
|
25
|
+
/*
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
30
|
+
*
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
34
|
+
* governing permissions and limitations under the License.
|
35
|
+
*/
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
function $842a195ed1671b15$var$disablePendingProps(props) {
|
48
|
+
// Don't allow interaction while isPending is true
|
49
|
+
if (props.isPending) {
|
50
|
+
props.onPress = undefined;
|
51
|
+
props.onPressStart = undefined;
|
52
|
+
props.onPressEnd = undefined;
|
53
|
+
props.onPressChange = undefined;
|
54
|
+
props.onPressUp = undefined;
|
55
|
+
props.onKeyDown = undefined;
|
56
|
+
props.onKeyUp = undefined;
|
57
|
+
props.onClick = undefined;
|
58
|
+
props.href = undefined;
|
59
|
+
}
|
60
|
+
return props;
|
61
|
+
}
|
62
|
+
function $842a195ed1671b15$var$Button(props, ref) {
|
63
|
+
var _buttonProps_arialabelledby;
|
64
|
+
props = (0, $hN0b7$reactspectrumprovider.useProviderProps)(props);
|
65
|
+
props = (0, $hN0b7$reactspectrumutils.useSlotProps)(props, "button");
|
66
|
+
props = $842a195ed1671b15$var$disablePendingProps(props);
|
67
|
+
let { elementType: Element = "button", children: children, variant: variant, style: style = variant === "accent" || variant === "cta" ? "fill" : "outline", staticColor: staticColor, isDisabled: isDisabled, isPending: isPending, autoFocus: autoFocus, ...otherProps } = props;
|
68
|
+
let domRef = (0, $hN0b7$reactspectrumutils.useFocusableRef)(ref);
|
69
|
+
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $hN0b7$reactariabutton.useButton)(props, domRef);
|
70
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $hN0b7$reactariainteractions.useHover)({
|
71
|
+
isDisabled: isDisabled
|
72
|
+
});
|
73
|
+
let [isFocused, onFocusChange] = (0, $hN0b7$react.useState)(false);
|
74
|
+
let { focusProps: focusProps } = (0, $hN0b7$reactariainteractions.useFocus)({
|
75
|
+
onFocusChange: onFocusChange,
|
76
|
+
isDisabled: isDisabled
|
77
|
+
});
|
78
|
+
let stringFormatter = (0, $hN0b7$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($b2da92ebd9a2bc00$exports))), "@react-spectrum/button");
|
79
|
+
let { styleProps: styleProps } = (0, $hN0b7$reactspectrumutils.useStyleProps)(otherProps);
|
80
|
+
let hasLabel = (0, $hN0b7$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($afc5a4514aca2340$exports)))["spectrum-Button-label"]}`, domRef);
|
81
|
+
let hasIcon = (0, $hN0b7$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($afc5a4514aca2340$exports)))["spectrum-Icon"]}`, domRef);
|
82
|
+
// an aria label will block children and their labels from being read, this is undesirable for pending state
|
83
|
+
let hasAriaLabel = !!buttonProps["aria-label"] || !!buttonProps["aria-labelledby"];
|
84
|
+
let [isProgressVisible, setIsProgressVisible] = (0, $hN0b7$react.useState)(false);
|
85
|
+
let backupButtonId = (0, $hN0b7$reactariautils.useId)();
|
86
|
+
let buttonId = buttonProps.id || backupButtonId;
|
87
|
+
let iconId = (0, $hN0b7$reactariautils.useId)();
|
88
|
+
let textId = (0, $hN0b7$reactariautils.useId)();
|
89
|
+
let spinnerId = (0, $hN0b7$reactariautils.useId)();
|
90
|
+
(0, $hN0b7$react.useEffect)(()=>{
|
91
|
+
let timeout;
|
92
|
+
if (isPending) // Start timer when isPending is set to true.
|
93
|
+
timeout = setTimeout(()=>{
|
94
|
+
setIsProgressVisible(true);
|
95
|
+
}, 1000);
|
96
|
+
else // Exit loading state when isPending is set to false. */
|
97
|
+
setIsProgressVisible(false);
|
98
|
+
return ()=>{
|
99
|
+
// Clean up on unmount or when user removes isPending prop before entering loading state.
|
100
|
+
clearTimeout(timeout);
|
101
|
+
};
|
102
|
+
}, [
|
103
|
+
isPending
|
104
|
+
]);
|
105
|
+
if (variant === "cta") variant = "accent";
|
106
|
+
else if (variant === "overBackground") {
|
107
|
+
variant = "primary";
|
108
|
+
staticColor = "white";
|
109
|
+
}
|
110
|
+
const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps["aria-label"] : ""} ${stringFormatter.format("pending")}`.trim();
|
111
|
+
var _buttonProps_arialabelledby_replace;
|
112
|
+
const isPendingAriaLiveLabelledby = hasAriaLabel ? (_buttonProps_arialabelledby_replace = (_buttonProps_arialabelledby = buttonProps["aria-labelledby"]) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, spinnerId)) !== null && _buttonProps_arialabelledby_replace !== void 0 ? _buttonProps_arialabelledby_replace : spinnerId : `${hasIcon ? iconId : ""} ${hasLabel ? textId : ""} ${spinnerId}`.trim();
|
113
|
+
let ariaLive = "polite";
|
114
|
+
if ((0, $hN0b7$reactariautils.isAppleDevice)() && (!hasAriaLabel || (0, $hN0b7$reactariautils.isFirefox)())) ariaLive = "off";
|
115
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactariafocus.FocusRing), {
|
116
|
+
focusRingClass: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "focus-ring"),
|
117
|
+
autoFocus: autoFocus
|
118
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement(Element, {
|
119
|
+
...styleProps,
|
120
|
+
...(0, $hN0b7$reactariautils.mergeProps)(buttonProps, hoverProps, focusProps),
|
121
|
+
id: buttonId,
|
122
|
+
ref: domRef,
|
123
|
+
"data-variant": variant,
|
124
|
+
"data-style": style,
|
125
|
+
"data-static-color": staticColor || undefined,
|
126
|
+
"aria-disabled": isPending ? "true" : undefined,
|
127
|
+
"aria-label": isPending ? isPendingAriaLiveLabel : buttonProps["aria-label"],
|
128
|
+
"aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps["aria-labelledby"],
|
129
|
+
className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-Button", {
|
130
|
+
"spectrum-Button--iconOnly": hasIcon && !hasLabel,
|
131
|
+
"is-disabled": isDisabled || isProgressVisible,
|
132
|
+
"is-active": isPressed,
|
133
|
+
"is-hovered": isHovered,
|
134
|
+
"spectrum-Button--pending": isProgressVisible
|
135
|
+
}, styleProps.className)
|
136
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumutils.SlotProvider), {
|
137
|
+
slots: {
|
138
|
+
icon: {
|
139
|
+
id: iconId,
|
140
|
+
size: "S",
|
141
|
+
UNSAFE_className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-Icon")
|
142
|
+
},
|
143
|
+
text: {
|
144
|
+
id: textId,
|
145
|
+
UNSAFE_className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-Button-label")
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}, typeof children === "string" ? /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumtext.Text), null, children) : children, isPending && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
|
149
|
+
"aria-hidden": "true",
|
150
|
+
style: {
|
151
|
+
visibility: isProgressVisible ? "visible" : "hidden"
|
152
|
+
},
|
153
|
+
className: (0, $hN0b7$reactspectrumutils.classNames)((0, ($parcel$interopDefault($afc5a4514aca2340$exports))), "spectrum-Button-circleLoader")
|
154
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, $hN0b7$reactspectrumprogress.ProgressCircle), {
|
155
|
+
"aria-label": isPendingAriaLiveLabel,
|
156
|
+
isIndeterminate: true,
|
157
|
+
size: "S",
|
158
|
+
staticColor: staticColor
|
159
|
+
})), isPending && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement((0, ($parcel$interopDefault($hN0b7$react))).Fragment, null, /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
|
160
|
+
"aria-live": isFocused ? ariaLive : "off"
|
161
|
+
}, isProgressVisible && /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
|
162
|
+
role: "img",
|
163
|
+
"aria-labelledby": isPendingAriaLiveLabelledby
|
164
|
+
})), /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).createElement("div", {
|
165
|
+
id: spinnerId,
|
166
|
+
role: "img",
|
167
|
+
"aria-label": isPendingAriaLiveLabel
|
168
|
+
})))));
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Buttons allow users to perform an action or to navigate to another page.
|
172
|
+
* They have multiple styles for various needs, and are ideal for calling attention to
|
173
|
+
* where a user needs to do something in order to move forward in a flow.
|
174
|
+
*/ let $842a195ed1671b15$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, ($parcel$interopDefault($hN0b7$react))).forwardRef($842a195ed1671b15$var$Button);
|
175
|
+
|
176
|
+
|
177
|
+
//# sourceMappingURL=Button.main.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AAyBD,SAAS,0CAAoB,KAAK;IAChC,kDAAkD;IAClD,IAAI,MAAM,SAAS,EAAE;QACnB,MAAM,OAAO,GAAG;QAChB,MAAM,YAAY,GAAG;QACrB,MAAM,UAAU,GAAG;QACnB,MAAM,aAAa,GAAG;QACtB,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;QAClB,MAAM,OAAO,GAAG;QAChB,MAAM,OAAO,GAAG;QAChB,MAAM,IAAI,GAAG;IACf;IACA,OAAO;AACT;AAEA,SAAS,6BAAyC,KAA6B,EAAE,GAA8B;QA2DzD;IA1DpD,QAA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CAAC,aAAa;QAC1E,mBAAiB,YAAY,8BAA8B,WAAW,CAAC,kBAAkB;QACzF,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL,mBACA;YACE,6BAA6B,WAAW,CAAC;YACzC,eAAe,cAAc;YAC7B,aAAa;YACb,cAAc;YACd,4BAA4B;QAC9B,GACA,WAAW,SAAS;qBAGxB,0DAAC,CAAA,GAAA,sCAAW;QACV,OAAO;YACL,MAAM;gBACJ,IAAI;gBACJ,MAAM;gBACN,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;YACvC;YACA,MAAM;gBACJ,IAAI;gBACJ,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;YACvC;QACF;OACC,OAAO,aAAa,yBACjB,0DAAC,CAAA,GAAA,6BAAG,SAAG,YACP,UACH,2BACC,0DAAC;QACC,eAAY;QACZ,OAAO;YAAC,YAAY,oBAAoB,YAAY;QAAQ;QAC5D,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBAC9B,0DAAC,CAAA,GAAA,2CAAa;QACZ,cAAY;QACZ,iBAAA;QACA,MAAK;QACL,aAAa;SAGlB,2BACC,oIACE,0DAAC;QAAI,aAAW,YAAY,WAAW;OACpC,mCACC,0DAAC;QAAI,MAAK;QAAM,mBAAiB;uBAOrC,0DAAC;QAAI,IAAI;QAAW,MAAK;QAAM,cAAY;;AAOzD;AAEA;;;;CAIC,GACD,IAAI,0DAAU,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","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.main.js.map"}
|