@primer/react 38.45.0-rc.72a855661 → 38.45.0-rc.cac8791d9

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.
@@ -1,12 +1,16 @@
1
1
  import { c } from "../utils/react-compiler-runtime.js";
2
+ import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
3
+ import { useResizeObserver } from "../hooks/useResizeObserver.js";
2
4
  import CounterLabel from "../CounterLabel/CounterLabel.js";
5
+ import { Tooltip } from "../TooltipV2/Tooltip.js";
3
6
  import SegmentedControl_module_css_default from "./SegmentedControl.module.css.js";
7
+ import { useRef, useState } from "react";
4
8
  import { jsx, jsxs } from "react/jsx-runtime";
5
9
  import { clsx } from "clsx";
6
10
  import { isElement } from "react-is";
7
11
  //#region src/SegmentedControl/SegmentedControlButton.tsx
8
12
  const SegmentedControlButton = (t0) => {
9
- const $ = c(36);
13
+ const $ = c(44);
10
14
  let children;
11
15
  let className;
12
16
  let count;
@@ -55,103 +59,142 @@ const SegmentedControlButton = (t0) => {
55
59
  ariaDisabled = $[10];
56
60
  rest = $[11];
57
61
  }
58
- const LeadingVisual = leadingVisual !== null && leadingVisual !== void 0 ? leadingVisual : leadingIcon;
62
+ const labelRef = useRef(null);
63
+ const [isTruncated, setIsTruncated] = useState(false);
59
64
  let t1;
60
65
  if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
61
- t1 = clsx(SegmentedControl_module_css_default.Item);
66
+ t1 = () => {
67
+ const label = labelRef.current;
68
+ if (label) setIsTruncated(label.scrollWidth > label.clientWidth);
69
+ };
62
70
  $[12] = t1;
63
71
  } else t1 = $[12];
64
- const t2 = selected ? "" : void 0;
65
- const t3 = disabled || ariaDisabled || void 0;
66
- let t4;
67
- if ($[13] !== className) {
68
- t4 = clsx(SegmentedControl_module_css_default.Button, className);
69
- $[13] = className;
70
- $[14] = t4;
71
- } else t4 = $[14];
72
- let t5;
73
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
74
- t5 = clsx(SegmentedControl_module_css_default.Content, "segmentedControl-content");
75
- $[15] = t5;
76
- } else t5 = $[15];
77
- let t6;
78
- if ($[16] !== LeadingVisual) {
79
- t6 = LeadingVisual && /* @__PURE__ */ jsx("div", {
72
+ const updateTruncation = t1;
73
+ useResizeObserver(updateTruncation, labelRef);
74
+ let t2;
75
+ if ($[13] !== children || $[14] !== selected) {
76
+ t2 = [
77
+ children,
78
+ selected,
79
+ updateTruncation
80
+ ];
81
+ $[13] = children;
82
+ $[14] = selected;
83
+ $[15] = t2;
84
+ } else t2 = $[15];
85
+ useIsomorphicLayoutEffect(updateTruncation, t2);
86
+ const LeadingVisual = leadingVisual !== null && leadingVisual !== void 0 ? leadingVisual : leadingIcon;
87
+ let t3;
88
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
89
+ t3 = clsx(SegmentedControl_module_css_default.Item);
90
+ $[16] = t3;
91
+ } else t3 = $[16];
92
+ const t4 = selected ? "" : void 0;
93
+ const t5 = isTruncated ? children : "";
94
+ const t6 = !isTruncated;
95
+ const t7 = disabled || ariaDisabled || void 0;
96
+ let t8;
97
+ if ($[17] !== className) {
98
+ t8 = clsx(SegmentedControl_module_css_default.Button, className);
99
+ $[17] = className;
100
+ $[18] = t8;
101
+ } else t8 = $[18];
102
+ let t9;
103
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
104
+ t9 = clsx(SegmentedControl_module_css_default.Content, "segmentedControl-content");
105
+ $[19] = t9;
106
+ } else t9 = $[19];
107
+ let t10;
108
+ if ($[20] !== LeadingVisual) {
109
+ t10 = LeadingVisual && /* @__PURE__ */ jsx("div", {
80
110
  className: SegmentedControl_module_css_default.LeadingIcon,
81
111
  children: isElement(LeadingVisual) ? LeadingVisual : /* @__PURE__ */ jsx(LeadingVisual, {})
82
112
  });
83
- $[16] = LeadingVisual;
84
- $[17] = t6;
85
- } else t6 = $[17];
86
- let t7;
87
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
88
- t7 = clsx(SegmentedControl_module_css_default.Text, "segmentedControl-text");
89
- $[18] = t7;
90
- } else t7 = $[18];
91
- let t8;
92
- if ($[19] !== children) {
93
- t8 = /* @__PURE__ */ jsx("div", {
94
- className: t7,
113
+ $[20] = LeadingVisual;
114
+ $[21] = t10;
115
+ } else t10 = $[21];
116
+ let t11;
117
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
118
+ t11 = clsx(SegmentedControl_module_css_default.Text, "segmentedControl-text");
119
+ $[22] = t11;
120
+ } else t11 = $[22];
121
+ let t12;
122
+ if ($[23] !== children) {
123
+ t12 = /* @__PURE__ */ jsx("div", {
124
+ ref: labelRef,
125
+ className: t11,
95
126
  "data-text": children,
96
127
  children
97
128
  });
98
- $[19] = children;
99
- $[20] = t8;
100
- } else t8 = $[20];
101
- let t9;
102
- if ($[21] !== count) {
103
- t9 = count !== void 0 && /* @__PURE__ */ jsx("span", {
129
+ $[23] = children;
130
+ $[24] = t12;
131
+ } else t12 = $[24];
132
+ let t13;
133
+ if ($[25] !== count) {
134
+ t13 = count !== void 0 && /* @__PURE__ */ jsx("span", {
104
135
  className: SegmentedControl_module_css_default.Counter,
105
136
  children: /* @__PURE__ */ jsx(CounterLabel, { children: count })
106
137
  });
107
- $[21] = count;
108
- $[22] = t9;
109
- } else t9 = $[22];
110
- let t10;
111
- if ($[23] !== t6 || $[24] !== t8 || $[25] !== t9) {
112
- t10 = /* @__PURE__ */ jsxs("span", {
113
- className: t5,
138
+ $[25] = count;
139
+ $[26] = t13;
140
+ } else t13 = $[26];
141
+ let t14;
142
+ if ($[27] !== t10 || $[28] !== t12 || $[29] !== t13) {
143
+ t14 = /* @__PURE__ */ jsxs("span", {
144
+ className: t9,
114
145
  children: [
115
- t6,
116
- t8,
117
- t9
146
+ t10,
147
+ t12,
148
+ t13
118
149
  ]
119
150
  });
120
- $[23] = t6;
121
- $[24] = t8;
122
- $[25] = t9;
123
- $[26] = t10;
124
- } else t10 = $[26];
125
- let t11;
126
- if ($[27] !== rest || $[28] !== selected || $[29] !== t10 || $[30] !== t3 || $[31] !== t4) {
127
- t11 = /* @__PURE__ */ jsx("button", {
151
+ $[27] = t10;
152
+ $[28] = t12;
153
+ $[29] = t13;
154
+ $[30] = t14;
155
+ } else t14 = $[30];
156
+ let t15;
157
+ if ($[31] !== rest || $[32] !== selected || $[33] !== t14 || $[34] !== t7 || $[35] !== t8) {
158
+ t15 = /* @__PURE__ */ jsx("button", {
128
159
  "aria-pressed": selected,
129
- "aria-disabled": t3,
130
- className: t4,
160
+ "aria-disabled": t7,
161
+ className: t8,
131
162
  type: "button",
132
163
  ...rest,
133
- children: t10
164
+ children: t14
134
165
  });
135
- $[27] = rest;
136
- $[28] = selected;
137
- $[29] = t10;
138
- $[30] = t3;
139
- $[31] = t4;
140
- $[32] = t11;
141
- } else t11 = $[32];
142
- let t12;
143
- if ($[33] !== t11 || $[34] !== t2) {
144
- t12 = /* @__PURE__ */ jsx("li", {
145
- className: t1,
146
- "data-selected": t2,
166
+ $[31] = rest;
167
+ $[32] = selected;
168
+ $[33] = t14;
169
+ $[34] = t7;
170
+ $[35] = t8;
171
+ $[36] = t15;
172
+ } else t15 = $[36];
173
+ let t16;
174
+ if ($[37] !== t15 || $[38] !== t5 || $[39] !== t6) {
175
+ t16 = /* @__PURE__ */ jsx(Tooltip, {
176
+ text: t5,
177
+ _privateDisableTooltip: t6,
178
+ children: t15
179
+ });
180
+ $[37] = t15;
181
+ $[38] = t5;
182
+ $[39] = t6;
183
+ $[40] = t16;
184
+ } else t16 = $[40];
185
+ let t17;
186
+ if ($[41] !== t16 || $[42] !== t4) {
187
+ t17 = /* @__PURE__ */ jsx("li", {
188
+ className: t3,
189
+ "data-selected": t4,
147
190
  "data-component": "SegmentedControl.Button",
148
- children: t11
191
+ children: t16
149
192
  });
150
- $[33] = t11;
151
- $[34] = t2;
152
- $[35] = t12;
153
- } else t12 = $[35];
154
- return t12;
193
+ $[41] = t16;
194
+ $[42] = t4;
195
+ $[43] = t17;
196
+ } else t17 = $[43];
197
+ return t17;
155
198
  };
156
199
  SegmentedControlButton.__SLOT__ = Symbol("SegmentedControl.Button");
157
200
  //#endregion
@@ -17,7 +17,7 @@ type TooltipProps = React.PropsWithChildren<{
17
17
  */
18
18
  delay?: 'short' | 'medium' | 'long';
19
19
  /**
20
- * Private API for use internally only. Prevents the tooltip from opening if `true`.
20
+ * Private API for use internally only. Closes the tooltip and prevents it from opening if `true`.
21
21
  *
22
22
  * Accessibility note: This prop should be used with caution. Only use when needing to
23
23
  * programmatically close the tooltip in response to a specific user action, such as
@@ -82,7 +82,7 @@ const isInteractive = (element) => {
82
82
  };
83
83
  const emptyKeybindingHints = [];
84
84
  const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
85
- const $ = c(58);
85
+ const $ = c(63);
86
86
  let children;
87
87
  let className;
88
88
  let id;
@@ -139,6 +139,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
139
139
  const [calculatedDirection, setCalculatedDirection] = useState(direction);
140
140
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
141
141
  const openTimeoutRef = React.useRef(null);
142
+ const shouldOpenOnFocusRef = useRef(false);
142
143
  const { safeSetTimeout, safeClearTimeout } = useSafeTimeout();
143
144
  let t6;
144
145
  if ($[11] !== _privateDisableTooltip || $[12] !== direction || $[13] !== readTriggerRef) {
@@ -193,15 +194,37 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
193
194
  } else t7 = $[17];
194
195
  const closeTooltip = t7;
195
196
  let t8;
196
- if ($[18] !== tooltipId) {
197
- t8 = { tooltipId };
198
- $[18] = tooltipId;
199
- $[19] = t8;
200
- } else t8 = $[19];
201
- const value = t8;
202
197
  let t9;
203
- if ($[20] !== readTriggerRef || $[21] !== type) {
204
- t9 = () => {
198
+ if ($[18] !== _privateDisableTooltip || $[19] !== closeTooltip || $[20] !== openTooltip) {
199
+ t8 = () => {
200
+ if (_privateDisableTooltip) closeTooltip();
201
+ else if (shouldOpenOnFocusRef.current) openTooltip();
202
+ };
203
+ t9 = [
204
+ _privateDisableTooltip,
205
+ closeTooltip,
206
+ openTooltip
207
+ ];
208
+ $[18] = _privateDisableTooltip;
209
+ $[19] = closeTooltip;
210
+ $[20] = openTooltip;
211
+ $[21] = t8;
212
+ $[22] = t9;
213
+ } else {
214
+ t8 = $[21];
215
+ t9 = $[22];
216
+ }
217
+ useEffect(t8, t9);
218
+ let t10;
219
+ if ($[23] !== tooltipId) {
220
+ t10 = { tooltipId };
221
+ $[23] = tooltipId;
222
+ $[24] = t10;
223
+ } else t10 = $[24];
224
+ const value = t10;
225
+ let t11;
226
+ if ($[25] !== readTriggerRef || $[26] !== type) {
227
+ t11 = () => {
205
228
  if (!tooltipElRef.current || !readTriggerRef.current) return;
206
229
  const trigger_0 = readTriggerRef.current;
207
230
  const isInvalidTrigger = !(trigger_0 instanceof HTMLElement);
@@ -221,56 +244,57 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
221
244
  }
222
245
  tooltipElRef.current.setAttribute("popover", "auto");
223
246
  };
224
- $[20] = readTriggerRef;
225
- $[21] = type;
226
- $[22] = t9;
227
- } else t9 = $[22];
228
- let t10;
229
- if ($[23] !== direction || $[24] !== readTriggerRef || $[25] !== type) {
230
- t10 = [
247
+ $[25] = readTriggerRef;
248
+ $[26] = type;
249
+ $[27] = t11;
250
+ } else t11 = $[27];
251
+ let t12;
252
+ if ($[28] !== direction || $[29] !== readTriggerRef || $[30] !== type) {
253
+ t12 = [
231
254
  tooltipElRef,
232
255
  readTriggerRef,
233
256
  direction,
234
257
  type
235
258
  ];
236
- $[23] = direction;
237
- $[24] = readTriggerRef;
238
- $[25] = type;
239
- $[26] = t10;
240
- } else t10 = $[26];
241
- useEffect(t9, t10);
242
- let t11;
243
- if ($[27] !== closeTooltip || $[28] !== isPopoverOpen) {
244
- t11 = (event) => {
259
+ $[28] = direction;
260
+ $[29] = readTriggerRef;
261
+ $[30] = type;
262
+ $[31] = t12;
263
+ } else t12 = $[31];
264
+ useEffect(t11, t12);
265
+ let t13;
266
+ if ($[32] !== closeTooltip || $[33] !== isPopoverOpen) {
267
+ t13 = (event) => {
245
268
  if (isPopoverOpen) {
269
+ shouldOpenOnFocusRef.current = false;
246
270
  event.stopImmediatePropagation();
247
271
  event.preventDefault();
248
272
  closeTooltip();
249
273
  }
250
274
  };
251
- $[27] = closeTooltip;
252
- $[28] = isPopoverOpen;
253
- $[29] = t11;
254
- } else t11 = $[29];
255
- let t12;
256
- if ($[30] !== isPopoverOpen) {
257
- t12 = [isPopoverOpen];
258
- $[30] = isPopoverOpen;
259
- $[31] = t12;
260
- } else t12 = $[31];
261
- useOnEscapePress(t11, t12);
275
+ $[32] = closeTooltip;
276
+ $[33] = isPopoverOpen;
277
+ $[34] = t13;
278
+ } else t13 = $[34];
279
+ let t14;
280
+ if ($[35] !== isPopoverOpen) {
281
+ t14 = [isPopoverOpen];
282
+ $[35] = isPopoverOpen;
283
+ $[36] = t14;
284
+ } else t14 = $[36];
285
+ useOnEscapePress(t13, t14);
262
286
  const platform = usePlatform();
263
287
  const hasAriaLabel_0 = "aria-label" in rest;
264
- let t13;
265
- if ($[32] !== keybindingHint) {
266
- t13 = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
267
- $[32] = keybindingHint;
268
- $[33] = t13;
269
- } else t13 = $[33];
270
- const keybindingHints = t13;
288
+ let t15;
289
+ if ($[37] !== keybindingHint) {
290
+ t15 = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint];
291
+ $[37] = keybindingHint;
292
+ $[38] = t15;
293
+ } else t15 = $[38];
294
+ const keybindingHints = t15;
271
295
  if (isFragmentTrigger) return child;
272
- const t14 = TooltipContext;
273
- const t15 = /*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
296
+ const t16 = TooltipContext;
297
+ const t17 = /*#__PURE__*/ React.isValidElement(child) && /*#__PURE__*/ React.cloneElement(child, {
274
298
  ref: appliedTriggerRef,
275
299
  "aria-describedby": (() => {
276
300
  if (type !== "description") return child.props["aria-describedby"];
@@ -281,6 +305,7 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
281
305
  "aria-labelledby": type === "label" ? tooltipId : child.props["aria-labelledby"],
282
306
  onBlur: (event_0) => {
283
307
  var _child$props$onBlur, _child$props;
308
+ shouldOpenOnFocusRef.current = false;
284
309
  closeTooltip();
285
310
  (_child$props$onBlur = (_child$props = child.props).onBlur) === null || _child$props$onBlur === void 0 || _child$props$onBlur.call(_child$props, event_0);
286
311
  },
@@ -291,19 +316,21 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
291
316
  },
292
317
  onFocus: (event_2) => {
293
318
  var _child$props$onFocus, _child$props3;
319
+ shouldOpenOnFocusRef.current = false;
320
+ (_child$props$onFocus = (_child$props3 = child.props).onFocus) === null || _child$props$onFocus === void 0 || _child$props$onFocus.call(_child$props3, event_2);
294
321
  try {
295
322
  if (!event_2.target.matches(":focus-visible")) return;
296
- } catch (t16) {}
323
+ } catch (t18) {}
324
+ shouldOpenOnFocusRef.current = true;
297
325
  openTooltip();
298
- (_child$props$onFocus = (_child$props3 = child.props).onFocus) === null || _child$props$onFocus === void 0 || _child$props$onFocus.call(_child$props3, event_2);
299
326
  },
300
327
  onMouseOverCapture: (event_3) => {
328
+ var _child$props$onMouseO, _child$props4;
329
+ (_child$props$onMouseO = (_child$props4 = child.props).onMouseOverCapture) === null || _child$props$onMouseO === void 0 || _child$props$onMouseO.call(_child$props4, event_3);
301
330
  const delayTime = delayTimeMap[delay] || 50;
302
331
  openTimeoutRef.current = safeSetTimeout(() => {
303
- var _child$props$onMouseE, _child$props4;
304
332
  if (!openTimeoutRef.current) return;
305
333
  openTooltip();
306
- (_child$props$onMouseE = (_child$props4 = child.props).onMouseEnter) === null || _child$props$onMouseE === void 0 || _child$props$onMouseE.call(_child$props4, event_3);
307
334
  }, delayTime);
308
335
  },
309
336
  onMouseLeave: (event_4) => {
@@ -312,17 +339,17 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
312
339
  (_child$props$onMouseL = (_child$props5 = child.props).onMouseLeave) === null || _child$props$onMouseL === void 0 || _child$props$onMouseL.call(_child$props5, event_4);
313
340
  }
314
341
  });
315
- let t17;
316
- if ($[34] !== className) {
317
- t17 = clsx(className, Tooltip_module_css_default.Tooltip);
318
- $[34] = className;
319
- $[35] = t17;
320
- } else t17 = $[35];
321
- const t18 = type === "description" ? "tooltip" : void 0;
322
- const t19 = hasAriaLabel_0 || keybindingHints.length === 0 ? tooltipId : void 0;
323
- let t20;
324
- if ($[36] !== hasAriaLabel_0 || $[37] !== keybindingHints || $[38] !== platform || $[39] !== text || $[40] !== tooltipId) {
325
- t20 = keybindingHints.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
342
+ let t19;
343
+ if ($[39] !== className) {
344
+ t19 = clsx(className, Tooltip_module_css_default.Tooltip);
345
+ $[39] = className;
346
+ $[40] = t19;
347
+ } else t19 = $[40];
348
+ const t20 = type === "description" ? "tooltip" : void 0;
349
+ const t21 = hasAriaLabel_0 || keybindingHints.length === 0 ? tooltipId : void 0;
350
+ let t22;
351
+ if ($[41] !== hasAriaLabel_0 || $[42] !== keybindingHints || $[43] !== platform || $[44] !== text || $[45] !== tooltipId) {
352
+ t22 = keybindingHints.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
326
353
  id: hasAriaLabel_0 ? void 0 : tooltipId,
327
354
  children: [text, /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
328
355
  "(",
@@ -335,57 +362,57 @@ const Tooltip = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
335
362
  "data-component": "Tooltip.KeybindingHintContainer",
336
363
  children: keybindingHints.map(_temp4)
337
364
  })] }) : text;
338
- $[36] = hasAriaLabel_0;
339
- $[37] = keybindingHints;
340
- $[38] = platform;
341
- $[39] = text;
342
- $[40] = tooltipId;
343
- $[41] = t20;
344
- } else t20 = $[41];
345
- let t21;
346
- if ($[42] !== calculatedDirection || $[43] !== closeTooltip || $[44] !== openTooltip || $[45] !== rest || $[46] !== t17 || $[47] !== t18 || $[48] !== t19 || $[49] !== t20) {
347
- t21 = /* @__PURE__ */ jsx("span", {
348
- className: t17,
365
+ $[41] = hasAriaLabel_0;
366
+ $[42] = keybindingHints;
367
+ $[43] = platform;
368
+ $[44] = text;
369
+ $[45] = tooltipId;
370
+ $[46] = t22;
371
+ } else t22 = $[46];
372
+ let t23;
373
+ if ($[47] !== calculatedDirection || $[48] !== closeTooltip || $[49] !== openTooltip || $[50] !== rest || $[51] !== t19 || $[52] !== t20 || $[53] !== t21 || $[54] !== t22) {
374
+ t23 = /* @__PURE__ */ jsx("span", {
375
+ className: t19,
349
376
  ref: tooltipElRef,
350
377
  "data-direction": calculatedDirection,
351
378
  "data-component": "Tooltip",
352
379
  ...rest,
353
- role: t18,
380
+ role: t20,
354
381
  "aria-hidden": true,
355
382
  onMouseEnter: openTooltip,
356
383
  onMouseLeave: closeTooltip,
357
- id: t19,
358
- children: t20
359
- });
360
- $[42] = calculatedDirection;
361
- $[43] = closeTooltip;
362
- $[44] = openTooltip;
363
- $[45] = rest;
364
- $[46] = t17;
365
- $[47] = t18;
366
- $[48] = t19;
367
- $[49] = t20;
368
- $[50] = t21;
369
- } else t21 = $[50];
370
- let t22;
371
- if ($[51] !== t15 || $[52] !== t21) {
372
- t22 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t15, t21] });
373
- $[51] = t15;
374
- $[52] = t21;
375
- $[53] = t22;
376
- } else t22 = $[53];
377
- let t23;
378
- if ($[54] !== t14.Provider || $[55] !== t22 || $[56] !== value) {
379
- t23 = /* @__PURE__ */ jsx(t14.Provider, {
380
- value,
384
+ id: t21,
381
385
  children: t22
382
386
  });
383
- $[54] = t14.Provider;
384
- $[55] = t22;
385
- $[56] = value;
387
+ $[47] = calculatedDirection;
388
+ $[48] = closeTooltip;
389
+ $[49] = openTooltip;
390
+ $[50] = rest;
391
+ $[51] = t19;
392
+ $[52] = t20;
393
+ $[53] = t21;
394
+ $[54] = t22;
395
+ $[55] = t23;
396
+ } else t23 = $[55];
397
+ let t24;
398
+ if ($[56] !== t17 || $[57] !== t23) {
399
+ t24 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t17, t23] });
400
+ $[56] = t17;
386
401
  $[57] = t23;
387
- } else t23 = $[57];
388
- return t23;
402
+ $[58] = t24;
403
+ } else t24 = $[58];
404
+ let t25;
405
+ if ($[59] !== t16.Provider || $[60] !== t24 || $[61] !== value) {
406
+ t25 = /* @__PURE__ */ jsx(t16.Provider, {
407
+ value,
408
+ children: t24
409
+ });
410
+ $[59] = t16.Provider;
411
+ $[60] = t24;
412
+ $[61] = value;
413
+ $[62] = t25;
414
+ } else t25 = $[62];
415
+ return t25;
389
416
  });
390
417
  Tooltip.__SLOT__ = Symbol("Tooltip");
391
418
  function _temp(grandChild) {
@@ -2793,7 +2793,7 @@
2793
2793
  },
2794
2794
  {
2795
2795
  "id": "experimental-components-datatable-features--with-collapsible-groups",
2796
- "code": "() => {\n const titleId = React.useId()\n const [expandedGroups, setExpandedGroups] = React.useState<\n ReadonlySet<DataTableRowId>\n >(() => new Set(['internal', 'public']))\n const [selectedRows, setSelectedRows] = React.useState<\n ReadonlySet<DataTableRowId>\n >(() => new Set())\n return (\n <Table.Container>\n <Table.Title as=\"h2\" id={titleId}>\n Collapsible repositories by visibility\n </Table.Title>\n <Table.Actions>\n <Button onClick={() => setExpandedGroups(new Set())}>\n Collapse all groups\n </Button>\n <Button\n onClick={() => setExpandedGroups(new Set(['internal', 'public']))}\n >\n Expand all groups\n </Button>\n </Table.Actions>\n <DataTable\n aria-labelledby={titleId}\n data={repoGroupsWithDisabledRow}\n columns={sortableGroupedColumns}\n collapsibleGroups\n expandedGroups={expandedGroups}\n onExpandedGroupsChange={({ expandedGroups }) =>\n setExpandedGroups(expandedGroups)\n }\n rowSelection\n selectedRows={selectedRows}\n onSelectionChange={({ selectedRows }) => setSelectedRows(selectedRows)}\n isRowSelectable={(repo) => repo.id !== 1}\n />\n </Table.Container>\n )\n}"
2796
+ "code": "() => {\n const titleId = React.useId()\n const [expandedGroups, setExpandedGroups] = React.useState<\n ReadonlySet<DataTableRowId>\n >(() => new Set(['public']))\n return (\n <Table.Container>\n <Table.Title as=\"h2\" id={titleId}>\n Repositories\n </Table.Title>\n <Table.Actions>\n <Button onClick={() => setExpandedGroups(new Set())}>\n Collapse all groups\n </Button>\n <Button onClick={() => setExpandedGroups(new Set(['public']))}>\n Expand all groups\n </Button>\n </Table.Actions>\n <DataTable\n aria-labelledby={titleId}\n data={[\n {\n id: 'github',\n name: 'github/github',\n visibility: 'Internal',\n },\n {\n groupId: 'public',\n label: 'Public',\n rows: [\n {\n id: 'react',\n name: 'primer/react',\n visibility: 'Public',\n },\n {\n id: 'css',\n name: 'primer/css',\n visibility: 'Public',\n },\n ],\n },\n ]}\n columns={[\n {\n header: 'Repository',\n field: 'name',\n rowHeader: true,\n },\n {\n header: 'Visibility',\n field: 'visibility',\n },\n ]}\n collapsibleGroups\n expandedGroups={expandedGroups}\n onExpandedGroupsChange={({ expandedGroups }) =>\n setExpandedGroups(expandedGroups)\n }\n rowSelection\n defaultSelectedRows={new Set(['react'])}\n />\n </Table.Container>\n )\n}"
2797
2797
  },
2798
2798
  {
2799
2799
  "id": "experimental-components-table-features--with-groups",
@@ -2834,7 +2834,7 @@
2834
2834
  {
2835
2835
  "name": "rowSelection",
2836
2836
  "type": "boolean",
2837
- "description": "Render row checkboxes and a select-all checkbox for the current page."
2837
+ "description": "Render row checkboxes and current-page select-all. Collapsible groups also get a checkbox for their selectable members."
2838
2838
  },
2839
2839
  {
2840
2840
  "name": "selectedRows",
@@ -3049,6 +3049,21 @@
3049
3049
  "type": "({ expanded }: { expanded: boolean }) => void",
3050
3050
  "description": "Handle a disclosure request. Controlled groups wait for the expanded prop to update."
3051
3051
  },
3052
+ {
3053
+ "name": "selection",
3054
+ "type": "'all' | 'some' | 'none'",
3055
+ "description": "Render a group checkbox with the given selection state."
3056
+ },
3057
+ {
3058
+ "name": "selectionDisabled",
3059
+ "type": "boolean",
3060
+ "description": "Disable the group checkbox without disabling its disclosure."
3061
+ },
3062
+ {
3063
+ "name": "onToggleSelect",
3064
+ "type": "() => void",
3065
+ "description": "Handle group checkbox activation. Consumers own member selection. When omitted, the group checkbox is disabled."
3066
+ },
3052
3067
  {
3053
3068
  "name": "id",
3054
3069
  "type": "string | number",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.45.0-rc.72a855661",
4
+ "version": "38.45.0-rc.cac8791d9",
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",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/DataTable/Table.module.css.js"],"names":[],"mappings":"AACA,oCAUE,mCAA8B,CAT9B,YAAa,CAEb,uHAMiB,CAPjB,6BASF,CAGA,gCAQE,iBAAkB,CANlB,8CAAuC,CACvC,gDAA6C,CAI7C,eAAgB,CAFhB,gBAIF,CAGA,mEANE,oCAA6B,CAL7B,QAkBF,CAPA,mCAEE,4CAAsC,CACtC,8CAA2C,CAG3C,kBAAmB,CAFnB,kDAGF,CAGA,kCAGE,kBAAmB,CADnB,mCAA8B,CAD9B,YAAa,CAGb,iBAAkB,CAClB,gBACF,CAGA,kCAIE,mDAA4C,CAC5C,iBAAkB,CAHlB,UAAW,CAKX,yCAAoC,CADpC,2CAAuC,CALvC,UAOF,CAGA,mOAGE,2CACF,CAOA,qEAJE,eAsCF,CAlCA,2BAEE,8BAA+B,CAC/B,wFAA2F,CAC3F,yBAA0B,CAW1B,4CAAwC,CADxC,wBAAyB,CAFzB,gBAAiB,CANjB,YAAa,CAGb,gCAAiC,CAQjC,kDAAmD,CANnD,mBAA0B,CAJ1B,UA2BF,CAdE,gEACE,4BAA6B,CAC7B,4BACF,CAEA,6DACE,2BAA4B,CAC5B,6BACF,CAEA,+DACE,4BAA6B,CAC7B,0BACF,CAIF,wFAEE,6FACF,CAEA,sFAEE,2FACF,CAEA,gEAME,kBAAmB,CACnB,0FAA0E,CAL1E,YAAa,CAEb,iCAAkC,CAClC,gBAGF,CAEA,0HAEE,YAAa,CAEb,wBAAyB,CADzB,cAEF,CAEA,2FACE,YAAa,CACb,0BACF,CAEA,4GACE,4FACF,CAIA,wHAEE,iDACF,CAGA,uHAEE,kDACF,CAGA,kNAEE,oDACF,CAGA,iNAEE,qDACF,CAGA,wNAIE,oDAAqD,CAErD,qDACF,CAOA,6KAEE,6CACF,CAEA,2KAEE,2CACF,CAGA,iCAGE,6CAAsC,CACtC,4FAA4E,CAF5E,kCAA2B,CAD3B,gDAIF,CAEA,6HAEE,oCACF,CAEA,iFAEE,sBACF,CAGA,mCACE,iBACF,CASA,yZAEE,kBACF,CAGA,+GACE,mEACF,CAGA,kDAIE,kBAAmB,CADnB,oCAA6B,CAF7B,YAAa,CACb,gDAGF,CAGA,uCACE,SACF,CAEA,4CACE,YAAa,CAEb,qBAAsB,CADtB,UAEF,CAEA,2CAEE,iCAqBF,CAnBE,6DACE,yBACF,CAEA,6DACE,2BACF,CAEA,6DACE,yBACF,CAEA,6DACE,yBACF,CAEA,6DACE,yBACF,CAGF,yEACE,gCACF,CAEA,8DACE,0FACF,CAEA,qCACE,gBACF,CAGA,sIAIE,gBACF,CAEA,0CACE,sIAIE,YAAa,CAEb,gBAAkB,CADlB,6BAEF,CACF,CAEA,0CAGE,kBAAmB,CAOnB,6CAAsC,CAGtC,0FAA0E,CAD1E,2FAA2E,CAD3E,6FAA6E,CAF7E,kCAA2B,CAJ3B,6CAAgD,CAJhD,YAAa,CACb,gBAAmB,CAKnB,iCAAkC,CAClC,gBAMF,CAEA,6CAEE,oBAAqB,CACrB,mCAA8B,CAF9B,YAGF,CAEA,2CAEE,oCAA6B,CAD7B,gDAEF,CAEA,2CACE,kCACF,CAEA,+CACE,YACF,CAEA,sCAOE,kBAAmB,CAEnB,iBAAkB,CAElB,gDAAwC,CALxC,oCAA6B,CAL7B,mBAAoB,CASpB,aAAc,CAPd,iCAA2B,CAK3B,sBAAuB,CAHvB,6EAAoE,CAHpE,gCAkBF,CAPE,4CACE,uDACF,CAEA,sEACE,uBACF,CAGF,qCACE,kCACF","file":"Table-7f0e985b.css","sourcesContent":["/* Container ---------------------------------------------------------------- */\n.TableContainer {\n display: grid;\n grid-template-columns: 1fr 1fr;\n grid-template-areas:\n 'title actions'\n 'divider divider'\n 'subtitle subtitle'\n 'filter filter'\n 'table table'\n 'footer footer';\n column-gap: var(--base-size-8);\n}\n\n/* TableTitle */\n.TableTitle {\n margin: 0;\n font-size: var(--text-body-size-medium);\n font-weight: var(--base-text-weight-semibold);\n /* stylelint-disable-next-line primer/typography */\n line-height: 20px;\n color: var(--fgColor-default);\n grid-area: title;\n align-self: center;\n}\n\n/* TableSubtitle */\n.TableSubtitle {\n margin: 0;\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-normal);\n line-height: var(--text-title-lineHeight-small);\n color: var(--fgColor-default);\n grid-area: subtitle;\n}\n\n/* TableActions */\n.TableActions {\n display: flex;\n column-gap: var(--base-size-8);\n align-items: center;\n grid-area: actions;\n justify-self: end;\n}\n\n/* TableDivider */\n.TableDivider {\n width: 100%;\n height: 1px;\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-default);\n grid-area: divider;\n margin-block-start: var(--base-size-16);\n margin-block-end: var(--base-size-8);\n}\n\n/* Spacing before the table */\n.TableTitle + .TableOverflowWrapper,\n.TableSubtitle + .TableOverflowWrapper,\n.TableActions + .TableOverflowWrapper {\n margin-block-start: var(--base-size-8);\n}\n\n.TableOverflowWrapper {\n grid-area: table;\n}\n\n/* Table -------------------------------------------------------------------- */\n.Table {\n /* Default table styles */\n --table-border-radius: 0.375rem;\n --table-cell-padding: var(--cell-padding-block, 0.5rem) var(--cell-padding-inline, 0.75rem);\n --table-font-size: 0.75rem;\n\n display: grid;\n width: 100%;\n /* stylelint-disable-next-line primer/typography */\n font-size: var(--table-font-size);\n /* stylelint-disable-next-line primer/typography */\n line-height: calc(20 / 12);\n border-spacing: 0;\n /* stylelint-disable-next-line primer/borders */\n border-collapse: separate;\n background-color: var(--bgColor-default);\n grid-area: table;\n grid-template-columns: var(--grid-template-columns);\n\n /* Density modes: condensed, normal, spacious */\n &:where([data-cell-padding='condensed']) {\n --cell-padding-block: 0.25rem;\n --cell-padding-inline: 0.5rem;\n }\n\n &:where([data-cell-padding='normal']) {\n --cell-padding-block: 0.5rem;\n --cell-padding-inline: 0.75rem;\n }\n\n &:where([data-cell-padding='spacious']) {\n --cell-padding-block: 0.75rem;\n --cell-padding-inline: 1rem;\n }\n}\n\n/* Borders */\n.TableCell:first-child,\n.TableHeader:first-child {\n border-inline-start: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableCell:last-child,\n.TableHeader:last-child {\n border-inline-end: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableHeader,\n.TableCell {\n display: flex;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--table-cell-padding);\n text-align: start;\n align-items: center;\n border-block-end: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableHeader:where([data-cell-align='end']),\n.TableCell:where([data-cell-align='end']) {\n display: flex;\n text-align: end;\n justify-content: flex-end;\n}\n\n.TableHeader[data-cell-align='end'] .TableSortButton {\n display: flex;\n flex-direction: row-reverse;\n}\n\n.TableHead .TableRow:first-of-type .TableHeader {\n border-block-start: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n/* Border radius */\n/* stylelint-disable-next-line selector-max-specificity */\n.TableHead .TableRow:first-of-type .TableHeader:first-child {\n /* stylelint-disable-next-line primer/borders */\n border-top-left-radius: var(--table-border-radius);\n}\n\n/* stylelint-disable-next-line selector-max-specificity */\n.TableHead .TableRow:first-of-type .TableHeader:last-child {\n /* stylelint-disable-next-line primer/borders */\n border-top-right-radius: var(--table-border-radius);\n}\n\n/* stylelint-disable-next-line selector-max-compound-selectors,selector-max-specificity */\n.TableOverflowWrapper:last-child .Table .TableBody:last-of-type .TableRow:last-of-type .TableCell:first-child {\n /* stylelint-disable-next-line primer/borders */\n border-bottom-left-radius: var(--table-border-radius);\n}\n\n/* stylelint-disable-next-line selector-max-compound-selectors,selector-max-specificity */\n.TableOverflowWrapper:last-child .Table .TableBody:last-of-type .TableRow:last-of-type .TableCell:last-child {\n /* stylelint-disable-next-line primer/borders */\n border-bottom-right-radius: var(--table-border-radius);\n}\n\n/* stylelint-disable selector-pseudo-class-disallowed-list, selector-max-compound-selectors -- scoped to a group header and its adjacent member body */\n.TableOverflowWrapper:last-child\n .TableGroupHeaderBody:where(:has(+ .TableBody:where([hidden], :empty):last-child))\n .TableGroupHeaderCell {\n /* stylelint-disable-next-line primer/borders */\n border-bottom-left-radius: var(--table-border-radius);\n /* stylelint-disable-next-line primer/borders */\n border-bottom-right-radius: var(--table-border-radius);\n}\n/* stylelint-enable selector-pseudo-class-disallowed-list, selector-max-compound-selectors */\n\n/**\n * Offset padding to make sure type aligns regardless of cell padding\n * selection\n */\n.TableRow > *:first-child:not(.TableCellSkeleton),\n.TableRow > *:first-child .TableCellSkeletonItem {\n padding-inline-start: var(--base-size-16);\n}\n\n.TableRow > *:last-child:not(.TableCellSkeleton),\n.TableRow > *:last-child .TableCellSkeletonItem {\n padding-inline-end: var(--base-size-16);\n}\n\n/* TableHeader */\n.TableHeader {\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-muted);\n background-color: var(--bgColor-muted);\n border-block-start: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableHeader:where([aria-sort='descending']),\n.TableHeader:where([aria-sort='ascending']) {\n color: var(--fgColor-default);\n}\n\n.TableSelectionHeader,\n.TableRowSelection {\n justify-content: center;\n}\n\n/* Control visibility of sort icons */\n.TableSortIcon {\n visibility: hidden;\n}\n\n/* The ASC icon is visible if the header is sortable and is hovered or focused */\n.TableHeader:hover .TableSortIcon--ascending,\n.TableHeader .TableSortButton:focus .TableSortIcon--ascending {\n visibility: visible;\n}\n\n/* Each sort icon is visible if the TableHeader is currently in the corresponding sort state */\n.TableHeader[aria-sort='ascending'] .TableSortIcon--ascending,\n.TableHeader[aria-sort='descending'] .TableSortIcon--descending {\n visibility: visible;\n}\n\n/* TableRow */\n.TableRow:hover .TableCell:not(.TableCellSkeleton) {\n background-color: var(--control-transparent-bgColor-hover);\n}\n\n/* TableCell */\n.TableCell:where([scope='row']) {\n display: flex;\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-default);\n align-items: center;\n}\n\n/* TableCellSkeleton */\n.TableCellSkeleton {\n padding: 0;\n}\n\n.TableCellSkeletonItems {\n display: flex;\n width: 100%;\n flex-direction: column;\n}\n\n.TableCellSkeletonItem {\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--table-cell-padding);\n\n &:nth-of-type(5n + 1) {\n --skeleton-item-width: 85%;\n }\n\n &:nth-of-type(5n + 2) {\n --skeleton-item-width: 67.5%;\n }\n\n &:nth-of-type(5n + 3) {\n --skeleton-item-width: 80%;\n }\n\n &:nth-of-type(5n + 4) {\n --skeleton-item-width: 60%;\n }\n\n &:nth-of-type(5n + 5) {\n --skeleton-item-width: 75%;\n }\n}\n\n.TableCellSkeletonItem [data-component='SkeletonText'] {\n width: var(--skeleton-item-width);\n}\n\n.TableCellSkeletonItem:not(:last-of-type) {\n border-block-end: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableSortButton {\n column-gap: 0.5rem;\n}\n\n/* Grid layout */\n.TableHead,\n.TableBody,\n.TableGroupHeaderBody,\n.TableRow {\n display: contents;\n}\n\n@supports (grid-template-columns: subgrid) {\n .TableHead,\n .TableBody,\n .TableGroupHeaderBody,\n .TableRow {\n display: grid;\n grid-template-columns: subgrid;\n grid-column: -1 /1;\n }\n}\n\n.TableGroupHeaderCell {\n display: flex;\n grid-column: 1 / -1;\n align-items: center;\n /* Match the padding on either side of the selection/data column boundary. */\n column-gap: calc(2 * var(--cell-padding-inline));\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--table-cell-padding);\n text-align: start;\n color: var(--fgColor-muted);\n background-color: var(--bgColor-muted);\n border-inline-start: var(--borderWidth-thin) solid var(--borderColor-default);\n border-inline-end: var(--borderWidth-thin) solid var(--borderColor-default);\n border-block-end: var(--borderWidth-thin) solid var(--borderColor-default);\n}\n\n.TableGroupHeaderContent {\n display: flex;\n align-items: baseline;\n column-gap: var(--base-size-8);\n}\n\n.TableGroupHeaderLabel {\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-default);\n}\n\n.TableGroupHeaderCount {\n color: var(--fgColor-muted);\n}\n\n.TableBody:where([hidden]) {\n display: none;\n}\n\n.TableGroupToggle {\n display: inline-flex;\n width: var(--base-size-24);\n height: var(--base-size-24);\n /* Center the hit target over the same 16px slot as a selection checkbox. */\n margin-inline: calc((var(--base-size-16) - var(--base-size-24)) / 2);\n color: var(--fgColor-default);\n align-items: center;\n justify-content: center;\n align-self: center;\n flex-shrink: 0;\n border-radius: var(--borderRadius-small);\n\n &:hover {\n background-color: var(--bgColor-neutral-muted);\n }\n\n &:where([aria-expanded='true']) svg {\n transform: rotate(90deg);\n }\n}\n\n.PlaceholderText {\n color: var(--fgColor-muted);\n}\n"]}