@primer/react 38.35.1-rc.f5a561aea → 38.36.0-rc.3fb350b1f

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,11 +1,20 @@
1
1
  # @primer/react
2
2
 
3
+ ## 38.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#8212](https://github.com/primer/react/pull/8212) [`9ac9343`](https://github.com/primer/react/commit/9ac9343a70fd0f70413a42cd27baf562a74dd4fc) Thanks [@mattcosta7](https://github.com/mattcosta7)! - ThemeProvider: Add a CSS-variable-based implementation to `@primer/react/next`
8
+ and deprecate the legacy JavaScript theme implementation.
9
+
3
10
  ## 38.35.1
4
11
 
5
12
  ### Patch Changes
6
13
 
7
14
  - [#8258](https://github.com/primer/react/pull/8258) [`edbcd94`](https://github.com/primer/react/commit/edbcd942354ff45148c2623be8b543ef8789a20f) Thanks [@llastflowers](https://github.com/llastflowers)! - Update `AvatarStack` to not reserve space when collapsed
8
15
 
16
+ - [#8273](https://github.com/primer/react/pull/8273) [`0c1e401`](https://github.com/primer/react/commit/0c1e401b6b0d57f95f8115ea90af78281751a766) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - NavList: Exclude group headings from navigation list item counts
17
+
9
18
  ## 38.35.0
10
19
 
11
20
  ### Minor Changes
@@ -133,14 +133,15 @@ const ActionBarIconButton = /*#__PURE__*/ forwardRef(({ disabled, onClick, ...pr
133
133
  disabled,
134
134
  onClick
135
135
  ]));
136
+ const clickHandler = useCallback((event) => {
137
+ if (disabled) return;
138
+ onClick === null || onClick === void 0 || onClick(event);
139
+ }, [disabled, onClick]);
136
140
  return /*#__PURE__*/ jsx(IconButton, {
137
141
  "aria-disabled": disabled,
138
142
  ref: mergedRef,
139
143
  size,
140
- onClick: useCallback((event) => {
141
- if (disabled) return;
142
- onClick === null || onClick === void 0 || onClick(event);
143
- }, [disabled, onClick]),
144
+ onClick: clickHandler,
144
145
  ...props,
145
146
  variant: "invisible",
146
147
  "data-overflowing": dataOverflowingAttr
@@ -163,14 +164,15 @@ const ActionBarButton = /*#__PURE__*/ forwardRef(({ disabled, onClick, ...props
163
164
  disabled,
164
165
  onClick
165
166
  ]));
167
+ const clickHandler = useCallback((event) => {
168
+ if (disabled) return;
169
+ onClick === null || onClick === void 0 || onClick(event);
170
+ }, [disabled, onClick]);
166
171
  return /*#__PURE__*/ jsx(ButtonComponent, {
167
172
  "aria-disabled": disabled,
168
173
  ref: mergedRef,
169
174
  size,
170
- onClick: useCallback((event) => {
171
- if (disabled) return;
172
- onClick === null || onClick === void 0 || onClick(event);
173
- }, [disabled, onClick]),
175
+ onClick: clickHandler,
174
176
  ...props,
175
177
  variant: "invisible",
176
178
  "data-overflowing": dataOverflowingAttr
@@ -0,0 +1,2 @@
1
+ .prc-ActionList-Group-lMIPQ{list-style:none}.prc-ActionList-Group-lMIPQ:not(:first-child){margin-block-start:var(--base-size-8,.5rem)}.prc-ActionList-GroupList-V5B3-{padding-inline-start:0}.prc-ActionList-GroupHeadingWrap-laXcX{color:var(--fgColor-muted,#59636e);display:flex;flex-direction:column;font-size:var(--text-body-size-small,.75rem);font-weight:var(--base-text-weight-semibold,600);line-height:18px;padding-block:var(--base-size-6,.375rem);padding-inline:var(--base-size-16,1rem)}.prc-ActionList-GroupHeadingWrap-laXcX:where([data-variant=filled]){background:var(--bgColor-muted,#f6f8fa);border-bottom:var(--borderWidth-thin,.0625rem) solid var(--borderColor-muted,#d1d9e0b3);border-top:var(--borderWidth-thin,.0625rem) solid var(--borderColor-muted,#d1d9e0b3);margin-block-end:var(--base-size-8,.5rem);margin-block-start:calc(var(--base-size-8,.5rem) - var(--borderWidth-thin,.0625rem));padding-inline:var(--base-size-16,1rem)}.prc-ActionList-GroupHeadingWrap-laXcX:where([data-variant=filled]):first-child{margin-block-start:0}.prc-ActionList-GroupHeading-STzxi{align-self:flex-start;color:var(--fgColor-muted,#59636e);font-size:var(--text-body-size-small,.75rem);font-weight:var(--base-text-weight-semibold,600);margin:0}.prc-ActionList-GroupHeadingWrap-laXcX[data-has-trailing-action]{align-items:center;flex-direction:row;gap:var(--base-size-8,.5rem);justify-content:space-between}.prc-ActionList-GroupHeadingWrap-laXcX[data-has-trailing-action]>.prc-ActionList-GroupHeading-STzxi{align-self:center}.prc-ActionList-GroupHeadingTrailingAction-jnb64{align-items:center;display:inline-flex;margin-inline-start:auto}
2
+ /*# sourceMappingURL=Group-d89306a8.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ActionList/Group.module.css.js"],"names":[],"mappings":"AAAA,4BACE,eAKF,CAHE,8CACE,2CACF,CAGF,gCACE,sBACF,CAEA,uCAQE,kCAA2B,CAP3B,YAAa,CAQb,qBAAsB,CAPtB,4CAAsC,CACtC,gDAA6C,CAI7C,gBAAiB,CAIjB,wCAAiC,CADjC,uCAoBF,CAjBE,oEAIE,uCAAgC,CAEhC,uFAAqE,CADrE,oFAAkE,CAFlE,yCAAoC,CADpC,oFAAsE,CAKtE,uCAKF,CAHE,gFACE,oBACF,CAQJ,mCAKE,qBAAsB,CADtB,kCAA2B,CAF3B,4CAAsC,CACtC,gDAA6C,CAF7C,QAKF,CAEA,iEAEE,kBAAmB,CADnB,kBAAmB,CAGnB,4BAAuB,CADvB,6BAMF,CAHE,oGACE,iBACF,CAGF,iDAEE,kBAAmB,CADnB,mBAAoB,CAEpB,wBACF","file":"Group-d89306a8.css","sourcesContent":[".Group {\n list-style: none;\n\n &:not(:first-child) {\n margin-block-start: var(--base-size-8);\n }\n}\n\n.GroupList {\n padding-inline-start: 0;\n}\n\n.GroupHeadingWrap {\n display: flex;\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-semibold);\n\n /* line-height: var(--text-body-lineHeight-small); use when FF rolls out */\n /* stylelint-disable-next-line primer/typography */\n line-height: 18px;\n color: var(--fgColor-muted);\n flex-direction: column;\n padding-inline: var(--base-size-16);\n padding-block: var(--base-size-6);\n\n &:where([data-variant='filled']) {\n /* stylelint-disable-next-line primer/spacing */\n margin-block-start: calc(var(--base-size-8) - var(--borderWidth-thin));\n margin-block-end: var(--base-size-8);\n background: var(--bgColor-muted);\n border-top: solid var(--borderWidth-thin) var(--borderColor-muted);\n border-bottom: solid var(--borderWidth-thin) var(--borderColor-muted);\n padding-inline: var(--base-size-16);\n\n &:first-child {\n margin-block-start: 0;\n }\n }\n\n /* & + ul:has(.GroupHeadingWrap) {\n outline: solid 1px red;\n } */\n}\n\n.GroupHeading {\n margin: 0;\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-muted);\n align-self: flex-start;\n}\n\n.GroupHeadingWrap[data-has-trailing-action] {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n gap: var(--base-size-8);\n\n & > .GroupHeading {\n align-self: center;\n }\n}\n\n.GroupHeadingTrailingAction {\n display: inline-flex;\n align-items: center;\n margin-inline-start: auto;\n}\n"]}
@@ -1,9 +1,9 @@
1
- import "./Group-efcb39da.css";
1
+ import "./Group-d89306a8.css";
2
2
  //#region src/ActionList/Group.module.css.js
3
3
  var Group_module_css_default = {
4
4
  "Group": "prc-ActionList-Group-lMIPQ",
5
- "GroupHeadingWrap": "prc-ActionList-GroupHeadingWrap-laXcX",
6
5
  "GroupList": "prc-ActionList-GroupList-V5B3-",
6
+ "GroupHeadingWrap": "prc-ActionList-GroupHeadingWrap-laXcX",
7
7
  "GroupHeading": "prc-ActionList-GroupHeading-STzxi",
8
8
  "GroupHeadingTrailingAction": "prc-ActionList-GroupHeadingTrailingAction-jnb64"
9
9
  };
@@ -37,7 +37,8 @@ const Heading = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
37
37
  t1 = $[6];
38
38
  }
39
39
  const visuallyHidden = t1 === void 0 ? false : t1;
40
- const mergedRef = useMergedRefs(forwardedRef, React.useRef(null));
40
+ const innerRef = React.useRef(null);
41
+ const mergedRef = useMergedRefs(forwardedRef, innerRef);
41
42
  const { headingId, variant: listVariant } = React.useContext(ListContext);
42
43
  const { container } = React.useContext(ActionListContainerContext);
43
44
  !(container !== "ActionMenu") && invariant(false, "ActionList.Heading shouldn't be used within an ActionMenu container. Menus are labelled by the menu button's name.");
@@ -11,11 +11,14 @@ const CounterLabel = /*#__PURE__*/ forwardRef(({ variant, scheme, className, chi
11
11
  ")"
12
12
  ] });
13
13
  const inferredVariant = variant || scheme || "secondary";
14
- return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("span", {
14
+ const counterProps = {
15
15
  ref: forwardedRef,
16
16
  ["aria-hidden"]: "true",
17
17
  ["data-variant"]: inferredVariant,
18
- ...rest,
18
+ ...rest
19
+ };
20
+ return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("span", {
21
+ ...counterProps,
19
22
  "data-component": dataComponent !== null && dataComponent !== void 0 ? dataComponent : "CounterLabel",
20
23
  className: clsx(className, CounterLabel_module_css_default.CounterLabel),
21
24
  children
@@ -34,7 +34,8 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
34
34
  t1 = () => {
35
35
  const { current: details } = detailsRef;
36
36
  if (!details) return;
37
- warning(details.querySelector("summary:not([data-default-summary])") === null, "The <Details> component must have a <summary> child component. You can either use <Details.Summary> or a native <summary> element.");
37
+ const summary = details.querySelector("summary:not([data-default-summary])");
38
+ warning(summary === null, "The <Details> component must have a <summary> child component. You can either use <Details.Summary> or a native <summary> element.");
38
39
  };
39
40
  t2 = [];
40
41
  $[5] = t1;
@@ -140,7 +140,7 @@ const _Dialog = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
140
140
  });
141
141
  const footer = (_slots$footer = slots.footer) !== null && _slots$footer !== void 0 ? _slots$footer : (renderFooter !== null && renderFooter !== void 0 ? renderFooter : DefaultFooter)(defaultedProps);
142
142
  const hasFooter = footer != null;
143
- useResizeObserver(useCallback(() => {
143
+ const updateFooterButtonLayout = useCallback(() => {
144
144
  if (!hasFooter) return;
145
145
  const dialogElement = dialogRef.current;
146
146
  if (!(dialogElement instanceof HTMLElement)) return;
@@ -150,7 +150,8 @@ const _Dialog = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
150
150
  const newLayout = bodyWrapper.clientHeight >= MIN_BODY_HEIGHT ? "wrap" : "scroll";
151
151
  dialogElement.setAttribute("data-footer-button-layout", newLayout);
152
152
  setFooterButtonLayout(newLayout);
153
- }, [hasFooter]), backdropRef);
153
+ }, [hasFooter]);
154
+ useResizeObserver(updateFooterButtonLayout, backdropRef);
154
155
  const positionDataAttributes = typeof position === "string" ? { "data-position-regular": position } : Object.fromEntries(Object.entries(position).map(([key, value]) => {
155
156
  return [`data-position-${key}`, value];
156
157
  }));
@@ -1,4 +1,4 @@
1
- import { FCWithSlotMarker } from "../utils/types/Slots.js";
1
+ import { FCWithSlotMarker, WithSlotMarker } from "../utils/types/Slots.js";
2
2
  import { ForwardRefComponent } from "../utils/polymorphic.js";
3
3
  import { DistributiveOmit, PolymorphicProps } from "../utils/modern-polymorphic.js";
4
4
  import { ActionListTrailingActionProps } from "../ActionList/TrailingAction.js";
@@ -71,7 +71,7 @@ declare const NavList: React.ForwardRefExoticComponent<Omit<NavListProps, "ref">
71
71
  Divider: FCWithSlotMarker<React.PropsWithChildren<ActionListDividerProps>>;
72
72
  Group: React.FC<NavListGroupProps>;
73
73
  GroupExpand: React.ForwardRefExoticComponent<NavListGroupExpandProps & React.RefAttributes<HTMLButtonElement>>;
74
- GroupHeading: React.FC<ActionListGroupHeadingProps>;
74
+ GroupHeading: WithSlotMarker<React.FC<ActionListGroupHeadingProps>>;
75
75
  };
76
76
  //#endregion
77
77
  export { NavList, NavListDividerProps, NavListGroupExpandProps, NavListGroupHeadingProps, NavListGroupProps, NavListHeadingProps, NavListItemProps, NavListLeadingVisualProps, NavListProps, NavListSubNavProps, NavListTrailingVisualProps };
@@ -3,6 +3,7 @@ import { useId as useId$1 } from "../hooks/useId.js";
3
3
  import { useSlots } from "../hooks/useSlots.js";
4
4
  import { fixedForwardRef } from "../utils/modern-polymorphic.js";
5
5
  import _VisuallyHidden_module_css_default from "../_VisuallyHidden.module.css.js";
6
+ import { asSlot } from "../utils/as-slot.js";
6
7
  import { ActionListContainerContext } from "../ActionList/ActionListContainerContext.js";
7
8
  import Heading$1 from "../Heading/Heading.js";
8
9
  import ActionList_module_css_default from "../ActionList/ActionList.module.css.js";
@@ -374,8 +375,23 @@ const Divider = ActionList.Divider;
374
375
  Divider.displayName = "NavList.Divider";
375
376
  const TrailingAction = ActionList.TrailingAction;
376
377
  TrailingAction.displayName = "NavList.TrailingAction";
378
+ function flattenFragmentChildren(children) {
379
+ const flattenedChildren = [];
380
+ React.Children.forEach(children, (child) => {
381
+ if (/*#__PURE__*/ React.isValidElement(child) && child.type === React.Fragment) flattenedChildren.push(...flattenFragmentChildren(child.props.children));
382
+ else flattenedChildren.push(child);
383
+ });
384
+ return flattenedChildren;
385
+ }
386
+ function removeChildFromFragments(children, childToRemove) {
387
+ return React.Children.map(children, (child) => {
388
+ if (child === childToRemove) return null;
389
+ if (/*#__PURE__*/ React.isValidElement(child) && child.type === React.Fragment) return /*#__PURE__*/ React.cloneElement(child, void 0, removeChildFromFragments(child.props.children, childToRemove));
390
+ return child;
391
+ });
392
+ }
377
393
  const Group = (t0) => {
378
- const $ = c(19);
394
+ const $ = c(26);
379
395
  let children;
380
396
  let hideDivider;
381
397
  let props;
@@ -395,48 +411,69 @@ const Group = (t0) => {
395
411
  }
396
412
  const headingLevel = React.useContext(NavListHeadingLevelContext);
397
413
  let t1;
398
- if ($[5] !== headingLevel) {
399
- t1 = headingLevel ? levelToHeadingTag(headingLevel + 1) : "h3";
400
- $[5] = headingLevel;
414
+ if ($[5] !== children) {
415
+ t1 = flattenFragmentChildren(children);
416
+ $[5] = children;
401
417
  $[6] = t1;
402
418
  } else t1 = $[6];
403
- const groupHeadingAs = t1;
404
419
  let t2;
405
- if ($[7] !== hideDivider) {
406
- t2 = !hideDivider && /*#__PURE__*/ jsx(ActionList.Divider, {});
407
- $[7] = hideDivider;
408
- $[8] = t2;
409
- } else t2 = $[8];
420
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
421
+ t2 = { groupHeading: GroupHeading };
422
+ $[7] = t2;
423
+ } else t2 = $[7];
424
+ const [slots] = useSlots(t1, t2);
410
425
  let t3;
411
- if ($[9] !== groupHeadingAs || $[10] !== title) {
412
- t3 = title ? /*#__PURE__*/ jsx(ActionList.GroupHeading, {
426
+ if ($[8] !== children || $[9] !== slots.groupHeading) {
427
+ t3 = slots.groupHeading ? removeChildFromFragments(children, slots.groupHeading) : children;
428
+ $[8] = children;
429
+ $[9] = slots.groupHeading;
430
+ $[10] = t3;
431
+ } else t3 = $[10];
432
+ const childrenWithoutHeading = t3;
433
+ let t4;
434
+ if ($[11] !== headingLevel) {
435
+ t4 = headingLevel ? levelToHeadingTag(headingLevel + 1) : "h3";
436
+ $[11] = headingLevel;
437
+ $[12] = t4;
438
+ } else t4 = $[12];
439
+ const groupHeadingAs = t4;
440
+ let t5;
441
+ if ($[13] !== hideDivider) {
442
+ t5 = !hideDivider && /*#__PURE__*/ jsx(ActionList.Divider, {});
443
+ $[13] = hideDivider;
444
+ $[14] = t5;
445
+ } else t5 = $[14];
446
+ let t6;
447
+ if ($[15] !== groupHeadingAs || $[16] !== slots.groupHeading || $[17] !== title) {
448
+ t6 = slots.groupHeading ? /*#__PURE__*/ React.cloneElement(slots.groupHeading, { headingWrapElement: "div" }) : title ? /*#__PURE__*/ jsx(ActionList.GroupHeading, {
413
449
  as: groupHeadingAs,
414
450
  "data-component": "ActionList.GroupHeading",
415
451
  children: title
416
452
  }) : null;
417
- $[9] = groupHeadingAs;
418
- $[10] = title;
419
- $[11] = t3;
420
- } else t3 = $[11];
421
- let t4;
422
- if ($[12] !== children || $[13] !== props || $[14] !== t3) {
423
- t4 = /*#__PURE__*/ jsxs(ActionList.Group, {
453
+ $[15] = groupHeadingAs;
454
+ $[16] = slots.groupHeading;
455
+ $[17] = title;
456
+ $[18] = t6;
457
+ } else t6 = $[18];
458
+ let t7;
459
+ if ($[19] !== childrenWithoutHeading || $[20] !== props || $[21] !== t6) {
460
+ t7 = /*#__PURE__*/ jsxs(ActionList.Group, {
424
461
  ...props,
425
- children: [t3, children]
462
+ children: [t6, childrenWithoutHeading]
426
463
  });
427
- $[12] = children;
428
- $[13] = props;
429
- $[14] = t3;
430
- $[15] = t4;
431
- } else t4 = $[15];
432
- let t5;
433
- if ($[16] !== t2 || $[17] !== t4) {
434
- t5 = /*#__PURE__*/ jsxs(Fragment, { children: [t2, t4] });
435
- $[16] = t2;
436
- $[17] = t4;
437
- $[18] = t5;
438
- } else t5 = $[18];
439
- return t5;
464
+ $[19] = childrenWithoutHeading;
465
+ $[20] = props;
466
+ $[21] = t6;
467
+ $[22] = t7;
468
+ } else t7 = $[22];
469
+ let t8;
470
+ if ($[23] !== t5 || $[24] !== t7) {
471
+ t8 = /*#__PURE__*/ jsxs(Fragment, { children: [t5, t7] });
472
+ $[23] = t5;
473
+ $[24] = t7;
474
+ $[25] = t8;
475
+ } else t8 = $[25];
476
+ return t8;
440
477
  };
441
478
  const GroupExpand = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
442
479
  const $ = c(23);
@@ -534,7 +571,7 @@ const GroupExpand = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
534
571
  * This is an alternative to the `title` prop on `NavList.Group`.
535
572
  * It was primarily added to allow links in group headings.
536
573
  */
537
- const GroupHeading = (t0) => {
574
+ const GroupHeadingImpl = (t0) => {
538
575
  const $ = c(13);
539
576
  let as;
540
577
  let className;
@@ -582,6 +619,7 @@ const GroupHeading = (t0) => {
582
619
  } else t3 = $[12];
583
620
  return t3;
584
621
  };
622
+ const GroupHeading = asSlot(GroupHeadingImpl, ActionList.GroupHeading);
585
623
  const NavList = Object.assign(Root, {
586
624
  Description: ActionList.Description,
587
625
  Heading,
@@ -72,7 +72,8 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
72
72
  if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
73
73
  if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === LeadingAction || isSlot(child_1, LeadingAction))) hasLeadingAction = true;
74
74
  }
75
- warning(Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3))) && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
75
+ const hasInteractiveContent = Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3)));
76
+ warning(hasInteractiveContent && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
76
77
  };
77
78
  t3 = [children, readRef];
78
79
  $[0] = children;
@@ -435,6 +435,31 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
435
435
  if (event.key !== "/" && !isAlphabetKey(event.nativeEvent)) return;
436
436
  event.stopPropagation();
437
437
  }, [overlayProps]);
438
+ const mergedOverlayProps = useMemo(() => ({
439
+ role: "dialog",
440
+ "aria-labelledby": titleId,
441
+ "aria-describedby": subtitle ? subtitleId : void 0,
442
+ ...overlayProps,
443
+ ...variant === "modal" ? {
444
+ top: "50vh",
445
+ left: "50vw",
446
+ anchorSide: void 0
447
+ } : {},
448
+ style: {
449
+ transform: variant === "modal" ? "translate(-50%, -50%)" : void 0,
450
+ ...isKeyboardVisible ? { maxHeight: availablePanelHeight !== void 0 ? `${availablePanelHeight}px` : "auto" } : {}
451
+ },
452
+ onKeyDown: preventBubbling
453
+ }), [
454
+ titleId,
455
+ subtitle,
456
+ subtitleId,
457
+ overlayProps,
458
+ variant,
459
+ isKeyboardVisible,
460
+ availablePanelHeight,
461
+ preventBubbling
462
+ ]);
438
463
  return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx(AnchoredOverlay, {
439
464
  renderAnchor: renderMenuAnchor,
440
465
  anchorRef,
@@ -442,31 +467,7 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
442
467
  open,
443
468
  onOpen,
444
469
  onClose,
445
- overlayProps: useMemo(() => ({
446
- role: "dialog",
447
- "aria-labelledby": titleId,
448
- "aria-describedby": subtitle ? subtitleId : void 0,
449
- ...overlayProps,
450
- ...variant === "modal" ? {
451
- top: "50vh",
452
- left: "50vw",
453
- anchorSide: void 0
454
- } : {},
455
- style: {
456
- transform: variant === "modal" ? "translate(-50%, -50%)" : void 0,
457
- ...isKeyboardVisible ? { maxHeight: availablePanelHeight !== void 0 ? `${availablePanelHeight}px` : "auto" } : {}
458
- },
459
- onKeyDown: preventBubbling
460
- }), [
461
- titleId,
462
- subtitle,
463
- subtitleId,
464
- overlayProps,
465
- variant,
466
- isKeyboardVisible,
467
- availablePanelHeight,
468
- preventBubbling
469
- ]),
470
+ overlayProps: mergedOverlayProps,
470
471
  focusTrapSettings,
471
472
  focusZoneSettings,
472
473
  height,
@@ -0,0 +1,20 @@
1
+ import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
+ import React from "react";
3
+
4
+ //#region src/ThemeContext.d.ts
5
+ interface ThemeContextValue {
6
+ /** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
7
+ theme?: Theme;
8
+ colorScheme?: string;
9
+ colorMode?: ColorModeWithAuto;
10
+ resolvedColorMode?: ColorMode;
11
+ /** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
12
+ resolvedColorScheme?: string;
13
+ dayScheme?: string;
14
+ nightScheme?: string;
15
+ setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
16
+ setDayScheme: React.Dispatch<React.SetStateAction<string>>;
17
+ setNightScheme: React.Dispatch<React.SetStateAction<string>>;
18
+ }
19
+ //#endregion
20
+ export { ThemeContextValue };
@@ -21,6 +21,9 @@ type ThemeProviderProps = {
21
21
  */
22
22
  contextOnly?: boolean;
23
23
  };
24
+ /**
25
+ * @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values.
26
+ */
24
27
  declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
25
28
  //#endregion
26
29
  export { ColorMode, ColorModeWithAuto, Theme, ThemeProvider, ThemeProvider as default, ThemeProviderProps };
@@ -1,16 +1,17 @@
1
1
  import theme from "./theme.js";
2
- import { useSyncedState } from "./hooks/useSyncedState.js";
3
- import { ThemeContext } from "./ThemeContext.js";
4
- import { useTheme } from "./useTheme.js";
2
+ import { ThemeProviderBase } from "./internal/components/ThemeProviderBase.js";
3
+ import { useThemeProvider } from "./internal/hooks/useThemeProvider.js";
5
4
  import { c } from "react-compiler-runtime";
6
5
  import { jsx } from "react/jsx-runtime";
7
- import React from "react";
6
+ import "react";
8
7
  import deepmerge from "deepmerge";
9
- const defaultDayScheme = "light";
10
- const defaultNightScheme = "dark";
8
+ //#region src/ThemeProvider.tsx
9
+ /**
10
+ * @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values.
11
+ */
11
12
  const ThemeProvider = (t0) => {
12
- var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
13
- const $ = c(34);
13
+ var _parentValue$theme;
14
+ const $ = c(14);
14
15
  let children;
15
16
  let props;
16
17
  if ($[0] !== t0) {
@@ -22,134 +23,43 @@ const ThemeProvider = (t0) => {
22
23
  children = $[1];
23
24
  props = $[2];
24
25
  }
25
- const { theme: fallbackTheme, colorMode: fallbackColorMode, dayScheme: fallbackDayScheme, nightScheme: fallbackNightScheme } = useTheme();
26
- const theme$1 = fallbackTheme !== null && fallbackTheme !== void 0 ? fallbackTheme : theme;
27
- const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : "day");
28
- const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
29
- const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
30
- const systemColorMode = useSystemColorMode();
31
- let resolvedColorMode;
26
+ const { parentValue, value } = useThemeProvider(props);
27
+ const theme$1 = (_parentValue$theme = parentValue.theme) !== null && _parentValue$theme !== void 0 ? _parentValue$theme : theme;
32
28
  let t1;
33
- if ($[3] !== colorMode || $[4] !== dayScheme || $[5] !== nightScheme || $[6] !== systemColorMode) {
34
- resolvedColorMode = resolveColorMode(colorMode, systemColorMode);
35
- t1 = chooseColorScheme(resolvedColorMode, dayScheme, nightScheme);
36
- $[3] = colorMode;
37
- $[4] = dayScheme;
38
- $[5] = nightScheme;
39
- $[6] = systemColorMode;
40
- $[7] = resolvedColorMode;
41
- $[8] = t1;
42
- } else {
43
- resolvedColorMode = $[7];
44
- t1 = $[8];
45
- }
46
- const colorScheme = t1;
29
+ if ($[3] !== theme$1 || $[4] !== value.colorScheme) {
30
+ t1 = applyColorScheme(theme$1, value.colorScheme);
31
+ $[3] = theme$1;
32
+ $[4] = value.colorScheme;
33
+ $[5] = t1;
34
+ } else t1 = $[5];
35
+ const { resolvedTheme, resolvedColorScheme } = t1;
47
36
  let t2;
48
- if ($[9] !== colorScheme || $[10] !== theme$1) {
49
- t2 = applyColorScheme(theme$1, colorScheme);
50
- $[9] = colorScheme;
51
- $[10] = theme$1;
52
- $[11] = t2;
53
- } else t2 = $[11];
54
- const { resolvedTheme, resolvedColorScheme } = t2;
55
- let t3;
56
- if ($[12] !== colorMode || $[13] !== colorScheme || $[14] !== dayScheme || $[15] !== nightScheme || $[16] !== resolvedColorMode || $[17] !== resolvedColorScheme || $[18] !== resolvedTheme || $[19] !== setColorMode || $[20] !== setDayScheme || $[21] !== setNightScheme) {
57
- t3 = {
37
+ if ($[6] !== resolvedColorScheme || $[7] !== resolvedTheme || $[8] !== value) {
38
+ t2 = {
39
+ ...value,
58
40
  theme: resolvedTheme,
59
- colorScheme,
60
- colorMode,
61
- resolvedColorMode,
62
- resolvedColorScheme,
63
- dayScheme,
64
- nightScheme,
65
- setColorMode,
66
- setDayScheme,
67
- setNightScheme
41
+ resolvedColorScheme
68
42
  };
69
- $[12] = colorMode;
70
- $[13] = colorScheme;
71
- $[14] = dayScheme;
72
- $[15] = nightScheme;
73
- $[16] = resolvedColorMode;
74
- $[17] = resolvedColorScheme;
75
- $[18] = resolvedTheme;
76
- $[19] = setColorMode;
77
- $[20] = setDayScheme;
78
- $[21] = setNightScheme;
79
- $[22] = t3;
80
- } else t3 = $[22];
81
- const contextValue = t3;
82
- if (props.contextOnly) {
83
- let t4;
84
- if ($[23] !== children || $[24] !== contextValue) {
85
- t4 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
86
- value: contextValue,
87
- children
88
- });
89
- $[23] = children;
90
- $[24] = contextValue;
91
- $[25] = t4;
92
- } else t4 = $[25];
93
- return t4;
94
- }
95
- const t4 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
96
- let t5;
97
- if ($[26] !== children || $[27] !== dayScheme || $[28] !== nightScheme || $[29] !== t4) {
98
- t5 = /*#__PURE__*/ jsx("div", {
99
- "data-component": "ThemeProvider",
100
- "data-color-mode": t4,
101
- "data-light-theme": dayScheme,
102
- "data-dark-theme": nightScheme,
103
- children
104
- });
105
- $[26] = children;
106
- $[27] = dayScheme;
107
- $[28] = nightScheme;
108
- $[29] = t4;
109
- $[30] = t5;
110
- } else t5 = $[30];
111
- let t6;
112
- if ($[31] !== contextValue || $[32] !== t5) {
113
- t6 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
43
+ $[6] = resolvedColorScheme;
44
+ $[7] = resolvedTheme;
45
+ $[8] = value;
46
+ $[9] = t2;
47
+ } else t2 = $[9];
48
+ const contextValue = t2;
49
+ let t3;
50
+ if ($[10] !== children || $[11] !== contextValue || $[12] !== props.contextOnly) {
51
+ t3 = /*#__PURE__*/ jsx(ThemeProviderBase, {
52
+ contextOnly: props.contextOnly,
114
53
  value: contextValue,
115
- children: t5
54
+ children
116
55
  });
117
- $[31] = contextValue;
118
- $[32] = t5;
119
- $[33] = t6;
120
- } else t6 = $[33];
121
- return t6;
56
+ $[10] = children;
57
+ $[11] = contextValue;
58
+ $[12] = props.contextOnly;
59
+ $[13] = t3;
60
+ } else t3 = $[13];
61
+ return t3;
122
62
  };
123
- function subscribeToSystemColorMode(callback) {
124
- var _window, _window$matchMedia;
125
- const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
126
- media === null || media === void 0 || media.addEventListener("change", callback);
127
- return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
128
- }
129
- function useSystemColorMode() {
130
- return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
131
- }
132
- function _temp() {
133
- return "day";
134
- }
135
- function getSystemColorMode() {
136
- var _window2, _window2$matchMedia, _window2$matchMedia$c;
137
- return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
138
- }
139
- function resolveColorMode(colorMode, systemColorMode) {
140
- switch (colorMode) {
141
- case "auto": return systemColorMode;
142
- default: return colorMode;
143
- }
144
- }
145
- function chooseColorScheme(colorMode, dayScheme, nightScheme) {
146
- switch (colorMode) {
147
- case "day":
148
- case "light": return dayScheme;
149
- case "dark":
150
- case "night": return nightScheme;
151
- }
152
- }
153
63
  function applyColorScheme(theme, colorScheme) {
154
64
  if (!theme.colorSchemes) return {
155
65
  resolvedTheme: theme,
@@ -100,10 +100,11 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
100
100
  const trigger = readTriggerRef.current;
101
101
  tooltip.showPopover();
102
102
  setIsPopoverOpen(true);
103
- const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, {
103
+ const settings = {
104
104
  side: directionToPosition[direction].side,
105
105
  align: directionToPosition[direction].align
106
- });
106
+ };
107
+ const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, settings);
107
108
  const calculatedDirection = positionToDirection[`${anchorSide}-${anchorAlign}`];
108
109
  setCalculatedDirection(calculatedDirection);
109
110
  tooltip.style.top = `${top}px`;
@@ -193,7 +193,6 @@ const ItemImpl = fixedForwardRef(({ id: itemId, containIntrinsicSize, current: i
193
193
  case "u":
194
194
  if (!(event.shiftKey && (event.metaKey || event.ctrlKey))) return;
195
195
  activateActionsDialog();
196
- break;
197
196
  }
198
197
  }, [
199
198
  onSelect,
@@ -59,7 +59,8 @@ const List = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
59
59
  const { firstGroupStyle, lastGroupStyle, headerStyle, itemStyle } = useListVariant(restProps.variant);
60
60
  const renderGroup = (groupProps) => {
61
61
  var _ref;
62
- return /*#__PURE__*/ createElement(((_ref = "renderGroup" in groupProps && groupProps.renderGroup) !== null && _ref !== void 0 ? _ref : restProps.renderGroup) || Group, {
62
+ const GroupComponent = ((_ref = "renderGroup" in groupProps && groupProps.renderGroup) !== null && _ref !== void 0 ? _ref : restProps.renderGroup) || Group;
63
+ return /*#__PURE__*/ createElement(GroupComponent, {
63
64
  ...groupProps,
64
65
  key: groupProps.groupId
65
66
  });