@arc-ui/components 11.8.0 → 11.9.0
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/Badge/Badge.cjs.d.ts +4 -0
- package/dist/Badge/Badge.cjs.js +3 -3
- package/dist/Badge/Badge.esm.d.ts +4 -0
- package/dist/Badge/Badge.esm.js +3 -3
- package/dist/ProgressStepper/ProgressStepper.cjs.d.ts +1 -89
- package/dist/ProgressStepper/ProgressStepper.cjs.js +10 -144
- package/dist/ProgressStepper/ProgressStepper.esm.d.ts +1 -89
- package/dist/ProgressStepper/ProgressStepper.esm.js +9 -143
- package/dist/Tabs/Tabs.cjs.d.ts +1 -75
- package/dist/Tabs/Tabs.cjs.js +11 -505
- package/dist/Tabs/Tabs.esm.d.ts +1 -75
- package/dist/Tabs/Tabs.esm.js +10 -504
- package/dist/TextArea/TextArea.cjs.js +20 -8
- package/dist/TextArea/TextArea.esm.js +20 -8
- package/dist/Toast/Toast.cjs.d.ts +1 -52
- package/dist/Toast/Toast.cjs.js +14 -734
- package/dist/Toast/Toast.esm.d.ts +1 -52
- package/dist/Toast/Toast.esm.js +13 -733
- package/dist/_shared/cjs/MediaCard-9483ad5f.d.ts +60 -0
- package/dist/_shared/cjs/ProgressStepper-f740d7bb.d.ts +89 -0
- package/dist/_shared/cjs/ProgressStepper-f740d7bb.js +149 -0
- package/dist/_shared/cjs/Tabs-fda49692.d.ts +75 -0
- package/dist/_shared/cjs/Tabs-fda49692.js +510 -0
- package/dist/_shared/cjs/Toast-0cb23cae.d.ts +52 -0
- package/dist/_shared/cjs/Toast-0cb23cae.js +739 -0
- package/dist/_shared/esm/MediaCard-9483ad5f.d.ts +60 -0
- package/dist/_shared/esm/ProgressStepper-7ab88f4c.d.ts +89 -0
- package/dist/_shared/esm/ProgressStepper-7ab88f4c.js +143 -0
- package/dist/_shared/esm/Tabs-5af0b940.d.ts +75 -0
- package/dist/_shared/esm/Tabs-5af0b940.js +504 -0
- package/dist/_shared/esm/Toast-43795e91.d.ts +52 -0
- package/dist/_shared/esm/Toast-43795e91.js +733 -0
- package/dist/index.es.js +2312 -407
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2667 -751
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/components/Badge/Badge.d.ts +4 -0
- package/dist/types/components/Toast/Toast.d.ts +2 -2
- package/dist/types/components/Toast/ToastNotification.d.ts +1 -1
- package/dist/types/components/index.d.ts +17 -6
- package/package.json +4 -4
package/dist/Tabs/Tabs.cjs.js
CHANGED
|
@@ -2,513 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var index$2 = require('../_shared/cjs/index-fb4b8fda.js');
|
|
11
|
-
var Icon = require('../_shared/cjs/Icon-e1dd45eb.js');
|
|
12
|
-
var Surface = require('../_shared/cjs/Surface-b7c51b2b.js');
|
|
13
|
-
var index$3 = require('../_shared/cjs/index-45bfb67b.js');
|
|
5
|
+
var Tabs = require('../_shared/cjs/Tabs-fda49692.js');
|
|
6
|
+
require('../_shared/cjs/filter-data-attrs-a30dcf5f.js');
|
|
7
|
+
require('react');
|
|
8
|
+
require('../_shared/cjs/extends-bb8ffacd.js');
|
|
9
|
+
require('../_shared/cjs/index-952918c9.js');
|
|
14
10
|
require('react-dom');
|
|
11
|
+
require('../_shared/cjs/index-27b53d49.js');
|
|
12
|
+
require('../_shared/cjs/index-fb4b8fda.js');
|
|
13
|
+
require('../_shared/cjs/Icon-e1dd45eb.js');
|
|
14
|
+
require('../_shared/cjs/index-45bfb67b.js');
|
|
15
15
|
require('../_shared/cjs/suffix-modifier-1ee2da04.js');
|
|
16
|
+
require('../_shared/cjs/Surface-b7c51b2b.js');
|
|
16
17
|
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
18
|
|
|
19
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$2);
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
/* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
|
|
23
|
-
const globalDir = React$2.useContext($f631663db3294ace$var$DirectionContext);
|
|
24
|
-
return localDir || globalDir || 'ltr';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const $d7bdfb9eb0fdf311$var$ENTRY_FOCUS = 'rovingFocusGroup.onEntryFocus';
|
|
28
|
-
const $d7bdfb9eb0fdf311$var$EVENT_OPTIONS = {
|
|
29
|
-
bubbles: false,
|
|
30
|
-
cancelable: true
|
|
31
|
-
};
|
|
32
|
-
/* -------------------------------------------------------------------------------------------------
|
|
33
|
-
* RovingFocusGroup
|
|
34
|
-
* -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$GROUP_NAME = 'RovingFocusGroup';
|
|
35
|
-
const [$d7bdfb9eb0fdf311$var$Collection, $d7bdfb9eb0fdf311$var$useCollection, $d7bdfb9eb0fdf311$var$createCollectionScope] = index.$e02a7d9cb1dc128c$export$c74125a8e3af6bb2($d7bdfb9eb0fdf311$var$GROUP_NAME);
|
|
36
|
-
const [$d7bdfb9eb0fdf311$var$createRovingFocusGroupContext, $d7bdfb9eb0fdf311$export$c7109489551a4f4] = index$1.$c512c27ab02ef895$export$50c7b4e9d9f19c1($d7bdfb9eb0fdf311$var$GROUP_NAME, [
|
|
37
|
-
$d7bdfb9eb0fdf311$var$createCollectionScope
|
|
38
|
-
]);
|
|
39
|
-
const [$d7bdfb9eb0fdf311$var$RovingFocusProvider, $d7bdfb9eb0fdf311$var$useRovingFocusContext] = $d7bdfb9eb0fdf311$var$createRovingFocusGroupContext($d7bdfb9eb0fdf311$var$GROUP_NAME);
|
|
40
|
-
const $d7bdfb9eb0fdf311$export$8699f7c8af148338 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
41
|
-
return /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$var$Collection.Provider, {
|
|
42
|
-
scope: props.__scopeRovingFocusGroup
|
|
43
|
-
}, /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$var$Collection.Slot, {
|
|
44
|
-
scope: props.__scopeRovingFocusGroup
|
|
45
|
-
}, /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$var$RovingFocusGroupImpl, _extends._extends({}, props, {
|
|
46
|
-
ref: forwardedRef
|
|
47
|
-
}))));
|
|
48
|
-
});
|
|
49
|
-
/* -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$RovingFocusGroupImpl = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
50
|
-
const { __scopeRovingFocusGroup: __scopeRovingFocusGroup , orientation: orientation , loop: loop = false , dir: dir , currentTabStopId: currentTabStopIdProp , defaultCurrentTabStopId: defaultCurrentTabStopId , onCurrentTabStopIdChange: onCurrentTabStopIdChange , onEntryFocus: onEntryFocus , ...groupProps } = props;
|
|
51
|
-
const ref = React$2.useRef(null);
|
|
52
|
-
const composedRefs = index$1.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
|
|
53
|
-
const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
|
|
54
|
-
const [currentTabStopId = null, setCurrentTabStopId] = index$1.$71cd76cc60e0454e$export$6f32135080cb4c3({
|
|
55
|
-
prop: currentTabStopIdProp,
|
|
56
|
-
defaultProp: defaultCurrentTabStopId,
|
|
57
|
-
onChange: onCurrentTabStopIdChange
|
|
58
|
-
});
|
|
59
|
-
const [isTabbingBackOut, setIsTabbingBackOut] = React$2.useState(false);
|
|
60
|
-
const handleEntryFocus = index$1.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEntryFocus);
|
|
61
|
-
const getItems = $d7bdfb9eb0fdf311$var$useCollection(__scopeRovingFocusGroup);
|
|
62
|
-
const isClickFocusRef = React$2.useRef(false);
|
|
63
|
-
const [focusableItemsCount, setFocusableItemsCount] = React$2.useState(0);
|
|
64
|
-
React$2.useEffect(()=>{
|
|
65
|
-
const node = ref.current;
|
|
66
|
-
if (node) {
|
|
67
|
-
node.addEventListener($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, handleEntryFocus);
|
|
68
|
-
return ()=>node.removeEventListener($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, handleEntryFocus)
|
|
69
|
-
;
|
|
70
|
-
}
|
|
71
|
-
}, [
|
|
72
|
-
handleEntryFocus
|
|
73
|
-
]);
|
|
74
|
-
return /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$var$RovingFocusProvider, {
|
|
75
|
-
scope: __scopeRovingFocusGroup,
|
|
76
|
-
orientation: orientation,
|
|
77
|
-
dir: direction,
|
|
78
|
-
loop: loop,
|
|
79
|
-
currentTabStopId: currentTabStopId,
|
|
80
|
-
onItemFocus: React$2.useCallback((tabStopId)=>setCurrentTabStopId(tabStopId)
|
|
81
|
-
, [
|
|
82
|
-
setCurrentTabStopId
|
|
83
|
-
]),
|
|
84
|
-
onItemShiftTab: React$2.useCallback(()=>setIsTabbingBackOut(true)
|
|
85
|
-
, []),
|
|
86
|
-
onFocusableItemAdd: React$2.useCallback(()=>setFocusableItemsCount((prevCount)=>prevCount + 1
|
|
87
|
-
)
|
|
88
|
-
, []),
|
|
89
|
-
onFocusableItemRemove: React$2.useCallback(()=>setFocusableItemsCount((prevCount)=>prevCount - 1
|
|
90
|
-
)
|
|
91
|
-
, [])
|
|
92
|
-
}, /*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends._extends({
|
|
93
|
-
tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
|
|
94
|
-
"data-orientation": orientation
|
|
95
|
-
}, groupProps, {
|
|
96
|
-
ref: composedRefs,
|
|
97
|
-
style: {
|
|
98
|
-
outline: 'none',
|
|
99
|
-
...props.style
|
|
100
|
-
},
|
|
101
|
-
onMouseDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, ()=>{
|
|
102
|
-
isClickFocusRef.current = true;
|
|
103
|
-
}),
|
|
104
|
-
onFocus: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, (event)=>{
|
|
105
|
-
// We normally wouldn't need this check, because we already check
|
|
106
|
-
// that the focus is on the current target and not bubbling to it.
|
|
107
|
-
// We do this because Safari doesn't focus buttons when clicked, and
|
|
108
|
-
// instead, the wrapper will get focused and not through a bubbling event.
|
|
109
|
-
const isKeyboardFocus = !isClickFocusRef.current;
|
|
110
|
-
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
111
|
-
const entryFocusEvent = new CustomEvent($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, $d7bdfb9eb0fdf311$var$EVENT_OPTIONS);
|
|
112
|
-
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
113
|
-
if (!entryFocusEvent.defaultPrevented) {
|
|
114
|
-
const items = getItems().filter((item)=>item.focusable
|
|
115
|
-
);
|
|
116
|
-
const activeItem = items.find((item)=>item.active
|
|
117
|
-
);
|
|
118
|
-
const currentItem = items.find((item)=>item.id === currentTabStopId
|
|
119
|
-
);
|
|
120
|
-
const candidateItems = [
|
|
121
|
-
activeItem,
|
|
122
|
-
currentItem,
|
|
123
|
-
...items
|
|
124
|
-
].filter(Boolean);
|
|
125
|
-
const candidateNodes = candidateItems.map((item)=>item.ref.current
|
|
126
|
-
);
|
|
127
|
-
$d7bdfb9eb0fdf311$var$focusFirst(candidateNodes);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
isClickFocusRef.current = false;
|
|
131
|
-
}),
|
|
132
|
-
onBlur: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlur, ()=>setIsTabbingBackOut(false)
|
|
133
|
-
)
|
|
134
|
-
})));
|
|
135
|
-
});
|
|
136
|
-
/* -------------------------------------------------------------------------------------------------
|
|
137
|
-
* RovingFocusGroupItem
|
|
138
|
-
* -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$ITEM_NAME = 'RovingFocusGroupItem';
|
|
139
|
-
const $d7bdfb9eb0fdf311$export$ab9df7c53fe8454 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
140
|
-
const { __scopeRovingFocusGroup: __scopeRovingFocusGroup , focusable: focusable = true , active: active = false , tabStopId: tabStopId , ...itemProps } = props;
|
|
141
|
-
const autoId = index$2.$1746a345f3d73bb7$export$f680877a34711e37();
|
|
142
|
-
const id = tabStopId || autoId;
|
|
143
|
-
const context = $d7bdfb9eb0fdf311$var$useRovingFocusContext($d7bdfb9eb0fdf311$var$ITEM_NAME, __scopeRovingFocusGroup);
|
|
144
|
-
const isCurrentTabStop = context.currentTabStopId === id;
|
|
145
|
-
const getItems = $d7bdfb9eb0fdf311$var$useCollection(__scopeRovingFocusGroup);
|
|
146
|
-
const { onFocusableItemAdd: onFocusableItemAdd , onFocusableItemRemove: onFocusableItemRemove } = context;
|
|
147
|
-
React$2.useEffect(()=>{
|
|
148
|
-
if (focusable) {
|
|
149
|
-
onFocusableItemAdd();
|
|
150
|
-
return ()=>onFocusableItemRemove()
|
|
151
|
-
;
|
|
152
|
-
}
|
|
153
|
-
}, [
|
|
154
|
-
focusable,
|
|
155
|
-
onFocusableItemAdd,
|
|
156
|
-
onFocusableItemRemove
|
|
157
|
-
]);
|
|
158
|
-
return /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$var$Collection.ItemSlot, {
|
|
159
|
-
scope: __scopeRovingFocusGroup,
|
|
160
|
-
id: id,
|
|
161
|
-
focusable: focusable,
|
|
162
|
-
active: active
|
|
163
|
-
}, /*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends._extends({
|
|
164
|
-
tabIndex: isCurrentTabStop ? 0 : -1,
|
|
165
|
-
"data-orientation": context.orientation
|
|
166
|
-
}, itemProps, {
|
|
167
|
-
ref: forwardedRef,
|
|
168
|
-
onMouseDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, (event)=>{
|
|
169
|
-
// We prevent focusing non-focusable items on `mousedown`.
|
|
170
|
-
// Even though the item has tabIndex={-1}, that only means take it out of the tab order.
|
|
171
|
-
if (!focusable) event.preventDefault(); // Safari doesn't focus a button when clicked so we run our logic on mousedown also
|
|
172
|
-
else context.onItemFocus(id);
|
|
173
|
-
}),
|
|
174
|
-
onFocus: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, ()=>context.onItemFocus(id)
|
|
175
|
-
),
|
|
176
|
-
onKeyDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event)=>{
|
|
177
|
-
if (event.key === 'Tab' && event.shiftKey) {
|
|
178
|
-
context.onItemShiftTab();
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (event.target !== event.currentTarget) return;
|
|
182
|
-
const focusIntent = $d7bdfb9eb0fdf311$var$getFocusIntent(event, context.orientation, context.dir);
|
|
183
|
-
if (focusIntent !== undefined) {
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
const items = getItems().filter((item)=>item.focusable
|
|
186
|
-
);
|
|
187
|
-
let candidateNodes = items.map((item)=>item.ref.current
|
|
188
|
-
);
|
|
189
|
-
if (focusIntent === 'last') candidateNodes.reverse();
|
|
190
|
-
else if (focusIntent === 'prev' || focusIntent === 'next') {
|
|
191
|
-
if (focusIntent === 'prev') candidateNodes.reverse();
|
|
192
|
-
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
193
|
-
candidateNodes = context.loop ? $d7bdfb9eb0fdf311$var$wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Imperative focus during keydown is risky so we prevent React's batching updates
|
|
197
|
-
* to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
|
|
198
|
-
*/ setTimeout(()=>$d7bdfb9eb0fdf311$var$focusFirst(candidateNodes)
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
})
|
|
202
|
-
})));
|
|
203
|
-
});
|
|
204
|
-
/* -----------------------------------------------------------------------------------------------*/ // prettier-ignore
|
|
205
|
-
const $d7bdfb9eb0fdf311$var$MAP_KEY_TO_FOCUS_INTENT = {
|
|
206
|
-
ArrowLeft: 'prev',
|
|
207
|
-
ArrowUp: 'prev',
|
|
208
|
-
ArrowRight: 'next',
|
|
209
|
-
ArrowDown: 'next',
|
|
210
|
-
PageUp: 'first',
|
|
211
|
-
Home: 'first',
|
|
212
|
-
PageDown: 'last',
|
|
213
|
-
End: 'last'
|
|
214
|
-
};
|
|
215
|
-
function $d7bdfb9eb0fdf311$var$getDirectionAwareKey(key, dir) {
|
|
216
|
-
if (dir !== 'rtl') return key;
|
|
217
|
-
return key === 'ArrowLeft' ? 'ArrowRight' : key === 'ArrowRight' ? 'ArrowLeft' : key;
|
|
218
|
-
}
|
|
219
|
-
function $d7bdfb9eb0fdf311$var$getFocusIntent(event, orientation, dir) {
|
|
220
|
-
const key = $d7bdfb9eb0fdf311$var$getDirectionAwareKey(event.key, dir);
|
|
221
|
-
if (orientation === 'vertical' && [
|
|
222
|
-
'ArrowLeft',
|
|
223
|
-
'ArrowRight'
|
|
224
|
-
].includes(key)) return undefined;
|
|
225
|
-
if (orientation === 'horizontal' && [
|
|
226
|
-
'ArrowUp',
|
|
227
|
-
'ArrowDown'
|
|
228
|
-
].includes(key)) return undefined;
|
|
229
|
-
return $d7bdfb9eb0fdf311$var$MAP_KEY_TO_FOCUS_INTENT[key];
|
|
230
|
-
}
|
|
231
|
-
function $d7bdfb9eb0fdf311$var$focusFirst(candidates) {
|
|
232
|
-
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
233
|
-
for (const candidate of candidates){
|
|
234
|
-
// if focus is already where we want to go, we don't want to keep going through the candidates
|
|
235
|
-
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
236
|
-
candidate.focus();
|
|
237
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Wraps an array around itself at a given start index
|
|
242
|
-
* Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
|
|
243
|
-
*/ function $d7bdfb9eb0fdf311$var$wrapArray(array, startIndex) {
|
|
244
|
-
return array.map((_, index)=>array[(startIndex + index) % array.length]
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
const $d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9 = $d7bdfb9eb0fdf311$export$8699f7c8af148338;
|
|
248
|
-
const $d7bdfb9eb0fdf311$export$6d08773d2e66f8f2 = $d7bdfb9eb0fdf311$export$ab9df7c53fe8454;
|
|
249
|
-
|
|
250
|
-
/* -------------------------------------------------------------------------------------------------
|
|
251
|
-
* Tabs
|
|
252
|
-
* -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TABS_NAME = 'Tabs';
|
|
253
|
-
const [$69cb30bb0017df05$var$createTabsContext, $69cb30bb0017df05$export$355f5bd209d7b13a] = index$1.$c512c27ab02ef895$export$50c7b4e9d9f19c1($69cb30bb0017df05$var$TABS_NAME, [
|
|
254
|
-
$d7bdfb9eb0fdf311$export$c7109489551a4f4
|
|
255
|
-
]);
|
|
256
|
-
const $69cb30bb0017df05$var$useRovingFocusGroupScope = $d7bdfb9eb0fdf311$export$c7109489551a4f4();
|
|
257
|
-
const [$69cb30bb0017df05$var$TabsProvider, $69cb30bb0017df05$var$useTabsContext] = $69cb30bb0017df05$var$createTabsContext($69cb30bb0017df05$var$TABS_NAME);
|
|
258
|
-
const $69cb30bb0017df05$export$b2539bed5023c21c = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
259
|
-
const { __scopeTabs: __scopeTabs , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , dir: dir , activationMode: activationMode = 'automatic' , ...tabsProps } = props;
|
|
260
|
-
const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
|
|
261
|
-
const [value, setValue] = index$1.$71cd76cc60e0454e$export$6f32135080cb4c3({
|
|
262
|
-
prop: valueProp,
|
|
263
|
-
onChange: onValueChange,
|
|
264
|
-
defaultProp: defaultValue
|
|
265
|
-
});
|
|
266
|
-
return /*#__PURE__*/ React$2.createElement($69cb30bb0017df05$var$TabsProvider, {
|
|
267
|
-
scope: __scopeTabs,
|
|
268
|
-
baseId: index$2.$1746a345f3d73bb7$export$f680877a34711e37(),
|
|
269
|
-
value: value,
|
|
270
|
-
onValueChange: setValue,
|
|
271
|
-
orientation: orientation,
|
|
272
|
-
dir: direction,
|
|
273
|
-
activationMode: activationMode
|
|
274
|
-
}, /*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends._extends({
|
|
275
|
-
dir: direction,
|
|
276
|
-
"data-orientation": orientation
|
|
277
|
-
}, tabsProps, {
|
|
278
|
-
ref: forwardedRef
|
|
279
|
-
})));
|
|
280
|
-
});
|
|
281
|
-
/* -------------------------------------------------------------------------------------------------
|
|
282
|
-
* TabsList
|
|
283
|
-
* -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TAB_LIST_NAME = 'TabsList';
|
|
284
|
-
const $69cb30bb0017df05$export$9712d22edc0d78c1 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
285
|
-
const { __scopeTabs: __scopeTabs , loop: loop = true , ...listProps } = props;
|
|
286
|
-
const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TAB_LIST_NAME, __scopeTabs);
|
|
287
|
-
const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
|
|
288
|
-
return /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, _extends._extends({
|
|
289
|
-
asChild: true
|
|
290
|
-
}, rovingFocusGroupScope, {
|
|
291
|
-
orientation: context.orientation,
|
|
292
|
-
dir: context.dir,
|
|
293
|
-
loop: loop
|
|
294
|
-
}), /*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends._extends({
|
|
295
|
-
role: "tablist",
|
|
296
|
-
"aria-orientation": context.orientation
|
|
297
|
-
}, listProps, {
|
|
298
|
-
ref: forwardedRef
|
|
299
|
-
})));
|
|
300
|
-
});
|
|
301
|
-
/* -------------------------------------------------------------------------------------------------
|
|
302
|
-
* TabsTrigger
|
|
303
|
-
* -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TRIGGER_NAME = 'TabsTrigger';
|
|
304
|
-
const $69cb30bb0017df05$export$8114b9fdfdf9f3ba = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
305
|
-
const { __scopeTabs: __scopeTabs , value: value , disabled: disabled = false , ...triggerProps } = props;
|
|
306
|
-
const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TRIGGER_NAME, __scopeTabs);
|
|
307
|
-
const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
|
|
308
|
-
const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
|
|
309
|
-
const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
|
|
310
|
-
const isSelected = value === context.value;
|
|
311
|
-
return /*#__PURE__*/ React$2.createElement($d7bdfb9eb0fdf311$export$6d08773d2e66f8f2, _extends._extends({
|
|
312
|
-
asChild: true
|
|
313
|
-
}, rovingFocusGroupScope, {
|
|
314
|
-
focusable: !disabled,
|
|
315
|
-
active: isSelected
|
|
316
|
-
}), /*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends._extends({
|
|
317
|
-
type: "button",
|
|
318
|
-
role: "tab",
|
|
319
|
-
"aria-selected": isSelected,
|
|
320
|
-
"aria-controls": contentId,
|
|
321
|
-
"data-state": isSelected ? 'active' : 'inactive',
|
|
322
|
-
"data-disabled": disabled ? '' : undefined,
|
|
323
|
-
disabled: disabled,
|
|
324
|
-
id: triggerId
|
|
325
|
-
}, triggerProps, {
|
|
326
|
-
ref: forwardedRef,
|
|
327
|
-
onMouseDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, (event)=>{
|
|
328
|
-
// only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
|
|
329
|
-
// but not when the control key is pressed (avoiding MacOS right click)
|
|
330
|
-
if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
|
|
331
|
-
else // prevent focus to avoid accidental activation
|
|
332
|
-
event.preventDefault();
|
|
333
|
-
}),
|
|
334
|
-
onKeyDown: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event)=>{
|
|
335
|
-
if ([
|
|
336
|
-
' ',
|
|
337
|
-
'Enter'
|
|
338
|
-
].includes(event.key)) context.onValueChange(value);
|
|
339
|
-
}),
|
|
340
|
-
onFocus: index$1.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, ()=>{
|
|
341
|
-
// handle "automatic" activation if necessary
|
|
342
|
-
// ie. activate tab following focus
|
|
343
|
-
const isAutomaticActivation = context.activationMode !== 'manual';
|
|
344
|
-
if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
|
|
345
|
-
})
|
|
346
|
-
})));
|
|
347
|
-
});
|
|
348
|
-
/* -------------------------------------------------------------------------------------------------
|
|
349
|
-
* TabsContent
|
|
350
|
-
* -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$CONTENT_NAME = 'TabsContent';
|
|
351
|
-
const $69cb30bb0017df05$export$bd905d70e8fd2ebb = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
|
|
352
|
-
const { __scopeTabs: __scopeTabs , value: value , forceMount: forceMount , children: children , ...contentProps } = props;
|
|
353
|
-
const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$CONTENT_NAME, __scopeTabs);
|
|
354
|
-
const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
|
|
355
|
-
const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
|
|
356
|
-
const isSelected = value === context.value;
|
|
357
|
-
const isMountAnimationPreventedRef = React$2.useRef(isSelected);
|
|
358
|
-
React$2.useEffect(()=>{
|
|
359
|
-
const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
|
|
360
|
-
);
|
|
361
|
-
return ()=>cancelAnimationFrame(rAF)
|
|
362
|
-
;
|
|
363
|
-
}, []);
|
|
364
|
-
return /*#__PURE__*/ React$2.createElement(index$1.$921a889cee6df7e8$export$99c2b779aa4e8b8b, {
|
|
365
|
-
present: forceMount || isSelected
|
|
366
|
-
}, ({ present: present })=>/*#__PURE__*/ React$2.createElement(index$1.$8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends._extends({
|
|
367
|
-
"data-state": isSelected ? 'active' : 'inactive',
|
|
368
|
-
"data-orientation": context.orientation,
|
|
369
|
-
role: "tabpanel",
|
|
370
|
-
"aria-labelledby": triggerId,
|
|
371
|
-
hidden: !present,
|
|
372
|
-
id: contentId,
|
|
373
|
-
tabIndex: 0
|
|
374
|
-
}, contentProps, {
|
|
375
|
-
ref: forwardedRef,
|
|
376
|
-
style: {
|
|
377
|
-
...props.style,
|
|
378
|
-
animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined
|
|
379
|
-
}
|
|
380
|
-
}), present && children)
|
|
381
|
-
);
|
|
382
|
-
});
|
|
383
|
-
/* ---------------------------------------------------------------------------------------------- */ function $69cb30bb0017df05$var$makeTriggerId(baseId, value) {
|
|
384
|
-
return `${baseId}-trigger-${value}`;
|
|
385
|
-
}
|
|
386
|
-
function $69cb30bb0017df05$var$makeContentId(baseId, value) {
|
|
387
|
-
return `${baseId}-content-${value}`;
|
|
388
|
-
}
|
|
389
|
-
const $69cb30bb0017df05$export$be92b6f5f03c0fe9 = $69cb30bb0017df05$export$b2539bed5023c21c;
|
|
390
|
-
const $69cb30bb0017df05$export$54c2e3dc7acea9f5 = $69cb30bb0017df05$export$9712d22edc0d78c1;
|
|
391
|
-
const $69cb30bb0017df05$export$41fb9f06171c75f4 = $69cb30bb0017df05$export$8114b9fdfdf9f3ba;
|
|
392
|
-
const $69cb30bb0017df05$export$7c6e2c02157bb7d2 = $69cb30bb0017df05$export$bd905d70e8fd2ebb;
|
|
393
|
-
|
|
394
|
-
var Tab = function (_a) {
|
|
395
|
-
var label = _a.label, value = _a.value, icon = _a.icon, iconActive = _a.iconActive, props = filterDataAttrs.__rest(_a, ["label", "value", "icon", "iconActive"]);
|
|
396
|
-
var surface = React$2.useContext(Surface.Context).surface;
|
|
397
|
-
return (React__default["default"].createElement($69cb30bb0017df05$export$41fb9f06171c75f4, filterDataAttrs.__assign({ className: index$3.classNames("arc-Tab-trigger", {
|
|
398
|
-
"arc-Tab-trigger--onDarkSurface": surface === "dark",
|
|
399
|
-
"arc-Tab-trigger--hasIcon": icon || iconActive
|
|
400
|
-
}), value: value }, filterDataAttrs.filterDataAttrs(props)),
|
|
401
|
-
icon && (React__default["default"].createElement("div", { className: "arc-Tab-triggerIcon", "data-testid": "arc-Tab-TriggerIcon" },
|
|
402
|
-
React__default["default"].createElement(Icon.Icon, { icon: icon }))),
|
|
403
|
-
iconActive && (React__default["default"].createElement("div", { className: "arc-Tab-triggerIcon arc-Tab-triggerIcon--active", "data-testid": "arc-Tab-TriggerIconActive" },
|
|
404
|
-
React__default["default"].createElement(Icon.Icon, { icon: iconActive }))),
|
|
405
|
-
label));
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
var TabContent = function (_a) {
|
|
409
|
-
var children = _a.children, value = _a.value;
|
|
410
|
-
return (React__default["default"].createElement($69cb30bb0017df05$export$7c6e2c02157bb7d2, { className: "arc-Tab-content", value: value }, children));
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const React$1 = React__default["default"];
|
|
414
|
-
const BtIconArrowRightFill = props =>
|
|
415
|
-
/*#__PURE__*/ React$1.createElement(
|
|
416
|
-
"svg",
|
|
417
|
-
Object.assign(
|
|
418
|
-
{
|
|
419
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
420
|
-
viewBox: "0 0 32 32"
|
|
421
|
-
},
|
|
422
|
-
props
|
|
423
|
-
),
|
|
424
|
-
/*#__PURE__*/ React$1.createElement("defs", null),
|
|
425
|
-
/*#__PURE__*/ React$1.createElement("path", {
|
|
426
|
-
d:
|
|
427
|
-
"M2,16A14,14,0,1,0,16,2,14,14,0,0,0,2,16Zm16.85352-4.35352L23.207,16l-4.35351,4.35352a.5.5,0,0,1-.707-.707L21.293,16.5H9.5a.5.5,0,0,1,0-1H21.293l-3.14649-3.14648a.5.5,0,0,1,.707-.707Z",
|
|
428
|
-
fill: "currentColor"
|
|
429
|
-
})
|
|
430
|
-
);
|
|
431
|
-
var BtIconArrowRightFill_2 = BtIconArrowRightFill;
|
|
432
|
-
|
|
433
|
-
const React = React__default["default"];
|
|
434
|
-
const BtIconArrowLeftFill = props =>
|
|
435
|
-
/*#__PURE__*/ React.createElement(
|
|
436
|
-
"svg",
|
|
437
|
-
Object.assign(
|
|
438
|
-
{
|
|
439
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
440
|
-
viewBox: "0 0 32 32"
|
|
441
|
-
},
|
|
442
|
-
props
|
|
443
|
-
),
|
|
444
|
-
/*#__PURE__*/ React.createElement("defs", null),
|
|
445
|
-
/*#__PURE__*/ React.createElement("path", {
|
|
446
|
-
d:
|
|
447
|
-
"M30,16A14,14,0,1,0,16,30,14,14,0,0,0,30,16ZM13.14648,20.35352,8.793,16l4.35351-4.35352a.5.5,0,0,1,.707.707L10.707,15.5H22.5a.5.5,0,0,1,0,1H10.707l3.14649,3.14648a.5.5,0,0,1-.707.707Z",
|
|
448
|
-
fill: "currentColor"
|
|
449
|
-
})
|
|
450
|
-
);
|
|
451
|
-
var BtIconArrowLeftFill_2 = BtIconArrowLeftFill;
|
|
452
|
-
|
|
453
|
-
var TabsList = function (_a) {
|
|
454
|
-
var children = _a.children, type = _a.type, isJustified = _a.isJustified, ariaLabel = _a.ariaLabel, props = filterDataAttrs.__rest(_a, ["children", "type", "isJustified", "ariaLabel"]);
|
|
455
|
-
var surface = React$2.useContext(Surface.Context).surface;
|
|
456
|
-
var tabsRef = React$2.useRef(null);
|
|
457
|
-
var _b = React$2.useState(false), rightOverflow = _b[0], setRightOverflow = _b[1];
|
|
458
|
-
var _c = React$2.useState(false), leftOverflow = _c[0], setLeftOverflow = _c[1];
|
|
459
|
-
var checkOverflow = function (element) {
|
|
460
|
-
if (element) {
|
|
461
|
-
if (element.scrollWidth > element.clientWidth) {
|
|
462
|
-
setRightOverflow(true);
|
|
463
|
-
}
|
|
464
|
-
if (element.scrollLeft + 10 >=
|
|
465
|
-
element.scrollWidth - element.clientWidth) {
|
|
466
|
-
setRightOverflow(false);
|
|
467
|
-
}
|
|
468
|
-
if (element.scrollLeft >= 1) {
|
|
469
|
-
setLeftOverflow(true);
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
setLeftOverflow(false);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
React$2.useEffect(function () {
|
|
477
|
-
checkOverflow(tabsRef.current);
|
|
478
|
-
}, []);
|
|
479
|
-
var scrollTabs = function (scrollAmount) {
|
|
480
|
-
if (tabsRef.current) {
|
|
481
|
-
tabsRef.current.scrollLeft += scrollAmount;
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
var onScroll = function (event) {
|
|
485
|
-
checkOverflow(event.currentTarget);
|
|
486
|
-
};
|
|
487
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
488
|
-
React__default["default"].createElement($69cb30bb0017df05$export$54c2e3dc7acea9f5, filterDataAttrs.__assign({ onScroll: onScroll, className: index$3.classNames("arc-Tabs", {
|
|
489
|
-
"arc-Tabs--contained": type === "contained",
|
|
490
|
-
"arc-Tabs--isJustified": isJustified,
|
|
491
|
-
"arc-Tabs--onDarkSurface": surface === "dark"
|
|
492
|
-
}), ref: tabsRef, "aria-label": ariaLabel }, filterDataAttrs.filterDataAttrs(props)), children),
|
|
493
|
-
leftOverflow && (React__default["default"].createElement("button", { className: index$3.classNames("arc-Tabs-overflowIcon arc-Tabs-overflowIcon--left", {
|
|
494
|
-
"arc-Tabs-overflowIcon--onDarkSurface": surface === "dark"
|
|
495
|
-
}), onClick: function () { return scrollTabs(-300); }, "aria-label": "Scroll Tabs Left", "data-testid": "arc-Tabs-overflowIconLeft" },
|
|
496
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconArrowLeftFill_2, size: 40, color: "brand" }))),
|
|
497
|
-
rightOverflow && (React__default["default"].createElement("button", { className: index$3.classNames("arc-Tabs-overflowIcon", {
|
|
498
|
-
"arc-Tabs-overflowIcon--onDarkSurface": surface === "dark"
|
|
499
|
-
}), onClick: function () { return scrollTabs(300); }, "aria-label": "Scroll Tabs Right", "data-testid": "arc-Tabs-overflowIconRight" },
|
|
500
|
-
React__default["default"].createElement(Icon.Icon, { icon: BtIconArrowRightFill_2, size: 40, color: "brand" })))));
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
var Tabs = function (_a) {
|
|
504
|
-
var children = _a.children, defaultValue = _a.defaultValue, onValueChange = _a.onValueChange, activationMode = _a.activationMode, props = filterDataAttrs.__rest(_a, ["children", "defaultValue", "onValueChange", "activationMode"]);
|
|
505
|
-
return (React__default["default"].createElement($69cb30bb0017df05$export$be92b6f5f03c0fe9, filterDataAttrs.__assign({ className: "arc-Tabs-root", defaultValue: defaultValue, onValueChange: onValueChange, activationMode: activationMode }, filterDataAttrs.filterDataAttrs(props)), children));
|
|
506
|
-
};
|
|
507
|
-
Tab.displayName = "Tabs.Tab";
|
|
508
|
-
TabsList.displayName = "Tabs.List";
|
|
509
|
-
TabContent.displayName = "Tabs.Content";
|
|
510
|
-
Tabs.Tab = Tab;
|
|
511
|
-
Tabs.List = TabsList;
|
|
512
|
-
Tabs.Content = TabContent;
|
|
513
|
-
|
|
514
|
-
exports.Tabs = Tabs;
|
|
20
|
+
exports.Tabs = Tabs.Tabs;
|
package/dist/Tabs/Tabs.esm.d.ts
CHANGED
|
@@ -1,75 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ArcIcon } from "../_shared/esm/arc-icon-17594b2f";
|
|
3
|
-
declare const Tab: FC<TabProps>;
|
|
4
|
-
interface TabProps {
|
|
5
|
-
/**
|
|
6
|
-
* Label to display on the Tab
|
|
7
|
-
*/
|
|
8
|
-
label: string;
|
|
9
|
-
/**
|
|
10
|
-
* Value to link `Tab` to `TabContent`
|
|
11
|
-
*/
|
|
12
|
-
value: string;
|
|
13
|
-
/**
|
|
14
|
-
* Determine what icon to display within the Tab.
|
|
15
|
-
*/
|
|
16
|
-
icon?: ArcIcon;
|
|
17
|
-
/**
|
|
18
|
-
* Determine what to display when `Tab` is active
|
|
19
|
-
*/
|
|
20
|
-
iconActive?: ArcIcon;
|
|
21
|
-
}
|
|
22
|
-
declare const TabContent: FC<TabContentProps>;
|
|
23
|
-
interface TabContentProps {
|
|
24
|
-
/**
|
|
25
|
-
* Content to display
|
|
26
|
-
*/
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
/**
|
|
29
|
-
* This value links the `TabContent` with `Tab`
|
|
30
|
-
*/
|
|
31
|
-
value: string;
|
|
32
|
-
}
|
|
33
|
-
declare const TabsList: FC<TabsListProps>;
|
|
34
|
-
interface TabsListProps {
|
|
35
|
-
/**
|
|
36
|
-
* Contents of the `Tabs` Should contain `Tab`
|
|
37
|
-
*/
|
|
38
|
-
children: ReactNode;
|
|
39
|
-
/**
|
|
40
|
-
* Determine if `Tabs` should be justified
|
|
41
|
-
*/
|
|
42
|
-
isJustified?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Determine the type of `Tabs`. Default is standard
|
|
45
|
-
*/
|
|
46
|
-
type?: "standard" | "contained";
|
|
47
|
-
/**
|
|
48
|
-
* Determine a accessible label for `Tabs`
|
|
49
|
-
*/
|
|
50
|
-
ariaLabel?: string;
|
|
51
|
-
}
|
|
52
|
-
declare const Tabs: FC<TabsProps> & {
|
|
53
|
-
Tab: typeof Tab;
|
|
54
|
-
Content: typeof TabContent;
|
|
55
|
-
List: typeof TabsList;
|
|
56
|
-
};
|
|
57
|
-
interface TabsProps {
|
|
58
|
-
/**
|
|
59
|
-
* Render children
|
|
60
|
-
*/
|
|
61
|
-
children: ReactNode;
|
|
62
|
-
/**
|
|
63
|
-
* Default to an inital value of a tab. If this is left blank it is possible for there to be no active tabs
|
|
64
|
-
*/
|
|
65
|
-
defaultValue?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Event handler called when the value changes.
|
|
68
|
-
*/
|
|
69
|
-
onValueChange?: (value: string) => void;
|
|
70
|
-
/**
|
|
71
|
-
* When automatic, tabs are activated when receiving focus. When manual, tabs are activated when clicked.
|
|
72
|
-
*/
|
|
73
|
-
activationMode?: "automatic" | "manual";
|
|
74
|
-
}
|
|
75
|
-
export { Tabs };
|
|
1
|
+
export { Tabs } from "../_shared/esm/Tabs-5af0b940";
|