@primer/react 0.0.0-20260408162035 → 0.0.0-20260408164838
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/CHANGELOG.md +1 -3
- package/dist/ActionBar/ActionBar-a41224b2.css +2 -0
- package/dist/ActionBar/ActionBar-a41224b2.css.map +1 -0
- package/dist/ActionBar/ActionBar.d.ts +1 -1
- package/dist/ActionBar/ActionBar.d.ts.map +1 -1
- package/dist/ActionBar/ActionBar.js +361 -288
- package/dist/ActionBar/ActionBar.module.css.js +2 -2
- package/dist/ActionBar/index.d.ts +1 -1
- package/dist/ActionList/List.d.ts.map +1 -1
- package/dist/ActionList/List.js +41 -41
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +3 -13
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +23 -23
- package/dist/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox/Checkbox.js +5 -5
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +5 -7
- package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
- package/dist/FilteredActionList/FilteredActionList.js +8 -8
- package/dist/PageHeader/PageHeader.d.ts.map +1 -1
- package/dist/PageHeader/PageHeader.js +30 -31
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +5 -6
- package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
- package/dist/TooltipV2/Tooltip.js +4 -4
- package/dist/experimental/Tabs/Tabs.d.ts +1 -1
- package/dist/experimental/Tabs/Tabs.d.ts.map +1 -1
- package/dist/experimental/Tabs/Tabs.js +16 -16
- package/dist/hooks/useMergedRefs.d.ts +1 -1
- package/dist/hooks/useMergedRefs.d.ts.map +1 -1
- package/dist/hooks/useMergedRefs.js +7 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.js +10 -10
- package/package.json +1 -1
- package/dist/ActionBar/ActionBar-3f7b52a3.css +0 -2
- package/dist/ActionBar/ActionBar-3f7b52a3.css.map +0 -1
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import React, { useRef,
|
|
2
|
+
import React, { useRef, useState, forwardRef, useMemo, useCallback } from 'react';
|
|
3
3
|
import { KebabHorizontalIcon } from '@primer/octicons-react';
|
|
4
4
|
import { ActionList } from '../ActionList/index.js';
|
|
5
|
+
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
6
|
+
import { useResizeObserver } from '../hooks/useResizeObserver.js';
|
|
5
7
|
import { IconButton } from '../Button/IconButton.js';
|
|
6
8
|
import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
7
9
|
import styles from './ActionBar.module.css.js';
|
|
8
10
|
import { clsx } from 'clsx';
|
|
9
11
|
import { createDescendantRegistry } from '../utils/descendant-registry.js';
|
|
10
|
-
import {
|
|
12
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
13
|
import { useMergedRefs } from '../hooks/useMergedRefs.js';
|
|
12
14
|
import { FocusKeys } from '@primer/behaviors';
|
|
13
15
|
import { ActionMenu } from '../ActionMenu/ActionMenu.js';
|
|
14
16
|
|
|
17
|
+
const ACTIONBAR_ITEM_GAP = 8;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Registry of descendants to render in the list or menu. To preserve insertion order across updates, children are
|
|
21
|
+
* set to `null` when unregistered rather than fully dropped from the map.
|
|
22
|
+
*/
|
|
23
|
+
|
|
15
24
|
const ActionBarContext = /*#__PURE__*/React.createContext({
|
|
16
25
|
size: 'medium',
|
|
26
|
+
isVisibleChild: () => true,
|
|
17
27
|
groupId: undefined
|
|
18
28
|
});
|
|
19
29
|
|
|
@@ -21,8 +31,23 @@ const ActionBarContext = /*#__PURE__*/React.createContext({
|
|
|
21
31
|
small (28px), medium (32px), large (40px)
|
|
22
32
|
*/
|
|
23
33
|
|
|
34
|
+
const MORE_BTN_WIDTH = 32;
|
|
24
35
|
const ActionBarItemsRegistry = createDescendantRegistry();
|
|
25
|
-
const
|
|
36
|
+
const calculatePossibleItems = (registryEntries, navWidth, gap, moreMenuWidth = 0) => {
|
|
37
|
+
const widthToFit = navWidth - moreMenuWidth;
|
|
38
|
+
let breakpoint = registryEntries.length; // assume all items will fit
|
|
39
|
+
let sumsOfChildWidth = 0;
|
|
40
|
+
for (const [index, [, child]] of registryEntries.entries()) {
|
|
41
|
+
sumsOfChildWidth += index > 0 ? child.width + gap : child.width;
|
|
42
|
+
if (sumsOfChildWidth > widthToFit) {
|
|
43
|
+
breakpoint = index;
|
|
44
|
+
break;
|
|
45
|
+
} else {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return breakpoint;
|
|
50
|
+
};
|
|
26
51
|
const renderMenuItem = (item, index) => {
|
|
27
52
|
if (item.type === 'divider') {
|
|
28
53
|
return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
|
|
@@ -71,8 +96,44 @@ const renderMenuItem = (item, index) => {
|
|
|
71
96
|
}, label);
|
|
72
97
|
};
|
|
73
98
|
renderMenuItem.displayName = "renderMenuItem";
|
|
99
|
+
const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap) => {
|
|
100
|
+
var _childRegistry$entrie;
|
|
101
|
+
const registryEntries = Array.from((_childRegistry$entrie = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.entries()) !== null && _childRegistry$entrie !== void 0 ? _childRegistry$entrie : []).filter(entry => entry[1] !== null && (entry[1].type !== 'action' || entry[1].groupId === undefined));
|
|
102
|
+
if (registryEntries.length === 0) return new Set();
|
|
103
|
+
const numberOfItemsPossible = calculatePossibleItems(registryEntries, navWidth, gap);
|
|
104
|
+
const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(registryEntries, navWidth, gap, moreMenuWidth || MORE_BTN_WIDTH);
|
|
105
|
+
const menuItems = new Set();
|
|
106
|
+
|
|
107
|
+
// First, we check if we can fit all the items with their icons
|
|
108
|
+
if (registryEntries.length >= numberOfItemsPossible) {
|
|
109
|
+
/* Below is an accessibility requirement. Never show only one item in the overflow menu.
|
|
110
|
+
* If there is only one item left to display in the overflow menu according to the calculation,
|
|
111
|
+
* we need to pull another item from the list into the overflow menu.
|
|
112
|
+
*/
|
|
113
|
+
const numberOfItemsInMenu = registryEntries.length - numberOfItemsPossibleWithMoreMenu;
|
|
114
|
+
const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
|
|
115
|
+
for (const [index, [id, child]] of registryEntries.entries()) {
|
|
116
|
+
if (index < numberOfListItems) {
|
|
117
|
+
continue;
|
|
118
|
+
//if the last item is a divider
|
|
119
|
+
} else if (child.type === 'divider') {
|
|
120
|
+
if (index === numberOfListItems - 1 || index === numberOfListItems) {
|
|
121
|
+
continue;
|
|
122
|
+
} else {
|
|
123
|
+
menuItems.add(id);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
menuItems.add(id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return menuItems;
|
|
130
|
+
} else if (numberOfItemsPossible > registryEntries.length && hasActiveMenu) {
|
|
131
|
+
/* If the items fit in the list and there are items in the overflow menu, we need to move them back to the list */
|
|
132
|
+
return new Set();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
74
135
|
const ActionBar = props => {
|
|
75
|
-
const $ = c(
|
|
136
|
+
const $ = c(38);
|
|
76
137
|
const {
|
|
77
138
|
size: t0,
|
|
78
139
|
children,
|
|
@@ -86,257 +147,276 @@ const ActionBar = props => {
|
|
|
86
147
|
const flush = t1 === undefined ? false : t1;
|
|
87
148
|
const gap = t2 === undefined ? "condensed" : t2;
|
|
88
149
|
const listRef = useRef(null);
|
|
150
|
+
const [computedGap, setComputedGap] = useState(ACTIONBAR_ITEM_GAP);
|
|
89
151
|
const [childRegistry, setChildRegistry] = ActionBarItemsRegistry.useRegistryState();
|
|
152
|
+
const [menuItemIds, setMenuItemIds] = useState(_temp);
|
|
90
153
|
const navRef = useRef(null);
|
|
91
154
|
let t3;
|
|
92
155
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
93
|
-
t3 = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const fromIndex = from ? items.indexOf(from) : -1;
|
|
102
|
-
switch (direction) {
|
|
103
|
-
case "start":
|
|
104
|
-
{
|
|
105
|
-
return items[0];
|
|
106
|
-
}
|
|
107
|
-
case "end":
|
|
108
|
-
{
|
|
109
|
-
return items.at(-1);
|
|
110
|
-
}
|
|
111
|
-
case "next":
|
|
112
|
-
{
|
|
113
|
-
var _items;
|
|
114
|
-
return (_items = items[fromIndex + 1]) !== null && _items !== void 0 ? _items : items[0];
|
|
115
|
-
}
|
|
116
|
-
case "previous":
|
|
117
|
-
{
|
|
118
|
-
var _items2;
|
|
119
|
-
return (_items2 = items[fromIndex - 1]) !== null && _items2 !== void 0 ? _items2 : items.at(-1);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
156
|
+
t3 = () => {
|
|
157
|
+
if (!listRef.current) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const g = window.getComputedStyle(listRef.current).gap;
|
|
161
|
+
const parsed = parseFloat(g);
|
|
162
|
+
if (!Number.isNaN(parsed)) {
|
|
163
|
+
setComputedGap(parsed);
|
|
122
164
|
}
|
|
123
165
|
};
|
|
124
166
|
$[0] = t3;
|
|
125
167
|
} else {
|
|
126
168
|
t3 = $[0];
|
|
127
169
|
}
|
|
128
|
-
useFocusZone(t3);
|
|
129
170
|
let t4;
|
|
130
|
-
if ($[1] !==
|
|
131
|
-
t4 =
|
|
132
|
-
$[1] =
|
|
171
|
+
if ($[1] !== gap) {
|
|
172
|
+
t4 = [gap];
|
|
173
|
+
$[1] = gap;
|
|
133
174
|
$[2] = t4;
|
|
134
175
|
} else {
|
|
135
176
|
t4 = $[2];
|
|
136
177
|
}
|
|
137
|
-
|
|
178
|
+
useIsomorphicLayoutEffect(t3, t4);
|
|
179
|
+
const moreMenuRef = useRef(null);
|
|
138
180
|
let t5;
|
|
139
|
-
if ($[3] !== size) {
|
|
140
|
-
t5 = {
|
|
141
|
-
|
|
181
|
+
if ($[3] !== childRegistry || $[4] !== computedGap || $[5] !== menuItemIds.size) {
|
|
182
|
+
t5 = resizeObserverEntries => {
|
|
183
|
+
var _moreMenuRef$current$, _moreMenuRef$current;
|
|
184
|
+
const navWidth = resizeObserverEntries[0].contentRect.width;
|
|
185
|
+
const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
|
|
186
|
+
const hasActiveMenu = menuItemIds.size > 0;
|
|
187
|
+
if (navWidth > 0) {
|
|
188
|
+
const newMenuItemIds = getMenuItems(navWidth, moreMenuWidth, childRegistry, hasActiveMenu, computedGap);
|
|
189
|
+
if (newMenuItemIds) {
|
|
190
|
+
setMenuItemIds(newMenuItemIds);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
142
193
|
};
|
|
143
|
-
$[3] =
|
|
144
|
-
$[4] =
|
|
194
|
+
$[3] = childRegistry;
|
|
195
|
+
$[4] = computedGap;
|
|
196
|
+
$[5] = menuItemIds.size;
|
|
197
|
+
$[6] = t5;
|
|
145
198
|
} else {
|
|
146
|
-
t5 = $[
|
|
199
|
+
t5 = $[6];
|
|
147
200
|
}
|
|
201
|
+
useResizeObserver(t5, navRef);
|
|
148
202
|
let t6;
|
|
149
|
-
if ($[
|
|
150
|
-
t6 =
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
203
|
+
if ($[7] !== menuItemIds) {
|
|
204
|
+
t6 = id => !menuItemIds.has(id);
|
|
205
|
+
$[7] = menuItemIds;
|
|
206
|
+
$[8] = t6;
|
|
153
207
|
} else {
|
|
154
|
-
t6 = $[
|
|
208
|
+
t6 = $[8];
|
|
155
209
|
}
|
|
156
|
-
const
|
|
157
|
-
let
|
|
158
|
-
if ($[
|
|
159
|
-
|
|
160
|
-
|
|
210
|
+
const isVisibleChild = t6;
|
|
211
|
+
let t7;
|
|
212
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
213
|
+
t7 = {
|
|
214
|
+
containerRef: listRef,
|
|
215
|
+
bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
|
|
216
|
+
focusOutBehavior: "wrap"
|
|
217
|
+
};
|
|
218
|
+
$[9] = t7;
|
|
161
219
|
} else {
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
$[10] =
|
|
220
|
+
t7 = $[9];
|
|
221
|
+
}
|
|
222
|
+
useFocusZone(t7);
|
|
223
|
+
let groupedItemsMap;
|
|
224
|
+
if ($[10] !== childRegistry) {
|
|
225
|
+
groupedItemsMap = new Map();
|
|
226
|
+
for (const [key, childProps] of childRegistry !== null && childRegistry !== void 0 ? childRegistry : []) {
|
|
227
|
+
if (childProps.type === "action" && childProps.groupId) {
|
|
228
|
+
const existingGroup = groupedItemsMap.get(childProps.groupId) || [];
|
|
229
|
+
existingGroup.push([key, childProps]);
|
|
230
|
+
groupedItemsMap.set(childProps.groupId, existingGroup);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
$[10] = childRegistry;
|
|
234
|
+
$[11] = groupedItemsMap;
|
|
176
235
|
} else {
|
|
177
|
-
|
|
236
|
+
groupedItemsMap = $[11];
|
|
178
237
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"data-more-button-inactive": t11,
|
|
190
|
-
size: size
|
|
191
|
-
})
|
|
192
|
-
});
|
|
193
|
-
$[11] = size;
|
|
194
|
-
$[12] = t10;
|
|
195
|
-
$[13] = t11;
|
|
196
|
-
$[14] = t12;
|
|
238
|
+
const groupedItems = groupedItemsMap;
|
|
239
|
+
let t8;
|
|
240
|
+
if ($[12] !== isVisibleChild || $[13] !== size) {
|
|
241
|
+
t8 = {
|
|
242
|
+
size,
|
|
243
|
+
isVisibleChild
|
|
244
|
+
};
|
|
245
|
+
$[12] = isVisibleChild;
|
|
246
|
+
$[13] = size;
|
|
247
|
+
$[14] = t8;
|
|
197
248
|
} else {
|
|
198
|
-
|
|
249
|
+
t8 = $[14];
|
|
199
250
|
}
|
|
200
|
-
let
|
|
201
|
-
if ($[15] !==
|
|
202
|
-
|
|
203
|
-
$[15] =
|
|
204
|
-
$[16] =
|
|
251
|
+
let t9;
|
|
252
|
+
if ($[15] !== className) {
|
|
253
|
+
t9 = clsx(className, styles.Nav);
|
|
254
|
+
$[15] = className;
|
|
255
|
+
$[16] = t9;
|
|
205
256
|
} else {
|
|
206
|
-
|
|
257
|
+
t9 = $[16];
|
|
207
258
|
}
|
|
208
|
-
let
|
|
209
|
-
if ($[17] !==
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
})
|
|
259
|
+
let t10;
|
|
260
|
+
if ($[17] !== children || $[18] !== setChildRegistry) {
|
|
261
|
+
t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
|
|
262
|
+
setRegistry: setChildRegistry,
|
|
263
|
+
children: children
|
|
214
264
|
});
|
|
215
|
-
$[17] =
|
|
216
|
-
$[18] =
|
|
265
|
+
$[17] = children;
|
|
266
|
+
$[18] = setChildRegistry;
|
|
267
|
+
$[19] = t10;
|
|
217
268
|
} else {
|
|
218
|
-
|
|
269
|
+
t10 = $[19];
|
|
219
270
|
}
|
|
220
|
-
let
|
|
221
|
-
if ($[
|
|
222
|
-
|
|
223
|
-
children: [
|
|
271
|
+
let t11;
|
|
272
|
+
if ($[20] !== ariaLabel || $[21] !== childRegistry || $[22] !== groupedItems || $[23] !== menuItemIds) {
|
|
273
|
+
t11 = menuItemIds.size > 0 && /*#__PURE__*/jsxs(ActionMenu, {
|
|
274
|
+
children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
|
|
275
|
+
children: /*#__PURE__*/jsx(IconButton, {
|
|
276
|
+
variant: "invisible",
|
|
277
|
+
"aria-label": `More ${ariaLabel} items`,
|
|
278
|
+
icon: KebabHorizontalIcon
|
|
279
|
+
})
|
|
280
|
+
}), /*#__PURE__*/jsx(ActionMenu.Overlay, {
|
|
281
|
+
children: /*#__PURE__*/jsx(ActionList, {
|
|
282
|
+
children: Array.from(menuItemIds).map(id_0 => {
|
|
283
|
+
const menuItem = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.get(id_0);
|
|
284
|
+
if (!menuItem) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
if (menuItem.type === "divider") {
|
|
288
|
+
return /*#__PURE__*/jsx(ActionList.Divider, {}, id_0);
|
|
289
|
+
} else {
|
|
290
|
+
if (menuItem.type === "action") {
|
|
291
|
+
const {
|
|
292
|
+
onClick,
|
|
293
|
+
icon: Icon,
|
|
294
|
+
label,
|
|
295
|
+
disabled
|
|
296
|
+
} = menuItem;
|
|
297
|
+
return /*#__PURE__*/jsxs(ActionList.Item, {
|
|
298
|
+
onSelect: event => {
|
|
299
|
+
typeof onClick === "function" && onClick(event);
|
|
300
|
+
},
|
|
301
|
+
disabled: disabled,
|
|
302
|
+
children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
|
|
303
|
+
children: /*#__PURE__*/jsx(Icon, {})
|
|
304
|
+
}), label]
|
|
305
|
+
}, label);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (menuItem.type === "menu") {
|
|
309
|
+
const menuItems = menuItem.items;
|
|
310
|
+
const {
|
|
311
|
+
icon: Icon_0,
|
|
312
|
+
label: label_0,
|
|
313
|
+
returnFocusRef
|
|
314
|
+
} = menuItem;
|
|
315
|
+
return /*#__PURE__*/jsxs(ActionMenu, {
|
|
316
|
+
children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
|
|
317
|
+
children: /*#__PURE__*/jsxs(ActionList.Item, {
|
|
318
|
+
children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
|
|
319
|
+
children: /*#__PURE__*/jsx(Icon_0, {})
|
|
320
|
+
}) : null, label_0]
|
|
321
|
+
})
|
|
322
|
+
}), /*#__PURE__*/jsx(ActionMenu.Overlay, {
|
|
323
|
+
...(returnFocusRef && {
|
|
324
|
+
returnFocusRef
|
|
325
|
+
}),
|
|
326
|
+
children: /*#__PURE__*/jsx(ActionList, {
|
|
327
|
+
children: menuItems.map(_temp2)
|
|
328
|
+
})
|
|
329
|
+
})]
|
|
330
|
+
}, id_0);
|
|
331
|
+
}
|
|
332
|
+
const groupedMenuItems = groupedItems.get(id_0) || [];
|
|
333
|
+
if (menuItem.type === "group") {
|
|
334
|
+
return /*#__PURE__*/jsx(React.Fragment, {
|
|
335
|
+
children: groupedMenuItems.map(_temp3)
|
|
336
|
+
}, id_0);
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
})]
|
|
224
341
|
});
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
342
|
+
$[20] = ariaLabel;
|
|
343
|
+
$[21] = childRegistry;
|
|
344
|
+
$[22] = groupedItems;
|
|
345
|
+
$[23] = menuItemIds;
|
|
346
|
+
$[24] = t11;
|
|
228
347
|
} else {
|
|
229
|
-
|
|
348
|
+
t11 = $[24];
|
|
230
349
|
}
|
|
231
|
-
let
|
|
232
|
-
if ($[
|
|
233
|
-
|
|
350
|
+
let t12;
|
|
351
|
+
if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
|
|
352
|
+
t12 = /*#__PURE__*/jsxs("div", {
|
|
234
353
|
ref: listRef,
|
|
235
354
|
role: "toolbar",
|
|
236
355
|
className: styles.List,
|
|
237
356
|
"aria-label": ariaLabel,
|
|
238
357
|
"aria-labelledby": ariaLabelledBy,
|
|
239
358
|
"data-gap": gap,
|
|
240
|
-
|
|
241
|
-
"data-has-overflow": t7,
|
|
242
|
-
children: [t9, t15]
|
|
359
|
+
children: [t10, t11]
|
|
243
360
|
});
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[28] = t9;
|
|
251
|
-
$[29] = t16;
|
|
361
|
+
$[25] = ariaLabel;
|
|
362
|
+
$[26] = ariaLabelledBy;
|
|
363
|
+
$[27] = gap;
|
|
364
|
+
$[28] = t10;
|
|
365
|
+
$[29] = t11;
|
|
366
|
+
$[30] = t12;
|
|
252
367
|
} else {
|
|
253
|
-
|
|
368
|
+
t12 = $[30];
|
|
254
369
|
}
|
|
255
|
-
let
|
|
256
|
-
if ($[
|
|
257
|
-
|
|
370
|
+
let t13;
|
|
371
|
+
if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
|
|
372
|
+
t13 = /*#__PURE__*/jsx("div", {
|
|
258
373
|
ref: navRef,
|
|
259
|
-
className:
|
|
374
|
+
className: t9,
|
|
260
375
|
"data-flush": flush,
|
|
261
|
-
children:
|
|
376
|
+
children: t12
|
|
262
377
|
});
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
$[
|
|
266
|
-
$[
|
|
378
|
+
$[31] = flush;
|
|
379
|
+
$[32] = t12;
|
|
380
|
+
$[33] = t9;
|
|
381
|
+
$[34] = t13;
|
|
267
382
|
} else {
|
|
268
|
-
|
|
383
|
+
t13 = $[34];
|
|
269
384
|
}
|
|
270
|
-
let
|
|
271
|
-
if ($[
|
|
272
|
-
|
|
273
|
-
value:
|
|
274
|
-
children:
|
|
385
|
+
let t14;
|
|
386
|
+
if ($[35] !== t13 || $[36] !== t8) {
|
|
387
|
+
t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
|
|
388
|
+
value: t8,
|
|
389
|
+
children: t13
|
|
275
390
|
});
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
278
|
-
$[
|
|
391
|
+
$[35] = t13;
|
|
392
|
+
$[36] = t8;
|
|
393
|
+
$[37] = t14;
|
|
279
394
|
} else {
|
|
280
|
-
|
|
395
|
+
t14 = $[37];
|
|
281
396
|
}
|
|
282
|
-
return
|
|
397
|
+
return t14;
|
|
283
398
|
};
|
|
284
|
-
function
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
|
|
288
|
-
const isInGroup = isGroupOverflowing !== undefined;
|
|
399
|
+
function useWidth(ref) {
|
|
400
|
+
const $ = c(3);
|
|
401
|
+
const [width, setWidth] = useState(-1);
|
|
289
402
|
let t0;
|
|
290
|
-
if ($[0] !== isInGroup || $[1] !== ref) {
|
|
291
|
-
t0 = onChange => {
|
|
292
|
-
if (isInGroup) {
|
|
293
|
-
return _temp4;
|
|
294
|
-
}
|
|
295
|
-
const observer = new IntersectionObserver(() => onChange(), {
|
|
296
|
-
threshold: 1
|
|
297
|
-
});
|
|
298
|
-
if (ref.current) {
|
|
299
|
-
observer.observe(ref.current);
|
|
300
|
-
}
|
|
301
|
-
return () => observer.disconnect();
|
|
302
|
-
};
|
|
303
|
-
$[0] = isInGroup;
|
|
304
|
-
$[1] = ref;
|
|
305
|
-
$[2] = t0;
|
|
306
|
-
} else {
|
|
307
|
-
t0 = $[2];
|
|
308
|
-
}
|
|
309
|
-
const subscribeIntersectionObserver = t0;
|
|
310
403
|
let t1;
|
|
311
|
-
if ($[
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
} else {
|
|
316
|
-
t1 = $[4];
|
|
317
|
-
}
|
|
318
|
-
const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp5);
|
|
319
|
-
const isOverflowing = isGroupOverflowing || isItemOverflowing;
|
|
320
|
-
ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
|
|
321
|
-
const t2 = isOverflowing ? "" : undefined;
|
|
322
|
-
let t3;
|
|
323
|
-
if ($[5] !== isOverflowing || $[6] !== t2) {
|
|
324
|
-
t3 = {
|
|
325
|
-
isOverflowing,
|
|
326
|
-
dataOverflowingAttr: t2
|
|
404
|
+
if ($[0] !== ref) {
|
|
405
|
+
t0 = () => {
|
|
406
|
+
var _ref$current$getBound, _ref$current;
|
|
407
|
+
return setWidth((_ref$current$getBound = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().width) !== null && _ref$current$getBound !== void 0 ? _ref$current$getBound : -1);
|
|
327
408
|
};
|
|
328
|
-
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
409
|
+
t1 = [ref];
|
|
410
|
+
$[0] = ref;
|
|
411
|
+
$[1] = t0;
|
|
412
|
+
$[2] = t1;
|
|
331
413
|
} else {
|
|
332
|
-
|
|
414
|
+
t0 = $[1];
|
|
415
|
+
t1 = $[2];
|
|
333
416
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
function _temp5() {
|
|
337
|
-
return false;
|
|
417
|
+
useIsomorphicLayoutEffect(t0, t1);
|
|
418
|
+
return width;
|
|
338
419
|
}
|
|
339
|
-
function _temp4() {}
|
|
340
420
|
const ActionBarIconButton = /*#__PURE__*/forwardRef(({
|
|
341
421
|
disabled,
|
|
342
422
|
onClick,
|
|
@@ -345,36 +425,44 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef(({
|
|
|
345
425
|
const ref = useRef(null);
|
|
346
426
|
const mergedRef = useMergedRefs(ref, forwardedRef);
|
|
347
427
|
const {
|
|
348
|
-
size
|
|
428
|
+
size,
|
|
429
|
+
isVisibleChild
|
|
349
430
|
} = React.useContext(ActionBarContext);
|
|
431
|
+
const {
|
|
432
|
+
groupId
|
|
433
|
+
} = React.useContext(ActionBarGroupContext);
|
|
434
|
+
const width = useWidth(ref);
|
|
350
435
|
const {
|
|
351
436
|
['aria-label']: ariaLabel,
|
|
352
437
|
icon
|
|
353
438
|
} = props;
|
|
354
|
-
const {
|
|
355
|
-
dataOverflowingAttr
|
|
356
|
-
} = useActionBarItem(ref, useMemo(() => ({
|
|
439
|
+
const registryProps = useMemo(() => ({
|
|
357
440
|
type: 'action',
|
|
358
441
|
label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
|
|
359
442
|
icon,
|
|
360
443
|
disabled: !!disabled,
|
|
361
|
-
onClick: onClick
|
|
362
|
-
|
|
444
|
+
onClick: onClick,
|
|
445
|
+
width,
|
|
446
|
+
groupId: groupId !== null && groupId !== void 0 ? groupId : undefined
|
|
447
|
+
}), [ariaLabel, icon, disabled, onClick, groupId, width]);
|
|
448
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
363
449
|
const clickHandler = useCallback(event => {
|
|
364
450
|
if (disabled) return;
|
|
365
451
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
366
452
|
}, [disabled, onClick]);
|
|
453
|
+
if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
|
|
367
454
|
return /*#__PURE__*/jsx(IconButton, {
|
|
368
455
|
"aria-disabled": disabled,
|
|
369
456
|
ref: mergedRef,
|
|
370
457
|
size: size,
|
|
371
458
|
onClick: clickHandler,
|
|
372
459
|
...props,
|
|
373
|
-
variant: "invisible"
|
|
374
|
-
"data-overflowing": dataOverflowingAttr
|
|
460
|
+
variant: "invisible"
|
|
375
461
|
});
|
|
376
462
|
});
|
|
377
|
-
const ActionBarGroupContext = /*#__PURE__*/React.createContext(
|
|
463
|
+
const ActionBarGroupContext = /*#__PURE__*/React.createContext({
|
|
464
|
+
groupId: null
|
|
465
|
+
});
|
|
378
466
|
const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
379
467
|
const $ = c(10);
|
|
380
468
|
const {
|
|
@@ -382,39 +470,38 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
382
470
|
} = t0;
|
|
383
471
|
const backupRef = useRef(null);
|
|
384
472
|
const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
473
|
+
const width = useWidth(ref);
|
|
385
474
|
let t1;
|
|
386
|
-
if ($[0]
|
|
475
|
+
if ($[0] !== width) {
|
|
387
476
|
t1 = {
|
|
388
|
-
type: "group"
|
|
477
|
+
type: "group",
|
|
478
|
+
width
|
|
389
479
|
};
|
|
390
|
-
$[0] =
|
|
480
|
+
$[0] = width;
|
|
481
|
+
$[1] = t1;
|
|
391
482
|
} else {
|
|
392
|
-
t1 = $[
|
|
483
|
+
t1 = $[1];
|
|
393
484
|
}
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
isOverflowing
|
|
397
|
-
} = useActionBarItem(ref, t1);
|
|
485
|
+
const registryProps = t1;
|
|
486
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
398
487
|
let t2;
|
|
399
|
-
if ($[
|
|
488
|
+
if ($[2] !== id) {
|
|
400
489
|
t2 = {
|
|
401
|
-
|
|
490
|
+
groupId: id
|
|
402
491
|
};
|
|
403
|
-
$[
|
|
404
|
-
$[
|
|
492
|
+
$[2] = id;
|
|
493
|
+
$[3] = t2;
|
|
405
494
|
} else {
|
|
406
|
-
t2 = $[
|
|
495
|
+
t2 = $[3];
|
|
407
496
|
}
|
|
408
497
|
let t3;
|
|
409
|
-
if ($[
|
|
498
|
+
if ($[4] !== children || $[5] !== ref) {
|
|
410
499
|
t3 = /*#__PURE__*/jsx("div", {
|
|
411
500
|
className: styles.Group,
|
|
412
501
|
ref: ref,
|
|
413
|
-
"data-overflowing": dataOverflowingAttr,
|
|
414
502
|
children: children
|
|
415
503
|
});
|
|
416
|
-
$[
|
|
417
|
-
$[4] = dataOverflowingAttr;
|
|
504
|
+
$[4] = children;
|
|
418
505
|
$[5] = ref;
|
|
419
506
|
$[6] = t3;
|
|
420
507
|
} else {
|
|
@@ -468,12 +555,17 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
468
555
|
}
|
|
469
556
|
const backupRef = useRef(null);
|
|
470
557
|
const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
558
|
+
const {
|
|
559
|
+
isVisibleChild
|
|
560
|
+
} = React.useContext(ActionBarContext);
|
|
471
561
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
562
|
+
const width = useWidth(ref);
|
|
472
563
|
const t1 = overflowIcon ? overflowIcon : icon;
|
|
473
564
|
let t2;
|
|
474
|
-
if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
|
|
565
|
+
if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
|
|
475
566
|
t2 = {
|
|
476
567
|
type: "menu",
|
|
568
|
+
width,
|
|
477
569
|
label: ariaLabel,
|
|
478
570
|
icon: t1,
|
|
479
571
|
returnFocusRef,
|
|
@@ -483,26 +575,27 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
483
575
|
$[8] = items;
|
|
484
576
|
$[9] = returnFocusRef;
|
|
485
577
|
$[10] = t1;
|
|
486
|
-
$[11] =
|
|
578
|
+
$[11] = width;
|
|
579
|
+
$[12] = t2;
|
|
487
580
|
} else {
|
|
488
|
-
t2 = $[
|
|
581
|
+
t2 = $[12];
|
|
582
|
+
}
|
|
583
|
+
const registryProps = t2;
|
|
584
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
585
|
+
if (!isVisibleChild(id)) {
|
|
586
|
+
return null;
|
|
489
587
|
}
|
|
490
|
-
const {
|
|
491
|
-
dataOverflowingAttr
|
|
492
|
-
} = useActionBarItem(ref, t2);
|
|
493
588
|
let t3;
|
|
494
|
-
if ($[
|
|
589
|
+
if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
|
|
495
590
|
t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
|
|
496
591
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
497
592
|
variant: "invisible",
|
|
498
593
|
"aria-label": ariaLabel,
|
|
499
594
|
icon: icon,
|
|
500
|
-
...props
|
|
501
|
-
"data-overflowing": dataOverflowingAttr
|
|
595
|
+
...props
|
|
502
596
|
})
|
|
503
597
|
});
|
|
504
|
-
$[
|
|
505
|
-
$[13] = dataOverflowingAttr;
|
|
598
|
+
$[13] = ariaLabel;
|
|
506
599
|
$[14] = icon;
|
|
507
600
|
$[15] = props;
|
|
508
601
|
$[16] = t3;
|
|
@@ -521,7 +614,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
521
614
|
}
|
|
522
615
|
let t5;
|
|
523
616
|
if ($[19] !== items) {
|
|
524
|
-
t5 = items.map(
|
|
617
|
+
t5 = items.map(_temp4);
|
|
525
618
|
$[19] = items;
|
|
526
619
|
$[20] = t5;
|
|
527
620
|
} else {
|
|
@@ -570,88 +663,68 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
|
570
663
|
const VerticalDivider = () => {
|
|
571
664
|
const $ = c(3);
|
|
572
665
|
const ref = useRef(null);
|
|
666
|
+
const {
|
|
667
|
+
isVisibleChild
|
|
668
|
+
} = React.useContext(ActionBarContext);
|
|
669
|
+
const width = useWidth(ref);
|
|
573
670
|
let t0;
|
|
574
|
-
if ($[0]
|
|
671
|
+
if ($[0] !== width) {
|
|
575
672
|
t0 = {
|
|
576
|
-
type: "divider"
|
|
673
|
+
type: "divider",
|
|
674
|
+
width
|
|
577
675
|
};
|
|
578
|
-
$[0] =
|
|
676
|
+
$[0] = width;
|
|
677
|
+
$[1] = t0;
|
|
579
678
|
} else {
|
|
580
|
-
t0 = $[
|
|
679
|
+
t0 = $[1];
|
|
680
|
+
}
|
|
681
|
+
const registryProps = t0;
|
|
682
|
+
const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
|
|
683
|
+
if (!isVisibleChild(id)) {
|
|
684
|
+
return null;
|
|
581
685
|
}
|
|
582
|
-
const {
|
|
583
|
-
dataOverflowingAttr
|
|
584
|
-
} = useActionBarItem(ref, t0);
|
|
585
686
|
let t1;
|
|
586
|
-
if ($[
|
|
687
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
587
688
|
t1 = /*#__PURE__*/jsx("div", {
|
|
588
689
|
ref: ref,
|
|
589
690
|
"data-component": "ActionBar.VerticalDivider",
|
|
590
691
|
"aria-hidden": "true",
|
|
591
|
-
className: styles.Divider
|
|
592
|
-
"data-overflowing": dataOverflowingAttr
|
|
692
|
+
className: styles.Divider
|
|
593
693
|
});
|
|
594
|
-
$[1] = dataOverflowingAttr;
|
|
595
694
|
$[2] = t1;
|
|
596
695
|
} else {
|
|
597
696
|
t1 = $[2];
|
|
598
697
|
}
|
|
599
698
|
return t1;
|
|
600
699
|
};
|
|
601
|
-
function _temp(
|
|
602
|
-
return
|
|
700
|
+
function _temp() {
|
|
701
|
+
return new Set();
|
|
603
702
|
}
|
|
604
703
|
function _temp2(item, index) {
|
|
605
704
|
return renderMenuItem(item, index);
|
|
606
705
|
}
|
|
607
706
|
function _temp3(t0) {
|
|
608
|
-
const [
|
|
609
|
-
if (
|
|
610
|
-
return /*#__PURE__*/jsx(ActionList.Divider, {}, id);
|
|
611
|
-
}
|
|
612
|
-
if (menuItem.type === "action") {
|
|
707
|
+
const [key_0, childProps_0] = t0;
|
|
708
|
+
if (childProps_0.type === "action") {
|
|
613
709
|
const {
|
|
614
|
-
onClick,
|
|
615
|
-
icon:
|
|
616
|
-
label,
|
|
617
|
-
disabled
|
|
618
|
-
} =
|
|
710
|
+
onClick: onClick_0,
|
|
711
|
+
icon: Icon_1,
|
|
712
|
+
label: label_1,
|
|
713
|
+
disabled: disabled_0
|
|
714
|
+
} = childProps_0;
|
|
619
715
|
return /*#__PURE__*/jsxs(ActionList.Item, {
|
|
620
|
-
onSelect:
|
|
621
|
-
typeof
|
|
716
|
+
onSelect: event_0 => {
|
|
717
|
+
typeof onClick_0 === "function" && onClick_0(event_0);
|
|
622
718
|
},
|
|
623
|
-
disabled:
|
|
719
|
+
disabled: disabled_0,
|
|
624
720
|
children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
|
|
625
|
-
children: /*#__PURE__*/jsx(
|
|
626
|
-
}),
|
|
627
|
-
},
|
|
628
|
-
}
|
|
629
|
-
if (menuItem.type === "menu") {
|
|
630
|
-
const menuItems = menuItem.items;
|
|
631
|
-
const {
|
|
632
|
-
icon: Icon_0,
|
|
633
|
-
label: label_0,
|
|
634
|
-
returnFocusRef
|
|
635
|
-
} = menuItem;
|
|
636
|
-
return /*#__PURE__*/jsxs(ActionMenu, {
|
|
637
|
-
children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
|
|
638
|
-
children: /*#__PURE__*/jsxs(ActionList.Item, {
|
|
639
|
-
children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
|
|
640
|
-
children: /*#__PURE__*/jsx(Icon_0, {})
|
|
641
|
-
}) : null, label_0]
|
|
642
|
-
})
|
|
643
|
-
}), /*#__PURE__*/jsx(ActionMenu.Overlay, {
|
|
644
|
-
...(returnFocusRef && {
|
|
645
|
-
returnFocusRef
|
|
646
|
-
}),
|
|
647
|
-
children: /*#__PURE__*/jsx(ActionList, {
|
|
648
|
-
children: menuItems.map(_temp2)
|
|
649
|
-
})
|
|
650
|
-
})]
|
|
651
|
-
}, id);
|
|
721
|
+
children: /*#__PURE__*/jsx(Icon_1, {})
|
|
722
|
+
}), label_1]
|
|
723
|
+
}, key_0);
|
|
652
724
|
}
|
|
725
|
+
return null;
|
|
653
726
|
}
|
|
654
|
-
function
|
|
727
|
+
function _temp4(item, index) {
|
|
655
728
|
return renderMenuItem(item, index);
|
|
656
729
|
}
|
|
657
730
|
|