@primer/react 0.0.0-20260226223231 → 0.0.0-20260227020135

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 (96) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/dist/ActionList/ActionList-c04a02d6.css +2 -0
  3. package/dist/ActionList/ActionList-c04a02d6.css.map +1 -0
  4. package/dist/ActionList/ActionList.module.css.js +1 -1
  5. package/dist/ActionList/Description.js +113 -35
  6. package/dist/ActionList/Divider.js +30 -11
  7. package/dist/ActionList/Group.js +294 -117
  8. package/dist/ActionList/Heading.js +77 -22
  9. package/dist/ActionList/Item.d.ts.map +1 -1
  10. package/dist/ActionList/Item.js +99 -37
  11. package/dist/ActionList/LinkItem.js +80 -24
  12. package/dist/ActionList/List.js +143 -33
  13. package/dist/ActionList/Selection.js +78 -30
  14. package/dist/ActionList/TrailingAction.js +83 -23
  15. package/dist/ActionList/Visuals.js +162 -64
  16. package/dist/AnchoredOverlay/AnchoredOverlay-6ec278c5.css +2 -0
  17. package/dist/AnchoredOverlay/AnchoredOverlay-6ec278c5.css.map +1 -0
  18. package/dist/AnchoredOverlay/AnchoredOverlay.js +4 -2
  19. package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +2 -2
  20. package/dist/Autocomplete/Autocomplete.js +76 -159
  21. package/dist/Autocomplete/AutocompleteMenu.js +128 -333
  22. package/dist/Autocomplete/AutocompleteOverlay.js +49 -130
  23. package/dist/Banner/Banner.d.ts.map +1 -1
  24. package/dist/Banner/Banner.js +112 -276
  25. package/dist/Blankslate/{Blankslate-f5a9755a.css → Blankslate-a039d79a.css} +2 -2
  26. package/dist/Blankslate/Blankslate-a039d79a.css.map +1 -0
  27. package/dist/Blankslate/Blankslate.module.css.js +1 -1
  28. package/dist/Button/ButtonBase.d.ts.map +1 -1
  29. package/dist/Button/ButtonBase.js +9 -14
  30. package/dist/Checkbox/Checkbox.js +55 -163
  31. package/dist/Dialog/Dialog.js +105 -347
  32. package/dist/FilteredActionList/FilteredActionList-02db90c6.css +2 -0
  33. package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +1 -0
  34. package/dist/FilteredActionList/FilteredActionList.d.ts +16 -1
  35. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  36. package/dist/FilteredActionList/FilteredActionList.js +147 -42
  37. package/dist/FilteredActionList/FilteredActionList.module.css.js +2 -2
  38. package/dist/Overlay/Overlay-390f808a.css +2 -0
  39. package/dist/Overlay/Overlay-390f808a.css.map +1 -0
  40. package/dist/Overlay/Overlay.module.css.js +1 -1
  41. package/dist/PageLayout/PageLayout-3444a142.css +2 -0
  42. package/dist/PageLayout/PageLayout-3444a142.css.map +1 -0
  43. package/dist/PageLayout/PageLayout.d.ts +72 -2
  44. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  45. package/dist/PageLayout/PageLayout.js +750 -1235
  46. package/dist/PageLayout/PageLayout.module.css.js +2 -2
  47. package/dist/PageLayout/usePaneWidth.d.ts +18 -6
  48. package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
  49. package/dist/PageLayout/usePaneWidth.js +126 -112
  50. package/dist/SelectPanel/SelectPanel.d.ts +1 -1
  51. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  52. package/dist/SelectPanel/SelectPanel.js +85 -33
  53. package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
  54. package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
  55. package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
  56. package/dist/Text/Text.d.ts +1 -1
  57. package/dist/Text/Text.d.ts.map +1 -1
  58. package/dist/Text/Text.js +10 -13
  59. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  60. package/dist/UnderlineNav/UnderlineNav.js +11 -4
  61. package/dist/UnderlineNav/UnderlineNavItem.js +56 -149
  62. package/dist/experimental/SelectPanel2/SelectPanel-f0c4b9ca.css +2 -0
  63. package/dist/experimental/SelectPanel2/{SelectPanel-1f8c23b5.css.map → SelectPanel-f0c4b9ca.css.map} +1 -1
  64. package/dist/experimental/SelectPanel2/SelectPanel.js +209 -593
  65. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +1 -1
  66. package/dist/hooks/useIsMacOS.d.ts +15 -3
  67. package/dist/hooks/useIsMacOS.d.ts.map +1 -1
  68. package/dist/hooks/useIsMacOS.js +24 -26
  69. package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
  70. package/dist/hooks/useRefObjectAsForwardedRef.js +10 -2
  71. package/dist/hooks/useScrollFlash.d.ts.map +1 -1
  72. package/dist/hooks/useScrollFlash.js +14 -22
  73. package/dist/hooks/useSlots.d.ts +50 -6
  74. package/dist/hooks/useSlots.d.ts.map +1 -1
  75. package/dist/hooks/useSlots.js +114 -36
  76. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +2 -0
  77. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +1 -0
  78. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  79. package/dist/live-region/Announce.d.ts.map +1 -1
  80. package/dist/live-region/Announce.js +7 -4
  81. package/generated/components.json +198 -6
  82. package/package.json +4 -4
  83. package/dist/ActionList/ActionList-f4ac3b54.css +0 -2
  84. package/dist/ActionList/ActionList-f4ac3b54.css.map +0 -1
  85. package/dist/AnchoredOverlay/AnchoredOverlay-b7d9fad3.css +0 -2
  86. package/dist/AnchoredOverlay/AnchoredOverlay-b7d9fad3.css.map +0 -1
  87. package/dist/Blankslate/Blankslate-f5a9755a.css.map +0 -1
  88. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +0 -2
  89. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +0 -1
  90. package/dist/Overlay/Overlay-c52b85b7.css +0 -2
  91. package/dist/Overlay/Overlay-c52b85b7.css.map +0 -1
  92. package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
  93. package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
  94. package/dist/experimental/SelectPanel2/SelectPanel-1f8c23b5.css +0 -2
  95. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css +0 -2
  96. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css.map +0 -1
@@ -108,6 +108,7 @@ function Panel({
108
108
  align,
109
109
  showSelectAll = false,
110
110
  focusPrependedElements,
111
+ virtualized,
111
112
  ...listProps
112
113
  }) {
113
114
  var _listProps$groupMetad;
@@ -132,8 +133,6 @@ function Panel({
132
133
  wide: false
133
134
  }, false);
134
135
  const [selectedOnSort, setSelectedOnSort] = useState([]);
135
- const [prevItems, setPrevItems] = useState([]);
136
- const [prevOpen, setPrevOpen] = useState(open);
137
136
  const initialHeightRef = useRef(0);
138
137
  const initialScaleRef = useRef(1);
139
138
  const noticeRef = useRef(null);
@@ -205,6 +204,19 @@ function Panel({
205
204
  resetSort();
206
205
  }
207
206
  }, [loadingManagedInternally, externalOnFilterChange, setInternalFilterValue, dataLoadedOnce, safeSetTimeout, safeClearTimeout, items.length, resetSort]);
207
+
208
+ // Pre-compute a Set of item IDs in the current filtered view for O(1) lookups
209
+ const itemsInViewSet = useMemo(() => {
210
+ const set = new Set();
211
+ for (const item of items) {
212
+ if (item.id !== undefined) {
213
+ set.add(item.id);
214
+ } else {
215
+ set.add(item);
216
+ }
217
+ }
218
+ return set;
219
+ }, [items]);
208
220
  const handleSelectAllChange = useCallback(checked => {
209
221
  // Exit early if not in multi-select mode
210
222
  if (!isMultiSelectVariant(selected)) {
@@ -212,13 +224,20 @@ function Panel({
212
224
  }
213
225
  const multiSelectOnChange = onSelectedChange;
214
226
  const selectedArray = selected;
215
- const selectedItemsNotInFilteredView = selectedArray.filter(selectedItem => !items.some(item => areItemsEqual(item, selectedItem)));
227
+
228
+ // Use Set for O(1) lookup instead of O(n) items.some()
229
+ const selectedItemsNotInFilteredView = selectedArray.filter(selectedItem => {
230
+ if (selectedItem.id !== undefined) {
231
+ return !itemsInViewSet.has(selectedItem.id);
232
+ }
233
+ return !itemsInViewSet.has(selectedItem);
234
+ });
216
235
  if (checked) {
217
236
  multiSelectOnChange([...selectedItemsNotInFilteredView, ...items]);
218
237
  } else {
219
238
  multiSelectOnChange(selectedItemsNotInFilteredView);
220
239
  }
221
- }, [items, onSelectedChange, selected]);
240
+ }, [items, itemsInViewSet, onSelectedChange, selected]);
222
241
 
223
242
  // disable body scroll when the panel is open on narrow screens
224
243
  useEffect(() => {
@@ -384,10 +403,29 @@ function Panel({
384
403
  });
385
404
  };
386
405
  }, [placeholder, renderAnchor, selected]);
406
+
407
+ // Pre-compute a Set of selected item IDs/references for O(1) lookups
408
+ // This optimizes isItemCurrentlySelected from O(m) to O(1) per call
409
+ const selectedItemsSet = useMemo(() => {
410
+ const set = new Set();
411
+ if (isMultiSelectVariant(selected)) {
412
+ for (const item of selected) {
413
+ if (item.id !== undefined) {
414
+ set.add(item.id);
415
+ } else {
416
+ set.add(item);
417
+ }
418
+ }
419
+ }
420
+ return set;
421
+ }, [selected]);
387
422
  const isItemCurrentlySelected = useCallback(item => {
388
- // For multi-select, we just need to check if the item is in the selected array
423
+ // For multi-select, use the pre-computed Set for O(1) lookup
389
424
  if (isMultiSelectVariant(selected)) {
390
- return doesItemsIncludeItem(selected, item);
425
+ if (item.id !== undefined) {
426
+ return selectedItemsSet.has(item.id);
427
+ }
428
+ return selectedItemsSet.has(item);
391
429
  }
392
430
 
393
431
  // For single-select modal, there is an intermediate state when the user has selected
@@ -398,8 +436,24 @@ function Panel({
398
436
 
399
437
  // For single-select anchored, we just need to check if the item is the selected item
400
438
  return (selected === null || selected === void 0 ? void 0 : selected.id) !== undefined ? selected.id === item.id : selected === item;
401
- }, [selected, intermediateSelected, isSingleSelectModal]);
439
+ }, [selected, selectedItemsSet, intermediateSelected, isSingleSelectModal]);
402
440
  const itemsToRender = useMemo(() => {
441
+ // Pre-compute a Set of selected item IDs/references for O(1) lookups during sorting
442
+ // This avoids O(m * k) work per comparison in the sort function
443
+ const selectedOnSortSet = new Set();
444
+ for (const item of selectedOnSort) {
445
+ if (item.id !== undefined) {
446
+ selectedOnSortSet.add(item.id);
447
+ } else {
448
+ selectedOnSortSet.add(item);
449
+ }
450
+ }
451
+ const isSelectedForSort = item => {
452
+ if (item.id !== undefined) {
453
+ return selectedOnSortSet.has(item.id);
454
+ }
455
+ return selectedOnSortSet.has(item);
456
+ };
403
457
  return items.map(item => {
404
458
  return {
405
459
  ...item,
@@ -436,42 +490,39 @@ function Panel({
436
490
  };
437
491
  }).sort((itemA, itemB) => {
438
492
  if (shouldOrderSelectedFirst) {
439
- // itemA is selected (for sorting purposes) if an object in selectedOnSort matches every property of itemA, except for the selected property
440
- const itemASelected = selectedOnSort.some(item => Object.entries(item).every(([key, value]) => {
441
- if (key === 'selected') {
442
- return true;
443
- }
444
- return itemA[key] === value;
445
- }));
446
-
447
- // itemB is selected (for sorting purposes) if an object in selectedOnSort matches every property of itemA, except for the selected property
448
- const itemBSelected = selectedOnSort.some(item => Object.entries(item).every(([key, value]) => {
449
- if (key === 'selected') {
450
- return true;
451
- }
452
- return itemB[key] === value;
453
- }));
493
+ const itemASelected = isSelectedForSort(itemA);
494
+ const itemBSelected = isSelectedForSort(itemB);
454
495
 
455
496
  // order selected items first
456
- if (itemASelected > itemBSelected) {
497
+ if (itemASelected && !itemBSelected) {
457
498
  return -1;
458
- } else if (itemASelected < itemBSelected) {
499
+ } else if (!itemASelected && itemBSelected) {
459
500
  return 1;
460
501
  }
461
502
  }
462
503
  return 0;
463
504
  });
464
505
  }, [onClose, onSelectedChange, items, selected, isItemCurrentlySelected, isSingleSelectModal, intermediateSelected, shouldOrderSelectedFirst, selectedOnSort]);
465
- if (prevItems !== items) {
466
- setPrevItems(items);
467
- if (prevItems.length === 0 && items.length > 0) {
506
+
507
+ // Track previous items and reset sort when items first load
508
+ const prevItemsRef = useRef(items);
509
+ useEffect(() => {
510
+ if (prevItemsRef.current !== items) {
511
+ if (prevItemsRef.current.length === 0 && items.length > 0) {
512
+ resetSort();
513
+ }
514
+ prevItemsRef.current = items;
515
+ }
516
+ }, [items, resetSort]);
517
+
518
+ // Reset sort when panel opens
519
+ const prevOpenRef = useRef(open);
520
+ useEffect(() => {
521
+ if (prevOpenRef.current !== open) {
468
522
  resetSort();
523
+ prevOpenRef.current = open;
469
524
  }
470
- }
471
- if (open !== prevOpen) {
472
- setPrevOpen(open);
473
- resetSort();
474
- }
525
+ }, [open, resetSort]);
475
526
  const focusTrapSettings = {
476
527
  initialFocusRef: inputRef || undefined
477
528
  };
@@ -681,7 +732,8 @@ function Panel({
681
732
  },
682
733
  fullScreenOnNarrow: usingFullScreenOnNarrow,
683
734
  className: clsx(className, classes.FilteredActionList),
684
- focusPrependedElements: focusPrependedElements
735
+ focusPrependedElements: focusPrependedElements,
736
+ virtualized: virtualized
685
737
  }), footer ? /*#__PURE__*/jsx("div", {
686
738
  className: classes.Footer,
687
739
  children: footer
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- import type { PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneProps } from '../PageLayout';
2
+ import type { PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneProps, PageLayoutSidebarProps } from '../PageLayout';
3
3
  export type SplitPageLayoutProps = {
4
4
  className?: string;
5
5
  };
@@ -10,12 +10,15 @@ export type SplitPageLayoutContentProps = PageLayoutContentProps;
10
10
  export declare const Content: React.FC<React.PropsWithChildren<SplitPageLayoutContentProps>>;
11
11
  export type SplitPageLayoutPaneProps = PageLayoutPaneProps;
12
12
  export declare const Pane: React.FC<React.PropsWithChildren<SplitPageLayoutPaneProps>>;
13
+ export type SplitPageLayoutSidebarProps = PageLayoutSidebarProps;
14
+ export declare const Sidebar: React.FC<React.PropsWithChildren<SplitPageLayoutSidebarProps>>;
13
15
  export type SplitPageLayoutFooterProps = PageLayoutFooterProps;
14
16
  export declare const Footer: React.FC<React.PropsWithChildren<SplitPageLayoutFooterProps>>;
15
17
  export declare const SplitPageLayout: React.FC<React.PropsWithChildren<SplitPageLayoutProps>> & {
16
18
  Header: React.FC<React.PropsWithChildren<PageLayoutHeaderProps>>;
17
19
  Content: React.FC<React.PropsWithChildren<PageLayoutContentProps>>;
18
20
  Pane: React.FC<React.PropsWithChildren<PageLayoutPaneProps>>;
21
+ Sidebar: React.FC<React.PropsWithChildren<PageLayoutSidebarProps>>;
19
22
  Footer: React.FC<React.PropsWithChildren<PageLayoutFooterProps>>;
20
23
  };
21
24
  //# sourceMappingURL=SplitPageLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SplitPageLayout.d.ts","sourceRoot":"","sources":["../../src/SplitPageLayout/SplitPageLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAMtB,MAAM,MAAM,oBAAoB,GAAG;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,CAAA;AAEvD,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAcxE,CAAA;AAOD,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAAA;AAE9D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAOhF,CAAA;AAOD,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,CAAA;AAEhE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,CAMlF,CAAA;AAOD,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAE1D,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAgB5E,CAAA;AAMD,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAAA;AAE9D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAOhF,CAAA;AAOD,eAAO,MAAM,eAAe;;;;;CAK1B,CAAA"}
1
+ {"version":3,"file":"SplitPageLayout.d.ts","sourceRoot":"","sources":["../../src/SplitPageLayout/SplitPageLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,eAAe,CAAA;AAMtB,MAAM,MAAM,oBAAoB,GAAG;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,CAAA;AAEvD,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAexE,CAAA;AAOD,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAAA;AAE9D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAOhF,CAAA;AAOD,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,CAAA;AAEhE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,CAMlF,CAAA;AAOD,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAE1D,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAgB5E,CAAA;AAMD,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,CAAA;AAEhE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,CAOlF,CAAA;AAOD,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAAA;AAE9D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CAOhF,CAAA;AAOD,eAAO,MAAM,eAAe;;;;;;CAM1B,CAAA"}
@@ -8,7 +8,8 @@ const Root = props => {
8
8
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
9
9
  t0 = {
10
10
  header: Header,
11
- footer: Footer
11
+ footer: Footer,
12
+ sidebar: Sidebar
12
13
  };
13
14
  $[0] = t0;
14
15
  } else {
@@ -176,6 +177,56 @@ const Pane = t0 => {
176
177
  };
177
178
  Pane.displayName = 'SplitPageLayout.Pane';
178
179
 
180
+ // ----------------------------------------------------------------------------
181
+ // SplitPageLayout.Sidebar
182
+
183
+ const Sidebar = t0 => {
184
+ const $ = c(10);
185
+ let props;
186
+ let t1;
187
+ let t2;
188
+ let t3;
189
+ if ($[0] !== t0) {
190
+ ({
191
+ position: t1,
192
+ padding: t2,
193
+ divider: t3,
194
+ ...props
195
+ } = t0);
196
+ $[0] = t0;
197
+ $[1] = props;
198
+ $[2] = t1;
199
+ $[3] = t2;
200
+ $[4] = t3;
201
+ } else {
202
+ props = $[1];
203
+ t1 = $[2];
204
+ t2 = $[3];
205
+ t3 = $[4];
206
+ }
207
+ const position = t1 === undefined ? "start" : t1;
208
+ const padding = t2 === undefined ? "normal" : t2;
209
+ const divider = t3 === undefined ? "line" : t3;
210
+ let t4;
211
+ if ($[5] !== divider || $[6] !== padding || $[7] !== position || $[8] !== props) {
212
+ t4 = /*#__PURE__*/jsx(PageLayout.Sidebar, {
213
+ position: position,
214
+ padding: padding,
215
+ divider: divider,
216
+ ...props
217
+ });
218
+ $[5] = divider;
219
+ $[6] = padding;
220
+ $[7] = position;
221
+ $[8] = props;
222
+ $[9] = t4;
223
+ } else {
224
+ t4 = $[9];
225
+ }
226
+ return t4;
227
+ };
228
+ Sidebar.displayName = 'SplitPageLayout.Sidebar';
229
+
179
230
  // ----------------------------------------------------------------------------
180
231
  // SplitPageLayout.Footer
181
232
 
@@ -226,7 +277,8 @@ const SplitPageLayout = Object.assign(Root, {
226
277
  Header,
227
278
  Content,
228
279
  Pane,
280
+ Sidebar,
229
281
  Footer
230
282
  });
231
283
 
232
- export { Content, Footer, Header, Pane, Root, SplitPageLayout };
284
+ export { Content, Footer, Header, Pane, Root, Sidebar, SplitPageLayout };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
  import { type PolymorphicProps } from '../utils/modern-polymorphic';
3
3
  export type TextProps<As extends React.ElementType = 'span'> = PolymorphicProps<As, 'span', {
4
4
  size?: 'large' | 'medium' | 'small';
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAA;AAG9C,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CAC7E,EAAE,EACF,MAAM,EACN;IACE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CACF,CAAA;yBAGa,EAAE,SAAS,KAAK,CAAC,WAAW;WAP/B,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;gBACvC,MAAM;;WAFX,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;gBACvC,MAAM;;;;AAuBtB,wBAAoC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Text/Text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAkB,KAAK,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CAC7E,EAAE,EACF,MAAM,EACN;IACE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CACF,CAAA;yBAGa,EAAE,SAAS,KAAK,CAAC,WAAW;WAP/B,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;gBACvC,MAAM;;WAFX,OAAO,GAAG,QAAQ,GAAG,OAAO;aAC1B,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU;gBACvC,MAAM;;;;AAetB,wBAAoC"}
package/dist/Text/Text.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import { c } from 'react-compiler-runtime';
2
2
  import { clsx } from 'clsx';
3
- import React from 'react';
4
3
  import classes from './Text.module.css.js';
5
4
  import { fixedForwardRef } from '../utils/modern-polymorphic.js';
6
5
  import { jsx } from 'react/jsx-runtime';
7
- import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
8
6
 
9
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
8
  function Text(props, ref) {
11
- const $ = c(14);
9
+ const $ = c(15);
12
10
  let className;
13
11
  let rest;
14
12
  let size;
@@ -36,8 +34,6 @@ function Text(props, ref) {
36
34
  weight = $[5];
37
35
  }
38
36
  const Component = t0 === undefined ? "span" : t0;
39
- const innerRef = React.useRef(null);
40
- useRefObjectAsForwardedRef(ref, innerRef);
41
37
  let t1;
42
38
  if ($[6] !== className) {
43
39
  t1 = clsx(className, classes.Text);
@@ -47,22 +43,23 @@ function Text(props, ref) {
47
43
  t1 = $[7];
48
44
  }
49
45
  let t2;
50
- if ($[8] !== Component || $[9] !== rest || $[10] !== size || $[11] !== t1 || $[12] !== weight) {
46
+ if ($[8] !== Component || $[9] !== ref || $[10] !== rest || $[11] !== size || $[12] !== t1 || $[13] !== weight) {
51
47
  t2 = /*#__PURE__*/jsx(Component, {
52
48
  className: t1,
53
49
  "data-size": size,
54
50
  "data-weight": weight,
55
51
  ...rest,
56
- ref: innerRef
52
+ ref: ref
57
53
  });
58
54
  $[8] = Component;
59
- $[9] = rest;
60
- $[10] = size;
61
- $[11] = t1;
62
- $[12] = weight;
63
- $[13] = t2;
55
+ $[9] = ref;
56
+ $[10] = rest;
57
+ $[11] = size;
58
+ $[12] = t1;
59
+ $[13] = weight;
60
+ $[14] = t2;
64
61
  } else {
65
- t2 = $[13];
62
+ t2 = $[14];
66
63
  }
67
64
  return t2;
68
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6D,MAAM,OAAO,CAAA;AAmBjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAuEhC,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,CAAC,SAAS,KAEgC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAChH,CAAA;AAgCD,eAAO,MAAM,YAAY,mFA8RxB,CAAA"}
1
+ {"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6D,MAAM,OAAO,CAAA;AAmBjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAwEhC,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,CAAC,SAAS,KAEgC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAChH,CAAA;AAgCD,eAAO,MAAM,YAAY,mFA8SxB,CAAA"}
@@ -27,7 +27,8 @@ const overflowEffect = (navWidth, moreMenuWidth, childArray, childWidthArray, no
27
27
  updateListAndMenu({
28
28
  items: childArray,
29
29
  menuItems: []
30
- }, iconsVisible);
30
+ }, iconsVisible, false);
31
+ return;
31
32
  }
32
33
  const numberOfItemsPossible = calculatePossibleItems(childWidthArray, navWidth);
33
34
  const numberOfItemsWithoutIconPossible = calculatePossibleItems(noIconChildWidthArray, navWidth);
@@ -78,7 +79,7 @@ const overflowEffect = (navWidth, moreMenuWidth, childArray, childWidthArray, no
78
79
  updateListAndMenu({
79
80
  items,
80
81
  menuItems
81
- }, iconsVisible);
82
+ }, iconsVisible, true);
82
83
  };
83
84
  const getValidChildren = children => {
84
85
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -133,6 +134,8 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
133
134
  const [iconsVisible, setIconsVisible] = useState(true);
134
135
  const [childWidthArray, setChildWidthArray] = useState([]);
135
136
  const [noIconChildWidthArray, setNoIconChildWidthArray] = useState([]);
137
+ // Track whether the initial overflow calculation is complete to prevent CLS
138
+ const [isOverflowMeasured, setIsOverflowMeasured] = useState(false);
136
139
  const validChildren = getValidChildren(children);
137
140
 
138
141
  // Responsive props object manages which items are in the list and which items are in the menu.
@@ -192,7 +195,7 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
192
195
  callback({
193
196
  items: updatedItemList,
194
197
  menuItems: updatedMenuItems
195
- }, false);
198
+ }, false, true);
196
199
  };
197
200
  // How many items do we need to pull in to the menu to make room for the selected menu item.
198
201
  function getBreakpointForItemSwapping(widthToFitIntoList, availableSpace) {
@@ -207,9 +210,12 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
207
210
  }
208
211
  return breakpoint;
209
212
  }
210
- const updateListAndMenu = useCallback((props, displayIcons) => {
213
+ const updateListAndMenu = useCallback((props, displayIcons, overflowMeasured) => {
211
214
  setResponsiveProps(props);
212
215
  setIconsVisible(displayIcons);
216
+ if (overflowMeasured) {
217
+ setIsOverflowMeasured(true);
218
+ }
213
219
  }, []);
214
220
  const setChildrenWidth = useCallback(size => {
215
221
  setChildWidthArray(arr => {
@@ -288,6 +294,7 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
288
294
  className: className,
289
295
  ref: navRef,
290
296
  "data-variant": variant,
297
+ "data-overflow-measured": isOverflowMeasured ? 'true' : 'false',
291
298
  children: /*#__PURE__*/jsxs(UnderlineItemList, {
292
299
  ref: listRef,
293
300
  role: "list",
@@ -1,58 +1,21 @@
1
- import { c } from 'react-compiler-runtime';
2
- import { forwardRef, useRef, useContext } from 'react';
1
+ import React, { forwardRef, useRef, useContext } from 'react';
3
2
  import { UnderlineNavContext } from './UnderlineNavContext.js';
4
3
  import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
5
4
  import { UnderlineItem } from '../internal/components/UnderlineTabbedInterface.js';
6
5
  import classes from './UnderlineNavItem.module.css.js';
7
6
  import { jsx } from 'react/jsx-runtime';
8
7
 
9
- const UnderlineNavItem = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
10
- var _leadingVisual;
11
- const $ = c(32);
12
- let Icon;
13
- let ariaCurrent;
14
- let children;
15
- let counter;
16
- let leadingVisual;
17
- let onSelect;
18
- let props;
19
- let t1;
20
- let t2;
21
- if ($[0] !== t0) {
22
- ({
23
- as: t1,
24
- href: t2,
25
- children,
26
- counter,
27
- onSelect,
28
- "aria-current": ariaCurrent,
29
- icon: Icon,
30
- leadingVisual,
31
- ...props
32
- } = t0);
33
- $[0] = t0;
34
- $[1] = Icon;
35
- $[2] = ariaCurrent;
36
- $[3] = children;
37
- $[4] = counter;
38
- $[5] = leadingVisual;
39
- $[6] = onSelect;
40
- $[7] = props;
41
- $[8] = t1;
42
- $[9] = t2;
43
- } else {
44
- Icon = $[1];
45
- ariaCurrent = $[2];
46
- children = $[3];
47
- counter = $[4];
48
- leadingVisual = $[5];
49
- onSelect = $[6];
50
- props = $[7];
51
- t1 = $[8];
52
- t2 = $[9];
53
- }
54
- const Component = t1 === undefined ? "a" : t1;
55
- const href = t2 === undefined ? "#" : t2;
8
+ const UnderlineNavItem = /*#__PURE__*/forwardRef(({
9
+ as: Component = 'a',
10
+ href = '#',
11
+ children,
12
+ counter,
13
+ onSelect,
14
+ 'aria-current': ariaCurrent,
15
+ icon: Icon,
16
+ leadingVisual,
17
+ ...props
18
+ }, forwardedRef) => {
56
19
  const backupRef = useRef(null);
57
20
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
58
21
  const {
@@ -61,107 +24,51 @@ const UnderlineNavItem = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
61
24
  loadingCounters,
62
25
  iconsVisible
63
26
  } = useContext(UnderlineNavContext);
64
- let t3;
65
- let t4;
66
- if ($[10] !== ref || $[11] !== setChildrenWidth || $[12] !== setNoIconChildrenWidth) {
67
- t3 = () => {
68
- if (ref.current) {
69
- const domRect = ref.current.getBoundingClientRect();
70
- const icon = Array.from(ref.current.children).find(_temp);
71
- const content = Array.from(ref.current.children).find(_temp2);
72
- const text = content.textContent;
73
- const iconWidthWithMargin = icon ? icon.getBoundingClientRect().width + Number(getComputedStyle(icon).marginRight.slice(0, -2)) + Number(getComputedStyle(icon).marginLeft.slice(0, -2)) : 0;
74
- setChildrenWidth({
75
- text,
76
- width: domRect.width
77
- });
78
- setNoIconChildrenWidth({
79
- text,
80
- width: domRect.width - iconWidthWithMargin
81
- });
82
- }
83
- };
84
- t4 = [ref, setChildrenWidth, setNoIconChildrenWidth];
85
- $[10] = ref;
86
- $[11] = setChildrenWidth;
87
- $[12] = setNoIconChildrenWidth;
88
- $[13] = t3;
89
- $[14] = t4;
90
- } else {
91
- t3 = $[13];
92
- t4 = $[14];
93
- }
94
- useIsomorphicLayoutEffect(t3, t4);
95
- let t5;
96
- if ($[15] !== onSelect) {
97
- t5 = event => {
98
- if ((event.key === " " || event.key === "Enter") && !event.defaultPrevented && typeof onSelect === "function") {
99
- onSelect(event);
100
- }
101
- };
102
- $[15] = onSelect;
103
- $[16] = t5;
104
- } else {
105
- t5 = $[16];
106
- }
107
- const keyDownHandler = t5;
108
- let t6;
109
- if ($[17] !== onSelect) {
110
- t6 = event_0 => {
111
- if (!event_0.defaultPrevented && typeof onSelect === "function") {
112
- onSelect(event_0);
113
- }
114
- };
115
- $[17] = onSelect;
116
- $[18] = t6;
117
- } else {
118
- t6 = $[18];
119
- }
120
- const clickHandler = t6;
121
- const t7 = (_leadingVisual = leadingVisual) !== null && _leadingVisual !== void 0 ? _leadingVisual : Icon;
122
- let t8;
123
- if ($[19] !== Component || $[20] !== ariaCurrent || $[21] !== children || $[22] !== clickHandler || $[23] !== counter || $[24] !== href || $[25] !== iconsVisible || $[26] !== keyDownHandler || $[27] !== loadingCounters || $[28] !== props || $[29] !== ref || $[30] !== t7) {
124
- t8 = /*#__PURE__*/jsx("li", {
125
- className: classes.UnderlineNavItem,
126
- children: /*#__PURE__*/jsx(UnderlineItem, {
127
- ref: ref,
128
- as: Component,
129
- href: href,
130
- "aria-current": ariaCurrent,
131
- onKeyDown: keyDownHandler,
132
- onClick: clickHandler,
133
- counter: counter,
134
- icon: t7,
135
- loadingCounters: loadingCounters,
136
- iconsVisible: iconsVisible,
137
- ...props,
138
- children: children
139
- })
140
- });
141
- $[19] = Component;
142
- $[20] = ariaCurrent;
143
- $[21] = children;
144
- $[22] = clickHandler;
145
- $[23] = counter;
146
- $[24] = href;
147
- $[25] = iconsVisible;
148
- $[26] = keyDownHandler;
149
- $[27] = loadingCounters;
150
- $[28] = props;
151
- $[29] = ref;
152
- $[30] = t7;
153
- $[31] = t8;
154
- } else {
155
- t8 = $[31];
156
- }
157
- return t8;
27
+ useIsomorphicLayoutEffect(() => {
28
+ if (ref.current) {
29
+ const domRect = ref.current.getBoundingClientRect();
30
+ const icon = Array.from(ref.current.children).find(child => child.getAttribute('data-component') === 'icon');
31
+ const content = Array.from(ref.current.children).find(child => child.getAttribute('data-component') === 'text');
32
+ const text = content.textContent;
33
+ const iconWidthWithMargin = icon ? icon.getBoundingClientRect().width + Number(getComputedStyle(icon).marginRight.slice(0, -2)) + Number(getComputedStyle(icon).marginLeft.slice(0, -2)) : 0;
34
+ setChildrenWidth({
35
+ text,
36
+ width: domRect.width
37
+ });
38
+ setNoIconChildrenWidth({
39
+ text,
40
+ width: domRect.width - iconWidthWithMargin
41
+ });
42
+ }
43
+ }, [ref, setChildrenWidth, setNoIconChildrenWidth]);
44
+ const keyDownHandler = React.useCallback(event => {
45
+ if ((event.key === ' ' || event.key === 'Enter') && !event.defaultPrevented && typeof onSelect === 'function') {
46
+ onSelect(event);
47
+ }
48
+ }, [onSelect]);
49
+ const clickHandler = React.useCallback(event => {
50
+ if (!event.defaultPrevented && typeof onSelect === 'function') {
51
+ onSelect(event);
52
+ }
53
+ }, [onSelect]);
54
+ return /*#__PURE__*/jsx("li", {
55
+ className: classes.UnderlineNavItem,
56
+ children: /*#__PURE__*/jsx(UnderlineItem, {
57
+ ref: ref,
58
+ as: Component,
59
+ href: href,
60
+ "aria-current": ariaCurrent,
61
+ onKeyDown: keyDownHandler,
62
+ onClick: clickHandler,
63
+ counter: counter,
64
+ icon: leadingVisual !== null && leadingVisual !== void 0 ? leadingVisual : Icon,
65
+ loadingCounters: loadingCounters,
66
+ iconsVisible: iconsVisible,
67
+ ...props,
68
+ children: children
69
+ })
70
+ });
158
71
  });
159
72
  UnderlineNavItem.displayName = 'UnderlineNavItem';
160
- function _temp(child) {
161
- return child.getAttribute("data-component") === "icon";
162
- }
163
- function _temp2(child_0) {
164
- return child_0.getAttribute("data-component") === "text";
165
- }
166
73
 
167
74
  export { UnderlineNavItem };