@primer/react 38.31.0-rc.f96563b64 → 38.31.1-rc.43134a516

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,19 @@
1
1
  # @primer/react
2
2
 
3
+ ## 38.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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.
8
+
3
9
  ## 38.31.0
4
10
 
5
11
  ### Minor Changes
6
12
 
7
13
  - [#8057](https://github.com/primer/react/pull/8057) [`0b9c81e`](https://github.com/primer/react/commit/0b9c81e7e8fef1dfc98f3b86b5a375d4ec7fe204) Thanks [@francinelucca](https://github.com/francinelucca)! - ThemeProvider: Remove `primer_react_theme_provider_remove_ssr_handoff` feature flag.
8
14
 
15
+ - [#8105](https://github.com/primer/react/pull/8105) [`be2950f`](https://github.com/primer/react/commit/be2950fd1ac268dd4e79258ab2cfe9241dd9e1c6) Thanks [@joshblack](https://github.com/joshblack)! - React Compiler: Enable compiler output for Banner, ConfirmationDialog, PageLayout, Pagination, UnderlineNav, `useMergedRefs`, and `useScrollFlash`
16
+
9
17
  ### Patch Changes
10
18
 
11
19
  - [#8066](https://github.com/primer/react/pull/8066) [`dd66aa2`](https://github.com/primer/react/commit/dd66aa27611f7ad56adb7429b50813d6af5a01d7) Thanks [@janmaarten-a11y](https://github.com/janmaarten-a11y)! - Fix invalid HTML nesting in `ActionList.Heading` by applying the visually-hidden styles directly to the heading element instead of wrapping it in a `span`.
@@ -4,12 +4,14 @@ import { ButtonComponent } from "../Button/Button.js";
4
4
  import { FocusKeys, useFocusZone } from "../hooks/useFocusZone.js";
5
5
  import { ActionList } from "../ActionList/index.js";
6
6
  import { ActionMenu } from "../ActionMenu/ActionMenu.js";
7
+ import { useIsClipped } from "../internal/hooks/useOverflowObserver.js";
8
+ import { OverflowObserverProvider } from "../internal/components/OverflowObserverProvider.js";
7
9
  import { createDescendantRegistry } from "../utils/descendant-registry.js";
8
10
  import ActionBar_module_css_default from "./ActionBar.module.css.js";
9
11
  import { c } from "react-compiler-runtime";
10
12
  import { clsx } from "clsx";
11
13
  import { jsx, jsxs } from "react/jsx-runtime";
12
- import React, { forwardRef, useCallback, useContext, useMemo, useRef, useState, useSyncExternalStore } from "react";
14
+ import React, { forwardRef, useCallback, useContext, useMemo, useRef, useState } from "react";
13
15
  import { KebabHorizontalIcon } from "@primer/octicons-react";
14
16
  //#region src/ActionBar/ActionBar.tsx
15
17
  const ActionBarContext = /*#__PURE__*/ React.createContext({ size: "medium" });
@@ -40,7 +42,7 @@ const renderMenuItem = (item, index) => {
40
42
  };
41
43
  renderMenuItem.displayName = "renderMenuItem";
42
44
  const ActionBar = (t0) => {
43
- const $ = c(40);
45
+ const $ = c(43);
44
46
  const { size: t1, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, flush: t2, className, gap: t3 } = t0;
45
47
  const size = t1 === void 0 ? "medium" : t1;
46
48
  const flush = t2 === void 0 ? false : t2;
@@ -90,56 +92,66 @@ const ActionBar = (t0) => {
90
92
  } else t11 = $[9];
91
93
  let t12;
92
94
  if ($[10] !== children || $[11] !== setChildRegistry) {
93
- t12 = /*#__PURE__*/ jsxs("div", {
94
- className: ActionBar_module_css_default.OverflowContainer,
95
- children: [t11, /*#__PURE__*/ jsx(ActionBarItemsRegistry.Provider, {
96
- setRegistry: setChildRegistry,
97
- children
98
- })]
95
+ t12 = /*#__PURE__*/ jsx(ActionBarItemsRegistry.Provider, {
96
+ setRegistry: setChildRegistry,
97
+ children
99
98
  });
100
99
  $[10] = children;
101
100
  $[11] = setChildRegistry;
102
101
  $[12] = t12;
103
102
  } else t12 = $[12];
104
- const t13 = `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`;
105
- const t14 = overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? void 0 : true;
106
- let t15;
107
- if ($[13] !== size || $[14] !== t13 || $[15] !== t14) {
108
- t15 = /*#__PURE__*/ jsx(ActionMenu.Anchor, { children: /*#__PURE__*/ jsx(IconButton, {
103
+ let t13;
104
+ if ($[13] !== containerRef || $[14] !== t12) {
105
+ t13 = /*#__PURE__*/ jsxs("div", {
106
+ className: ActionBar_module_css_default.OverflowContainer,
107
+ children: [t11, /*#__PURE__*/ jsx(OverflowObserverProvider, {
108
+ rootRef: containerRef,
109
+ children: t12
110
+ })]
111
+ });
112
+ $[13] = containerRef;
113
+ $[14] = t12;
114
+ $[15] = t13;
115
+ } else t13 = $[15];
116
+ const t14 = `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`;
117
+ const t15 = overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? void 0 : true;
118
+ let t16;
119
+ if ($[16] !== size || $[17] !== t14 || $[18] !== t15) {
120
+ t16 = /*#__PURE__*/ jsx(ActionMenu.Anchor, { children: /*#__PURE__*/ jsx(IconButton, {
109
121
  variant: "invisible",
110
- "aria-label": t13,
122
+ "aria-label": t14,
111
123
  icon: KebabHorizontalIcon,
112
124
  className: ActionBar_module_css_default.MoreButton,
113
- "data-more-button-inactive": t14,
125
+ "data-more-button-inactive": t15,
114
126
  size
115
127
  }) });
116
- $[13] = size;
117
- $[14] = t13;
118
- $[15] = t14;
119
- $[16] = t15;
120
- } else t15 = $[16];
121
- let t16;
122
- if ($[17] !== overflowItems) {
123
- t16 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp4);
124
- $[17] = overflowItems;
125
- $[18] = t16;
126
- } else t16 = $[18];
127
- let t17;
128
- if ($[19] !== t16) {
129
- t17 = /*#__PURE__*/ jsx(ActionMenu.Overlay, { children: /*#__PURE__*/ jsx(ActionList, { children: t16 }) });
128
+ $[16] = size;
129
+ $[17] = t14;
130
+ $[18] = t15;
130
131
  $[19] = t16;
131
- $[20] = t17;
132
- } else t17 = $[20];
132
+ } else t16 = $[19];
133
+ let t17;
134
+ if ($[20] !== overflowItems) {
135
+ t17 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp4);
136
+ $[20] = overflowItems;
137
+ $[21] = t17;
138
+ } else t17 = $[21];
133
139
  let t18;
134
- if ($[21] !== t15 || $[22] !== t17) {
135
- t18 = /*#__PURE__*/ jsxs(ActionMenu, { children: [t15, t17] });
136
- $[21] = t15;
140
+ if ($[22] !== t17) {
141
+ t18 = /*#__PURE__*/ jsx(ActionMenu.Overlay, { children: /*#__PURE__*/ jsx(ActionList, { children: t17 }) });
137
142
  $[22] = t17;
138
143
  $[23] = t18;
139
144
  } else t18 = $[23];
140
145
  let t19;
141
- if ($[24] !== ariaLabel || $[25] !== ariaLabelledBy || $[26] !== gap || $[27] !== size || $[28] !== t10 || $[29] !== t12 || $[30] !== t18 || $[31] !== t9) {
142
- t19 = /*#__PURE__*/ jsxs("div", {
146
+ if ($[24] !== t16 || $[25] !== t18) {
147
+ t19 = /*#__PURE__*/ jsxs(ActionMenu, { children: [t16, t18] });
148
+ $[24] = t16;
149
+ $[25] = t18;
150
+ $[26] = t19;
151
+ } else t19 = $[26];
152
+ let t20;
153
+ if ($[27] !== ariaLabel || $[28] !== ariaLabelledBy || $[29] !== gap || $[30] !== size || $[31] !== t10 || $[32] !== t13 || $[33] !== t19 || $[34] !== t9) {
154
+ t20 = /*#__PURE__*/ jsxs("div", {
143
155
  ref: t9,
144
156
  role: "toolbar",
145
157
  className: ActionBar_module_css_default.List,
@@ -148,87 +160,70 @@ const ActionBar = (t0) => {
148
160
  "data-gap": gap,
149
161
  "data-size": size,
150
162
  "data-has-overflow": t10,
151
- children: [t12, t18]
163
+ children: [t13, t19]
152
164
  });
153
- $[24] = ariaLabel;
154
- $[25] = ariaLabelledBy;
155
- $[26] = gap;
156
- $[27] = size;
157
- $[28] = t10;
158
- $[29] = t12;
159
- $[30] = t18;
160
- $[31] = t9;
161
- $[32] = t19;
162
- } else t19 = $[32];
163
- let t20;
164
- if ($[33] !== flush || $[34] !== t19 || $[35] !== t8) {
165
- t20 = /*#__PURE__*/ jsx("div", {
165
+ $[27] = ariaLabel;
166
+ $[28] = ariaLabelledBy;
167
+ $[29] = gap;
168
+ $[30] = size;
169
+ $[31] = t10;
170
+ $[32] = t13;
171
+ $[33] = t19;
172
+ $[34] = t9;
173
+ $[35] = t20;
174
+ } else t20 = $[35];
175
+ let t21;
176
+ if ($[36] !== flush || $[37] !== t20 || $[38] !== t8) {
177
+ t21 = /*#__PURE__*/ jsx("div", {
166
178
  className: t8,
167
179
  "data-component": "ActionBar",
168
180
  "data-flush": flush,
169
- children: t19
170
- });
171
- $[33] = flush;
172
- $[34] = t19;
173
- $[35] = t8;
174
- $[36] = t20;
175
- } else t20 = $[36];
176
- let t21;
177
- if ($[37] !== t20 || $[38] !== t7) {
178
- t21 = /*#__PURE__*/ jsx(ActionBarContext.Provider, {
179
- value: t7,
180
181
  children: t20
181
182
  });
183
+ $[36] = flush;
182
184
  $[37] = t20;
183
- $[38] = t7;
185
+ $[38] = t8;
184
186
  $[39] = t21;
185
187
  } else t21 = $[39];
186
- return t21;
188
+ let t22;
189
+ if ($[40] !== t21 || $[41] !== t7) {
190
+ t22 = /*#__PURE__*/ jsx(ActionBarContext.Provider, {
191
+ value: t7,
192
+ children: t21
193
+ });
194
+ $[40] = t21;
195
+ $[41] = t7;
196
+ $[42] = t22;
197
+ } else t22 = $[42];
198
+ return t22;
187
199
  };
188
200
  function useActionBarItem(ref, registryProps) {
189
201
  var _useContext;
190
- const $ = c(8);
202
+ const $ = c(5);
191
203
  const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
192
204
  const isInGroup = isGroupOverflowing !== void 0;
193
205
  let t0;
194
- if ($[0] !== isInGroup || $[1] !== ref) {
195
- t0 = (onChange) => {
196
- if (isInGroup) return _temp5;
197
- const observer = new IntersectionObserver(() => onChange(), { threshold: .75 });
198
- if (ref.current) observer.observe(ref.current);
199
- return () => observer.disconnect();
200
- };
206
+ if ($[0] !== isInGroup) {
207
+ t0 = { disabled: isInGroup };
201
208
  $[0] = isInGroup;
202
- $[1] = ref;
203
- $[2] = t0;
204
- } else t0 = $[2];
205
- const subscribeIntersectionObserver = t0;
206
- let t1;
207
- if ($[3] !== ref) {
208
- t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
209
- $[3] = ref;
210
- $[4] = t1;
211
- } else t1 = $[4];
212
- const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp6);
209
+ $[1] = t0;
210
+ } else t0 = $[1];
211
+ const isItemOverflowing = useIsClipped(ref, t0);
213
212
  const isOverflowing = isGroupOverflowing || isItemOverflowing;
214
213
  ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
215
- const t2 = isOverflowing ? "" : void 0;
216
- let t3;
217
- if ($[5] !== isOverflowing || $[6] !== t2) {
218
- t3 = {
214
+ const t1 = isOverflowing ? "" : void 0;
215
+ let t2;
216
+ if ($[2] !== isOverflowing || $[3] !== t1) {
217
+ t2 = {
219
218
  isOverflowing,
220
- dataOverflowingAttr: t2
219
+ dataOverflowingAttr: t1
221
220
  };
222
- $[5] = isOverflowing;
223
- $[6] = t2;
224
- $[7] = t3;
225
- } else t3 = $[7];
226
- return t3;
227
- }
228
- function _temp6() {
229
- return false;
221
+ $[2] = isOverflowing;
222
+ $[3] = t1;
223
+ $[4] = t2;
224
+ } else t2 = $[4];
225
+ return t2;
230
226
  }
231
- function _temp5() {}
232
227
  const ActionBarIconButton = /*#__PURE__*/ forwardRef(({ disabled, onClick, ...props }, forwardedRef) => {
233
228
  const ref = useRef(null);
234
229
  const mergedRef = useMergedRefs(forwardedRef, ref);
@@ -444,7 +439,7 @@ const ActionBarMenu = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
444
439
  } else t4 = $[18];
445
440
  let t5;
446
441
  if ($[19] !== items) {
447
- t5 = items.map(_temp7);
442
+ t5 = items.map(_temp5);
448
443
  $[19] = items;
449
444
  $[20] = t5;
450
445
  } else t5 = $[20];
@@ -534,7 +529,7 @@ function _temp4(t0) {
534
529
  })] }, id);
535
530
  }
536
531
  }
537
- function _temp7(item, index) {
532
+ function _temp5(item, index) {
538
533
  return renderMenuItem(item, index);
539
534
  }
540
535
  //#endregion
@@ -3,8 +3,9 @@ import { AutocompleteContext, AutocompleteDeferredInputContext, AutocompleteInpu
3
3
  import AutocompleteInput from "./AutocompleteInput.js";
4
4
  import AutocompleteMenu from "./AutocompleteMenu.js";
5
5
  import AutocompleteOverlay from "./AutocompleteOverlay.js";
6
+ import { c } from "react-compiler-runtime";
6
7
  import { jsx } from "react/jsx-runtime";
7
- import { useCallback, useDeferredValue, useMemo, useReducer, useRef } from "react";
8
+ import { useDeferredValue, useReducer, useRef } from "react";
8
9
  //#region src/Autocomplete/Autocomplete.tsx
9
10
  const initialState = {
10
11
  inputValue: "",
@@ -39,88 +40,144 @@ const reducer = (state, action) => {
39
40
  default: return state;
40
41
  }
41
42
  };
42
- const Autocomplete = ({ children, id: idProp }) => {
43
+ const Autocomplete = (t0) => {
44
+ const $ = c(24);
45
+ const { children, id: idProp } = t0;
43
46
  const activeDescendantRef = useRef(null);
44
47
  const scrollContainerRef = useRef(null);
45
48
  const inputRef = useRef(null);
46
49
  const [state, dispatch] = useReducer(reducer, initialState);
47
50
  const { inputValue, showMenu, autocompleteSuggestion, isMenuDirectlyActivated, selectedItemLength } = state;
48
- const setInputValue = useCallback((value) => {
49
- dispatch({
50
- type: "inputValue",
51
- payload: value
52
- });
53
- }, []);
54
- const setShowMenu = useCallback((value) => {
55
- dispatch({
56
- type: "showMenu",
57
- payload: value
58
- });
59
- }, []);
60
- const setAutocompleteSuggestion = useCallback((value) => {
61
- dispatch({
62
- type: "autocompleteSuggestion",
63
- payload: value
64
- });
65
- }, []);
66
- const setIsMenuDirectlyActivated = useCallback((value) => {
67
- dispatch({
68
- type: "isMenuDirectlyActivated",
69
- payload: value
70
- });
71
- }, []);
72
- const setSelectedItemLength = useCallback((value) => {
73
- dispatch({
74
- type: "selectedItemLength",
75
- payload: value
76
- });
77
- }, []);
51
+ let t1;
52
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
53
+ t1 = (value) => {
54
+ dispatch({
55
+ type: "inputValue",
56
+ payload: value
57
+ });
58
+ };
59
+ $[0] = t1;
60
+ } else t1 = $[0];
61
+ const setInputValue = t1;
62
+ let t2;
63
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
64
+ t2 = (value_0) => {
65
+ dispatch({
66
+ type: "showMenu",
67
+ payload: value_0
68
+ });
69
+ };
70
+ $[1] = t2;
71
+ } else t2 = $[1];
72
+ const setShowMenu = t2;
73
+ let t3;
74
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
75
+ t3 = (value_1) => {
76
+ dispatch({
77
+ type: "autocompleteSuggestion",
78
+ payload: value_1
79
+ });
80
+ };
81
+ $[2] = t3;
82
+ } else t3 = $[2];
83
+ const setAutocompleteSuggestion = t3;
84
+ let t4;
85
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
86
+ t4 = (value_2) => {
87
+ dispatch({
88
+ type: "isMenuDirectlyActivated",
89
+ payload: value_2
90
+ });
91
+ };
92
+ $[3] = t4;
93
+ } else t4 = $[3];
94
+ const setIsMenuDirectlyActivated = t4;
95
+ let t5;
96
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
97
+ t5 = (value_3) => {
98
+ dispatch({
99
+ type: "selectedItemLength",
100
+ payload: value_3
101
+ });
102
+ };
103
+ $[4] = t5;
104
+ } else t5 = $[4];
105
+ const setSelectedItemLength = t5;
78
106
  const id = useId$1(idProp);
79
- const autocompleteContextValue = useMemo(() => ({
80
- activeDescendantRef,
81
- id,
82
- inputRef,
83
- scrollContainerRef,
84
- selectedItemLength,
85
- setAutocompleteSuggestion,
86
- setInputValue,
87
- setIsMenuDirectlyActivated,
88
- setShowMenu,
89
- setSelectedItemLength,
90
- showMenu
91
- }), [
92
- id,
93
- selectedItemLength,
94
- setAutocompleteSuggestion,
95
- setInputValue,
96
- setIsMenuDirectlyActivated,
97
- setShowMenu,
98
- setSelectedItemLength,
99
- showMenu
100
- ]);
101
- const autocompleteInputContextValue = useMemo(() => ({
102
- autocompleteSuggestion,
103
- inputValue,
104
- isMenuDirectlyActivated
105
- }), [
106
- autocompleteSuggestion,
107
- inputValue,
108
- isMenuDirectlyActivated
109
- ]);
107
+ let t6;
108
+ if ($[5] !== id || $[6] !== selectedItemLength || $[7] !== showMenu) {
109
+ t6 = {
110
+ activeDescendantRef,
111
+ id,
112
+ inputRef,
113
+ scrollContainerRef,
114
+ selectedItemLength,
115
+ setAutocompleteSuggestion,
116
+ setInputValue,
117
+ setIsMenuDirectlyActivated,
118
+ setShowMenu,
119
+ setSelectedItemLength,
120
+ showMenu
121
+ };
122
+ $[5] = id;
123
+ $[6] = selectedItemLength;
124
+ $[7] = showMenu;
125
+ $[8] = t6;
126
+ } else t6 = $[8];
127
+ const autocompleteContextValue = t6;
128
+ let t7;
129
+ if ($[9] !== autocompleteSuggestion || $[10] !== inputValue || $[11] !== isMenuDirectlyActivated) {
130
+ t7 = {
131
+ autocompleteSuggestion,
132
+ inputValue,
133
+ isMenuDirectlyActivated
134
+ };
135
+ $[9] = autocompleteSuggestion;
136
+ $[10] = inputValue;
137
+ $[11] = isMenuDirectlyActivated;
138
+ $[12] = t7;
139
+ } else t7 = $[12];
140
+ const autocompleteInputContextValue = t7;
110
141
  const deferredInputValue = useDeferredValue(inputValue);
111
- const autocompleteDeferredInputContextValue = useMemo(() => ({ deferredInputValue }), [deferredInputValue]);
112
- return /*#__PURE__*/ jsx(AutocompleteContext.Provider, {
113
- value: autocompleteContextValue,
114
- children: /*#__PURE__*/ jsx(AutocompleteInputContext.Provider, {
142
+ let t8;
143
+ if ($[13] !== deferredInputValue) {
144
+ t8 = { deferredInputValue };
145
+ $[13] = deferredInputValue;
146
+ $[14] = t8;
147
+ } else t8 = $[14];
148
+ const autocompleteDeferredInputContextValue = t8;
149
+ let t9;
150
+ if ($[15] !== autocompleteDeferredInputContextValue || $[16] !== children) {
151
+ t9 = /*#__PURE__*/ jsx(AutocompleteDeferredInputContext.Provider, {
152
+ value: autocompleteDeferredInputContextValue,
153
+ children
154
+ });
155
+ $[15] = autocompleteDeferredInputContextValue;
156
+ $[16] = children;
157
+ $[17] = t9;
158
+ } else t9 = $[17];
159
+ let t10;
160
+ if ($[18] !== autocompleteInputContextValue || $[19] !== t9) {
161
+ t10 = /*#__PURE__*/ jsx(AutocompleteInputContext.Provider, {
115
162
  value: autocompleteInputContextValue,
116
- children: /*#__PURE__*/ jsx(AutocompleteDeferredInputContext.Provider, {
117
- value: autocompleteDeferredInputContextValue,
118
- children
119
- })
120
- })
121
- });
163
+ children: t9
164
+ });
165
+ $[18] = autocompleteInputContextValue;
166
+ $[19] = t9;
167
+ $[20] = t10;
168
+ } else t10 = $[20];
169
+ let t11;
170
+ if ($[21] !== autocompleteContextValue || $[22] !== t10) {
171
+ t11 = /*#__PURE__*/ jsx(AutocompleteContext.Provider, {
172
+ value: autocompleteContextValue,
173
+ children: t10
174
+ });
175
+ $[21] = autocompleteContextValue;
176
+ $[22] = t10;
177
+ $[23] = t11;
178
+ } else t11 = $[23];
179
+ return t11;
122
180
  };
123
- Autocomplete.displayName = "Autocomplete";
124
181
  var Autocomplete_default = Object.assign(Autocomplete, {
125
182
  __SLOT__: Symbol("Autocomplete"),
126
183
  Context: AutocompleteContext,