@primer/react 0.0.0-20260601092328 → 0.0.0-20260601130945

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,9 +1,11 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260601092328
3
+ ## 0.0.0-20260601130945
4
4
 
5
5
  ### Minor Changes
6
6
 
7
+ - [#7900](https://github.com/primer/react/pull/7900) [`ea2ad86`](https://github.com/primer/react/commit/ea2ad8678471635cb14e62667b06b27694605ca5) Thanks [@mattcosta7](https://github.com/mattcosta7)! - `PageLayout.Sidebar` (and `SplitPageLayout.Sidebar`): add controlled-width support via `currentWidth` + `onResizeEnd`, matching the discriminated-union API already on `PageLayout.Pane`. The underlying `usePaneWidth` hook already supported these options; this wires them through the component's prop surface. Existing usage is unchanged — the props are opt-in and the uncontrolled (default or `widthStorageKey`-backed) behavior is preserved exactly.
8
+
7
9
  - [#7906](https://github.com/primer/react/pull/7906) [`adc5299`](https://github.com/primer/react/commit/adc5299f3d98519119fb9547e50dd2985fc96174) Thanks [@jonrohan](https://github.com/jonrohan)! - Text: Add `whiteSpace` prop to control the CSS `white-space` property
8
10
 
9
11
  ### Patch Changes
@@ -160,7 +160,7 @@ export type PageLayoutPaneProps = PageLayoutPaneBaseProps & ({
160
160
  currentWidth?: never;
161
161
  });
162
162
  declare const Pane: React.ForwardRefExoticComponent<React.PropsWithChildren<PageLayoutPaneProps> & React.RefAttributes<HTMLDivElement>>;
163
- export type PageLayoutSidebarProps = {
163
+ export type PageLayoutSidebarBaseProps = {
164
164
  /**
165
165
  * A unique label for the sidebar region
166
166
  */
@@ -175,7 +175,10 @@ export type PageLayoutSidebarProps = {
175
175
  */
176
176
  position?: 'start' | 'end';
177
177
  /**
178
- * Width configuration for the sidebar
178
+ * Width configuration for the sidebar.
179
+ *
180
+ * When `resizable` is enabled, this defines the default width and constraints
181
+ * (min/max bounds for dragging). Use `currentWidth` to control the displayed width.
179
182
  */
180
183
  width?: PaneWidth | CustomWidthOptions;
181
184
  /**
@@ -190,7 +193,7 @@ export type PageLayoutSidebarProps = {
190
193
  resizable?: boolean;
191
194
  /**
192
195
  * localStorage key used to persist the sidebar width across sessions.
193
- * Only applies when `resizable` is `true`.
196
+ * Only applies when `resizable` is `true` and no `onResizeEnd` callback is provided.
194
197
  * When omitted, localStorage is not used.
195
198
  */
196
199
  widthStorageKey?: string;
@@ -226,9 +229,24 @@ export type PageLayoutSidebarProps = {
226
229
  className?: string;
227
230
  style?: React.CSSProperties;
228
231
  };
229
- declare const Sidebar: React.ForwardRefExoticComponent<PageLayoutSidebarProps & {
230
- children?: React.ReactNode | undefined;
231
- } & React.RefAttributes<HTMLDivElement>>;
232
+ export type PageLayoutSidebarProps = PageLayoutSidebarBaseProps & ({
233
+ /**
234
+ * Callback fired when a resize operation ends (drag release or keyboard key up).
235
+ * When provided, this callback is used instead of localStorage persistence.
236
+ */
237
+ onResizeEnd: (width: number) => void;
238
+ /**
239
+ * Current/controlled width value in pixels.
240
+ * When provided, this is used as the current sidebar width instead of internal state.
241
+ * The `width` prop still defines the default used when resetting (e.g., double-click).
242
+ * Pass `undefined` when the persisted value has not loaded yet (e.g., async fetch).
243
+ */
244
+ currentWidth: number | undefined;
245
+ } | {
246
+ onResizeEnd?: never;
247
+ currentWidth?: never;
248
+ });
249
+ declare const Sidebar: React.ForwardRefExoticComponent<React.PropsWithChildren<PageLayoutSidebarProps> & React.RefAttributes<HTMLDivElement>>;
232
250
  export type PageLayoutFooterProps = {
233
251
  /**
234
252
  * A unique label for the rendered contentinfo landmark
@@ -1 +1 @@
1
- {"version":3,"file":"PageLayout.d.ts","sourceRoot":"","sources":["../../src/PageLayout/PageLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAQhE,OAAO,KAAK,EAAC,gBAAgB,EAAE,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AC,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAC3D,OAAO,CAAC,EAAE,MAAM,OAAO,WAAW,CAAA;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAA;IACxF;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC1D,MAAM,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;AA6DD,eAAO,MAAM,UAAU;;;UAGP,cAAc,CAAC,OAAO,IAAI,CAAC;aACrB,cAAc,CAAC,OAAO,OAAO,CAAC;;CAElD,CAAA"}
@@ -742,6 +742,8 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
742
742
  position = 'start',
743
743
  width = 'medium',
744
744
  minWidth = 256,
745
+ currentWidth: controlledWidth,
746
+ onResizeEnd,
745
747
  padding = 'none',
746
748
  resizable = false,
747
749
  widthStorageKey,
@@ -783,7 +785,9 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
783
785
  paneRef: sidebarRef,
784
786
  handleRef,
785
787
  contentWrapperRef: sidebarContentWrapperRef,
786
- constrainToViewport: true
788
+ constrainToViewport: true,
789
+ onResizeEnd,
790
+ currentWidth: controlledWidth
787
791
  });
788
792
  const mergedSidebarRef = useMergedRefs(forwardRef, sidebarRef);
789
793
  const hasOverflow = useOverflow(sidebarRef);
@@ -827,8 +831,9 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
827
831
  ref: mergedSidebarRef
828
832
  // Suppress hydration mismatch for --pane-width when localStorage
829
833
  // provides a width that differs from the server-rendered default.
834
+ // Not needed when onResizeEnd is provided (localStorage isn't read).
830
835
  ,
831
- suppressHydrationWarning: resizable === true && !!widthStorageKey,
836
+ suppressHydrationWarning: resizable === true && !!widthStorageKey && !onResizeEnd,
832
837
  ...(hasOverflow ? overflowProps : {}),
833
838
  ...labelProp,
834
839
  ...(id && {
@@ -1 +1 @@
1
- {"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AA0BvE,MAAM,WAAW,4BAA6B,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IAC7E,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACpD,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAcD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,4BAA4B,EACvC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IACD,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACnD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACjD,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC,CAiJA"}
1
+ {"version":3,"file":"useAnchoredPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnchoredPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AA0BvE,MAAM,WAAW,4BAA6B,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IAC7E,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACpD,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,4BAA4B,EACvC,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC;IACD,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACnD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACjD,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;CACrC,CAiIA"}
@@ -24,16 +24,6 @@ function getScrollableAncestors(element) {
24
24
  scrollables.push(window);
25
25
  return scrollables;
26
26
  }
27
- function hasOverflowingDescendant(element) {
28
- if (!element) return false;
29
- for (const descendant of element.querySelectorAll('*')) {
30
- if (descendant.scrollHeight > descendant.clientHeight || descendant.scrollWidth > descendant.clientWidth) {
31
- return true;
32
- }
33
- }
34
- return false;
35
- }
36
-
37
27
  /**
38
28
  * Calculates the top and left values for an absolutely-positioned floating element
39
29
  * to be anchored to some anchor element. Returns refs for the floating element
@@ -60,23 +50,9 @@ function useAnchoredPosition(settings, dependencies = []) {
60
50
  const updateElementHeight = () => {
61
51
  let heightUpdated = false;
62
52
  setPrevHeight(prevHeight => {
63
- var _floatingElement$clie, _floatingElement$scro;
64
- const floatingElement = floatingElementRef.current;
65
- const currentHeight = (_floatingElement$clie = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.clientHeight) !== null && _floatingElement$clie !== void 0 ? _floatingElement$clie : 0;
66
- const desiredHeight = Math.max((_floatingElement$scro = floatingElement === null || floatingElement === void 0 ? void 0 : floatingElement.scrollHeight) !== null && _floatingElement$scro !== void 0 ? _floatingElement$scro : 0, currentHeight);
67
- const contentNeedsMoreHeight = prevHeight !== undefined && desiredHeight > prevHeight || hasOverflowingDescendant(floatingElement);
68
-
69
- // if the element is trying to shrink in height, restore to old height to prevent it from jumping.
70
- // When the content now needs to grow past the previous height, clear any stale inline height instead.
71
- if (prevHeight && prevHeight > currentHeight) {
72
- if (contentNeedsMoreHeight) {
73
- requestAnimationFrame(() => {
74
- if (floatingElementRef.current instanceof HTMLElement) {
75
- floatingElementRef.current.style.height = '';
76
- }
77
- });
78
- return prevHeight;
79
- }
53
+ var _floatingElementRef$c, _floatingElementRef$c2;
54
+ // if the element is trying to shrink in height, restore to old height to prevent it from jumping
55
+ if (prevHeight && prevHeight > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0)) {
80
56
  requestAnimationFrame(() => {
81
57
  floatingElementRef.current.style.height = `${prevHeight}px`;
82
58
  });
@@ -87,15 +63,15 @@ function useAnchoredPosition(settings, dependencies = []) {
87
63
  return heightUpdated;
88
64
  };
89
65
  const updatePosition = React.useCallback(() => {
90
- var _floatingElementRef$c3;
66
+ var _floatingElementRef$c5;
91
67
  if (!enabled) return;
92
68
  if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
93
69
  const newPosition = getAnchoredPosition(floatingElementRef.current, anchorElementRef.current, settings);
94
70
  setPosition(prev => {
95
71
  if (settings !== null && settings !== void 0 && settings.pinPosition && topPositionChanged(prev, newPosition)) {
96
- var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c, _floatingElementRef$c2;
72
+ var _anchorElementRef$cur, _anchorElementRef$cur2, _floatingElementRef$c3, _floatingElementRef$c4;
97
73
  const anchorTop = (_anchorElementRef$cur = (_anchorElementRef$cur2 = anchorElementRef.current) === null || _anchorElementRef$cur2 === void 0 ? void 0 : _anchorElementRef$cur2.getBoundingClientRect().top) !== null && _anchorElementRef$cur !== void 0 ? _anchorElementRef$cur : 0;
98
- const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$c = (_floatingElementRef$c2 = floatingElementRef.current) === null || _floatingElementRef$c2 === void 0 ? void 0 : _floatingElementRef$c2.clientHeight) !== null && _floatingElementRef$c !== void 0 ? _floatingElementRef$c : 0);
74
+ const elementStillFitsOnTop = anchorTop > ((_floatingElementRef$c3 = (_floatingElementRef$c4 = floatingElementRef.current) === null || _floatingElementRef$c4 === void 0 ? void 0 : _floatingElementRef$c4.clientHeight) !== null && _floatingElementRef$c3 !== void 0 ? _floatingElementRef$c3 : 0);
99
75
  if (elementStillFitsOnTop && updateElementHeight()) {
100
76
  return prev;
101
77
  }
@@ -112,7 +88,7 @@ function useAnchoredPosition(settings, dependencies = []) {
112
88
  setPosition(undefined);
113
89
  (_savedOnPositionChang2 = savedOnPositionChange.current) === null || _savedOnPositionChang2 === void 0 ? void 0 : _savedOnPositionChang2.call(savedOnPositionChange, undefined);
114
90
  }
115
- setPrevHeight((_floatingElementRef$c3 = floatingElementRef.current) === null || _floatingElementRef$c3 === void 0 ? void 0 : _floatingElementRef$c3.clientHeight);
91
+ setPrevHeight((_floatingElementRef$c5 = floatingElementRef.current) === null || _floatingElementRef$c5 === void 0 ? void 0 : _floatingElementRef$c5.clientHeight);
116
92
  },
117
93
  // eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
118
94
  [floatingElementRef, anchorElementRef, enabled, ...dependencies]);
@@ -5041,6 +5041,14 @@
5041
5041
  "id": "components-pagelayout-features--resizable-sidebar",
5042
5042
  "code": "() => (\n <PageLayout containerWidth=\"full\">\n <PageLayout.Sidebar\n resizable\n position=\"end\"\n aria-label=\"Resizable sidebar\"\n style={{\n height: 'auto',\n }}\n width={{\n min: '200px',\n default: '300px',\n max: '2000px',\n }}\n >\n <Placeholder height=\"100%\" label=\"Resizable Sidebar\" />\n </PageLayout.Sidebar>\n <PageLayout.Header>\n <Placeholder height={64} label=\"Header\" />\n </PageLayout.Header>\n <PageLayout.Pane position=\"start\" aria-label=\"Side pane\">\n <Placeholder height={320} label=\"Pane\" />\n </PageLayout.Pane>\n <PageLayout.Content>\n <Placeholder height={640} label=\"Content\" />\n </PageLayout.Content>\n <PageLayout.Footer>\n <Placeholder height={64} label=\"Footer\" />\n </PageLayout.Footer>\n </PageLayout>\n)"
5043
5043
  },
5044
+ {
5045
+ "id": "components-pagelayout-features--resizable-sidebar-without-persistence",
5046
+ "code": "() => {\n const [currentWidth, setCurrentWidth] = React.useState<number>(300)\n return (\n <PageLayout containerWidth=\"full\">\n <PageLayout.Sidebar\n resizable\n position=\"start\"\n currentWidth={currentWidth}\n onResizeEnd={setCurrentWidth}\n aria-label=\"Resizable sidebar (controlled)\"\n style={{\n height: 'auto',\n }}\n width={{\n min: '200px',\n default: '300px',\n max: '600px',\n }}\n >\n <Placeholder\n height=\"100%\"\n label={`Sidebar (controlled, width: ${currentWidth}px)`}\n />\n </PageLayout.Sidebar>\n <PageLayout.Header>\n <Placeholder height={64} label=\"Header\" />\n </PageLayout.Header>\n <PageLayout.Content>\n <Placeholder height={640} label=\"Content\" />\n </PageLayout.Content>\n <PageLayout.Footer>\n <Placeholder height={64} label=\"Footer\" />\n </PageLayout.Footer>\n </PageLayout>\n )\n}"
5047
+ },
5048
+ {
5049
+ "id": "components-pagelayout-features--resizable-sidebar-with-custom-persistence",
5050
+ "code": "() => {\n const key = 'page-layout-features-stories-custom-persistence-sidebar-width'\n\n // Read initial width from localStorage (CSR only), falling back to medium preset\n const getInitialWidth = (): number => {\n if (typeof window !== 'undefined') {\n const storedWidth = localStorage.getItem(key)\n if (storedWidth !== null) {\n const parsed = parseFloat(storedWidth)\n if (!isNaN(parsed) && parsed > 0) {\n return parsed\n }\n }\n }\n return defaultPaneWidth.medium\n }\n const [currentWidth, setCurrentWidth] =\n React.useState<number>(getInitialWidth)\n useIsomorphicLayoutEffect(() => {\n setCurrentWidth(getInitialWidth())\n }, [])\n const handleWidthChange = (width: number) => {\n setCurrentWidth(width)\n localStorage.setItem(key, width.toString())\n }\n return (\n <PageLayout containerWidth=\"full\">\n <PageLayout.Sidebar\n resizable\n position=\"start\"\n currentWidth={currentWidth}\n onResizeEnd={handleWidthChange}\n aria-label=\"Resizable sidebar (custom persistence)\"\n style={{\n height: 'auto',\n }}\n width={{\n min: '200px',\n default: `${defaultPaneWidth.medium}px`,\n max: '600px',\n }}\n >\n <Placeholder\n height=\"100%\"\n label={`Sidebar (width: ${currentWidth}px)`}\n />\n </PageLayout.Sidebar>\n <PageLayout.Header>\n <Placeholder height={64} label=\"Header\" />\n </PageLayout.Header>\n <PageLayout.Content>\n <Placeholder height={640} label=\"Content\" />\n </PageLayout.Content>\n <PageLayout.Footer>\n <Placeholder height={64} label=\"Footer\" />\n </PageLayout.Footer>\n </PageLayout>\n )\n}"
5051
+ },
5044
5052
  {
5045
5053
  "id": "components-pagelayout-features--sidebar-with-pane-resizable",
5046
5054
  "code": "() => (\n <PageLayout containerWidth=\"full\">\n <PageLayout.Sidebar\n style={{\n height: 'auto',\n }}\n resizable\n position=\"end\"\n aria-label=\"Navigation sidebar\"\n width={{\n min: '200px',\n default: '300px',\n max: '2000px',\n }}\n >\n <Placeholder height=\"100%\" label=\"Resizable Sidebar\" />\n </PageLayout.Sidebar>\n <PageLayout.Header>\n <Placeholder height={64} label=\"Header\" />\n </PageLayout.Header>\n <PageLayout.Pane resizable position=\"start\" aria-label=\"Side pane\">\n <Placeholder height={320} label=\"Resizable Pane\" />\n </PageLayout.Pane>\n <PageLayout.Content>\n <Placeholder height={640} label=\"Content\" />\n </PageLayout.Content>\n <PageLayout.Footer>\n <Placeholder height={64} label=\"Footer\" />\n </PageLayout.Footer>\n </PageLayout>\n)"
@@ -5296,7 +5304,22 @@
5296
5304
  "name": "resizable",
5297
5305
  "type": "boolean",
5298
5306
  "defaultValue": "false",
5299
- "description": "When true, the sidebar may be resized by the user. Width is persisted to localStorage by default."
5307
+ "description": "When true, the sidebar may be resized by the user. By default no persistence is applied; pass `widthStorageKey` to persist via localStorage, or use `onResizeEnd` + `currentWidth` for fully controlled persistence."
5308
+ },
5309
+ {
5310
+ "name": "currentWidth",
5311
+ "type": "number | undefined",
5312
+ "description": "Current/controlled width value in pixels. Required when `onResizeEnd` is provided. Pass `undefined` when the persisted value has not loaded yet. The `width` prop still defines the default used when resetting (e.g., double-click)."
5313
+ },
5314
+ {
5315
+ "name": "onResizeEnd",
5316
+ "type": "(width: number) => void",
5317
+ "description": "Callback fired when a resize operation ends (drag release or keyboard key up). When provided, replaces localStorage persistence. Requires `currentWidth`."
5318
+ },
5319
+ {
5320
+ "name": "widthStorageKey",
5321
+ "type": "string",
5322
+ "description": "localStorage key used to persist the sidebar width across sessions. Only applies when `resizable` is `true` and no `onResizeEnd` callback is provided. When omitted, localStorage is not used."
5300
5323
  },
5301
5324
  {
5302
5325
  "name": "padding",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260601092328",
4
+ "version": "0.0.0-20260601130945",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",