@primer/react 38.47.0-rc.0f998b98f → 38.47.0-rc.207872287
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 +2 -0
- package/dist/ActionList/List.js +2 -2
- package/dist/Checkbox/Checkbox.js +4 -4
- package/dist/PageLayout/usePaneWidth.js +27 -25
- package/dist/TextInput/TextInput.js +2 -2
- package/dist/TreeView/useTreeRovingTabIndex.js +11 -10
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +6 -2
- package/dist/hooks/useRefObjectAsForwardedRef.js +2 -2
- package/dist/hooks/useSyncedState.js +15 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
- [#8708](https://github.com/primer/react/pull/8708) [`16c41d3`](https://github.com/primer/react/commit/16c41d3e57bb7358d887c613aaeb22aaea3a0d97) Thanks [@vivanvv](https://github.com/vivanvv)! - Pagination: Disable Next for empty results when page numbers are hidden.
|
|
14
14
|
|
|
15
|
+
- [#8731](https://github.com/primer/react/pull/8731) [`cb71c93`](https://github.com/primer/react/commit/cb71c93fada0adb063905e1894fe1667c0e3c3fa) Thanks [@dependabot](https://github.com/apps/dependabot)! - PageLayout and TreeView: Preserve pane resizing and keyboard focus behavior
|
|
16
|
+
|
|
15
17
|
## 38.46.0
|
|
16
18
|
|
|
17
19
|
### Minor Changes
|
package/dist/ActionList/List.js
CHANGED
|
@@ -121,7 +121,7 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
121
121
|
} else t10 = $[21];
|
|
122
122
|
const listContextValue = t10;
|
|
123
123
|
let t11;
|
|
124
|
-
if ($[22] !== readRef
|
|
124
|
+
if ($[22] !== readRef) {
|
|
125
125
|
t11 = () => {
|
|
126
126
|
const list = readRef.current;
|
|
127
127
|
if (!list) return;
|
|
@@ -130,7 +130,7 @@ const UnwrappedList = (props, forwardedRef) => {
|
|
|
130
130
|
if (hasMixed && current !== "true") list.setAttribute("data-mixed-descriptions", "true");
|
|
131
131
|
else if (!hasMixed && current !== null) list.removeAttribute("data-mixed-descriptions");
|
|
132
132
|
};
|
|
133
|
-
$[22] = readRef
|
|
133
|
+
$[22] = readRef;
|
|
134
134
|
$[23] = t11;
|
|
135
135
|
} else t11 = $[23];
|
|
136
136
|
useIsomorphicLayoutEffect(t11);
|
|
@@ -61,7 +61,7 @@ const Checkbox = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
61
61
|
const appliedRef = mergedRefEnabled ? mergedRef : providedOrCreatedRef;
|
|
62
62
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
63
63
|
let t1;
|
|
64
|
-
if ($[12] !== checkboxGroupContext || $[13] !== indeterminate || $[14] !== onChange || $[15] !== readRef
|
|
64
|
+
if ($[12] !== checkboxGroupContext || $[13] !== indeterminate || $[14] !== onChange || $[15] !== readRef) {
|
|
65
65
|
t1 = (e) => {
|
|
66
66
|
checkboxGroupContext.onChange && checkboxGroupContext.onChange(e);
|
|
67
67
|
onChange && onChange(e);
|
|
@@ -73,7 +73,7 @@ const Checkbox = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
73
73
|
$[12] = checkboxGroupContext;
|
|
74
74
|
$[13] = indeterminate;
|
|
75
75
|
$[14] = onChange;
|
|
76
|
-
$[15] = readRef
|
|
76
|
+
$[15] = readRef;
|
|
77
77
|
$[16] = t1;
|
|
78
78
|
} else t1 = $[16];
|
|
79
79
|
const handleOnChange = t1;
|
|
@@ -110,12 +110,12 @@ const Checkbox = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
110
110
|
} else t5 = $[27];
|
|
111
111
|
const inputProps = t5;
|
|
112
112
|
let t6;
|
|
113
|
-
if ($[28] !== indeterminate || $[29] !== readRef
|
|
113
|
+
if ($[28] !== indeterminate || $[29] !== readRef) {
|
|
114
114
|
t6 = () => {
|
|
115
115
|
if (readRef.current) readRef.current.indeterminate = indeterminate || false;
|
|
116
116
|
};
|
|
117
117
|
$[28] = indeterminate;
|
|
118
|
-
$[29] = readRef
|
|
118
|
+
$[29] = readRef;
|
|
119
119
|
$[30] = t6;
|
|
120
120
|
} else t6 = $[30];
|
|
121
121
|
let t7;
|
|
@@ -235,12 +235,12 @@ function usePaneWidth(t0) {
|
|
|
235
235
|
t13 = () => {
|
|
236
236
|
var _paneRef$current3;
|
|
237
237
|
if (!resizable) return;
|
|
238
|
-
|
|
238
|
+
const viewportState = { lastWidth: window.innerWidth };
|
|
239
239
|
const syncAll = () => {
|
|
240
240
|
var _paneRef$current;
|
|
241
241
|
const currentViewportWidth = window.innerWidth;
|
|
242
|
-
const crossedBreakpoint =
|
|
243
|
-
|
|
242
|
+
const crossedBreakpoint = viewportState.lastWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT || viewportState.lastWidth >= DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT && currentViewportWidth < DEFAULT_PANE_MAX_WIDTH_DIFF_BREAKPOINT;
|
|
243
|
+
viewportState.lastWidth = currentViewportWidth;
|
|
244
244
|
if (crossedBreakpoint) maxWidthDiffRef.current = getMaxWidthDiffFromViewport();
|
|
245
245
|
const actualMax = getMaxPaneWidthRef.current();
|
|
246
246
|
(_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 || _paneRef$current.style.setProperty("--pane-max-width", `${actualMax}px`);
|
|
@@ -275,50 +275,52 @@ function usePaneWidth(t0) {
|
|
|
275
275
|
setMaxPaneWidth(initialMax);
|
|
276
276
|
});
|
|
277
277
|
if (customMaxWidth !== null && !constrainToViewport) return;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
const resizeState = {
|
|
279
|
+
lastUpdateTime: 0,
|
|
280
|
+
pendingUpdate: false,
|
|
281
|
+
rafId: null,
|
|
282
|
+
debounceId: null,
|
|
283
|
+
isResizing: false
|
|
284
|
+
};
|
|
283
285
|
const startResizeOptimizations = () => {
|
|
284
286
|
var _paneRef$current4, _contentWrapperRef$cu;
|
|
285
|
-
if (isResizing) return;
|
|
286
|
-
isResizing = true;
|
|
287
|
+
if (resizeState.isResizing) return;
|
|
288
|
+
resizeState.isResizing = true;
|
|
287
289
|
(_paneRef$current4 = paneRef.current) === null || _paneRef$current4 === void 0 || _paneRef$current4.setAttribute("data-dragging", "true");
|
|
288
290
|
contentWrapperRef === null || contentWrapperRef === void 0 || (_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 || _contentWrapperRef$cu.setAttribute("data-dragging", "true");
|
|
289
291
|
};
|
|
290
292
|
const endResizeOptimizations = () => {
|
|
291
293
|
var _paneRef$current5, _contentWrapperRef$cu2;
|
|
292
|
-
if (!isResizing) return;
|
|
293
|
-
isResizing = false;
|
|
294
|
+
if (!resizeState.isResizing) return;
|
|
295
|
+
resizeState.isResizing = false;
|
|
294
296
|
(_paneRef$current5 = paneRef.current) === null || _paneRef$current5 === void 0 || _paneRef$current5.removeAttribute("data-dragging");
|
|
295
297
|
contentWrapperRef === null || contentWrapperRef === void 0 || (_contentWrapperRef$cu2 = contentWrapperRef.current) === null || _contentWrapperRef$cu2 === void 0 || _contentWrapperRef$cu2.removeAttribute("data-dragging");
|
|
296
298
|
};
|
|
297
299
|
const handleResize = () => {
|
|
298
300
|
startResizeOptimizations();
|
|
299
301
|
const now = Date.now();
|
|
300
|
-
if (now - lastUpdateTime >= 16) {
|
|
301
|
-
lastUpdateTime = now;
|
|
302
|
+
if (now - resizeState.lastUpdateTime >= 16) {
|
|
303
|
+
resizeState.lastUpdateTime = now;
|
|
302
304
|
syncAll();
|
|
303
|
-
} else if (!pendingUpdate) {
|
|
304
|
-
pendingUpdate = true;
|
|
305
|
-
rafId = requestAnimationFrame(() => {
|
|
306
|
-
pendingUpdate = false;
|
|
307
|
-
rafId = null;
|
|
308
|
-
lastUpdateTime = Date.now();
|
|
305
|
+
} else if (!resizeState.pendingUpdate) {
|
|
306
|
+
resizeState.pendingUpdate = true;
|
|
307
|
+
resizeState.rafId = requestAnimationFrame(() => {
|
|
308
|
+
resizeState.pendingUpdate = false;
|
|
309
|
+
resizeState.rafId = null;
|
|
310
|
+
resizeState.lastUpdateTime = Date.now();
|
|
309
311
|
syncAll();
|
|
310
312
|
});
|
|
311
313
|
}
|
|
312
|
-
if (debounceId !== null) clearTimeout(debounceId);
|
|
313
|
-
debounceId = setTimeout(() => {
|
|
314
|
-
debounceId = null;
|
|
314
|
+
if (resizeState.debounceId !== null) clearTimeout(resizeState.debounceId);
|
|
315
|
+
resizeState.debounceId = setTimeout(() => {
|
|
316
|
+
resizeState.debounceId = null;
|
|
315
317
|
endResizeOptimizations();
|
|
316
318
|
}, 150);
|
|
317
319
|
};
|
|
318
320
|
window.addEventListener("resize", handleResize);
|
|
319
321
|
return () => {
|
|
320
|
-
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
321
|
-
if (debounceId !== null) clearTimeout(debounceId);
|
|
322
|
+
if (resizeState.rafId !== null) cancelAnimationFrame(resizeState.rafId);
|
|
323
|
+
if (resizeState.debounceId !== null) clearTimeout(resizeState.debounceId);
|
|
322
324
|
endResizeOptimizations();
|
|
323
325
|
window.removeEventListener("resize", handleResize);
|
|
324
326
|
};
|
|
@@ -54,7 +54,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
54
54
|
const showTrailingLoadingIndicator = loading && (loaderPosition === "trailing" || Boolean(loaderPosition === "auto" && !LeadingVisual));
|
|
55
55
|
const isSegmentedInputType = type === "date" || type === "time" || type === "datetime-local";
|
|
56
56
|
let t6;
|
|
57
|
-
if ($[4] !== isSegmentedInputType || $[5] !== readRef
|
|
57
|
+
if ($[4] !== isSegmentedInputType || $[5] !== readRef) {
|
|
58
58
|
t6 = (e) => {
|
|
59
59
|
if (e.target !== readRef.current || !isSegmentedInputType) {
|
|
60
60
|
var _readRef$current;
|
|
@@ -62,7 +62,7 @@ const TextInput = /*#__PURE__*/ React.forwardRef((t0, ref) => {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
$[4] = isSegmentedInputType;
|
|
65
|
-
$[5] = readRef
|
|
65
|
+
$[5] = readRef;
|
|
66
66
|
$[6] = t6;
|
|
67
67
|
} else t6 = $[6];
|
|
68
68
|
const focusInput = t6;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c } from "../utils/react-compiler-runtime.js";
|
|
2
2
|
import { getNextFocusableElement } from "./useRovingTabIndex.js";
|
|
3
|
-
import { useEffect } from "react";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
4
|
import { isEditableElement } from "@primer/behaviors/utils";
|
|
5
5
|
// src/TreeView/useTreeRovingTabIndex.ts
|
|
6
6
|
const TREE_ITEM = "[role=\"treeitem\"]";
|
|
@@ -43,20 +43,21 @@ function useTreeRovingTabIndex(t0) {
|
|
|
43
43
|
const $ = c(5);
|
|
44
44
|
const { containerRef, mouseDownRef, preventScroll: t1 } = t0;
|
|
45
45
|
const preventScroll = t1 === void 0 ? true : t1;
|
|
46
|
+
const tabStopRef = useRef(null);
|
|
46
47
|
let t2;
|
|
47
48
|
let t3;
|
|
48
49
|
if ($[0] !== containerRef || $[1] !== mouseDownRef || $[2] !== preventScroll) {
|
|
49
50
|
t2 = () => {
|
|
51
|
+
tabStopRef.current = null;
|
|
50
52
|
const root = containerRef.current;
|
|
51
53
|
if (!root) return;
|
|
52
54
|
const container = root;
|
|
53
|
-
let tabStop = null;
|
|
54
55
|
const setTabStop = function setTabStop(element) {
|
|
55
|
-
var
|
|
56
|
-
if (element ===
|
|
57
|
-
(
|
|
56
|
+
var _tabStopRef$current;
|
|
57
|
+
if (element === tabStopRef.current) return;
|
|
58
|
+
(_tabStopRef$current = tabStopRef.current) === null || _tabStopRef$current === void 0 || _tabStopRef$current.setAttribute("tabindex", "-1");
|
|
58
59
|
element === null || element === void 0 || element.setAttribute("tabindex", "0");
|
|
59
|
-
|
|
60
|
+
tabStopRef.current = element;
|
|
60
61
|
};
|
|
61
62
|
const getPreferredItem = function getPreferredItem(t4) {
|
|
62
63
|
var _ref, _container$querySelec;
|
|
@@ -64,12 +65,12 @@ function useTreeRovingTabIndex(t0) {
|
|
|
64
65
|
return (_ref = (_container$querySelec = container.querySelector(CURRENT_TREE_ITEM)) !== null && _container$querySelec !== void 0 ? _container$querySelec : candidate) !== null && _ref !== void 0 ? _ref : container.querySelector(TREE_ITEM);
|
|
65
66
|
};
|
|
66
67
|
const removeElementFromTabOrder = function removeElementFromTabOrder(element_0) {
|
|
67
|
-
if (element_0.matches(NESTED_TABBABLE) || element_0 !==
|
|
68
|
+
if (element_0.matches(NESTED_TABBABLE) || element_0 !== tabStopRef.current && element_0.matches(TABBABLE_TREE_ITEM)) element_0.setAttribute("tabindex", "-1");
|
|
68
69
|
};
|
|
69
70
|
const removeFromTabOrder = function removeFromTabOrder(root_0) {
|
|
70
71
|
removeElementFromTabOrder(root_0);
|
|
71
72
|
for (const element_1 of root_0.querySelectorAll(NESTED_TABBABLE)) element_1.setAttribute("tabindex", "-1");
|
|
72
|
-
for (const element_2 of root_0.querySelectorAll(TABBABLE_TREE_ITEM)) if (element_2 !==
|
|
73
|
+
for (const element_2 of root_0.querySelectorAll(TABBABLE_TREE_ITEM)) if (element_2 !== tabStopRef.current) element_2.setAttribute("tabindex", "-1");
|
|
73
74
|
};
|
|
74
75
|
const activeElement = document.activeElement;
|
|
75
76
|
setTabStop(getPreferredItem(activeElement instanceof HTMLElement && container.contains(activeElement) && activeElement.getAttribute("role") === "treeitem" ? activeElement : null));
|
|
@@ -82,8 +83,8 @@ function useTreeRovingTabIndex(t0) {
|
|
|
82
83
|
}
|
|
83
84
|
for (const node of mutation.addedNodes) if (node instanceof Element) removeFromTabOrder(node);
|
|
84
85
|
}
|
|
85
|
-
if (!
|
|
86
|
-
|
|
86
|
+
if (!tabStopRef.current || !container.contains(tabStopRef.current)) {
|
|
87
|
+
tabStopRef.current = null;
|
|
87
88
|
setTabStop(getPreferredItem());
|
|
88
89
|
}
|
|
89
90
|
});
|
|
@@ -76,13 +76,17 @@ const UnderlinePanels = (t0) => {
|
|
|
76
76
|
if (/*#__PURE__*/ isValidElement(child) && (child.type === Tab || isSlot(child, Tab))) {
|
|
77
77
|
var _child$props$value;
|
|
78
78
|
const value = (_child$props$value = child.props.value) !== null && _child$props$value !== void 0 ? _child$props$value : `${indices.tab}`;
|
|
79
|
-
|
|
79
|
+
let t3 = indices.tab;
|
|
80
|
+
t3++;
|
|
81
|
+
indices.tab = t3;
|
|
80
82
|
return /*#__PURE__*/ cloneElement(child, { value });
|
|
81
83
|
}
|
|
82
84
|
if (/*#__PURE__*/ isValidElement(child) && (child.type === Panel || isSlot(child, Panel))) {
|
|
83
85
|
var _child$props$value2;
|
|
84
86
|
const value_0 = (_child$props$value2 = child.props.value) !== null && _child$props$value2 !== void 0 ? _child$props$value2 : `${indices.panel}`;
|
|
85
|
-
|
|
87
|
+
let t4 = indices.panel;
|
|
88
|
+
t4++;
|
|
89
|
+
indices.panel = t4;
|
|
86
90
|
return /*#__PURE__*/ cloneElement(child, { value: value_0 });
|
|
87
91
|
}
|
|
88
92
|
return child;
|
|
@@ -23,9 +23,9 @@ import { useImperativeHandle } from "react";
|
|
|
23
23
|
function useRefObjectAsForwardedRef(forwardedRef, refObject) {
|
|
24
24
|
const $ = c(2);
|
|
25
25
|
let t0;
|
|
26
|
-
if ($[0] !== refObject
|
|
26
|
+
if ($[0] !== refObject) {
|
|
27
27
|
t0 = () => refObject.current;
|
|
28
|
-
$[0] = refObject
|
|
28
|
+
$[0] = refObject;
|
|
29
29
|
$[1] = t0;
|
|
30
30
|
} else t0 = $[1];
|
|
31
31
|
useImperativeHandle(forwardedRef, t0);
|
|
@@ -12,23 +12,29 @@ import { useState } from "react";
|
|
|
12
12
|
* This is adapted almost directly from https://beta.reactjs.org/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
13
13
|
*/
|
|
14
14
|
const useSyncedState = (initialValue, t0) => {
|
|
15
|
-
const $ = c(
|
|
15
|
+
const $ = c(4);
|
|
16
16
|
const { isPropUpdateDisabled: t1, isEqual: t2 } = t0 === void 0 ? {} : t0;
|
|
17
17
|
const isPropUpdateDisabled = t1 === void 0 ? false : t1;
|
|
18
18
|
const isEqual = t2 === void 0 ? Object.is : t2;
|
|
19
19
|
const [state, setState] = useState(initialValue);
|
|
20
20
|
const [previous, setPrevious] = useState(initialValue);
|
|
21
|
-
|
|
21
|
+
let t3;
|
|
22
|
+
if ($[0] !== initialValue) {
|
|
23
|
+
t3 = initialValue instanceof Function ? initialValue() : initialValue;
|
|
24
|
+
$[0] = initialValue;
|
|
25
|
+
$[1] = t3;
|
|
26
|
+
} else t3 = $[1];
|
|
27
|
+
const nextInitialValue = t3;
|
|
22
28
|
if (!isPropUpdateDisabled && !isEqual(previous, nextInitialValue)) {
|
|
23
29
|
setPrevious(nextInitialValue);
|
|
24
30
|
setState(nextInitialValue);
|
|
25
31
|
}
|
|
26
|
-
let
|
|
27
|
-
if ($[
|
|
28
|
-
|
|
29
|
-
$[
|
|
30
|
-
$[
|
|
31
|
-
} else
|
|
32
|
-
return
|
|
32
|
+
let t4;
|
|
33
|
+
if ($[2] !== state) {
|
|
34
|
+
t4 = [state, setState];
|
|
35
|
+
$[2] = state;
|
|
36
|
+
$[3] = t4;
|
|
37
|
+
} else t4 = $[3];
|
|
38
|
+
return t4;
|
|
33
39
|
};
|
|
34
40
|
export { useSyncedState };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.47.0-rc.
|
|
4
|
+
"version": "38.47.0-rc.207872287",
|
|
5
5
|
"description": "An implementation of GitHub's Primer Design System using React",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"mdast-util-to-string": "4.0.0",
|
|
157
157
|
"micromark-extension-frontmatter": "2.0.0",
|
|
158
158
|
"micromark-extension-mdxjs": "3.0.0",
|
|
159
|
-
"oxc-transform-react": "^0.
|
|
159
|
+
"oxc-transform-react": "^0.157.0",
|
|
160
160
|
"postcss-preset-primer": "^0.0.0",
|
|
161
161
|
"publint": "^0.3.15",
|
|
162
162
|
"react": "18.3.1",
|