@primer/react 0.0.0-20260707193228 → 0.0.0-20260707193314
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 +3 -5
- package/dist/Autocomplete/AutocompleteMenu.js +44 -36
- package/dist/LabelGroup/LabelGroup.js +23 -32
- package/dist/SelectPanel/SelectPanel.js +6 -4
- package/dist/ToggleSwitch/ToggleSwitch.js +2 -2
- package/dist/experimental/SelectPanel2/SelectPanel.js +9 -1
- package/dist/hooks/useMedia.js +43 -44
- package/dist/internal/components/ValidationAnimationContainer.js +30 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260707193314
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
### Patch Changes
|
|
19
19
|
|
|
20
|
-
- [#8005](https://github.com/primer/react/pull/8005) [`5d24be4`](https://github.com/primer/react/commit/5d24be483f2fdfa305970907984d04522e2aa13c) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Derive `AutocompleteMenu` close-time re-sorting and `LabelGroup` numeric truncation during render instead of in effects, removing redundant render passes. No public API or visual changes.
|
|
21
|
-
|
|
22
|
-
- [#8001](https://github.com/primer/react/pull/8001) [`4e6cf0d`](https://github.com/primer/react/commit/4e6cf0d1715e0371169b291be7a503f2d15f7bc5) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Derive state during render instead of in effects for `useMedia`, `ToggleSwitch`, `SelectPanel`, and the internal validation animation container, removing redundant render passes. Note: `useMedia` now returns the live `matchMedia` value on the first client render; `defaultState` is only used for the SSR/hydration snapshot (no public API changes).
|
|
23
|
-
|
|
24
20
|
- Fake entry to force publishing
|
|
25
21
|
|
|
26
22
|
- [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
|
|
27
23
|
|
|
24
|
+
- [#7904](https://github.com/primer/react/pull/7904) [`9683f3f`](https://github.com/primer/react/commit/9683f3f099ed9fcc46a7ac110cbea07256e339f0) Thanks [@mattcosta7](https://github.com/mattcosta7)! - SelectPanel (experimental v2): replace the `:has(input:placeholder-shown)` selector that hid the clear-action button with a `data-empty` attribute derived from React state. The clear-action visibility no longer triggers a descendant `:has()` re-evaluation on every keystroke.
|
|
25
|
+
|
|
28
26
|
- [#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.
|
|
29
27
|
|
|
30
28
|
## 38.31.0
|
|
@@ -43,7 +43,7 @@ const debounceAnnouncement = debounce((announcement) => {
|
|
|
43
43
|
announce(announcement);
|
|
44
44
|
}, 250);
|
|
45
45
|
function AutocompleteMenu(props) {
|
|
46
|
-
const $ = c(
|
|
46
|
+
const $ = c(78);
|
|
47
47
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
48
48
|
const deferredInputContext = useContext(AutocompleteDeferredInputContext);
|
|
49
49
|
if (autocompleteContext === null || deferredInputContext === null) throw new Error("AutocompleteContext returned null values");
|
|
@@ -253,46 +253,54 @@ function AutocompleteMenu(props) {
|
|
|
253
253
|
t16 = $[54];
|
|
254
254
|
}
|
|
255
255
|
useEffect(t15, t16);
|
|
256
|
-
if (showMenu === false) {
|
|
257
|
-
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
258
|
-
if (!(itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]))) setSortedItemIds(itemIdSortResult);
|
|
259
|
-
}
|
|
260
256
|
let t17;
|
|
261
257
|
let t18;
|
|
262
|
-
if ($[55] !== onOpenChange || $[56] !== showMenu) {
|
|
258
|
+
if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
|
|
263
259
|
t17 = () => {
|
|
260
|
+
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
261
|
+
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
|
|
262
|
+
if (showMenu === false && !sortResultMatchesState) setSortedItemIds(itemIdSortResult);
|
|
264
263
|
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
265
264
|
};
|
|
266
|
-
t18 = [
|
|
265
|
+
t18 = [
|
|
266
|
+
showMenu,
|
|
267
|
+
onOpenChange,
|
|
268
|
+
selectedItemIds,
|
|
269
|
+
sortOnCloseFn,
|
|
270
|
+
sortedItemIds
|
|
271
|
+
];
|
|
267
272
|
$[55] = onOpenChange;
|
|
268
|
-
$[56] =
|
|
269
|
-
$[57] =
|
|
270
|
-
$[58] =
|
|
273
|
+
$[56] = selectedItemIds;
|
|
274
|
+
$[57] = showMenu;
|
|
275
|
+
$[58] = sortOnCloseFn;
|
|
276
|
+
$[59] = sortedItemIds;
|
|
277
|
+
$[60] = t17;
|
|
278
|
+
$[61] = t18;
|
|
271
279
|
} else {
|
|
272
|
-
t17 = $[
|
|
273
|
-
t18 = $[
|
|
280
|
+
t17 = $[60];
|
|
281
|
+
t18 = $[61];
|
|
274
282
|
}
|
|
275
283
|
useEffect(t17, t18);
|
|
276
284
|
let t19;
|
|
277
|
-
if ($[
|
|
285
|
+
if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
|
|
278
286
|
t19 = () => {
|
|
279
287
|
if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
|
|
280
288
|
};
|
|
281
|
-
$[
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
} else t19 = $[
|
|
289
|
+
$[62] = selectedItemIds.length;
|
|
290
|
+
$[63] = setSelectedItemLength;
|
|
291
|
+
$[64] = t19;
|
|
292
|
+
} else t19 = $[64];
|
|
285
293
|
let t20;
|
|
286
|
-
if ($[
|
|
294
|
+
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
287
295
|
t20 = [selectedItemIds, setSelectedItemLength];
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
} else t20 = $[
|
|
296
|
+
$[65] = selectedItemIds;
|
|
297
|
+
$[66] = setSelectedItemLength;
|
|
298
|
+
$[67] = t20;
|
|
299
|
+
} else t20 = $[67];
|
|
292
300
|
useEffect(t19, t20);
|
|
293
301
|
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
294
302
|
let t21;
|
|
295
|
-
if ($[
|
|
303
|
+
if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
|
|
296
304
|
t21 = loading ? /*#__PURE__*/ jsx("div", {
|
|
297
305
|
className: AutocompleteMenu_module_css_default.SpinnerWrapper,
|
|
298
306
|
children: /*#__PURE__*/ jsx(Spinner, {})
|
|
@@ -310,24 +318,24 @@ function AutocompleteMenu(props) {
|
|
|
310
318
|
children: emptyStateText
|
|
311
319
|
}) : null
|
|
312
320
|
});
|
|
313
|
-
$[
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
} else t21 = $[
|
|
321
|
+
$[68] = allItemsToRender;
|
|
322
|
+
$[69] = ariaLabelledBy;
|
|
323
|
+
$[70] = emptyStateText;
|
|
324
|
+
$[71] = id;
|
|
325
|
+
$[72] = loading;
|
|
326
|
+
$[73] = selectionVariant;
|
|
327
|
+
$[74] = t21;
|
|
328
|
+
} else t21 = $[74];
|
|
321
329
|
let t22;
|
|
322
|
-
if ($[
|
|
330
|
+
if ($[75] !== showMenu || $[76] !== t21) {
|
|
323
331
|
t22 = /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
324
332
|
isVisible: showMenu,
|
|
325
333
|
children: t21
|
|
326
334
|
});
|
|
327
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
} else t22 = $[
|
|
335
|
+
$[75] = showMenu;
|
|
336
|
+
$[76] = t21;
|
|
337
|
+
$[77] = t22;
|
|
338
|
+
} else t22 = $[77];
|
|
331
339
|
return t22;
|
|
332
340
|
}
|
|
333
341
|
function _temp5(item_2) {
|
|
@@ -14,16 +14,6 @@ const getOverlayWidth = (buttonClientRect, containerRef, overlayPaddingPx) => {
|
|
|
14
14
|
var _containerRef$current;
|
|
15
15
|
return overlayPaddingPx + buttonClientRect.right - (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().left) || 0);
|
|
16
16
|
};
|
|
17
|
-
const getVisibilityMapAfterIndex = (childCount, truncateAfter) => {
|
|
18
|
-
const updatedEntries = {};
|
|
19
|
-
for (let index = 0; index < childCount; index++) updatedEntries[index.toString()] = index < truncateAfter;
|
|
20
|
-
return updatedEntries;
|
|
21
|
-
};
|
|
22
|
-
const visibilityMapsMatch = (left, right) => {
|
|
23
|
-
const leftKeys = Object.keys(left);
|
|
24
|
-
const rightKeys = Object.keys(right);
|
|
25
|
-
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);
|
|
26
|
-
};
|
|
27
17
|
const InlineToggle = (t0) => {
|
|
28
18
|
const $ = c(7);
|
|
29
19
|
const { collapseButtonRef, collapseInlineExpandedChildren, expandButtonRef, hiddenItemIds, isOverflowShown, showAllTokensInline } = t0;
|
|
@@ -143,7 +133,6 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
143
133
|
bottom: 0,
|
|
144
134
|
toJSON: () => void 0
|
|
145
135
|
});
|
|
146
|
-
const childArray = React.Children.toArray(children);
|
|
147
136
|
const overlayPaddingPx = 8;
|
|
148
137
|
const hiddenItemIds = Object.keys(visibilityMap).filter((key) => !visibilityMap[key]);
|
|
149
138
|
const overlayWidth = hiddenItemIds.length && overflowStyle === "overlay" ? getOverlayWidth(buttonClientRect, containerRef, overlayPaddingPx) : void 0;
|
|
@@ -155,8 +144,15 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
155
144
|
}
|
|
156
145
|
}, [buttonClientRect]);
|
|
157
146
|
const hideChildrenAfterIndex = React.useCallback((truncateAfter) => {
|
|
158
|
-
|
|
159
|
-
|
|
147
|
+
var _containerRef$current2;
|
|
148
|
+
const containerChildren = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children) || [];
|
|
149
|
+
const updatedEntries = {};
|
|
150
|
+
for (const child of containerChildren) {
|
|
151
|
+
const targetId = child.getAttribute("data-index");
|
|
152
|
+
if (targetId) updatedEntries[targetId] = parseInt(targetId, 10) < truncateAfter;
|
|
153
|
+
}
|
|
154
|
+
setVisibilityMap(updatedEntries);
|
|
155
|
+
}, []);
|
|
160
156
|
const openOverflowOverlay = React.useCallback(() => setIsOverflowShown(true), [setIsOverflowShown]);
|
|
161
157
|
const closeOverflowOverlay = React.useCallback(() => {
|
|
162
158
|
setIsOverflowShown(false);
|
|
@@ -177,39 +173,34 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
177
173
|
setVisibilityMap({});
|
|
178
174
|
setIsOverflowShown(true);
|
|
179
175
|
}, [setVisibilityMap, setIsOverflowShown]);
|
|
180
|
-
const numericVisibilityMap = React.useMemo(() => visibleChildCount && typeof visibleChildCount === "number" && !isOverflowShown ? getVisibilityMapAfterIndex(childArray.length, visibleChildCount) : void 0, [
|
|
181
|
-
childArray.length,
|
|
182
|
-
isOverflowShown,
|
|
183
|
-
visibleChildCount
|
|
184
|
-
]);
|
|
185
|
-
if (numericVisibilityMap && !visibilityMapsMatch(visibilityMap, numericVisibilityMap)) setVisibilityMap(numericVisibilityMap);
|
|
186
176
|
React.useEffect(() => {
|
|
187
177
|
if (!visibleChildCount || isOverflowShown) return;
|
|
188
178
|
if (visibleChildCount === "auto") {
|
|
189
179
|
const observer = new IntersectionObserver((entries) => {
|
|
190
|
-
const
|
|
180
|
+
const updatedEntries_0 = {};
|
|
191
181
|
for (const entry of entries) {
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
182
|
+
const targetId_0 = entry.target.getAttribute("data-index");
|
|
183
|
+
if (targetId_0) updatedEntries_0[targetId_0] = entry.isIntersecting;
|
|
194
184
|
}
|
|
195
185
|
setVisibilityMap((prev) => ({
|
|
196
186
|
...prev,
|
|
197
|
-
...
|
|
187
|
+
...updatedEntries_0
|
|
198
188
|
}));
|
|
199
189
|
}, {
|
|
200
190
|
root: containerRef.current,
|
|
201
191
|
rootMargin: `0px -${buttonClientRect.width}px 0px 0px`,
|
|
202
192
|
threshold: 1
|
|
203
193
|
});
|
|
204
|
-
for (const item of ((_containerRef$
|
|
205
|
-
var _containerRef$
|
|
194
|
+
for (const item of ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []) {
|
|
195
|
+
var _containerRef$current3;
|
|
206
196
|
if (item.getAttribute("data-index")) observer.observe(item);
|
|
207
197
|
}
|
|
208
198
|
return () => observer.disconnect();
|
|
209
|
-
}
|
|
199
|
+
} else hideChildrenAfterIndex(visibleChildCount);
|
|
210
200
|
}, [
|
|
211
201
|
buttonClientRect,
|
|
212
202
|
visibleChildCount,
|
|
203
|
+
hideChildrenAfterIndex,
|
|
213
204
|
isOverflowShown
|
|
214
205
|
]);
|
|
215
206
|
React.useEffect(() => {
|
|
@@ -239,10 +230,10 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
239
230
|
"data-list": isList || void 0,
|
|
240
231
|
className: clsx(className, LabelGroup_module_css_default.Container),
|
|
241
232
|
"data-component": "LabelGroup",
|
|
242
|
-
children: [
|
|
233
|
+
children: [React.Children.map(children, (child_0, index) => /*#__PURE__*/ jsx(ItemWrapperComponent, {
|
|
243
234
|
"data-index": index,
|
|
244
235
|
className: clsx(LabelGroup_module_css_default.ItemWrapper, { [LabelGroup_module_css_default["ItemWrapper--hidden"]]: hiddenItemIds.includes(index.toString()) }),
|
|
245
|
-
children:
|
|
236
|
+
children: child_0
|
|
246
237
|
}, index)), /*#__PURE__*/ jsx(ToggleWrapper, {
|
|
247
238
|
"data-component": "LabelGroup.Toggle",
|
|
248
239
|
children: overflowStyle === "inline" ? /*#__PURE__*/ jsx(InlineToggle, {
|
|
@@ -252,7 +243,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
252
243
|
hiddenItemIds,
|
|
253
244
|
isOverflowShown,
|
|
254
245
|
showAllTokensInline,
|
|
255
|
-
totalLength:
|
|
246
|
+
totalLength: React.Children.toArray(children).length
|
|
256
247
|
}) : /*#__PURE__*/ jsx(OverlayToggle, {
|
|
257
248
|
closeOverflowOverlay,
|
|
258
249
|
expandButtonRef,
|
|
@@ -261,7 +252,7 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
261
252
|
openOverflowOverlay,
|
|
262
253
|
overlayPaddingPx,
|
|
263
254
|
overlayWidth,
|
|
264
|
-
totalLength:
|
|
255
|
+
totalLength: React.Children.toArray(children).length,
|
|
265
256
|
children
|
|
266
257
|
})
|
|
267
258
|
})]
|
|
@@ -270,8 +261,8 @@ const LabelGroup = ({ children, visibleChildCount, overflowStyle = "overlay", as
|
|
|
270
261
|
"data-list": isList || void 0,
|
|
271
262
|
className: clsx(className, LabelGroup_module_css_default.Container),
|
|
272
263
|
"data-component": "LabelGroup",
|
|
273
|
-
children: isList ? React.Children.map(children, (
|
|
274
|
-
return /*#__PURE__*/ jsx("li", { children:
|
|
264
|
+
children: isList ? React.Children.map(children, (child_1, index_0) => {
|
|
265
|
+
return /*#__PURE__*/ jsx("li", { children: child_1 }, index_0);
|
|
275
266
|
}) : children
|
|
276
267
|
});
|
|
277
268
|
};
|
|
@@ -99,11 +99,13 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
|
|
|
99
99
|
const selectedValueId = id ? `${id}-selected-value` : void 0;
|
|
100
100
|
const isSingleSelectModal = variant === "modal" && !isMultiSelectVariant(selected);
|
|
101
101
|
const [intermediateSelected, setIntermediateSelected] = useState(isSingleSelectModal ? selected : void 0);
|
|
102
|
-
|
|
103
|
-
if (prevOpen !== open) {
|
|
104
|
-
setPrevOpen(open);
|
|
102
|
+
useEffect(() => {
|
|
105
103
|
setIntermediateSelected(isSingleSelectModal ? selected : void 0);
|
|
106
|
-
}
|
|
104
|
+
}, [
|
|
105
|
+
isSingleSelectModal,
|
|
106
|
+
open,
|
|
107
|
+
selected
|
|
108
|
+
]);
|
|
107
109
|
const onListContainerRefChanged = useCallback((node) => {
|
|
108
110
|
setListContainerElement(node);
|
|
109
111
|
if (!node && needsNoItemsAnnouncement) setNeedsNoItemsAnnouncement(false);
|
|
@@ -179,12 +179,12 @@ const ToggleSwitch = /*#__PURE__*/ React.forwardRef(function ToggleSwitch(props,
|
|
|
179
179
|
t7 = $[30];
|
|
180
180
|
}
|
|
181
181
|
useEffect(t6, t7);
|
|
182
|
-
if (!loading && isLoadingLabelVisible) setIsLoadingLabelVisible(false);
|
|
183
182
|
let t8;
|
|
184
183
|
let t9;
|
|
185
184
|
if ($[31] !== isLoadingLabelVisible || $[32] !== loading || $[33] !== loadingLabelDelay || $[34] !== safeSetTimeout) {
|
|
186
185
|
t8 = () => {
|
|
187
|
-
if (loading &&
|
|
186
|
+
if (!loading && isLoadingLabelVisible) setIsLoadingLabelVisible(false);
|
|
187
|
+
else if (loading && !isLoadingLabelVisible) safeSetTimeout(() => {
|
|
188
188
|
setIsLoadingLabelVisible(true);
|
|
189
189
|
}, loadingLabelDelay);
|
|
190
190
|
};
|
|
@@ -276,9 +276,15 @@ SelectPanelHeader.__SLOT__ = Symbol("SelectPanel.Header");
|
|
|
276
276
|
const SelectPanelSearchInput = ({ onChange: propsOnChange, onKeyDown: propsOnKeyDown, className, ...props }) => {
|
|
277
277
|
const inputRef = /*#__PURE__*/ React.createRef();
|
|
278
278
|
const { setSearchQuery, moveFocusToList } = React.useContext(SelectPanelContext);
|
|
279
|
+
const [uncontrolledEmpty, setUncontrolledEmpty] = React.useState(() => {
|
|
280
|
+
var _ref, _props$value;
|
|
281
|
+
return ((_ref = (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : props.defaultValue) !== null && _ref !== void 0 ? _ref : "") === "";
|
|
282
|
+
});
|
|
283
|
+
const isEmpty = props.value !== void 0 ? props.value === "" : uncontrolledEmpty;
|
|
279
284
|
const internalOnChange = (event) => {
|
|
280
285
|
if (typeof propsOnChange === "function") propsOnChange(event);
|
|
281
286
|
else setSearchQuery(event.target.value);
|
|
287
|
+
setUncontrolledEmpty(event.target.value === "");
|
|
282
288
|
};
|
|
283
289
|
const internalKeyDown = (event) => {
|
|
284
290
|
if (event.key === "ArrowDown") {
|
|
@@ -303,12 +309,14 @@ const SelectPanelSearchInput = ({ onChange: propsOnChange, onKeyDown: propsOnKey
|
|
|
303
309
|
target: inputRef.current,
|
|
304
310
|
currentTarget: inputRef.current
|
|
305
311
|
});
|
|
312
|
+
setUncontrolledEmpty(true);
|
|
306
313
|
}
|
|
307
314
|
}),
|
|
308
315
|
className: clsx(SelectPanel_module_css_default.TextInput, className),
|
|
309
316
|
onChange: internalOnChange,
|
|
310
317
|
onKeyDown: internalKeyDown,
|
|
311
|
-
...props
|
|
318
|
+
...props,
|
|
319
|
+
"data-empty": isEmpty || void 0
|
|
312
320
|
});
|
|
313
321
|
};
|
|
314
322
|
SelectPanelSearchInput.displayName = "SelectPanelSearchInput";
|
package/dist/hooks/useMedia.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { canUseDOM } from "../utils/environment.js";
|
|
1
2
|
import { warning } from "../utils/warning.js";
|
|
2
3
|
import { MatchMediaContext } from "./MatchMediaContext.js";
|
|
3
4
|
import { c } from "react-compiler-runtime";
|
|
4
|
-
import { useContext,
|
|
5
|
+
import React, { useContext, useEffect } from "react";
|
|
5
6
|
//#region src/hooks/useMedia.ts
|
|
6
7
|
/**
|
|
7
8
|
* `useMedia` will use the given `mediaQueryString` with `matchMedia` to
|
|
@@ -17,54 +18,52 @@ import { useContext, useSyncExternalStore } from "react";
|
|
|
17
18
|
* }
|
|
18
19
|
*/
|
|
19
20
|
function useMedia(mediaQueryString, defaultState) {
|
|
20
|
-
const $ = c(
|
|
21
|
-
const
|
|
21
|
+
const $ = c(8);
|
|
22
|
+
const features = useContext(MatchMediaContext);
|
|
22
23
|
let t0;
|
|
23
|
-
if ($[0] !==
|
|
24
|
-
t0 = (
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mediaQueryList.removeEventListener("change", onStoreChange);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
mediaQueryList.addListener(onStoreChange);
|
|
34
|
-
return () => {
|
|
35
|
-
mediaQueryList.removeListener(onStoreChange);
|
|
36
|
-
};
|
|
24
|
+
if ($[0] !== defaultState || $[1] !== features || $[2] !== mediaQueryString) {
|
|
25
|
+
t0 = () => {
|
|
26
|
+
if (features[mediaQueryString] !== void 0) return features[mediaQueryString];
|
|
27
|
+
if (defaultState !== void 0) return defaultState;
|
|
28
|
+
if (canUseDOM) return window.matchMedia(mediaQueryString).matches;
|
|
29
|
+
warning(true, "`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
|
|
30
|
+
return false;
|
|
37
31
|
};
|
|
38
|
-
$[0] =
|
|
39
|
-
$[1] =
|
|
40
|
-
$[2] =
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
$[0] = defaultState;
|
|
33
|
+
$[1] = features;
|
|
34
|
+
$[2] = mediaQueryString;
|
|
35
|
+
$[3] = t0;
|
|
36
|
+
} else t0 = $[3];
|
|
37
|
+
const [matches, setMatches] = React.useState(t0);
|
|
38
|
+
if (features[mediaQueryString] !== void 0 && matches !== features[mediaQueryString]) setMatches(features[mediaQueryString]);
|
|
43
39
|
let t1;
|
|
44
|
-
if ($[3] !== contextValue || $[4] !== mediaQueryString) {
|
|
45
|
-
t1 = () => {
|
|
46
|
-
if (contextValue !== void 0) return contextValue;
|
|
47
|
-
return window.matchMedia(mediaQueryString).matches;
|
|
48
|
-
};
|
|
49
|
-
$[3] = contextValue;
|
|
50
|
-
$[4] = mediaQueryString;
|
|
51
|
-
$[5] = t1;
|
|
52
|
-
} else t1 = $[5];
|
|
53
|
-
const getSnapshot = t1;
|
|
54
40
|
let t2;
|
|
55
|
-
if ($[
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
if ($[4] !== features || $[5] !== mediaQueryString) {
|
|
42
|
+
t1 = () => {
|
|
43
|
+
if (features[mediaQueryString] !== void 0) return;
|
|
44
|
+
const listener = function listener(event) {
|
|
45
|
+
setMatches(event.matches);
|
|
46
|
+
};
|
|
47
|
+
const mediaQueryList = window.matchMedia(mediaQueryString);
|
|
48
|
+
if (mediaQueryList.addEventListener) mediaQueryList.addEventListener("change", listener);
|
|
49
|
+
else mediaQueryList.addListener(listener);
|
|
50
|
+
setMatches(mediaQueryList.matches);
|
|
51
|
+
return () => {
|
|
52
|
+
if (mediaQueryList.addEventListener) mediaQueryList.removeEventListener("change", listener);
|
|
53
|
+
else mediaQueryList.removeListener(listener);
|
|
54
|
+
};
|
|
61
55
|
};
|
|
62
|
-
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
t2 = [features, mediaQueryString];
|
|
57
|
+
$[4] = features;
|
|
58
|
+
$[5] = mediaQueryString;
|
|
59
|
+
$[6] = t1;
|
|
60
|
+
$[7] = t2;
|
|
61
|
+
} else {
|
|
62
|
+
t1 = $[6];
|
|
63
|
+
t2 = $[7];
|
|
64
|
+
}
|
|
65
|
+
useEffect(t1, t2);
|
|
66
|
+
return matches;
|
|
67
67
|
}
|
|
68
|
-
function _temp() {}
|
|
69
68
|
//#endregion
|
|
70
69
|
export { useMedia };
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
import ValidationAnimationContainer_module_css_default from "./ValidationAnimationContainer.module.css.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
//#region src/internal/components/ValidationAnimationContainer.tsx
|
|
6
6
|
const ValidationAnimationContainer = (t0) => {
|
|
7
|
-
const $ = c(
|
|
7
|
+
const $ = c(10);
|
|
8
8
|
const { show, children } = t0;
|
|
9
9
|
const [shouldRender, setRender] = useState(show);
|
|
10
|
-
if (show && !shouldRender) setRender(true);
|
|
11
10
|
let t1;
|
|
11
|
+
let t2;
|
|
12
12
|
if ($[0] !== show) {
|
|
13
13
|
t1 = () => {
|
|
14
|
-
if (
|
|
14
|
+
if (show) setRender(true);
|
|
15
15
|
};
|
|
16
|
+
t2 = [show];
|
|
16
17
|
$[0] = show;
|
|
17
18
|
$[1] = t1;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
$[2] = t2;
|
|
20
|
+
} else {
|
|
21
|
+
t1 = $[1];
|
|
22
|
+
t2 = $[2];
|
|
23
|
+
}
|
|
24
|
+
useEffect(t1, t2);
|
|
25
|
+
let t3;
|
|
26
|
+
if ($[3] !== show) {
|
|
27
|
+
t3 = () => {
|
|
28
|
+
if (!show) setRender(false);
|
|
29
|
+
};
|
|
30
|
+
$[3] = show;
|
|
31
|
+
$[4] = t3;
|
|
32
|
+
} else t3 = $[4];
|
|
33
|
+
const onAnimationEnd = t3;
|
|
34
|
+
let t4;
|
|
35
|
+
if ($[5] !== children || $[6] !== onAnimationEnd || $[7] !== shouldRender || $[8] !== show) {
|
|
36
|
+
t4 = shouldRender ? /*#__PURE__*/ jsx("div", {
|
|
23
37
|
style: {
|
|
24
38
|
height: show ? "auto" : 0,
|
|
25
39
|
overflow: "hidden"
|
|
@@ -31,13 +45,13 @@ const ValidationAnimationContainer = (t0) => {
|
|
|
31
45
|
children
|
|
32
46
|
})
|
|
33
47
|
}) : null;
|
|
34
|
-
$[
|
|
35
|
-
$[
|
|
36
|
-
$[
|
|
37
|
-
$[
|
|
38
|
-
$[
|
|
39
|
-
} else
|
|
40
|
-
return
|
|
48
|
+
$[5] = children;
|
|
49
|
+
$[6] = onAnimationEnd;
|
|
50
|
+
$[7] = shouldRender;
|
|
51
|
+
$[8] = show;
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
} else t4 = $[9];
|
|
54
|
+
return t4;
|
|
41
55
|
};
|
|
42
56
|
//#endregion
|
|
43
57
|
export { ValidationAnimationContainer as default };
|
package/package.json
CHANGED