@react-spectrum/s2 3.0.0-nightly-adae13c78-241218 → 3.0.0-nightly-50c7ada5d-241220
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/ActionBar.cjs +262 -0
- package/dist/ActionBar.cjs.map +1 -0
- package/dist/ActionBar.css +284 -0
- package/dist/ActionBar.css.map +1 -0
- package/dist/ActionBar.mjs +255 -0
- package/dist/ActionBar.mjs.map +1 -0
- package/dist/ActionButtonGroup.cjs.map +1 -1
- package/dist/ActionButtonGroup.css.map +1 -1
- package/dist/ActionButtonGroup.mjs.map +1 -1
- package/dist/Button.cjs +49 -9
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css +42 -18
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs +49 -9
- package/dist/Button.mjs.map +1 -1
- package/dist/CardView.cjs +33 -6
- package/dist/CardView.cjs.map +1 -1
- package/dist/CardView.css +28 -4
- package/dist/CardView.css.map +1 -1
- package/dist/CardView.mjs +35 -8
- package/dist/CardView.mjs.map +1 -1
- package/dist/CheckboxGroup.cjs +2 -1
- package/dist/CheckboxGroup.cjs.map +1 -1
- package/dist/CheckboxGroup.css.map +1 -1
- package/dist/CheckboxGroup.mjs +2 -1
- package/dist/CheckboxGroup.mjs.map +1 -1
- package/dist/CloseButton.cjs +9 -10
- package/dist/CloseButton.cjs.map +1 -1
- package/dist/CloseButton.css +4 -4
- package/dist/CloseButton.css.map +1 -1
- package/dist/CloseButton.mjs +9 -10
- package/dist/CloseButton.mjs.map +1 -1
- package/dist/TableView.cjs +54 -29
- package/dist/TableView.cjs.map +1 -1
- package/dist/TableView.css +12 -12
- package/dist/TableView.css.map +1 -1
- package/dist/TableView.mjs +55 -30
- package/dist/TableView.mjs.map +1 -1
- package/dist/ar-AE.cjs +10 -2
- package/dist/ar-AE.cjs.map +1 -1
- package/dist/ar-AE.mjs +10 -2
- package/dist/ar-AE.mjs.map +1 -1
- package/dist/bg-BG.cjs +11 -2
- package/dist/bg-BG.cjs.map +1 -1
- package/dist/bg-BG.mjs +11 -2
- package/dist/bg-BG.mjs.map +1 -1
- package/dist/cs-CZ.cjs +7 -2
- package/dist/cs-CZ.cjs.map +1 -1
- package/dist/cs-CZ.mjs +7 -2
- package/dist/cs-CZ.mjs.map +1 -1
- package/dist/da-DK.cjs +12 -4
- package/dist/da-DK.cjs.map +1 -1
- package/dist/da-DK.mjs +12 -4
- package/dist/da-DK.mjs.map +1 -1
- package/dist/de-DE.cjs +11 -2
- package/dist/de-DE.cjs.map +1 -1
- package/dist/de-DE.mjs +11 -2
- package/dist/de-DE.mjs.map +1 -1
- package/dist/el-GR.cjs +11 -2
- package/dist/el-GR.cjs.map +1 -1
- package/dist/el-GR.mjs +11 -2
- package/dist/el-GR.mjs.map +1 -1
- package/dist/en-US.cjs +8 -0
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +8 -0
- package/dist/en-US.mjs.map +1 -1
- package/dist/es-ES.cjs +11 -2
- package/dist/es-ES.cjs.map +1 -1
- package/dist/es-ES.mjs +11 -2
- package/dist/es-ES.mjs.map +1 -1
- package/dist/et-EE.cjs +10 -2
- package/dist/et-EE.cjs.map +1 -1
- package/dist/et-EE.mjs +10 -2
- package/dist/et-EE.mjs.map +1 -1
- package/dist/fi-FI.cjs +10 -2
- package/dist/fi-FI.cjs.map +1 -1
- package/dist/fi-FI.mjs +10 -2
- package/dist/fi-FI.mjs.map +1 -1
- package/dist/fr-FR.cjs +11 -2
- package/dist/fr-FR.cjs.map +1 -1
- package/dist/fr-FR.mjs +11 -2
- package/dist/fr-FR.mjs.map +1 -1
- package/dist/he-IL.cjs +11 -2
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +11 -2
- package/dist/he-IL.mjs.map +1 -1
- package/dist/hr-HR.cjs +7 -2
- package/dist/hr-HR.cjs.map +1 -1
- package/dist/hr-HR.mjs +7 -2
- package/dist/hr-HR.mjs.map +1 -1
- package/dist/hu-HU.cjs +10 -2
- package/dist/hu-HU.cjs.map +1 -1
- package/dist/hu-HU.mjs +10 -2
- package/dist/hu-HU.mjs.map +1 -1
- package/dist/it-IT.cjs +11 -2
- package/dist/it-IT.cjs.map +1 -1
- package/dist/it-IT.mjs +11 -2
- package/dist/it-IT.mjs.map +1 -1
- package/dist/ja-JP.cjs +10 -2
- package/dist/ja-JP.cjs.map +1 -1
- package/dist/ja-JP.mjs +10 -2
- package/dist/ja-JP.mjs.map +1 -1
- package/dist/ko-KR.cjs +12 -4
- package/dist/ko-KR.cjs.map +1 -1
- package/dist/ko-KR.mjs +12 -4
- package/dist/ko-KR.mjs.map +1 -1
- package/dist/lt-LT.cjs +9 -4
- package/dist/lt-LT.cjs.map +1 -1
- package/dist/lt-LT.mjs +9 -4
- package/dist/lt-LT.mjs.map +1 -1
- package/dist/lv-LV.cjs +11 -3
- package/dist/lv-LV.cjs.map +1 -1
- package/dist/lv-LV.mjs +11 -3
- package/dist/lv-LV.mjs.map +1 -1
- package/dist/main.cjs +4 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +3 -1
- package/dist/module.mjs.map +1 -1
- package/dist/nb-NO.cjs +9 -4
- package/dist/nb-NO.cjs.map +1 -1
- package/dist/nb-NO.mjs +9 -4
- package/dist/nb-NO.mjs.map +1 -1
- package/dist/nl-NL.cjs +10 -2
- package/dist/nl-NL.cjs.map +1 -1
- package/dist/nl-NL.mjs +10 -2
- package/dist/nl-NL.mjs.map +1 -1
- package/dist/pl-PL.cjs +8 -3
- package/dist/pl-PL.cjs.map +1 -1
- package/dist/pl-PL.mjs +8 -3
- package/dist/pl-PL.mjs.map +1 -1
- package/dist/pt-BR.cjs +11 -2
- package/dist/pt-BR.cjs.map +1 -1
- package/dist/pt-BR.mjs +11 -2
- package/dist/pt-BR.mjs.map +1 -1
- package/dist/pt-PT.cjs +11 -2
- package/dist/pt-PT.cjs.map +1 -1
- package/dist/pt-PT.mjs +11 -2
- package/dist/pt-PT.mjs.map +1 -1
- package/dist/ro-RO.cjs +12 -3
- package/dist/ro-RO.cjs.map +1 -1
- package/dist/ro-RO.mjs +12 -3
- package/dist/ro-RO.mjs.map +1 -1
- package/dist/ru-RU.cjs +7 -2
- package/dist/ru-RU.cjs.map +1 -1
- package/dist/ru-RU.mjs +7 -2
- package/dist/ru-RU.mjs.map +1 -1
- package/dist/sk-SK.cjs +7 -2
- package/dist/sk-SK.cjs.map +1 -1
- package/dist/sk-SK.mjs +7 -2
- package/dist/sk-SK.mjs.map +1 -1
- package/dist/sl-SI.cjs +7 -2
- package/dist/sl-SI.cjs.map +1 -1
- package/dist/sl-SI.mjs +7 -2
- package/dist/sl-SI.mjs.map +1 -1
- package/dist/sr-SP.cjs +7 -2
- package/dist/sr-SP.cjs.map +1 -1
- package/dist/sr-SP.mjs +7 -2
- package/dist/sr-SP.mjs.map +1 -1
- package/dist/sv-SE.cjs +11 -2
- package/dist/sv-SE.cjs.map +1 -1
- package/dist/sv-SE.mjs +11 -2
- package/dist/sv-SE.mjs.map +1 -1
- package/dist/tr-TR.cjs +10 -2
- package/dist/tr-TR.cjs.map +1 -1
- package/dist/tr-TR.mjs +10 -2
- package/dist/tr-TR.mjs.map +1 -1
- package/dist/types.d.ts +34 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.cjs +7 -2
- package/dist/uk-UA.cjs.map +1 -1
- package/dist/uk-UA.mjs +7 -2
- package/dist/uk-UA.mjs.map +1 -1
- package/dist/zh-CN.cjs +10 -2
- package/dist/zh-CN.cjs.map +1 -1
- package/dist/zh-CN.mjs +10 -2
- package/dist/zh-CN.mjs.map +1 -1
- package/dist/zh-TW.cjs +10 -2
- package/dist/zh-TW.cjs.map +1 -1
- package/dist/zh-TW.mjs +10 -2
- package/dist/zh-TW.mjs.map +1 -1
- package/package.json +19 -18
- package/src/ActionBar.tsx +235 -0
- package/src/ActionButtonGroup.tsx +3 -2
- package/src/Button.tsx +56 -7
- package/src/CardView.tsx +35 -8
- package/src/CheckboxGroup.tsx +1 -1
- package/src/CloseButton.tsx +4 -5
- package/src/TableView.tsx +32 -18
- package/src/index.ts +2 -0
- package/style/dist/main.cjs +1 -0
- package/style/dist/main.cjs.map +1 -1
- package/style/dist/module.mjs +2 -2
- package/style/dist/module.mjs.map +1 -1
- package/style/dist/spectrum-theme.cjs +4 -0
- package/style/dist/spectrum-theme.cjs.map +1 -1
- package/style/dist/spectrum-theme.mjs +4 -1
- package/style/dist/spectrum-theme.mjs.map +1 -1
- package/style/dist/types.d.ts +1 -0
- package/style/dist/types.d.ts.map +1 -1
- package/style/index.ts +1 -1
- package/style/spectrum-theme.ts +4 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import "./ActionBar.css";
|
|
2
|
+
import {ActionButtonGroup as $10401bdc118cbc90$export$73d695ae27330056} from "./ActionButtonGroup.mjs";
|
|
3
|
+
import {CloseButton as $a9cda54c4f47ce52$export$de65de8213222d10} from "./CloseButton.mjs";
|
|
4
|
+
import $kxwJw$intlStringsmjs from "./intlStrings.mjs";
|
|
5
|
+
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
|
|
6
|
+
import {jsx as $kxwJw$jsx, jsxs as $kxwJw$jsxs} from "react/jsx-runtime";
|
|
7
|
+
import {announce as $kxwJw$announce} from "@react-aria/live-announcer";
|
|
8
|
+
import {createContext as $kxwJw$createContext, forwardRef as $kxwJw$forwardRef, useState as $kxwJw$useState, useCallback as $kxwJw$useCallback, useRef as $kxwJw$useRef, useEffect as $kxwJw$useEffect, useMemo as $kxwJw$useMemo} from "react";
|
|
9
|
+
import {useKeyboard as $kxwJw$useKeyboard, FocusScope as $kxwJw$FocusScope} from "react-aria";
|
|
10
|
+
import {useControlledState as $kxwJw$useControlledState} from "@react-stately/utils";
|
|
11
|
+
import {useDOMRef as $kxwJw$useDOMRef} from "@react-spectrum/utils";
|
|
12
|
+
import {useExitAnimation as $kxwJw$useExitAnimation, useResizeObserver as $kxwJw$useResizeObserver} from "@react-aria/utils";
|
|
13
|
+
import {useLocalizedStringFormatter as $kxwJw$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
/*
|
|
20
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
21
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
23
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
26
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
27
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
28
|
+
* governing permissions and limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const $f21f2186348fbc5b$var$slideIn = "-d9bqcx";
|
|
42
|
+
const $f21f2186348fbc5b$var$slideOut = "-e7i2y9";
|
|
43
|
+
const $f21f2186348fbc5b$var$actionBarStyles = function anonymous(props) {
|
|
44
|
+
let rules = " .";
|
|
45
|
+
rules += ' _vd';
|
|
46
|
+
rules += ' _wd';
|
|
47
|
+
rules += ' _xd';
|
|
48
|
+
rules += ' _yd';
|
|
49
|
+
if (props.isEmphasized) {
|
|
50
|
+
if (props.isPressed) rules += ' -_1de2x0q_b-o';
|
|
51
|
+
else if (props.isFocusVisible) rules += ' -_1de2x0q_b-o';
|
|
52
|
+
else if (props.isHovered) rules += ' -_1de2x0q_b-o';
|
|
53
|
+
else rules += ' -_1de2x0q_b-n';
|
|
54
|
+
} else rules += ' -_1de2x0q_b-______x';
|
|
55
|
+
rules += ' b-1de2x0q';
|
|
56
|
+
rules += ' _tb';
|
|
57
|
+
rules += ' __na';
|
|
58
|
+
rules += ' _Lb';
|
|
59
|
+
rules += ' _Nb';
|
|
60
|
+
rules += ' _M-3hmpv';
|
|
61
|
+
rules += ' da_____I';
|
|
62
|
+
if (props.isEmphasized) rules += ' da';
|
|
63
|
+
else rules += ' dh';
|
|
64
|
+
rules += ' Cd';
|
|
65
|
+
rules += ' Dd';
|
|
66
|
+
rules += ' Ee';
|
|
67
|
+
rules += ' Fe';
|
|
68
|
+
rules += ' _Zd';
|
|
69
|
+
rules += ' if';
|
|
70
|
+
rules += ' jf';
|
|
71
|
+
rules += ' _1c';
|
|
72
|
+
if (props.isInContainer) rules += ' Ua';
|
|
73
|
+
rules += ' Zd';
|
|
74
|
+
rules += ' Vd';
|
|
75
|
+
rules += ' -w2j5q1_W-d';
|
|
76
|
+
if (props.isInContainer) rules += ' la';
|
|
77
|
+
else rules += ' lb';
|
|
78
|
+
rules += ' y_d';
|
|
79
|
+
rules += ' z_d';
|
|
80
|
+
rules += ' r_______________T';
|
|
81
|
+
if (props.isExiting) rules += ' _S-y93obf';
|
|
82
|
+
else if (props.isInContainer) rules += ' _S-xn3rp9';
|
|
83
|
+
rules += ' _T-375xx3';
|
|
84
|
+
if (props.isExiting) rules += ' _Ya';
|
|
85
|
+
else if (props.isInContainer) rules += ' _Ya';
|
|
86
|
+
return rules;
|
|
87
|
+
};
|
|
88
|
+
const $f21f2186348fbc5b$export$9f306827c48feef4 = /*#__PURE__*/ (0, $kxwJw$createContext)(null);
|
|
89
|
+
const $f21f2186348fbc5b$export$e213cebad6250b4a = /*#__PURE__*/ (0, $kxwJw$forwardRef)(function ActionBar(props, ref) {
|
|
90
|
+
[props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $f21f2186348fbc5b$export$9f306827c48feef4);
|
|
91
|
+
let domRef = (0, $kxwJw$useDOMRef)(ref);
|
|
92
|
+
let isOpen = props.selectedItemCount !== 0;
|
|
93
|
+
let isExiting = (0, $kxwJw$useExitAnimation)(domRef, isOpen && props.scrollRef != null);
|
|
94
|
+
if (!isOpen && !isExiting) return null;
|
|
95
|
+
return /*#__PURE__*/ (0, $kxwJw$jsx)($f21f2186348fbc5b$var$ActionBarInner, {
|
|
96
|
+
...props,
|
|
97
|
+
ref: domRef,
|
|
98
|
+
isExiting: isExiting
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
const $f21f2186348fbc5b$var$ActionBarInner = /*#__PURE__*/ (0, $kxwJw$forwardRef)(function ActionBarInner(props1, ref) {
|
|
102
|
+
let { isEmphasized: isEmphasized, selectedItemCount: selectedItemCount = 0, children: children, onClearSelection: onClearSelection, isExiting: isExiting } = props1;
|
|
103
|
+
let stringFormatter = (0, $kxwJw$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kxwJw$intlStringsmjs))), '@react-spectrum/s2');
|
|
104
|
+
// Store the last count greater than zero so that we can retain it while rendering the fade-out animation.
|
|
105
|
+
let [lastCount, setLastCount] = (0, $kxwJw$useState)(selectedItemCount);
|
|
106
|
+
if ((selectedItemCount === 'all' || selectedItemCount > 0) && selectedItemCount !== lastCount) setLastCount(selectedItemCount);
|
|
107
|
+
// Measure the width of the collection's scrollbar and offset the action bar by that amount.
|
|
108
|
+
let scrollRef = props1.scrollRef;
|
|
109
|
+
let [scrollbarWidth, setScrollbarWidth] = (0, $kxwJw$useState)(0);
|
|
110
|
+
let updateScrollbarWidth = (0, $kxwJw$useCallback)(()=>{
|
|
111
|
+
let el = scrollRef?.current;
|
|
112
|
+
if (el) {
|
|
113
|
+
let w = el.offsetWidth - el.clientWidth;
|
|
114
|
+
setScrollbarWidth(w);
|
|
115
|
+
}
|
|
116
|
+
}, [
|
|
117
|
+
scrollRef
|
|
118
|
+
]);
|
|
119
|
+
(0, $kxwJw$useResizeObserver)({
|
|
120
|
+
ref: scrollRef,
|
|
121
|
+
onResize: updateScrollbarWidth
|
|
122
|
+
});
|
|
123
|
+
let { keyboardProps: keyboardProps } = (0, $kxwJw$useKeyboard)({
|
|
124
|
+
onKeyDown (e) {
|
|
125
|
+
if (e.key === 'Escape') {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
onClearSelection?.();
|
|
128
|
+
} else e.continuePropagation();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// Announce "actions available" on mount.
|
|
132
|
+
let isInitial = (0, $kxwJw$useRef)(true);
|
|
133
|
+
(0, $kxwJw$useEffect)(()=>{
|
|
134
|
+
if (isInitial.current && scrollRef) {
|
|
135
|
+
isInitial.current = false;
|
|
136
|
+
(0, $kxwJw$announce)(stringFormatter.format('actionbar.actionsAvailable'));
|
|
137
|
+
}
|
|
138
|
+
}, [
|
|
139
|
+
stringFormatter,
|
|
140
|
+
scrollRef
|
|
141
|
+
]);
|
|
142
|
+
return /*#__PURE__*/ (0, $kxwJw$jsx)((0, $kxwJw$FocusScope), {
|
|
143
|
+
restoreFocus: true,
|
|
144
|
+
children: /*#__PURE__*/ (0, $kxwJw$jsxs)("div", {
|
|
145
|
+
ref: ref,
|
|
146
|
+
...keyboardProps,
|
|
147
|
+
className: $f21f2186348fbc5b$var$actionBarStyles({
|
|
148
|
+
isEmphasized: isEmphasized,
|
|
149
|
+
isInContainer: !!scrollRef,
|
|
150
|
+
isExiting: isExiting
|
|
151
|
+
}),
|
|
152
|
+
style: {
|
|
153
|
+
insetInlineEnd: `calc(var(--insetEnd) + ${scrollbarWidth}px)`
|
|
154
|
+
},
|
|
155
|
+
children: [
|
|
156
|
+
/*#__PURE__*/ (0, $kxwJw$jsx)("div", {
|
|
157
|
+
className: " . __A-3t1y y_d",
|
|
158
|
+
children: /*#__PURE__*/ (0, $kxwJw$jsx)((0, $10401bdc118cbc90$export$73d695ae27330056), {
|
|
159
|
+
staticColor: isEmphasized ? 'auto' : undefined,
|
|
160
|
+
isQuiet: true,
|
|
161
|
+
"aria-label": stringFormatter.format('actionbar.actions'),
|
|
162
|
+
children: children
|
|
163
|
+
})
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ (0, $kxwJw$jsxs)("div", {
|
|
166
|
+
className: " . __A-3t1x _Zd _1c ic jc",
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ (0, $kxwJw$jsx)((0, $a9cda54c4f47ce52$export$de65de8213222d10), {
|
|
169
|
+
staticColor: isEmphasized ? 'auto' : undefined,
|
|
170
|
+
"aria-label": stringFormatter.format('actionbar.clearSelection'),
|
|
171
|
+
onPress: ()=>onClearSelection?.()
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ (0, $kxwJw$jsx)("span", {
|
|
174
|
+
className: function anonymous(props) {
|
|
175
|
+
let rules = " .";
|
|
176
|
+
rules += ' _c-bc1l9oh';
|
|
177
|
+
rules += ' _c-1uotwbwg';
|
|
178
|
+
rules += ' _c-eo0c6sf';
|
|
179
|
+
rules += ' _c-enzzrge';
|
|
180
|
+
rules += ' _c-enzykdd';
|
|
181
|
+
rules += ' _c-enzwzjc';
|
|
182
|
+
rules += ' _c-enzrfpb';
|
|
183
|
+
rules += ' _ca';
|
|
184
|
+
rules += ' _dbf';
|
|
185
|
+
rules += ' _de';
|
|
186
|
+
rules += ' _eb';
|
|
187
|
+
rules += ' _f-1x99dlob';
|
|
188
|
+
rules += ' _fa';
|
|
189
|
+
if (props.isEmphasized) rules += ' ad';
|
|
190
|
+
else {
|
|
191
|
+
if (props.isPressed) rules += ' ao';
|
|
192
|
+
else if (props.isFocusVisible) rules += ' ao';
|
|
193
|
+
else if (props.isHovered) rules += ' ao';
|
|
194
|
+
else rules += ' an';
|
|
195
|
+
}
|
|
196
|
+
return rules;
|
|
197
|
+
}({
|
|
198
|
+
isEmphasized: isEmphasized
|
|
199
|
+
}),
|
|
200
|
+
children: lastCount === 'all' ? stringFormatter.format('actionbar.selectedAll') : stringFormatter.format('actionbar.selected', {
|
|
201
|
+
count: lastCount
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
function $f21f2186348fbc5b$export$13f32e21845e01d0(props) {
|
|
211
|
+
let { renderActionBar: renderActionBar, scrollRef: scrollRef } = props;
|
|
212
|
+
let [selectedKeys, setSelectedKeys] = (0, $kxwJw$useControlledState)(props.selectedKeys, props.defaultSelectedKeys || new Set(), props.onSelectionChange);
|
|
213
|
+
let selectedKeysSet = (0, $kxwJw$useMemo)(()=>selectedKeys === 'all' ? selectedKeys : new Set(selectedKeys), [
|
|
214
|
+
selectedKeys
|
|
215
|
+
]);
|
|
216
|
+
let actionBar = (0, $kxwJw$useMemo)(()=>renderActionBar?.(selectedKeysSet), [
|
|
217
|
+
renderActionBar,
|
|
218
|
+
selectedKeysSet
|
|
219
|
+
]);
|
|
220
|
+
let selectedItemCount = selectedKeysSet === 'all' ? 'all' : selectedKeysSet.size;
|
|
221
|
+
let [actionBarHeight, setActionBarHeight] = (0, $kxwJw$useState)(0);
|
|
222
|
+
let actionBarRef = (0, $kxwJw$useCallback)((ref)=>{
|
|
223
|
+
let actionBar = ref?.UNSAFE_getDOMNode();
|
|
224
|
+
if (actionBar) setActionBarHeight(actionBar.offsetHeight + 8);
|
|
225
|
+
else setActionBarHeight(0);
|
|
226
|
+
}, []);
|
|
227
|
+
let actionBarContext = (0, $kxwJw$useMemo)(()=>({
|
|
228
|
+
ref: actionBarRef,
|
|
229
|
+
scrollRef: scrollRef,
|
|
230
|
+
selectedItemCount: selectedItemCount,
|
|
231
|
+
onClearSelection: ()=>setSelectedKeys(new Set())
|
|
232
|
+
}), [
|
|
233
|
+
scrollRef,
|
|
234
|
+
actionBarRef,
|
|
235
|
+
selectedItemCount,
|
|
236
|
+
setSelectedKeys
|
|
237
|
+
]);
|
|
238
|
+
let wrappedActionBar = (0, $kxwJw$useMemo)(()=>/*#__PURE__*/ (0, $kxwJw$jsx)($f21f2186348fbc5b$export$9f306827c48feef4.Provider, {
|
|
239
|
+
value: actionBarContext,
|
|
240
|
+
children: actionBar
|
|
241
|
+
}), [
|
|
242
|
+
actionBarContext,
|
|
243
|
+
actionBar
|
|
244
|
+
]);
|
|
245
|
+
return {
|
|
246
|
+
selectedKeys: selectedKeys,
|
|
247
|
+
onSelectionChange: setSelectedKeys,
|
|
248
|
+
actionBar: wrappedActionBar,
|
|
249
|
+
actionBarHeight: actionBarHeight
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
export {$f21f2186348fbc5b$export$9f306827c48feef4 as ActionBarContext, $f21f2186348fbc5b$export$e213cebad6250b4a as ActionBar, $f21f2186348fbc5b$export$13f32e21845e01d0 as useActionBarContainer};
|
|
255
|
+
//# sourceMappingURL=ActionBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AAmBD,MAAM;AAKN,MAAM;AAKN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DC,MAAM,0DAAmB,CAAA,GAAA,oBAAY,EAAsE;AAE3G,MAAM,0DAAY,CAAA,GAAA,iBAAS,EAAE,SAAS,UAAU,KAAqB,EAAE,GAA2B;IACvG,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,IAAI,SAAS,MAAM,iBAAiB,KAAK;IACzC,IAAI,YAAY,CAAA,GAAA,uBAAe,EAAE,QAAQ,UAAU,MAAM,SAAS,IAAI;IACtE,IAAI,CAAC,UAAU,CAAC,WACd,OAAO;IAGT,qBAAO,gBAAC;QAAgB,GAAG,KAAK;QAAE,KAAK;QAAQ,WAAW;;AAC5D;AAEA,MAAM,qDAAiB,CAAA,GAAA,iBAAS,EAAE,SAAS,eAAe,M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AE5C,mBAAmB;IAEvB,GAAG,EAAE;IAEL,IAAI,mBAAmB,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YACpC,KAAK;uBACL;+BACA;YACA,kBAAkB,IAAM,gBAAgB,IAAI;QAC9C,CAAA,GAAI;QAAC;QAAW;QAAc;QAAmB;KAAgB;IAEjE,IAAI,mBAAmB,CAAA,GAAA,cAAM,EAAE,kBAC7B,gBAAC,0CAAiB,QAAQ;YAAC,OAAO;sBAC/B;YAEF;QAAC;QAAkB;KAAU;IAEhC,OAAO;sBACL;QACA,mBAAmB;QACnB,WAAW;yBACX;IACF;AACF","sources":["packages/@react-spectrum/s2/src/ActionBar.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ActionButtonGroup} from './ActionButtonGroup';\nimport {announce} from '@react-aria/live-announcer';\nimport {CloseButton} from './CloseButton';\nimport {ContextValue, SlotProps} from 'react-aria-components';\nimport {createContext, ForwardedRef, forwardRef, ReactElement, ReactNode, RefObject, useCallback, useEffect, useMemo, useRef, useState} from 'react';\nimport {DOMRef, DOMRefValue, Key} from '@react-types/shared';\nimport {FocusScope, useKeyboard} from 'react-aria';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {style} from '../style' with {type: 'macro'};\nimport {useControlledState} from '@react-stately/utils';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useExitAnimation, useResizeObserver} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nconst slideIn = keyframes(`\n from { transform: translateY(100%); opacity: 0 }\n to { transform: translateY(0px); opacity: 1 }\n`);\n\nconst slideOut = keyframes(`\n from { transform: translateY(0px); opacity: 1 }\n to { transform: translateY(100%); opacity: 0 }\n`);\n\nconst actionBarStyles = style({\n borderRadius: 'lg',\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: {\n default: 'elevated',\n isEmphasized: 'neutral'\n }\n },\n backgroundColor: '--s2-container-bg',\n boxShadow: 'elevated',\n boxSizing: 'border-box',\n outlineStyle: 'solid',\n outlineWidth: 1,\n outlineOffset: -1,\n outlineColor: {\n default: 'gray-200',\n isEmphasized: 'transparent',\n forcedColors: 'ButtonBorder'\n },\n paddingX: 8,\n paddingY: 12,\n display: 'flex',\n gap: 16,\n alignItems: 'center',\n position: {\n isInContainer: 'absolute'\n },\n bottom: 8,\n insetStart: 8,\n '--insetEnd': {\n type: 'insetEnd',\n value: 8\n },\n width: {\n default: 'full',\n isInContainer: 'auto'\n },\n marginX: 'auto',\n maxWidth: 960,\n animation: {\n isInContainer: slideIn,\n isExiting: slideOut\n },\n animationDuration: 200\n});\n\nexport interface ActionBarProps extends SlotProps {\n /** A list of ActionButtons to display. */\n children: ReactNode,\n /** Whether the ActionBar should be displayed with a emphasized style. */\n isEmphasized?: boolean,\n /** The number of selected items that the ActionBar is currently linked to. If 0, the ActionBar is hidden. */\n selectedItemCount?: number | 'all',\n /** Handler that is called when the ActionBar clear button is pressed. */\n onClearSelection?: () => void,\n /** A ref to the scrollable element the ActionBar appears above. */\n scrollRef?: RefObject<HTMLElement | null>\n}\n\nexport const ActionBarContext = createContext<ContextValue<Partial<ActionBarProps>, DOMRefValue<HTMLDivElement>>>(null);\n\nexport const ActionBar = forwardRef(function ActionBar(props: ActionBarProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ActionBarContext);\n let domRef = useDOMRef(ref);\n\n let isOpen = props.selectedItemCount !== 0;\n let isExiting = useExitAnimation(domRef, isOpen && props.scrollRef != null);\n if (!isOpen && !isExiting) {\n return null;\n }\n\n return <ActionBarInner {...props} ref={domRef} isExiting={isExiting} />;\n});\n\nconst ActionBarInner = forwardRef(function ActionBarInner(props: ActionBarProps & {isExiting: boolean}, ref: ForwardedRef<HTMLDivElement | null>) {\n let {isEmphasized, selectedItemCount = 0, children, onClearSelection, isExiting} = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n\n // Store the last count greater than zero so that we can retain it while rendering the fade-out animation.\n let [lastCount, setLastCount] = useState(selectedItemCount);\n if ((selectedItemCount === 'all' || selectedItemCount > 0) && selectedItemCount !== lastCount) {\n setLastCount(selectedItemCount);\n }\n \n // Measure the width of the collection's scrollbar and offset the action bar by that amount.\n let scrollRef = props.scrollRef;\n let [scrollbarWidth, setScrollbarWidth] = useState(0);\n let updateScrollbarWidth = useCallback(() => {\n let el = scrollRef?.current;\n if (el) {\n let w = el.offsetWidth - el.clientWidth;\n setScrollbarWidth(w);\n }\n }, [scrollRef]);\n\n useResizeObserver({\n ref: scrollRef,\n onResize: updateScrollbarWidth\n });\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n if (e.key === 'Escape') {\n e.preventDefault();\n onClearSelection?.();\n } else {\n e.continuePropagation();\n }\n }\n });\n\n // Announce \"actions available\" on mount.\n let isInitial = useRef(true);\n useEffect(() => {\n if (isInitial.current && scrollRef) {\n isInitial.current = false;\n announce(stringFormatter.format('actionbar.actionsAvailable'));\n }\n }, [stringFormatter, scrollRef]);\n\n return (\n <FocusScope restoreFocus>\n <div\n ref={ref}\n {...keyboardProps}\n className={actionBarStyles({isEmphasized, isInContainer: !!scrollRef, isExiting})}\n style={{insetInlineEnd: `calc(var(--insetEnd) + ${scrollbarWidth}px)`}}>\n <div className={style({order: 1, marginStart: 'auto'})}>\n <ActionButtonGroup\n staticColor={isEmphasized ? 'auto' : undefined}\n isQuiet\n aria-label={stringFormatter.format('actionbar.actions')}>\n {children}\n </ActionButtonGroup>\n </div>\n <div className={style({order: 0, display: 'flex', alignItems: 'center', gap: 4})}>\n <CloseButton\n staticColor={isEmphasized ? 'auto' : undefined}\n aria-label={stringFormatter.format('actionbar.clearSelection')}\n onPress={() => onClearSelection?.()} />\n <span className={style({font: 'ui', color: {default: 'neutral', isEmphasized: 'gray-25'}})({isEmphasized})}>\n {lastCount === 'all'\n ? stringFormatter.format('actionbar.selectedAll')\n : stringFormatter.format('actionbar.selected', {count: lastCount})}\n </span>\n </div>\n </div>\n </FocusScope>\n );\n});\n\ninterface ActionBarContainerHookProps {\n selectedKeys?: 'all' | Iterable<Key>,\n defaultSelectedKeys?: 'all' | Iterable<Key>,\n onSelectionChange?: (keys: Set<Key>) => void,\n renderActionBar?: (selectedKeys: 'all' | Set<Key>) => ReactElement,\n scrollRef?: RefObject<HTMLElement | null>\n}\n\nexport function useActionBarContainer(props: ActionBarContainerHookProps) {\n let {renderActionBar, scrollRef} = props;\n let [selectedKeys, setSelectedKeys] = useControlledState(props.selectedKeys, props.defaultSelectedKeys || new Set(), props.onSelectionChange);\n let selectedKeysSet = useMemo(() => selectedKeys === 'all' ? selectedKeys as 'all' : new Set(selectedKeys), [selectedKeys]);\n let actionBar = useMemo(() => renderActionBar?.(selectedKeysSet), [renderActionBar, selectedKeysSet]);\n let selectedItemCount = selectedKeysSet === 'all' ? 'all' as const : selectedKeysSet.size;\n let [actionBarHeight, setActionBarHeight] = useState(0);\n let actionBarRef = useCallback((ref: DOMRefValue | null) => {\n let actionBar = ref?.UNSAFE_getDOMNode();\n if (actionBar) {\n setActionBarHeight(actionBar.offsetHeight + 8);\n } else {\n setActionBarHeight(0);\n }\n }, []);\n\n let actionBarContext = useMemo(() => ({\n ref: actionBarRef,\n scrollRef,\n selectedItemCount,\n onClearSelection: () => setSelectedKeys(new Set())\n }), [scrollRef, actionBarRef, selectedItemCount, setSelectedKeys]);\n\n let wrappedActionBar = useMemo(() => (\n <ActionBarContext.Provider value={actionBarContext}>\n {actionBar}\n </ActionBarContext.Provider>\n ), [actionBarContext, actionBar]);\n\n return {\n selectedKeys,\n onSelectionChange: setSelectedKeys,\n actionBar: wrappedActionBar,\n actionBarHeight\n };\n}\n"],"names":[],"version":3,"file":"ActionBar.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAuCM,MAAM;;;;;;;;;;;;;;;;;;;;;;;AAyBN,MAAM,0DAA2B,CAAA,GAAA,0BAAY,EAAiE;AAK9G,MAAM,0DAAoB,CAAA,GAAA,uBAAS,EAAE,SAAS,kBAAkB,KAA6B,EAAE,GAAiC;IACrI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,WACF,UAAU,iBACV,OAAO,kBACP,cAAc,2BACd,WAAW,YACX,QAAQ,oBACR,mBAAmB,kBACnB,YAAY,UACZ,MAAM,EACP,GAAG;IAEJ,qBACE,gCAAC,CAAA,GAAA,kCAAM;QACJ,GAAG,KAAK;QACT,KAAK;QACL,OAAO;QACP,WAAW,mBAAmB,0CAAiB;kBAAC;qBAAM;yBAAS;yBAAa;QAAW,GAAG;kBAC1F,cAAA,gCAAC,0CAAyB,QAAQ;YAAC,OAAO;sBACvC;;;AAIT","sources":["packages/@react-spectrum/s2/src/ActionButtonGroup.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps} from '@react-types/shared';\nimport {ContextValue, SlotProps, Toolbar} from 'react-aria-components';\nimport {createContext, ForwardedRef, forwardRef, ReactNode} from 'react';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {style} from '../style' with {type: 'macro'};\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ActionButtonGroupProps extends AriaLabelingProps, UnsafeStyles, SlotProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /** The children of the group. */\n children: ReactNode,\n /**\n * Size of the buttons.\n * @default \"M\"\n */\n size?: 'XS' | 'S' | 'M' | 'L' | 'XL',\n /**\n * Spacing between the buttons.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular',\n /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */\n isQuiet?: boolean,\n /** Whether the buttons should divide the container width equally. */\n isJustified?: boolean,\n /** Whether the button should be displayed with an [emphasized style](https://spectrum.adobe.com/page/action-button/#Emphasis). */\n staticColor?: 'white' | 'black' | 'auto',\n /**\n * The axis the group should align with.\n * @default 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical',\n /** Whether the group is disabled. */\n isDisabled?: boolean\n}\n\nexport const actionGroupStyle = style({\n display: 'flex',\n flexDirection: {\n orientation: {\n horizontal: 'row',\n vertical: 'column'\n }\n },\n gap: {\n density: {\n compact: 2,\n regular: {\n size: {\n XS: 4,\n S: 4,\n M: 8,\n L: 8,\n XL: 8\n }\n }\n }\n }\n}, getAllowedOverrides({height: true}));\n\n\nexport const ActionButtonGroupContext = createContext<ContextValue<Partial<ActionButtonGroupProps>, HTMLDivElement>>(null);\n\n/**\n * An ActionButtonGroup is a grouping of related ActionButtons.\n */\nexport const ActionButtonGroup = forwardRef(function ActionButtonGroup(props: ActionButtonGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ActionButtonGroupContext);\n let {\n density = 'regular',\n size = 'M',\n orientation = 'horizontal',\n isJustified,\n children,\n UNSAFE_className = '',\n UNSAFE_style,\n styles\n } = props;\n\n return (\n <Toolbar\n {...props}\n ref={ref}\n style={UNSAFE_style}\n className={UNSAFE_className + actionGroupStyle({size, density, orientation, isJustified}, styles)}>\n <ActionButtonGroupContext.Provider value={props}>\n {children}\n </ActionButtonGroupContext.Provider>\n </Toolbar>\n );\n});\n"],"names":[],"version":3,"file":"ActionButtonGroup.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":"AAiDgC;;;;AAAA;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAAA","sources":["packages/@react-spectrum/s2/src/ActionButtonGroup.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps} from '@react-types/shared';\nimport {ContextValue, SlotProps, Toolbar} from 'react-aria-components';\nimport {createContext, ForwardedRef, forwardRef, ReactNode} from 'react';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {style} from '../style' with {type: 'macro'};\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ActionButtonGroupProps extends AriaLabelingProps, UnsafeStyles, SlotProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /** The children of the group. */\n children: ReactNode,\n /**\n * Size of the buttons.\n * @default \"M\"\n */\n size?: 'XS' | 'S' | 'M' | 'L' | 'XL',\n /**\n * Spacing between the buttons.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular',\n /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */\n isQuiet?: boolean,\n /** Whether the buttons should divide the container width equally. */\n isJustified?: boolean,\n /** Whether the button should be displayed with an [emphasized style](https://spectrum.adobe.com/page/action-button/#Emphasis). */\n staticColor?: 'white' | 'black' | 'auto',\n /**\n * The axis the group should align with.\n * @default 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical',\n /** Whether the group is disabled. */\n isDisabled?: boolean\n}\n\nexport const actionGroupStyle = style({\n display: 'flex',\n flexDirection: {\n orientation: {\n horizontal: 'row',\n vertical: 'column'\n }\n },\n gap: {\n density: {\n compact: 2,\n regular: {\n size: {\n XS: 4,\n S: 4,\n M: 8,\n L: 8,\n XL: 8\n }\n }\n }\n }\n}, getAllowedOverrides({height: true}));\n\n\nexport const ActionButtonGroupContext = createContext<ContextValue<Partial<ActionButtonGroupProps>, HTMLDivElement>>(null);\n\n/**\n * An ActionButtonGroup is a grouping of related ActionButtons.\n */\nexport const ActionButtonGroup = forwardRef(function ActionButtonGroup(props: ActionButtonGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ActionButtonGroupContext);\n let {\n density = 'regular',\n size = 'M',\n orientation = 'horizontal',\n isJustified,\n children,\n UNSAFE_className = '',\n UNSAFE_style,\n styles\n } = props;\n\n return (\n <Toolbar\n {...props}\n ref={ref}\n style={UNSAFE_style}\n className={UNSAFE_className + actionGroupStyle({size, density, orientation, isJustified}, styles)}>\n <ActionButtonGroupContext.Provider value={props}>\n {children}\n </ActionButtonGroupContext.Provider>\n </Toolbar>\n );\n});\n"],"names":[],"version":3,"file":"ActionButtonGroup.css.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;AAuCM,MAAM;;;;;;;;;;;;;;;;;;;;;;;AAyBN,MAAM,0DAA2B,CAAA,GAAA,oBAAY,EAAiE;AAK9G,MAAM,0DAAoB,CAAA,GAAA,iBAAS,EAAE,SAAS,kBAAkB,KAA6B,EAAE,GAAiC;IACrI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,WACF,UAAU,iBACV,OAAO,kBACP,cAAc,2BACd,WAAW,YACX,QAAQ,oBACR,mBAAmB,kBACnB,YAAY,UACZ,MAAM,EACP,GAAG;IAEJ,qBACE,gBAAC,CAAA,GAAA,cAAM;QACJ,GAAG,KAAK;QACT,KAAK;QACL,OAAO;QACP,WAAW,mBAAmB,0CAAiB;kBAAC;qBAAM;yBAAS;yBAAa;QAAW,GAAG;kBAC1F,cAAA,gBAAC,0CAAyB,QAAQ;YAAC,OAAO;sBACvC;;;AAIT","sources":["packages/@react-spectrum/s2/src/ActionButtonGroup.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps} from '@react-types/shared';\nimport {ContextValue, SlotProps, Toolbar} from 'react-aria-components';\nimport {createContext, ForwardedRef, forwardRef, ReactNode} from 'react';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {style} from '../style' with {type: 'macro'};\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ActionButtonGroupProps extends AriaLabelingProps, UnsafeStyles, SlotProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /** The children of the group. */\n children: ReactNode,\n /**\n * Size of the buttons.\n * @default \"M\"\n */\n size?: 'XS' | 'S' | 'M' | 'L' | 'XL',\n /**\n * Spacing between the buttons.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular',\n /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */\n isQuiet?: boolean,\n /** Whether the buttons should divide the container width equally. */\n isJustified?: boolean,\n /** Whether the button should be displayed with an [emphasized style](https://spectrum.adobe.com/page/action-button/#Emphasis). */\n staticColor?: 'white' | 'black' | 'auto',\n /**\n * The axis the group should align with.\n * @default 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical',\n /** Whether the group is disabled. */\n isDisabled?: boolean\n}\n\nexport const actionGroupStyle = style({\n display: 'flex',\n flexDirection: {\n orientation: {\n horizontal: 'row',\n vertical: 'column'\n }\n },\n gap: {\n density: {\n compact: 2,\n regular: {\n size: {\n XS: 4,\n S: 4,\n M: 8,\n L: 8,\n XL: 8\n }\n }\n }\n }\n}, getAllowedOverrides({height: true}));\n\n\nexport const ActionButtonGroupContext = createContext<ContextValue<Partial<ActionButtonGroupProps>, HTMLDivElement>>(null);\n\n/**\n * An ActionButtonGroup is a grouping of related ActionButtons.\n */\nexport const ActionButtonGroup = forwardRef(function ActionButtonGroup(props: ActionButtonGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ActionButtonGroupContext);\n let {\n density = 'regular',\n size = 'M',\n orientation = 'horizontal',\n isJustified,\n children,\n UNSAFE_className = '',\n UNSAFE_style,\n styles\n } = props;\n\n return (\n <Toolbar\n {...props}\n ref={ref}\n style={UNSAFE_style}\n className={UNSAFE_className + actionGroupStyle({size, density, orientation, isJustified}, styles)}>\n <ActionButtonGroupContext.Provider value={props}>\n {children}\n </ActionButtonGroupContext.Provider>\n </Toolbar>\n );\n});\n"],"names":[],"version":3,"file":"ActionButtonGroup.mjs.map"}
|
package/dist/Button.cjs
CHANGED
|
@@ -120,12 +120,18 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
120
120
|
if (props.isStaticColor) {
|
|
121
121
|
if (props.isDisabled) rules += ' a_____A';
|
|
122
122
|
else if (props.fillStyle === "outline") {
|
|
123
|
-
if (props.
|
|
124
|
-
else if (props.
|
|
125
|
-
else
|
|
126
|
-
|
|
123
|
+
if (props.variant === "genai") rules += ' ac';
|
|
124
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
125
|
+
else {
|
|
126
|
+
if (props.isPressed) rules += ' a_____F';
|
|
127
|
+
else if (props.isFocusVisible) rules += ' a_____F';
|
|
128
|
+
else if (props.isHovered) rules += ' a_____F';
|
|
129
|
+
else rules += ' a_____E';
|
|
130
|
+
}
|
|
127
131
|
} else if (props.fillStyle === "fill") {
|
|
128
|
-
if (props.variant === "
|
|
132
|
+
if (props.variant === "genai") rules += ' ac';
|
|
133
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
134
|
+
else if (props.variant === "secondary") {
|
|
129
135
|
if (props.isPressed) rules += ' a_____F';
|
|
130
136
|
else if (props.isFocusVisible) rules += ' a_____F';
|
|
131
137
|
else if (props.isHovered) rules += ' a_____F';
|
|
@@ -134,6 +140,8 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
134
140
|
}
|
|
135
141
|
} else if (props.fillStyle === "outline") {
|
|
136
142
|
if (props.isDisabled) rules += ' aj';
|
|
143
|
+
else if (props.variant === "genai") rules += ' ac';
|
|
144
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
137
145
|
else {
|
|
138
146
|
if (props.isPressed) rules += ' ao';
|
|
139
147
|
else if (props.isFocusVisible) rules += ' ao';
|
|
@@ -142,6 +150,8 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
142
150
|
}
|
|
143
151
|
} else if (props.fillStyle === "fill") {
|
|
144
152
|
if (props.isDisabled) rules += ' aj';
|
|
153
|
+
else if (props.variant === "genai") rules += ' ac';
|
|
154
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
145
155
|
else if (props.variant === "negative") rules += ' ac';
|
|
146
156
|
else if (props.variant === "accent") rules += ' ac';
|
|
147
157
|
else if (props.variant === "secondary") {
|
|
@@ -180,9 +190,13 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
180
190
|
rules += ' wa';
|
|
181
191
|
rules += ' u-375tp0';
|
|
182
192
|
rules += ' v-375tp1';
|
|
183
|
-
if (props.
|
|
193
|
+
if (props.variant === "genai") rules += ' sa';
|
|
194
|
+
else if (props.variant === "premium") rules += ' sa';
|
|
195
|
+
else if (props.fillStyle === "outline") rules += ' sc';
|
|
184
196
|
else if (props.fillStyle === "fill") rules += ' sa';
|
|
185
|
-
if (props.
|
|
197
|
+
if (props.variant === "genai") rules += ' ta';
|
|
198
|
+
else if (props.variant === "premium") rules += ' ta';
|
|
199
|
+
else if (props.fillStyle === "outline") rules += ' tc';
|
|
186
200
|
else if (props.fillStyle === "fill") rules += ' ta';
|
|
187
201
|
rules += ' -_1gogtue_E--1dbqcch';
|
|
188
202
|
rules += ' -oelgqu_A--soocica';
|
|
@@ -215,6 +229,20 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
215
229
|
else if (props.isHovered) rules += ' co';
|
|
216
230
|
else rules += ' cn';
|
|
217
231
|
}
|
|
232
|
+
rules += ' _Ba-yknrp1';
|
|
233
|
+
if (props.isPending) rules += ' _B-yknrp1';
|
|
234
|
+
else if (props.isDisabled) rules += ' _B-yknrp1';
|
|
235
|
+
else if (props.variant === "genai") {
|
|
236
|
+
if (props.isFocusVisible) rules += ' _B-1gcd5pl';
|
|
237
|
+
else if (props.isPressed) rules += ' _B-1gcd5pl';
|
|
238
|
+
else if (props.isHovered) rules += ' _B-1gcd5pl';
|
|
239
|
+
else rules += ' _B-u0nzys';
|
|
240
|
+
} else if (props.variant === "premium") {
|
|
241
|
+
if (props.isFocusVisible) rules += ' _B-2xhv0x';
|
|
242
|
+
else if (props.isPressed) rules += ' _B-2xhv0x';
|
|
243
|
+
else if (props.isHovered) rules += ' _B-2xhv0x';
|
|
244
|
+
else rules += ' _B-riuwfd';
|
|
245
|
+
}
|
|
218
246
|
rules += ' b-375toh';
|
|
219
247
|
rules += ' -rwx0fg_e-b';
|
|
220
248
|
rules += ' _zb';
|
|
@@ -224,9 +252,13 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
224
252
|
else if (props.size === "S") rules += ' -_375tou_o-h';
|
|
225
253
|
else if (props.size === "XS") rules += ' -_375tou_o-g';
|
|
226
254
|
else rules += ' -_375tou_o-f';
|
|
227
|
-
if (props.
|
|
255
|
+
if (props.variant === "genai") rules += ' -_375tp0_u-a';
|
|
256
|
+
else if (props.variant === "premium") rules += ' -_375tp0_u-a';
|
|
257
|
+
else if (props.fillStyle === "outline") rules += ' -_375tp0_u-c';
|
|
228
258
|
else if (props.fillStyle === "fill") rules += ' -_375tp0_u-a';
|
|
229
|
-
if (props.
|
|
259
|
+
if (props.variant === "genai") rules += ' -_375tp1_v-a';
|
|
260
|
+
else if (props.variant === "premium") rules += ' -_375tp1_v-a';
|
|
261
|
+
else if (props.fillStyle === "outline") rules += ' -_375tp1_v-c';
|
|
230
262
|
else if (props.fillStyle === "fill") rules += ' -_375tp1_v-a';
|
|
231
263
|
if (props.fillStyle === "outline") rules += ' -_375toh_b-a_____J';
|
|
232
264
|
else if (props.fillStyle === "fill") {
|
|
@@ -240,9 +272,13 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
240
272
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____x';
|
|
241
273
|
else if (props.isPressed) rules += ' -_375toh_b-_____x';
|
|
242
274
|
else if (props.isHovered) rules += ' -_375toh_b-_____x';
|
|
275
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-n';
|
|
276
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-n';
|
|
243
277
|
else rules += ' -_375toh_b-a';
|
|
244
278
|
} else if (props.fillStyle === "fill") {
|
|
245
279
|
if (props.isDisabled) rules += ' -_375toh_b-_____x';
|
|
280
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-n';
|
|
281
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-n';
|
|
246
282
|
else if (props.variant === "secondary") {
|
|
247
283
|
if (props.isPressed) rules += ' -_375toh_b-_____y';
|
|
248
284
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____y';
|
|
@@ -260,9 +296,13 @@ const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
|
260
296
|
else if (props.isFocusVisible) rules += ' -_375toh_b-g';
|
|
261
297
|
else if (props.isPressed) rules += ' -_375toh_b-g';
|
|
262
298
|
else if (props.isHovered) rules += ' -_375toh_b-g';
|
|
299
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-g';
|
|
300
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-g';
|
|
263
301
|
else rules += ' -_375toh_b-a';
|
|
264
302
|
} else if (props.fillStyle === "fill") {
|
|
265
303
|
if (props.isDisabled) rules += ' -_375toh_b-g';
|
|
304
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-g';
|
|
305
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-g';
|
|
266
306
|
else if (props.variant === "negative") {
|
|
267
307
|
if (props.isPressed) rules += ' -_375toh_b-_____Y';
|
|
268
308
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____Y';
|
package/dist/Button.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAmE;AAEhH,MAAM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yB;IAE9D,qBACE,gCAAC,CAAA,GAAA,+BAAG;QACD,GAAG,KAAK;QACT,KAAK;QACL,OAAO,CAAA,GAAA,oCAAS,EAAE,QAAQ,MAAM,YAAY;QAC5C,WAAW,CAAA,cAAe,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,6BAAO;gBAChE,GAAG,WAAW;gBACd,+CAA+C;gBAC/C,WAAW,YAAY,SAAS,IAAI,qBAAqB,UAAU;gBACnE,SAAS,MAAM,OAAO,IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;gBAC9B,eAAe,CAAC,CAAC,MAAM,WAAW;gBAClC,WAAW;YACb,GAAG,MAAM,MAAM;kBACf,cAAA,gCAAC,CAAA,GAAA,mCAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,MAAM;wBACN,kHAAkH;wBAClH,iBAAiB;oBACnB;iBAAE;gBACF;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,wCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,8BAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, focusRing, fontRelative, style} from '../style' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black' | 'auto'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';\nconst button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n [iconOnly]: 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n [iconOnly]: 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n [iconOnly]: 0\n },\n paddingY: 0,\n aspectRatio: {\n [iconOnly]: 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n [iconOnly]: 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100')\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800')\n }\n },\n outline: baseColor('transparent-overlay-800')\n },\n isDisabled: 'transparent-overlay-400'\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nexport const Button = forwardRef(function Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\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 return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor,\n isStaticColor: !!staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n});\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nexport const LinkButton = forwardRef(function LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor,\n isStaticColor: !!props.staticColor,\n isPending: false\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({paddingY: '--labelPadding', order: 1}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n});\n"],"names":[],"version":3,"file":"Button.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAmE;AAEhH,MAAM,iCAAW;AACjB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,GAAG,KAAK;QACT,KAAK;QACL,OAAO,CAAA,GAAA,oCAAS,EAAE,QAAQ,MAAM,YAAY;QAC5C,WAAW,CAAA,cAAe,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,6BAAO;gBAChE,GAAG,WAAW;gBACd,+CAA+C;gBAC/C,WAAW,YAAY,SAAS,IAAI,qBAAqB,UAAU;gBACnE,SAAS,MAAM,OAAO,IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;gBAC9B,eAAe,CAAC,CAAC,MAAM,WAAW;gBAClC,WAAW;YACb,GAAG,MAAM,MAAM;kBACf,cAAA,gCAAC,CAAA,GAAA,mCAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,MAAM;wBACN,kHAAkH;wBAClH,iBAAiB;oBACnB;iBAAE;gBACF;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,wCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,8BAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, focusRing, fontRelative, linearGradient, style} from '../style' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, getAllowedOverrides, staticColor, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative' | 'premium' | 'genai',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black' | 'auto'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';\nconst button = style<ButtonRenderProps & ButtonStyleProps & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n [iconOnly]: 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n [iconOnly]: 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n [iconOnly]: 0\n },\n paddingY: 0,\n aspectRatio: {\n [iconOnly]: 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n },\n variant: {\n premium: 0,\n genai: 0\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n [iconOnly]: 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundImage: {\n variant: {\n premium: {\n default: linearGradient('96deg', ['fuchsia-900', 0], ['indigo-900', 66], ['blue-900', 100]),\n isHovered: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isPressed: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100])\n },\n genai: {\n default: linearGradient('96deg', ['red-900', 0], ['magenta-900', 33], ['indigo-900', 100]),\n isHovered: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isPressed: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100])\n }\n },\n isDisabled: 'none',\n isPending: 'none',\n forcedColors: 'none'\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative',\n premium: 'gray-100',\n genai: 'gray-100'\n },\n isDisabled: 'disabled'\n },\n outline: {\n variant: {\n premium: 'gray-100',\n genai: 'gray-100'\n },\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100'),\n premium: 'gray-800',\n genai: 'gray-800'\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n variant: {\n premium: 'gray-800',\n genai: 'gray-800'\n },\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white',\n premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n variant: {\n premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800'),\n premium: 'white',\n genai: 'white'\n }\n },\n outline: {\n variant: {\n premium: 'white',\n genai: 'white'\n },\n default: baseColor('transparent-overlay-800')\n }\n },\n isDisabled: 'transparent-overlay-400'\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nexport const Button = forwardRef(function Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\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 return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor,\n isStaticColor: !!staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n});\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nexport const LinkButton = forwardRef(function LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor,\n isStaticColor: !!props.staticColor,\n isPending: false\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({paddingY: '--labelPadding', order: 1}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n});\n"],"names":[],"version":3,"file":"Button.cjs.map"}
|