@primer/react 38.32.0-rc.4bb4bba69 → 38.32.0-rc.55b6eaf9c
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/dist/ActionBar/ActionBar.js +424 -130
- package/dist/FilteredActionList/FilteredActionList.js +155 -66
- package/dist/FilteredActionList/useAnnouncements.js +138 -66
- package/dist/LabelGroup/LabelGroup.js +110 -76
- package/dist/Overlay/Overlay.js +169 -45
- package/dist/TextInput/TextInput.js +7 -7
- package/dist/TreeView/TreeView.js +814 -309
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +95 -38
- package/dist/hooks/useControllableState.js +3 -3
- package/package.json +1 -3
|
@@ -6,6 +6,7 @@ import { isSlot } from "../../utils/is-slot.js";
|
|
|
6
6
|
import { createComponent } from "../../utils/create-component.js";
|
|
7
7
|
import { UnderlineItem, UnderlineItemList, UnderlineWrapper } from "../../internal/components/UnderlineTabbedInterface.js";
|
|
8
8
|
import UnderlinePanels_module_css_default from "./UnderlinePanels.module.css.js";
|
|
9
|
+
import { c } from "react-compiler-runtime";
|
|
9
10
|
import { clsx } from "clsx";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import React, { Children, cloneElement, createContext, isValidElement, useContext, useMemo, useRef, useState } from "react";
|
|
@@ -21,7 +22,7 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
|
|
|
21
22
|
const wrapperRef = useRef(null);
|
|
22
23
|
const listRef = useRef(null);
|
|
23
24
|
const parentId = useId$1(props.id);
|
|
24
|
-
const [
|
|
25
|
+
const [tabs_0, tabPanels_0, tabsHaveIcons_0] = useMemo(() => {
|
|
25
26
|
let tabIndex = 0;
|
|
26
27
|
let panelIndex = 0;
|
|
27
28
|
const childrenWithProps = Children.map(children, (child) => {
|
|
@@ -31,10 +32,10 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
|
|
|
31
32
|
});
|
|
32
33
|
const tabs = [];
|
|
33
34
|
const tabPanels = [];
|
|
34
|
-
for (const
|
|
35
|
-
if (!/*#__PURE__*/ isValidElement(
|
|
36
|
-
if (
|
|
37
|
-
else if (
|
|
35
|
+
for (const child_0 of Children.toArray(childrenWithProps)) {
|
|
36
|
+
if (!/*#__PURE__*/ isValidElement(child_0)) continue;
|
|
37
|
+
if (child_0.type === Tab || isSlot(child_0, Tab)) tabs.push(child_0);
|
|
38
|
+
else if (child_0.type === Panel || isSlot(child_0, Panel)) tabPanels.push(child_0);
|
|
38
39
|
}
|
|
39
40
|
return [
|
|
40
41
|
tabs,
|
|
@@ -52,20 +53,20 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
|
|
|
52
53
|
}, [iconsVisible]);
|
|
53
54
|
const listWidthRef = useRef(0);
|
|
54
55
|
useResizeObserver((entries) => {
|
|
55
|
-
if (!
|
|
56
|
+
if (!tabsHaveIcons_0) return;
|
|
56
57
|
if (!iconsVisibleRef.current) return;
|
|
57
58
|
listWidthRef.current = entries[0].contentRect.width;
|
|
58
59
|
}, listRef, []);
|
|
59
60
|
useResizeObserver((resizeObserverEntries) => {
|
|
60
|
-
if (!
|
|
61
|
+
if (!tabsHaveIcons_0) return;
|
|
61
62
|
const wrapperWidth = resizeObserverEntries[0].contentRect.width;
|
|
62
63
|
setIconsVisible(wrapperWidth > listWidthRef.current);
|
|
63
64
|
}, wrapperRef, []);
|
|
64
|
-
!(
|
|
65
|
-
const ariaSelected = /*#__PURE__*/ React.isValidElement(
|
|
65
|
+
!(tabs_0.filter((tab_0) => {
|
|
66
|
+
const ariaSelected = /*#__PURE__*/ React.isValidElement(tab_0) && tab_0.props["aria-selected"];
|
|
66
67
|
return ariaSelected === true || ariaSelected === "true";
|
|
67
68
|
}).length <= 1) && invariant(false, "Only one tab can be selected at a time.");
|
|
68
|
-
!(
|
|
69
|
+
!(tabs_0.length === tabPanels_0.length) && invariant(false, `The number of tabs and panels must be equal. Counted ${tabs_0.length} tabs and ${tabPanels_0.length} panels.`);
|
|
69
70
|
return /*#__PURE__*/ jsx(UnderlinePanelsContext.Provider, {
|
|
70
71
|
value: contextValue,
|
|
71
72
|
children: /*#__PURE__*/ jsxs(TabContainerComponent, { children: [/*#__PURE__*/ jsx(UnderlineWrapper, {
|
|
@@ -79,44 +80,100 @@ const UnderlinePanels = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabel
|
|
|
79
80
|
"aria-label": ariaLabel,
|
|
80
81
|
"aria-labelledby": ariaLabelledBy,
|
|
81
82
|
role: "tablist",
|
|
82
|
-
children:
|
|
83
|
+
children: tabs_0
|
|
83
84
|
})
|
|
84
|
-
}),
|
|
85
|
+
}), tabPanels_0] })
|
|
85
86
|
});
|
|
86
87
|
};
|
|
87
88
|
UnderlinePanels.displayName = "UnderlinePanels";
|
|
88
|
-
const TabImpl = (
|
|
89
|
+
const TabImpl = (t0) => {
|
|
90
|
+
const $ = c(15);
|
|
91
|
+
let ariaSelected;
|
|
92
|
+
let onSelect;
|
|
93
|
+
let props;
|
|
94
|
+
if ($[0] !== t0) {
|
|
95
|
+
({"aria-selected": ariaSelected, onSelect, ...props} = t0);
|
|
96
|
+
$[0] = t0;
|
|
97
|
+
$[1] = ariaSelected;
|
|
98
|
+
$[2] = onSelect;
|
|
99
|
+
$[3] = props;
|
|
100
|
+
} else {
|
|
101
|
+
ariaSelected = $[1];
|
|
102
|
+
onSelect = $[2];
|
|
103
|
+
props = $[3];
|
|
104
|
+
}
|
|
89
105
|
const { loadingCounters } = useContext(UnderlinePanelsContext);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
106
|
+
let t1;
|
|
107
|
+
if ($[4] !== onSelect) {
|
|
108
|
+
t1 = (event) => {
|
|
109
|
+
if (!event.defaultPrevented && typeof onSelect === "function") onSelect(event);
|
|
110
|
+
};
|
|
111
|
+
$[4] = onSelect;
|
|
112
|
+
$[5] = t1;
|
|
113
|
+
} else t1 = $[5];
|
|
114
|
+
const clickHandler = t1;
|
|
115
|
+
let t2;
|
|
116
|
+
if ($[6] !== onSelect) {
|
|
117
|
+
t2 = (event_0) => {
|
|
118
|
+
if ((event_0.key === " " || event_0.key === "Enter") && !event_0.defaultPrevented && typeof onSelect === "function") onSelect(event_0);
|
|
119
|
+
};
|
|
120
|
+
$[6] = onSelect;
|
|
121
|
+
$[7] = t2;
|
|
122
|
+
} else t2 = $[7];
|
|
123
|
+
const keyDownHandler = t2;
|
|
124
|
+
const t3 = ariaSelected ? 0 : -1;
|
|
125
|
+
let t4;
|
|
126
|
+
if ($[8] !== ariaSelected || $[9] !== clickHandler || $[10] !== keyDownHandler || $[11] !== loadingCounters || $[12] !== props || $[13] !== t3) {
|
|
127
|
+
t4 = /*#__PURE__*/ jsx(UnderlineItem, {
|
|
128
|
+
as: "button",
|
|
129
|
+
role: "tab",
|
|
130
|
+
tabIndex: t3,
|
|
131
|
+
"aria-selected": ariaSelected,
|
|
132
|
+
type: "button",
|
|
133
|
+
onClick: clickHandler,
|
|
134
|
+
onKeyDown: keyDownHandler,
|
|
135
|
+
loadingCounters,
|
|
136
|
+
...props
|
|
137
|
+
});
|
|
138
|
+
$[8] = ariaSelected;
|
|
139
|
+
$[9] = clickHandler;
|
|
140
|
+
$[10] = keyDownHandler;
|
|
141
|
+
$[11] = loadingCounters;
|
|
142
|
+
$[12] = props;
|
|
143
|
+
$[13] = t3;
|
|
144
|
+
$[14] = t4;
|
|
145
|
+
} else t4 = $[14];
|
|
146
|
+
return t4;
|
|
107
147
|
};
|
|
108
|
-
TabImpl.displayName = "TabImpl";
|
|
109
148
|
TabImpl.displayName = "UnderlinePanels.Tab";
|
|
110
149
|
const Tab = /*#__PURE__*/ React.memo(TabImpl);
|
|
111
150
|
Tab.displayName = "UnderlinePanels.Tab";
|
|
112
|
-
const Panel = (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
const Panel = (t0) => {
|
|
152
|
+
const $ = c(6);
|
|
153
|
+
let children;
|
|
154
|
+
let rest;
|
|
155
|
+
if ($[0] !== t0) {
|
|
156
|
+
({children, ...rest} = t0);
|
|
157
|
+
$[0] = t0;
|
|
158
|
+
$[1] = children;
|
|
159
|
+
$[2] = rest;
|
|
160
|
+
} else {
|
|
161
|
+
children = $[1];
|
|
162
|
+
rest = $[2];
|
|
163
|
+
}
|
|
164
|
+
let t1;
|
|
165
|
+
if ($[3] !== children || $[4] !== rest) {
|
|
166
|
+
t1 = /*#__PURE__*/ jsx("div", {
|
|
167
|
+
role: "tabpanel",
|
|
168
|
+
...rest,
|
|
169
|
+
children
|
|
170
|
+
});
|
|
171
|
+
$[3] = children;
|
|
172
|
+
$[4] = rest;
|
|
173
|
+
$[5] = t1;
|
|
174
|
+
} else t1 = $[5];
|
|
175
|
+
return t1;
|
|
118
176
|
};
|
|
119
|
-
Panel.displayName = "Panel";
|
|
120
177
|
Panel.displayName = "UnderlinePanels.Panel";
|
|
121
178
|
var UnderlinePanels_default = Object.assign(UnderlinePanels, {
|
|
122
179
|
Panel,
|
|
@@ -21,9 +21,9 @@ function useControllableState({ name = "custom", defaultValue, value, onChange }
|
|
|
21
21
|
if (controlled.current === null) controlled.current = value !== void 0;
|
|
22
22
|
const setState = React.useCallback((stateOrUpdater) => {
|
|
23
23
|
var _stableOnChange$curre;
|
|
24
|
-
const
|
|
25
|
-
if (controlled.current === false) internalSetState(
|
|
26
|
-
(_stableOnChange$curre = stableOnChange.current) === null || _stableOnChange$curre === void 0 || _stableOnChange$curre.call(stableOnChange,
|
|
24
|
+
const value_0 = typeof stateOrUpdater === "function" ? stateOrUpdater(state) : stateOrUpdater;
|
|
25
|
+
if (controlled.current === false) internalSetState(value_0);
|
|
26
|
+
(_stableOnChange$curre = stableOnChange.current) === null || _stableOnChange$curre === void 0 || _stableOnChange$curre.call(stableOnChange, value_0);
|
|
27
27
|
}, [state]);
|
|
28
28
|
React.useEffect(() => {
|
|
29
29
|
const controlledValue = value !== void 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.32.0-rc.
|
|
4
|
+
"version": "38.32.0-rc.55b6eaf9c",
|
|
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",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"build:hooks.json": "tsx script/hooks-json/build.ts",
|
|
48
48
|
"build:precompile-color-schemes": "tsx script/precompile-color-schemes.ts",
|
|
49
49
|
"lint:npm": "publint --types",
|
|
50
|
-
"lint:react-compiler": "node script/lint-react-compiler.ts",
|
|
51
50
|
"storybook": "storybook",
|
|
52
51
|
"type-check": "tsc --noEmit",
|
|
53
52
|
"type-css-modules": "tcm -p src/**/*.module.css"
|
|
@@ -109,7 +108,6 @@
|
|
|
109
108
|
"@figma/code-connect": "1.3.2",
|
|
110
109
|
"@primer/css": "^21.5.1",
|
|
111
110
|
"@primer/doc-gen": "^0.0.1",
|
|
112
|
-
"@primer/react-compiler-check": "^0.0.0",
|
|
113
111
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
114
112
|
"@storybook/addon-a11y": "^10.4.6",
|
|
115
113
|
"@storybook/addon-docs": "^10.4.6",
|