@primer/react 38.31.0 → 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 +6 -0
- package/dist/ActionBar/ActionBar.js +93 -98
- package/dist/UnderlineNav/UnderlineNav.js +90 -79
- package/dist/UnderlineNav/UnderlineNavItem.js +48 -64
- package/dist/internal/components/OverflowObserverProvider.js +157 -0
- package/dist/internal/hooks/useOverflowObserver.js +57 -0
- package/dist/utils/descendant-registry.js +79 -42
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
|
@@ -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
|
|
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(
|
|
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__*/
|
|
94
|
-
|
|
95
|
-
children
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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":
|
|
122
|
+
"aria-label": t14,
|
|
111
123
|
icon: KebabHorizontalIcon,
|
|
112
124
|
className: ActionBar_module_css_default.MoreButton,
|
|
113
|
-
"data-more-button-inactive":
|
|
125
|
+
"data-more-button-inactive": t15,
|
|
114
126
|
size
|
|
115
127
|
}) });
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
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
|
-
|
|
132
|
-
|
|
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 ($[
|
|
135
|
-
t18 = /*#__PURE__*/
|
|
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] !==
|
|
142
|
-
t19 = /*#__PURE__*/ jsxs(
|
|
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: [
|
|
163
|
+
children: [t13, t19]
|
|
152
164
|
});
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
162
|
-
} else
|
|
163
|
-
let
|
|
164
|
-
if ($[
|
|
165
|
-
|
|
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] =
|
|
185
|
+
$[38] = t8;
|
|
184
186
|
$[39] = t21;
|
|
185
187
|
} else t21 = $[39];
|
|
186
|
-
|
|
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(
|
|
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
|
|
195
|
-
t0 =
|
|
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] =
|
|
203
|
-
|
|
204
|
-
|
|
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
|
|
216
|
-
let
|
|
217
|
-
if ($[
|
|
218
|
-
|
|
214
|
+
const t1 = isOverflowing ? "" : void 0;
|
|
215
|
+
let t2;
|
|
216
|
+
if ($[2] !== isOverflowing || $[3] !== t1) {
|
|
217
|
+
t2 = {
|
|
219
218
|
isOverflowing,
|
|
220
|
-
dataOverflowingAttr:
|
|
219
|
+
dataOverflowingAttr: t1
|
|
221
220
|
};
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
} else
|
|
226
|
-
return
|
|
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(
|
|
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
|
|
532
|
+
function _temp5(item, index) {
|
|
538
533
|
return renderMenuItem(item, index);
|
|
539
534
|
}
|
|
540
535
|
//#endregion
|
|
@@ -6,6 +6,7 @@ import { ActionList } from "../ActionList/index.js";
|
|
|
6
6
|
import { ActionMenu } from "../ActionMenu/ActionMenu.js";
|
|
7
7
|
import { SkeletonText } from "../SkeletonText/SkeletonText.js";
|
|
8
8
|
import { LoadingCounter, UnderlineItemList, UnderlineWrapper } from "../internal/components/UnderlineTabbedInterface.js";
|
|
9
|
+
import { OverflowObserverProvider } from "../internal/components/OverflowObserverProvider.js";
|
|
9
10
|
import UnderlineNav_module_css_default from "./UnderlineNav.module.css.js";
|
|
10
11
|
import { UnderlineNavContext } from "./UnderlineNavContext.js";
|
|
11
12
|
import { UnderlineNavItemsRegistry } from "./UnderlineNavItemsRegistry.js";
|
|
@@ -16,7 +17,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
16
17
|
import { forwardRef, useRef, useState } from "react";
|
|
17
18
|
//#region src/UnderlineNav/UnderlineNav.tsx
|
|
18
19
|
const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
19
|
-
const $ = c(
|
|
20
|
+
const $ = c(52);
|
|
20
21
|
const { as: t1, "aria-label": ariaLabel, loadingCounters: t2, variant: t3, className, children } = t0;
|
|
21
22
|
const as = t1 === void 0 ? "nav" : t1;
|
|
22
23
|
const loadingCounters = t2 === void 0 ? false : t2;
|
|
@@ -98,52 +99,62 @@ const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
|
98
99
|
const t12 = isOverflowing ? "true" : void 0;
|
|
99
100
|
let t13;
|
|
100
101
|
if ($[17] !== children || $[18] !== setRegisteredItems) {
|
|
101
|
-
t13 = /*#__PURE__*/ jsx(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
className: UnderlineNav_module_css_default.ItemsList,
|
|
105
|
-
children: /*#__PURE__*/ jsx(UnderlineNavItemsRegistry.Provider, {
|
|
106
|
-
setRegistry: setRegisteredItems,
|
|
107
|
-
children
|
|
108
|
-
})
|
|
102
|
+
t13 = /*#__PURE__*/ jsx(UnderlineNavItemsRegistry.Provider, {
|
|
103
|
+
setRegistry: setRegisteredItems,
|
|
104
|
+
children
|
|
109
105
|
});
|
|
110
106
|
$[17] = children;
|
|
111
107
|
$[18] = setRegisteredItems;
|
|
112
108
|
$[19] = t13;
|
|
113
109
|
} else t13 = $[19];
|
|
114
110
|
let t14;
|
|
115
|
-
if ($[20]
|
|
116
|
-
t14 = /*#__PURE__*/ jsx(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
if ($[20] !== navRef || $[21] !== t13) {
|
|
112
|
+
t14 = /*#__PURE__*/ jsx(UnderlineItemList, {
|
|
113
|
+
ref: listRef,
|
|
114
|
+
role: "list",
|
|
115
|
+
className: UnderlineNav_module_css_default.ItemsList,
|
|
116
|
+
children: /*#__PURE__*/ jsx(OverflowObserverProvider, {
|
|
117
|
+
rootRef: navRef,
|
|
118
|
+
children: t13
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
$[20] = navRef;
|
|
122
|
+
$[21] = t13;
|
|
123
|
+
$[22] = t14;
|
|
124
|
+
} else t14 = $[22];
|
|
125
|
+
let t15;
|
|
126
|
+
if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
|
|
127
|
+
t15 = /*#__PURE__*/ jsx("div", { className: UnderlineNav_module_css_default.MoreButtonDivider });
|
|
128
|
+
$[23] = t15;
|
|
129
|
+
} else t15 = $[23];
|
|
130
|
+
const t16 = overflowingCurrentItem ? "true" : void 0;
|
|
131
|
+
const t17 = overflowingCurrentItem ? "More items, including current item" : void 0;
|
|
132
|
+
let t18;
|
|
133
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
134
|
+
t18 = /*#__PURE__*/ jsxs("span", { children: ["More", /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
124
135
|
as: "span",
|
|
125
136
|
children: " items"
|
|
126
137
|
})] });
|
|
127
|
-
$[
|
|
128
|
-
} else
|
|
129
|
-
let
|
|
130
|
-
if ($[
|
|
131
|
-
|
|
138
|
+
$[24] = t18;
|
|
139
|
+
} else t18 = $[24];
|
|
140
|
+
let t19;
|
|
141
|
+
if ($[25] !== t16 || $[26] !== t17) {
|
|
142
|
+
t19 = /*#__PURE__*/ jsx(ActionMenu.Button, {
|
|
132
143
|
className: UnderlineNav_module_css_default.MoreButton,
|
|
133
144
|
variant: "invisible",
|
|
134
145
|
"data-component": "overflow-menu-button",
|
|
135
|
-
"data-current":
|
|
136
|
-
"aria-label":
|
|
137
|
-
children:
|
|
146
|
+
"data-current": t16,
|
|
147
|
+
"aria-label": t17,
|
|
148
|
+
children: t18
|
|
138
149
|
});
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
} else
|
|
143
|
-
let
|
|
144
|
-
if ($[
|
|
145
|
-
|
|
146
|
-
const [key, allProps] =
|
|
150
|
+
$[25] = t16;
|
|
151
|
+
$[26] = t17;
|
|
152
|
+
$[27] = t19;
|
|
153
|
+
} else t19 = $[27];
|
|
154
|
+
let t20;
|
|
155
|
+
if ($[28] !== loadingCounters || $[29] !== overflowMenuItems || $[30] !== registeredItems) {
|
|
156
|
+
t20 = registeredItems === void 0 ? /*#__PURE__*/ jsx(ActionList.Item, { children: /*#__PURE__*/ jsx(SkeletonText, {}) }) : overflowMenuItems.map((t21) => {
|
|
157
|
+
const [key, allProps] = t21;
|
|
147
158
|
const { children: menuItemChildren, counter, onSelect, ...menuItemProps } = allProps;
|
|
148
159
|
return /*#__PURE__*/ jsxs(ActionList.LinkItem, {
|
|
149
160
|
onClick: (event) => onSelect === null || onSelect === void 0 ? void 0 : onSelect(event),
|
|
@@ -158,35 +169,35 @@ const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
|
158
169
|
}) })]
|
|
159
170
|
}, key);
|
|
160
171
|
});
|
|
161
|
-
$[
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
} else
|
|
166
|
-
let t20;
|
|
167
|
-
if ($[29] !== t19) {
|
|
168
|
-
t20 = /*#__PURE__*/ jsx(ActionMenu.Overlay, { children: /*#__PURE__*/ jsx(ActionList, { children: t19 }) });
|
|
169
|
-
$[29] = t19;
|
|
170
|
-
$[30] = t20;
|
|
171
|
-
} else t20 = $[30];
|
|
172
|
+
$[28] = loadingCounters;
|
|
173
|
+
$[29] = overflowMenuItems;
|
|
174
|
+
$[30] = registeredItems;
|
|
175
|
+
$[31] = t20;
|
|
176
|
+
} else t20 = $[31];
|
|
172
177
|
let t21;
|
|
173
|
-
if ($[
|
|
174
|
-
t21 = /*#__PURE__*/
|
|
178
|
+
if ($[32] !== t20) {
|
|
179
|
+
t21 = /*#__PURE__*/ jsx(ActionMenu.Overlay, { children: /*#__PURE__*/ jsx(ActionList, { children: t20 }) });
|
|
180
|
+
$[32] = t20;
|
|
181
|
+
$[33] = t21;
|
|
182
|
+
} else t21 = $[33];
|
|
183
|
+
let t22;
|
|
184
|
+
if ($[34] !== menuOpen || $[35] !== t19 || $[36] !== t21) {
|
|
185
|
+
t22 = /*#__PURE__*/ jsxs("div", {
|
|
175
186
|
className: UnderlineNav_module_css_default.MoreButtonContainer,
|
|
176
|
-
children: [
|
|
187
|
+
children: [t15, /*#__PURE__*/ jsxs(ActionMenu, {
|
|
177
188
|
open: menuOpen,
|
|
178
189
|
onOpenChange: setMenuOpen,
|
|
179
|
-
children: [
|
|
190
|
+
children: [t19, t21]
|
|
180
191
|
})]
|
|
181
192
|
});
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
} else
|
|
187
|
-
let
|
|
188
|
-
if ($[
|
|
189
|
-
|
|
193
|
+
$[34] = menuOpen;
|
|
194
|
+
$[35] = t19;
|
|
195
|
+
$[36] = t21;
|
|
196
|
+
$[37] = t22;
|
|
197
|
+
} else t22 = $[37];
|
|
198
|
+
let t23;
|
|
199
|
+
if ($[38] !== ariaLabel || $[39] !== as || $[40] !== navRef || $[41] !== t10 || $[42] !== t11 || $[43] !== t12 || $[44] !== t14 || $[45] !== t22 || $[46] !== variant) {
|
|
200
|
+
t23 = /*#__PURE__*/ jsxs(UnderlineWrapper, {
|
|
190
201
|
as,
|
|
191
202
|
"aria-label": ariaLabel,
|
|
192
203
|
className: t10,
|
|
@@ -195,31 +206,31 @@ const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
|
195
206
|
"data-overflow-mode": "wrap",
|
|
196
207
|
"data-hide-icons": t11,
|
|
197
208
|
"data-has-overflow": t12,
|
|
198
|
-
children: [
|
|
209
|
+
children: [t14, t22]
|
|
199
210
|
});
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
} else
|
|
211
|
-
let
|
|
212
|
-
if ($[
|
|
213
|
-
|
|
211
|
+
$[38] = ariaLabel;
|
|
212
|
+
$[39] = as;
|
|
213
|
+
$[40] = navRef;
|
|
214
|
+
$[41] = t10;
|
|
215
|
+
$[42] = t11;
|
|
216
|
+
$[43] = t12;
|
|
217
|
+
$[44] = t14;
|
|
218
|
+
$[45] = t22;
|
|
219
|
+
$[46] = variant;
|
|
220
|
+
$[47] = t23;
|
|
221
|
+
} else t23 = $[47];
|
|
222
|
+
let t24;
|
|
223
|
+
if ($[48] !== contextValue || $[49] !== t23 || $[50] !== t9) {
|
|
224
|
+
t24 = /*#__PURE__*/ jsxs(UnderlineNavContext.Provider, {
|
|
214
225
|
value: contextValue,
|
|
215
|
-
children: [t9,
|
|
226
|
+
children: [t9, t23]
|
|
216
227
|
});
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
} else
|
|
222
|
-
return
|
|
228
|
+
$[48] = contextValue;
|
|
229
|
+
$[49] = t23;
|
|
230
|
+
$[50] = t9;
|
|
231
|
+
$[51] = t24;
|
|
232
|
+
} else t24 = $[51];
|
|
233
|
+
return t24;
|
|
223
234
|
});
|
|
224
235
|
UnderlineNav.displayName = "UnderlineNav";
|
|
225
236
|
function _temp(entry) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { UnderlineItem } from "../internal/components/UnderlineTabbedInterface.js";
|
|
2
|
+
import { useIsClipped } from "../internal/hooks/useOverflowObserver.js";
|
|
2
3
|
import { UnderlineNavContext } from "./UnderlineNavContext.js";
|
|
3
4
|
import { UnderlineNavItemsRegistry } from "./UnderlineNavItemsRegistry.js";
|
|
4
5
|
import UnderlineNavItem_module_css_default from "./UnderlineNavItem.module.css.js";
|
|
5
6
|
import { c } from "react-compiler-runtime";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { forwardRef, useContext, useRef
|
|
8
|
+
import { forwardRef, useContext, useRef } from "react";
|
|
8
9
|
//#region src/UnderlineNav/UnderlineNavItem.tsx
|
|
9
10
|
const UnderlineNavItem = /*#__PURE__*/ forwardRef((allProps, forwardedRef) => {
|
|
10
11
|
var _leadingVisual;
|
|
11
|
-
const $ = c(
|
|
12
|
+
const $ = c(30);
|
|
12
13
|
let Icon;
|
|
13
14
|
let ariaCurrent;
|
|
14
15
|
let children;
|
|
@@ -45,46 +46,32 @@ const UnderlineNavItem = /*#__PURE__*/ forwardRef((allProps, forwardedRef) => {
|
|
|
45
46
|
const href = t1 === void 0 ? "#" : t1;
|
|
46
47
|
const ref = useRef(null);
|
|
47
48
|
const { loadingCounters } = useContext(UnderlineNavContext);
|
|
49
|
+
const isOverflowing = useIsClipped(ref);
|
|
50
|
+
UnderlineNavItemsRegistry.useRegisterDescendant(isOverflowing ? allProps : null);
|
|
48
51
|
let t2;
|
|
49
|
-
if ($[10]
|
|
50
|
-
t2 = (
|
|
51
|
-
|
|
52
|
-
if (ref.current) observer.observe(ref.current);
|
|
53
|
-
return () => observer.disconnect();
|
|
52
|
+
if ($[10] !== onSelect) {
|
|
53
|
+
t2 = (event) => {
|
|
54
|
+
if ((event.key === " " || event.key === "Enter") && !event.defaultPrevented && typeof onSelect === "function") onSelect(event);
|
|
54
55
|
};
|
|
55
|
-
$[10] =
|
|
56
|
-
|
|
56
|
+
$[10] = onSelect;
|
|
57
|
+
$[11] = t2;
|
|
58
|
+
} else t2 = $[11];
|
|
59
|
+
const keyDownHandler = t2;
|
|
57
60
|
let t3;
|
|
58
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
59
|
-
t3 = () => ref.current ? ref.current.offsetTop > 0 : false;
|
|
60
|
-
$[11] = t3;
|
|
61
|
-
} else t3 = $[11];
|
|
62
|
-
const isOverflowing = useSyncExternalStore(t2, t3, _temp);
|
|
63
|
-
UnderlineNavItemsRegistry.useRegisterDescendant(isOverflowing ? allProps : null);
|
|
64
|
-
let t4;
|
|
65
61
|
if ($[12] !== onSelect) {
|
|
66
|
-
|
|
67
|
-
if ((event.key === " " || event.key === "Enter") && !event.defaultPrevented && typeof onSelect === "function") onSelect(event);
|
|
68
|
-
};
|
|
69
|
-
$[12] = onSelect;
|
|
70
|
-
$[13] = t4;
|
|
71
|
-
} else t4 = $[13];
|
|
72
|
-
const keyDownHandler = t4;
|
|
73
|
-
let t5;
|
|
74
|
-
if ($[14] !== onSelect) {
|
|
75
|
-
t5 = (event_0) => {
|
|
62
|
+
t3 = (event_0) => {
|
|
76
63
|
if (!event_0.defaultPrevented && typeof onSelect === "function") onSelect(event_0);
|
|
77
64
|
};
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
} else
|
|
81
|
-
const clickHandler =
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
let
|
|
86
|
-
if ($[
|
|
87
|
-
|
|
65
|
+
$[12] = onSelect;
|
|
66
|
+
$[13] = t3;
|
|
67
|
+
} else t3 = $[13];
|
|
68
|
+
const clickHandler = t3;
|
|
69
|
+
const t4 = isOverflowing ? true : allProps["aria-hidden"];
|
|
70
|
+
const t5 = (_leadingVisual = leadingVisual) !== null && _leadingVisual !== void 0 ? _leadingVisual : Icon;
|
|
71
|
+
const t6 = isOverflowing ? -1 : allProps.tabIndex;
|
|
72
|
+
let t7;
|
|
73
|
+
if ($[14] !== Component || $[15] !== ariaCurrent || $[16] !== children || $[17] !== clickHandler || $[18] !== counter || $[19] !== forwardedRef || $[20] !== href || $[21] !== keyDownHandler || $[22] !== loadingCounters || $[23] !== props || $[24] !== t5 || $[25] !== t6) {
|
|
74
|
+
t7 = /*#__PURE__*/ jsx(UnderlineItem, {
|
|
88
75
|
ref: forwardedRef,
|
|
89
76
|
as: Component,
|
|
90
77
|
href,
|
|
@@ -92,43 +79,40 @@ const UnderlineNavItem = /*#__PURE__*/ forwardRef((allProps, forwardedRef) => {
|
|
|
92
79
|
onKeyDown: keyDownHandler,
|
|
93
80
|
onClick: clickHandler,
|
|
94
81
|
counter,
|
|
95
|
-
icon:
|
|
82
|
+
icon: t5,
|
|
96
83
|
loadingCounters,
|
|
97
84
|
...props,
|
|
98
|
-
tabIndex:
|
|
85
|
+
tabIndex: t6,
|
|
99
86
|
children
|
|
100
87
|
});
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
88
|
+
$[14] = Component;
|
|
89
|
+
$[15] = ariaCurrent;
|
|
90
|
+
$[16] = children;
|
|
91
|
+
$[17] = clickHandler;
|
|
92
|
+
$[18] = counter;
|
|
93
|
+
$[19] = forwardedRef;
|
|
94
|
+
$[20] = href;
|
|
95
|
+
$[21] = keyDownHandler;
|
|
96
|
+
$[22] = loadingCounters;
|
|
97
|
+
$[23] = props;
|
|
98
|
+
$[24] = t5;
|
|
99
|
+
$[25] = t6;
|
|
111
100
|
$[26] = t7;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if ($[29] !== t6 || $[30] !== t9) {
|
|
117
|
-
t10 = /*#__PURE__*/ jsx("li", {
|
|
101
|
+
} else t7 = $[26];
|
|
102
|
+
let t8;
|
|
103
|
+
if ($[27] !== t4 || $[28] !== t7) {
|
|
104
|
+
t8 = /*#__PURE__*/ jsx("li", {
|
|
118
105
|
className: UnderlineNavItem_module_css_default.UnderlineNavItem,
|
|
119
106
|
ref,
|
|
120
|
-
"aria-hidden":
|
|
121
|
-
children:
|
|
107
|
+
"aria-hidden": t4,
|
|
108
|
+
children: t7
|
|
122
109
|
});
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
} else
|
|
127
|
-
return
|
|
110
|
+
$[27] = t4;
|
|
111
|
+
$[28] = t7;
|
|
112
|
+
$[29] = t8;
|
|
113
|
+
} else t8 = $[29];
|
|
114
|
+
return t8;
|
|
128
115
|
});
|
|
129
116
|
UnderlineNavItem.displayName = "UnderlineNavItem";
|
|
130
|
-
function _temp() {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
117
|
//#endregion
|
|
134
118
|
export { UnderlineNavItem };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import useIsomorphicLayoutEffect from "../../utils/useIsomorphicLayoutEffect.js";
|
|
2
|
+
import { OverflowObserverContext } from "../hooks/useOverflowObserver.js";
|
|
3
|
+
import { c } from "react-compiler-runtime";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
//#region src/internal/components/OverflowObserverProvider.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Owns a single `IntersectionObserver` shared by every descendant that calls `useIsClipped`, instead of each item
|
|
9
|
+
* creating its own observer. Each observed element maps to a set of change callbacks; one observer notification fans
|
|
10
|
+
* out to all of them.
|
|
11
|
+
*
|
|
12
|
+
* `rootRef` must point to the element that clips overflowing children (typically a single-row, `overflow: hidden`
|
|
13
|
+
* container). The observer is root-scoped to that element so children that wrap onto a clipped row are reported as
|
|
14
|
+
* overflowing. Until the root is attached the provider stays inert (it never falls back to the viewport, which would
|
|
15
|
+
* not reflect the container's clipping) and re-checks on later renders.
|
|
16
|
+
*/
|
|
17
|
+
function OverflowObserverProvider(t0) {
|
|
18
|
+
const $ = c(15);
|
|
19
|
+
const { children, rootRef } = t0;
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t1 = /* @__PURE__ */ new Map();
|
|
23
|
+
$[0] = t1;
|
|
24
|
+
} else t1 = $[0];
|
|
25
|
+
const subscribersRef = useRef(t1);
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t2 = /* @__PURE__ */ new Set();
|
|
29
|
+
$[1] = t2;
|
|
30
|
+
} else t2 = $[1];
|
|
31
|
+
const observedElementsRef = useRef(t2);
|
|
32
|
+
const observerRef = useRef(null);
|
|
33
|
+
const observerRootRef = useRef(null);
|
|
34
|
+
let t3;
|
|
35
|
+
if ($[2] !== rootRef) {
|
|
36
|
+
t3 = () => {
|
|
37
|
+
var _observerRef$current;
|
|
38
|
+
if (!supportsIntersectionObserver()) return null;
|
|
39
|
+
const root = rootRef.current;
|
|
40
|
+
if (root === null) return null;
|
|
41
|
+
if (observerRef.current && observerRootRef.current === root) return observerRef.current;
|
|
42
|
+
(_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 || _observerRef$current.disconnect();
|
|
43
|
+
observedElementsRef.current.clear();
|
|
44
|
+
observerRef.current = new IntersectionObserver((entries) => {
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const callbacks = subscribersRef.current.get(entry.target);
|
|
47
|
+
if (!callbacks) continue;
|
|
48
|
+
const isOverflowing = getIsOverflowing(entry);
|
|
49
|
+
for (const cb of callbacks) cb(isOverflowing);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
root,
|
|
53
|
+
threshold: [0, 1]
|
|
54
|
+
});
|
|
55
|
+
observerRootRef.current = root;
|
|
56
|
+
return observerRef.current;
|
|
57
|
+
};
|
|
58
|
+
$[2] = rootRef;
|
|
59
|
+
$[3] = t3;
|
|
60
|
+
} else t3 = $[3];
|
|
61
|
+
const getObserver = t3;
|
|
62
|
+
let t4;
|
|
63
|
+
if ($[4] !== getObserver) {
|
|
64
|
+
t4 = () => {
|
|
65
|
+
const observer = getObserver();
|
|
66
|
+
if (!observer) return;
|
|
67
|
+
for (const element of subscribersRef.current.keys()) if (!observedElementsRef.current.has(element)) {
|
|
68
|
+
observer.observe(element);
|
|
69
|
+
observedElementsRef.current.add(element);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
$[4] = getObserver;
|
|
73
|
+
$[5] = t4;
|
|
74
|
+
} else t4 = $[5];
|
|
75
|
+
const observeSubscribedElements = t4;
|
|
76
|
+
let t5;
|
|
77
|
+
if ($[6] !== observeSubscribedElements) {
|
|
78
|
+
t5 = (element_0, onOverflowChange) => {
|
|
79
|
+
let callbacks_0 = subscribersRef.current.get(element_0);
|
|
80
|
+
if (!callbacks_0) {
|
|
81
|
+
callbacks_0 = /* @__PURE__ */ new Set();
|
|
82
|
+
subscribersRef.current.set(element_0, callbacks_0);
|
|
83
|
+
}
|
|
84
|
+
callbacks_0.add(onOverflowChange);
|
|
85
|
+
observeSubscribedElements();
|
|
86
|
+
return () => {
|
|
87
|
+
const set = subscribersRef.current.get(element_0);
|
|
88
|
+
if (!set) return;
|
|
89
|
+
set.delete(onOverflowChange);
|
|
90
|
+
if (set.size === 0) {
|
|
91
|
+
var _observerRef$current2;
|
|
92
|
+
subscribersRef.current.delete(element_0);
|
|
93
|
+
observedElementsRef.current.delete(element_0);
|
|
94
|
+
(_observerRef$current2 = observerRef.current) === null || _observerRef$current2 === void 0 || _observerRef$current2.unobserve(element_0);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
$[6] = observeSubscribedElements;
|
|
99
|
+
$[7] = t5;
|
|
100
|
+
} else t5 = $[7];
|
|
101
|
+
const observe = t5;
|
|
102
|
+
let t6;
|
|
103
|
+
if ($[8] !== observeSubscribedElements) {
|
|
104
|
+
t6 = () => {
|
|
105
|
+
observeSubscribedElements();
|
|
106
|
+
};
|
|
107
|
+
$[8] = observeSubscribedElements;
|
|
108
|
+
$[9] = t6;
|
|
109
|
+
} else t6 = $[9];
|
|
110
|
+
useIsomorphicLayoutEffect(t6);
|
|
111
|
+
let t7;
|
|
112
|
+
let t8;
|
|
113
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
114
|
+
t7 = () => {
|
|
115
|
+
const subscribers = subscribersRef.current;
|
|
116
|
+
const observedElements = observedElementsRef.current;
|
|
117
|
+
return () => {
|
|
118
|
+
var _observerRef$current3;
|
|
119
|
+
(_observerRef$current3 = observerRef.current) === null || _observerRef$current3 === void 0 || _observerRef$current3.disconnect();
|
|
120
|
+
observerRef.current = null;
|
|
121
|
+
observedElements.clear();
|
|
122
|
+
subscribers.clear();
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
t8 = [];
|
|
126
|
+
$[10] = t7;
|
|
127
|
+
$[11] = t8;
|
|
128
|
+
} else {
|
|
129
|
+
t7 = $[10];
|
|
130
|
+
t8 = $[11];
|
|
131
|
+
}
|
|
132
|
+
useEffect(t7, t8);
|
|
133
|
+
let t9;
|
|
134
|
+
if ($[12] !== children || $[13] !== observe) {
|
|
135
|
+
t9 = /*#__PURE__*/ jsx(OverflowObserverContext.Provider, {
|
|
136
|
+
value: observe,
|
|
137
|
+
children
|
|
138
|
+
});
|
|
139
|
+
$[12] = children;
|
|
140
|
+
$[13] = observe;
|
|
141
|
+
$[14] = t9;
|
|
142
|
+
} else t9 = $[14];
|
|
143
|
+
return t9;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Treat any target that is not fully visible within the observer root as overflowing. Wrapped items should be fully
|
|
147
|
+
* clipped (`isIntersecting: false`, `intersectionRatio: 0`), but partial ratios also count as overflowing to guard
|
|
148
|
+
* against sub-pixel boundary cases.
|
|
149
|
+
*/
|
|
150
|
+
function getIsOverflowing(entry) {
|
|
151
|
+
return !entry.isIntersecting || entry.intersectionRatio < 1;
|
|
152
|
+
}
|
|
153
|
+
function supportsIntersectionObserver() {
|
|
154
|
+
return typeof IntersectionObserver !== "undefined";
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { OverflowObserverProvider };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
|
+
import { createContext, useContext, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/internal/hooks/useOverflowObserver.ts
|
|
4
|
+
/** Subscribe a single observed element to the shared `IntersectionObserver`. Returns an unsubscribe function. */
|
|
5
|
+
/** Provided by `OverflowObserverProvider`; `null` when no provider is present. Consumed via `useIsClipped`. */
|
|
6
|
+
const OverflowObserverContext = /*#__PURE__*/ createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Track whether `ref`'s element is currently clipped (overflowing) by the nearest `OverflowObserverProvider`'s
|
|
9
|
+
* root-scoped `IntersectionObserver`.
|
|
10
|
+
*
|
|
11
|
+
* Returns `false` when there is no surrounding provider, during SSR, when `IntersectionObserver` is unavailable, or when
|
|
12
|
+
* `disabled` is set.
|
|
13
|
+
*
|
|
14
|
+
* @param ref Ref to the element whose overflow state should be tracked.
|
|
15
|
+
* @param options.disabled When true, skips observer subscription entirely and always reports `false`. Useful for items
|
|
16
|
+
* whose overflow is determined by an ancestor (e.g. ActionBar items inside an overflowing group).
|
|
17
|
+
*/
|
|
18
|
+
function useIsClipped(ref, options) {
|
|
19
|
+
var _options$disabled;
|
|
20
|
+
const $ = c(6);
|
|
21
|
+
const disabled = (_options$disabled = options === null || options === void 0 ? void 0 : options.disabled) !== null && _options$disabled !== void 0 ? _options$disabled : false;
|
|
22
|
+
const observe = useContext(OverflowObserverContext);
|
|
23
|
+
const isOverflowingRef = useRef(false);
|
|
24
|
+
let t0;
|
|
25
|
+
if ($[0] !== disabled || $[1] !== observe || $[2] !== ref) {
|
|
26
|
+
t0 = (onChange) => {
|
|
27
|
+
if (disabled) return _temp;
|
|
28
|
+
const element = ref.current;
|
|
29
|
+
if (!element || observe === null) return _temp2;
|
|
30
|
+
const updateOverflowState = (isOverflowing) => {
|
|
31
|
+
if (isOverflowing !== isOverflowingRef.current) {
|
|
32
|
+
isOverflowingRef.current = isOverflowing;
|
|
33
|
+
onChange();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return observe(element, updateOverflowState);
|
|
37
|
+
};
|
|
38
|
+
$[0] = disabled;
|
|
39
|
+
$[1] = observe;
|
|
40
|
+
$[2] = ref;
|
|
41
|
+
$[3] = t0;
|
|
42
|
+
} else t0 = $[3];
|
|
43
|
+
const subscribe = t0;
|
|
44
|
+
let t1;
|
|
45
|
+
if ($[4] !== disabled) {
|
|
46
|
+
t1 = () => disabled ? false : isOverflowingRef.current;
|
|
47
|
+
$[4] = disabled;
|
|
48
|
+
$[5] = t1;
|
|
49
|
+
} else t1 = $[5];
|
|
50
|
+
return useSyncExternalStore(subscribe, t1, getOverflowServerSnapshot);
|
|
51
|
+
}
|
|
52
|
+
/** Stable server snapshot for `useIsClipped`: overflow is never measured during SSR. */
|
|
53
|
+
function _temp2() {}
|
|
54
|
+
function _temp() {}
|
|
55
|
+
const getOverflowServerSnapshot = () => false;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { OverflowObserverContext, useIsClipped };
|
|
@@ -89,25 +89,57 @@ function createDescendantRegistry() {
|
|
|
89
89
|
const unsetValue = Symbol("unset");
|
|
90
90
|
/** Provide context for registering descendant components. This only needs to wrap `children`. */
|
|
91
91
|
function Provider(t0) {
|
|
92
|
-
const $ = c(
|
|
92
|
+
const $ = c(17);
|
|
93
93
|
const { children, setRegistry } = t0;
|
|
94
94
|
const workingRegistryRef = useRef("queued");
|
|
95
95
|
const [key, rebuildRegistry] = useReducer(_temp, 0);
|
|
96
|
+
const pendingRebuildRef = useRef(false);
|
|
97
|
+
const isMountedRef = useRef(true);
|
|
96
98
|
let t1;
|
|
97
99
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
-
t1 =
|
|
99
|
-
if (
|
|
100
|
+
t1 = () => {
|
|
101
|
+
if (pendingRebuildRef.current) return;
|
|
102
|
+
pendingRebuildRef.current = true;
|
|
103
|
+
scheduleMicrotask(() => {
|
|
104
|
+
pendingRebuildRef.current = false;
|
|
105
|
+
if (isMountedRef.current) rebuildRegistry();
|
|
106
|
+
});
|
|
100
107
|
};
|
|
101
108
|
$[0] = t1;
|
|
102
109
|
} else t1 = $[0];
|
|
103
|
-
|
|
110
|
+
const scheduleRebuild = t1;
|
|
104
111
|
let t2;
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
let t3;
|
|
113
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
114
|
+
t2 = () => {
|
|
115
|
+
isMountedRef.current = true;
|
|
116
|
+
return () => {
|
|
117
|
+
isMountedRef.current = false;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
t3 = [];
|
|
121
|
+
$[1] = t2;
|
|
122
|
+
$[2] = t3;
|
|
123
|
+
} else {
|
|
124
|
+
t2 = $[1];
|
|
125
|
+
t3 = $[2];
|
|
126
|
+
}
|
|
127
|
+
useEffect(t2, t3);
|
|
128
|
+
let t4;
|
|
129
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
130
|
+
t4 = function instantiateNewRegistry() {
|
|
131
|
+
if (workingRegistryRef.current === "queued") workingRegistryRef.current = /* @__PURE__ */ new Map();
|
|
132
|
+
};
|
|
133
|
+
$[3] = t4;
|
|
134
|
+
} else t4 = $[3];
|
|
135
|
+
useIsomorphicLayoutEffect(t4);
|
|
136
|
+
let t5;
|
|
137
|
+
if ($[4] !== setRegistry) {
|
|
138
|
+
t5 = (id) => {
|
|
107
139
|
if (workingRegistryRef.current instanceof Map) workingRegistryRef.current.set(id, unsetValue);
|
|
108
140
|
else if (workingRegistryRef.current === "idle") {
|
|
109
141
|
workingRegistryRef.current = "queued";
|
|
110
|
-
|
|
142
|
+
scheduleRebuild();
|
|
111
143
|
}
|
|
112
144
|
return function unregister() {
|
|
113
145
|
if (workingRegistryRef.current instanceof Map) workingRegistryRef.current.delete(id);
|
|
@@ -118,57 +150,57 @@ function createDescendantRegistry() {
|
|
|
118
150
|
});
|
|
119
151
|
};
|
|
120
152
|
};
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
} else
|
|
124
|
-
const register =
|
|
125
|
-
let
|
|
126
|
-
if ($[
|
|
127
|
-
|
|
153
|
+
$[4] = setRegistry;
|
|
154
|
+
$[5] = t5;
|
|
155
|
+
} else t5 = $[5];
|
|
156
|
+
const register = t5;
|
|
157
|
+
let t6;
|
|
158
|
+
if ($[6] !== setRegistry) {
|
|
159
|
+
t6 = (id_0, value) => {
|
|
128
160
|
if (workingRegistryRef.current instanceof Map) workingRegistryRef.current.set(id_0, value);
|
|
129
161
|
else if (workingRegistryRef.current === "idle") setRegistry((prev_1) => new Map(prev_1).set(id_0, value));
|
|
130
162
|
};
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
} else
|
|
134
|
-
const updateValue =
|
|
135
|
-
let
|
|
136
|
-
if ($[
|
|
137
|
-
|
|
163
|
+
$[6] = setRegistry;
|
|
164
|
+
$[7] = t6;
|
|
165
|
+
} else t6 = $[7];
|
|
166
|
+
const updateValue = t6;
|
|
167
|
+
let t7;
|
|
168
|
+
if ($[8] !== setRegistry) {
|
|
169
|
+
t7 = function commitWorkingRegistry() {
|
|
138
170
|
if (workingRegistryRef.current instanceof Map) {
|
|
139
171
|
const setEntries = Array.from(workingRegistryRef.current.entries()).filter(_temp2);
|
|
140
172
|
setRegistry(new Map(setEntries));
|
|
141
173
|
workingRegistryRef.current = "idle";
|
|
142
174
|
}
|
|
143
175
|
};
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
} else
|
|
147
|
-
useEffect(
|
|
148
|
-
let
|
|
149
|
-
if ($[
|
|
150
|
-
|
|
176
|
+
$[8] = setRegistry;
|
|
177
|
+
$[9] = t7;
|
|
178
|
+
} else t7 = $[9];
|
|
179
|
+
useEffect(t7);
|
|
180
|
+
let t8;
|
|
181
|
+
if ($[10] !== key || $[11] !== register || $[12] !== updateValue) {
|
|
182
|
+
t8 = {
|
|
151
183
|
register,
|
|
152
184
|
updateValue,
|
|
153
185
|
key
|
|
154
186
|
};
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
} else
|
|
160
|
-
const contextValue =
|
|
161
|
-
let
|
|
162
|
-
if ($[
|
|
163
|
-
|
|
187
|
+
$[10] = key;
|
|
188
|
+
$[11] = register;
|
|
189
|
+
$[12] = updateValue;
|
|
190
|
+
$[13] = t8;
|
|
191
|
+
} else t8 = $[13];
|
|
192
|
+
const contextValue = t8;
|
|
193
|
+
let t9;
|
|
194
|
+
if ($[14] !== children || $[15] !== contextValue) {
|
|
195
|
+
t9 = /*#__PURE__*/ jsx(Context.Provider, {
|
|
164
196
|
value: contextValue,
|
|
165
197
|
children
|
|
166
198
|
});
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
} else
|
|
171
|
-
return
|
|
199
|
+
$[14] = children;
|
|
200
|
+
$[15] = contextValue;
|
|
201
|
+
$[16] = t9;
|
|
202
|
+
} else t9 = $[16];
|
|
203
|
+
return t9;
|
|
172
204
|
}
|
|
173
205
|
function _temp2(entry) {
|
|
174
206
|
return entry[1] !== unsetValue;
|
|
@@ -182,5 +214,10 @@ function createDescendantRegistry() {
|
|
|
182
214
|
useRegisterDescendant
|
|
183
215
|
};
|
|
184
216
|
}
|
|
217
|
+
/** Schedule a callback on a microtask, with a fallback for environments that lack `queueMicrotask`. */
|
|
218
|
+
function scheduleMicrotask(callback) {
|
|
219
|
+
if (typeof queueMicrotask === "function") queueMicrotask(callback);
|
|
220
|
+
else setTimeout(callback);
|
|
221
|
+
}
|
|
185
222
|
//#endregion
|
|
186
223
|
export { createDescendantRegistry };
|
package/package.json
CHANGED