@primer/react 0.0.0-20260707214244 → 0.0.0-20260710131553

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/ActionBar/ActionBar.js +130 -424
  3. package/dist/FilteredActionList/FilteredActionList.js +66 -155
  4. package/dist/FilteredActionList/useAnnouncements.js +66 -138
  5. package/dist/LabelGroup/LabelGroup.js +70 -104
  6. package/dist/Overlay/Overlay.js +45 -169
  7. package/dist/TextInput/TextInput.js +7 -7
  8. package/dist/ToggleSwitch/ToggleSwitch.js +167 -186
  9. package/dist/TreeView/TreeView.js +309 -814
  10. package/dist/UnderlineNav/UnderlineNav-a06bbc74.css +2 -0
  11. package/dist/UnderlineNav/UnderlineNav-a06bbc74.css.map +1 -0
  12. package/dist/UnderlineNav/UnderlineNav.d.ts +5 -0
  13. package/dist/UnderlineNav/UnderlineNav.js +136 -129
  14. package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -1
  15. package/dist/experimental/UnderlinePanels/UnderlinePanels.js +38 -95
  16. package/dist/hooks/useControllableState.js +3 -3
  17. package/dist/hooks/useMedia.js +44 -43
  18. package/dist/internal/components/UnderlineTabbedInterface-25587345.css +2 -0
  19. package/dist/internal/components/UnderlineTabbedInterface-25587345.css.map +1 -0
  20. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  21. package/dist/internal/components/ValidationAnimationContainer.js +40 -34
  22. package/package.json +3 -1
  23. package/dist/UnderlineNav/UnderlineNav-47547980.css +0 -2
  24. package/dist/UnderlineNav/UnderlineNav-47547980.css.map +0 -1
  25. package/dist/internal/components/UnderlineTabbedInterface-1745a3d6.css +0 -2
  26. package/dist/internal/components/UnderlineTabbedInterface-1745a3d6.css.map +0 -1
@@ -3,7 +3,6 @@ import { IconButton } from "../Button/IconButton.js";
3
3
  import { ButtonComponent } from "../Button/Button.js";
4
4
  import { AnchoredOverlay } from "../AnchoredOverlay/AnchoredOverlay.js";
5
5
  import LabelGroup_module_css_default from "./LabelGroup.module.css.js";
6
- import { c } from "react-compiler-runtime";
7
6
  import { clsx } from "clsx";
8
7
  import { jsx, jsxs } from "react/jsx-runtime";
9
8
  import React from "react";
@@ -24,108 +23,75 @@ const visibilityMapsMatch = (left, right) => {
24
23
  const rightKeys = Object.keys(right);
25
24
  return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);
26
25
  };
27
- const InlineToggle = (t0) => {
28
- const $ = c(7);
29
- const { collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline } = t0;
30
- let t1;
31
- if ($[0] !== collapseButtonRef || $[1] !== collapseInlineExpandedChildren || $[2] !== expandButtonRef || $[3] !== hiddenItemIds || $[4] !== isOverflowShown || $[5] !== showAllTokensInline) {
32
- t1 = isOverflowShown ? /*#__PURE__*/ jsx(ButtonComponent, {
33
- ref: collapseButtonRef,
34
- onClick: collapseInlineExpandedChildren,
35
- size: "small",
36
- variant: "invisible",
37
- children: "Show less"
38
- }) : hiddenItemIds.length ? /*#__PURE__*/ jsxs(ButtonComponent, {
39
- ref: expandButtonRef,
26
+ const InlineToggle = ({ collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline }) => isOverflowShown ? /*#__PURE__*/ jsx(ButtonComponent, {
27
+ ref: collapseButtonRef,
28
+ onClick: collapseInlineExpandedChildren,
29
+ size: "small",
30
+ variant: "invisible",
31
+ children: "Show less"
32
+ }) : hiddenItemIds.length ? /*#__PURE__*/ jsxs(ButtonComponent, {
33
+ ref: expandButtonRef,
34
+ variant: "invisible",
35
+ size: "small",
36
+ onClick: showAllTokensInline,
37
+ children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
38
+ "Show +",
39
+ hiddenItemIds.length,
40
+ " more"
41
+ ] }), /*#__PURE__*/ jsxs("span", {
42
+ "aria-hidden": "true",
43
+ children: ["+", hiddenItemIds.length]
44
+ })]
45
+ }) : null;
46
+ const OverlayToggle = ({ children, closeOverflowOverlay, expandButtonRef, hiddenItemIds, isOverflowShown, openOverflowOverlay, overlayPaddingPx, overlayWidth, totalLength }) => hiddenItemIds.length ? /*#__PURE__*/ jsx(AnchoredOverlay, {
47
+ open: isOverflowShown,
48
+ onOpen: openOverflowOverlay,
49
+ onClose: closeOverflowOverlay,
50
+ width: "auto",
51
+ height: "auto",
52
+ align: "start",
53
+ side: "inside-right",
54
+ anchorRef: expandButtonRef,
55
+ anchorOffset: overlayPaddingPx * -1,
56
+ alignmentOffset: overlayPaddingPx * -1,
57
+ renderAnchor: (props) => /*#__PURE__*/ jsxs(ButtonComponent, {
58
+ variant: "invisible",
59
+ size: "small",
60
+ ...props,
61
+ ref: expandButtonRef,
62
+ children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
63
+ "Show +",
64
+ hiddenItemIds.length,
65
+ " more"
66
+ ] }), /*#__PURE__*/ jsxs("span", {
67
+ "aria-hidden": "true",
68
+ children: ["+", hiddenItemIds.length]
69
+ })]
70
+ }),
71
+ focusZoneSettings: { disabled: true },
72
+ overlayProps: {
73
+ role: "dialog",
74
+ "aria-label": `All ${totalLength} labels`,
75
+ "aria-modal": true
76
+ },
77
+ children: /*#__PURE__*/ jsxs("div", {
78
+ className: LabelGroup_module_css_default.OverlayContainer,
79
+ style: {
80
+ width: overlayWidth,
81
+ padding: `${overlayPaddingPx}px`
82
+ },
83
+ children: [/*#__PURE__*/ jsx("div", {
84
+ className: LabelGroup_module_css_default.OverlayInner,
85
+ children
86
+ }), /*#__PURE__*/ jsx(IconButton, {
87
+ onClick: closeOverflowOverlay,
88
+ icon: XIcon,
89
+ "aria-label": "Close",
40
90
  variant: "invisible",
41
- size: "small",
42
- onClick: showAllTokensInline,
43
- children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
44
- "Show +",
45
- hiddenItemIds.length,
46
- " more"
47
- ] }), /*#__PURE__*/ jsxs("span", {
48
- "aria-hidden": "true",
49
- children: ["+", hiddenItemIds.length]
50
- })]
51
- }) : null;
52
- $[0] = collapseButtonRef;
53
- $[1] = collapseInlineExpandedChildren;
54
- $[2] = expandButtonRef;
55
- $[3] = hiddenItemIds;
56
- $[4] = isOverflowShown;
57
- $[5] = showAllTokensInline;
58
- $[6] = t1;
59
- } else t1 = $[6];
60
- return t1;
61
- };
62
- const OverlayToggle = (t0) => {
63
- const $ = c(10);
64
- const { children, closeOverflowOverlay, expandButtonRef, hiddenItemIds, isOverflowShown, openOverflowOverlay, overlayPaddingPx, overlayWidth, totalLength } = t0;
65
- let t1;
66
- if ($[0] !== children || $[1] !== closeOverflowOverlay || $[2] !== expandButtonRef || $[3] !== hiddenItemIds.length || $[4] !== isOverflowShown || $[5] !== openOverflowOverlay || $[6] !== overlayPaddingPx || $[7] !== overlayWidth || $[8] !== totalLength) {
67
- t1 = hiddenItemIds.length ? /*#__PURE__*/ jsx(AnchoredOverlay, {
68
- open: isOverflowShown,
69
- onOpen: openOverflowOverlay,
70
- onClose: closeOverflowOverlay,
71
- width: "auto",
72
- height: "auto",
73
- align: "start",
74
- side: "inside-right",
75
- anchorRef: expandButtonRef,
76
- anchorOffset: overlayPaddingPx * -1,
77
- alignmentOffset: overlayPaddingPx * -1,
78
- renderAnchor: (props) => /*#__PURE__*/ jsxs(ButtonComponent, {
79
- variant: "invisible",
80
- size: "small",
81
- ...props,
82
- ref: expandButtonRef,
83
- children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
84
- "Show +",
85
- hiddenItemIds.length,
86
- " more"
87
- ] }), /*#__PURE__*/ jsxs("span", {
88
- "aria-hidden": "true",
89
- children: ["+", hiddenItemIds.length]
90
- })]
91
- }),
92
- focusZoneSettings: { disabled: true },
93
- overlayProps: {
94
- role: "dialog",
95
- "aria-label": `All ${totalLength} labels`,
96
- "aria-modal": true
97
- },
98
- children: /*#__PURE__*/ jsxs("div", {
99
- className: LabelGroup_module_css_default.OverlayContainer,
100
- style: {
101
- width: overlayWidth,
102
- padding: `${overlayPaddingPx}px`
103
- },
104
- children: [/*#__PURE__*/ jsx("div", {
105
- className: LabelGroup_module_css_default.OverlayInner,
106
- children
107
- }), /*#__PURE__*/ jsx(IconButton, {
108
- onClick: closeOverflowOverlay,
109
- icon: XIcon,
110
- "aria-label": "Close",
111
- variant: "invisible",
112
- className: LabelGroup_module_css_default.CloseButton
113
- })]
114
- })
115
- }) : null;
116
- $[0] = children;
117
- $[1] = closeOverflowOverlay;
118
- $[2] = expandButtonRef;
119
- $[3] = hiddenItemIds.length;
120
- $[4] = isOverflowShown;
121
- $[5] = openOverflowOverlay;
122
- $[6] = overlayPaddingPx;
123
- $[7] = overlayWidth;
124
- $[8] = totalLength;
125
- $[9] = t1;
126
- } else t1 = $[9];
127
- return t1;
128
- };
91
+ className: LabelGroup_module_css_default.CloseButton
92
+ })]
93
+ })
94
+ }) : null;
129
95
  const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as: Component = "ul", className }) => {
130
96
  const containerRef = React.useRef(null);
131
97
  const collapseButtonRef = React.useRef(null);
@@ -270,8 +236,8 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
270
236
  "data-list": isList || void 0,
271
237
  className: clsx(className, LabelGroup_module_css_default.Container),
272
238
  "data-component": "LabelGroup",
273
- children: isList ? React.Children.map(children, (child_0, index_0) => {
274
- return /*#__PURE__*/ jsx("li", { children: child_0 }, index_0);
239
+ children: isList ? React.Children.map(children, (child, index) => {
240
+ return /*#__PURE__*/ jsx("li", { children: child }, index);
275
241
  }) : children
276
242
  });
277
243
  };
@@ -4,7 +4,6 @@ import { useOverlay } from "../hooks/useOverlay.js";
4
4
  import Portal_default from "../Portal/index.js";
5
5
  import { useFeatureFlag } from "../FeatureFlags/useFeatureFlag.js";
6
6
  import Overlay_module_css_default from "./Overlay.module.css.js";
7
- import { c } from "react-compiler-runtime";
8
7
  import { clsx } from "clsx";
9
8
  import { jsx } from "react/jsx-runtime";
10
9
  import React, { useEffect, useRef } from "react";
@@ -82,179 +81,56 @@ const BaseOverlay = /*#__PURE__*/ React.forwardRef(({ visibility, height, width,
82
81
  * @param width Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `480px`, `xlarge` corresponds to `640px`, `xxlarge` corresponds to `960px`.
83
82
 
84
83
  */
85
- const Overlay = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
86
- const $ = c(47);
87
- let _PrivateDisablePortal;
88
- let anchorSide;
89
- let ignoreClickRefs;
90
- let initialFocusRef;
91
- let left;
92
- let onClickOutside;
93
- let onEscape;
94
- let portalContainerName;
95
- let preventFocusOnOpen;
96
- let props;
97
- let responsiveVariant;
98
- let returnFocusRef;
99
- let right;
100
- let t1;
101
- let t2;
102
- let t3;
103
- let t4;
104
- let t5;
105
- if ($[0] !== t0) {
106
- ({anchorSide, _PrivateDisablePortal, height: t1, ignoreClickRefs, initialFocusRef, left, onClickOutside, onEscape, portalContainerName, preventOverflow: t2, preventFocusOnOpen, returnFocusRef, right, role: t3, visibility: t4, width: t5, responsiveVariant, ...props} = t0);
107
- $[0] = t0;
108
- $[1] = _PrivateDisablePortal;
109
- $[2] = anchorSide;
110
- $[3] = ignoreClickRefs;
111
- $[4] = initialFocusRef;
112
- $[5] = left;
113
- $[6] = onClickOutside;
114
- $[7] = onEscape;
115
- $[8] = portalContainerName;
116
- $[9] = preventFocusOnOpen;
117
- $[10] = props;
118
- $[11] = responsiveVariant;
119
- $[12] = returnFocusRef;
120
- $[13] = right;
121
- $[14] = t1;
122
- $[15] = t2;
123
- $[16] = t3;
124
- $[17] = t4;
125
- $[18] = t5;
126
- } else {
127
- _PrivateDisablePortal = $[1];
128
- anchorSide = $[2];
129
- ignoreClickRefs = $[3];
130
- initialFocusRef = $[4];
131
- left = $[5];
132
- onClickOutside = $[6];
133
- onEscape = $[7];
134
- portalContainerName = $[8];
135
- preventFocusOnOpen = $[9];
136
- props = $[10];
137
- responsiveVariant = $[11];
138
- returnFocusRef = $[12];
139
- right = $[13];
140
- t1 = $[14];
141
- t2 = $[15];
142
- t3 = $[16];
143
- t4 = $[17];
144
- t5 = $[18];
145
- }
146
- const height = t1 === void 0 ? "auto" : t1;
147
- const preventOverflow = t2 === void 0 ? true : t2;
148
- const role = t3 === void 0 ? "none" : t3;
149
- const visibility = t4 === void 0 ? "visible" : t4;
150
- const width = t5 === void 0 ? "auto" : t5;
84
+ const Overlay = /*#__PURE__*/ React.forwardRef(({ anchorSide, _PrivateDisablePortal, height = "auto", ignoreClickRefs, initialFocusRef, left, onClickOutside, onEscape, portalContainerName, preventOverflow = true, preventFocusOnOpen, returnFocusRef, right, role = "none", visibility = "visible", width = "auto", responsiveVariant, ...props }, forwardedRef) => {
151
85
  const overlayRef = useRef(null);
152
86
  const mergedOverlayRef = useMergedRefs(forwardedRef, overlayRef);
87
+ const slideAnimationDistance = 8;
88
+ const slideAnimationEasing = "cubic-bezier(0.33, 1, 0.68, 1)";
153
89
  const cssAnchorPositioning = useFeatureFlag("primer_react_css_anchor_positioning");
154
- let t6;
155
- if ($[19] !== ignoreClickRefs || $[20] !== initialFocusRef || $[21] !== onClickOutside || $[22] !== onEscape || $[23] !== preventFocusOnOpen || $[24] !== returnFocusRef) {
156
- t6 = {
157
- overlayRef,
158
- returnFocusRef,
159
- onEscape,
160
- ignoreClickRefs,
161
- onClickOutside,
162
- initialFocusRef,
163
- preventFocusOnOpen
164
- };
165
- $[19] = ignoreClickRefs;
166
- $[20] = initialFocusRef;
167
- $[21] = onClickOutside;
168
- $[22] = onEscape;
169
- $[23] = preventFocusOnOpen;
170
- $[24] = returnFocusRef;
171
- $[25] = t6;
172
- } else t6 = $[25];
173
- useOverlay(t6);
174
- let t7;
175
- let t8;
176
- if ($[26] !== height) {
177
- t7 = () => {
178
- var _overlayRef$current;
179
- if (height === "initial" && (_overlayRef$current = overlayRef.current) !== null && _overlayRef$current !== void 0 && _overlayRef$current.clientHeight) overlayRef.current.style.height = `${overlayRef.current.clientHeight}px`;
180
- };
181
- t8 = [height];
182
- $[26] = height;
183
- $[27] = t7;
184
- $[28] = t8;
185
- } else {
186
- t7 = $[27];
187
- t8 = $[28];
188
- }
189
- useEffect(t7, t8);
190
- let t10;
191
- let t9;
192
- if ($[29] !== anchorSide || $[30] !== visibility) {
193
- t9 = () => {
194
- var _overlayRef$current2;
195
- const { x, y } = getSlideAnimationStartingVector(anchorSide);
196
- if (!x && !y || !((_overlayRef$current2 = overlayRef.current) !== null && _overlayRef$current2 !== void 0 && _overlayRef$current2.animate) || visibility === "hidden") return;
197
- overlayRef.current.animate({ transform: [`translate(${8 * x}px, ${8 * y}px)`, "translate(0, 0)"] }, {
198
- duration: animationDuration,
199
- easing: "cubic-bezier(0.33, 1, 0.68, 1)"
200
- });
201
- };
202
- t10 = [
203
- anchorSide,
204
- 8,
205
- "cubic-bezier(0.33, 1, 0.68, 1)",
206
- visibility
207
- ];
208
- $[29] = anchorSide;
209
- $[30] = visibility;
210
- $[31] = t10;
211
- $[32] = t9;
212
- } else {
213
- t10 = $[31];
214
- t9 = $[32];
215
- }
216
- useIsomorphicLayoutEffect(t9, t10);
217
- const leftPosition = left === void 0 && right === void 0 ? 0 : left;
218
- const t11 = !preventOverflow ? true : void 0;
219
- let t12;
220
- if ($[33] !== height || $[34] !== leftPosition || $[35] !== mergedOverlayRef || $[36] !== props || $[37] !== responsiveVariant || $[38] !== right || $[39] !== role || $[40] !== t11 || $[41] !== visibility || $[42] !== width) {
221
- t12 = /*#__PURE__*/ jsx(BaseOverlay, {
222
- role,
223
- width,
224
- "data-reflow-container": t11,
225
- ref: mergedOverlayRef,
226
- left: leftPosition,
227
- right,
228
- height,
229
- visibility,
230
- "data-responsive": responsiveVariant,
231
- ...props
90
+ useOverlay({
91
+ overlayRef,
92
+ returnFocusRef,
93
+ onEscape,
94
+ ignoreClickRefs,
95
+ onClickOutside,
96
+ initialFocusRef,
97
+ preventFocusOnOpen
98
+ });
99
+ useEffect(() => {
100
+ var _overlayRef$current;
101
+ if (height === "initial" && (_overlayRef$current = overlayRef.current) !== null && _overlayRef$current !== void 0 && _overlayRef$current.clientHeight) overlayRef.current.style.height = `${overlayRef.current.clientHeight}px`;
102
+ }, [height]);
103
+ useIsomorphicLayoutEffect(() => {
104
+ var _overlayRef$current2;
105
+ const { x, y } = getSlideAnimationStartingVector(anchorSide);
106
+ if (!x && !y || !((_overlayRef$current2 = overlayRef.current) !== null && _overlayRef$current2 !== void 0 && _overlayRef$current2.animate) || visibility === "hidden") return;
107
+ overlayRef.current.animate({ transform: [`translate(${slideAnimationDistance * x}px, ${slideAnimationDistance * y}px)`, `translate(0, 0)`] }, {
108
+ duration: animationDuration,
109
+ easing: slideAnimationEasing
232
110
  });
233
- $[33] = height;
234
- $[34] = leftPosition;
235
- $[35] = mergedOverlayRef;
236
- $[36] = props;
237
- $[37] = responsiveVariant;
238
- $[38] = right;
239
- $[39] = role;
240
- $[40] = t11;
241
- $[41] = visibility;
242
- $[42] = width;
243
- $[43] = t12;
244
- } else t12 = $[43];
245
- const overlayContent = t12;
111
+ }, [
112
+ anchorSide,
113
+ slideAnimationDistance,
114
+ slideAnimationEasing,
115
+ visibility
116
+ ]);
117
+ const overlayContent = /*#__PURE__*/ jsx(BaseOverlay, {
118
+ role,
119
+ width,
120
+ "data-reflow-container": !preventOverflow ? true : void 0,
121
+ ref: mergedOverlayRef,
122
+ left: left === void 0 && right === void 0 ? 0 : left,
123
+ right,
124
+ height,
125
+ visibility,
126
+ "data-responsive": responsiveVariant,
127
+ ...props
128
+ });
246
129
  if (_PrivateDisablePortal && cssAnchorPositioning) return overlayContent;
247
- let t13;
248
- if ($[44] !== overlayContent || $[45] !== portalContainerName) {
249
- t13 = /*#__PURE__*/ jsx(Portal_default, {
250
- containerName: portalContainerName,
251
- children: overlayContent
252
- });
253
- $[44] = overlayContent;
254
- $[45] = portalContainerName;
255
- $[46] = t13;
256
- } else t13 = $[46];
257
- return t13;
130
+ return /*#__PURE__*/ jsx(Portal_default, {
131
+ containerName: portalContainerName,
132
+ children: overlayContent
133
+ });
258
134
  });
259
135
  //#endregion
260
136
  export { BaseOverlay, Overlay as default };
@@ -38,17 +38,17 @@ const TextInput = /*#__PURE__*/ React.forwardRef(({ icon: IconComponent, leading
38
38
  const trailingVisualId = useId();
39
39
  const loadingId = useId();
40
40
  const inputDescribedBy = clsx(inputProps["aria-describedby"], LeadingVisual && leadingVisualId, TrailingVisual && trailingVisualId, loading && loadingId) || void 0;
41
- const handleInputFocus = useCallback((e_0) => {
41
+ const handleInputFocus = useCallback((e) => {
42
42
  setIsInputFocused(true);
43
- onFocus && onFocus(e_0);
43
+ onFocus && onFocus(e);
44
44
  }, [onFocus]);
45
- const handleInputBlur = useCallback((e_1) => {
45
+ const handleInputBlur = useCallback((e) => {
46
46
  setIsInputFocused(false);
47
- onBlur && onBlur(e_1);
47
+ onBlur && onBlur(e);
48
48
  }, [onBlur]);
49
- const handleInputChange = useCallback((e_2) => {
50
- if (characterLimit && !isControlled) setUncontrolledLength(e_2.target.value.length);
51
- onChange === null || onChange === void 0 || onChange(e_2);
49
+ const handleInputChange = useCallback((e) => {
50
+ if (characterLimit && !isControlled) setUncontrolledLength(e.target.value.length);
51
+ onChange === null || onChange === void 0 || onChange(e);
52
52
  }, [
53
53
  onChange,
54
54
  characterLimit,