@primer/react 0.0.0-20261105162617 → 0.0.0-20261106221139

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +25 -7
  2. package/dist/ActionList/ActionList-520997eb.css +2 -0
  3. package/dist/ActionList/ActionList-520997eb.css.map +1 -0
  4. package/dist/ActionList/ActionList.module.css.js +4 -2
  5. package/dist/ActionList/Item.js +169 -162
  6. package/dist/ActionList/LinkItem.js +97 -30
  7. package/dist/Blankslate/{Blankslate-11d7a7fd.css → Blankslate-670cf090.css} +2 -2
  8. package/dist/Blankslate/Blankslate-670cf090.css.map +1 -0
  9. package/dist/Blankslate/Blankslate.js +46 -36
  10. package/dist/Blankslate/Blankslate.module.css.js +1 -1
  11. package/dist/Breadcrumbs/{Breadcrumbs-c913a296.css → Breadcrumbs-16d81430.css} +2 -2
  12. package/dist/Breadcrumbs/Breadcrumbs-16d81430.css.map +1 -0
  13. package/dist/Breadcrumbs/Breadcrumbs.js +392 -402
  14. package/dist/Breadcrumbs/Breadcrumbs.module.css.js +1 -1
  15. package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
  16. package/dist/SegmentedControl/SegmentedControl-99b8e34e.css +2 -0
  17. package/dist/SegmentedControl/SegmentedControl-99b8e34e.css.map +1 -0
  18. package/dist/SegmentedControl/SegmentedControl.module.css.js +1 -1
  19. package/dist/SegmentedControl/SegmentedControlButton.js +76 -119
  20. package/dist/Skeleton/SkeletonBox-6305aba6.css +2 -0
  21. package/dist/Skeleton/SkeletonBox-6305aba6.css.map +1 -0
  22. package/dist/Skeleton/SkeletonBox.js +2 -1
  23. package/dist/Skeleton/SkeletonBox.module.css.js +2 -5
  24. package/dist/Skeleton/skeleton-27888827.css +2 -0
  25. package/dist/Skeleton/skeleton-27888827.css.map +1 -0
  26. package/dist/Skeleton/skeleton.module.css.js +8 -0
  27. package/dist/SkeletonAvatar/SkeletonAvatar.d.ts +3 -0
  28. package/dist/SkeletonAvatar/SkeletonAvatar.js +75 -59
  29. package/dist/SkeletonText/SkeletonText.d.ts +3 -0
  30. package/dist/SkeletonText/SkeletonText.js +86 -70
  31. package/dist/Stack/Stack-1790a166.css +2 -0
  32. package/dist/Stack/Stack-1790a166.css.map +1 -0
  33. package/dist/Stack/Stack.d.ts +1 -1
  34. package/dist/Stack/Stack.module.css.js +1 -1
  35. package/dist/TooltipV2/Tooltip.d.ts +1 -1
  36. package/dist/TooltipV2/Tooltip.js +107 -130
  37. package/dist/TreeView/{TreeView-1bf45a33.css → TreeView-6e565888.css} +2 -2
  38. package/dist/TreeView/TreeView-6e565888.css.map +1 -0
  39. package/dist/TreeView/TreeView.module.css.js +1 -1
  40. package/dist/hooks/useOnEscapePress.d.ts +2 -0
  41. package/dist/hooks/useOnEscapePress.js +11 -4
  42. package/dist/hooks/useOnOutsideClick.js +2 -1
  43. package/dist/index.js +1 -1
  44. package/generated/components.json +1 -1
  45. package/package.json +10 -10
  46. package/dist/ActionList/ActionList-64885d7a.css +0 -2
  47. package/dist/ActionList/ActionList-64885d7a.css.map +0 -1
  48. package/dist/Blankslate/Blankslate-11d7a7fd.css.map +0 -1
  49. package/dist/Breadcrumbs/Breadcrumbs-c913a296.css.map +0 -1
  50. package/dist/SegmentedControl/SegmentedControl-3dc28307.css +0 -2
  51. package/dist/SegmentedControl/SegmentedControl-3dc28307.css.map +0 -1
  52. package/dist/Skeleton/SkeletonBox-e078be7c.css +0 -2
  53. package/dist/Skeleton/SkeletonBox-e078be7c.css.map +0 -1
  54. package/dist/Stack/Stack-58c33984.css +0 -2
  55. package/dist/Stack/Stack-58c33984.css.map +0 -1
  56. package/dist/TreeView/TreeView-1bf45a33.css.map +0 -1
@@ -7,466 +7,447 @@ import { fixedForwardRef } from "../utils/modern-polymorphic.js";
7
7
  import { IconButton } from "../Button/IconButton.js";
8
8
  import { ActionList } from "../ActionList/index.js";
9
9
  import Breadcrumbs_module_css_default from "./Breadcrumbs.module.css.js";
10
+ import Details from "../Details/Details.js";
10
11
  import React, { useRef, useState } from "react";
11
12
  import { jsx, jsxs } from "react/jsx-runtime";
12
13
  import { clsx } from "clsx";
13
14
  import { KebabHorizontalIcon } from "@primer/octicons-react";
14
15
  //#region src/Breadcrumbs/Breadcrumbs.tsx
15
- const MENU_BUTTON_WIDTH = 32;
16
- const SEPARATOR_ICON_WIDTH = 16;
17
- const NARROW_WIDTH = 544;
18
- const INITIAL_FIT = {
19
- extra: 0,
20
- rootCollapsed: false,
21
- narrow: false
22
- };
23
- function minVisible(withRoot, narrow, itemCount) {
24
- if (withRoot) return 3;
25
- return narrow && itemCount > 2 ? 1 : 4;
26
- }
27
- function countRule(withRoot, narrow, itemCount) {
28
- return Math.max(0, itemCount - minVisible(withRoot, narrow, itemCount));
29
- }
30
- const INITIAL_SEPARATORS = {
31
- plain: SEPARATOR_ICON_WIDTH,
32
- collapsed: SEPARATOR_ICON_WIDTH
33
- };
34
- function computeFit(widths, separators, available, withRoot) {
35
- const itemCount = widths.length;
36
- if (available <= 0 || itemCount === 0) return INITIAL_FIT;
37
- const narrow = available < NARROW_WIDTH;
38
- const min = minVisible(withRoot, narrow, itemCount);
39
- const rootWidth = withRoot ? widths[0] + separators.collapsed : 0;
40
- const menuCount = (collapsed) => Math.max(0, collapsed - (withRoot ? 1 : 0));
41
- let tailWidth = widths.reduce((sum, width) => sum + width + separators.collapsed, 0);
42
- const total = widths.reduce((sum, width) => sum + width, 0);
43
- const width = (collapsed) => menuCount(collapsed) === 0 ? total + separators.plain * (itemCount - 1) : rootWidth + tailWidth + MENU_BUTTON_WIDTH;
44
- let collapsed = 0;
45
- let rootCollapsed = false;
46
- while (width(collapsed) > available || itemCount - collapsed > min) {
47
- tailWidth -= widths[collapsed] + separators.collapsed;
48
- collapsed += 1;
49
- if (itemCount - collapsed === 1 && width(collapsed) > available) {
50
- rootCollapsed = withRoot;
51
- break;
52
- }
53
- }
54
- return {
55
- extra: collapsed - countRule(withRoot, narrow, itemCount),
56
- rootCollapsed,
57
- narrow
58
- };
59
- }
60
- function getContentWidth(nav) {
61
- const { paddingLeft, paddingRight } = getComputedStyle(nav);
62
- return nav.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
63
- }
64
- const sameFit = (a, b) => a.extra === b.extra && a.rootCollapsed === b.rootCollapsed && a.narrow === b.narrow;
65
- function getValidChildren(children) {
66
- return React.Children.toArray(children).filter((child) => /*#__PURE__*/ React.isValidElement(child));
67
- }
68
- function OverflowMenu(t0) {
69
- const $ = c(15);
70
- const { items, open, setOpen } = t0;
71
- const buttonRef = useRef(null);
16
+ const BreadcrumbsList = (t0) => {
17
+ const $ = c(2);
18
+ const { children } = t0;
72
19
  let t1;
73
- if ($[0] !== setOpen) {
74
- t1 = () => setOpen(false);
75
- $[0] = setOpen;
20
+ if ($[0] !== children) {
21
+ t1 = /* @__PURE__ */ jsx("ol", {
22
+ className: Breadcrumbs_module_css_default.BreadcrumbsList,
23
+ children
24
+ });
25
+ $[0] = children;
76
26
  $[1] = t1;
77
27
  } else t1 = $[1];
78
- const close = t1;
79
- const t2 = `${items.length} more breadcrumb items`;
80
- let t3;
81
- if ($[2] !== setOpen) {
82
- t3 = () => setOpen(_temp);
83
- $[2] = setOpen;
84
- $[3] = t3;
85
- } else t3 = $[3];
86
- let t4;
87
- if ($[4] !== open || $[5] !== t2 || $[6] !== t3) {
88
- t4 = /* @__PURE__ */ jsx(IconButton, {
89
- ref: buttonRef,
90
- "aria-label": t2,
91
- "aria-expanded": open,
92
- onClick: t3,
93
- variant: "invisible",
94
- size: "small",
95
- icon: KebabHorizontalIcon,
96
- tooltipDirection: "e"
97
- });
98
- $[4] = open;
99
- $[5] = t2;
100
- $[6] = t3;
101
- $[7] = t4;
102
- } else t4 = $[7];
103
- let t5;
104
- if ($[8] !== close || $[9] !== items || $[10] !== open) {
105
- t5 = open ? /* @__PURE__ */ jsx(OverflowMenuOverlay, {
106
- items,
107
- close,
108
- buttonRef
109
- }) : null;
110
- $[8] = close;
111
- $[9] = items;
112
- $[10] = open;
113
- $[11] = t5;
114
- } else t5 = $[11];
115
- let t6;
116
- if ($[12] !== t4 || $[13] !== t5) {
117
- t6 = /* @__PURE__ */ jsxs("div", {
118
- className: Breadcrumbs_module_css_default.MenuDetails,
119
- "data-component": "Breadcrumbs.MenuItem",
120
- children: [t4, t5]
121
- });
122
- $[12] = t4;
123
- $[13] = t5;
124
- $[14] = t6;
125
- } else t6 = $[14];
126
- return t6;
127
- }
128
- function _temp(value) {
129
- return !value;
130
- }
131
- function OverflowMenuOverlay(t0) {
132
- const $ = c(13);
133
- const { items, close, buttonRef } = t0;
134
- const containerRef = useRef(null);
28
+ return t1;
29
+ };
30
+ const BreadcrumbsMenuItem = /*#__PURE__*/ React.forwardRef((t0, menuRefCallback) => {
31
+ const $ = c(25);
32
+ let ariaLabel;
33
+ let items;
34
+ let rest;
35
+ if ($[0] !== t0) {
36
+ ({items, "aria-label": ariaLabel, ...rest} = t0);
37
+ $[0] = t0;
38
+ $[1] = ariaLabel;
39
+ $[2] = items;
40
+ $[3] = rest;
41
+ } else {
42
+ ariaLabel = $[1];
43
+ items = $[2];
44
+ rest = $[3];
45
+ }
46
+ const [isOpen, setIsOpen] = useState(false);
47
+ const detailsRef = useRef(null);
48
+ const menuButtonRef = useRef(null);
49
+ const menuContainerRef = useRef(null);
135
50
  let t1;
51
+ if ($[4] !== menuRefCallback) {
52
+ t1 = (element) => {
53
+ detailsRef.current = element;
54
+ if (typeof menuRefCallback === "function") menuRefCallback(element);
55
+ };
56
+ $[4] = menuRefCallback;
57
+ $[5] = t1;
58
+ } else t1 = $[5];
59
+ const detailsRefCallback = t1;
136
60
  let t2;
137
- if ($[0] !== buttonRef || $[1] !== close) {
138
- t1 = (event) => {
139
- var _buttonRef$current;
61
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
62
+ t2 = (event) => {
140
63
  event.preventDefault();
141
- close();
142
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
64
+ if (detailsRef.current) {
65
+ const newOpenState = !detailsRef.current.open;
66
+ detailsRef.current.open = newOpenState;
67
+ setIsOpen(newOpenState);
68
+ }
143
69
  };
144
- t2 = [close, buttonRef];
145
- $[0] = buttonRef;
146
- $[1] = close;
147
- $[2] = t1;
148
- $[3] = t2;
149
- } else {
150
- t1 = $[2];
151
- t2 = $[3];
152
- }
153
- useOnEscapePress(t1, t2);
70
+ $[6] = t2;
71
+ } else t2 = $[6];
72
+ const handleSummaryClick = t2;
154
73
  let t3;
155
- if ($[4] !== buttonRef) {
156
- t3 = [buttonRef];
157
- $[4] = buttonRef;
158
- $[5] = t3;
159
- } else t3 = $[5];
160
- let t4;
161
- if ($[6] !== close || $[7] !== t3) {
162
- t4 = {
163
- onClickOutside: close,
164
- containerRef,
165
- ignoreClickRefs: t3
74
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
75
+ t3 = () => {
76
+ if (detailsRef.current) {
77
+ detailsRef.current.open = false;
78
+ setIsOpen(false);
79
+ }
166
80
  };
167
- $[6] = close;
168
81
  $[7] = t3;
82
+ } else t3 = $[7];
83
+ const closeOverlay = t3;
84
+ let t4;
85
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
86
+ t4 = () => {
87
+ var _menuButtonRef$curren;
88
+ (_menuButtonRef$curren = menuButtonRef.current) === null || _menuButtonRef$curren === void 0 || _menuButtonRef$curren.focus();
89
+ };
169
90
  $[8] = t4;
170
91
  } else t4 = $[8];
171
- useOnOutsideClick(t4);
92
+ const focusOnMenuButton = t4;
172
93
  let t5;
173
- if ($[9] !== items) {
174
- t5 = items.map(_temp2);
175
- $[9] = items;
176
- $[10] = t5;
177
- } else t5 = $[10];
178
94
  let t6;
179
- if ($[11] !== t5) {
180
- t6 = /* @__PURE__ */ jsx("div", {
181
- ref: containerRef,
95
+ if ($[9] !== isOpen) {
96
+ t5 = (event_0) => {
97
+ if (isOpen) {
98
+ event_0.preventDefault();
99
+ closeOverlay();
100
+ focusOnMenuButton();
101
+ }
102
+ };
103
+ t6 = [isOpen];
104
+ $[9] = isOpen;
105
+ $[10] = t5;
106
+ $[11] = t6;
107
+ } else {
108
+ t5 = $[10];
109
+ t6 = $[11];
110
+ }
111
+ useOnEscapePress(t5, t6);
112
+ let t7;
113
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
114
+ t7 = {
115
+ onClickOutside: closeOverlay,
116
+ containerRef: menuContainerRef,
117
+ ignoreClickRefs: [menuButtonRef]
118
+ };
119
+ $[12] = t7;
120
+ } else t7 = $[12];
121
+ useOnOutsideClick(t7);
122
+ const t8 = ariaLabel || `${items.length} more breadcrumb items`;
123
+ const t9 = isOpen ? "true" : "false";
124
+ let t10;
125
+ if ($[13] !== rest || $[14] !== t8 || $[15] !== t9) {
126
+ t10 = /* @__PURE__ */ jsx(IconButton, {
127
+ as: "summary",
128
+ role: "button",
129
+ ref: menuButtonRef,
130
+ "aria-label": t8,
131
+ "aria-haspopup": "true",
132
+ "aria-expanded": t9,
133
+ onClick: handleSummaryClick,
134
+ variant: "invisible",
135
+ size: "small",
136
+ icon: KebabHorizontalIcon,
137
+ tooltipDirection: "e",
138
+ ...rest
139
+ });
140
+ $[13] = rest;
141
+ $[14] = t8;
142
+ $[15] = t9;
143
+ $[16] = t10;
144
+ } else t10 = $[16];
145
+ let t11;
146
+ if ($[17] !== items) {
147
+ t11 = items.map(_temp);
148
+ $[17] = items;
149
+ $[18] = t11;
150
+ } else t11 = $[18];
151
+ let t12;
152
+ if ($[19] !== t11) {
153
+ t12 = /* @__PURE__ */ jsx("div", {
154
+ ref: menuContainerRef,
182
155
  className: Breadcrumbs_module_css_default.MenuOverlay,
183
- children: /* @__PURE__ */ jsx(ActionList, { children: t5 })
156
+ children: /* @__PURE__ */ jsx(ActionList, { children: t11 })
184
157
  });
185
- $[11] = t5;
186
- $[12] = t6;
187
- } else t6 = $[12];
188
- return t6;
189
- }
190
- function _temp2(item) {
191
- const { children, selected, as: Component, ...itemProps } = item.props;
192
- return /* @__PURE__ */ jsx(ActionList.LinkItem, {
193
- as: Component,
194
- ...itemProps,
195
- "aria-current": selected ? "page" : void 0,
196
- children
197
- }, item.key);
158
+ $[19] = t11;
159
+ $[20] = t12;
160
+ } else t12 = $[20];
161
+ let t13;
162
+ if ($[21] !== detailsRefCallback || $[22] !== t10 || $[23] !== t12) {
163
+ t13 = /* @__PURE__ */ jsxs(Details, {
164
+ ref: detailsRefCallback,
165
+ className: Breadcrumbs_module_css_default.MenuDetails,
166
+ "data-component": "Breadcrumbs.MenuItem",
167
+ children: [t10, t12]
168
+ });
169
+ $[21] = detailsRefCallback;
170
+ $[22] = t10;
171
+ $[23] = t12;
172
+ $[24] = t13;
173
+ } else t13 = $[24];
174
+ return t13;
175
+ });
176
+ BreadcrumbsMenuItem.displayName = "Breadcrumbs.MenuItem";
177
+ const getValidChildren = (children) => {
178
+ return React.Children.toArray(children).filter((child) => /*#__PURE__*/ React.isValidElement(child));
179
+ };
180
+ const MENU_BUTTON_FALLBACK_WIDTH = 32;
181
+ const CONTAINER_FALLBACK_WIDTH = 800;
182
+ function calculateOverflow({ availableWidth, itemCount, childArrayWidths, menuButtonWidth, overflow, hideRoot }) {
183
+ var _childArrayWidths$;
184
+ let eHideRoot = hideRoot;
185
+ const rootItemWidth = (_childArrayWidths$ = childArrayWidths[0]) !== null && _childArrayWidths$ !== void 0 ? _childArrayWidths$ : 0;
186
+ const isNarrow = availableWidth < 544;
187
+ let MIN_VISIBLE_ITEMS = 4;
188
+ if (!eHideRoot) MIN_VISIBLE_ITEMS = 3;
189
+ else if (isNarrow && itemCount > 2) MIN_VISIBLE_ITEMS = 1;
190
+ const calculateVisibleItemsWidth = (w) => {
191
+ const widths = w.reduce((sum, width) => sum + width + 16, 0);
192
+ return !eHideRoot ? rootItemWidth + widths : widths;
193
+ };
194
+ let currentVisibleItemWidths = [...childArrayWidths];
195
+ let menuItemCount = 0;
196
+ if (availableWidth > 0 && currentVisibleItemWidths.length > 0) {
197
+ let visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths);
198
+ while ((overflow === "menu" || overflow === "menu-with-root") && (visibleItemsWidthTotal > availableWidth || currentVisibleItemWidths.length > MIN_VISIBLE_ITEMS)) {
199
+ menuItemCount += 1;
200
+ currentVisibleItemWidths = currentVisibleItemWidths.slice(1);
201
+ visibleItemsWidthTotal = calculateVisibleItemsWidth(currentVisibleItemWidths) + menuButtonWidth;
202
+ if (currentVisibleItemWidths.length === 1 && visibleItemsWidthTotal > availableWidth) {
203
+ eHideRoot = true;
204
+ break;
205
+ } else eHideRoot = hideRoot;
206
+ }
207
+ }
208
+ return {
209
+ menuItemCount,
210
+ effectiveHideRoot: eHideRoot
211
+ };
198
212
  }
199
213
  function Breadcrumbs(t0) {
200
- const $ = c(60);
214
+ const $ = c(48);
201
215
  const { className, children, style, overflow: t1, variant: t2 } = t0;
202
216
  const overflow = t1 === void 0 ? "wrap" : t1;
203
217
  const variant = t2 === void 0 ? "normal" : t2;
204
- const navRef = useRef(null);
218
+ const containerRef = useRef(null);
219
+ const hideRoot = !(overflow === "menu-with-root");
205
220
  let t3;
206
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
207
- t3 = /* @__PURE__ */ new Map();
208
- $[0] = t3;
209
- } else t3 = $[0];
210
- const widthsRef = useRef(t3);
211
- const [fit, setFit] = useState(INITIAL_FIT);
212
- const fitRef = useRef(INITIAL_FIT);
213
- const separatorsRef = useRef(INITIAL_SEPARATORS);
214
- const [menuOpen, setMenuOpen] = useState(false);
215
- const collapsible = overflow !== "wrap";
216
- const withRoot = overflow === "menu-with-root";
221
+ if ($[0] !== children) {
222
+ t3 = getValidChildren(children);
223
+ $[0] = children;
224
+ $[1] = t3;
225
+ } else t3 = $[1];
226
+ const childArray = t3;
227
+ const rootItem = childArray[0];
228
+ const [childArrayWidths, setChildArrayWidths] = useState(_temp2);
229
+ const [containerWidth, setContainerWidth] = useState(null);
230
+ const [menuButtonWidth, setMenuButtonWidth] = useState(MENU_BUTTON_FALLBACK_WIDTH);
217
231
  let t4;
218
- if ($[1] !== children) {
219
- t4 = getValidChildren(children);
220
- $[1] = children;
232
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
233
+ t4 = (element) => {
234
+ if (element) {
235
+ const iconButtonElement = element.querySelector("button[data-component=\"IconButton\"]");
236
+ if (iconButtonElement) {
237
+ const measuredWidth = iconButtonElement.offsetWidth;
238
+ setMenuButtonWidth((prev) => prev === measuredWidth ? prev : measuredWidth);
239
+ }
240
+ }
241
+ };
221
242
  $[2] = t4;
222
243
  } else t4 = $[2];
223
- const items = t4;
224
- const itemCount = items.length;
244
+ const measureMenuButton = t4;
225
245
  let t5;
226
- if ($[3] !== items || $[4] !== withRoot) {
227
- t5 = (available) => {
228
- const next = computeFit(items.map((item) => {
229
- var _widthsRef$current$ge, _item$key;
230
- return (_widthsRef$current$ge = widthsRef.current.get((_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : "")) !== null && _widthsRef$current$ge !== void 0 ? _widthsRef$current$ge : 0;
231
- }), separatorsRef.current, available, withRoot);
232
- if (sameFit(fitRef.current, next)) return;
233
- fitRef.current = next;
234
- setFit(next);
246
+ if ($[3] !== childArray.length || $[4] !== overflow) {
247
+ t5 = () => {
248
+ if (overflow === "wrap") return;
249
+ const containerElement = containerRef.current;
250
+ if (!containerElement) return;
251
+ const measuredContainerWidth = containerElement.offsetWidth;
252
+ setContainerWidth((prev_0) => prev_0 === measuredContainerWidth ? prev_0 : measuredContainerWidth);
253
+ const listElement = containerElement.querySelector("ol");
254
+ if (listElement && listElement.children.length > 0 && listElement.children.length === childArray.length) {
255
+ const widths = Array.from(listElement.children).map(_temp3);
256
+ setChildArrayWidths(widths);
257
+ }
235
258
  };
236
- $[3] = items;
237
- $[4] = withRoot;
259
+ $[3] = childArray.length;
260
+ $[4] = overflow;
238
261
  $[5] = t5;
239
262
  } else t5 = $[5];
240
- const updateFit = t5;
241
263
  let t6;
242
- if ($[6] !== items || $[7] !== updateFit) {
243
- t6 = (nav, available_0) => {
244
- const previous = widthsRef.current;
245
- const widths_0 = /* @__PURE__ */ new Map();
246
- let separators = separatorsRef.current;
247
- for (const item_0 of items) {
248
- var _item_0$key;
249
- const width = previous.get((_item_0$key = item_0.key) !== null && _item_0$key !== void 0 ? _item_0$key : "");
250
- if (width !== void 0) {
251
- var _item_0$key2;
252
- widths_0.set((_item_0$key2 = item_0.key) !== null && _item_0$key2 !== void 0 ? _item_0$key2 : "", width);
253
- }
254
- }
255
- for (const li of nav.querySelectorAll(":scope > ol > li[data-index]")) {
256
- var _items$Number;
257
- const key = (_items$Number = items[Number(li.getAttribute("data-index"))]) === null || _items$Number === void 0 ? void 0 : _items$Number.key;
258
- const crumb = li.firstElementChild;
259
- if (key == null || !crumb) continue;
260
- const crumbWidth = crumb.getBoundingClientRect().width;
261
- widths_0.set(key, crumbWidth);
262
- if (li.nextElementSibling && !li.hasAttribute("data-collapsed")) {
263
- const separator = li.getBoundingClientRect().width - crumbWidth;
264
- const kind = li.classList.contains(Breadcrumbs_module_css_default.ItemWrapper) ? "plain" : "collapsed";
265
- if (separators[kind] !== separator) separators = {
266
- ...separators,
267
- [kind]: separator
268
- };
269
- }
270
- }
271
- separatorsRef.current = separators;
272
- widthsRef.current = widths_0;
273
- updateFit(available_0);
274
- };
275
- $[6] = items;
276
- $[7] = updateFit;
264
+ if ($[6] !== childArray || $[7] !== overflow) {
265
+ t6 = [childArray, overflow];
266
+ $[6] = childArray;
267
+ $[7] = overflow;
277
268
  $[8] = t6;
278
269
  } else t6 = $[8];
279
- const measure = t6;
280
- const hiddenRef = useRef(false);
270
+ useIsomorphicLayoutEffect(t5, t6);
281
271
  let t7;
282
- if ($[9] !== collapsible || $[10] !== measure) {
283
- t7 = () => {
284
- const nav_0 = navRef.current;
285
- if (!collapsible || !nav_0) return;
286
- if (!nav_0.hasAttribute("data-hydrated")) nav_0.setAttribute("data-hydrated", "");
287
- const available_1 = getContentWidth(nav_0);
288
- hiddenRef.current = available_1 <= 0;
289
- if (!hiddenRef.current) measure(nav_0, available_1);
272
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
273
+ t7 = (entries) => {
274
+ if (entries[0]) {
275
+ const width = Math.round(entries[0].contentRect.width);
276
+ setContainerWidth((prev_1) => prev_1 === width ? prev_1 : width);
277
+ }
290
278
  };
291
- $[9] = collapsible;
292
- $[10] = measure;
293
- $[11] = t7;
294
- } else t7 = $[11];
279
+ $[9] = t7;
280
+ } else t7 = $[9];
295
281
  let t8;
296
- if ($[12] !== collapsible || $[13] !== fit || $[14] !== measure || $[15] !== menuOpen) {
297
- t8 = [
298
- collapsible,
299
- fit,
300
- menuOpen,
301
- measure
302
- ];
303
- $[12] = collapsible;
304
- $[13] = fit;
305
- $[14] = measure;
306
- $[15] = menuOpen;
307
- $[16] = t8;
308
- } else t8 = $[16];
309
- useIsomorphicLayoutEffect(t7, t8);
282
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
283
+ t8 = [];
284
+ $[10] = t8;
285
+ } else t8 = $[10];
286
+ useResizeObserver(t7, containerRef, t8, overflow !== "wrap");
310
287
  let t9;
311
- if ($[17] !== measure || $[18] !== updateFit) {
312
- t9 = () => {
313
- const nav_1 = navRef.current;
314
- if (!nav_1) return;
315
- const available_2 = getContentWidth(nav_1);
316
- if (available_2 <= 0) hiddenRef.current = true;
317
- else if (hiddenRef.current) {
318
- hiddenRef.current = false;
319
- measure(nav_1, available_2);
320
- } else updateFit(available_2);
321
- };
322
- $[17] = measure;
323
- $[18] = updateFit;
324
- $[19] = t9;
325
- } else t9 = $[19];
326
- let t10;
327
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
328
- t10 = [];
329
- $[20] = t10;
330
- } else t10 = $[20];
331
- useResizeObserver(t9, navRef, t10, collapsible);
332
- let content;
333
- if (!collapsible) {
334
- if (menuOpen) setMenuOpen(false);
335
- let t11;
336
- if ($[21] !== children) {
337
- t11 = React.Children.map(children, _temp3);
338
- $[21] = children;
339
- $[22] = t11;
340
- } else t11 = $[22];
341
- content = t11;
342
- } else {
343
- const collapsed = Math.min(Math.max(itemCount - 1, 0), countRule(withRoot, fit.narrow, itemCount) + fit.extra);
344
- const rootVisible = withRoot && !(collapsed > 0 && fit.rootCollapsed);
288
+ bb0: {
289
+ if (overflow === "wrap" || childArrayWidths.length !== childArray.length) {
290
+ let t10;
291
+ if ($[11] !== hideRoot) {
292
+ t10 = {
293
+ menuItemCount: 0,
294
+ effectiveHideRoot: hideRoot
295
+ };
296
+ $[11] = hideRoot;
297
+ $[12] = t10;
298
+ } else t10 = $[12];
299
+ t9 = t10;
300
+ break bb0;
301
+ }
302
+ const t10 = containerWidth !== null && containerWidth !== void 0 ? containerWidth : CONTAINER_FALLBACK_WIDTH;
345
303
  let t11;
346
- if ($[23] !== collapsed || $[24] !== items || $[25] !== rootVisible) {
347
- t11 = items.slice(rootVisible ? 1 : 0, collapsed);
348
- $[23] = collapsed;
349
- $[24] = items;
350
- $[25] = rootVisible;
351
- $[26] = t11;
352
- } else t11 = $[26];
353
- const menuItems = t11;
354
- if (menuOpen && menuItems.length === 0) setMenuOpen(false);
355
- const plain = menuItems.length === 0;
356
- const alwaysCollapsed = countRule(withRoot, false, itemCount);
357
- let listItems;
358
- if ($[27] !== alwaysCollapsed || $[28] !== collapsed || $[29] !== itemCount || $[30] !== items || $[31] !== menuItems || $[32] !== menuOpen || $[33] !== plain || $[34] !== rootVisible || $[35] !== withRoot) {
359
- listItems = [];
360
- for (const [index, item_1] of items.entries()) {
361
- const isRoot = withRoot && index === 0;
362
- const isCollapsed = index < collapsed && !(isRoot && rootVisible);
363
- if (isCollapsed && index < alwaysCollapsed && !isRoot) continue;
364
- const rendered = !isCollapsed || !menuOpen;
365
- listItems.push(/* @__PURE__ */ jsxs("li", {
366
- className: plain ? Breadcrumbs_module_css_default.ItemWrapper : Breadcrumbs_module_css_default.BreadcrumbsItem,
367
- "data-index": rendered ? index : void 0,
368
- "data-collapsed": isCollapsed ? "" : void 0,
369
- children: [rendered ? item_1 : null, plain ? null : /* @__PURE__ */ jsx(ItemSeparator, {})]
370
- }, item_1.key));
371
- }
372
- if (!plain || !withRoot && itemCount > 2) {
373
- let t12;
374
- if ($[37] !== itemCount || $[38] !== items || $[39] !== menuItems || $[40] !== plain) {
375
- t12 = plain ? items.slice(0, itemCount - 1) : menuItems;
376
- $[37] = itemCount;
377
- $[38] = items;
378
- $[39] = menuItems;
379
- $[40] = plain;
380
- $[41] = t12;
381
- } else t12 = $[41];
382
- let t13;
383
- if ($[42] !== menuOpen || $[43] !== t12) {
384
- t13 = /* @__PURE__ */ jsx(OverflowMenu, {
385
- items: t12,
386
- open: menuOpen,
387
- setOpen: setMenuOpen
388
- });
389
- $[42] = menuOpen;
390
- $[43] = t12;
391
- $[44] = t13;
392
- } else t13 = $[44];
393
- let t14;
394
- if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
395
- t14 = /* @__PURE__ */ jsx(ItemSeparator, {});
396
- $[45] = t14;
397
- } else t14 = $[45];
398
- let t15;
399
- if ($[46] !== plain || $[47] !== t13) {
400
- t15 = /* @__PURE__ */ jsxs("li", {
401
- className: Breadcrumbs_module_css_default.BreadcrumbsItem,
402
- "data-overflow-menu": "",
403
- hidden: plain,
404
- children: [t13, t14]
405
- }, "breadcrumbs-menu");
406
- $[46] = plain;
407
- $[47] = t13;
408
- $[48] = t15;
409
- } else t15 = $[48];
410
- listItems.splice(withRoot && rootVisible ? 1 : 0, 0, t15);
411
- }
412
- $[27] = alwaysCollapsed;
413
- $[28] = collapsed;
414
- $[29] = itemCount;
415
- $[30] = items;
416
- $[31] = menuItems;
417
- $[32] = menuOpen;
418
- $[33] = plain;
419
- $[34] = rootVisible;
420
- $[35] = withRoot;
421
- $[36] = listItems;
422
- } else listItems = $[36];
423
- content = listItems;
304
+ if ($[13] !== childArray.length || $[14] !== childArrayWidths || $[15] !== hideRoot || $[16] !== menuButtonWidth || $[17] !== overflow || $[18] !== t10) {
305
+ t11 = calculateOverflow({
306
+ availableWidth: t10,
307
+ itemCount: childArray.length,
308
+ childArrayWidths,
309
+ menuButtonWidth,
310
+ overflow,
311
+ hideRoot
312
+ });
313
+ $[13] = childArray.length;
314
+ $[14] = childArrayWidths;
315
+ $[15] = hideRoot;
316
+ $[16] = menuButtonWidth;
317
+ $[17] = overflow;
318
+ $[18] = t10;
319
+ $[19] = t11;
320
+ } else t11 = $[19];
321
+ t9 = t11;
424
322
  }
323
+ const { menuItemCount, effectiveHideRoot } = t9;
324
+ let t10;
325
+ if ($[20] !== childArray || $[21] !== children || $[22] !== effectiveHideRoot || $[23] !== menuItemCount || $[24] !== overflow || $[25] !== rootItem) {
326
+ bb1: {
327
+ if (overflow === "wrap" || menuItemCount === 0) {
328
+ let t11;
329
+ if ($[27] !== children) {
330
+ t11 = React.Children.map(children, _temp4);
331
+ $[27] = children;
332
+ $[28] = t11;
333
+ } else t11 = $[28];
334
+ t10 = t11;
335
+ break bb1;
336
+ }
337
+ const menuItems = childArray.slice(0, menuItemCount);
338
+ const visibleItems = childArray.slice(menuItemCount);
339
+ const effectiveMenuItems = effectiveHideRoot ? menuItems : menuItems.slice(1);
340
+ const t11 = `${effectiveMenuItems.length} more breadcrumb items`;
341
+ let t12;
342
+ if ($[29] !== effectiveMenuItems || $[30] !== t11) {
343
+ t12 = /* @__PURE__ */ jsx(BreadcrumbsMenuItem, {
344
+ ref: measureMenuButton,
345
+ items: effectiveMenuItems,
346
+ "aria-label": t11
347
+ });
348
+ $[29] = effectiveMenuItems;
349
+ $[30] = t11;
350
+ $[31] = t12;
351
+ } else t12 = $[31];
352
+ let t13;
353
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
354
+ t13 = /* @__PURE__ */ jsx(ItemSeparator, {});
355
+ $[32] = t13;
356
+ } else t13 = $[32];
357
+ let t14;
358
+ if ($[33] !== t12) {
359
+ t14 = /* @__PURE__ */ jsxs("li", {
360
+ className: Breadcrumbs_module_css_default.BreadcrumbsItem,
361
+ "data-overflow-menu": "",
362
+ children: [t12, t13]
363
+ }, "breadcrumbs-menu");
364
+ $[33] = t12;
365
+ $[34] = t14;
366
+ } else t14 = $[34];
367
+ const menuElement = t14;
368
+ const visibleElements = visibleItems.map(_temp5);
369
+ let t15;
370
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
371
+ t15 = /* @__PURE__ */ jsx(ItemSeparator, {});
372
+ $[35] = t15;
373
+ } else t15 = $[35];
374
+ let t16;
375
+ if ($[36] !== rootItem) {
376
+ t16 = /* @__PURE__ */ jsxs("li", {
377
+ className: Breadcrumbs_module_css_default.BreadcrumbsItem,
378
+ children: [rootItem, t15]
379
+ }, "rootElement");
380
+ $[36] = rootItem;
381
+ $[37] = t16;
382
+ } else t16 = $[37];
383
+ const rootElement = t16;
384
+ if (effectiveHideRoot) t10 = [menuElement, ...visibleElements];
385
+ else t10 = [
386
+ rootElement,
387
+ menuElement,
388
+ ...visibleElements
389
+ ];
390
+ }
391
+ $[20] = childArray;
392
+ $[21] = children;
393
+ $[22] = effectiveHideRoot;
394
+ $[23] = menuItemCount;
395
+ $[24] = overflow;
396
+ $[25] = rootItem;
397
+ $[26] = t10;
398
+ } else t10 = $[26];
399
+ const finalChildren = t10;
425
400
  let t11;
426
- if ($[49] !== className) {
401
+ if ($[38] !== className) {
427
402
  t11 = clsx(className, Breadcrumbs_module_css_default.BreadcrumbsBase);
428
- $[49] = className;
429
- $[50] = t11;
430
- } else t11 = $[50];
431
- const t12 = collapsible && overflow === "menu" && itemCount > 2 ? "" : void 0;
403
+ $[38] = className;
404
+ $[39] = t11;
405
+ } else t11 = $[39];
406
+ let t12;
407
+ if ($[40] !== finalChildren) {
408
+ t12 = /* @__PURE__ */ jsx(BreadcrumbsList, { children: finalChildren });
409
+ $[40] = finalChildren;
410
+ $[41] = t12;
411
+ } else t12 = $[41];
432
412
  let t13;
433
- if ($[51] !== content || $[52] !== t12) {
434
- t13 = /* @__PURE__ */ jsx("ol", {
435
- className: Breadcrumbs_module_css_default.BreadcrumbsList,
436
- "data-narrow-collapse": t12,
437
- children: content
438
- });
439
- $[51] = content;
440
- $[52] = t12;
441
- $[53] = t13;
442
- } else t13 = $[53];
443
- let t14;
444
- if ($[54] !== overflow || $[55] !== style || $[56] !== t11 || $[57] !== t13 || $[58] !== variant) {
445
- t14 = /* @__PURE__ */ jsx("nav", {
413
+ if ($[42] !== overflow || $[43] !== style || $[44] !== t11 || $[45] !== t12 || $[46] !== variant) {
414
+ t13 = /* @__PURE__ */ jsx("nav", {
446
415
  className: t11,
447
416
  "aria-label": "Breadcrumbs",
448
417
  style,
449
- ref: navRef,
418
+ ref: containerRef,
450
419
  "data-overflow": overflow,
451
420
  "data-variant": variant,
452
421
  "data-component": "Breadcrumbs",
453
- children: t13
422
+ children: t12
454
423
  });
455
- $[54] = overflow;
456
- $[55] = style;
457
- $[56] = t11;
458
- $[57] = t13;
459
- $[58] = variant;
460
- $[59] = t14;
461
- } else t14 = $[59];
462
- return t14;
424
+ $[42] = overflow;
425
+ $[43] = style;
426
+ $[44] = t11;
427
+ $[45] = t12;
428
+ $[46] = variant;
429
+ $[47] = t13;
430
+ } else t13 = $[47];
431
+ return t13;
463
432
  }
464
- function _temp3(child) {
433
+ function _temp5(child_1, index) {
434
+ return /* @__PURE__ */ jsxs("li", {
435
+ className: Breadcrumbs_module_css_default.BreadcrumbsItem,
436
+ children: [child_1, /* @__PURE__ */ jsx(ItemSeparator, {})]
437
+ }, `visible + ${index}`);
438
+ }
439
+ function _temp4(child_0) {
465
440
  return /* @__PURE__ */ jsx("li", {
466
441
  className: Breadcrumbs_module_css_default.ItemWrapper,
467
- children: child
442
+ children: child_0
468
443
  });
469
444
  }
445
+ function _temp3(child) {
446
+ return child.offsetWidth;
447
+ }
448
+ function _temp2() {
449
+ return [];
450
+ }
470
451
  const ItemSeparator = () => {
471
452
  const $ = c(1);
472
453
  let t0;
@@ -506,5 +487,14 @@ var Breadcrumbs_default = Object.assign(Breadcrumbs, { Item: BreadcrumbsItemWith
506
487
  * @deprecated Use the `Breadcrumbs` component instead (i.e. `<Breadcrumb>` → `<Breadcrumbs>`)
507
488
  */
508
489
  const Breadcrumb = Object.assign(Breadcrumbs, { Item: BreadcrumbsItem });
490
+ function _temp(item, index) {
491
+ const { children, selected, as: Component, ...itemProps } = item.props;
492
+ return /* @__PURE__ */ jsx(ActionList.LinkItem, {
493
+ as: Component,
494
+ ...itemProps,
495
+ "aria-current": selected ? "page" : void 0,
496
+ children
497
+ }, index);
498
+ }
509
499
  //#endregion
510
500
  export { Breadcrumb, Breadcrumbs_default as default };