@primer/react 0.0.0-20260617130545 → 0.0.0-20260617130554
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260617130554
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
- [#7976](https://github.com/primer/react/pull/7976) [`1fac927`](https://github.com/primer/react/commit/1fac9270c497c1904acbb3eb60805630aab82a97) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - NavList: add a small gap between items for readability, including before expanded sub-navs, behind the `primer_react_action_list_item_gap` feature flag
|
|
12
12
|
|
|
13
|
-
- [#
|
|
13
|
+
- [#7935](https://github.com/primer/react/pull/7935) [`2765933`](https://github.com/primer/react/commit/276593387ec84f72aeba02a940b5e0a4d0a026a9) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - ConfirmationDialog: `useConfirm`/`confirm` now removes its host element from `document.body` after the dialog is closed, and uses a fresh host element per call, so the empty container no longer lingers or leaks into other components and tests
|
|
14
14
|
|
|
15
15
|
- [#7929](https://github.com/primer/react/pull/7929) [`48c34ca`](https://github.com/primer/react/commit/48c34ca452a5449b0ba901783edb169b6a1e1882) Thanks [@joshblack](https://github.com/joshblack)! - FilteredActionList: Make body skeleton widths stable for server rendering
|
|
16
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC/B,OAAO,KAA6E,MAAM,OAAO,CAAA;AAUjG,OAAO,EAAC,KAAK,gBAAgB,EAAkB,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACrD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAA;IAC7C;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAC,CAAA;AA8GF,iBAAS,WAAW,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAiB,EAAE,OAAkB,EAAC,EAAE,gBAAgB,qBAwMzG;kBAxMQ,WAAW;;;AAoNpB,KAAK,0BAA0B,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,gBAAgB,CACpF,EAAE,EACF,GAAG,EACH;IACE,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CACF,CAAA;AAuBD,MAAM,MAAM,oBAAoB,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,0BAA0B,CAAC,EAAE,CAAC,CAAA;;YApBlG,EAAE,SAAS,KAAK,CAAC,WAAW;aANtB,EAAE;mBACI,OAAO;;aADb,EAAE;mBACI,OAAO;;;;;;;AA4BtB,wBAAiF;AAEjF;;GAEG;AACH,eAAO,MAAM,UAAU;WA5BpB,EAAE,SAAS,KAAK,CAAC,WAAW;aANtB,EAAE;mBACI,OAAO;;aADb,EAAE;mBACI,OAAO;;;;CAiCuD,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import React, { useRef, useState } from 'react';
|
|
3
|
+
import React, { useRef, useCallback, useState, useMemo, useEffect } from 'react';
|
|
4
4
|
import classes from './Breadcrumbs.module.css.js';
|
|
5
|
-
import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
|
|
6
5
|
import { ActionList } from '../ActionList/index.js';
|
|
7
6
|
import { IconButton } from '../Button/IconButton.js';
|
|
8
7
|
import { KebabHorizontalIcon } from '@primer/octicons-react';
|
|
@@ -207,350 +206,177 @@ const getValidChildren = children => {
|
|
|
207
206
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
207
|
return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child));
|
|
209
208
|
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// split actually changes, not on every sub-threshold resize. Kept outside the
|
|
217
|
-
// component so it has no hidden dependency on previous state and can be called
|
|
218
|
-
// directly during render.
|
|
219
|
-
function calculateOverflow({
|
|
220
|
-
availableWidth,
|
|
221
|
-
itemCount,
|
|
222
|
-
childArrayWidths,
|
|
223
|
-
menuButtonWidth,
|
|
224
|
-
overflow,
|
|
225
|
-
hideRoot
|
|
209
|
+
function Breadcrumbs({
|
|
210
|
+
className,
|
|
211
|
+
children,
|
|
212
|
+
style,
|
|
213
|
+
overflow = 'wrap',
|
|
214
|
+
variant = 'normal'
|
|
226
215
|
}) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
} else if (isNarrow && itemCount > 2) {
|
|
236
|
-
MIN_VISIBLE_ITEMS = 1;
|
|
237
|
-
}
|
|
238
|
-
const calculateVisibleItemsWidth = w => {
|
|
239
|
-
const widths = w.reduce((sum, width) => sum + width + 16, 0);
|
|
240
|
-
return !eHideRoot ? rootItemWidth + widths : widths;
|
|
241
|
-
};
|
|
242
|
-
let currentVisibleItemWidths = [...childArrayWidths];
|
|
243
|
-
let menuItemCount = 0;
|
|
244
|
-
if (availableWidth > 0 && currentVisibleItemWidths.length > 0) {
|
|
245
|
-
let visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths);
|
|
246
|
-
while ((overflow === 'menu' || overflow === 'menu-with-root') && (visibleItemsWidthTotal > availableWidth || currentVisibleItemWidths.length > MIN_VISIBLE_ITEMS)) {
|
|
247
|
-
menuItemCount += 1;
|
|
248
|
-
currentVisibleItemWidths = currentVisibleItemWidths.slice(1);
|
|
249
|
-
|
|
250
|
-
// A menu button is now shown, so its width is always part of the total.
|
|
251
|
-
visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths) + menuButtonWidth;
|
|
252
|
-
if (currentVisibleItemWidths.length === 1 && visibleItemsWidthTotal > availableWidth) {
|
|
253
|
-
eHideRoot = true;
|
|
254
|
-
break;
|
|
255
|
-
} else {
|
|
256
|
-
eHideRoot = hideRoot;
|
|
216
|
+
const containerRef = useRef(null);
|
|
217
|
+
const measureMenuButton = useCallback(element => {
|
|
218
|
+
if (element) {
|
|
219
|
+
const iconButtonElement = element.querySelector('button[data-component="IconButton"]');
|
|
220
|
+
if (iconButtonElement) {
|
|
221
|
+
const measuredWidth = iconButtonElement.offsetWidth;
|
|
222
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
223
|
+
setMenuButtonWidth(measuredWidth);
|
|
257
224
|
}
|
|
258
225
|
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
function Breadcrumbs(t0) {
|
|
266
|
-
const $ = c(48);
|
|
267
|
-
const {
|
|
268
|
-
className,
|
|
269
|
-
children,
|
|
270
|
-
style,
|
|
271
|
-
overflow: t1,
|
|
272
|
-
variant: t2
|
|
273
|
-
} = t0;
|
|
274
|
-
const overflow = t1 === undefined ? "wrap" : t1;
|
|
275
|
-
const variant = t2 === undefined ? "normal" : t2;
|
|
276
|
-
const containerRef = useRef(null);
|
|
277
|
-
const hideRoot = !(overflow === "menu-with-root");
|
|
278
|
-
let t3;
|
|
279
|
-
if ($[0] !== children) {
|
|
280
|
-
t3 = getValidChildren(children);
|
|
281
|
-
$[0] = children;
|
|
282
|
-
$[1] = t3;
|
|
283
|
-
} else {
|
|
284
|
-
t3 = $[1];
|
|
285
|
-
}
|
|
286
|
-
const childArray = t3;
|
|
226
|
+
}, []);
|
|
227
|
+
const hideRoot = !(overflow === 'menu-with-root');
|
|
228
|
+
const [effectiveHideRoot, setEffectiveHideRoot] = useState(hideRoot);
|
|
229
|
+
const childArray = useMemo(() => getValidChildren(children), [children]);
|
|
287
230
|
const rootItem = childArray[0];
|
|
288
|
-
|
|
289
|
-
|
|
231
|
+
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
|
+
const [visibleItems, setVisibleItems] = useState(() => childArray);
|
|
234
|
+
const [childArrayWidths, setChildArrayWidths] = useState(() => []);
|
|
235
|
+
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
const [menuItems, setMenuItems] = useState([]);
|
|
238
|
+
const [rootItemWidth, setRootItemWidth] = useState(0);
|
|
239
|
+
const MENU_BUTTON_FALLBACK_WIDTH = 32; // Design system small IconButton
|
|
290
240
|
const [menuButtonWidth, setMenuButtonWidth] = useState(MENU_BUTTON_FALLBACK_WIDTH);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
var _containerRef$current;
|
|
243
|
+
const listElement = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('ol');
|
|
244
|
+
if (listElement && listElement.children.length > 0 && listElement.children.length === childArray.length) {
|
|
245
|
+
const listElementArray = Array.from(listElement.children);
|
|
246
|
+
const widths = listElementArray.map(child => child.offsetWidth);
|
|
247
|
+
setChildArrayWidths(widths);
|
|
248
|
+
setRootItemWidth(listElementArray[0].offsetWidth);
|
|
249
|
+
}
|
|
250
|
+
}, [childArray]);
|
|
251
|
+
const calculateOverflow = useCallback(availableWidth => {
|
|
252
|
+
let eHideRoot = effectiveHideRoot;
|
|
253
|
+
const MENU_BUTTON_WIDTH = menuButtonWidth;
|
|
254
|
+
const NARROW_BREAKPOINT = 544;
|
|
255
|
+
const isNarrow = availableWidth < NARROW_BREAKPOINT;
|
|
256
|
+
let MIN_VISIBLE_ITEMS = 4;
|
|
257
|
+
if (!eHideRoot) {
|
|
258
|
+
MIN_VISIBLE_ITEMS = 3;
|
|
259
|
+
} else if (isNarrow && childArray.length > 2) {
|
|
260
|
+
MIN_VISIBLE_ITEMS = 1;
|
|
261
|
+
}
|
|
262
|
+
const calculateVisibleItemsWidth = w => {
|
|
263
|
+
const widths_0 = w.reduce((sum, width) => sum + width + 16, 0);
|
|
264
|
+
return !eHideRoot ? rootItemWidth + widths_0 : widths_0;
|
|
301
265
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
const containerElement = containerRef.current;
|
|
314
|
-
if (!containerElement) {
|
|
315
|
-
return;
|
|
266
|
+
let currentVisibleItems = [...childArray];
|
|
267
|
+
let currentVisibleItemWidths = [...childArrayWidths];
|
|
268
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
|
+
let currentMenuItems = [];
|
|
270
|
+
let currentMenuItemsWidths = [];
|
|
271
|
+
if (availableWidth > 0 && currentVisibleItemWidths.length > 0) {
|
|
272
|
+
let visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths);
|
|
273
|
+
if (currentMenuItems.length > 0) {
|
|
274
|
+
visibleItemsWidthTotal += MENU_BUTTON_WIDTH;
|
|
316
275
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
$[6] = childArray;
|
|
335
|
-
$[7] = overflow;
|
|
336
|
-
$[8] = t6;
|
|
337
|
-
} else {
|
|
338
|
-
t6 = $[8];
|
|
339
|
-
}
|
|
340
|
-
useIsomorphicLayoutEffect(t5, t6);
|
|
341
|
-
let t7;
|
|
342
|
-
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
343
|
-
t7 = entries => {
|
|
344
|
-
if (entries[0]) {
|
|
345
|
-
const width = Math.round(entries[0].contentRect.width);
|
|
346
|
-
setContainerWidth(prev_1 => prev_1 === width ? prev_1 : width);
|
|
276
|
+
while ((overflow === 'menu' || overflow === 'menu-with-root') && (visibleItemsWidthTotal > availableWidth || currentVisibleItems.length > MIN_VISIBLE_ITEMS)) {
|
|
277
|
+
const itemToHide = currentVisibleItems[0];
|
|
278
|
+
const itemToHideWidth = currentVisibleItemWidths[0];
|
|
279
|
+
currentMenuItems = [...currentMenuItems, itemToHide];
|
|
280
|
+
currentMenuItemsWidths = [...currentMenuItemsWidths, itemToHideWidth];
|
|
281
|
+
currentVisibleItems = currentVisibleItems.slice(1);
|
|
282
|
+
currentVisibleItemWidths = currentVisibleItemWidths.slice(1);
|
|
283
|
+
visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths);
|
|
284
|
+
if (currentMenuItems.length > 0) {
|
|
285
|
+
visibleItemsWidthTotal += MENU_BUTTON_WIDTH;
|
|
286
|
+
}
|
|
287
|
+
if (currentVisibleItems.length === 1 && visibleItemsWidthTotal > availableWidth) {
|
|
288
|
+
eHideRoot = true;
|
|
289
|
+
break;
|
|
290
|
+
} else {
|
|
291
|
+
eHideRoot = hideRoot;
|
|
292
|
+
}
|
|
347
293
|
}
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
visibleItems: currentVisibleItems,
|
|
297
|
+
menuItems: currentMenuItems,
|
|
298
|
+
effectiveHideRoot: eHideRoot
|
|
348
299
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
t8 = $[10];
|
|
359
|
-
}
|
|
360
|
-
useResizeObserver(t7, containerRef, t8, overflow !== "wrap");
|
|
361
|
-
let t9;
|
|
362
|
-
bb0: {
|
|
363
|
-
if (overflow === "wrap" || childArrayWidths.length !== childArray.length) {
|
|
364
|
-
let t10;
|
|
365
|
-
if ($[11] !== hideRoot) {
|
|
366
|
-
t10 = {
|
|
367
|
-
menuItemCount: 0,
|
|
368
|
-
effectiveHideRoot: hideRoot
|
|
369
|
-
};
|
|
370
|
-
$[11] = hideRoot;
|
|
371
|
-
$[12] = t10;
|
|
372
|
-
} else {
|
|
373
|
-
t10 = $[12];
|
|
300
|
+
}, [childArray, childArrayWidths, effectiveHideRoot, hideRoot, overflow, rootItemWidth, menuButtonWidth]);
|
|
301
|
+
const handleResize = useCallback(entries => {
|
|
302
|
+
if (entries[0]) {
|
|
303
|
+
const containerWidth = entries[0].contentRect.width;
|
|
304
|
+
const result = calculateOverflow(containerWidth);
|
|
305
|
+
if (visibleItems.length !== result.visibleItems.length && menuItems.length !== result.menuItems.length || result.effectiveHideRoot !== effectiveHideRoot) {
|
|
306
|
+
setVisibleItems(result.visibleItems);
|
|
307
|
+
setMenuItems(result.menuItems);
|
|
308
|
+
setEffectiveHideRoot(result.effectiveHideRoot);
|
|
374
309
|
}
|
|
375
|
-
t9 = t10;
|
|
376
|
-
break bb0;
|
|
377
310
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
$[19] = t11;
|
|
396
|
-
} else {
|
|
397
|
-
t11 = $[19];
|
|
311
|
+
}, [calculateOverflow, effectiveHideRoot, menuItems.length, visibleItems.length]);
|
|
312
|
+
useResizeObserver(handleResize, containerRef);
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
// eslint-disable-next-line react-you-might-not-need-an-effect/no-event-handler
|
|
315
|
+
if ((overflow === 'menu' || overflow === 'menu-with-root') && childArray.length > 5 && menuItems.length === 0) {
|
|
316
|
+
var _containerRef$current2;
|
|
317
|
+
const containerWidth_0 = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetWidth) || 800;
|
|
318
|
+
const result_0 = calculateOverflow(containerWidth_0);
|
|
319
|
+
|
|
320
|
+
// eslint-disable-next-line react-you-might-not-need-an-effect/no-adjust-state-on-prop-change, react-you-might-not-need-an-effect/no-chain-state-updates
|
|
321
|
+
setVisibleItems(result_0.visibleItems);
|
|
322
|
+
|
|
323
|
+
// eslint-disable-next-line react-you-might-not-need-an-effect/no-adjust-state-on-prop-change, react-you-might-not-need-an-effect/no-chain-state-updates
|
|
324
|
+
setMenuItems(result_0.menuItems);
|
|
325
|
+
|
|
326
|
+
// eslint-disable-next-line react-you-might-not-need-an-effect/no-chain-state-updates, react-you-might-not-need-an-effect/no-derived-state
|
|
327
|
+
setEffectiveHideRoot(result_0.effectiveHideRoot);
|
|
398
328
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if ($[20] !== childArray || $[21] !== children || $[22] !== effectiveHideRoot || $[23] !== menuItemCount || $[24] !== overflow || $[25] !== rootItem) {
|
|
407
|
-
bb1: {
|
|
408
|
-
if (overflow === "wrap" || menuItemCount === 0) {
|
|
409
|
-
let t11;
|
|
410
|
-
if ($[27] !== children) {
|
|
411
|
-
t11 = React.Children.map(children, _temp4);
|
|
412
|
-
$[27] = children;
|
|
413
|
-
$[28] = t11;
|
|
414
|
-
} else {
|
|
415
|
-
t11 = $[28];
|
|
416
|
-
}
|
|
417
|
-
t10 = t11;
|
|
418
|
-
break bb1;
|
|
419
|
-
}
|
|
420
|
-
const menuItems = childArray.slice(0, menuItemCount);
|
|
421
|
-
const visibleItems = childArray.slice(menuItemCount);
|
|
422
|
-
const effectiveMenuItems = effectiveHideRoot ? menuItems : menuItems.slice(1);
|
|
423
|
-
const t11 = `${effectiveMenuItems.length} more breadcrumb items`;
|
|
424
|
-
let t12;
|
|
425
|
-
if ($[29] !== effectiveMenuItems || $[30] !== t11) {
|
|
426
|
-
t12 = /*#__PURE__*/jsx(BreadcrumbsMenuItem, {
|
|
427
|
-
ref: measureMenuButton,
|
|
428
|
-
items: effectiveMenuItems,
|
|
429
|
-
"aria-label": t11
|
|
430
|
-
});
|
|
431
|
-
$[29] = effectiveMenuItems;
|
|
432
|
-
$[30] = t11;
|
|
433
|
-
$[31] = t12;
|
|
434
|
-
} else {
|
|
435
|
-
t12 = $[31];
|
|
436
|
-
}
|
|
437
|
-
let t13;
|
|
438
|
-
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
439
|
-
t13 = /*#__PURE__*/jsx(ItemSeparator, {});
|
|
440
|
-
$[32] = t13;
|
|
441
|
-
} else {
|
|
442
|
-
t13 = $[32];
|
|
443
|
-
}
|
|
444
|
-
let t14;
|
|
445
|
-
if ($[33] !== t12) {
|
|
446
|
-
t14 = /*#__PURE__*/jsxs("li", {
|
|
447
|
-
className: classes.BreadcrumbsItem,
|
|
448
|
-
children: [t12, t13]
|
|
449
|
-
}, "breadcrumbs-menu");
|
|
450
|
-
$[33] = t12;
|
|
451
|
-
$[34] = t14;
|
|
452
|
-
} else {
|
|
453
|
-
t14 = $[34];
|
|
454
|
-
}
|
|
455
|
-
const menuElement = t14;
|
|
456
|
-
const visibleElements = visibleItems.map(_temp5);
|
|
457
|
-
let t15;
|
|
458
|
-
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
459
|
-
t15 = /*#__PURE__*/jsx(ItemSeparator, {});
|
|
460
|
-
$[35] = t15;
|
|
461
|
-
} else {
|
|
462
|
-
t15 = $[35];
|
|
463
|
-
}
|
|
464
|
-
let t16;
|
|
465
|
-
if ($[36] !== rootItem) {
|
|
466
|
-
t16 = /*#__PURE__*/jsxs("li", {
|
|
467
|
-
className: classes.BreadcrumbsItem,
|
|
468
|
-
children: [rootItem, t15]
|
|
469
|
-
}, "rootElement");
|
|
470
|
-
$[36] = rootItem;
|
|
471
|
-
$[37] = t16;
|
|
472
|
-
} else {
|
|
473
|
-
t16 = $[37];
|
|
474
|
-
}
|
|
475
|
-
const rootElement = t16;
|
|
476
|
-
if (effectiveHideRoot) {
|
|
477
|
-
t10 = [menuElement, ...visibleElements];
|
|
478
|
-
} else {
|
|
479
|
-
t10 = [rootElement, menuElement, ...visibleElements];
|
|
480
|
-
}
|
|
329
|
+
}, [overflow, childArray, calculateOverflow, menuItems.length]);
|
|
330
|
+
const finalChildren = React.useMemo(() => {
|
|
331
|
+
if (overflow === 'wrap' || menuItems.length === 0) {
|
|
332
|
+
return React.Children.map(children, child_0 => /*#__PURE__*/jsx("li", {
|
|
333
|
+
className: classes.ItemWrapper,
|
|
334
|
+
children: child_0
|
|
335
|
+
}));
|
|
481
336
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
337
|
+
let effectiveMenuItems = [...menuItems];
|
|
338
|
+
// In 'menu-with-root' mode, include the root item inside the menu even if it's visible in the breadcrumbs
|
|
339
|
+
if (!effectiveHideRoot) {
|
|
340
|
+
effectiveMenuItems = [...menuItems.slice(1)];
|
|
341
|
+
}
|
|
342
|
+
const menuElement = /*#__PURE__*/jsxs("li", {
|
|
343
|
+
className: classes.BreadcrumbsItem,
|
|
344
|
+
children: [/*#__PURE__*/jsx(BreadcrumbsMenuItem, {
|
|
345
|
+
ref: measureMenuButton,
|
|
346
|
+
items: effectiveMenuItems,
|
|
347
|
+
"aria-label": `${effectiveMenuItems.length} more breadcrumb items`
|
|
348
|
+
}), /*#__PURE__*/jsx(ItemSeparator, {})]
|
|
349
|
+
}, "breadcrumbs-menu");
|
|
350
|
+
const visibleElements = visibleItems.map((child_1, index) => /*#__PURE__*/jsxs("li", {
|
|
351
|
+
className: classes.BreadcrumbsItem,
|
|
352
|
+
children: [child_1, /*#__PURE__*/jsx(ItemSeparator, {})]
|
|
353
|
+
}, `visible + ${index}`));
|
|
354
|
+
const rootElement = /*#__PURE__*/jsxs("li", {
|
|
355
|
+
className: classes.BreadcrumbsItem,
|
|
356
|
+
children: [rootItem, /*#__PURE__*/jsx(ItemSeparator, {})]
|
|
357
|
+
}, `rootElement`);
|
|
358
|
+
if (effectiveHideRoot) {
|
|
359
|
+
// Show: [overflow menu, leaf breadcrumb]
|
|
360
|
+
return [menuElement, ...visibleElements];
|
|
361
|
+
} else {
|
|
362
|
+
// Show: [root breadcrumb, overflow menu, leaf breadcrumb]
|
|
363
|
+
return [rootElement, menuElement, ...visibleElements];
|
|
364
|
+
}
|
|
365
|
+
}, [overflow, menuItems, effectiveHideRoot, measureMenuButton, visibleItems, rootItem, children]);
|
|
366
|
+
return /*#__PURE__*/jsx("nav", {
|
|
367
|
+
className: clsx(className, classes.BreadcrumbsBase),
|
|
368
|
+
"aria-label": "Breadcrumbs",
|
|
369
|
+
style: style,
|
|
370
|
+
ref: containerRef,
|
|
371
|
+
"data-overflow": overflow,
|
|
372
|
+
"data-variant": variant,
|
|
373
|
+
"data-component": "Breadcrumbs",
|
|
374
|
+
children: /*#__PURE__*/jsx(BreadcrumbsList, {
|
|
504
375
|
children: finalChildren
|
|
505
|
-
})
|
|
506
|
-
$[40] = finalChildren;
|
|
507
|
-
$[41] = t12;
|
|
508
|
-
} else {
|
|
509
|
-
t12 = $[41];
|
|
510
|
-
}
|
|
511
|
-
let t13;
|
|
512
|
-
if ($[42] !== overflow || $[43] !== style || $[44] !== t11 || $[45] !== t12 || $[46] !== variant) {
|
|
513
|
-
t13 = /*#__PURE__*/jsx("nav", {
|
|
514
|
-
className: t11,
|
|
515
|
-
"aria-label": "Breadcrumbs",
|
|
516
|
-
style: style,
|
|
517
|
-
ref: containerRef,
|
|
518
|
-
"data-overflow": overflow,
|
|
519
|
-
"data-variant": variant,
|
|
520
|
-
"data-component": "Breadcrumbs",
|
|
521
|
-
children: t12
|
|
522
|
-
});
|
|
523
|
-
$[42] = overflow;
|
|
524
|
-
$[43] = style;
|
|
525
|
-
$[44] = t11;
|
|
526
|
-
$[45] = t12;
|
|
527
|
-
$[46] = variant;
|
|
528
|
-
$[47] = t13;
|
|
529
|
-
} else {
|
|
530
|
-
t13 = $[47];
|
|
531
|
-
}
|
|
532
|
-
return t13;
|
|
533
|
-
}
|
|
534
|
-
function _temp5(child_1, index) {
|
|
535
|
-
return /*#__PURE__*/jsxs("li", {
|
|
536
|
-
className: classes.BreadcrumbsItem,
|
|
537
|
-
children: [child_1, /*#__PURE__*/jsx(ItemSeparator, {})]
|
|
538
|
-
}, `visible + ${index}`);
|
|
539
|
-
}
|
|
540
|
-
_temp5.displayName = "_temp5";
|
|
541
|
-
function _temp4(child_0) {
|
|
542
|
-
return /*#__PURE__*/jsx("li", {
|
|
543
|
-
className: classes.ItemWrapper,
|
|
544
|
-
children: child_0
|
|
376
|
+
})
|
|
545
377
|
});
|
|
546
378
|
}
|
|
547
|
-
|
|
548
|
-
function _temp3(child) {
|
|
549
|
-
return child.offsetWidth;
|
|
550
|
-
}
|
|
551
|
-
function _temp2() {
|
|
552
|
-
return [];
|
|
553
|
-
}
|
|
379
|
+
Breadcrumbs.displayName = "Breadcrumbs";
|
|
554
380
|
const ItemSeparator = () => {
|
|
555
381
|
const $ = c(1);
|
|
556
382
|
let t0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfirm.d.ts","sourceRoot":"","sources":["../../src/ConfirmationDialog/useConfirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAGxC,OAAO,EAAqB,KAAK,uBAAuB,EAAC,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"useConfirm.d.ts","sourceRoot":"","sources":["../../src/ConfirmationDialog/useConfirm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAGxC,OAAO,EAAqB,KAAK,uBAAuB,EAAC,MAAM,sBAAsB,CAAA;AAErF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,uBAAuB,EAAE,SAAS,CAAC,GAAG;IAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;CAAC,CAAA;AAuBlG;;;;GAIG;AACH,wBAAgB,UAAU,cACa,cAAc,sBAIpD"}
|
|
@@ -3,23 +3,19 @@ import { createRoot } from 'react-dom/client';
|
|
|
3
3
|
import BaseStyles from '../BaseStyles.js';
|
|
4
4
|
import { ConfirmationDialog } from './ConfirmationDialog.js';
|
|
5
5
|
|
|
6
|
-
let hostElement = null;
|
|
7
6
|
async function confirm(options) {
|
|
8
7
|
const {
|
|
9
8
|
content,
|
|
10
9
|
...confirmationDialogProps
|
|
11
10
|
} = options;
|
|
12
11
|
return new Promise(resolve => {
|
|
13
|
-
hostElement
|
|
14
|
-
|
|
12
|
+
const hostElement = document.createElement('div');
|
|
13
|
+
document.body.append(hostElement);
|
|
15
14
|
const root = createRoot(hostElement);
|
|
16
15
|
const onClose = gesture => {
|
|
17
16
|
root.unmount();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} else {
|
|
21
|
-
resolve(false);
|
|
22
|
-
}
|
|
17
|
+
hostElement.remove();
|
|
18
|
+
resolve(gesture === 'confirm');
|
|
23
19
|
};
|
|
24
20
|
root.render(/*#__PURE__*/React.createElement(BaseStyles, null, /*#__PURE__*/React.createElement(ConfirmationDialog, {
|
|
25
21
|
...confirmationDialogProps,
|
package/package.json
CHANGED