@primer/react 38.32.0-rc.4bb4bba69 → 38.32.0-rc.55b6eaf9c

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.
@@ -3,6 +3,7 @@ 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";
6
7
  import { clsx } from "clsx";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import React from "react";
@@ -13,75 +14,108 @@ const getOverlayWidth = (buttonClientRect, containerRef, overlayPaddingPx) => {
13
14
  var _containerRef$current;
14
15
  return overlayPaddingPx + buttonClientRect.right - (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().left) || 0);
15
16
  };
16
- const InlineToggle = ({ collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline }) => isOverflowShown ? /*#__PURE__*/ jsx(ButtonComponent, {
17
- ref: collapseButtonRef,
18
- onClick: collapseInlineExpandedChildren,
19
- size: "small",
20
- variant: "invisible",
21
- children: "Show less"
22
- }) : hiddenItemIds.length ? /*#__PURE__*/ jsxs(ButtonComponent, {
23
- ref: expandButtonRef,
24
- variant: "invisible",
25
- size: "small",
26
- onClick: showAllTokensInline,
27
- children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
28
- "Show +",
29
- hiddenItemIds.length,
30
- " more"
31
- ] }), /*#__PURE__*/ jsxs("span", {
32
- "aria-hidden": "true",
33
- children: ["+", hiddenItemIds.length]
34
- })]
35
- }) : null;
36
- const OverlayToggle = ({ children, closeOverflowOverlay, expandButtonRef, hiddenItemIds, isOverflowShown, openOverflowOverlay, overlayPaddingPx, overlayWidth, totalLength }) => hiddenItemIds.length ? /*#__PURE__*/ jsx(AnchoredOverlay, {
37
- open: isOverflowShown,
38
- onOpen: openOverflowOverlay,
39
- onClose: closeOverflowOverlay,
40
- width: "auto",
41
- height: "auto",
42
- align: "start",
43
- side: "inside-right",
44
- anchorRef: expandButtonRef,
45
- anchorOffset: overlayPaddingPx * -1,
46
- alignmentOffset: overlayPaddingPx * -1,
47
- renderAnchor: (props) => /*#__PURE__*/ jsxs(ButtonComponent, {
48
- variant: "invisible",
49
- size: "small",
50
- ...props,
51
- ref: expandButtonRef,
52
- children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
53
- "Show +",
54
- hiddenItemIds.length,
55
- " more"
56
- ] }), /*#__PURE__*/ jsxs("span", {
57
- "aria-hidden": "true",
58
- children: ["+", hiddenItemIds.length]
59
- })]
60
- }),
61
- focusZoneSettings: { disabled: true },
62
- overlayProps: {
63
- role: "dialog",
64
- "aria-label": `All ${totalLength} labels`,
65
- "aria-modal": true
66
- },
67
- children: /*#__PURE__*/ jsxs("div", {
68
- className: LabelGroup_module_css_default.OverlayContainer,
69
- style: {
70
- width: overlayWidth,
71
- padding: `${overlayPaddingPx}px`
72
- },
73
- children: [/*#__PURE__*/ jsx("div", {
74
- className: LabelGroup_module_css_default.OverlayInner,
75
- children
76
- }), /*#__PURE__*/ jsx(IconButton, {
77
- onClick: closeOverflowOverlay,
78
- icon: XIcon,
79
- "aria-label": "Close",
17
+ const InlineToggle = (t0) => {
18
+ const $ = c(7);
19
+ const { collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline } = t0;
20
+ let t1;
21
+ if ($[0] !== collapseButtonRef || $[1] !== collapseInlineExpandedChildren || $[2] !== expandButtonRef || $[3] !== hiddenItemIds || $[4] !== isOverflowShown || $[5] !== showAllTokensInline) {
22
+ t1 = isOverflowShown ? /*#__PURE__*/ jsx(ButtonComponent, {
23
+ ref: collapseButtonRef,
24
+ onClick: collapseInlineExpandedChildren,
25
+ size: "small",
80
26
  variant: "invisible",
81
- className: LabelGroup_module_css_default.CloseButton
82
- })]
83
- })
84
- }) : null;
27
+ children: "Show less"
28
+ }) : hiddenItemIds.length ? /*#__PURE__*/ jsxs(ButtonComponent, {
29
+ ref: expandButtonRef,
30
+ variant: "invisible",
31
+ size: "small",
32
+ onClick: showAllTokensInline,
33
+ children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
34
+ "Show +",
35
+ hiddenItemIds.length,
36
+ " more"
37
+ ] }), /*#__PURE__*/ jsxs("span", {
38
+ "aria-hidden": "true",
39
+ children: ["+", hiddenItemIds.length]
40
+ })]
41
+ }) : null;
42
+ $[0] = collapseButtonRef;
43
+ $[1] = collapseInlineExpandedChildren;
44
+ $[2] = expandButtonRef;
45
+ $[3] = hiddenItemIds;
46
+ $[4] = isOverflowShown;
47
+ $[5] = showAllTokensInline;
48
+ $[6] = t1;
49
+ } else t1 = $[6];
50
+ return t1;
51
+ };
52
+ const OverlayToggle = (t0) => {
53
+ const $ = c(10);
54
+ const { children, closeOverflowOverlay, expandButtonRef, hiddenItemIds, isOverflowShown, openOverflowOverlay, overlayPaddingPx, overlayWidth, totalLength } = t0;
55
+ let t1;
56
+ if ($[0] !== children || $[1] !== closeOverflowOverlay || $[2] !== expandButtonRef || $[3] !== hiddenItemIds.length || $[4] !== isOverflowShown || $[5] !== openOverflowOverlay || $[6] !== overlayPaddingPx || $[7] !== overlayWidth || $[8] !== totalLength) {
57
+ t1 = hiddenItemIds.length ? /*#__PURE__*/ jsx(AnchoredOverlay, {
58
+ open: isOverflowShown,
59
+ onOpen: openOverflowOverlay,
60
+ onClose: closeOverflowOverlay,
61
+ width: "auto",
62
+ height: "auto",
63
+ align: "start",
64
+ side: "inside-right",
65
+ anchorRef: expandButtonRef,
66
+ anchorOffset: overlayPaddingPx * -1,
67
+ alignmentOffset: overlayPaddingPx * -1,
68
+ renderAnchor: (props) => /*#__PURE__*/ jsxs(ButtonComponent, {
69
+ variant: "invisible",
70
+ size: "small",
71
+ ...props,
72
+ ref: expandButtonRef,
73
+ children: [/*#__PURE__*/ jsxs(VisuallyHidden, { children: [
74
+ "Show +",
75
+ hiddenItemIds.length,
76
+ " more"
77
+ ] }), /*#__PURE__*/ jsxs("span", {
78
+ "aria-hidden": "true",
79
+ children: ["+", hiddenItemIds.length]
80
+ })]
81
+ }),
82
+ focusZoneSettings: { disabled: true },
83
+ overlayProps: {
84
+ role: "dialog",
85
+ "aria-label": `All ${totalLength} labels`,
86
+ "aria-modal": true
87
+ },
88
+ children: /*#__PURE__*/ jsxs("div", {
89
+ className: LabelGroup_module_css_default.OverlayContainer,
90
+ style: {
91
+ width: overlayWidth,
92
+ padding: `${overlayPaddingPx}px`
93
+ },
94
+ children: [/*#__PURE__*/ jsx("div", {
95
+ className: LabelGroup_module_css_default.OverlayInner,
96
+ children
97
+ }), /*#__PURE__*/ jsx(IconButton, {
98
+ onClick: closeOverflowOverlay,
99
+ icon: XIcon,
100
+ "aria-label": "Close",
101
+ variant: "invisible",
102
+ className: LabelGroup_module_css_default.CloseButton
103
+ })]
104
+ })
105
+ }) : null;
106
+ $[0] = children;
107
+ $[1] = closeOverflowOverlay;
108
+ $[2] = expandButtonRef;
109
+ $[3] = hiddenItemIds.length;
110
+ $[4] = isOverflowShown;
111
+ $[5] = openOverflowOverlay;
112
+ $[6] = overlayPaddingPx;
113
+ $[7] = overlayWidth;
114
+ $[8] = totalLength;
115
+ $[9] = t1;
116
+ } else t1 = $[9];
117
+ return t1;
118
+ };
85
119
  const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as: Component = "ul", className }) => {
86
120
  const containerRef = React.useRef(null);
87
121
  const collapseButtonRef = React.useRef(null);
@@ -143,14 +177,14 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
143
177
  if (!visibleChildCount || isOverflowShown) return;
144
178
  if (visibleChildCount === "auto") {
145
179
  const observer = new IntersectionObserver((entries) => {
146
- const updatedEntries = {};
180
+ const updatedEntries_0 = {};
147
181
  for (const entry of entries) {
148
- const targetId = entry.target.getAttribute("data-index");
149
- if (targetId) updatedEntries[targetId] = entry.isIntersecting;
182
+ const targetId_0 = entry.target.getAttribute("data-index");
183
+ if (targetId_0) updatedEntries_0[targetId_0] = entry.isIntersecting;
150
184
  }
151
185
  setVisibilityMap((prev) => ({
152
186
  ...prev,
153
- ...updatedEntries
187
+ ...updatedEntries_0
154
188
  }));
155
189
  }, {
156
190
  root: containerRef.current,
@@ -196,10 +230,10 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
196
230
  "data-list": isList || void 0,
197
231
  className: clsx(className, LabelGroup_module_css_default.Container),
198
232
  "data-component": "LabelGroup",
199
- children: [React.Children.map(children, (child, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
233
+ children: [React.Children.map(children, (child_0, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
200
234
  "data-index": index,
201
235
  className: clsx(LabelGroup_module_css_default.ItemWrapper, { [LabelGroup_module_css_default["ItemWrapper--hidden"]]: hiddenItemIds.includes(index.toString()) }),
202
- children: child
236
+ children: child_0
203
237
  }, index)), /*#__PURE__*/ jsx(ToggleWrapper, {
204
238
  "data-component": "LabelGroup.Toggle",
205
239
  children: overflowStyle === "inline" ? /*#__PURE__*/ jsx(InlineToggle, {
@@ -227,8 +261,8 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
227
261
  "data-list": isList || void 0,
228
262
  className: clsx(className, LabelGroup_module_css_default.Container),
229
263
  "data-component": "LabelGroup",
230
- children: isList ? React.Children.map(children, (child, index) => {
231
- return /*#__PURE__*/ jsx("li", { children: child }, index);
264
+ children: isList ? React.Children.map(children, (child_1, index_0) => {
265
+ return /*#__PURE__*/ jsx("li", { children: child_1 }, index_0);
232
266
  }) : children
233
267
  });
234
268
  };
@@ -4,6 +4,7 @@ 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";
7
8
  import { clsx } from "clsx";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
  import React, { useEffect, useRef } from "react";
@@ -81,56 +82,179 @@ const BaseOverlay = /*#__PURE__*/ React.forwardRef(({ visibility, height, width,
81
82
  * @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`.
82
83
 
83
84
  */
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) => {
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;
85
151
  const overlayRef = useRef(null);
86
152
  const mergedOverlayRef = useMergedRefs(forwardedRef, overlayRef);
87
- const slideAnimationDistance = 8;
88
- const slideAnimationEasing = "cubic-bezier(0.33, 1, 0.68, 1)";
89
153
  const cssAnchorPositioning = useFeatureFlag("primer_react_css_anchor_positioning");
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
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
110
232
  });
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
- });
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;
129
246
  if (_PrivateDisablePortal && cssAnchorPositioning) return overlayContent;
130
- return /*#__PURE__*/ jsx(Portal_default, {
131
- containerName: portalContainerName,
132
- children: overlayContent
133
- });
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;
134
258
  });
135
259
  //#endregion
136
260
  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) => {
41
+ const handleInputFocus = useCallback((e_0) => {
42
42
  setIsInputFocused(true);
43
- onFocus && onFocus(e);
43
+ onFocus && onFocus(e_0);
44
44
  }, [onFocus]);
45
- const handleInputBlur = useCallback((e) => {
45
+ const handleInputBlur = useCallback((e_1) => {
46
46
  setIsInputFocused(false);
47
- onBlur && onBlur(e);
47
+ onBlur && onBlur(e_1);
48
48
  }, [onBlur]);
49
- const handleInputChange = useCallback((e) => {
50
- if (characterLimit && !isControlled) setUncontrolledLength(e.target.value.length);
51
- onChange === null || onChange === void 0 || onChange(e);
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);
52
52
  }, [
53
53
  onChange,
54
54
  characterLimit,