@primer/react 0.0.0-20260218214943 → 0.0.0-20260219011733
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 +8 -2
- package/dist/ActionList/ActionList-c04a02d6.css +2 -0
- package/dist/ActionList/ActionList-c04a02d6.css.map +1 -0
- package/dist/ActionList/ActionList.module.css.js +1 -1
- package/dist/ActionList/Item.d.ts.map +1 -1
- package/dist/ActionList/Item.js +1 -0
- package/dist/PageLayout/PageLayout-06f4c069.css +2 -0
- package/dist/PageLayout/PageLayout-06f4c069.css.map +1 -0
- package/dist/PageLayout/PageLayout.d.ts +72 -2
- package/dist/PageLayout/PageLayout.d.ts.map +1 -1
- package/dist/PageLayout/PageLayout.js +497 -44
- package/dist/PageLayout/PageLayout.module.css.js +2 -2
- package/dist/PageLayout/usePaneWidth.d.ts +18 -5
- package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
- package/dist/PageLayout/usePaneWidth.js +125 -111
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +82 -32
- package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
- package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
- package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
- package/generated/components.json +189 -3
- package/package.json +1 -1
- package/dist/ActionList/ActionList-f4ac3b54.css +0 -2
- package/dist/ActionList/ActionList-f4ac3b54.css.map +0 -1
- package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
- package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
|
@@ -16,10 +16,17 @@ export type UsePaneWidthOptions = {
|
|
|
16
16
|
width: PaneWidthValue;
|
|
17
17
|
minWidth: number;
|
|
18
18
|
resizable: boolean;
|
|
19
|
-
|
|
19
|
+
/** localStorage key for persisting width. When undefined, localStorage is not used. */
|
|
20
|
+
widthStorageKey?: string;
|
|
20
21
|
paneRef: React.RefObject<HTMLDivElement | null>;
|
|
21
22
|
handleRef: React.RefObject<HTMLDivElement | null>;
|
|
22
23
|
contentWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
24
|
+
/**
|
|
25
|
+
* When true, custom max width values are capped to the viewport-based max.
|
|
26
|
+
* This prevents overflow in non-wrapping flex layouts (e.g., Sidebar).
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
constrainToViewport?: boolean;
|
|
23
30
|
/** Callback fired when a resize operation ends (drag release or keyboard key up) */
|
|
24
31
|
onResizeEnd?: (width: number) => void;
|
|
25
32
|
/** Current/controlled width value in pixels (used instead of internal state; default from `width` is still used for reset) */
|
|
@@ -46,6 +53,11 @@ export type UsePaneWidthResult = {
|
|
|
46
53
|
* Imported from CSS to ensure JS fallback matches the CSS default.
|
|
47
54
|
*/
|
|
48
55
|
export declare const DEFAULT_MAX_WIDTH_DIFF: number;
|
|
56
|
+
/**
|
|
57
|
+
* Default value for --sidebar-max-width-diff CSS variable.
|
|
58
|
+
* Unlike --pane-max-width-diff, this is constant across all viewport sizes.
|
|
59
|
+
*/
|
|
60
|
+
export declare const DEFAULT_SIDEBAR_MAX_WIDTH_DIFF: number;
|
|
49
61
|
/**
|
|
50
62
|
* Default max pane width for SSR when viewport is unknown.
|
|
51
63
|
* Updated to actual value in layout effect before paint.
|
|
@@ -62,11 +74,12 @@ export declare const isCustomWidthOptions: (width: PaneWidthValue) => width is C
|
|
|
62
74
|
export declare const isPaneWidth: (width: PaneWidthValue) => width is PaneWidth;
|
|
63
75
|
export declare const getDefaultPaneWidth: (w: PaneWidthValue) => number;
|
|
64
76
|
/**
|
|
65
|
-
* Gets the
|
|
66
|
-
*
|
|
77
|
+
* Gets the max-width-diff CSS variable value from a pane element.
|
|
78
|
+
* For sidebars, reads --sidebar-max-width-diff (constant across viewports).
|
|
79
|
+
* For panes, reads --pane-max-width-diff (changes at 1280px breakpoint).
|
|
67
80
|
* Note: This calls getComputedStyle which forces layout - cache the result when possible.
|
|
68
81
|
*/
|
|
69
|
-
export declare function getPaneMaxWidthDiff(paneElement: HTMLElement | null): number;
|
|
82
|
+
export declare function getPaneMaxWidthDiff(paneElement: HTMLElement | null, isSidebar?: boolean): number;
|
|
70
83
|
export declare const updateAriaValues: (handle: HTMLElement | null, values: {
|
|
71
84
|
current?: number;
|
|
72
85
|
min?: number;
|
|
@@ -82,6 +95,6 @@ export declare const updateAriaValues: (handle: HTMLElement | null, values: {
|
|
|
82
95
|
* - When `onResizeEnd` is provided: Calls the callback instead of localStorage
|
|
83
96
|
* - When `resizable` is `false` or `undefined`: Not resizable, no persistence
|
|
84
97
|
*/
|
|
85
|
-
export declare function usePaneWidth({ width, minWidth, resizable, widthStorageKey, paneRef, handleRef, contentWrapperRef, onResizeEnd, currentWidth: controlledWidth, }: UsePaneWidthOptions): UsePaneWidthResult;
|
|
98
|
+
export declare function usePaneWidth({ width, minWidth, resizable, widthStorageKey, paneRef, handleRef, contentWrapperRef, constrainToViewport, onResizeEnd, currentWidth: controlledWidth, }: UsePaneWidthOptions): UsePaneWidthResult;
|
|
86
99
|
export {};
|
|
87
100
|
//# sourceMappingURL=usePaneWidth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaneWidth.d.ts","sourceRoot":"","sources":["../../src/PageLayout/usePaneWidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAA;AAOrD,KAAK,WAAW,GAAG,GAAG,MAAM,IAAI,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,WAAW,CAAA;IAChB,OAAO,EAAE,WAAW,CAAA;IACpB,GAAG,EAAE,WAAW,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEpD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,kBAAkB,CAAA;AAE3D,MAAM,MAAM,mBAAmB,GAAG;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wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,mBAA2B,EAC3B,WAAW,EACX,YAAY,EAAE,eAAe,GAC9B,EAAE,mBAAmB,GAAG,kBAAkB,CAuQ1C"}
|
|
@@ -21,6 +21,12 @@ import classes from './PageLayout.module.css.js';
|
|
|
21
21
|
*/
|
|
22
22
|
const DEFAULT_MAX_WIDTH_DIFF = Number(classes.paneMaxWidthDiffDefault);
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Default value for --sidebar-max-width-diff CSS variable.
|
|
26
|
+
* Unlike --pane-max-width-diff, this is constant across all viewport sizes.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_SIDEBAR_MAX_WIDTH_DIFF = Number(classes.sidebarMaxWidthDiffDefault);
|
|
29
|
+
|
|
24
30
|
// --pane-max-width-diff changes at this breakpoint in PageLayout.module.css.
|
|
25
31
|
const DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT = Number(classes.paneMaxWidthDiffBreakpoint);
|
|
26
32
|
/**
|
|
@@ -61,14 +67,17 @@ const getDefaultPaneWidth = w => {
|
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
|
-
* Gets the
|
|
65
|
-
*
|
|
70
|
+
* Gets the max-width-diff CSS variable value from a pane element.
|
|
71
|
+
* For sidebars, reads --sidebar-max-width-diff (constant across viewports).
|
|
72
|
+
* For panes, reads --pane-max-width-diff (changes at 1280px breakpoint).
|
|
66
73
|
* Note: This calls getComputedStyle which forces layout - cache the result when possible.
|
|
67
74
|
*/
|
|
68
|
-
function getPaneMaxWidthDiff(paneElement) {
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
75
|
+
function getPaneMaxWidthDiff(paneElement, isSidebar = false) {
|
|
76
|
+
const defaultValue = isSidebar ? DEFAULT_SIDEBAR_MAX_WIDTH_DIFF : DEFAULT_MAX_WIDTH_DIFF;
|
|
77
|
+
const cssVar = isSidebar ? '--sidebar-max-width-diff' : '--pane-max-width-diff';
|
|
78
|
+
if (!paneElement) return defaultValue;
|
|
79
|
+
const value = parseInt(getComputedStyle(paneElement).getPropertyValue(cssVar), 10);
|
|
80
|
+
return value > 0 ? value : defaultValue;
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
// Helper to update ARIA slider attributes via direct DOM manipulation
|
|
@@ -121,7 +130,7 @@ const localStoragePersister = {
|
|
|
121
130
|
* - When `resizable` is `false` or `undefined`: Not resizable, no persistence
|
|
122
131
|
*/
|
|
123
132
|
function usePaneWidth(t0) {
|
|
124
|
-
const $ = c(
|
|
133
|
+
const $ = c(42);
|
|
125
134
|
const {
|
|
126
135
|
width,
|
|
127
136
|
minWidth,
|
|
@@ -130,60 +139,64 @@ function usePaneWidth(t0) {
|
|
|
130
139
|
paneRef,
|
|
131
140
|
handleRef,
|
|
132
141
|
contentWrapperRef,
|
|
142
|
+
constrainToViewport: t1,
|
|
133
143
|
onResizeEnd,
|
|
134
144
|
currentWidth: controlledWidth
|
|
135
145
|
} = t0;
|
|
146
|
+
const constrainToViewport = t1 === undefined ? false : t1;
|
|
136
147
|
const isCustomWidth = isCustomWidthOptions(width);
|
|
137
148
|
const minPaneWidth = isCustomWidth ? parseInt(width.min, 10) : minWidth;
|
|
138
149
|
const customMaxWidth = isCustomWidth ? parseInt(width.max, 10) : null;
|
|
139
150
|
const widthStorageKeyRef = React.useRef(widthStorageKey);
|
|
140
151
|
const onResizeEndRef = React.useRef(onResizeEnd);
|
|
141
|
-
let
|
|
152
|
+
let t2;
|
|
142
153
|
if ($[0] !== onResizeEnd || $[1] !== widthStorageKey) {
|
|
143
|
-
|
|
154
|
+
t2 = () => {
|
|
144
155
|
widthStorageKeyRef.current = widthStorageKey;
|
|
145
156
|
onResizeEndRef.current = onResizeEnd;
|
|
146
157
|
};
|
|
147
158
|
$[0] = onResizeEnd;
|
|
148
159
|
$[1] = widthStorageKey;
|
|
149
|
-
$[2] =
|
|
160
|
+
$[2] = t2;
|
|
150
161
|
} else {
|
|
151
|
-
|
|
162
|
+
t2 = $[2];
|
|
152
163
|
}
|
|
153
|
-
useIsomorphicLayoutEffect(
|
|
154
|
-
const maxWidthDiffRef = React.useRef(DEFAULT_MAX_WIDTH_DIFF);
|
|
155
|
-
let
|
|
156
|
-
if ($[3] !==
|
|
157
|
-
|
|
164
|
+
useIsomorphicLayoutEffect(t2);
|
|
165
|
+
const maxWidthDiffRef = React.useRef(constrainToViewport ? DEFAULT_SIDEBAR_MAX_WIDTH_DIFF : DEFAULT_MAX_WIDTH_DIFF);
|
|
166
|
+
let t3;
|
|
167
|
+
if ($[3] !== constrainToViewport || $[4] !== customMaxWidth || $[5] !== minPaneWidth) {
|
|
168
|
+
t3 = () => {
|
|
169
|
+
const viewportWidth = window.innerWidth;
|
|
170
|
+
const viewportMax = viewportWidth > 0 ? Math.max(minPaneWidth, viewportWidth - maxWidthDiffRef.current) : minPaneWidth;
|
|
158
171
|
if (customMaxWidth !== null) {
|
|
159
|
-
return customMaxWidth;
|
|
172
|
+
return constrainToViewport ? Math.min(customMaxWidth, viewportMax) : customMaxWidth;
|
|
160
173
|
}
|
|
161
|
-
|
|
162
|
-
return viewportWidth > 0 ? Math.max(minPaneWidth, viewportWidth - maxWidthDiffRef.current) : minPaneWidth;
|
|
174
|
+
return viewportMax;
|
|
163
175
|
};
|
|
164
|
-
$[3] =
|
|
165
|
-
$[4] =
|
|
166
|
-
$[5] =
|
|
176
|
+
$[3] = constrainToViewport;
|
|
177
|
+
$[4] = customMaxWidth;
|
|
178
|
+
$[5] = minPaneWidth;
|
|
179
|
+
$[6] = t3;
|
|
167
180
|
} else {
|
|
168
|
-
|
|
181
|
+
t3 = $[6];
|
|
169
182
|
}
|
|
170
|
-
const getMaxPaneWidth =
|
|
171
|
-
let
|
|
172
|
-
if ($[
|
|
173
|
-
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
183
|
+
const getMaxPaneWidth = t3;
|
|
184
|
+
let t4;
|
|
185
|
+
if ($[7] !== width) {
|
|
186
|
+
t4 = getDefaultPaneWidth(width);
|
|
187
|
+
$[7] = width;
|
|
188
|
+
$[8] = t4;
|
|
176
189
|
} else {
|
|
177
|
-
|
|
190
|
+
t4 = $[8];
|
|
178
191
|
}
|
|
179
|
-
const defaultWidth =
|
|
180
|
-
let
|
|
181
|
-
if ($[
|
|
182
|
-
|
|
192
|
+
const defaultWidth = t4;
|
|
193
|
+
let t5;
|
|
194
|
+
if ($[9] !== controlledWidth || $[10] !== defaultWidth || $[11] !== onResizeEnd || $[12] !== resizable || $[13] !== widthStorageKey) {
|
|
195
|
+
t5 = () => {
|
|
183
196
|
if (typeof controlledWidth === "number") {
|
|
184
197
|
return controlledWidth;
|
|
185
198
|
}
|
|
186
|
-
const shouldUseLocalStorage = onResizeEnd === undefined && resizable === true;
|
|
199
|
+
const shouldUseLocalStorage = onResizeEnd === undefined && resizable === true && widthStorageKey !== undefined;
|
|
187
200
|
if (shouldUseLocalStorage) {
|
|
188
201
|
const storedWidth = localStoragePersister.get(widthStorageKey);
|
|
189
202
|
if (storedWidth !== null) {
|
|
@@ -192,16 +205,16 @@ function usePaneWidth(t0) {
|
|
|
192
205
|
}
|
|
193
206
|
return defaultWidth;
|
|
194
207
|
};
|
|
195
|
-
$[
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
208
|
+
$[9] = controlledWidth;
|
|
209
|
+
$[10] = defaultWidth;
|
|
210
|
+
$[11] = onResizeEnd;
|
|
211
|
+
$[12] = resizable;
|
|
212
|
+
$[13] = widthStorageKey;
|
|
213
|
+
$[14] = t5;
|
|
201
214
|
} else {
|
|
202
|
-
|
|
215
|
+
t5 = $[14];
|
|
203
216
|
}
|
|
204
|
-
const [currentWidthState, setCurrentWidthState] = React.useState(
|
|
217
|
+
const [currentWidthState, setCurrentWidthState] = React.useState(t5);
|
|
205
218
|
const [prevDefaultWidth, setPrevDefaultWidth] = React.useState(defaultWidth);
|
|
206
219
|
const [prevControlledWidth, setPrevControlledWidth] = React.useState(controlledWidth);
|
|
207
220
|
const controlledWidthChanged = controlledWidth !== prevControlledWidth;
|
|
@@ -224,42 +237,42 @@ function usePaneWidth(t0) {
|
|
|
224
237
|
}
|
|
225
238
|
const currentWidth = controlledWidth !== null && controlledWidth !== void 0 ? controlledWidth : currentWidthState;
|
|
226
239
|
const currentWidthRef = React.useRef(currentWidth);
|
|
227
|
-
let
|
|
228
|
-
if ($[
|
|
229
|
-
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
240
|
+
let t6;
|
|
241
|
+
if ($[15] !== customMaxWidth) {
|
|
242
|
+
t6 = () => customMaxWidth !== null && customMaxWidth !== void 0 ? customMaxWidth : SSR_DEFAULT_MAX_WIDTH;
|
|
243
|
+
$[15] = customMaxWidth;
|
|
244
|
+
$[16] = t6;
|
|
232
245
|
} else {
|
|
233
|
-
|
|
246
|
+
t6 = $[16];
|
|
234
247
|
}
|
|
235
|
-
const [maxPaneWidth, setMaxPaneWidth] = React.useState(
|
|
236
|
-
let t6;
|
|
248
|
+
const [maxPaneWidth, setMaxPaneWidth] = React.useState(t6);
|
|
237
249
|
let t7;
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
let t8;
|
|
251
|
+
if ($[17] !== currentWidth) {
|
|
252
|
+
t7 = () => {
|
|
240
253
|
currentWidthRef.current = currentWidth;
|
|
241
254
|
};
|
|
242
|
-
|
|
243
|
-
$[
|
|
244
|
-
$[17] = t6;
|
|
255
|
+
t8 = [currentWidth];
|
|
256
|
+
$[17] = currentWidth;
|
|
245
257
|
$[18] = t7;
|
|
258
|
+
$[19] = t8;
|
|
246
259
|
} else {
|
|
247
|
-
t6 = $[17];
|
|
248
260
|
t7 = $[18];
|
|
261
|
+
t8 = $[19];
|
|
249
262
|
}
|
|
250
|
-
useIsomorphicLayoutEffect(
|
|
251
|
-
let
|
|
252
|
-
if ($[
|
|
253
|
-
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
263
|
+
useIsomorphicLayoutEffect(t7, t8);
|
|
264
|
+
let t9;
|
|
265
|
+
if ($[20] !== width) {
|
|
266
|
+
t9 = () => getDefaultPaneWidth(width);
|
|
267
|
+
$[20] = width;
|
|
268
|
+
$[21] = t9;
|
|
256
269
|
} else {
|
|
257
|
-
|
|
270
|
+
t9 = $[21];
|
|
258
271
|
}
|
|
259
|
-
const getDefaultWidth =
|
|
260
|
-
let
|
|
261
|
-
if ($[
|
|
262
|
-
|
|
272
|
+
const getDefaultWidth = t9;
|
|
273
|
+
let t10;
|
|
274
|
+
if ($[22] !== resizable) {
|
|
275
|
+
t10 = value => {
|
|
263
276
|
const rounded = Math.round(value);
|
|
264
277
|
currentWidthRef.current = rounded;
|
|
265
278
|
startTransition(() => {
|
|
@@ -271,32 +284,32 @@ function usePaneWidth(t0) {
|
|
|
271
284
|
} catch {}
|
|
272
285
|
return;
|
|
273
286
|
}
|
|
274
|
-
if (resizable) {
|
|
287
|
+
if (resizable && widthStorageKeyRef.current) {
|
|
275
288
|
localStoragePersister.save(widthStorageKeyRef.current, rounded);
|
|
276
289
|
}
|
|
277
290
|
};
|
|
278
|
-
$[
|
|
279
|
-
$[
|
|
291
|
+
$[22] = resizable;
|
|
292
|
+
$[23] = t10;
|
|
280
293
|
} else {
|
|
281
|
-
|
|
294
|
+
t10 = $[23];
|
|
282
295
|
}
|
|
283
|
-
const saveWidth =
|
|
296
|
+
const saveWidth = t10;
|
|
284
297
|
const getMaxPaneWidthRef = React.useRef(getMaxPaneWidth);
|
|
285
|
-
let
|
|
286
|
-
if ($[
|
|
287
|
-
|
|
298
|
+
let t11;
|
|
299
|
+
if ($[24] !== getMaxPaneWidth) {
|
|
300
|
+
t11 = () => {
|
|
288
301
|
getMaxPaneWidthRef.current = getMaxPaneWidth;
|
|
289
302
|
};
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
303
|
+
$[24] = getMaxPaneWidth;
|
|
304
|
+
$[25] = t11;
|
|
292
305
|
} else {
|
|
293
|
-
|
|
306
|
+
t11 = $[25];
|
|
294
307
|
}
|
|
295
|
-
useIsomorphicLayoutEffect(
|
|
296
|
-
let t11;
|
|
308
|
+
useIsomorphicLayoutEffect(t11);
|
|
297
309
|
let t12;
|
|
298
|
-
|
|
299
|
-
|
|
310
|
+
let t13;
|
|
311
|
+
if ($[26] !== constrainToViewport || $[27] !== contentWrapperRef || $[28] !== customMaxWidth || $[29] !== handleRef || $[30] !== minPaneWidth || $[31] !== paneRef || $[32] !== resizable) {
|
|
312
|
+
t12 = () => {
|
|
300
313
|
var _paneRef$current3;
|
|
301
314
|
if (!resizable) {
|
|
302
315
|
return;
|
|
@@ -308,7 +321,7 @@ function usePaneWidth(t0) {
|
|
|
308
321
|
const crossedBreakpoint = lastViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT || lastViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT;
|
|
309
322
|
lastViewportWidth = currentViewportWidth;
|
|
310
323
|
if (crossedBreakpoint) {
|
|
311
|
-
maxWidthDiffRef.current = getPaneMaxWidthDiff(paneRef.current);
|
|
324
|
+
maxWidthDiffRef.current = getPaneMaxWidthDiff(paneRef.current, constrainToViewport);
|
|
312
325
|
}
|
|
313
326
|
const actualMax = getMaxPaneWidthRef.current();
|
|
314
327
|
(_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.style.setProperty("--pane-max-width", `${actualMax}px`);
|
|
@@ -329,7 +342,7 @@ function usePaneWidth(t0) {
|
|
|
329
342
|
}
|
|
330
343
|
});
|
|
331
344
|
};
|
|
332
|
-
maxWidthDiffRef.current = getPaneMaxWidthDiff(paneRef.current);
|
|
345
|
+
maxWidthDiffRef.current = getPaneMaxWidthDiff(paneRef.current, constrainToViewport);
|
|
333
346
|
const initialMax = getMaxPaneWidthRef.current();
|
|
334
347
|
setMaxPaneWidth(initialMax);
|
|
335
348
|
(_paneRef$current3 = paneRef.current) === null || _paneRef$current3 === void 0 ? void 0 : _paneRef$current3.style.setProperty("--pane-max-width", `${initialMax}px`);
|
|
@@ -338,7 +351,7 @@ function usePaneWidth(t0) {
|
|
|
338
351
|
max: initialMax,
|
|
339
352
|
current: currentWidthRef.current
|
|
340
353
|
});
|
|
341
|
-
if (customMaxWidth !== null) {
|
|
354
|
+
if (customMaxWidth !== null && !constrainToViewport) {
|
|
342
355
|
return;
|
|
343
356
|
}
|
|
344
357
|
let lastUpdateTime = 0;
|
|
@@ -401,23 +414,24 @@ function usePaneWidth(t0) {
|
|
|
401
414
|
window.removeEventListener("resize", handleResize);
|
|
402
415
|
};
|
|
403
416
|
};
|
|
404
|
-
|
|
405
|
-
$[
|
|
406
|
-
$[
|
|
407
|
-
$[
|
|
408
|
-
$[
|
|
409
|
-
$[
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
417
|
+
t13 = [resizable, customMaxWidth, constrainToViewport, minPaneWidth, paneRef, handleRef, contentWrapperRef];
|
|
418
|
+
$[26] = constrainToViewport;
|
|
419
|
+
$[27] = contentWrapperRef;
|
|
420
|
+
$[28] = customMaxWidth;
|
|
421
|
+
$[29] = handleRef;
|
|
422
|
+
$[30] = minPaneWidth;
|
|
423
|
+
$[31] = paneRef;
|
|
424
|
+
$[32] = resizable;
|
|
425
|
+
$[33] = t12;
|
|
426
|
+
$[34] = t13;
|
|
413
427
|
} else {
|
|
414
|
-
|
|
415
|
-
|
|
428
|
+
t12 = $[33];
|
|
429
|
+
t13 = $[34];
|
|
416
430
|
}
|
|
417
|
-
useIsomorphicLayoutEffect(
|
|
418
|
-
let
|
|
419
|
-
if ($[
|
|
420
|
-
|
|
431
|
+
useIsomorphicLayoutEffect(t12, t13);
|
|
432
|
+
let t14;
|
|
433
|
+
if ($[35] !== currentWidth || $[36] !== getDefaultWidth || $[37] !== getMaxPaneWidth || $[38] !== maxPaneWidth || $[39] !== minPaneWidth || $[40] !== saveWidth) {
|
|
434
|
+
t14 = {
|
|
421
435
|
currentWidth,
|
|
422
436
|
currentWidthRef,
|
|
423
437
|
minPaneWidth,
|
|
@@ -426,17 +440,17 @@ function usePaneWidth(t0) {
|
|
|
426
440
|
saveWidth,
|
|
427
441
|
getDefaultWidth
|
|
428
442
|
};
|
|
429
|
-
$[
|
|
430
|
-
$[
|
|
431
|
-
$[
|
|
432
|
-
$[
|
|
433
|
-
$[
|
|
434
|
-
$[
|
|
435
|
-
$[
|
|
443
|
+
$[35] = currentWidth;
|
|
444
|
+
$[36] = getDefaultWidth;
|
|
445
|
+
$[37] = getMaxPaneWidth;
|
|
446
|
+
$[38] = maxPaneWidth;
|
|
447
|
+
$[39] = minPaneWidth;
|
|
448
|
+
$[40] = saveWidth;
|
|
449
|
+
$[41] = t14;
|
|
436
450
|
} else {
|
|
437
|
-
|
|
451
|
+
t14 = $[41];
|
|
438
452
|
}
|
|
439
|
-
return
|
|
453
|
+
return t14;
|
|
440
454
|
}
|
|
441
455
|
|
|
442
|
-
export { ARROW_KEY_STEP, DEFAULT_MAX_WIDTH_DIFF, SSR_DEFAULT_MAX_WIDTH, defaultPaneWidth, getDefaultPaneWidth, getPaneMaxWidthDiff, isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth };
|
|
456
|
+
export { ARROW_KEY_STEP, DEFAULT_MAX_WIDTH_DIFF, DEFAULT_SIDEBAR_MAX_WIDTH_DIFF, SSR_DEFAULT_MAX_WIDTH, defaultPaneWidth, getDefaultPaneWidth, getPaneMaxWidthDiff, isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/SelectPanel.tsx"],"names":[],"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zB,iBAAS,KAAK,CAAC,EACb,IAAI,EACJ,YAAY,EACZ,YAAkC,EAClC,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EACX,eAAgC,EAChC,UAA4B,EAC5B,QAAQ,EACR,KAA0E,EAC1E,QAAQ,EACR,gBAAgB,EAChB,WAAW,EAAE,mBAAmB,EAChC,cAAc,EAAE,sBAAsB,EACtC,KAAK,EACL,MAAM,EACN,cAAc,EACd,YAAY,EACZ,OAAO,EACP,kBAA8B,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAoB,EACpB,eAAe,EACf,wBAA+B,EAC/B,yBAAyB,EACzB,KAAK,EACL,aAAqB,EACrB,sBAAsB,EACtB,GAAG,SAAS,EACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAgyBhC;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAM1C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,GAAG,WAAW,CAM1D,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA"}
|
|
@@ -132,8 +132,6 @@ function Panel({
|
|
|
132
132
|
wide: false
|
|
133
133
|
}, false);
|
|
134
134
|
const [selectedOnSort, setSelectedOnSort] = useState([]);
|
|
135
|
-
const [prevItems, setPrevItems] = useState([]);
|
|
136
|
-
const [prevOpen, setPrevOpen] = useState(open);
|
|
137
135
|
const initialHeightRef = useRef(0);
|
|
138
136
|
const initialScaleRef = useRef(1);
|
|
139
137
|
const noticeRef = useRef(null);
|
|
@@ -205,6 +203,19 @@ function Panel({
|
|
|
205
203
|
resetSort();
|
|
206
204
|
}
|
|
207
205
|
}, [loadingManagedInternally, externalOnFilterChange, setInternalFilterValue, dataLoadedOnce, safeSetTimeout, safeClearTimeout, items.length, resetSort]);
|
|
206
|
+
|
|
207
|
+
// Pre-compute a Set of item IDs in the current filtered view for O(1) lookups
|
|
208
|
+
const itemsInViewSet = useMemo(() => {
|
|
209
|
+
const set = new Set();
|
|
210
|
+
for (const item of items) {
|
|
211
|
+
if (item.id !== undefined) {
|
|
212
|
+
set.add(item.id);
|
|
213
|
+
} else {
|
|
214
|
+
set.add(item);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return set;
|
|
218
|
+
}, [items]);
|
|
208
219
|
const handleSelectAllChange = useCallback(checked => {
|
|
209
220
|
// Exit early if not in multi-select mode
|
|
210
221
|
if (!isMultiSelectVariant(selected)) {
|
|
@@ -212,13 +223,20 @@ function Panel({
|
|
|
212
223
|
}
|
|
213
224
|
const multiSelectOnChange = onSelectedChange;
|
|
214
225
|
const selectedArray = selected;
|
|
215
|
-
|
|
226
|
+
|
|
227
|
+
// Use Set for O(1) lookup instead of O(n) items.some()
|
|
228
|
+
const selectedItemsNotInFilteredView = selectedArray.filter(selectedItem => {
|
|
229
|
+
if (selectedItem.id !== undefined) {
|
|
230
|
+
return !itemsInViewSet.has(selectedItem.id);
|
|
231
|
+
}
|
|
232
|
+
return !itemsInViewSet.has(selectedItem);
|
|
233
|
+
});
|
|
216
234
|
if (checked) {
|
|
217
235
|
multiSelectOnChange([...selectedItemsNotInFilteredView, ...items]);
|
|
218
236
|
} else {
|
|
219
237
|
multiSelectOnChange(selectedItemsNotInFilteredView);
|
|
220
238
|
}
|
|
221
|
-
}, [items, onSelectedChange, selected]);
|
|
239
|
+
}, [items, itemsInViewSet, onSelectedChange, selected]);
|
|
222
240
|
|
|
223
241
|
// disable body scroll when the panel is open on narrow screens
|
|
224
242
|
useEffect(() => {
|
|
@@ -384,10 +402,29 @@ function Panel({
|
|
|
384
402
|
});
|
|
385
403
|
};
|
|
386
404
|
}, [placeholder, renderAnchor, selected]);
|
|
405
|
+
|
|
406
|
+
// Pre-compute a Set of selected item IDs/references for O(1) lookups
|
|
407
|
+
// This optimizes isItemCurrentlySelected from O(m) to O(1) per call
|
|
408
|
+
const selectedItemsSet = useMemo(() => {
|
|
409
|
+
const set = new Set();
|
|
410
|
+
if (isMultiSelectVariant(selected)) {
|
|
411
|
+
for (const item of selected) {
|
|
412
|
+
if (item.id !== undefined) {
|
|
413
|
+
set.add(item.id);
|
|
414
|
+
} else {
|
|
415
|
+
set.add(item);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return set;
|
|
420
|
+
}, [selected]);
|
|
387
421
|
const isItemCurrentlySelected = useCallback(item => {
|
|
388
|
-
// For multi-select,
|
|
422
|
+
// For multi-select, use the pre-computed Set for O(1) lookup
|
|
389
423
|
if (isMultiSelectVariant(selected)) {
|
|
390
|
-
|
|
424
|
+
if (item.id !== undefined) {
|
|
425
|
+
return selectedItemsSet.has(item.id);
|
|
426
|
+
}
|
|
427
|
+
return selectedItemsSet.has(item);
|
|
391
428
|
}
|
|
392
429
|
|
|
393
430
|
// For single-select modal, there is an intermediate state when the user has selected
|
|
@@ -398,8 +435,24 @@ function Panel({
|
|
|
398
435
|
|
|
399
436
|
// For single-select anchored, we just need to check if the item is the selected item
|
|
400
437
|
return (selected === null || selected === void 0 ? void 0 : selected.id) !== undefined ? selected.id === item.id : selected === item;
|
|
401
|
-
}, [selected, intermediateSelected, isSingleSelectModal]);
|
|
438
|
+
}, [selected, selectedItemsSet, intermediateSelected, isSingleSelectModal]);
|
|
402
439
|
const itemsToRender = useMemo(() => {
|
|
440
|
+
// Pre-compute a Set of selected item IDs/references for O(1) lookups during sorting
|
|
441
|
+
// This avoids O(m * k) work per comparison in the sort function
|
|
442
|
+
const selectedOnSortSet = new Set();
|
|
443
|
+
for (const item of selectedOnSort) {
|
|
444
|
+
if (item.id !== undefined) {
|
|
445
|
+
selectedOnSortSet.add(item.id);
|
|
446
|
+
} else {
|
|
447
|
+
selectedOnSortSet.add(item);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const isSelectedForSort = item => {
|
|
451
|
+
if (item.id !== undefined) {
|
|
452
|
+
return selectedOnSortSet.has(item.id);
|
|
453
|
+
}
|
|
454
|
+
return selectedOnSortSet.has(item);
|
|
455
|
+
};
|
|
403
456
|
return items.map(item => {
|
|
404
457
|
return {
|
|
405
458
|
...item,
|
|
@@ -436,42 +489,39 @@ function Panel({
|
|
|
436
489
|
};
|
|
437
490
|
}).sort((itemA, itemB) => {
|
|
438
491
|
if (shouldOrderSelectedFirst) {
|
|
439
|
-
|
|
440
|
-
const
|
|
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
|
-
}));
|
|
492
|
+
const itemASelected = isSelectedForSort(itemA);
|
|
493
|
+
const itemBSelected = isSelectedForSort(itemB);
|
|
454
494
|
|
|
455
495
|
// order selected items first
|
|
456
|
-
if (itemASelected
|
|
496
|
+
if (itemASelected && !itemBSelected) {
|
|
457
497
|
return -1;
|
|
458
|
-
} else if (itemASelected
|
|
498
|
+
} else if (!itemASelected && itemBSelected) {
|
|
459
499
|
return 1;
|
|
460
500
|
}
|
|
461
501
|
}
|
|
462
502
|
return 0;
|
|
463
503
|
});
|
|
464
504
|
}, [onClose, onSelectedChange, items, selected, isItemCurrentlySelected, isSingleSelectModal, intermediateSelected, shouldOrderSelectedFirst, selectedOnSort]);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
505
|
+
|
|
506
|
+
// Track previous items and reset sort when items first load
|
|
507
|
+
const prevItemsRef = useRef(items);
|
|
508
|
+
useEffect(() => {
|
|
509
|
+
if (prevItemsRef.current !== items) {
|
|
510
|
+
if (prevItemsRef.current.length === 0 && items.length > 0) {
|
|
511
|
+
resetSort();
|
|
512
|
+
}
|
|
513
|
+
prevItemsRef.current = items;
|
|
514
|
+
}
|
|
515
|
+
}, [items, resetSort]);
|
|
516
|
+
|
|
517
|
+
// Reset sort when panel opens
|
|
518
|
+
const prevOpenRef = useRef(open);
|
|
519
|
+
useEffect(() => {
|
|
520
|
+
if (prevOpenRef.current !== open) {
|
|
468
521
|
resetSort();
|
|
522
|
+
prevOpenRef.current = open;
|
|
469
523
|
}
|
|
470
|
-
}
|
|
471
|
-
if (open !== prevOpen) {
|
|
472
|
-
setPrevOpen(open);
|
|
473
|
-
resetSort();
|
|
474
|
-
}
|
|
524
|
+
}, [open, resetSort]);
|
|
475
525
|
const focusTrapSettings = {
|
|
476
526
|
initialFocusRef: inputRef || undefined
|
|
477
527
|
};
|
|
@@ -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,
|
|
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,CAA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