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