@primer/react 0.0.0-20260707192942 → 0.0.0-20260707193228

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260707192942
3
+ ## 0.0.0-20260707193228
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -17,12 +17,14 @@
17
17
 
18
18
  ### Patch Changes
19
19
 
20
+ - [#8005](https://github.com/primer/react/pull/8005) [`5d24be4`](https://github.com/primer/react/commit/5d24be483f2fdfa305970907984d04522e2aa13c) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Derive `AutocompleteMenu` close-time re-sorting and `LabelGroup` numeric truncation during render instead of in effects, removing redundant render passes. No public API or visual changes.
21
+
22
+ - [#8001](https://github.com/primer/react/pull/8001) [`4e6cf0d`](https://github.com/primer/react/commit/4e6cf0d1715e0371169b291be7a503f2d15f7bc5) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Derive state during render instead of in effects for `useMedia`, `ToggleSwitch`, `SelectPanel`, and the internal validation animation container, removing redundant render passes. Note: `useMedia` now returns the live `matchMedia` value on the first client render; `defaultState` is only used for the SSR/hydration snapshot (no public API changes).
23
+
20
24
  - Fake entry to force publishing
21
25
 
22
26
  - [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
23
27
 
24
- - [#7903](https://github.com/primer/react/pull/7903) [`6d3da65`](https://github.com/primer/react/commit/6d3da6556c26b40b106e92ffd6b120e66a281deb) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SegmentedControl: improve rendering performance by removing an expensive `:has()` selector used for the inter-item divider. No visual or API changes.
25
-
26
28
  - [#8035](https://github.com/primer/react/pull/8035) [`723f4d6`](https://github.com/primer/react/commit/723f4d6db12710e2b94f56b945a937158fcbb127) Thanks [@mattcosta7](https://github.com/mattcosta7)! - UnderlineNav, ActionBar: Detect item overflow with a single shared IntersectionObserver per component instead of one observer per item, reducing observer churn during resize. No public API changes.
27
29
 
28
30
  ## 38.31.0
@@ -43,7 +43,7 @@ const debounceAnnouncement = debounce((announcement) => {
43
43
  announce(announcement);
44
44
  }, 250);
45
45
  function AutocompleteMenu(props) {
46
- const $ = c(78);
46
+ const $ = c(75);
47
47
  const autocompleteContext = useContext(AutocompleteContext);
48
48
  const deferredInputContext = useContext(AutocompleteDeferredInputContext);
49
49
  if (autocompleteContext === null || deferredInputContext === null) throw new Error("AutocompleteContext returned null values");
@@ -253,54 +253,46 @@ function AutocompleteMenu(props) {
253
253
  t16 = $[54];
254
254
  }
255
255
  useEffect(t15, t16);
256
+ if (showMenu === false) {
257
+ const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
258
+ if (!(itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]))) setSortedItemIds(itemIdSortResult);
259
+ }
256
260
  let t17;
257
261
  let t18;
258
- if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
262
+ if ($[55] !== onOpenChange || $[56] !== showMenu) {
259
263
  t17 = () => {
260
- const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
261
- const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
262
- if (showMenu === false && !sortResultMatchesState) setSortedItemIds(itemIdSortResult);
263
264
  onOpenChange && onOpenChange(Boolean(showMenu));
264
265
  };
265
- t18 = [
266
- showMenu,
267
- onOpenChange,
268
- selectedItemIds,
269
- sortOnCloseFn,
270
- sortedItemIds
271
- ];
266
+ t18 = [showMenu, onOpenChange];
272
267
  $[55] = onOpenChange;
273
- $[56] = selectedItemIds;
274
- $[57] = showMenu;
275
- $[58] = sortOnCloseFn;
276
- $[59] = sortedItemIds;
277
- $[60] = t17;
278
- $[61] = t18;
268
+ $[56] = showMenu;
269
+ $[57] = t17;
270
+ $[58] = t18;
279
271
  } else {
280
- t17 = $[60];
281
- t18 = $[61];
272
+ t17 = $[57];
273
+ t18 = $[58];
282
274
  }
283
275
  useEffect(t17, t18);
284
276
  let t19;
285
- if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
277
+ if ($[59] !== selectedItemIds.length || $[60] !== setSelectedItemLength) {
286
278
  t19 = () => {
287
279
  if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
288
280
  };
289
- $[62] = selectedItemIds.length;
290
- $[63] = setSelectedItemLength;
291
- $[64] = t19;
292
- } else t19 = $[64];
281
+ $[59] = selectedItemIds.length;
282
+ $[60] = setSelectedItemLength;
283
+ $[61] = t19;
284
+ } else t19 = $[61];
293
285
  let t20;
294
- if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
286
+ if ($[62] !== selectedItemIds || $[63] !== setSelectedItemLength) {
295
287
  t20 = [selectedItemIds, setSelectedItemLength];
296
- $[65] = selectedItemIds;
297
- $[66] = setSelectedItemLength;
298
- $[67] = t20;
299
- } else t20 = $[67];
288
+ $[62] = selectedItemIds;
289
+ $[63] = setSelectedItemLength;
290
+ $[64] = t20;
291
+ } else t20 = $[64];
300
292
  useEffect(t19, t20);
301
293
  if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
302
294
  let t21;
303
- if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
295
+ if ($[65] !== allItemsToRender || $[66] !== ariaLabelledBy || $[67] !== emptyStateText || $[68] !== id || $[69] !== loading || $[70] !== selectionVariant) {
304
296
  t21 = loading ? /*#__PURE__*/ jsx("div", {
305
297
  className: AutocompleteMenu_module_css_default.SpinnerWrapper,
306
298
  children: /*#__PURE__*/ jsx(Spinner, {})
@@ -318,24 +310,24 @@ function AutocompleteMenu(props) {
318
310
  children: emptyStateText
319
311
  }) : null
320
312
  });
321
- $[68] = allItemsToRender;
322
- $[69] = ariaLabelledBy;
323
- $[70] = emptyStateText;
324
- $[71] = id;
325
- $[72] = loading;
326
- $[73] = selectionVariant;
327
- $[74] = t21;
328
- } else t21 = $[74];
313
+ $[65] = allItemsToRender;
314
+ $[66] = ariaLabelledBy;
315
+ $[67] = emptyStateText;
316
+ $[68] = id;
317
+ $[69] = loading;
318
+ $[70] = selectionVariant;
319
+ $[71] = t21;
320
+ } else t21 = $[71];
329
321
  let t22;
330
- if ($[75] !== showMenu || $[76] !== t21) {
322
+ if ($[72] !== showMenu || $[73] !== t21) {
331
323
  t22 = /*#__PURE__*/ jsx(VisuallyHidden, {
332
324
  isVisible: showMenu,
333
325
  children: t21
334
326
  });
335
- $[75] = showMenu;
336
- $[76] = t21;
337
- $[77] = t22;
338
- } else t22 = $[77];
327
+ $[72] = showMenu;
328
+ $[73] = t21;
329
+ $[74] = t22;
330
+ } else t22 = $[74];
339
331
  return t22;
340
332
  }
341
333
  function _temp5(item_2) {
@@ -14,6 +14,16 @@ const getOverlayWidth = (buttonClientRect, containerRef, overlayPaddingPx) => {
14
14
  var _containerRef$current;
15
15
  return overlayPaddingPx + buttonClientRect.right - (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().left) || 0);
16
16
  };
17
+ const getVisibilityMapAfterIndex = (childCount, truncateAfter) => {
18
+ const updatedEntries = {};
19
+ for (let index = 0; index < childCount; index++) updatedEntries[index.toString()] = index < truncateAfter;
20
+ return updatedEntries;
21
+ };
22
+ const visibilityMapsMatch = (left, right) => {
23
+ const leftKeys = Object.keys(left);
24
+ const rightKeys = Object.keys(right);
25
+ return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);
26
+ };
17
27
  const InlineToggle = (t0) => {
18
28
  const $ = c(7);
19
29
  const { collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline } = t0;
@@ -133,6 +143,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
133
143
  bottom: 0,
134
144
  toJSON: () => void 0
135
145
  });
146
+ const childArray = React.Children.toArray(children);
136
147
  const overlayPaddingPx = 8;
137
148
  const hiddenItemIds = Object.keys(visibilityMap).filter((key) => !visibilityMap[key]);
138
149
  const overlayWidth = hiddenItemIds.length && overflowStyle === "overlay" ? getOverlayWidth(buttonClientRect, containerRef, overlayPaddingPx) : void 0;
@@ -144,15 +155,8 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
144
155
  }
145
156
  }, [buttonClientRect]);
146
157
  const hideChildrenAfterIndex = React.useCallback((truncateAfter) => {
147
- var _containerRef$current2;
148
- const containerChildren = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children) || [];
149
- const updatedEntries = {};
150
- for (const child of containerChildren) {
151
- const targetId = child.getAttribute("data-index");
152
- if (targetId) updatedEntries[targetId] = parseInt(targetId, 10) < truncateAfter;
153
- }
154
- setVisibilityMap(updatedEntries);
155
- }, []);
158
+ setVisibilityMap(getVisibilityMapAfterIndex(childArray.length, truncateAfter));
159
+ }, [childArray.length]);
156
160
  const openOverflowOverlay = React.useCallback(() => setIsOverflowShown(true), [setIsOverflowShown]);
157
161
  const closeOverflowOverlay = React.useCallback(() => {
158
162
  setIsOverflowShown(false);
@@ -173,34 +177,39 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
173
177
  setVisibilityMap({});
174
178
  setIsOverflowShown(true);
175
179
  }, [setVisibilityMap, setIsOverflowShown]);
180
+ const numericVisibilityMap = React.useMemo(() => visibleChildCount && typeof visibleChildCount === "number" && !isOverflowShown ? getVisibilityMapAfterIndex(childArray.length, visibleChildCount) : void 0, [
181
+ childArray.length,
182
+ isOverflowShown,
183
+ visibleChildCount
184
+ ]);
185
+ if (numericVisibilityMap && !visibilityMapsMatch(visibilityMap, numericVisibilityMap)) setVisibilityMap(numericVisibilityMap);
176
186
  React.useEffect(() => {
177
187
  if (!visibleChildCount || isOverflowShown) return;
178
188
  if (visibleChildCount === "auto") {
179
189
  const observer = new IntersectionObserver((entries) => {
180
- const updatedEntries_0 = {};
190
+ const updatedEntries = {};
181
191
  for (const entry of entries) {
182
- const targetId_0 = entry.target.getAttribute("data-index");
183
- if (targetId_0) updatedEntries_0[targetId_0] = entry.isIntersecting;
192
+ const targetId = entry.target.getAttribute("data-index");
193
+ if (targetId) updatedEntries[targetId] = entry.isIntersecting;
184
194
  }
185
195
  setVisibilityMap((prev) => ({
186
196
  ...prev,
187
- ...updatedEntries_0
197
+ ...updatedEntries
188
198
  }));
189
199
  }, {
190
200
  root: containerRef.current,
191
201
  rootMargin: `0px -${buttonClientRect.width}px 0px 0px`,
192
202
  threshold: 1
193
203
  });
194
- for (const item of ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []) {
195
- var _containerRef$current3;
204
+ for (const item of ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children) || []) {
205
+ var _containerRef$current2;
196
206
  if (item.getAttribute("data-index")) observer.observe(item);
197
207
  }
198
208
  return () => observer.disconnect();
199
- } else hideChildrenAfterIndex(visibleChildCount);
209
+ }
200
210
  }, [
201
211
  buttonClientRect,
202
212
  visibleChildCount,
203
- hideChildrenAfterIndex,
204
213
  isOverflowShown
205
214
  ]);
206
215
  React.useEffect(() => {
@@ -230,10 +239,10 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
230
239
  "data-list": isList || void 0,
231
240
  className: clsx(className, LabelGroup_module_css_default.Container),
232
241
  "data-component": "LabelGroup",
233
- children: [React.Children.map(children, (child_0, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
242
+ children: [childArray.map((child, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
234
243
  "data-index": index,
235
244
  className: clsx(LabelGroup_module_css_default.ItemWrapper, { [LabelGroup_module_css_default["ItemWrapper--hidden"]]: hiddenItemIds.includes(index.toString()) }),
236
- children: child_0
245
+ children: child
237
246
  }, index)), /*#__PURE__*/ jsx(ToggleWrapper, {
238
247
  "data-component": "LabelGroup.Toggle",
239
248
  children: overflowStyle === "inline" ? /*#__PURE__*/ jsx(InlineToggle, {
@@ -243,7 +252,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
243
252
  hiddenItemIds,
244
253
  isOverflowShown,
245
254
  showAllTokensInline,
246
- totalLength: React.Children.toArray(children).length
255
+ totalLength: childArray.length
247
256
  }) : /*#__PURE__*/ jsx(OverlayToggle, {
248
257
  closeOverflowOverlay,
249
258
  expandButtonRef,
@@ -252,7 +261,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
252
261
  openOverflowOverlay,
253
262
  overlayPaddingPx,
254
263
  overlayWidth,
255
- totalLength: React.Children.toArray(children).length,
264
+ totalLength: childArray.length,
256
265
  children
257
266
  })
258
267
  })]
@@ -261,8 +270,8 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
261
270
  "data-list": isList || void 0,
262
271
  className: clsx(className, LabelGroup_module_css_default.Container),
263
272
  "data-component": "LabelGroup",
264
- children: isList ? React.Children.map(children, (child_1, index_0) => {
265
- return /*#__PURE__*/ jsx("li", { children: child_1 }, index_0);
273
+ children: isList ? React.Children.map(children, (child_0, index_0) => {
274
+ return /*#__PURE__*/ jsx("li", { children: child_0 }, index_0);
266
275
  }) : children
267
276
  });
268
277
  };
@@ -0,0 +1,2 @@
1
+ .prc-SegmentedControl-SegmentedControl-lqIXp{--segmented-control-icon-width:32px;background-color:var(--controlTrack-bgColor-rest,#e6eaef);border:var(--borderWidth-thin,.0625rem) solid var(--controlTrack-borderColor-rest,transparent);border-radius:var(--borderRadius-medium,.375rem);display:inline-flex;font-size:var(--text-body-size-medium,.875rem);height:32px;margin:0;padding:0}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]:not([data-full-width-wide=true]),.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}.prc-SegmentedControl-SegmentedControl-lqIXp:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);height:28px}.prc-SegmentedControl-DropdownContainer-ZaPMn{display:none}.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant=dropdown]{display:block}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-narrow=dropdown]{display:block}}@media (min-width:48rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-regular=dropdown]{display:block}}@media (min-width:87.5rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-wide=dropdown]{display:block}}.prc-SegmentedControl-Item-tSCQh{display:block;flex-grow:1;margin-bottom:-1px;margin-top:-1px;position:relative}.prc-SegmentedControl-Item-tSCQh:not(:last-child){margin-right:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):after{background-color:var(--borderColor-default,#d1d9e0);bottom:var(--base-size-8,.5rem);content:"";position:absolute;right:calc(var(--base-size-2,.125rem)*-1);top:var(--base-size-8,.5rem);width:1px}.prc-SegmentedControl-Item-tSCQh:not(:last-child):has(+[data-selected]):after,.prc-SegmentedControl-Item-tSCQh:not(:last-child):where([data-selected]):after{background-color:transparent}.prc-SegmentedControl-Item-tSCQh:first-child{margin-left:-1px}.prc-SegmentedControl-Item-tSCQh:last-child{margin-right:-1px}.prc-SegmentedControl-Item-tSCQh .prc-SegmentedControl-Counter-GmZOI{align-items:center;display:flex;margin-inline-start:var(--base-size-8,.5rem)}.prc-SegmentedControl-Button-E48xz{--segmented-control-button-inner-padding:12px;--segmented-control-button-bg-inset:4px;--segmented-control-outer-radius:var(--borderRadius-medium,0.375rem);background-color:transparent;border-color:transparent;border-radius:var(--segmented-control-outer-radius);border-width:0;color:currentColor;cursor:pointer;font-family:inherit;font-size:inherit;font-weight:var(--base-text-weight-normal,400);height:100%;padding:var(--segmented-control-button-bg-inset);width:100%}.prc-SegmentedControl-Button-E48xz svg{fill:var(--fgColor-muted,#59636e);color:var(--fgColor-muted,#59636e)}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled):not(:focus-visible){outline:1px solid transparent}.prc-SegmentedControl-Button-E48xz:focus-visible:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:focus-visible:not(:last-child):after{width:0}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]){background-color:transparent;color:var(--fgColor-disabled,#818b98);cursor:not-allowed}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]) svg{fill:var(--fgColor-disabled,#818b98);color:var(--fgColor-disabled,#818b98)}@media (pointer:coarse){.prc-SegmentedControl-Button-E48xz:before{content:"";left:0;min-height:44px;position:absolute;right:0;top:50%;transform:translateY(-50%)}}.prc-SegmentedControl-IconButton-tlzDE{width:var(--segmented-control-icon-width,32px)}.prc-SegmentedControl-Content-1COlk{align-items:center;border-color:transparent;border-radius:calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset)/2);border-style:solid;border-width:var(--borderWidth-thin,.0625rem);display:flex;height:100%;justify-content:center;padding-left:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));padding-right:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset))}.prc-SegmentedControl-Button-E48xz[aria-current=true]{font-weight:var(--base-text-weight-semibold,600);padding:0}.prc-SegmentedControl-Button-E48xz[aria-current=true] .prc-SegmentedControl-Content-1COlk{background-color:var(--controlKnob-bgColor-rest,#fff);border-color:var(--controlKnob-borderColor-rest,#d1d9e0);border-radius:var(--segmented-control-outer-radius);padding-left:var(--segmented-control-button-inner-padding);padding-right:var(--segmented-control-button-inner-padding)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):hover .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-hover,#e0e6eb)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):active .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-active,#dae0e7)}.prc-SegmentedControl-Text-7S2y2:after{content:attr(data-text);display:block;font-weight:var(--base-text-weight-semibold,600);height:0;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none;visibility:hidden}.prc-SegmentedControl-LeadingIcon-74n5s{margin-right:var(--base-size-4,.25rem)}
2
+ /*# sourceMappingURL=SegmentedControl-a004561f.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SegmentedControl/SegmentedControl.module.css.js"],"names":[],"mappings":"AAAA,6CAEE,mCAAoC,CASpC,yDAAkD,CAClD,8FAAuF,CACvF,gDAAyC,CATzC,mBAAoB,CAMpB,8CAAuC,CAHvC,WAAY,CAEZ,QAAS,CADT,SA0HF,CAlHE,mEACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,oEACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CAEA,wCACE,0EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,2EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,yBACE,2EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,4EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,2BACE,wEACE,YAAa,CACb,UAAW,CAEX,mCACF,CASA,qLACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAQA,2KACE,YACF,CAEA,wCAKE,yLACE,YACF,CACF,CAEA,yBAKE,2LACE,YACF,CACF,CAEA,2BAKE,qLACE,YACF,CACF,CAEA,sEAGE,4CAAsC,CADtC,WAEF,CAGF,8CACE,YAwBF,CArBE,qEACE,aACF,CAEA,wCACE,4EACE,aACF,CACF,CAEA,yBACE,6EACE,aACF,CACF,CAEA,2BACE,0EACE,aACF,CACF,CAGF,iCAEE,aAAc,CAKd,WAAY,CADZ,kBAAmB,CAFnB,eAAgB,CAHhB,iBA6CF,CArCE,kDAEE,gBAkBF,CAhBE,wDAQE,mDAA4C,CAJ5C,+BAA0B,CAE1B,UAAW,CALX,iBAAkB,CAElB,yCAAoC,CADpC,4BAAuB,CAGvB,SAIF,CAGA,6JAEE,4BACF,CAGF,6CAEE,gBACF,CAEA,4CAEE,iBACF,CAEA,qEAGE,kBAAmB,CADnB,YAAa,CADb,4CAGF,CAGF,mCAEE,6CAA8C,CAC9C,uCAAwC,CACxC,oEAA4D,CAW5D,4BAA6B,CAC7B,wBAAyB,CAGzB,mDAAoD,CAFpD,cAAe,CAJf,kBAAmB,CACnB,cAAe,CAJf,mBAAoB,CACpB,iBAAkB,CAClB,8CAA2C,CAL3C,WAAY,CAEZ,gDAAiD,CAHjD,UAmEF,CApDE,uCACE,iCAA0B,CAC1B,kCACF,CAGA,wDAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAOF,CAHE,4EACE,6BACF,CAIF,gEAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAEF,CAGA,8EAEE,OACF,CAEA,gFAGE,4BAA6B,CAD7B,qCAA8B,CAD9B,kBAQF,CAJE,oFACE,oCAA6B,CAC7B,qCACF,CAGF,wBACE,0CAME,UAAW,CAFX,MAAO,CACP,eAAgB,CAJhB,iBAAkB,CAElB,OAAQ,CADR,OAAQ,CAKR,0BACF,CACF,CAGF,uCACE,8CACF,CAEA,oCAiBE,kBAAmB,CAVnB,wBAAyB,CASzB,sGAAyG,CARzG,kBAAmB,CACnB,6CAAqC,CARrC,YAAa,CACb,WAAY,CAgBZ,sBAAuB,CAZvB,2GAA4G,CAF5G,4GAeF,CAEA,sDAEE,gDAA6C,CAD7C,SAaF,CAVE,0FAKE,qDAAiD,CACjD,wDAAiD,CAEjD,mDAAoD,CAJpD,0DAA2D,CAF3D,2DAOF,CAIA,2HACE,0DACF,CAEA,4HACE,2DACF,CAGF,uCAOE,uBAAwB,CANxB,aAAc,CAGd,gDAA6C,CAF7C,QAAS,CACT,eAAgB,CAEhB,mBAAoB,CAGpB,wBAAiB,CAAjB,gBAAiB,CAFjB,iBAGF,CAEA,wCACE,sCACF","file":"SegmentedControl-a004561f.css","sourcesContent":[".SegmentedControl {\n /* TODO: use primitive `control.medium.size` when it is available instead of '32px' */\n --segmented-control-icon-width: 32px;\n\n display: inline-flex;\n\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 32px;\n padding: 0;\n margin: 0;\n font-size: var(--text-body-size-medium);\n background-color: var(--controlTrack-bgColor-rest);\n border: var(--borderWidth-thin) solid var(--controlTrack-borderColor-rest, transparent);\n border-radius: var(--borderRadius-medium);\n\n /* Responsive full-width */\n &[data-full-width='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n @media (--viewportRange-narrow) {\n &[data-full-width-narrow='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-narrow='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-full-width-regular='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-regular='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-full-width-wide='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-wide='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n &[data-full-width-regular='true']:not([data-full-width-wide='true']) {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n /* Hide when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: none;\n }\n\n /* Handle hideLabels variant - hide button text */\n &[data-variant='hideLabels'] .Text {\n display: none;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: none;\n }\n\n &[data-variant-narrow='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: none;\n }\n\n &[data-variant-regular='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: none;\n }\n\n &[data-variant-wide='hideLabels'] .Text {\n display: none;\n }\n }\n\n &:where([data-size='small']) {\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 28px;\n font-size: var(--text-body-size-small);\n }\n}\n\n.DropdownContainer {\n display: none;\n\n /* Show when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: block;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: block;\n }\n }\n}\n\n.Item {\n position: relative;\n display: block;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: -1px;\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n flex-grow: 1;\n\n &:not(:last-child) {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: 1px;\n\n &::after {\n position: absolute;\n top: var(--base-size-8);\n right: calc(-1 * var(--base-size-2));\n bottom: var(--base-size-8);\n width: 1px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-default);\n }\n\n /* stylelint-disable-next-line selector-pseudo-class-disallowed-list -- scoped to CSS Module, audited (github/github-ui#17224) */\n &:has(+ [data-selected])::after,\n &:where([data-selected])::after {\n background-color: transparent;\n }\n }\n\n &:first-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -1px;\n }\n\n &:last-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: -1px;\n }\n\n .Counter {\n margin-inline-start: var(--base-size-8);\n display: flex;\n align-items: center;\n }\n}\n\n.Button {\n /* TODO: use primitive `primer.control.medium.paddingInline.normal` when it is available */\n --segmented-control-button-inner-padding: 12px;\n --segmented-control-button-bg-inset: 4px;\n --segmented-control-outer-radius: var(--borderRadius-medium);\n\n width: 100%;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--segmented-control-button-bg-inset);\n font-family: inherit;\n font-size: inherit;\n font-weight: var(--base-text-weight-normal);\n color: currentColor;\n cursor: pointer;\n background-color: transparent;\n border-color: transparent;\n border-width: 0;\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n\n & svg {\n fill: var(--fgColor-muted);\n color: var(--fgColor-muted);\n }\n\n /* fallback :focus state */\n &:focus:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n\n /* remove fallback :focus if :focus-visible is supported */\n &:not(:focus-visible) {\n outline: solid 1px transparent;\n }\n }\n\n /* default focus state */\n &:focus-visible:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n }\n\n /* stylelint-disable-next-line selector-max-specificity */\n &:focus:focus-visible:not(:last-child)::after {\n /* fixes an issue where the focus outline shows over the pseudo-element */\n width: 0;\n }\n\n &[aria-disabled='true']:not([aria-current='true']) {\n cursor: not-allowed;\n color: var(--fgColor-disabled);\n background-color: transparent;\n\n & svg {\n fill: var(--fgColor-disabled);\n color: var(--fgColor-disabled);\n }\n }\n\n @media (pointer: coarse) {\n &::before {\n position: absolute;\n top: 50%;\n right: 0;\n left: 0;\n min-height: 44px;\n content: '';\n transform: translateY(-50%);\n }\n }\n}\n\n.IconButton {\n width: var(--segmented-control-icon-width, 32px);\n}\n\n.Content {\n display: flex;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding-right: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n /* stylelint-disable-next-line primer/spacing */\n padding-left: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n border-color: transparent;\n border-style: solid;\n border-width: var(--borderWidth-thin);\n\n /*\n innerRadius = outerRadius - distance/2\n https://stackoverflow.com/questions/2932146/math-problem-determine-the-corner-radius-of-an-inner-border-based-on-outer-corn\n */\n /* stylelint-disable-next-line primer/borders */\n border-radius: calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset) / 2);\n align-items: center;\n justify-content: center;\n}\n\n.Button[aria-current='true'] {\n padding: 0;\n font-weight: var(--base-text-weight-semibold);\n\n .Content {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--segmented-control-button-inner-padding);\n /* stylelint-disable-next-line primer/spacing */\n padding-left: var(--segmented-control-button-inner-padding);\n background-color: var(--controlKnob-bgColor-rest);\n border-color: var(--controlKnob-borderColor-rest);\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n }\n}\n\n.Button:not([aria-current='true'], [aria-disabled='true']) {\n &:hover .Content {\n background-color: var(--controlTrack-bgColor-hover);\n }\n\n &:active .Content {\n background-color: var(--controlTrack-bgColor-active);\n }\n}\n\n.Text::after {\n display: block;\n height: 0;\n overflow: hidden;\n font-weight: var(--base-text-weight-semibold);\n pointer-events: none;\n visibility: hidden;\n content: attr(data-text);\n user-select: none;\n}\n\n.LeadingIcon {\n margin-right: var(--base-size-4);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import "./SegmentedControl-66516913.css";
1
+ import "./SegmentedControl-a004561f.css";
2
2
  //#region src/SegmentedControl/SegmentedControl.module.css.js
3
3
  var SegmentedControl_module_css_default = {
4
4
  "SegmentedControl": "prc-SegmentedControl-SegmentedControl-lqIXp",
@@ -99,13 +99,11 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
99
99
  const selectedValueId = id ? `${id}-selected-value` : void 0;
100
100
  const isSingleSelectModal = variant === "modal" && !isMultiSelectVariant(selected);
101
101
  const [intermediateSelected, setIntermediateSelected] = useState(isSingleSelectModal ? selected : void 0);
102
- useEffect(() => {
102
+ const [prevOpen, setPrevOpen] = useState(open);
103
+ if (prevOpen !== open) {
104
+ setPrevOpen(open);
103
105
  setIntermediateSelected(isSingleSelectModal ? selected : void 0);
104
- }, [
105
- isSingleSelectModal,
106
- open,
107
- selected
108
- ]);
106
+ }
109
107
  const onListContainerRefChanged = useCallback((node) => {
110
108
  setListContainerElement(node);
111
109
  if (!node && needsNoItemsAnnouncement) setNeedsNoItemsAnnouncement(false);
@@ -179,12 +179,12 @@ const ToggleSwitch = /*#__PURE__*/ React.forwardRef(function ToggleSwitch(props,
179
179
  t7 = $[30];
180
180
  }
181
181
  useEffect(t6, t7);
182
+ if (!loading && isLoadingLabelVisible) setIsLoadingLabelVisible(false);
182
183
  let t8;
183
184
  let t9;
184
185
  if ($[31] !== isLoadingLabelVisible || $[32] !== loading || $[33] !== loadingLabelDelay || $[34] !== safeSetTimeout) {
185
186
  t8 = () => {
186
- if (!loading && isLoadingLabelVisible) setIsLoadingLabelVisible(false);
187
- else if (loading && !isLoadingLabelVisible) safeSetTimeout(() => {
187
+ if (loading && !isLoadingLabelVisible) safeSetTimeout(() => {
188
188
  setIsLoadingLabelVisible(true);
189
189
  }, loadingLabelDelay);
190
190
  };
@@ -1,8 +1,7 @@
1
- import { canUseDOM } from "../utils/environment.js";
2
1
  import { warning } from "../utils/warning.js";
3
2
  import { MatchMediaContext } from "./MatchMediaContext.js";
4
3
  import { c } from "react-compiler-runtime";
5
- import React, { useContext, useEffect } from "react";
4
+ import { useContext, useSyncExternalStore } from "react";
6
5
  //#region src/hooks/useMedia.ts
7
6
  /**
8
7
  * `useMedia` will use the given `mediaQueryString` with `matchMedia` to
@@ -18,52 +17,54 @@ import React, { useContext, useEffect } from "react";
18
17
  * }
19
18
  */
20
19
  function useMedia(mediaQueryString, defaultState) {
21
- const $ = c(8);
22
- const features = useContext(MatchMediaContext);
20
+ const $ = c(9);
21
+ const contextValue = useContext(MatchMediaContext)[mediaQueryString];
23
22
  let t0;
24
- if ($[0] !== defaultState || $[1] !== features || $[2] !== mediaQueryString) {
25
- t0 = () => {
26
- if (features[mediaQueryString] !== void 0) return features[mediaQueryString];
27
- if (defaultState !== void 0) return defaultState;
28
- if (canUseDOM) return window.matchMedia(mediaQueryString).matches;
29
- warning(true, "`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
30
- return false;
31
- };
32
- $[0] = defaultState;
33
- $[1] = features;
34
- $[2] = mediaQueryString;
35
- $[3] = t0;
36
- } else t0 = $[3];
37
- const [matches, setMatches] = React.useState(t0);
38
- if (features[mediaQueryString] !== void 0 && matches !== features[mediaQueryString]) setMatches(features[mediaQueryString]);
39
- let t1;
40
- let t2;
41
- if ($[4] !== features || $[5] !== mediaQueryString) {
42
- t1 = () => {
43
- if (features[mediaQueryString] !== void 0) return;
44
- const listener = function listener(event) {
45
- setMatches(event.matches);
46
- };
23
+ if ($[0] !== contextValue || $[1] !== mediaQueryString) {
24
+ t0 = (onStoreChange) => {
25
+ if (contextValue !== void 0) return _temp;
47
26
  const mediaQueryList = window.matchMedia(mediaQueryString);
48
- if (mediaQueryList.addEventListener) mediaQueryList.addEventListener("change", listener);
49
- else mediaQueryList.addListener(listener);
50
- setMatches(mediaQueryList.matches);
27
+ if (mediaQueryList.addEventListener) {
28
+ mediaQueryList.addEventListener("change", onStoreChange);
29
+ return () => {
30
+ mediaQueryList.removeEventListener("change", onStoreChange);
31
+ };
32
+ }
33
+ mediaQueryList.addListener(onStoreChange);
51
34
  return () => {
52
- if (mediaQueryList.addEventListener) mediaQueryList.removeEventListener("change", listener);
53
- else mediaQueryList.removeListener(listener);
35
+ mediaQueryList.removeListener(onStoreChange);
54
36
  };
55
37
  };
56
- t2 = [features, mediaQueryString];
57
- $[4] = features;
58
- $[5] = mediaQueryString;
59
- $[6] = t1;
60
- $[7] = t2;
61
- } else {
62
- t1 = $[6];
63
- t2 = $[7];
64
- }
65
- useEffect(t1, t2);
66
- return matches;
38
+ $[0] = contextValue;
39
+ $[1] = mediaQueryString;
40
+ $[2] = t0;
41
+ } else t0 = $[2];
42
+ const subscribe = t0;
43
+ let t1;
44
+ if ($[3] !== contextValue || $[4] !== mediaQueryString) {
45
+ t1 = () => {
46
+ if (contextValue !== void 0) return contextValue;
47
+ return window.matchMedia(mediaQueryString).matches;
48
+ };
49
+ $[3] = contextValue;
50
+ $[4] = mediaQueryString;
51
+ $[5] = t1;
52
+ } else t1 = $[5];
53
+ const getSnapshot = t1;
54
+ let t2;
55
+ if ($[6] !== contextValue || $[7] !== defaultState) {
56
+ t2 = () => {
57
+ if (contextValue !== void 0) return contextValue;
58
+ if (defaultState !== void 0) return defaultState;
59
+ warning(typeof window === "undefined", "`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
60
+ return false;
61
+ };
62
+ $[6] = contextValue;
63
+ $[7] = defaultState;
64
+ $[8] = t2;
65
+ } else t2 = $[8];
66
+ return useSyncExternalStore(subscribe, getSnapshot, t2);
67
67
  }
68
+ function _temp() {}
68
69
  //#endregion
69
70
  export { useMedia };
@@ -1,39 +1,25 @@
1
1
  import ValidationAnimationContainer_module_css_default from "./ValidationAnimationContainer.module.css.js";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { jsx } from "react/jsx-runtime";
4
- import { useEffect, useState } from "react";
4
+ import { useState } from "react";
5
5
  //#region src/internal/components/ValidationAnimationContainer.tsx
6
6
  const ValidationAnimationContainer = (t0) => {
7
- const $ = c(10);
7
+ const $ = c(7);
8
8
  const { show, children } = t0;
9
9
  const [shouldRender, setRender] = useState(show);
10
+ if (show && !shouldRender) setRender(true);
10
11
  let t1;
11
- let t2;
12
12
  if ($[0] !== show) {
13
13
  t1 = () => {
14
- if (show) setRender(true);
14
+ if (!show) setRender(false);
15
15
  };
16
- t2 = [show];
17
16
  $[0] = show;
18
17
  $[1] = t1;
19
- $[2] = t2;
20
- } else {
21
- t1 = $[1];
22
- t2 = $[2];
23
- }
24
- useEffect(t1, t2);
25
- let t3;
26
- if ($[3] !== show) {
27
- t3 = () => {
28
- if (!show) setRender(false);
29
- };
30
- $[3] = show;
31
- $[4] = t3;
32
- } else t3 = $[4];
33
- const onAnimationEnd = t3;
34
- let t4;
35
- if ($[5] !== children || $[6] !== onAnimationEnd || $[7] !== shouldRender || $[8] !== show) {
36
- t4 = shouldRender ? /*#__PURE__*/ jsx("div", {
18
+ } else t1 = $[1];
19
+ const onAnimationEnd = t1;
20
+ let t2;
21
+ if ($[2] !== children || $[3] !== onAnimationEnd || $[4] !== shouldRender || $[5] !== show) {
22
+ t2 = shouldRender ? /*#__PURE__*/ jsx("div", {
37
23
  style: {
38
24
  height: show ? "auto" : 0,
39
25
  overflow: "hidden"
@@ -45,13 +31,13 @@ const ValidationAnimationContainer = (t0) => {
45
31
  children
46
32
  })
47
33
  }) : null;
48
- $[5] = children;
49
- $[6] = onAnimationEnd;
50
- $[7] = shouldRender;
51
- $[8] = show;
52
- $[9] = t4;
53
- } else t4 = $[9];
54
- return t4;
34
+ $[2] = children;
35
+ $[3] = onAnimationEnd;
36
+ $[4] = shouldRender;
37
+ $[5] = show;
38
+ $[6] = t2;
39
+ } else t2 = $[6];
40
+ return t2;
55
41
  };
56
42
  //#endregion
57
43
  export { ValidationAnimationContainer as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260707192942",
4
+ "version": "0.0.0-20260707193228",
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,2 +0,0 @@
1
- .prc-SegmentedControl-SegmentedControl-lqIXp{--segmented-control-icon-width:32px;background-color:var(--controlTrack-bgColor-rest,#e6eaef);border:var(--borderWidth-thin,.0625rem) solid var(--controlTrack-borderColor-rest,transparent);border-radius:var(--borderRadius-medium,.375rem);display:inline-flex;font-size:var(--text-body-size-medium,.875rem);height:32px;margin:0;padding:0}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-narrow=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=true]{display:flex;width:100%;--segmented-control-icon-width:100%}.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-regular=true]:not([data-full-width-wide=true]),.prc-SegmentedControl-SegmentedControl-lqIXp[data-full-width-wide=false]{display:inline-flex;width:auto;--segmented-control-icon-width:32px}}.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-narrow=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:48rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-regular=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}@media (min-width:87.5rem){.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=dropdown],.prc-SegmentedControl-SegmentedControl-lqIXp[data-variant-wide=hideLabels] .prc-SegmentedControl-Text-7S2y2{display:none}}.prc-SegmentedControl-SegmentedControl-lqIXp:where([data-size=small]){font-size:var(--text-body-size-small,.75rem);height:28px}.prc-SegmentedControl-DropdownContainer-ZaPMn{display:none}.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant=dropdown]{display:block}@media (max-width:calc(48rem - 0.02px)){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-narrow=dropdown]{display:block}}@media (min-width:48rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-regular=dropdown]{display:block}}@media (min-width:87.5rem){.prc-SegmentedControl-DropdownContainer-ZaPMn[data-variant-wide=dropdown]{display:block}}.prc-SegmentedControl-Item-tSCQh{display:block;flex-grow:1;margin-bottom:-1px;margin-top:-1px;position:relative}.prc-SegmentedControl-Item-tSCQh:not(:last-child){margin-right:1px}.prc-SegmentedControl-Item-tSCQh:not(:first-child):before{background-color:var(--borderColor-default,#d1d9e0);bottom:var(--base-size-8,.5rem);content:"";left:0;position:absolute;top:var(--base-size-8,.5rem);width:1px}.prc-SegmentedControl-Item-tSCQh[data-selected]:before{background-color:transparent}.prc-SegmentedControl-Item-tSCQh:first-child{margin-left:-1px}.prc-SegmentedControl-Item-tSCQh:last-child{margin-right:-1px}.prc-SegmentedControl-Item-tSCQh .prc-SegmentedControl-Counter-GmZOI{align-items:center;display:flex;margin-inline-start:var(--base-size-8,.5rem)}.prc-SegmentedControl-Button-E48xz,.prc-SegmentedControl-Item-tSCQh[data-selected]+.prc-SegmentedControl-Item-tSCQh:before{background-color:transparent}.prc-SegmentedControl-Button-E48xz{--segmented-control-button-inner-padding:12px;--segmented-control-button-bg-inset:4px;--segmented-control-outer-radius:var(--borderRadius-medium,0.375rem);border-color:transparent;border-radius:var(--segmented-control-outer-radius);border-width:0;color:currentColor;cursor:pointer;font-family:inherit;font-size:inherit;font-weight:var(--base-text-weight-normal,400);height:100%;padding:var(--segmented-control-button-bg-inset);width:100%}.prc-SegmentedControl-Button-E48xz svg{fill:var(--fgColor-muted,#59636e);color:var(--fgColor-muted,#59636e)}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:not(:disabled):not(:focus-visible){outline:1px solid transparent}.prc-SegmentedControl-Button-E48xz:focus-visible:not(:disabled){box-shadow:none;outline:var(--base-size-2,.125rem) solid var(--fgColor-accent,#0969da);outline-offset:-1px}.prc-SegmentedControl-Button-E48xz:focus:focus-visible:not(:last-child):after{width:0}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]){background-color:transparent;color:var(--fgColor-disabled,#818b98);cursor:not-allowed}.prc-SegmentedControl-Button-E48xz[aria-disabled=true]:not([aria-current=true]) svg{fill:var(--fgColor-disabled,#818b98);color:var(--fgColor-disabled,#818b98)}@media (pointer:coarse){.prc-SegmentedControl-Button-E48xz:before{content:"";left:0;min-height:44px;position:absolute;right:0;top:50%;transform:translateY(-50%)}}.prc-SegmentedControl-IconButton-tlzDE{width:var(--segmented-control-icon-width,32px)}.prc-SegmentedControl-Content-1COlk{align-items:center;border-color:transparent;border-radius:calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset)/2);border-style:solid;border-width:var(--borderWidth-thin,.0625rem);display:flex;height:100%;justify-content:center;padding-left:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));padding-right:calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset))}.prc-SegmentedControl-Button-E48xz[aria-current=true]{font-weight:var(--base-text-weight-semibold,600);padding:0}.prc-SegmentedControl-Button-E48xz[aria-current=true] .prc-SegmentedControl-Content-1COlk{background-color:var(--controlKnob-bgColor-rest,#fff);border-color:var(--controlKnob-borderColor-rest,#d1d9e0);border-radius:var(--segmented-control-outer-radius);padding-left:var(--segmented-control-button-inner-padding);padding-right:var(--segmented-control-button-inner-padding)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):hover .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-hover,#e0e6eb)}.prc-SegmentedControl-Button-E48xz:not([aria-current=true],[aria-disabled=true]):active .prc-SegmentedControl-Content-1COlk{background-color:var(--controlTrack-bgColor-active,#dae0e7)}.prc-SegmentedControl-Text-7S2y2:after{content:attr(data-text);display:block;font-weight:var(--base-text-weight-semibold,600);height:0;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none;visibility:hidden}.prc-SegmentedControl-LeadingIcon-74n5s{margin-right:var(--base-size-4,.25rem)}
2
- /*# sourceMappingURL=SegmentedControl-66516913.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/SegmentedControl/SegmentedControl.module.css.js"],"names":[],"mappings":"AAAA,6CAEE,mCAAoC,CASpC,yDAAkD,CAClD,8FAAuF,CACvF,gDAAyC,CATzC,mBAAoB,CAMpB,8CAAuC,CAHvC,WAAY,CAEZ,QAAS,CADT,SA0HF,CAlHE,mEACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,oEACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CAEA,wCACE,0EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,2EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,yBACE,2EACE,YAAa,CACb,UAAW,CAEX,mCACF,CAEA,4EACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAEA,2BACE,wEACE,YAAa,CACb,UAAW,CAEX,mCACF,CASA,qLACE,mBAAoB,CACpB,UAAW,CAEX,mCACF,CACF,CAQA,2KACE,YACF,CAEA,wCAKE,yLACE,YACF,CACF,CAEA,yBAKE,2LACE,YACF,CACF,CAEA,2BAKE,qLACE,YACF,CACF,CAEA,sEAGE,4CAAsC,CADtC,WAEF,CAGF,8CACE,YAwBF,CArBE,qEACE,aACF,CAEA,wCACE,4EACE,aACF,CACF,CAEA,yBACE,6EACE,aACF,CACF,CAEA,2BACE,0EACE,aACF,CACF,CAGF,iCAEE,aAAc,CAKd,WAAY,CADZ,kBAAmB,CAFnB,eAAgB,CAHhB,iBA0DF,CAlDE,kDAEE,gBACF,CAWA,0DAQE,mDAA4C,CAJ5C,+BAA0B,CAE1B,UAAW,CAHX,MAAO,CAFP,iBAAkB,CAClB,4BAAuB,CAGvB,SAIF,CAQA,uDACE,4BACF,CAEA,6CAEE,gBACF,CAEA,4CAEE,iBACF,CAEA,qEAGE,kBAAmB,CADnB,YAAa,CADb,4CAGF,CAaF,2HAHE,4BA4EF,CAzEA,mCAEE,6CAA8C,CAC9C,uCAAwC,CACxC,oEAA4D,CAY5D,wBAAyB,CAGzB,mDAAoD,CAFpD,cAAe,CAJf,kBAAmB,CACnB,cAAe,CAJf,mBAAoB,CACpB,iBAAkB,CAClB,8CAA2C,CAL3C,WAAY,CAEZ,gDAAiD,CAHjD,UAmEF,CApDE,uCACE,iCAA0B,CAC1B,kCACF,CAGA,wDAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAOF,CAHE,4EACE,6BACF,CAIF,gEAGE,eAAgB,CAFhB,sEAAuD,CACvD,mBAEF,CAGA,8EAEE,OACF,CAEA,gFAGE,4BAA6B,CAD7B,qCAA8B,CAD9B,kBAQF,CAJE,oFACE,oCAA6B,CAC7B,qCACF,CAGF,wBACE,0CAME,UAAW,CAFX,MAAO,CACP,eAAgB,CAJhB,iBAAkB,CAElB,OAAQ,CADR,OAAQ,CAKR,0BACF,CACF,CAGF,uCACE,8CACF,CAEA,oCAiBE,kBAAmB,CAVnB,wBAAyB,CASzB,sGAAyG,CARzG,kBAAmB,CACnB,6CAAqC,CARrC,YAAa,CACb,WAAY,CAgBZ,sBAAuB,CAZvB,2GAA4G,CAF5G,4GAeF,CAEA,sDAEE,gDAA6C,CAD7C,SAaF,CAVE,0FAKE,qDAAiD,CACjD,wDAAiD,CAEjD,mDAAoD,CAJpD,0DAA2D,CAF3D,2DAOF,CAIA,2HACE,0DACF,CAEA,4HACE,2DACF,CAGF,uCAOE,uBAAwB,CANxB,aAAc,CAGd,gDAA6C,CAF7C,QAAS,CACT,eAAgB,CAEhB,mBAAoB,CAGpB,wBAAiB,CAAjB,gBAAiB,CAFjB,iBAGF,CAEA,wCACE,sCACF","file":"SegmentedControl-66516913.css","sourcesContent":[".SegmentedControl {\n /* TODO: use primitive `control.medium.size` when it is available instead of '32px' */\n --segmented-control-icon-width: 32px;\n\n display: inline-flex;\n\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 32px;\n padding: 0;\n margin: 0;\n font-size: var(--text-body-size-medium);\n background-color: var(--controlTrack-bgColor-rest);\n border: var(--borderWidth-thin) solid var(--controlTrack-borderColor-rest, transparent);\n border-radius: var(--borderRadius-medium);\n\n /* Responsive full-width */\n &[data-full-width='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n @media (--viewportRange-narrow) {\n &[data-full-width-narrow='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-narrow='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-full-width-regular='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-regular='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-full-width-wide='true'] {\n display: flex;\n width: 100%;\n\n --segmented-control-icon-width: 100%;\n }\n\n &[data-full-width-wide='false'] {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n\n &[data-full-width-regular='true']:not([data-full-width-wide='true']) {\n display: inline-flex;\n width: auto;\n\n --segmented-control-icon-width: 32px;\n }\n }\n\n /* Hide when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: none;\n }\n\n /* Handle hideLabels variant - hide button text */\n &[data-variant='hideLabels'] .Text {\n display: none;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: none;\n }\n\n &[data-variant-narrow='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: none;\n }\n\n &[data-variant-regular='hideLabels'] .Text {\n display: none;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: none;\n }\n\n &[data-variant-wide='hideLabels'] .Text {\n display: none;\n }\n }\n\n &:where([data-size='small']) {\n /* TODO: use primitive `control.{small|medium}.size` when it is available */\n height: 28px;\n font-size: var(--text-body-size-small);\n }\n}\n\n.DropdownContainer {\n display: none;\n\n /* Show when dropdown variant is active */\n &[data-variant='dropdown'] {\n display: block;\n }\n\n @media (--viewportRange-narrow) {\n &[data-variant-narrow='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-regular) {\n &[data-variant-regular='dropdown'] {\n display: block;\n }\n }\n\n @media (--viewportRange-wide) {\n &[data-variant-wide='dropdown'] {\n display: block;\n }\n }\n}\n\n.Item {\n position: relative;\n display: block;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: -1px;\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n flex-grow: 1;\n\n &:not(:last-child) {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: 1px;\n }\n\n /*\n * Divider is drawn on the LEADING edge of each non-first item (rather than\n * the trailing edge of each non-last item) so the \"hide divider before the\n * selected item\" case can be expressed as a plain adjacent-sibling selector\n * instead of `:has(+ [data-selected])`. Visual position is unchanged: the\n * original `::after` at `right: -2px` (1px wide) on item N sat in the first\n * 1px of item N+1's column (the previous item has `margin-right: 1px`), so\n * the equivalent ::before on item N+1 lives at `left: 0`.\n */\n &:not(:first-child)::before {\n position: absolute;\n top: var(--base-size-8);\n left: 0;\n bottom: var(--base-size-8);\n width: 1px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-default);\n }\n\n /*\n * Hide the divider on the leading edge of the selected item itself. Uses a\n * plain `[data-selected]` (not `:where()`) so specificity matches the divider\n * rule above (0,2,1) and wins by source order; `:where()` would drop to\n * (0,1,1) and lose, leaving the divider visible.\n */\n &[data-selected]::before {\n background-color: transparent;\n }\n\n &:first-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -1px;\n }\n\n &:last-child {\n /* stylelint-disable-next-line primer/spacing */\n margin-right: -1px;\n }\n\n .Counter {\n margin-inline-start: var(--base-size-8);\n display: flex;\n align-items: center;\n }\n}\n\n/*\n * Hide the divider on the leading edge of the item that immediately follows\n * the selected item. Adjacent-sibling combinator avoids the previous\n * `:has(+ [data-selected])::after` which forced a sibling-direction `:has()`\n * re-evaluation on every selection change.\n */\n.Item[data-selected] + .Item::before {\n background-color: transparent;\n}\n\n.Button {\n /* TODO: use primitive `primer.control.medium.paddingInline.normal` when it is available */\n --segmented-control-button-inner-padding: 12px;\n --segmented-control-button-bg-inset: 4px;\n --segmented-control-outer-radius: var(--borderRadius-medium);\n\n width: 100%;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding: var(--segmented-control-button-bg-inset);\n font-family: inherit;\n font-size: inherit;\n font-weight: var(--base-text-weight-normal);\n color: currentColor;\n cursor: pointer;\n background-color: transparent;\n border-color: transparent;\n border-width: 0;\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n\n & svg {\n fill: var(--fgColor-muted);\n color: var(--fgColor-muted);\n }\n\n /* fallback :focus state */\n &:focus:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n\n /* remove fallback :focus if :focus-visible is supported */\n &:not(:focus-visible) {\n outline: solid 1px transparent;\n }\n }\n\n /* default focus state */\n &:focus-visible:not(:disabled) {\n outline: var(--base-size-2) solid var(--fgColor-accent);\n outline-offset: -1px;\n box-shadow: none;\n }\n\n /* stylelint-disable-next-line selector-max-specificity */\n &:focus:focus-visible:not(:last-child)::after {\n /* fixes an issue where the focus outline shows over the pseudo-element */\n width: 0;\n }\n\n &[aria-disabled='true']:not([aria-current='true']) {\n cursor: not-allowed;\n color: var(--fgColor-disabled);\n background-color: transparent;\n\n & svg {\n fill: var(--fgColor-disabled);\n color: var(--fgColor-disabled);\n }\n }\n\n @media (pointer: coarse) {\n &::before {\n position: absolute;\n top: 50%;\n right: 0;\n left: 0;\n min-height: 44px;\n content: '';\n transform: translateY(-50%);\n }\n }\n}\n\n.IconButton {\n width: var(--segmented-control-icon-width, 32px);\n}\n\n.Content {\n display: flex;\n height: 100%;\n /* stylelint-disable-next-line primer/spacing */\n padding-right: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n /* stylelint-disable-next-line primer/spacing */\n padding-left: calc(var(--segmented-control-button-inner-padding) - var(--segmented-control-button-bg-inset));\n border-color: transparent;\n border-style: solid;\n border-width: var(--borderWidth-thin);\n\n /*\n innerRadius = outerRadius - distance/2\n https://stackoverflow.com/questions/2932146/math-problem-determine-the-corner-radius-of-an-inner-border-based-on-outer-corn\n */\n /* stylelint-disable-next-line primer/borders */\n border-radius: calc(var(--segmented-control-outer-radius) - var(--segmented-control-button-bg-inset) / 2);\n align-items: center;\n justify-content: center;\n}\n\n.Button[aria-current='true'] {\n padding: 0;\n font-weight: var(--base-text-weight-semibold);\n\n .Content {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--segmented-control-button-inner-padding);\n /* stylelint-disable-next-line primer/spacing */\n padding-left: var(--segmented-control-button-inner-padding);\n background-color: var(--controlKnob-bgColor-rest);\n border-color: var(--controlKnob-borderColor-rest);\n /* stylelint-disable-next-line primer/borders */\n border-radius: var(--segmented-control-outer-radius);\n }\n}\n\n.Button:not([aria-current='true'], [aria-disabled='true']) {\n &:hover .Content {\n background-color: var(--controlTrack-bgColor-hover);\n }\n\n &:active .Content {\n background-color: var(--controlTrack-bgColor-active);\n }\n}\n\n.Text::after {\n display: block;\n height: 0;\n overflow: hidden;\n font-weight: var(--base-text-weight-semibold);\n pointer-events: none;\n visibility: hidden;\n content: attr(data-text);\n user-select: none;\n}\n\n.LeadingIcon {\n margin-right: var(--base-size-4);\n}\n"]}