@primer/react 0.0.0-20260714183333 → 0.0.0-20260714202217
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 +3 -15
- package/dist/ActionBar/ActionBar.js +1 -1
- package/dist/ActionList/Group.js +1 -1
- package/dist/ActionList/List.js +16 -10
- package/dist/AnchoredOverlay/AnchoredOverlay.js +9 -3
- package/dist/Autocomplete/AutocompleteInput.js +10 -7
- package/dist/ButtonGroup/ButtonGroup.js +12 -5
- package/dist/Checkbox/Checkbox.js +10 -3
- package/dist/Dialog/Dialog.js +9 -2
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/FilteredActionList/FilteredActionList.js +15 -4
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/PageHeader/PageHeader.js +18 -9
- package/dist/PageLayout/PageLayout.js +260 -67
- package/dist/PageLayout/index.d.ts +1 -3
- package/dist/PageLayout/usePaneWidth.d.ts +1 -55
- package/dist/PageLayout/usePaneWidth.js +5 -10
- package/dist/SelectPanel/SelectPanel.js +1 -1
- package/dist/TextInput/TextInput.js +10 -3
- package/dist/TooltipV2/Tooltip.js +9 -2
- package/dist/experimental/Tabs/types.d.ts +2 -2
- package/dist/experimental/Tabs/useTabList.js +15 -7
- package/dist/experimental/index.js +3 -3
- package/dist/hooks/useAnchoredPosition.js +1 -14
- package/dist/hooks/useMergedRefs.js +4 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +7 -10
- package/dist/hooks/useProvidedRefOrCreate.js +7 -10
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/package.json +1 -1
- package/dist/PageLayout/DragHandle.d.ts +0 -38
- package/dist/PageLayout/DragHandle.js +0 -220
|
@@ -7,12 +7,14 @@ import { useOverflow } from "../hooks/useOverflow.js";
|
|
|
7
7
|
import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
|
|
8
8
|
import PageLayout_module_css_default from "./PageLayout.module.css.js";
|
|
9
9
|
import { isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth } from "./usePaneWidth.js";
|
|
10
|
-
import {
|
|
10
|
+
import { removeDraggingStyles, setDraggingStyles } from "./paneUtils.js";
|
|
11
11
|
import { c } from "react-compiler-runtime";
|
|
12
12
|
import { clsx } from "clsx";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import React, { memo, useRef } from "react";
|
|
15
15
|
//#region src/PageLayout/PageLayout.tsx
|
|
16
|
+
const isArrowKey = (key) => key === "ArrowLeft" || key === "ArrowRight" || key === "ArrowUp" || key === "ArrowDown";
|
|
17
|
+
const isShrinkKey = (key) => key === "ArrowLeft" || key === "ArrowDown";
|
|
16
18
|
const PageLayoutContext = /*#__PURE__*/ React.createContext({
|
|
17
19
|
padding: "normal",
|
|
18
20
|
rowGap: "normal",
|
|
@@ -265,9 +267,9 @@ const VerticalDivider = /*#__PURE__*/ memo((t0) => {
|
|
|
265
267
|
});
|
|
266
268
|
VerticalDivider.displayName = "VerticalDivider";
|
|
267
269
|
const SidebarDivider = /*#__PURE__*/ memo(function SidebarDivider(t0) {
|
|
268
|
-
const $ = c(
|
|
270
|
+
const $ = c(22);
|
|
269
271
|
const { position, divider, resizable, minPaneWidth, maxPaneWidth, currentWidth, currentWidthRef, handleRef, sidebarRef, dragStartClientXRef, dragStartWidthRef, dragMaxWidthRef, getMaxPaneWidth, getDefaultWidth, saveWidth } = t0;
|
|
270
|
-
const { columnGap
|
|
272
|
+
const { columnGap } = React.useContext(PageLayoutContext);
|
|
271
273
|
const t1 = resizable ? "line" : divider;
|
|
272
274
|
const t2 = `var(--spacing-${columnGap})`;
|
|
273
275
|
let t3;
|
|
@@ -278,11 +280,9 @@ const SidebarDivider = /*#__PURE__*/ memo(function SidebarDivider(t0) {
|
|
|
278
280
|
} else t3 = $[1];
|
|
279
281
|
const t4 = t3;
|
|
280
282
|
let t5;
|
|
281
|
-
if ($[2] !==
|
|
283
|
+
if ($[2] !== currentWidth || $[3] !== currentWidthRef || $[4] !== dragMaxWidthRef || $[5] !== dragStartClientXRef || $[6] !== dragStartWidthRef || $[7] !== getDefaultWidth || $[8] !== getMaxPaneWidth || $[9] !== handleRef || $[10] !== maxPaneWidth || $[11] !== minPaneWidth || $[12] !== position || $[13] !== resizable || $[14] !== saveWidth || $[15] !== sidebarRef) {
|
|
282
284
|
t5 = resizable ? /*#__PURE__*/ jsx(DragHandle, {
|
|
283
285
|
handleRef,
|
|
284
|
-
dragTargetRef: paneRef,
|
|
285
|
-
contentWrapperRef,
|
|
286
286
|
"aria-valuemin": minPaneWidth,
|
|
287
287
|
"aria-valuemax": maxPaneWidth,
|
|
288
288
|
"aria-valuenow": currentWidth,
|
|
@@ -334,26 +334,24 @@ const SidebarDivider = /*#__PURE__*/ memo(function SidebarDivider(t0) {
|
|
|
334
334
|
saveWidth(resetWidth);
|
|
335
335
|
}
|
|
336
336
|
}) : null;
|
|
337
|
-
$[2] =
|
|
338
|
-
$[3] =
|
|
339
|
-
$[4] =
|
|
340
|
-
$[5] =
|
|
341
|
-
$[6] =
|
|
342
|
-
$[7] =
|
|
343
|
-
$[8] =
|
|
344
|
-
$[9] =
|
|
345
|
-
$[10] =
|
|
346
|
-
$[11] =
|
|
347
|
-
$[12] =
|
|
348
|
-
$[13] =
|
|
349
|
-
$[14] =
|
|
350
|
-
$[15] =
|
|
351
|
-
$[16] =
|
|
352
|
-
|
|
353
|
-
$[18] = t5;
|
|
354
|
-
} else t5 = $[18];
|
|
337
|
+
$[2] = currentWidth;
|
|
338
|
+
$[3] = currentWidthRef;
|
|
339
|
+
$[4] = dragMaxWidthRef;
|
|
340
|
+
$[5] = dragStartClientXRef;
|
|
341
|
+
$[6] = dragStartWidthRef;
|
|
342
|
+
$[7] = getDefaultWidth;
|
|
343
|
+
$[8] = getMaxPaneWidth;
|
|
344
|
+
$[9] = handleRef;
|
|
345
|
+
$[10] = maxPaneWidth;
|
|
346
|
+
$[11] = minPaneWidth;
|
|
347
|
+
$[12] = position;
|
|
348
|
+
$[13] = resizable;
|
|
349
|
+
$[14] = saveWidth;
|
|
350
|
+
$[15] = sidebarRef;
|
|
351
|
+
$[16] = t5;
|
|
352
|
+
} else t5 = $[16];
|
|
355
353
|
let t6;
|
|
356
|
-
if ($[
|
|
354
|
+
if ($[17] !== position || $[18] !== t1 || $[19] !== t4 || $[20] !== t5) {
|
|
357
355
|
t6 = /*#__PURE__*/ jsx(VerticalDivider, {
|
|
358
356
|
variant: t1,
|
|
359
357
|
position,
|
|
@@ -361,14 +359,212 @@ const SidebarDivider = /*#__PURE__*/ memo(function SidebarDivider(t0) {
|
|
|
361
359
|
style: t4,
|
|
362
360
|
children: t5
|
|
363
361
|
});
|
|
364
|
-
$[
|
|
365
|
-
$[
|
|
366
|
-
$[
|
|
367
|
-
$[
|
|
368
|
-
$[
|
|
369
|
-
} else t6 = $[
|
|
362
|
+
$[17] = position;
|
|
363
|
+
$[18] = t1;
|
|
364
|
+
$[19] = t4;
|
|
365
|
+
$[20] = t5;
|
|
366
|
+
$[21] = t6;
|
|
367
|
+
} else t6 = $[21];
|
|
370
368
|
return t6;
|
|
371
369
|
});
|
|
370
|
+
/**
|
|
371
|
+
* DragHandle - handles all pointer and keyboard interactions for resizing
|
|
372
|
+
* ARIA values are set in JSX for SSR accessibility,
|
|
373
|
+
* then updated via DOM manipulation during drag for performance
|
|
374
|
+
*/
|
|
375
|
+
const DragHandle = /*#__PURE__*/ memo(function DragHandle(t0) {
|
|
376
|
+
const $ = c(35);
|
|
377
|
+
const { handleRef, onDragStart, onDrag, onDragEnd, onDoubleClick, "aria-valuemin": ariaValueMin, "aria-valuemax": ariaValueMax, "aria-valuenow": ariaValueNow } = t0;
|
|
378
|
+
const stableOnDragStart = React.useRef(onDragStart);
|
|
379
|
+
const stableOnDrag = React.useRef(onDrag);
|
|
380
|
+
const stableOnDragEnd = React.useRef(onDragEnd);
|
|
381
|
+
let t1;
|
|
382
|
+
if ($[0] !== onDrag || $[1] !== onDragEnd || $[2] !== onDragStart) {
|
|
383
|
+
t1 = () => {
|
|
384
|
+
stableOnDragStart.current = onDragStart;
|
|
385
|
+
stableOnDrag.current = onDrag;
|
|
386
|
+
stableOnDragEnd.current = onDragEnd;
|
|
387
|
+
};
|
|
388
|
+
$[0] = onDrag;
|
|
389
|
+
$[1] = onDragEnd;
|
|
390
|
+
$[2] = onDragStart;
|
|
391
|
+
$[3] = t1;
|
|
392
|
+
} else t1 = $[3];
|
|
393
|
+
React.useEffect(t1);
|
|
394
|
+
const { paneRef, contentWrapperRef } = React.useContext(PageLayoutContext);
|
|
395
|
+
const isDraggingRef = React.useRef(false);
|
|
396
|
+
let t2;
|
|
397
|
+
if ($[4] !== contentWrapperRef || $[5] !== handleRef || $[6] !== paneRef) {
|
|
398
|
+
t2 = () => {
|
|
399
|
+
if (isDraggingRef.current) return;
|
|
400
|
+
setDraggingStyles({
|
|
401
|
+
handle: handleRef.current,
|
|
402
|
+
pane: paneRef.current,
|
|
403
|
+
contentWrapper: contentWrapperRef.current
|
|
404
|
+
});
|
|
405
|
+
isDraggingRef.current = true;
|
|
406
|
+
};
|
|
407
|
+
$[4] = contentWrapperRef;
|
|
408
|
+
$[5] = handleRef;
|
|
409
|
+
$[6] = paneRef;
|
|
410
|
+
$[7] = t2;
|
|
411
|
+
} else t2 = $[7];
|
|
412
|
+
const startDragging = t2;
|
|
413
|
+
let t3;
|
|
414
|
+
if ($[8] !== contentWrapperRef || $[9] !== handleRef || $[10] !== paneRef) {
|
|
415
|
+
t3 = () => {
|
|
416
|
+
if (!isDraggingRef.current) return;
|
|
417
|
+
removeDraggingStyles({
|
|
418
|
+
handle: handleRef.current,
|
|
419
|
+
pane: paneRef.current,
|
|
420
|
+
contentWrapper: contentWrapperRef.current
|
|
421
|
+
});
|
|
422
|
+
isDraggingRef.current = false;
|
|
423
|
+
};
|
|
424
|
+
$[8] = contentWrapperRef;
|
|
425
|
+
$[9] = handleRef;
|
|
426
|
+
$[10] = paneRef;
|
|
427
|
+
$[11] = t3;
|
|
428
|
+
} else t3 = $[11];
|
|
429
|
+
const endDragging = t3;
|
|
430
|
+
let t4;
|
|
431
|
+
if ($[12] !== startDragging) {
|
|
432
|
+
t4 = (event) => {
|
|
433
|
+
if (event.button !== 0) return;
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
const target = event.currentTarget;
|
|
436
|
+
try {
|
|
437
|
+
target.setPointerCapture(event.pointerId);
|
|
438
|
+
} catch {}
|
|
439
|
+
stableOnDragStart.current(event.clientX);
|
|
440
|
+
startDragging();
|
|
441
|
+
};
|
|
442
|
+
$[12] = startDragging;
|
|
443
|
+
$[13] = t4;
|
|
444
|
+
} else t4 = $[13];
|
|
445
|
+
const handlePointerDown = t4;
|
|
446
|
+
const rafIdRef = React.useRef(null);
|
|
447
|
+
const pendingClientXRef = React.useRef(null);
|
|
448
|
+
let t5;
|
|
449
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
450
|
+
t5 = (event_0) => {
|
|
451
|
+
if (!isDraggingRef.current) return;
|
|
452
|
+
event_0.preventDefault();
|
|
453
|
+
pendingClientXRef.current = event_0.clientX;
|
|
454
|
+
if (rafIdRef.current === null) rafIdRef.current = requestAnimationFrame(() => {
|
|
455
|
+
rafIdRef.current = null;
|
|
456
|
+
if (pendingClientXRef.current !== null) {
|
|
457
|
+
stableOnDrag.current(pendingClientXRef.current, false);
|
|
458
|
+
pendingClientXRef.current = null;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
$[14] = t5;
|
|
463
|
+
} else t5 = $[14];
|
|
464
|
+
const handlePointerMove = t5;
|
|
465
|
+
let t6;
|
|
466
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
467
|
+
t6 = (event_1) => {
|
|
468
|
+
if (!isDraggingRef.current) return;
|
|
469
|
+
event_1.preventDefault();
|
|
470
|
+
};
|
|
471
|
+
$[15] = t6;
|
|
472
|
+
} else t6 = $[15];
|
|
473
|
+
const handlePointerUp = t6;
|
|
474
|
+
let t7;
|
|
475
|
+
if ($[16] !== endDragging) {
|
|
476
|
+
t7 = () => {
|
|
477
|
+
if (!isDraggingRef.current) return;
|
|
478
|
+
if (rafIdRef.current !== null) {
|
|
479
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
480
|
+
rafIdRef.current = null;
|
|
481
|
+
pendingClientXRef.current = null;
|
|
482
|
+
}
|
|
483
|
+
endDragging();
|
|
484
|
+
stableOnDragEnd.current();
|
|
485
|
+
};
|
|
486
|
+
$[16] = endDragging;
|
|
487
|
+
$[17] = t7;
|
|
488
|
+
} else t7 = $[17];
|
|
489
|
+
const handleLostPointerCapture = t7;
|
|
490
|
+
let t8;
|
|
491
|
+
if ($[18] !== startDragging) {
|
|
492
|
+
t8 = (event_2) => {
|
|
493
|
+
if (!isArrowKey(event_2.key)) return;
|
|
494
|
+
event_2.preventDefault();
|
|
495
|
+
const delta = isShrinkKey(event_2.key) ? -3 : 3;
|
|
496
|
+
if (!isDraggingRef.current) startDragging();
|
|
497
|
+
stableOnDrag.current(delta, true);
|
|
498
|
+
};
|
|
499
|
+
$[18] = startDragging;
|
|
500
|
+
$[19] = t8;
|
|
501
|
+
} else t8 = $[19];
|
|
502
|
+
const handleKeyDown = t8;
|
|
503
|
+
let t9;
|
|
504
|
+
if ($[20] !== endDragging) {
|
|
505
|
+
t9 = (event_3) => {
|
|
506
|
+
if (!isArrowKey(event_3.key)) return;
|
|
507
|
+
event_3.preventDefault();
|
|
508
|
+
endDragging();
|
|
509
|
+
stableOnDragEnd.current();
|
|
510
|
+
};
|
|
511
|
+
$[20] = endDragging;
|
|
512
|
+
$[21] = t9;
|
|
513
|
+
} else t9 = $[21];
|
|
514
|
+
const handleKeyUp = t9;
|
|
515
|
+
let t10;
|
|
516
|
+
let t11;
|
|
517
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
518
|
+
t10 = () => () => {
|
|
519
|
+
if (rafIdRef.current !== null) {
|
|
520
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
521
|
+
rafIdRef.current = null;
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
t11 = [];
|
|
525
|
+
$[22] = t10;
|
|
526
|
+
$[23] = t11;
|
|
527
|
+
} else {
|
|
528
|
+
t10 = $[22];
|
|
529
|
+
t11 = $[23];
|
|
530
|
+
}
|
|
531
|
+
React.useEffect(t10, t11);
|
|
532
|
+
const t12 = ariaValueNow !== void 0 ? `Pane width ${ariaValueNow} pixels` : void 0;
|
|
533
|
+
let t13;
|
|
534
|
+
if ($[24] !== ariaValueMax || $[25] !== ariaValueMin || $[26] !== ariaValueNow || $[27] !== handleKeyDown || $[28] !== handleKeyUp || $[29] !== handleLostPointerCapture || $[30] !== handlePointerDown || $[31] !== handleRef || $[32] !== onDoubleClick || $[33] !== t12) {
|
|
535
|
+
t13 = /*#__PURE__*/ jsx("div", {
|
|
536
|
+
ref: handleRef,
|
|
537
|
+
className: PageLayout_module_css_default.DraggableHandle,
|
|
538
|
+
"data-component": "PageLayout.DragHandle",
|
|
539
|
+
role: "slider",
|
|
540
|
+
"aria-label": "Draggable pane splitter",
|
|
541
|
+
"aria-valuemin": ariaValueMin,
|
|
542
|
+
"aria-valuemax": ariaValueMax,
|
|
543
|
+
"aria-valuenow": ariaValueNow,
|
|
544
|
+
"aria-valuetext": t12,
|
|
545
|
+
tabIndex: 0,
|
|
546
|
+
onPointerDown: handlePointerDown,
|
|
547
|
+
onPointerMove: handlePointerMove,
|
|
548
|
+
onPointerUp: handlePointerUp,
|
|
549
|
+
onLostPointerCapture: handleLostPointerCapture,
|
|
550
|
+
onKeyDown: handleKeyDown,
|
|
551
|
+
onKeyUp: handleKeyUp,
|
|
552
|
+
onDoubleClick
|
|
553
|
+
});
|
|
554
|
+
$[24] = ariaValueMax;
|
|
555
|
+
$[25] = ariaValueMin;
|
|
556
|
+
$[26] = ariaValueNow;
|
|
557
|
+
$[27] = handleKeyDown;
|
|
558
|
+
$[28] = handleKeyUp;
|
|
559
|
+
$[29] = handleLostPointerCapture;
|
|
560
|
+
$[30] = handlePointerDown;
|
|
561
|
+
$[31] = handleRef;
|
|
562
|
+
$[32] = onDoubleClick;
|
|
563
|
+
$[33] = t12;
|
|
564
|
+
$[34] = t13;
|
|
565
|
+
} else t13 = $[34];
|
|
566
|
+
return t13;
|
|
567
|
+
});
|
|
372
568
|
const Header = (t0) => {
|
|
373
569
|
const $ = c(29);
|
|
374
570
|
const { "aria-label": label, "aria-labelledby": labelledBy, padding: t1, divider: t2, dividerWhenNarrow: t3, hidden: t4, children, style, className, "data-component": t5 } = t0;
|
|
@@ -549,7 +745,7 @@ const overflowProps = {
|
|
|
549
745
|
role: "region"
|
|
550
746
|
};
|
|
551
747
|
const Pane = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
552
|
-
const $ = c(
|
|
748
|
+
const $ = c(97);
|
|
553
749
|
const { "aria-label": label, "aria-labelledby": labelledBy, position: t1, positionWhenNarrow: t2, width: t3, minWidth: t4, currentWidth: controlledWidth, onResizeEnd, padding: t5, resizable: t6, widthStorageKey: t7, divider: t8, dividerWhenNarrow: t9, sticky: t10, offsetHeader: t11, hidden: t12, children, id, className, style, "data-component": t13 } = t0;
|
|
554
750
|
const responsivePosition = t1 === void 0 ? "end" : t1;
|
|
555
751
|
const positionWhenNarrow = t2 === void 0 ? "inherit" : t2;
|
|
@@ -802,11 +998,9 @@ const Pane = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
|
802
998
|
} else t48 = $[70];
|
|
803
999
|
const t49 = t48;
|
|
804
1000
|
let t50;
|
|
805
|
-
if ($[71] !==
|
|
1001
|
+
if ($[71] !== currentWidth || $[72] !== currentWidthRef || $[73] !== getDefaultWidth || $[74] !== getMaxPaneWidth || $[75] !== maxPaneWidth || $[76] !== minPaneWidth || $[77] !== paneRef || $[78] !== position || $[79] !== resizable || $[80] !== saveWidth) {
|
|
806
1002
|
t50 = resizable ? /*#__PURE__*/ jsx(DragHandle, {
|
|
807
1003
|
handleRef,
|
|
808
|
-
dragTargetRef: paneRef,
|
|
809
|
-
contentWrapperRef,
|
|
810
1004
|
"aria-valuemin": minPaneWidth,
|
|
811
1005
|
"aria-valuemax": maxPaneWidth,
|
|
812
1006
|
"aria-valuenow": currentWidth,
|
|
@@ -858,21 +1052,20 @@ const Pane = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
|
858
1052
|
saveWidth(resetWidth);
|
|
859
1053
|
}
|
|
860
1054
|
}) : null;
|
|
861
|
-
$[71] =
|
|
862
|
-
$[72] =
|
|
863
|
-
$[73] =
|
|
864
|
-
$[74] =
|
|
865
|
-
$[75] =
|
|
866
|
-
$[76] =
|
|
867
|
-
$[77] =
|
|
868
|
-
$[78] =
|
|
869
|
-
$[79] =
|
|
870
|
-
$[80] =
|
|
871
|
-
$[81] =
|
|
872
|
-
|
|
873
|
-
} else t50 = $[82];
|
|
1055
|
+
$[71] = currentWidth;
|
|
1056
|
+
$[72] = currentWidthRef;
|
|
1057
|
+
$[73] = getDefaultWidth;
|
|
1058
|
+
$[74] = getMaxPaneWidth;
|
|
1059
|
+
$[75] = maxPaneWidth;
|
|
1060
|
+
$[76] = minPaneWidth;
|
|
1061
|
+
$[77] = paneRef;
|
|
1062
|
+
$[78] = position;
|
|
1063
|
+
$[79] = resizable;
|
|
1064
|
+
$[80] = saveWidth;
|
|
1065
|
+
$[81] = t50;
|
|
1066
|
+
} else t50 = $[81];
|
|
874
1067
|
let t51;
|
|
875
|
-
if ($[
|
|
1068
|
+
if ($[82] !== positionProp || $[83] !== resizable || $[84] !== t46 || $[85] !== t49 || $[86] !== t50) {
|
|
876
1069
|
t51 = /*#__PURE__*/ jsx(VerticalDivider, {
|
|
877
1070
|
variant: t46,
|
|
878
1071
|
draggable: resizable,
|
|
@@ -881,15 +1074,15 @@ const Pane = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
|
881
1074
|
style: t49,
|
|
882
1075
|
children: t50
|
|
883
1076
|
});
|
|
884
|
-
$[
|
|
885
|
-
$[
|
|
886
|
-
$[
|
|
887
|
-
$[
|
|
888
|
-
$[
|
|
889
|
-
$[
|
|
890
|
-
} else t51 = $[
|
|
1077
|
+
$[82] = positionProp;
|
|
1078
|
+
$[83] = resizable;
|
|
1079
|
+
$[84] = t46;
|
|
1080
|
+
$[85] = t49;
|
|
1081
|
+
$[86] = t50;
|
|
1082
|
+
$[87] = t51;
|
|
1083
|
+
} else t51 = $[87];
|
|
891
1084
|
let t52;
|
|
892
|
-
if ($[
|
|
1085
|
+
if ($[88] !== t19 || $[89] !== t24 || $[90] !== t25 || $[91] !== t26 || $[92] !== t27 || $[93] !== t32 || $[94] !== t45 || $[95] !== t51) {
|
|
893
1086
|
t52 = /*#__PURE__*/ jsxs("div", {
|
|
894
1087
|
className: t19,
|
|
895
1088
|
style: t24,
|
|
@@ -902,16 +1095,16 @@ const Pane = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
|
902
1095
|
t51
|
|
903
1096
|
]
|
|
904
1097
|
});
|
|
905
|
-
$[
|
|
906
|
-
$[
|
|
907
|
-
$[
|
|
908
|
-
$[
|
|
909
|
-
$[
|
|
910
|
-
$[
|
|
911
|
-
$[
|
|
912
|
-
$[
|
|
913
|
-
$[
|
|
914
|
-
} else t52 = $[
|
|
1098
|
+
$[88] = t19;
|
|
1099
|
+
$[89] = t24;
|
|
1100
|
+
$[90] = t25;
|
|
1101
|
+
$[91] = t26;
|
|
1102
|
+
$[92] = t27;
|
|
1103
|
+
$[93] = t32;
|
|
1104
|
+
$[94] = t45;
|
|
1105
|
+
$[95] = t51;
|
|
1106
|
+
$[96] = t52;
|
|
1107
|
+
} else t52 = $[96];
|
|
915
1108
|
return t52;
|
|
916
1109
|
});
|
|
917
1110
|
Pane.displayName = "PageLayout.Pane";
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { CustomWidthOptions, PaneWidth, PaneWidthValue, UsePaneWidthOptions, UsePaneWidthResult, defaultPaneWidth, usePaneWidth } from "./usePaneWidth.js";
|
|
2
1
|
import { PageLayout, PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneBaseProps, PageLayoutPaneProps, PageLayoutProps, PageLayoutSidebarBaseProps, PageLayoutSidebarProps } from "./PageLayout.js";
|
|
3
|
-
|
|
4
|
-
export { type CustomWidthOptions, DragHandle, type DragHandleProps, PageLayout, PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneBaseProps, PageLayoutPaneProps, PageLayoutProps, PageLayoutSidebarBaseProps, PageLayoutSidebarProps, type PaneWidth, type PaneWidthValue, type UsePaneWidthOptions, type UsePaneWidthResult, defaultPaneWidth, usePaneWidth };
|
|
2
|
+
export { PageLayout, PageLayoutContentProps, PageLayoutFooterProps, PageLayoutHeaderProps, PageLayoutPaneBaseProps, PageLayoutPaneProps, PageLayoutProps, PageLayoutSidebarBaseProps, PageLayoutSidebarProps };
|
|
@@ -14,59 +14,5 @@ type PaneWidth = 'small' | 'medium' | 'large';
|
|
|
14
14
|
* - `CustomWidthOptions`: Explicit min/default/max constraints
|
|
15
15
|
*/
|
|
16
16
|
type PaneWidthValue = PaneWidth | CustomWidthOptions;
|
|
17
|
-
type UsePaneWidthOptions = {
|
|
18
|
-
width: PaneWidthValue;
|
|
19
|
-
minWidth: number;
|
|
20
|
-
resizable: boolean; /** localStorage key for persisting width. When undefined, localStorage is not used. */
|
|
21
|
-
widthStorageKey?: string;
|
|
22
|
-
paneRef: React.RefObject<HTMLDivElement | null>;
|
|
23
|
-
handleRef: React.RefObject<HTMLDivElement | null>;
|
|
24
|
-
/**
|
|
25
|
-
* Optional ref to the content wrapper element. Only used by PageLayout for its
|
|
26
|
-
* viewport/content math during resize. Standalone consumers can omit this.
|
|
27
|
-
*/
|
|
28
|
-
contentWrapperRef?: React.RefObject<HTMLDivElement | null>;
|
|
29
|
-
/**
|
|
30
|
-
* When true, custom max width values are capped to the viewport-based max.
|
|
31
|
-
* This prevents overflow in non-wrapping flex layouts (e.g., Sidebar).
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
constrainToViewport?: boolean; /** Callback fired when a resize operation ends (drag release or keyboard key up) */
|
|
35
|
-
onResizeEnd?: (width: number) => void; /** Current/controlled width value in pixels (used instead of internal state; default from `width` is still used for reset) */
|
|
36
|
-
currentWidth?: number;
|
|
37
|
-
};
|
|
38
|
-
type UsePaneWidthResult = {
|
|
39
|
-
/** Current width for React state (used in ARIA attributes) */currentWidth: number; /** Mutable ref tracking width during drag operations */
|
|
40
|
-
currentWidthRef: React.MutableRefObject<number>; /** Minimum allowed pane width */
|
|
41
|
-
minPaneWidth: number; /** Maximum allowed pane width (updates on viewport resize) */
|
|
42
|
-
maxPaneWidth: number; /** Calculate current max width constraint */
|
|
43
|
-
getMaxPaneWidth: () => number; /** Persist width to localStorage and sync React state */
|
|
44
|
-
saveWidth: (value: number) => void; /** Reset to default width */
|
|
45
|
-
getDefaultWidth: () => number;
|
|
46
|
-
};
|
|
47
|
-
/** Default widths for preset size options */
|
|
48
|
-
declare const defaultPaneWidth: Record<PaneWidth, number>;
|
|
49
|
-
/**
|
|
50
|
-
* Manages pane width state with storage persistence and viewport constraints.
|
|
51
|
-
* Handles initialization from storage, clamping on viewport resize, and provides
|
|
52
|
-
* functions to save and reset width.
|
|
53
|
-
*
|
|
54
|
-
* Storage behavior:
|
|
55
|
-
* - When `resizable` is `true` and `onResizeEnd` is not provided: Uses localStorage
|
|
56
|
-
* - When `onResizeEnd` is provided: Calls the callback instead of localStorage
|
|
57
|
-
* - When `resizable` is `false` or `undefined`: Not resizable, no persistence
|
|
58
|
-
*/
|
|
59
|
-
declare function usePaneWidth({
|
|
60
|
-
width,
|
|
61
|
-
minWidth,
|
|
62
|
-
resizable,
|
|
63
|
-
widthStorageKey,
|
|
64
|
-
paneRef,
|
|
65
|
-
handleRef,
|
|
66
|
-
contentWrapperRef,
|
|
67
|
-
constrainToViewport,
|
|
68
|
-
onResizeEnd,
|
|
69
|
-
currentWidth: controlledWidth
|
|
70
|
-
}: UsePaneWidthOptions): UsePaneWidthResult;
|
|
71
17
|
//#endregion
|
|
72
|
-
export { CustomWidthOptions, PaneWidth, PaneWidthValue
|
|
18
|
+
export { CustomWidthOptions, PaneWidth, PaneWidthValue };
|
|
@@ -47,18 +47,13 @@ function getMaxWidthDiffFromViewport() {
|
|
|
47
47
|
if (!canUseDOM) return DEFAULT_MAX_WIDTH_DIFF;
|
|
48
48
|
return window.innerWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT ? WIDE_MAX_WIDTH_DIFF : DEFAULT_MAX_WIDTH_DIFF;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
* Default formatter for the drag handle's `aria-valuetext`.
|
|
52
|
-
* Kept in sync between the rendered attribute and drag-time DOM writes.
|
|
53
|
-
*/
|
|
54
|
-
const defaultFormatValueText = (valueNow) => `Pane width ${valueNow} pixels`;
|
|
55
|
-
const updateAriaValues = (handle, values, formatValueText = defaultFormatValueText) => {
|
|
50
|
+
const updateAriaValues = (handle, values) => {
|
|
56
51
|
if (!handle) return;
|
|
57
52
|
if (values.min !== void 0) handle.setAttribute("aria-valuemin", String(values.min));
|
|
58
53
|
if (values.max !== void 0) handle.setAttribute("aria-valuemax", String(values.max));
|
|
59
54
|
if (values.current !== void 0) {
|
|
60
55
|
handle.setAttribute("aria-valuenow", String(values.current));
|
|
61
|
-
handle.setAttribute("aria-valuetext",
|
|
56
|
+
handle.setAttribute("aria-valuetext", `Pane width ${values.current} pixels`);
|
|
62
57
|
}
|
|
63
58
|
};
|
|
64
59
|
const localStoragePersister = {
|
|
@@ -279,14 +274,14 @@ function usePaneWidth(t0) {
|
|
|
279
274
|
if (isResizing) return;
|
|
280
275
|
isResizing = true;
|
|
281
276
|
(_paneRef$current4 = paneRef.current) === null || _paneRef$current4 === void 0 || _paneRef$current4.setAttribute("data-dragging", "true");
|
|
282
|
-
|
|
277
|
+
(_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 || _contentWrapperRef$cu.setAttribute("data-dragging", "true");
|
|
283
278
|
};
|
|
284
279
|
const endResizeOptimizations = () => {
|
|
285
280
|
var _paneRef$current5, _contentWrapperRef$cu2;
|
|
286
281
|
if (!isResizing) return;
|
|
287
282
|
isResizing = false;
|
|
288
283
|
(_paneRef$current5 = paneRef.current) === null || _paneRef$current5 === void 0 || _paneRef$current5.removeAttribute("data-dragging");
|
|
289
|
-
|
|
284
|
+
(_contentWrapperRef$cu2 = contentWrapperRef.current) === null || _contentWrapperRef$cu2 === void 0 || _contentWrapperRef$cu2.removeAttribute("data-dragging");
|
|
290
285
|
};
|
|
291
286
|
const handleResize = () => {
|
|
292
287
|
startResizeOptimizations();
|
|
@@ -362,4 +357,4 @@ function usePaneWidth(t0) {
|
|
|
362
357
|
return t14;
|
|
363
358
|
}
|
|
364
359
|
//#endregion
|
|
365
|
-
export { DEFAULT_MAX_WIDTH_DIFF, DEFAULT_SIDEBAR_MAX_WIDTH_DIFF,
|
|
360
|
+
export { DEFAULT_MAX_WIDTH_DIFF, DEFAULT_SIDEBAR_MAX_WIDTH_DIFF, defaultPaneWidth, getDefaultPaneWidth, getMaxWidthDiffFromViewport, isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth };
|
|
@@ -2,13 +2,13 @@ import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
|
2
2
|
import { useProvidedStateOrCreate } from "../hooks/useProvidedStateOrCreate.js";
|
|
3
3
|
import { isAlphabetKey } from "../hooks/useMnemonics.js";
|
|
4
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
5
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
6
|
import useSafeTimeout from "../hooks/useSafeTimeout.js";
|
|
6
7
|
import { IconButton } from "../Button/IconButton.js";
|
|
7
8
|
import { LinkButton } from "../Button/LinkButton.js";
|
|
8
9
|
import { ButtonComponent } from "../Button/Button.js";
|
|
9
10
|
import { useResponsiveValue } from "../hooks/useResponsiveValue.js";
|
|
10
11
|
import Heading from "../Heading/Heading.js";
|
|
11
|
-
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
12
12
|
import { AnchoredOverlay } from "../AnchoredOverlay/AnchoredOverlay.js";
|
|
13
13
|
import { Banner } from "../Banner/index.js";
|
|
14
14
|
import { useFormControlContext } from "../FormControl/_FormControlContext.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { AriaStatus } from "../live-region/AriaStatus.js";
|
|
4
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
3
5
|
import Text_default from "../Text/Text.js";
|
|
4
6
|
import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
|
|
5
7
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -11,14 +13,19 @@ import UnstyledTextInput from "../internal/components/UnstyledTextInput.js";
|
|
|
11
13
|
import { getCharacterCountState } from "../utils/character-counter.js";
|
|
12
14
|
import { clsx } from "clsx";
|
|
13
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import React, { useCallback, useId, useState } from "react";
|
|
16
|
+
import React, { useCallback, useId, useRef, useState } from "react";
|
|
15
17
|
import { isValidElementType } from "react-is";
|
|
16
18
|
import { AlertFillIcon } from "@primer/octicons-react";
|
|
17
19
|
//#region src/TextInput/TextInput.tsx
|
|
18
20
|
const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, trailingAction, block, className, contrast, disabled, loading, loaderPosition = "auto", loaderText = "Loading", monospace, validationStatus, size: sizeProp, onFocus, onBlur, variant: variantProp, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, type = "text", required, characterLimit, onChange, value, defaultValue, "data-component": dataComponent, ...inputProps }, ref) => {
|
|
19
21
|
var _counter$isOverLimit;
|
|
20
22
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
21
|
-
const
|
|
23
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
24
|
+
const internalRef = useRef(null);
|
|
25
|
+
const mergedRef = useMergedRefs(internalRef, ref);
|
|
26
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(ref);
|
|
27
|
+
const inputRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
28
|
+
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
22
29
|
const isControlled = value !== void 0;
|
|
23
30
|
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== void 0 ? String(defaultValue).length : 0);
|
|
24
31
|
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
@@ -88,7 +95,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
|
|
|
88
95
|
children: typeof LeadingVisual !== "string" && isValidElementType(LeadingVisual) ? /*#__PURE__*/ jsx(LeadingVisual, {}) : LeadingVisual
|
|
89
96
|
}),
|
|
90
97
|
/*#__PURE__*/ jsx(UnstyledTextInput, {
|
|
91
|
-
ref:
|
|
98
|
+
ref: appliedRef,
|
|
92
99
|
disabled,
|
|
93
100
|
onFocus: handleInputFocus,
|
|
94
101
|
onBlur: handleInputBlur,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
1
2
|
import { useProvidedRefOrCreate } from "../hooks/useProvidedRefOrCreate.js";
|
|
2
3
|
import { useOnEscapePress } from "../hooks/useOnEscapePress.js";
|
|
3
4
|
import { useId as useId$1 } from "../hooks/useId.js";
|
|
4
5
|
import { warning } from "../utils/warning.js";
|
|
6
|
+
import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
|
|
5
7
|
import { invariant } from "../utils/invariant.js";
|
|
6
8
|
import Tooltip_module_css_default from "./Tooltip.module.css.js";
|
|
7
9
|
import VisuallyHidden from "../_VisuallyHidden.js";
|
|
@@ -80,7 +82,12 @@ const emptyKeybindingHints = [];
|
|
|
80
82
|
const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type = "description", children, id, className, keybindingHint = emptyKeybindingHints, delay = "short", _privateDisableTooltip = false, ...rest }, forwardedRef) => {
|
|
81
83
|
const tooltipId = useId$1(id);
|
|
82
84
|
const child = Children.only(children);
|
|
83
|
-
const
|
|
85
|
+
const mergedRefEnabled = useFeatureFlag("primer_react_merged_forwarded_refs");
|
|
86
|
+
const internalRef = useRef(null);
|
|
87
|
+
const mergedTriggerRef = useMergedRefs(internalRef, forwardedRef);
|
|
88
|
+
const providedOrCreatedRef = useProvidedRefOrCreate(forwardedRef);
|
|
89
|
+
const triggerRef = mergedRefEnabled ? internalRef : providedOrCreatedRef;
|
|
90
|
+
const appliedTriggerRef = mergedRefEnabled ? mergedTriggerRef : providedOrCreatedRef;
|
|
84
91
|
const tooltipElRef = useRef(null);
|
|
85
92
|
const [calculatedDirection, setCalculatedDirection] = useState(direction);
|
|
86
93
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
@@ -157,7 +164,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
157
164
|
return /*#__PURE__*/ jsx(TooltipContext.Provider, {
|
|
158
165
|
value,
|
|
159
166
|
children: /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
|
|
160
|
-
ref:
|
|
167
|
+
ref: appliedTriggerRef,
|
|
161
168
|
"aria-describedby": (() => {
|
|
162
169
|
if (type !== "description") return child.props["aria-describedby"];
|
|
163
170
|
const existingDescribedBy = child.props["aria-describedby"];
|
|
@@ -73,7 +73,7 @@ type TabPanelProps = {
|
|
|
73
73
|
value: string;
|
|
74
74
|
};
|
|
75
75
|
type TabListHookProps<T extends HTMLElement> = TabListProps & {
|
|
76
|
-
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.
|
|
76
|
+
/** Optional ref to use for the tablist. If none is provided, one will be generated automatically */ref?: React.Ref<T | null>;
|
|
77
77
|
};
|
|
78
78
|
type TabListHookResult<T extends HTMLElement> = {
|
|
79
79
|
/** Props to be spread onto the tablist element */tabListProps: {
|
|
@@ -81,7 +81,7 @@ type TabListHookResult<T extends HTMLElement> = {
|
|
|
81
81
|
'aria-orientation': AriaAttributes['aria-orientation'];
|
|
82
82
|
'aria-label': AriaAttributes['aria-label'];
|
|
83
83
|
'aria-labelledby': AriaAttributes['aria-labelledby'];
|
|
84
|
-
ref: React.
|
|
84
|
+
ref: React.Ref<T | null>;
|
|
85
85
|
role: 'tablist';
|
|
86
86
|
};
|
|
87
87
|
};
|