@primer/react 0.0.0-20260225211348 → 0.0.0-20260225214420

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 (83) hide show
  1. package/CHANGELOG.md +37 -5
  2. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  3. package/dist/ActionBar/ActionBar.js +431 -281
  4. package/dist/ActionList/ActionList-c04a02d6.css +2 -0
  5. package/dist/ActionList/ActionList-c04a02d6.css.map +1 -0
  6. package/dist/ActionList/ActionList.module.css.js +1 -1
  7. package/dist/ActionList/Item.d.ts.map +1 -1
  8. package/dist/ActionList/Item.js +1 -0
  9. package/dist/Autocomplete/Autocomplete.js +76 -159
  10. package/dist/Autocomplete/AutocompleteMenu.js +128 -333
  11. package/dist/Autocomplete/AutocompleteOverlay.js +49 -130
  12. package/dist/Banner/Banner.js +64 -238
  13. package/dist/Blankslate/{Blankslate-f5a9755a.css → Blankslate-a039d79a.css} +2 -2
  14. package/dist/Blankslate/Blankslate-a039d79a.css.map +1 -0
  15. package/dist/Blankslate/Blankslate.module.css.js +1 -1
  16. package/dist/Button/ButtonBase.d.ts.map +1 -1
  17. package/dist/Button/ButtonBase.js +9 -14
  18. package/dist/Checkbox/Checkbox.js +55 -163
  19. package/dist/Dialog/Dialog-1a86df19.css +2 -0
  20. package/dist/Dialog/Dialog-1a86df19.css.map +1 -0
  21. package/dist/Dialog/Dialog.d.ts +7 -0
  22. package/dist/Dialog/Dialog.d.ts.map +1 -1
  23. package/dist/Dialog/Dialog.js +112 -347
  24. package/dist/Dialog/Dialog.module.css.js +1 -1
  25. package/dist/FilteredActionList/FilteredActionList-02db90c6.css +2 -0
  26. package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +1 -0
  27. package/dist/FilteredActionList/FilteredActionList.d.ts +16 -1
  28. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  29. package/dist/FilteredActionList/FilteredActionList.js +147 -42
  30. package/dist/FilteredActionList/FilteredActionList.module.css.js +2 -2
  31. package/dist/Overlay/Overlay-15519c09.css +2 -0
  32. package/dist/Overlay/Overlay-15519c09.css.map +1 -0
  33. package/dist/Overlay/Overlay.module.css.js +1 -1
  34. package/dist/PageLayout/PageLayout-3444a142.css +2 -0
  35. package/dist/PageLayout/PageLayout-3444a142.css.map +1 -0
  36. package/dist/PageLayout/PageLayout.d.ts +72 -2
  37. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  38. package/dist/PageLayout/PageLayout.js +750 -1235
  39. package/dist/PageLayout/PageLayout.module.css.js +2 -2
  40. package/dist/PageLayout/usePaneWidth.d.ts +18 -6
  41. package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
  42. package/dist/PageLayout/usePaneWidth.js +126 -112
  43. package/dist/SelectPanel/SelectPanel.d.ts +1 -1
  44. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  45. package/dist/SelectPanel/SelectPanel.js +85 -33
  46. package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
  47. package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
  48. package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
  49. package/dist/Text/Text.d.ts +1 -1
  50. package/dist/Text/Text.d.ts.map +1 -1
  51. package/dist/Text/Text.js +10 -13
  52. package/dist/UnderlineNav/UnderlineNavItem.js +56 -149
  53. package/dist/experimental/SelectPanel2/SelectPanel-f0c4b9ca.css +2 -0
  54. package/dist/experimental/SelectPanel2/{SelectPanel-1f8c23b5.css.map → SelectPanel-f0c4b9ca.css.map} +1 -1
  55. package/dist/experimental/SelectPanel2/SelectPanel.js +209 -593
  56. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +1 -1
  57. package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
  58. package/dist/hooks/useRefObjectAsForwardedRef.js +10 -2
  59. package/dist/hooks/useScrollFlash.d.ts.map +1 -1
  60. package/dist/hooks/useScrollFlash.js +14 -22
  61. package/dist/hooks/useSlots.d.ts +50 -6
  62. package/dist/hooks/useSlots.d.ts.map +1 -1
  63. package/dist/hooks/useSlots.js +114 -36
  64. package/dist/live-region/Announce.d.ts.map +1 -1
  65. package/dist/live-region/Announce.js +7 -4
  66. package/dist/utils/environment.js +9 -0
  67. package/generated/components.json +216 -5
  68. package/package.json +4 -4
  69. package/dist/ActionList/ActionList-f4ac3b54.css +0 -2
  70. package/dist/ActionList/ActionList-f4ac3b54.css.map +0 -1
  71. package/dist/Blankslate/Blankslate-f5a9755a.css.map +0 -1
  72. package/dist/Dialog/Dialog-9e7a4691.css +0 -2
  73. package/dist/Dialog/Dialog-9e7a4691.css.map +0 -1
  74. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +0 -2
  75. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +0 -1
  76. package/dist/Overlay/Overlay-43cda449.css +0 -2
  77. package/dist/Overlay/Overlay-43cda449.css.map +0 -1
  78. package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
  79. package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
  80. package/dist/experimental/SelectPanel2/SelectPanel-1f8c23b5.css +0 -2
  81. package/dist/utils/descendant-registry.d.ts +0 -32
  82. package/dist/utils/descendant-registry.d.ts.map +0 -1
  83. package/dist/utils/descendant-registry.js +0 -222
@@ -1,4 +1,3 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React, { useRef, memo } from 'react';
3
2
  import { clsx } from 'clsx';
4
3
  import { useId } from '../hooks/useId.js';
@@ -9,9 +8,9 @@ import { useOverflow } from '../hooks/useOverflow.js';
9
8
  import { warning } from '../utils/warning.js';
10
9
  import { getResponsiveAttributes } from '../internal/utils/getResponsiveAttributes.js';
11
10
  import classes from './PageLayout.module.css.js';
12
- import { usePaneWidth, isCustomWidthOptions, isPaneWidth, updateAriaValues, ARROW_KEY_STEP } from './usePaneWidth.js';
11
+ import { usePaneWidth, isPaneWidth, isCustomWidthOptions, updateAriaValues, ARROW_KEY_STEP } from './usePaneWidth.js';
13
12
  import { setDraggingStyles, removeDraggingStyles } from './paneUtils.js';
14
- import { jsxs, jsx } from 'react/jsx-runtime';
13
+ import { jsx, jsxs } from 'react/jsx-runtime';
15
14
 
16
15
  const isArrowKey = key => key === 'ArrowLeft' || key === 'ArrowRight' || key === 'ArrowUp' || key === 'ArrowDown';
17
16
  const isShrinkKey = key => key === 'ArrowLeft' || key === 'ArrowDown';
@@ -24,895 +23,533 @@ const PageLayoutContext = /*#__PURE__*/React.createContext({
24
23
  },
25
24
  contentWrapperRef: {
26
25
  current: null
26
+ },
27
+ sidebarRef: {
28
+ current: null
29
+ },
30
+ sidebarContentWrapperRef: {
31
+ current: null
27
32
  }
28
33
  });
29
34
 
30
35
  // TODO: refs
31
- const Root = t0 => {
32
- const $ = c(22);
33
- const {
34
- containerWidth: t1,
35
- padding: t2,
36
- rowGap: t3,
37
- columnGap: t4,
38
- children,
39
- className,
40
- style,
41
- _slotsConfig: slotsConfig
42
- } = t0;
43
- const containerWidth = t1 === undefined ? "xlarge" : t1;
44
- const padding = t2 === undefined ? "normal" : t2;
45
- const rowGap = t3 === undefined ? "normal" : t3;
46
- const columnGap = t4 === undefined ? "normal" : t4;
36
+ const Root = ({
37
+ containerWidth = 'xlarge',
38
+ padding = 'normal',
39
+ rowGap = 'normal',
40
+ columnGap = 'normal',
41
+ children,
42
+ className,
43
+ style,
44
+ _slotsConfig: slotsConfig
45
+ }) => {
47
46
  const paneRef = useRef(null);
48
47
  const contentWrapperRef = useRef(null);
49
- let t5;
50
- if ($[0] !== slotsConfig) {
51
- t5 = slotsConfig !== null && slotsConfig !== void 0 ? slotsConfig : {
52
- header: Header,
53
- footer: Footer
54
- };
55
- $[0] = slotsConfig;
56
- $[1] = t5;
57
- } else {
58
- t5 = $[1];
59
- }
60
- const [slots, rest] = useSlots(children, t5);
61
- let t6;
62
- if ($[2] !== columnGap || $[3] !== padding || $[4] !== rowGap) {
63
- t6 = {
48
+ const sidebarRef = useRef(null);
49
+ const sidebarContentWrapperRef = useRef(null);
50
+ const [slots, rest] = useSlots(children, slotsConfig !== null && slotsConfig !== void 0 ? slotsConfig : {
51
+ header: Header,
52
+ footer: Footer,
53
+ sidebar: Sidebar
54
+ });
55
+ const memoizedContextValue = React.useMemo(() => {
56
+ return {
64
57
  padding,
65
58
  rowGap,
66
59
  columnGap,
67
60
  paneRef,
68
- contentWrapperRef
61
+ contentWrapperRef,
62
+ sidebarRef,
63
+ sidebarContentWrapperRef
69
64
  };
70
- $[2] = columnGap;
71
- $[3] = padding;
72
- $[4] = rowGap;
73
- $[5] = t6;
74
- } else {
75
- t6 = $[5];
76
- }
77
- const memoizedContextValue = t6;
78
- const t7 = slots.header;
79
- let t8;
80
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
81
- t8 = clsx(classes.PageLayoutContent);
82
- $[6] = t8;
83
- } else {
84
- t8 = $[6];
85
- }
86
- let t9;
87
- if ($[7] !== rest) {
88
- t9 = /*#__PURE__*/jsx("div", {
89
- className: t8,
90
- children: rest
91
- });
92
- $[7] = rest;
93
- $[8] = t9;
94
- } else {
95
- t9 = $[8];
96
- }
97
- let t10;
98
- if ($[9] !== containerWidth || $[10] !== slots.footer || $[11] !== slots.header || $[12] !== t9) {
99
- t10 = /*#__PURE__*/jsxs("div", {
100
- className: classes.PageLayoutWrapper,
101
- "data-width": containerWidth,
102
- children: [t7, t9, slots.footer]
103
- });
104
- $[9] = containerWidth;
105
- $[10] = slots.footer;
106
- $[11] = slots.header;
107
- $[12] = t9;
108
- $[13] = t10;
109
- } else {
110
- t10 = $[13];
111
- }
112
- let t11;
113
- if ($[14] !== className || $[15] !== padding || $[16] !== style || $[17] !== t10) {
114
- t11 = /*#__PURE__*/jsx(RootWrapper, {
65
+ }, [padding, rowGap, columnGap, paneRef, contentWrapperRef, sidebarRef, sidebarContentWrapperRef]);
66
+ return /*#__PURE__*/jsx(PageLayoutContext.Provider, {
67
+ value: memoizedContextValue,
68
+ children: /*#__PURE__*/jsxs(RootWrapper, {
115
69
  style: style,
116
70
  padding: padding,
117
71
  className: className,
118
- children: t10
119
- });
120
- $[14] = className;
121
- $[15] = padding;
122
- $[16] = style;
123
- $[17] = t10;
124
- $[18] = t11;
125
- } else {
126
- t11 = $[18];
127
- }
128
- let t12;
129
- if ($[19] !== memoizedContextValue || $[20] !== t11) {
130
- t12 = /*#__PURE__*/jsx(PageLayoutContext.Provider, {
131
- value: memoizedContextValue,
132
- children: t11
133
- });
134
- $[19] = memoizedContextValue;
135
- $[20] = t11;
136
- $[21] = t12;
137
- } else {
138
- t12 = $[21];
139
- }
140
- return t12;
72
+ hasSidebar: !!slots.sidebar,
73
+ children: [slots.sidebar, /*#__PURE__*/jsxs("div", {
74
+ ref: sidebarContentWrapperRef,
75
+ className: classes.PageLayoutWrapper,
76
+ "data-width": containerWidth,
77
+ children: [slots.header, /*#__PURE__*/jsx("div", {
78
+ className: clsx(classes.PageLayoutContent),
79
+ children: rest
80
+ }), slots.footer]
81
+ })]
82
+ })
83
+ });
141
84
  };
142
- const RootWrapper = /*#__PURE__*/memo(t0 => {
143
- const $ = c(9);
144
- const {
145
- style,
146
- padding,
147
- children,
148
- className
149
- } = t0;
150
- const t1 = `var(--spacing-${padding})`;
151
- let t2;
152
- if ($[0] !== style || $[1] !== t1) {
153
- t2 = {
154
- "--spacing": t1,
85
+ Root.displayName = "Root";
86
+ const RootWrapper = /*#__PURE__*/memo(({
87
+ style,
88
+ padding,
89
+ children,
90
+ className,
91
+ hasSidebar
92
+ }) => {
93
+ return /*#__PURE__*/jsx("div", {
94
+ style: {
95
+ '--spacing': `var(--spacing-${padding})`,
155
96
  ...style
156
- };
157
- $[0] = style;
158
- $[1] = t1;
159
- $[2] = t2;
160
- } else {
161
- t2 = $[2];
162
- }
163
- const t3 = t2;
164
- let t4;
165
- if ($[3] !== className) {
166
- t4 = clsx(classes.PageLayoutRoot, className);
167
- $[3] = className;
168
- $[4] = t4;
169
- } else {
170
- t4 = $[4];
171
- }
172
- let t5;
173
- if ($[5] !== children || $[6] !== t3 || $[7] !== t4) {
174
- t5 = /*#__PURE__*/jsx("div", {
175
- style: t3,
176
- className: t4,
177
- children: children
178
- });
179
- $[5] = children;
180
- $[6] = t3;
181
- $[7] = t4;
182
- $[8] = t5;
183
- } else {
184
- t5 = $[8];
185
- }
186
- return t5;
97
+ },
98
+ className: clsx(classes.PageLayoutRoot, className),
99
+ "data-has-sidebar": hasSidebar || undefined,
100
+ children: children
101
+ });
187
102
  });
188
103
  Root.displayName = 'PageLayout';
189
104
 
190
105
  // ----------------------------------------------------------------------------
191
106
  // Divider (internal)
192
107
 
193
- const HorizontalDivider = /*#__PURE__*/memo(t0 => {
194
- const $ = c(14);
195
- const {
196
- variant: t1,
197
- className,
198
- position,
199
- style
200
- } = t0;
201
- const variant = t1 === undefined ? "none" : t1;
108
+ const HorizontalDivider = /*#__PURE__*/memo(({
109
+ variant = 'none',
110
+ className,
111
+ position,
112
+ style
113
+ }) => {
202
114
  const {
203
115
  padding
204
116
  } = React.useContext(PageLayoutContext);
205
- let t2;
206
- if ($[0] !== className) {
207
- t2 = clsx(classes.HorizontalDivider, className);
208
- $[0] = className;
209
- $[1] = t2;
210
- } else {
211
- t2 = $[1];
212
- }
213
- let t3;
214
- if ($[2] !== variant) {
215
- t3 = getResponsiveAttributes("variant", variant);
216
- $[2] = variant;
217
- $[3] = t3;
218
- } else {
219
- t3 = $[3];
220
- }
221
- let t4;
222
- if ($[4] !== position) {
223
- t4 = getResponsiveAttributes("position", position);
224
- $[4] = position;
225
- $[5] = t4;
226
- } else {
227
- t4 = $[5];
228
- }
229
- const t5 = `var(--spacing-${padding})`;
230
- let t6;
231
- if ($[6] !== style || $[7] !== t5) {
232
- t6 = {
233
- "--spacing-divider": t5,
117
+ return /*#__PURE__*/jsx("div", {
118
+ className: clsx(classes.HorizontalDivider, className),
119
+ ...getResponsiveAttributes('variant', variant),
120
+ ...getResponsiveAttributes('position', position),
121
+ style: {
122
+ '--spacing-divider': `var(--spacing-${padding})`,
234
123
  ...style
235
- };
236
- $[6] = style;
237
- $[7] = t5;
238
- $[8] = t6;
239
- } else {
240
- t6 = $[8];
241
- }
242
- const t7 = t6;
243
- let t8;
244
- if ($[9] !== t2 || $[10] !== t3 || $[11] !== t4 || $[12] !== t7) {
245
- t8 = /*#__PURE__*/jsx("div", {
246
- className: t2,
247
- ...t3,
248
- ...t4,
249
- style: t7
250
- });
251
- $[9] = t2;
252
- $[10] = t3;
253
- $[11] = t4;
254
- $[12] = t7;
255
- $[13] = t8;
256
- } else {
257
- t8 = $[13];
258
- }
259
- return t8;
124
+ }
125
+ });
260
126
  });
261
127
  HorizontalDivider.displayName = 'HorizontalDivider';
262
- const VerticalDivider = /*#__PURE__*/memo(t0 => {
263
- const $ = c(12);
264
- const {
265
- variant: t1,
266
- position,
267
- className,
268
- style,
269
- children
270
- } = t0;
271
- const variant = t1 === undefined ? "none" : t1;
272
- let t2;
273
- if ($[0] !== className) {
274
- t2 = clsx(classes.VerticalDivider, className);
275
- $[0] = className;
276
- $[1] = t2;
277
- } else {
278
- t2 = $[1];
279
- }
280
- let t3;
281
- if ($[2] !== variant) {
282
- t3 = getResponsiveAttributes("variant", variant);
283
- $[2] = variant;
284
- $[3] = t3;
285
- } else {
286
- t3 = $[3];
287
- }
288
- let t4;
289
- if ($[4] !== position) {
290
- t4 = getResponsiveAttributes("position", position);
291
- $[4] = position;
292
- $[5] = t4;
293
- } else {
294
- t4 = $[5];
295
- }
296
- let t5;
297
- if ($[6] !== children || $[7] !== style || $[8] !== t2 || $[9] !== t3 || $[10] !== t4) {
298
- t5 = /*#__PURE__*/jsx("div", {
299
- className: t2,
300
- ...t3,
301
- ...t4,
302
- style: style,
303
- children: children
304
- });
305
- $[6] = children;
306
- $[7] = style;
307
- $[8] = t2;
308
- $[9] = t3;
309
- $[10] = t4;
310
- $[11] = t5;
311
- } else {
312
- t5 = $[11];
313
- }
314
- return t5;
128
+ const VerticalDivider = /*#__PURE__*/memo(({
129
+ variant = 'none',
130
+ position,
131
+ className,
132
+ style,
133
+ children
134
+ }) => {
135
+ return /*#__PURE__*/jsx("div", {
136
+ className: clsx(classes.VerticalDivider, className),
137
+ ...getResponsiveAttributes('variant', variant),
138
+ ...getResponsiveAttributes('position', position),
139
+ style: style,
140
+ children: children
141
+ });
315
142
  });
316
143
  VerticalDivider.displayName = 'VerticalDivider';
144
+ const SidebarDivider = /*#__PURE__*/memo(function SidebarDivider({
145
+ position,
146
+ divider,
147
+ resizable,
148
+ minPaneWidth,
149
+ maxPaneWidth,
150
+ currentWidth,
151
+ currentWidthRef,
152
+ handleRef,
153
+ sidebarRef,
154
+ dragStartClientXRef,
155
+ dragStartWidthRef,
156
+ dragMaxWidthRef,
157
+ getMaxPaneWidth,
158
+ getDefaultWidth,
159
+ saveWidth
160
+ }) {
161
+ const {
162
+ columnGap
163
+ } = React.useContext(PageLayoutContext);
164
+ return /*#__PURE__*/jsx(VerticalDivider, {
165
+ variant: resizable ? 'line' : divider,
166
+ position: position,
167
+ className: classes.SidebarVerticalDivider,
168
+ style: {
169
+ '--spacing': `var(--spacing-${columnGap})`
170
+ },
171
+ children: resizable ? /*#__PURE__*/jsx(DragHandle, {
172
+ handleRef: handleRef,
173
+ "aria-valuemin": minPaneWidth,
174
+ "aria-valuemax": maxPaneWidth,
175
+ "aria-valuenow": currentWidth,
176
+ onDragStart: clientX => {
177
+ var _sidebarRef$current$g, _sidebarRef$current;
178
+ dragStartClientXRef.current = clientX;
179
+ dragStartWidthRef.current = (_sidebarRef$current$g = (_sidebarRef$current = sidebarRef.current) === null || _sidebarRef$current === void 0 ? void 0 : _sidebarRef$current.getBoundingClientRect().width) !== null && _sidebarRef$current$g !== void 0 ? _sidebarRef$current$g : currentWidthRef.current;
180
+ dragMaxWidthRef.current = getMaxPaneWidth();
181
+ },
182
+ onDrag: (value, isKeyboard) => {
183
+ const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
184
+ if (isKeyboard) {
185
+ // For position='end': invert the delta so arrow keys feel natural
186
+ // ArrowRight should shrink (move divider right), ArrowLeft should expand
187
+ const delta = position === 'end' ? -value : value;
188
+ const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
189
+ if (newWidth !== currentWidthRef.current) {
190
+ var _sidebarRef$current2;
191
+ currentWidthRef.current = newWidth;
192
+ (_sidebarRef$current2 = sidebarRef.current) === null || _sidebarRef$current2 === void 0 ? void 0 : _sidebarRef$current2.style.setProperty('--pane-width', `${newWidth}px`);
193
+ updateAriaValues(handleRef.current, {
194
+ current: newWidth,
195
+ max: maxWidth
196
+ });
197
+ }
198
+ } else {
199
+ if (sidebarRef.current) {
200
+ const deltaX = value - dragStartClientXRef.current;
201
+ // For position='end': cursor moving left (negative delta) increases width
202
+ // For position='start': cursor moving right (positive delta) increases width
203
+ const directedDelta = position === 'end' ? -deltaX : deltaX;
204
+ const newWidth = dragStartWidthRef.current + directedDelta;
205
+ const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
206
+ if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
207
+ sidebarRef.current.style.setProperty('--pane-width', `${clampedWidth}px`);
208
+ currentWidthRef.current = clampedWidth;
209
+ updateAriaValues(handleRef.current, {
210
+ current: Math.round(clampedWidth),
211
+ max: maxWidth
212
+ });
213
+ }
214
+ }
215
+ }
216
+ },
217
+ onDragEnd: () => {
218
+ saveWidth(currentWidthRef.current);
219
+ },
220
+ onDoubleClick: () => {
221
+ const resetWidth = getDefaultWidth();
222
+ if (sidebarRef.current) {
223
+ sidebarRef.current.style.setProperty('--pane-width', `${resetWidth}px`);
224
+ currentWidthRef.current = resetWidth;
225
+ updateAriaValues(handleRef.current, {
226
+ current: resetWidth
227
+ });
228
+ }
229
+ saveWidth(resetWidth);
230
+ }
231
+ }) : null
232
+ });
233
+ });
317
234
  /**
318
235
  * DragHandle - handles all pointer and keyboard interactions for resizing
319
236
  * ARIA values are set in JSX for SSR accessibility,
320
237
  * then updated via DOM manipulation during drag for performance
321
238
  */
322
- const DragHandle = /*#__PURE__*/memo(function DragHandle(t0) {
323
- const $ = c(35);
324
- const {
325
- handleRef,
326
- onDragStart,
327
- onDrag,
328
- onDragEnd,
329
- onDoubleClick,
330
- "aria-valuemin": ariaValueMin,
331
- "aria-valuemax": ariaValueMax,
332
- "aria-valuenow": ariaValueNow
333
- } = t0;
239
+ const DragHandle = /*#__PURE__*/memo(function DragHandle({
240
+ handleRef,
241
+ onDragStart,
242
+ onDrag,
243
+ onDragEnd,
244
+ onDoubleClick,
245
+ 'aria-valuemin': ariaValueMin,
246
+ 'aria-valuemax': ariaValueMax,
247
+ 'aria-valuenow': ariaValueNow
248
+ }) {
334
249
  const stableOnDragStart = React.useRef(onDragStart);
335
250
  const stableOnDrag = React.useRef(onDrag);
336
251
  const stableOnDragEnd = React.useRef(onDragEnd);
337
- let t1;
338
- if ($[0] !== onDrag || $[1] !== onDragEnd || $[2] !== onDragStart) {
339
- t1 = () => {
340
- stableOnDragStart.current = onDragStart;
341
- stableOnDrag.current = onDrag;
342
- stableOnDragEnd.current = onDragEnd;
343
- };
344
- $[0] = onDrag;
345
- $[1] = onDragEnd;
346
- $[2] = onDragStart;
347
- $[3] = t1;
348
- } else {
349
- t1 = $[3];
350
- }
351
- React.useEffect(t1);
252
+ React.useEffect(() => {
253
+ stableOnDragStart.current = onDragStart;
254
+ stableOnDrag.current = onDrag;
255
+ stableOnDragEnd.current = onDragEnd;
256
+ });
352
257
  const {
353
258
  paneRef,
354
259
  contentWrapperRef
355
260
  } = React.useContext(PageLayoutContext);
261
+
262
+ // Dragging state as a ref - cheaper than reading from DOM style
356
263
  const isDraggingRef = React.useRef(false);
357
- let t2;
358
- if ($[4] !== contentWrapperRef || $[5] !== handleRef || $[6] !== paneRef) {
359
- t2 = () => {
360
- if (isDraggingRef.current) {
361
- return;
362
- }
363
- setDraggingStyles({
364
- handle: handleRef.current,
365
- pane: paneRef.current,
366
- contentWrapper: contentWrapperRef.current
367
- });
368
- isDraggingRef.current = true;
369
- };
370
- $[4] = contentWrapperRef;
371
- $[5] = handleRef;
372
- $[6] = paneRef;
373
- $[7] = t2;
374
- } else {
375
- t2 = $[7];
376
- }
377
- const startDragging = t2;
378
- let t3;
379
- if ($[8] !== contentWrapperRef || $[9] !== handleRef || $[10] !== paneRef) {
380
- t3 = () => {
381
- if (!isDraggingRef.current) {
382
- return;
383
- }
384
- removeDraggingStyles({
385
- handle: handleRef.current,
386
- pane: paneRef.current,
387
- contentWrapper: contentWrapperRef.current
388
- });
389
- isDraggingRef.current = false;
390
- };
391
- $[8] = contentWrapperRef;
392
- $[9] = handleRef;
393
- $[10] = paneRef;
394
- $[11] = t3;
395
- } else {
396
- t3 = $[11];
397
- }
398
- const endDragging = t3;
399
- let t4;
400
- if ($[12] !== startDragging) {
401
- t4 = event => {
402
- if (event.button !== 0) {
403
- return;
404
- }
405
- event.preventDefault();
406
- const target = event.currentTarget;
407
- try {
408
- target.setPointerCapture(event.pointerId);
409
- } catch {}
410
- stableOnDragStart.current(event.clientX);
411
- startDragging();
412
- };
413
- $[12] = startDragging;
414
- $[13] = t4;
415
- } else {
416
- t4 = $[13];
417
- }
418
- const handlePointerDown = t4;
264
+
265
+ // Set inline styles for drag optimizations - zero overhead at rest
266
+ const startDragging = React.useCallback(() => {
267
+ if (isDraggingRef.current) return;
268
+ setDraggingStyles({
269
+ handle: handleRef.current,
270
+ pane: paneRef.current,
271
+ contentWrapper: contentWrapperRef.current
272
+ });
273
+ isDraggingRef.current = true;
274
+ }, [handleRef, contentWrapperRef, paneRef]);
275
+ const endDragging = React.useCallback(() => {
276
+ if (!isDraggingRef.current) return;
277
+ removeDraggingStyles({
278
+ handle: handleRef.current,
279
+ pane: paneRef.current,
280
+ contentWrapper: contentWrapperRef.current
281
+ });
282
+ isDraggingRef.current = false;
283
+ }, [handleRef, contentWrapperRef, paneRef]);
284
+
285
+ /**
286
+ * Pointer down starts a drag operation
287
+ * Capture the pointer to continue receiving events outside the handle area
288
+ */
289
+ const handlePointerDown = React.useCallback(event => {
290
+ if (event.button !== 0) return;
291
+ event.preventDefault();
292
+ const target = event.currentTarget;
293
+ // Try to capture pointer - may fail in test environments or if pointer is already released
294
+ try {
295
+ target.setPointerCapture(event.pointerId);
296
+ } catch {
297
+ // Ignore - pointer capture is a nice-to-have for dragging outside the element
298
+ }
299
+ stableOnDragStart.current(event.clientX);
300
+ startDragging();
301
+ }, [startDragging]);
302
+
303
+ // Simple rAF throttle - one update per frame, latest position wins
419
304
  const rafIdRef = React.useRef(null);
420
305
  const pendingClientXRef = React.useRef(null);
421
- let t5;
422
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
423
- t5 = event_0 => {
424
- if (!isDraggingRef.current) {
425
- return;
426
- }
427
- event_0.preventDefault();
428
- pendingClientXRef.current = event_0.clientX;
429
- if (rafIdRef.current === null) {
430
- rafIdRef.current = requestAnimationFrame(() => {
431
- rafIdRef.current = null;
432
- if (pendingClientXRef.current !== null) {
433
- stableOnDrag.current(pendingClientXRef.current, false);
434
- pendingClientXRef.current = null;
435
- }
436
- });
437
- }
438
- };
439
- $[14] = t5;
440
- } else {
441
- t5 = $[14];
442
- }
443
- const handlePointerMove = t5;
444
- let t6;
445
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
446
- t6 = event_1 => {
447
- if (!isDraggingRef.current) {
448
- return;
449
- }
450
- event_1.preventDefault();
451
- };
452
- $[15] = t6;
453
- } else {
454
- t6 = $[15];
455
- }
456
- const handlePointerUp = t6;
457
- let t7;
458
- if ($[16] !== endDragging) {
459
- t7 = () => {
460
- if (!isDraggingRef.current) {
461
- return;
462
- }
463
- if (rafIdRef.current !== null) {
464
- cancelAnimationFrame(rafIdRef.current);
306
+
307
+ /**
308
+ * Pointer move during drag
309
+ * Calls onDrag with absolute cursor X position
310
+ * Uses rAF to coalesce updates to one per frame
311
+ */
312
+ const handlePointerMove = React.useCallback(event => {
313
+ if (!isDraggingRef.current) return;
314
+ event.preventDefault();
315
+
316
+ // Store latest position - only the final position before rAF fires matters
317
+ pendingClientXRef.current = event.clientX;
318
+
319
+ // Schedule update if not already scheduled
320
+ if (rafIdRef.current === null) {
321
+ rafIdRef.current = requestAnimationFrame(() => {
465
322
  rafIdRef.current = null;
466
- pendingClientXRef.current = null;
467
- }
468
- endDragging();
469
- stableOnDragEnd.current();
470
- };
471
- $[16] = endDragging;
472
- $[17] = t7;
473
- } else {
474
- t7 = $[17];
475
- }
476
- const handleLostPointerCapture = t7;
477
- let t8;
478
- if ($[18] !== startDragging) {
479
- t8 = event_2 => {
480
- if (!isArrowKey(event_2.key)) {
481
- return;
482
- }
483
- event_2.preventDefault();
484
- const delta = isShrinkKey(event_2.key) ? -ARROW_KEY_STEP : ARROW_KEY_STEP;
485
- if (!isDraggingRef.current) {
486
- startDragging();
487
- }
488
- stableOnDrag.current(delta, true);
489
- };
490
- $[18] = startDragging;
491
- $[19] = t8;
492
- } else {
493
- t8 = $[19];
494
- }
495
- const handleKeyDown = t8;
496
- let t9;
497
- if ($[20] !== endDragging) {
498
- t9 = event_3 => {
499
- if (!isArrowKey(event_3.key)) {
500
- return;
501
- }
502
- event_3.preventDefault();
503
- endDragging();
504
- stableOnDragEnd.current();
505
- };
506
- $[20] = endDragging;
507
- $[21] = t9;
508
- } else {
509
- t9 = $[21];
510
- }
511
- const handleKeyUp = t9;
512
- let t10;
513
- let t11;
514
- if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
515
- t10 = () => () => {
323
+ if (pendingClientXRef.current !== null) {
324
+ stableOnDrag.current(pendingClientXRef.current, false);
325
+ pendingClientXRef.current = null;
326
+ }
327
+ });
328
+ }
329
+ }, []);
330
+
331
+ /**
332
+ * Pointer up - cleanup is handled by onLostPointerCapture event
333
+ * which fires when pointer capture is released (including on pointerup)
334
+ */
335
+ const handlePointerUp = React.useCallback(event => {
336
+ if (!isDraggingRef.current) return;
337
+ event.preventDefault();
338
+ }, []);
339
+
340
+ /**
341
+ * Lost pointer capture ends a drag operation
342
+ * Cleans up dragging state and cancels any pending rAF
343
+ * Calls onDragEnd callback
344
+ */
345
+ const handleLostPointerCapture = React.useCallback(() => {
346
+ if (!isDraggingRef.current) return;
347
+ // Cancel any pending rAF to prevent stale updates
348
+ if (rafIdRef.current !== null) {
349
+ cancelAnimationFrame(rafIdRef.current);
350
+ rafIdRef.current = null;
351
+ pendingClientXRef.current = null;
352
+ }
353
+ endDragging();
354
+ stableOnDragEnd.current();
355
+ }, [endDragging]);
356
+
357
+ /**
358
+ * Keyboard handling for accessibility
359
+ * Arrow keys adjust the pane size in 3px increments
360
+ * Prevents default scrolling behavior
361
+ * Sets and clears dragging state via data attribute
362
+ * Calls onDrag
363
+ */
364
+ const handleKeyDown = React.useCallback(event => {
365
+ if (!isArrowKey(event.key)) return;
366
+ event.preventDefault();
367
+
368
+ // https://github.com/github/accessibility/issues/5101#issuecomment-1822870655
369
+ const delta = isShrinkKey(event.key) ? -ARROW_KEY_STEP : ARROW_KEY_STEP;
370
+
371
+ // Only set dragging on first keydown (not repeats)
372
+ if (!isDraggingRef.current) {
373
+ startDragging();
374
+ }
375
+ stableOnDrag.current(delta, true);
376
+ }, [startDragging]);
377
+ const handleKeyUp = React.useCallback(event => {
378
+ if (!isArrowKey(event.key)) return;
379
+ event.preventDefault();
380
+ endDragging();
381
+ stableOnDragEnd.current();
382
+ }, [endDragging]);
383
+
384
+ // Cleanup rAF on unmount to prevent stale callbacks
385
+ React.useEffect(() => {
386
+ return () => {
516
387
  if (rafIdRef.current !== null) {
517
388
  cancelAnimationFrame(rafIdRef.current);
518
389
  rafIdRef.current = null;
519
390
  }
520
391
  };
521
- t11 = [];
522
- $[22] = t10;
523
- $[23] = t11;
524
- } else {
525
- t10 = $[22];
526
- t11 = $[23];
527
- }
528
- React.useEffect(t10, t11);
529
- const t12 = ariaValueNow !== undefined ? `Pane width ${ariaValueNow} pixels` : undefined;
530
- let t13;
531
- if ($[24] !== ariaValueMax || $[25] !== ariaValueMin || $[26] !== ariaValueNow || $[27] !== handleKeyDown || $[28] !== handleKeyUp || $[29] !== handleLostPointerCapture || $[30] !== handlePointerDown || $[31] !== handleRef || $[32] !== onDoubleClick || $[33] !== t12) {
532
- t13 = /*#__PURE__*/jsx("div", {
533
- ref: handleRef,
534
- className: classes.DraggableHandle,
535
- role: "slider",
536
- "aria-label": "Draggable pane splitter",
537
- "aria-valuemin": ariaValueMin,
538
- "aria-valuemax": ariaValueMax,
539
- "aria-valuenow": ariaValueNow,
540
- "aria-valuetext": t12,
541
- tabIndex: 0,
542
- onPointerDown: handlePointerDown,
543
- onPointerMove: handlePointerMove,
544
- onPointerUp: handlePointerUp,
545
- onLostPointerCapture: handleLostPointerCapture,
546
- onKeyDown: handleKeyDown,
547
- onKeyUp: handleKeyUp,
548
- onDoubleClick: onDoubleClick
549
- });
550
- $[24] = ariaValueMax;
551
- $[25] = ariaValueMin;
552
- $[26] = ariaValueNow;
553
- $[27] = handleKeyDown;
554
- $[28] = handleKeyUp;
555
- $[29] = handleLostPointerCapture;
556
- $[30] = handlePointerDown;
557
- $[31] = handleRef;
558
- $[32] = onDoubleClick;
559
- $[33] = t12;
560
- $[34] = t13;
561
- } else {
562
- t13 = $[34];
563
- }
564
- return t13;
392
+ }, []);
393
+ return /*#__PURE__*/jsx("div", {
394
+ ref: handleRef,
395
+ className: classes.DraggableHandle,
396
+ role: "slider",
397
+ "aria-label": "Draggable pane splitter",
398
+ "aria-valuemin": ariaValueMin,
399
+ "aria-valuemax": ariaValueMax,
400
+ "aria-valuenow": ariaValueNow,
401
+ "aria-valuetext": ariaValueNow !== undefined ? `Pane width ${ariaValueNow} pixels` : undefined,
402
+ tabIndex: 0,
403
+ onPointerDown: handlePointerDown,
404
+ onPointerMove: handlePointerMove,
405
+ onPointerUp: handlePointerUp,
406
+ onLostPointerCapture: handleLostPointerCapture,
407
+ onKeyDown: handleKeyDown,
408
+ onKeyUp: handleKeyUp,
409
+ onDoubleClick: onDoubleClick
410
+ });
565
411
  });
566
412
 
567
413
  // ----------------------------------------------------------------------------
568
414
  // PageLayout.Header
569
415
 
570
- const Header = t0 => {
571
- const $ = c(28);
572
- const {
573
- "aria-label": label,
574
- "aria-labelledby": labelledBy,
575
- padding: t1,
576
- divider: t2,
577
- dividerWhenNarrow: t3,
578
- hidden: t4,
579
- children,
580
- style,
581
- className
582
- } = t0;
583
- const padding = t1 === undefined ? "none" : t1;
584
- const divider = t2 === undefined ? "none" : t2;
585
- const dividerWhenNarrow = t3 === undefined ? "inherit" : t3;
586
- const hidden = t4 === undefined ? false : t4;
587
- let t5;
588
- if ($[0] !== divider || $[1] !== dividerWhenNarrow) {
589
- t5 = !isResponsiveValue(divider) && dividerWhenNarrow !== "inherit" ? {
590
- regular: divider,
591
- narrow: dividerWhenNarrow
592
- } : divider;
593
- $[0] = divider;
594
- $[1] = dividerWhenNarrow;
595
- $[2] = t5;
596
- } else {
597
- t5 = $[2];
598
- }
599
- const dividerProp = t5;
416
+ const Header = ({
417
+ 'aria-label': label,
418
+ 'aria-labelledby': labelledBy,
419
+ padding = 'none',
420
+ divider = 'none',
421
+ dividerWhenNarrow = 'inherit',
422
+ hidden = false,
423
+ children,
424
+ style,
425
+ className
426
+ }) => {
427
+ // Combine divider and dividerWhenNarrow for backwards compatibility
428
+ const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== 'inherit' ? {
429
+ regular: divider,
430
+ narrow: dividerWhenNarrow
431
+ } : divider;
600
432
  const {
601
433
  rowGap
602
434
  } = React.useContext(PageLayoutContext);
603
- let t6;
604
- if ($[3] !== hidden) {
605
- t6 = getResponsiveAttributes("hidden", hidden);
606
- $[3] = hidden;
607
- $[4] = t6;
608
- } else {
609
- t6 = $[4];
610
- }
611
- let t7;
612
- if ($[5] !== className) {
613
- t7 = clsx(classes.Header, className);
614
- $[5] = className;
615
- $[6] = t7;
616
- } else {
617
- t7 = $[6];
618
- }
619
- const t8 = `var(--spacing-${rowGap})`;
620
- let t9;
621
- if ($[7] !== style || $[8] !== t8) {
622
- t9 = {
623
- "--spacing": t8,
435
+ return /*#__PURE__*/jsxs("header", {
436
+ "aria-label": label,
437
+ "aria-labelledby": labelledBy,
438
+ ...getResponsiveAttributes('hidden', hidden),
439
+ className: clsx(classes.Header, className),
440
+ style: {
441
+ '--spacing': `var(--spacing-${rowGap})`,
624
442
  ...style
625
- };
626
- $[7] = style;
627
- $[8] = t8;
628
- $[9] = t9;
629
- } else {
630
- t9 = $[9];
631
- }
632
- const t10 = t9;
633
- const t11 = `var(--spacing-${padding})`;
634
- let t12;
635
- if ($[10] !== t11) {
636
- t12 = {
637
- "--spacing": t11
638
- };
639
- $[10] = t11;
640
- $[11] = t12;
641
- } else {
642
- t12 = $[11];
643
- }
644
- const t13 = t12;
645
- let t14;
646
- if ($[12] !== children || $[13] !== t13) {
647
- t14 = /*#__PURE__*/jsx("div", {
443
+ },
444
+ children: [/*#__PURE__*/jsx("div", {
648
445
  className: classes.HeaderContent,
649
- style: t13,
446
+ style: {
447
+ '--spacing': `var(--spacing-${padding})`
448
+ },
650
449
  children: children
651
- });
652
- $[12] = children;
653
- $[13] = t13;
654
- $[14] = t14;
655
- } else {
656
- t14 = $[14];
657
- }
658
- const t15 = `var(--spacing-${rowGap})`;
659
- let t16;
660
- if ($[15] !== t15) {
661
- t16 = {
662
- "--spacing": t15
663
- };
664
- $[15] = t15;
665
- $[16] = t16;
666
- } else {
667
- t16 = $[16];
668
- }
669
- const t17 = t16;
670
- let t18;
671
- if ($[17] !== dividerProp || $[18] !== t17) {
672
- t18 = /*#__PURE__*/jsx(HorizontalDivider, {
450
+ }), /*#__PURE__*/jsx(HorizontalDivider, {
673
451
  variant: dividerProp,
674
452
  className: classes.HeaderHorizontalDivider,
675
- style: t17
676
- });
677
- $[17] = dividerProp;
678
- $[18] = t17;
679
- $[19] = t18;
680
- } else {
681
- t18 = $[19];
682
- }
683
- let t19;
684
- if ($[20] !== label || $[21] !== labelledBy || $[22] !== t10 || $[23] !== t14 || $[24] !== t18 || $[25] !== t6 || $[26] !== t7) {
685
- t19 = /*#__PURE__*/jsxs("header", {
686
- "aria-label": label,
687
- "aria-labelledby": labelledBy,
688
- ...t6,
689
- className: t7,
690
- style: t10,
691
- children: [t14, t18]
692
- });
693
- $[20] = label;
694
- $[21] = labelledBy;
695
- $[22] = t10;
696
- $[23] = t14;
697
- $[24] = t18;
698
- $[25] = t6;
699
- $[26] = t7;
700
- $[27] = t19;
701
- } else {
702
- t19 = $[27];
703
- }
704
- return t19;
453
+ style: {
454
+ '--spacing': `var(--spacing-${rowGap})`
455
+ }
456
+ })]
457
+ });
705
458
  };
459
+ Header.displayName = "Header";
706
460
  Header.displayName = 'PageLayout.Header';
707
- const Content = t0 => {
708
- const $ = c(19);
709
- const {
710
- as: t1,
711
- "aria-label": label,
712
- "aria-labelledby": labelledBy,
713
- width: t2,
714
- padding: t3,
715
- hidden: t4,
716
- children,
717
- className,
718
- style
719
- } = t0;
720
- const as = t1 === undefined ? "main" : t1;
721
- const width = t2 === undefined ? "full" : t2;
722
- const padding = t3 === undefined ? "none" : t3;
723
- const hidden = t4 === undefined ? false : t4;
461
+ const Content = ({
462
+ as = 'main',
463
+ 'aria-label': label,
464
+ 'aria-labelledby': labelledBy,
465
+ width = 'full',
466
+ padding = 'none',
467
+ hidden = false,
468
+ children,
469
+ className,
470
+ style
471
+ }) => {
724
472
  const Component = as;
725
473
  const {
726
474
  contentWrapperRef
727
475
  } = React.useContext(PageLayoutContext);
728
- let t5;
729
- if ($[0] !== className) {
730
- t5 = clsx(classes.ContentWrapper, className);
731
- $[0] = className;
732
- $[1] = t5;
733
- } else {
734
- t5 = $[1];
735
- }
736
- let t6;
737
- if ($[2] !== hidden) {
738
- t6 = getResponsiveAttributes("is-hidden", hidden);
739
- $[2] = hidden;
740
- $[3] = t6;
741
- } else {
742
- t6 = $[3];
743
- }
744
- const t7 = `var(--spacing-${padding})`;
745
- let t8;
746
- if ($[4] !== t7) {
747
- t8 = {
748
- "--spacing": t7
749
- };
750
- $[4] = t7;
751
- $[5] = t8;
752
- } else {
753
- t8 = $[5];
754
- }
755
- const t9 = t8;
756
- let t10;
757
- if ($[6] !== children || $[7] !== t9 || $[8] !== width) {
758
- t10 = /*#__PURE__*/jsx("div", {
476
+ return /*#__PURE__*/jsx(Component, {
477
+ ref: contentWrapperRef,
478
+ "aria-label": label,
479
+ "aria-labelledby": labelledBy,
480
+ style: style,
481
+ className: clsx(classes.ContentWrapper, className),
482
+ ...getResponsiveAttributes('is-hidden', hidden),
483
+ children: /*#__PURE__*/jsx("div", {
759
484
  className: classes.Content,
760
485
  "data-width": width,
761
- style: t9,
486
+ style: {
487
+ '--spacing': `var(--spacing-${padding})`
488
+ },
762
489
  children: children
763
- });
764
- $[6] = children;
765
- $[7] = t9;
766
- $[8] = width;
767
- $[9] = t10;
768
- } else {
769
- t10 = $[9];
770
- }
771
- let t11;
772
- if ($[10] !== Component || $[11] !== contentWrapperRef || $[12] !== label || $[13] !== labelledBy || $[14] !== style || $[15] !== t10 || $[16] !== t5 || $[17] !== t6) {
773
- t11 = /*#__PURE__*/jsx(Component, {
774
- ref: contentWrapperRef,
775
- "aria-label": label,
776
- "aria-labelledby": labelledBy,
777
- style: style,
778
- className: t5,
779
- ...t6,
780
- children: t10
781
- });
782
- $[10] = Component;
783
- $[11] = contentWrapperRef;
784
- $[12] = label;
785
- $[13] = labelledBy;
786
- $[14] = style;
787
- $[15] = t10;
788
- $[16] = t5;
789
- $[17] = t6;
790
- $[18] = t11;
791
- } else {
792
- t11 = $[18];
793
- }
794
- return t11;
490
+ })
491
+ });
795
492
  };
493
+ Content.displayName = "Content";
796
494
  Content.displayName = 'PageLayout.Content';
797
495
  const overflowProps = {
798
496
  tabIndex: 0,
799
497
  role: 'region'
800
498
  };
801
- const Pane = /*#__PURE__*/React.forwardRef((t0, forwardRef) => {
802
- const $ = c(96);
803
- const {
804
- "aria-label": label,
805
- "aria-labelledby": labelledBy,
806
- position: t1,
807
- positionWhenNarrow: t2,
808
- width: t3,
809
- minWidth: t4,
810
- currentWidth: controlledWidth,
811
- onResizeEnd,
812
- padding: t5,
813
- resizable: t6,
814
- widthStorageKey: t7,
815
- divider: t8,
816
- dividerWhenNarrow: t9,
817
- sticky: t10,
818
- offsetHeader: t11,
819
- hidden: t12,
820
- children,
821
- id,
822
- className,
823
- style
824
- } = t0;
825
- const responsivePosition = t1 === undefined ? "end" : t1;
826
- const positionWhenNarrow = t2 === undefined ? "inherit" : t2;
827
- const width = t3 === undefined ? "medium" : t3;
828
- const minWidth = t4 === undefined ? 256 : t4;
829
- const padding = t5 === undefined ? "none" : t5;
830
- const resizable = t6 === undefined ? false : t6;
831
- const widthStorageKey = t7 === undefined ? "paneWidth" : t7;
832
- const responsiveDivider = t8 === undefined ? "none" : t8;
833
- const dividerWhenNarrow = t9 === undefined ? "inherit" : t9;
834
- const sticky = t10 === undefined ? false : t10;
835
- const offsetHeader = t11 === undefined ? 0 : t11;
836
- const responsiveHidden = t12 === undefined ? false : t12;
837
- let t13;
838
- if ($[0] !== positionWhenNarrow || $[1] !== responsivePosition) {
839
- t13 = !isResponsiveValue(responsivePosition) && positionWhenNarrow !== "inherit" ? {
840
- regular: responsivePosition,
841
- narrow: positionWhenNarrow
842
- } : responsivePosition;
843
- $[0] = positionWhenNarrow;
844
- $[1] = responsivePosition;
845
- $[2] = t13;
846
- } else {
847
- t13 = $[2];
848
- }
849
- const positionProp = t13;
850
- let t14;
851
- if ($[3] !== dividerWhenNarrow || $[4] !== responsiveDivider) {
852
- t14 = !isResponsiveValue(responsiveDivider) && dividerWhenNarrow !== "inherit" ? {
853
- regular: responsiveDivider,
854
- narrow: dividerWhenNarrow
855
- } : responsiveDivider;
856
- $[3] = dividerWhenNarrow;
857
- $[4] = responsiveDivider;
858
- $[5] = t14;
859
- } else {
860
- t14 = $[5];
861
- }
862
- const dividerProp = t14;
863
- let t15;
864
- if ($[6] !== positionProp) {
865
- t15 = isResponsiveValue(positionProp) ? "end" : positionProp;
866
- $[6] = positionProp;
867
- $[7] = t15;
868
- } else {
869
- t15 = $[7];
870
- }
871
- const position = t15;
872
- let t16;
873
- if ($[8] !== dividerProp) {
874
- t16 = isResponsiveValue(dividerProp) ? "none" : dividerProp;
875
- $[8] = dividerProp;
876
- $[9] = t16;
877
- } else {
878
- t16 = $[9];
879
- }
880
- const dividerVariant = t16;
499
+ const Pane = /*#__PURE__*/React.forwardRef(({
500
+ 'aria-label': label,
501
+ 'aria-labelledby': labelledBy,
502
+ position: responsivePosition = 'end',
503
+ positionWhenNarrow = 'inherit',
504
+ width = 'medium',
505
+ minWidth = 256,
506
+ currentWidth: controlledWidth,
507
+ onResizeEnd,
508
+ padding = 'none',
509
+ resizable = false,
510
+ widthStorageKey = 'paneWidth',
511
+ divider: responsiveDivider = 'none',
512
+ dividerWhenNarrow = 'inherit',
513
+ sticky = false,
514
+ offsetHeader = 0,
515
+ hidden: responsiveHidden = false,
516
+ children,
517
+ id,
518
+ className,
519
+ style
520
+ }, forwardRef) => {
521
+ // Combine position and positionWhenNarrow for backwards compatibility
522
+ const positionProp = !isResponsiveValue(responsivePosition) && positionWhenNarrow !== 'inherit' ? {
523
+ regular: responsivePosition,
524
+ narrow: positionWhenNarrow
525
+ } : responsivePosition;
526
+
527
+ // Combine divider and dividerWhenNarrow for backwards compatibility
528
+ const dividerProp = !isResponsiveValue(responsiveDivider) && dividerWhenNarrow !== 'inherit' ? {
529
+ regular: responsiveDivider,
530
+ narrow: dividerWhenNarrow
531
+ } : responsiveDivider;
532
+
533
+ // For components that need responsive values in JavaScript logic, we'll use a fallback value
534
+ // The actual responsive behavior will be handled by CSS through data attributes
535
+ const position = isResponsiveValue(positionProp) ? 'end' : positionProp;
536
+ const dividerVariant = isResponsiveValue(dividerProp) ? 'none' : dividerProp;
881
537
  const {
882
538
  rowGap,
883
539
  columnGap,
884
540
  paneRef,
885
541
  contentWrapperRef
886
542
  } = React.useContext(PageLayoutContext);
543
+
544
+ // Ref to the drag handle for updating ARIA attributes
887
545
  const handleRef = React.useRef(null);
546
+
547
+ // Cache drag start values to calculate relative delta during drag
548
+ // This approach is immune to layout shifts (scrollbars appearing/disappearing)
888
549
  const dragStartClientXRef = React.useRef(0);
889
550
  const dragStartWidthRef = React.useRef(0);
551
+ // Cache max width at drag start - won't change during a drag operation
890
552
  const dragMaxWidthRef = React.useRef(0);
891
- let t17;
892
- if ($[10] !== contentWrapperRef || $[11] !== controlledWidth || $[12] !== minWidth || $[13] !== onResizeEnd || $[14] !== paneRef || $[15] !== resizable || $[16] !== width || $[17] !== widthStorageKey) {
893
- t17 = {
894
- width,
895
- minWidth,
896
- resizable,
897
- widthStorageKey,
898
- paneRef,
899
- handleRef,
900
- contentWrapperRef,
901
- onResizeEnd,
902
- currentWidth: controlledWidth
903
- };
904
- $[10] = contentWrapperRef;
905
- $[11] = controlledWidth;
906
- $[12] = minWidth;
907
- $[13] = onResizeEnd;
908
- $[14] = paneRef;
909
- $[15] = resizable;
910
- $[16] = width;
911
- $[17] = widthStorageKey;
912
- $[18] = t17;
913
- } else {
914
- t17 = $[18];
915
- }
916
553
  const {
917
554
  currentWidth,
918
555
  currentWidthRef,
@@ -921,473 +558,349 @@ const Pane = /*#__PURE__*/React.forwardRef((t0, forwardRef) => {
921
558
  getMaxPaneWidth,
922
559
  saveWidth,
923
560
  getDefaultWidth
924
- } = usePaneWidth(t17);
561
+ } = usePaneWidth({
562
+ width,
563
+ minWidth,
564
+ resizable,
565
+ widthStorageKey,
566
+ paneRef,
567
+ handleRef,
568
+ contentWrapperRef,
569
+ onResizeEnd,
570
+ currentWidth: controlledWidth
571
+ });
925
572
  useRefObjectAsForwardedRef(forwardRef, paneRef);
926
573
  const hasOverflow = useOverflow(paneRef);
927
574
  const paneId = useId(id);
928
- let labelProp;
929
- if ($[19] !== hasOverflow || $[20] !== label || $[21] !== labelledBy) {
930
- labelProp = {};
931
- if (hasOverflow) {
932
- process.env.NODE_ENV !== "production" ? warning(label === undefined && labelledBy === undefined, "The <PageLayout.Pane> has overflow and `aria-label` or `aria-labelledby` has not been set. Please provide `aria-label` or `aria-labelledby` to <PageLayout.Pane> in order to label this region.") : void 0;
933
- if (labelledBy) {
934
- labelProp["aria-labelledby"] = labelledBy;
935
- } else {
936
- if (label) {
937
- labelProp["aria-label"] = label;
938
- }
939
- }
575
+ const labelProp = {};
576
+ if (hasOverflow) {
577
+ process.env.NODE_ENV !== "production" ? warning(label === undefined && labelledBy === undefined, 'The <PageLayout.Pane> has overflow and `aria-label` or `aria-labelledby` has not been set. ' + 'Please provide `aria-label` or `aria-labelledby` to <PageLayout.Pane> in order to label this ' + 'region.') : void 0;
578
+ if (labelledBy) {
579
+ labelProp['aria-labelledby'] = labelledBy;
580
+ } else if (label) {
581
+ labelProp['aria-label'] = label;
940
582
  }
941
- $[19] = hasOverflow;
942
- $[20] = label;
943
- $[21] = labelledBy;
944
- $[22] = labelProp;
945
- } else {
946
- labelProp = $[22];
947
- }
948
- let t18;
949
- if ($[23] !== className) {
950
- t18 = clsx(classes.PaneWrapper, className);
951
- $[23] = className;
952
- $[24] = t18;
953
- } else {
954
- t18 = $[24];
955
583
  }
956
- const t19 = typeof offsetHeader === "number" ? `${offsetHeader}px` : offsetHeader;
957
- const t20 = `var(--spacing-${rowGap})`;
958
- const t21 = `var(--spacing-${columnGap})`;
959
- let t22;
960
- if ($[25] !== style || $[26] !== t19 || $[27] !== t20 || $[28] !== t21) {
961
- t22 = {
962
- "--offset-header": t19,
963
- "--spacing-row": t20,
964
- "--spacing-column": t21,
584
+ return /*#__PURE__*/jsxs("div", {
585
+ className: clsx(classes.PaneWrapper, className),
586
+ style: {
587
+ '--offset-header': typeof offsetHeader === 'number' ? `${offsetHeader}px` : offsetHeader,
588
+ '--spacing-row': `var(--spacing-${rowGap})`,
589
+ '--spacing-column': `var(--spacing-${columnGap})`,
965
590
  ...style
966
- };
967
- $[25] = style;
968
- $[26] = t19;
969
- $[27] = t20;
970
- $[28] = t21;
971
- $[29] = t22;
972
- } else {
973
- t22 = $[29];
974
- }
975
- const t23 = t22;
976
- let t24;
977
- if ($[30] !== responsiveHidden) {
978
- t24 = getResponsiveAttributes("is-hidden", responsiveHidden);
979
- $[30] = responsiveHidden;
980
- $[31] = t24;
981
- } else {
982
- t24 = $[31];
983
- }
984
- let t25;
985
- if ($[32] !== positionProp) {
986
- t25 = getResponsiveAttributes("position", positionProp);
987
- $[32] = positionProp;
988
- $[33] = t25;
989
- } else {
990
- t25 = $[33];
991
- }
992
- const t26 = sticky || undefined;
993
- let t27;
994
- if ($[34] !== dividerProp || $[35] !== dividerVariant) {
995
- t27 = isResponsiveValue(dividerProp) ? dividerProp : {
996
- narrow: dividerVariant,
997
- regular: "none"
998
- };
999
- $[34] = dividerProp;
1000
- $[35] = dividerVariant;
1001
- $[36] = t27;
1002
- } else {
1003
- t27 = $[36];
1004
- }
1005
- const t28 = `var(--spacing-${rowGap})`;
1006
- let t29;
1007
- if ($[37] !== t28) {
1008
- t29 = {
1009
- "--spacing": t28
1010
- };
1011
- $[37] = t28;
1012
- $[38] = t29;
1013
- } else {
1014
- t29 = $[38];
1015
- }
1016
- const t30 = t29;
1017
- let t31;
1018
- if ($[39] !== positionProp || $[40] !== t27 || $[41] !== t30) {
1019
- t31 = /*#__PURE__*/jsx(HorizontalDivider, {
1020
- variant: t27,
591
+ },
592
+ ...getResponsiveAttributes('is-hidden', responsiveHidden),
593
+ ...getResponsiveAttributes('position', positionProp),
594
+ "data-sticky": sticky || undefined,
595
+ children: [/*#__PURE__*/jsx(HorizontalDivider, {
596
+ variant: isResponsiveValue(dividerProp) ? dividerProp : {
597
+ narrow: dividerVariant,
598
+ regular: 'none'
599
+ },
1021
600
  className: classes.PaneHorizontalDivider,
1022
- style: t30,
601
+ style: {
602
+ '--spacing': `var(--spacing-${rowGap})`
603
+ },
1023
604
  position: positionProp
1024
- });
1025
- $[39] = positionProp;
1026
- $[40] = t27;
1027
- $[41] = t30;
1028
- $[42] = t31;
1029
- } else {
1030
- t31 = $[42];
1031
- }
1032
- const t32 = resizable === true && !onResizeEnd;
1033
- let t33;
1034
- if ($[43] !== hasOverflow) {
1035
- t33 = hasOverflow ? overflowProps : {};
1036
- $[43] = hasOverflow;
1037
- $[44] = t33;
1038
- } else {
1039
- t33 = $[44];
1040
- }
1041
- let t34;
1042
- if ($[45] !== id || $[46] !== paneId) {
1043
- t34 = id && {
1044
- id: paneId
1045
- };
1046
- $[45] = id;
1047
- $[46] = paneId;
1048
- $[47] = t34;
1049
- } else {
1050
- t34 = $[47];
1051
- }
1052
- const t35 = resizable || undefined;
1053
- const t36 = `var(--spacing-${padding})`;
1054
- const t37 = isCustomWidthOptions(width) ? width.min : `${minWidth}px`;
1055
- const t38 = isCustomWidthOptions(width) ? width.max : "calc(100vw - var(--pane-max-width-diff))";
1056
- const t39 = isCustomWidthOptions(width) ? width.default : undefined;
1057
- const t40 = `var(--pane-width-${isPaneWidth(width) ? width : "custom"})`;
1058
- const t41 = `${currentWidth}px`;
1059
- let t42;
1060
- if ($[48] !== t36 || $[49] !== t37 || $[50] !== t38 || $[51] !== t39 || $[52] !== t40 || $[53] !== t41) {
1061
- t42 = {
1062
- "--spacing": t36,
1063
- "--pane-min-width": t37,
1064
- "--pane-max-width": t38,
1065
- "--pane-width-custom": t39,
1066
- "--pane-width-size": t40,
1067
- "--pane-width": t41
1068
- };
1069
- $[48] = t36;
1070
- $[49] = t37;
1071
- $[50] = t38;
1072
- $[51] = t39;
1073
- $[52] = t40;
1074
- $[53] = t41;
1075
- $[54] = t42;
1076
- } else {
1077
- t42 = $[54];
1078
- }
1079
- const t43 = t42;
1080
- let t44;
1081
- if ($[55] !== children || $[56] !== labelProp || $[57] !== paneRef || $[58] !== t32 || $[59] !== t33 || $[60] !== t34 || $[61] !== t35 || $[62] !== t43) {
1082
- t44 = /*#__PURE__*/jsx("div", {
1083
- ref: paneRef,
1084
- suppressHydrationWarning: t32,
1085
- ...t33,
605
+ }), /*#__PURE__*/jsx("div", {
606
+ ref: paneRef
607
+ // Suppress hydration mismatch for --pane-width when localStorage
608
+ // provides a width that differs from the server-rendered default.
609
+ // Not needed when onResizeEnd is provided (localStorage isn't read).
610
+ ,
611
+ suppressHydrationWarning: resizable === true && !onResizeEnd,
612
+ ...(hasOverflow ? overflowProps : {}),
1086
613
  ...labelProp,
1087
- ...t34,
614
+ ...(id && {
615
+ id: paneId
616
+ }),
1088
617
  className: classes.Pane,
1089
- "data-resizable": t35,
1090
- style: t43,
618
+ "data-resizable": resizable || undefined,
619
+ style: {
620
+ '--spacing': `var(--spacing-${padding})`,
621
+ '--pane-min-width': isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
622
+ '--pane-max-width': isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--pane-max-width-diff))`,
623
+ '--pane-width-custom': isCustomWidthOptions(width) ? width.default : undefined,
624
+ '--pane-width-size': `var(--pane-width-${isPaneWidth(width) ? width : 'custom'})`,
625
+ '--pane-width': `${currentWidth}px`
626
+ },
1091
627
  children: children
1092
- });
1093
- $[55] = children;
1094
- $[56] = labelProp;
1095
- $[57] = paneRef;
1096
- $[58] = t32;
1097
- $[59] = t33;
1098
- $[60] = t34;
1099
- $[61] = t35;
1100
- $[62] = t43;
1101
- $[63] = t44;
1102
- } else {
1103
- t44 = $[63];
1104
- }
1105
- let t45;
1106
- if ($[64] !== dividerProp || $[65] !== dividerVariant || $[66] !== resizable) {
1107
- t45 = isResponsiveValue(dividerProp) ? {
1108
- narrow: "none",
1109
- regular: resizable ? "line" : dividerProp.regular || "none",
1110
- wide: resizable ? "line" : dividerProp.wide || dividerProp.regular || "none"
1111
- } : {
1112
- narrow: "none",
1113
- regular: resizable ? "line" : dividerVariant
1114
- };
1115
- $[64] = dividerProp;
1116
- $[65] = dividerVariant;
1117
- $[66] = resizable;
1118
- $[67] = t45;
1119
- } else {
1120
- t45 = $[67];
1121
- }
1122
- const t46 = `var(--spacing-${columnGap})`;
1123
- let t47;
1124
- if ($[68] !== t46) {
1125
- t47 = {
1126
- "--spacing": t46
1127
- };
1128
- $[68] = t46;
1129
- $[69] = t47;
1130
- } else {
1131
- t47 = $[69];
1132
- }
1133
- const t48 = t47;
1134
- let t49;
1135
- if ($[70] !== currentWidth || $[71] !== currentWidthRef || $[72] !== getDefaultWidth || $[73] !== getMaxPaneWidth || $[74] !== maxPaneWidth || $[75] !== minPaneWidth || $[76] !== paneRef || $[77] !== position || $[78] !== resizable || $[79] !== saveWidth) {
1136
- t49 = resizable ? /*#__PURE__*/jsx(DragHandle, {
1137
- handleRef: handleRef,
1138
- "aria-valuemin": minPaneWidth,
1139
- "aria-valuemax": maxPaneWidth,
1140
- "aria-valuenow": currentWidth,
1141
- onDragStart: clientX => {
1142
- var _paneRef$current$getB, _paneRef$current;
1143
- dragStartClientXRef.current = clientX;
1144
- dragStartWidthRef.current = (_paneRef$current$getB = (_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.getBoundingClientRect().width) !== null && _paneRef$current$getB !== void 0 ? _paneRef$current$getB : currentWidthRef.current;
1145
- dragMaxWidthRef.current = getMaxPaneWidth();
628
+ }), /*#__PURE__*/jsx(VerticalDivider, {
629
+ variant: isResponsiveValue(dividerProp) ? {
630
+ narrow: 'none',
631
+ regular: resizable ? 'line' : dividerProp.regular || 'none',
632
+ wide: resizable ? 'line' : dividerProp.wide || dividerProp.regular || 'none'
633
+ } : {
634
+ narrow: 'none',
635
+ // If pane is resizable, always show a vertical divider on regular viewports
636
+ regular: resizable ? 'line' : dividerVariant
637
+ }
638
+ // If pane is resizable, the divider should be draggable
639
+ ,
640
+ draggable: resizable,
641
+ position: positionProp,
642
+ className: classes.PaneVerticalDivider,
643
+ style: {
644
+ '--spacing': `var(--spacing-${columnGap})`
1146
645
  },
1147
- onDrag: (value, isKeyboard) => {
1148
- const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
1149
- if (isKeyboard) {
1150
- const delta = value;
1151
- const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
1152
- if (newWidth !== currentWidthRef.current) {
1153
- var _paneRef$current2;
1154
- currentWidthRef.current = newWidth;
1155
- (_paneRef$current2 = paneRef.current) === null || _paneRef$current2 === void 0 ? void 0 : _paneRef$current2.style.setProperty("--pane-width", `${newWidth}px`);
1156
- updateAriaValues(handleRef.current, {
1157
- current: newWidth,
1158
- max: maxWidth
1159
- });
1160
- }
1161
- } else {
1162
- if (paneRef.current) {
1163
- const deltaX = value - dragStartClientXRef.current;
1164
- const directedDelta = position === "end" ? -deltaX : deltaX;
1165
- const newWidth_0 = dragStartWidthRef.current + directedDelta;
1166
- const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth_0));
1167
- if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
1168
- paneRef.current.style.setProperty("--pane-width", `${clampedWidth}px`);
1169
- currentWidthRef.current = clampedWidth;
646
+ children: resizable ? /*#__PURE__*/jsx(DragHandle, {
647
+ handleRef: handleRef,
648
+ "aria-valuemin": minPaneWidth,
649
+ "aria-valuemax": maxPaneWidth,
650
+ "aria-valuenow": currentWidth,
651
+ onDragStart: clientX => {
652
+ var _paneRef$current$getB, _paneRef$current;
653
+ // Cache cursor position and pane width at drag start
654
+ // Using relative delta (current - start) is immune to layout shifts
655
+ // (e.g., scrollbars appearing/disappearing during drag)
656
+ dragStartClientXRef.current = clientX;
657
+ dragStartWidthRef.current = (_paneRef$current$getB = (_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.getBoundingClientRect().width) !== null && _paneRef$current$getB !== void 0 ? _paneRef$current$getB : currentWidthRef.current;
658
+ // Cache max width - won't change during drag
659
+ dragMaxWidthRef.current = getMaxPaneWidth();
660
+ },
661
+ onDrag: (value, isKeyboard) => {
662
+ // Use cached max width for pointer drag, fresh value for keyboard (less frequent)
663
+ const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
664
+ if (isKeyboard) {
665
+ // Keyboard: value is a delta (e.g., +3 or -3)
666
+ const delta = value;
667
+ const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
668
+ if (newWidth !== currentWidthRef.current) {
669
+ var _paneRef$current2;
670
+ currentWidthRef.current = newWidth;
671
+ (_paneRef$current2 = paneRef.current) === null || _paneRef$current2 === void 0 ? void 0 : _paneRef$current2.style.setProperty('--pane-width', `${newWidth}px`);
1170
672
  updateAriaValues(handleRef.current, {
1171
- current: Math.round(clampedWidth),
673
+ current: newWidth,
1172
674
  max: maxWidth
1173
675
  });
1174
676
  }
677
+ } else {
678
+ // Pointer: value is clientX - calculate width using relative delta from drag start
679
+ // This approach is immune to layout shifts during drag
680
+ if (paneRef.current) {
681
+ const deltaX = value - dragStartClientXRef.current;
682
+ // For position='end': cursor moving left (negative delta) increases width
683
+ // For position='start': cursor moving right (positive delta) increases width
684
+ const directedDelta = position === 'end' ? -deltaX : deltaX;
685
+ const newWidth = dragStartWidthRef.current + directedDelta;
686
+ const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
687
+
688
+ // Only update if width actually changed
689
+ if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
690
+ paneRef.current.style.setProperty('--pane-width', `${clampedWidth}px`);
691
+ currentWidthRef.current = clampedWidth;
692
+ updateAriaValues(handleRef.current, {
693
+ current: Math.round(clampedWidth),
694
+ max: maxWidth
695
+ });
696
+ }
697
+ }
1175
698
  }
699
+ },
700
+ onDragEnd: () => {
701
+ // Sync React state so parent re-renders use the correct width
702
+ saveWidth(currentWidthRef.current);
703
+ },
704
+ onDoubleClick: () => {
705
+ const resetWidth = getDefaultWidth();
706
+ if (paneRef.current) {
707
+ paneRef.current.style.setProperty('--pane-width', `${resetWidth}px`);
708
+ currentWidthRef.current = resetWidth;
709
+ updateAriaValues(handleRef.current, {
710
+ current: resetWidth
711
+ });
712
+ }
713
+ saveWidth(resetWidth);
1176
714
  }
1177
- },
1178
- onDragEnd: () => {
1179
- saveWidth(currentWidthRef.current);
1180
- },
1181
- onDoubleClick: () => {
1182
- const resetWidth = getDefaultWidth();
1183
- if (paneRef.current) {
1184
- paneRef.current.style.setProperty("--pane-width", `${resetWidth}px`);
1185
- currentWidthRef.current = resetWidth;
1186
- updateAriaValues(handleRef.current, {
1187
- current: resetWidth
1188
- });
1189
- }
1190
- saveWidth(resetWidth);
1191
- }
1192
- }) : null;
1193
- $[70] = currentWidth;
1194
- $[71] = currentWidthRef;
1195
- $[72] = getDefaultWidth;
1196
- $[73] = getMaxPaneWidth;
1197
- $[74] = maxPaneWidth;
1198
- $[75] = minPaneWidth;
1199
- $[76] = paneRef;
1200
- $[77] = position;
1201
- $[78] = resizable;
1202
- $[79] = saveWidth;
1203
- $[80] = t49;
1204
- } else {
1205
- t49 = $[80];
1206
- }
1207
- let t50;
1208
- if ($[81] !== positionProp || $[82] !== resizable || $[83] !== t45 || $[84] !== t48 || $[85] !== t49) {
1209
- t50 = /*#__PURE__*/jsx(VerticalDivider, {
1210
- variant: t45,
1211
- draggable: resizable,
1212
- position: positionProp,
1213
- className: classes.PaneVerticalDivider,
1214
- style: t48,
1215
- children: t49
1216
- });
1217
- $[81] = positionProp;
1218
- $[82] = resizable;
1219
- $[83] = t45;
1220
- $[84] = t48;
1221
- $[85] = t49;
1222
- $[86] = t50;
1223
- } else {
1224
- t50 = $[86];
1225
- }
1226
- let t51;
1227
- if ($[87] !== t18 || $[88] !== t23 || $[89] !== t24 || $[90] !== t25 || $[91] !== t26 || $[92] !== t31 || $[93] !== t44 || $[94] !== t50) {
1228
- t51 = /*#__PURE__*/jsxs("div", {
1229
- className: t18,
1230
- style: t23,
1231
- ...t24,
1232
- ...t25,
1233
- "data-sticky": t26,
1234
- children: [t31, t44, t50]
1235
- });
1236
- $[87] = t18;
1237
- $[88] = t23;
1238
- $[89] = t24;
1239
- $[90] = t25;
1240
- $[91] = t26;
1241
- $[92] = t31;
1242
- $[93] = t44;
1243
- $[94] = t50;
1244
- $[95] = t51;
1245
- } else {
1246
- t51 = $[95];
1247
- }
1248
- return t51;
715
+ }) : null
716
+ })]
717
+ });
1249
718
  });
1250
719
  Pane.displayName = 'PageLayout.Pane';
1251
720
 
1252
721
  // ----------------------------------------------------------------------------
1253
722
  // PageLayout.Footer
1254
723
 
1255
- const Footer = t0 => {
1256
- const $ = c(28);
724
+ // ----------------------------------------------------------------------------
725
+ // PageLayout.Sidebar
726
+
727
+ const Sidebar = /*#__PURE__*/React.forwardRef(({
728
+ 'aria-label': label,
729
+ 'aria-labelledby': labelledBy,
730
+ position = 'start',
731
+ width = 'medium',
732
+ minWidth = 256,
733
+ padding = 'none',
734
+ resizable = false,
735
+ widthStorageKey,
736
+ divider = 'none',
737
+ sticky = false,
738
+ responsiveVariant = 'default',
739
+ hidden: responsiveHidden = false,
740
+ children,
741
+ id,
742
+ className,
743
+ style
744
+ }, forwardRef) => {
1257
745
  const {
1258
- "aria-label": label,
1259
- "aria-labelledby": labelledBy,
1260
- padding: t1,
1261
- divider: t2,
1262
- dividerWhenNarrow: t3,
1263
- hidden: t4,
1264
- children,
1265
- className,
1266
- style
1267
- } = t0;
1268
- const padding = t1 === undefined ? "none" : t1;
1269
- const divider = t2 === undefined ? "none" : t2;
1270
- const dividerWhenNarrow = t3 === undefined ? "inherit" : t3;
1271
- const hidden = t4 === undefined ? false : t4;
1272
- let t5;
1273
- if ($[0] !== divider || $[1] !== dividerWhenNarrow) {
1274
- t5 = !isResponsiveValue(divider) && dividerWhenNarrow !== "inherit" ? {
1275
- regular: divider,
1276
- narrow: dividerWhenNarrow
1277
- } : divider;
1278
- $[0] = divider;
1279
- $[1] = dividerWhenNarrow;
1280
- $[2] = t5;
1281
- } else {
1282
- t5 = $[2];
746
+ columnGap,
747
+ sidebarRef,
748
+ sidebarContentWrapperRef
749
+ } = React.useContext(PageLayoutContext);
750
+
751
+ // Ref to the drag handle for updating ARIA attributes
752
+ const handleRef = React.useRef(null);
753
+
754
+ // Cache drag start values to calculate relative delta during drag
755
+ const dragStartClientXRef = React.useRef(0);
756
+ const dragStartWidthRef = React.useRef(0);
757
+ const dragMaxWidthRef = React.useRef(0);
758
+ const {
759
+ currentWidth,
760
+ currentWidthRef,
761
+ minPaneWidth,
762
+ maxPaneWidth,
763
+ getMaxPaneWidth,
764
+ saveWidth,
765
+ getDefaultWidth
766
+ } = usePaneWidth({
767
+ width,
768
+ minWidth,
769
+ resizable,
770
+ widthStorageKey,
771
+ paneRef: sidebarRef,
772
+ handleRef,
773
+ contentWrapperRef: sidebarContentWrapperRef,
774
+ constrainToViewport: true
775
+ });
776
+ useRefObjectAsForwardedRef(forwardRef, sidebarRef);
777
+ const hasOverflow = useOverflow(sidebarRef);
778
+ const sidebarId = useId(id);
779
+ const labelProp = {};
780
+ if (hasOverflow) {
781
+ process.env.NODE_ENV !== "production" ? warning(label === undefined && labelledBy === undefined, 'The <PageLayout.Sidebar> has overflow and `aria-label` or `aria-labelledby` has not been set. ' + 'Please provide `aria-label` or `aria-labelledby` to <PageLayout.Sidebar> in order to label this ' + 'region.') : void 0;
782
+ if (labelledBy) {
783
+ labelProp['aria-labelledby'] = labelledBy;
784
+ } else if (label) {
785
+ labelProp['aria-label'] = label;
786
+ }
1283
787
  }
1284
- const dividerProp = t5;
788
+ return /*#__PURE__*/jsxs("div", {
789
+ className: clsx(classes.SidebarWrapper, className),
790
+ style: {
791
+ '--spacing-column': `var(--spacing-${columnGap})`,
792
+ ...style
793
+ },
794
+ ...getResponsiveAttributes('is-hidden', responsiveHidden),
795
+ "data-position": position,
796
+ "data-sticky": sticky || undefined,
797
+ "data-responsive-variant": responsiveVariant !== 'default' ? responsiveVariant : undefined,
798
+ children: [position === 'end' && /*#__PURE__*/jsx(SidebarDivider, {
799
+ position: position,
800
+ divider: divider,
801
+ resizable: resizable,
802
+ minPaneWidth: minPaneWidth,
803
+ maxPaneWidth: maxPaneWidth,
804
+ currentWidth: currentWidth,
805
+ currentWidthRef: currentWidthRef,
806
+ handleRef: handleRef,
807
+ sidebarRef: sidebarRef,
808
+ dragStartClientXRef: dragStartClientXRef,
809
+ dragStartWidthRef: dragStartWidthRef,
810
+ dragMaxWidthRef: dragMaxWidthRef,
811
+ getMaxPaneWidth: getMaxPaneWidth,
812
+ getDefaultWidth: getDefaultWidth,
813
+ saveWidth: saveWidth
814
+ }), /*#__PURE__*/jsx("div", {
815
+ ref: sidebarRef
816
+ // Suppress hydration mismatch for --pane-width when localStorage
817
+ // provides a width that differs from the server-rendered default.
818
+ ,
819
+ suppressHydrationWarning: resizable === true && !!widthStorageKey,
820
+ ...(hasOverflow ? overflowProps : {}),
821
+ ...labelProp,
822
+ ...(id && {
823
+ id: sidebarId
824
+ }),
825
+ className: classes.Sidebar,
826
+ "data-resizable": resizable || undefined,
827
+ style: {
828
+ '--spacing': `var(--spacing-${padding})`,
829
+ '--pane-min-width': isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
830
+ '--pane-max-width': isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--sidebar-max-width-diff))`,
831
+ '--pane-width-custom': isCustomWidthOptions(width) ? width.default : undefined,
832
+ '--pane-width-size': `var(--pane-width-${isPaneWidth(width) ? width : 'custom'})`,
833
+ '--pane-width': `${currentWidth}px`
834
+ },
835
+ children: children
836
+ }), position === 'start' && /*#__PURE__*/jsx(SidebarDivider, {
837
+ position: position,
838
+ divider: divider,
839
+ resizable: resizable,
840
+ minPaneWidth: minPaneWidth,
841
+ maxPaneWidth: maxPaneWidth,
842
+ currentWidth: currentWidth,
843
+ currentWidthRef: currentWidthRef,
844
+ handleRef: handleRef,
845
+ sidebarRef: sidebarRef,
846
+ dragStartClientXRef: dragStartClientXRef,
847
+ dragStartWidthRef: dragStartWidthRef,
848
+ dragMaxWidthRef: dragMaxWidthRef,
849
+ getMaxPaneWidth: getMaxPaneWidth,
850
+ getDefaultWidth: getDefaultWidth,
851
+ saveWidth: saveWidth
852
+ })]
853
+ });
854
+ });
855
+ Sidebar.displayName = 'PageLayout.Sidebar';
856
+
857
+ // ----------------------------------------------------------------------------
858
+ // PageLayout.Footer
859
+
860
+ const Footer = ({
861
+ 'aria-label': label,
862
+ 'aria-labelledby': labelledBy,
863
+ padding = 'none',
864
+ divider = 'none',
865
+ dividerWhenNarrow = 'inherit',
866
+ hidden = false,
867
+ children,
868
+ className,
869
+ style
870
+ }) => {
871
+ // Combine divider and dividerWhenNarrow for backwards compatibility
872
+ const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== 'inherit' ? {
873
+ regular: divider,
874
+ narrow: dividerWhenNarrow
875
+ } : divider;
1285
876
  const {
1286
877
  rowGap
1287
878
  } = React.useContext(PageLayoutContext);
1288
- let t6;
1289
- if ($[3] !== hidden) {
1290
- t6 = getResponsiveAttributes("hidden", hidden);
1291
- $[3] = hidden;
1292
- $[4] = t6;
1293
- } else {
1294
- t6 = $[4];
1295
- }
1296
- let t7;
1297
- if ($[5] !== className) {
1298
- t7 = clsx(classes.FooterWrapper, className);
1299
- $[5] = className;
1300
- $[6] = t7;
1301
- } else {
1302
- t7 = $[6];
1303
- }
1304
- const t8 = `var(--spacing-${rowGap})`;
1305
- let t9;
1306
- if ($[7] !== style || $[8] !== t8) {
1307
- t9 = {
1308
- "--spacing": t8,
879
+ return /*#__PURE__*/jsxs("footer", {
880
+ "aria-label": label,
881
+ "aria-labelledby": labelledBy,
882
+ ...getResponsiveAttributes('hidden', hidden),
883
+ className: clsx(classes.FooterWrapper, className),
884
+ style: {
885
+ '--spacing': `var(--spacing-${rowGap})`,
1309
886
  ...style
1310
- };
1311
- $[7] = style;
1312
- $[8] = t8;
1313
- $[9] = t9;
1314
- } else {
1315
- t9 = $[9];
1316
- }
1317
- const t10 = t9;
1318
- const t11 = `var(--spacing-${rowGap})`;
1319
- let t12;
1320
- if ($[10] !== t11) {
1321
- t12 = {
1322
- "--spacing": t11
1323
- };
1324
- $[10] = t11;
1325
- $[11] = t12;
1326
- } else {
1327
- t12 = $[11];
1328
- }
1329
- const t13 = t12;
1330
- let t14;
1331
- if ($[12] !== dividerProp || $[13] !== t13) {
1332
- t14 = /*#__PURE__*/jsx(HorizontalDivider, {
887
+ },
888
+ children: [/*#__PURE__*/jsx(HorizontalDivider, {
1333
889
  className: classes.FooterHorizontalDivider,
1334
- style: t13,
890
+ style: {
891
+ '--spacing': `var(--spacing-${rowGap})`
892
+ },
1335
893
  variant: dividerProp
1336
- });
1337
- $[12] = dividerProp;
1338
- $[13] = t13;
1339
- $[14] = t14;
1340
- } else {
1341
- t14 = $[14];
1342
- }
1343
- const t15 = `var(--spacing-${padding})`;
1344
- let t16;
1345
- if ($[15] !== t15) {
1346
- t16 = {
1347
- "--spacing": t15
1348
- };
1349
- $[15] = t15;
1350
- $[16] = t16;
1351
- } else {
1352
- t16 = $[16];
1353
- }
1354
- const t17 = t16;
1355
- let t18;
1356
- if ($[17] !== children || $[18] !== t17) {
1357
- t18 = /*#__PURE__*/jsx("div", {
894
+ }), /*#__PURE__*/jsx("div", {
1358
895
  className: classes.FooterContent,
1359
- style: t17,
896
+ style: {
897
+ '--spacing': `var(--spacing-${padding})`
898
+ },
1360
899
  children: children
1361
- });
1362
- $[17] = children;
1363
- $[18] = t17;
1364
- $[19] = t18;
1365
- } else {
1366
- t18 = $[19];
1367
- }
1368
- let t19;
1369
- if ($[20] !== label || $[21] !== labelledBy || $[22] !== t10 || $[23] !== t14 || $[24] !== t18 || $[25] !== t6 || $[26] !== t7) {
1370
- t19 = /*#__PURE__*/jsxs("footer", {
1371
- "aria-label": label,
1372
- "aria-labelledby": labelledBy,
1373
- ...t6,
1374
- className: t7,
1375
- style: t10,
1376
- children: [t14, t18]
1377
- });
1378
- $[20] = label;
1379
- $[21] = labelledBy;
1380
- $[22] = t10;
1381
- $[23] = t14;
1382
- $[24] = t18;
1383
- $[25] = t6;
1384
- $[26] = t7;
1385
- $[27] = t19;
1386
- } else {
1387
- t19 = $[27];
1388
- }
1389
- return t19;
900
+ })]
901
+ });
1390
902
  };
903
+ Footer.displayName = "Footer";
1391
904
  Footer.displayName = 'PageLayout.Footer';
1392
905
 
1393
906
  // ----------------------------------------------------------------------------
@@ -1398,11 +911,13 @@ const PageLayout = Object.assign(Root, {
1398
911
  Header,
1399
912
  Content,
1400
913
  Pane: Pane,
914
+ Sidebar: Sidebar,
1401
915
  Footer
1402
916
  });
1403
917
  Header.__SLOT__ = Symbol('PageLayout.Header');
1404
918
  Content.__SLOT__ = Symbol('PageLayout.Content');
1405
919
  Pane.__SLOT__ = Symbol('PageLayout.Pane');
920
+ Sidebar.__SLOT__ = Symbol('PageLayout.Sidebar');
1406
921
  Footer.__SLOT__ = Symbol('PageLayout.Footer');
1407
922
 
1408
923
  export { PageLayout };