@primer/react 38.43.0-rc.fd837f586 → 38.44.0-rc.0a55e3e04
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 +22 -0
- package/dist/DataTable/DataTable.d.ts +20 -0
- package/dist/DataTable/DataTable.js +106 -88
- package/dist/DataTable/Table-0327e248.css +2 -0
- package/dist/DataTable/Table-0327e248.css.map +1 -0
- package/dist/DataTable/Table.js +53 -41
- package/dist/DataTable/Table.module.css.js +6 -5
- package/dist/DataTable/TableGroup.d.ts +25 -1
- package/dist/DataTable/TableGroup.js +195 -119
- package/dist/DataTable/useTable.js +184 -131
- package/dist/SegmentedControl/SegmentedControl-99b8e34e.css +2 -0
- package/dist/SegmentedControl/SegmentedControl-99b8e34e.css.map +1 -0
- package/dist/SegmentedControl/SegmentedControl.module.css.js +1 -1
- package/dist/SelectPanel/SelectPanel.js +85 -38
- package/dist/Token/_RemoveTokenButton.js +115 -20
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +417 -121
- package/dist/hooks/useControllableState.js +70 -19
- package/dist/hooks/useOnOutsideClick.js +48 -21
- package/dist/hooks/useSafeTimeout.js +54 -19
- package/dist/internal/hooks/useDevOnlyEffect.js +3 -8
- package/generated/components.json +47 -0
- package/package.json +3 -3
- package/dist/DataTable/Table-6ee6a868.css +0 -2
- package/dist/DataTable/Table-6ee6a868.css.map +0 -1
- package/dist/SegmentedControl/SegmentedControl-e68d4197.css +0 -2
- package/dist/SegmentedControl/SegmentedControl-e68d4197.css.map +0 -1
|
@@ -1,159 +1,235 @@
|
|
|
1
1
|
import { c } from "../utils/react-compiler-runtime.js";
|
|
2
2
|
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
3
|
+
import { useControllableState } from "../hooks/useControllableState.js";
|
|
4
|
+
import { Button } from "../internal/components/ButtonReset.js";
|
|
3
5
|
import { TableGroupContext } from "./TableGroupContext.js";
|
|
4
6
|
import Table_module_css_default from "./Table.module.css.js";
|
|
5
7
|
import { TableRow } from "./Table.js";
|
|
6
|
-
import { useId } from "react";
|
|
8
|
+
import { useId, useRef } from "react";
|
|
7
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { clsx } from "clsx";
|
|
11
|
+
import { ChevronRightIcon } from "@primer/octicons-react";
|
|
9
12
|
//#region src/DataTable/TableGroup.tsx
|
|
10
13
|
function TableGroup(t0) {
|
|
11
|
-
const $ = c(
|
|
12
|
-
const { className, id, label, rowCount, colSpan, children, "aria-label": ariaLabel } = t0;
|
|
14
|
+
const $ = c(60);
|
|
15
|
+
const { className, id, label, rowCount, colSpan, children, "aria-label": ariaLabel, collapsible: t1, expanded: controlledExpanded, defaultExpanded: t2, onExpandedChange } = t0;
|
|
16
|
+
const collapsible = t1 === void 0 ? false : t1;
|
|
17
|
+
const defaultExpanded = t2 === void 0 ? true : t2;
|
|
13
18
|
const headerId = useId();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
t1 = { headerId };
|
|
17
|
-
$[0] = headerId;
|
|
18
|
-
$[1] = t1;
|
|
19
|
-
} else t1 = $[1];
|
|
20
|
-
const contextValue = t1;
|
|
21
|
-
let t2;
|
|
22
|
-
if ($[2] !== className) {
|
|
23
|
-
t2 = clsx("TableGroupHeaderBody", Table_module_css_default.TableGroupHeaderBody, className);
|
|
24
|
-
$[2] = className;
|
|
25
|
-
$[3] = t2;
|
|
26
|
-
} else t2 = $[3];
|
|
19
|
+
const bodyId = useId();
|
|
20
|
+
const headerRef = useRef(null);
|
|
27
21
|
let t3;
|
|
28
|
-
if ($[
|
|
29
|
-
t3 =
|
|
30
|
-
$[
|
|
31
|
-
|
|
22
|
+
if ($[0] !== onExpandedChange) {
|
|
23
|
+
t3 = (value) => onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange({ expanded: value });
|
|
24
|
+
$[0] = onExpandedChange;
|
|
25
|
+
$[1] = t3;
|
|
26
|
+
} else t3 = $[1];
|
|
32
27
|
let t4;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
if ($[2] !== controlledExpanded || $[3] !== defaultExpanded || $[4] !== t3) {
|
|
29
|
+
t4 = {
|
|
30
|
+
name: "Table.Group expanded",
|
|
31
|
+
value: controlledExpanded,
|
|
32
|
+
defaultValue: defaultExpanded,
|
|
33
|
+
onChange: t3
|
|
34
|
+
};
|
|
35
|
+
$[2] = controlledExpanded;
|
|
36
|
+
$[3] = defaultExpanded;
|
|
37
|
+
$[4] = t3;
|
|
37
38
|
$[5] = t4;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
} else t4 = $[5];
|
|
40
|
+
const [expanded, setExpanded] = useControllableState(t4);
|
|
41
|
+
const isExpanded = !collapsible || expanded;
|
|
42
|
+
let t5;
|
|
43
|
+
if ($[6] !== headerId) {
|
|
44
|
+
t5 = { headerId };
|
|
45
|
+
$[6] = headerId;
|
|
46
|
+
$[7] = t5;
|
|
47
|
+
} else t5 = $[7];
|
|
48
|
+
const contextValue = t5;
|
|
43
49
|
let t6;
|
|
44
|
-
if ($[
|
|
45
|
-
t6 =
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
if ($[8] !== isExpanded) {
|
|
51
|
+
t6 = (body) => {
|
|
52
|
+
if (!isExpanded && body !== null && body !== void 0 && body.contains(body.ownerDocument.activeElement)) {
|
|
53
|
+
var _headerRef$current;
|
|
54
|
+
(_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 || (_headerRef$current = _headerRef$current.querySelector("button")) === null || _headerRef$current === void 0 || _headerRef$current.focus();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
$[8] = isExpanded;
|
|
58
|
+
$[9] = t6;
|
|
59
|
+
} else t6 = $[9];
|
|
60
|
+
const bodyRef = t6;
|
|
48
61
|
let t7;
|
|
49
|
-
if ($[
|
|
50
|
-
t7 =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
$[8] = label;
|
|
55
|
-
$[9] = t7;
|
|
56
|
-
} else t7 = $[9];
|
|
62
|
+
if ($[10] !== className) {
|
|
63
|
+
t7 = clsx("TableGroupHeaderBody", Table_module_css_default.TableGroupHeaderBody, className);
|
|
64
|
+
$[10] = className;
|
|
65
|
+
$[11] = t7;
|
|
66
|
+
} else t7 = $[11];
|
|
57
67
|
let t8;
|
|
58
|
-
if ($[
|
|
59
|
-
t8 = clsx("
|
|
60
|
-
$[
|
|
61
|
-
} else t8 = $[
|
|
62
|
-
const t9 =
|
|
68
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
69
|
+
t8 = clsx("TableGroupHeaderCell", Table_module_css_default.TableGroupHeaderCell);
|
|
70
|
+
$[12] = t8;
|
|
71
|
+
} else t8 = $[12];
|
|
72
|
+
const t9 = collapsible ? ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : label : ariaLabel;
|
|
63
73
|
let t10;
|
|
64
|
-
if ($[
|
|
65
|
-
t10 = /* @__PURE__ */ jsx(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
if ($[13] !== ariaLabel || $[14] !== bodyId || $[15] !== collapsible || $[16] !== expanded || $[17] !== isExpanded || $[18] !== label || $[19] !== rowCount || $[20] !== setExpanded) {
|
|
75
|
+
t10 = collapsible ? /* @__PURE__ */ jsx(Button, {
|
|
76
|
+
className: Table_module_css_default.TableGroupToggle,
|
|
77
|
+
"data-component": "Table.Group.Toggle",
|
|
78
|
+
"aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : label,
|
|
79
|
+
"aria-description": `${rowCount} ${rowCount === 1 ? "row" : "rows"}`,
|
|
80
|
+
"aria-expanded": isExpanded,
|
|
81
|
+
"aria-controls": bodyId,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
setExpanded(!expanded);
|
|
84
|
+
},
|
|
85
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { "aria-hidden": "true" })
|
|
86
|
+
}) : null;
|
|
87
|
+
$[13] = ariaLabel;
|
|
88
|
+
$[14] = bodyId;
|
|
89
|
+
$[15] = collapsible;
|
|
90
|
+
$[16] = expanded;
|
|
91
|
+
$[17] = isExpanded;
|
|
92
|
+
$[18] = label;
|
|
93
|
+
$[19] = rowCount;
|
|
94
|
+
$[20] = setExpanded;
|
|
95
|
+
$[21] = t10;
|
|
96
|
+
} else t10 = $[21];
|
|
69
97
|
let t11;
|
|
70
|
-
if ($[
|
|
71
|
-
t11 =
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
99
|
+
t11 = clsx("TableGroupHeaderContent", Table_module_css_default.TableGroupHeaderContent);
|
|
100
|
+
$[22] = t11;
|
|
101
|
+
} else t11 = $[22];
|
|
102
|
+
const t12 = collapsible || void 0;
|
|
103
|
+
let t13;
|
|
104
|
+
if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
|
|
105
|
+
t13 = clsx("TableGroupHeaderLabel", Table_module_css_default.TableGroupHeaderLabel);
|
|
106
|
+
$[23] = t13;
|
|
107
|
+
} else t13 = $[23];
|
|
108
|
+
let t14;
|
|
109
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
110
|
+
t14 = /* @__PURE__ */ jsx(VisuallyHidden, { children: "," });
|
|
111
|
+
$[24] = t14;
|
|
112
|
+
} else t14 = $[24];
|
|
113
|
+
let t15;
|
|
114
|
+
if ($[25] !== label) {
|
|
115
|
+
t15 = /* @__PURE__ */ jsxs("span", {
|
|
116
|
+
className: t13,
|
|
117
|
+
children: [label, t14]
|
|
74
118
|
});
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
$[25] = label;
|
|
120
|
+
$[26] = t15;
|
|
121
|
+
} else t15 = $[26];
|
|
122
|
+
let t16;
|
|
123
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
124
|
+
t16 = clsx("TableGroupHeaderCount", Table_module_css_default.TableGroupHeaderCount);
|
|
125
|
+
$[27] = t16;
|
|
126
|
+
} else t16 = $[27];
|
|
127
|
+
const t17 = rowCount === 1 ? " row" : " rows";
|
|
128
|
+
let t18;
|
|
129
|
+
if ($[28] !== t17) {
|
|
130
|
+
t18 = /* @__PURE__ */ jsx(VisuallyHidden, { children: t17 });
|
|
131
|
+
$[28] = t17;
|
|
132
|
+
$[29] = t18;
|
|
133
|
+
} else t18 = $[29];
|
|
134
|
+
let t19;
|
|
135
|
+
if ($[30] !== rowCount || $[31] !== t18) {
|
|
136
|
+
t19 = /* @__PURE__ */ jsxs("span", {
|
|
137
|
+
className: t16,
|
|
138
|
+
children: [rowCount, t18]
|
|
84
139
|
});
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
} else
|
|
89
|
-
let
|
|
90
|
-
if ($[
|
|
91
|
-
|
|
140
|
+
$[30] = rowCount;
|
|
141
|
+
$[31] = t18;
|
|
142
|
+
$[32] = t19;
|
|
143
|
+
} else t19 = $[32];
|
|
144
|
+
let t20;
|
|
145
|
+
if ($[33] !== t12 || $[34] !== t15 || $[35] !== t19) {
|
|
146
|
+
t20 = /* @__PURE__ */ jsxs("span", {
|
|
147
|
+
className: t11,
|
|
148
|
+
"aria-hidden": t12,
|
|
149
|
+
children: [t15, t19]
|
|
150
|
+
});
|
|
151
|
+
$[33] = t12;
|
|
152
|
+
$[34] = t15;
|
|
153
|
+
$[35] = t19;
|
|
154
|
+
$[36] = t20;
|
|
155
|
+
} else t20 = $[36];
|
|
156
|
+
let t21;
|
|
157
|
+
if ($[37] !== colSpan || $[38] !== headerId || $[39] !== t10 || $[40] !== t20 || $[41] !== t9) {
|
|
158
|
+
t21 = /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsxs("th", {
|
|
92
159
|
id: headerId,
|
|
93
|
-
|
|
160
|
+
ref: headerRef,
|
|
161
|
+
className: t8,
|
|
94
162
|
scope: "colgroup",
|
|
95
163
|
colSpan,
|
|
96
164
|
role: "columnheader",
|
|
97
|
-
"aria-label":
|
|
165
|
+
"aria-label": t9,
|
|
98
166
|
"data-component": "Table.Group.Header",
|
|
99
|
-
children:
|
|
167
|
+
children: [t10, t20]
|
|
100
168
|
}) });
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
169
|
+
$[37] = colSpan;
|
|
170
|
+
$[38] = headerId;
|
|
171
|
+
$[39] = t10;
|
|
172
|
+
$[40] = t20;
|
|
173
|
+
$[41] = t9;
|
|
174
|
+
$[42] = t21;
|
|
175
|
+
} else t21 = $[42];
|
|
176
|
+
let t22;
|
|
177
|
+
if ($[43] !== id || $[44] !== t21 || $[45] !== t7) {
|
|
178
|
+
t22 = /* @__PURE__ */ jsx("tbody", {
|
|
179
|
+
className: t7,
|
|
111
180
|
role: "rowgroup",
|
|
112
181
|
"data-component": "Table.Group",
|
|
113
182
|
"data-group-id": id,
|
|
114
|
-
children:
|
|
183
|
+
children: t21
|
|
115
184
|
});
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
} else
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
185
|
+
$[43] = id;
|
|
186
|
+
$[44] = t21;
|
|
187
|
+
$[45] = t7;
|
|
188
|
+
$[46] = t22;
|
|
189
|
+
} else t22 = $[46];
|
|
190
|
+
const t23 = !isExpanded;
|
|
191
|
+
let t24;
|
|
192
|
+
if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
|
|
193
|
+
t24 = clsx("TableBody", Table_module_css_default.TableBody);
|
|
194
|
+
$[47] = t24;
|
|
195
|
+
} else t24 = $[47];
|
|
196
|
+
let t25;
|
|
197
|
+
if ($[48] !== children || $[49] !== contextValue) {
|
|
198
|
+
t25 = /* @__PURE__ */ jsx(TableGroupContext.Provider, {
|
|
129
199
|
value: contextValue,
|
|
130
200
|
children
|
|
131
201
|
});
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
} else
|
|
136
|
-
let
|
|
137
|
-
if ($[
|
|
138
|
-
|
|
139
|
-
|
|
202
|
+
$[48] = children;
|
|
203
|
+
$[49] = contextValue;
|
|
204
|
+
$[50] = t25;
|
|
205
|
+
} else t25 = $[50];
|
|
206
|
+
let t26;
|
|
207
|
+
if ($[51] !== bodyId || $[52] !== bodyRef || $[53] !== id || $[54] !== t23 || $[55] !== t25) {
|
|
208
|
+
t26 = /* @__PURE__ */ jsx("tbody", {
|
|
209
|
+
id: bodyId,
|
|
210
|
+
ref: bodyRef,
|
|
211
|
+
hidden: t23,
|
|
212
|
+
className: t24,
|
|
140
213
|
role: "rowgroup",
|
|
141
214
|
"data-component": "Table.Group.Body",
|
|
142
215
|
"data-group-id": id,
|
|
143
|
-
children:
|
|
216
|
+
children: t25
|
|
144
217
|
});
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
$[
|
|
155
|
-
|
|
156
|
-
|
|
218
|
+
$[51] = bodyId;
|
|
219
|
+
$[52] = bodyRef;
|
|
220
|
+
$[53] = id;
|
|
221
|
+
$[54] = t23;
|
|
222
|
+
$[55] = t25;
|
|
223
|
+
$[56] = t26;
|
|
224
|
+
} else t26 = $[56];
|
|
225
|
+
let t27;
|
|
226
|
+
if ($[57] !== t22 || $[58] !== t26) {
|
|
227
|
+
t27 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t22, t26] });
|
|
228
|
+
$[57] = t22;
|
|
229
|
+
$[58] = t26;
|
|
230
|
+
$[59] = t27;
|
|
231
|
+
} else t27 = $[59];
|
|
232
|
+
return t27;
|
|
157
233
|
}
|
|
158
234
|
//#endregion
|
|
159
235
|
export { TableGroup };
|