@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 +8 -0
- package/dist/ActionBar/ActionBar.js +93 -98
- package/dist/Autocomplete/Autocomplete.js +131 -74
- package/dist/Autocomplete/AutocompleteMenu.js +277 -119
- package/dist/Autocomplete/AutocompleteOverlay.js +113 -38
- package/dist/Banner/Banner.js +414 -96
- package/dist/Button/Button.js +29 -8
- package/dist/Button/IconButton.js +120 -28
- package/dist/Button/LinkButton.js +34 -8
- package/dist/ConfirmationDialog/ConfirmationDialog.js +86 -24
- package/dist/PageLayout/PageLayout.js +1274 -478
- package/dist/Pagination/Pagination.js +196 -70
- package/dist/SelectPanel/SelectPanelMessage.js +72 -29
- package/dist/UnderlineNav/UnderlineNav.js +214 -63
- package/dist/UnderlineNav/UnderlineNavItem.js +94 -22
- package/dist/hooks/useMergedRefs.js +20 -11
- package/dist/hooks/useScrollFlash.js +24 -10
- 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
|
@@ -5,8 +5,9 @@ import { useFocusZone } from "../hooks/useFocusZone.js";
|
|
|
5
5
|
import { ActionList } from "../ActionList/index.js";
|
|
6
6
|
import { AutocompleteContext, AutocompleteDeferredInputContext } from "./AutocompleteContext.js";
|
|
7
7
|
import AutocompleteMenu_module_css_default from "./AutocompleteMenu.module.css.js";
|
|
8
|
+
import { c } from "react-compiler-runtime";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import React, { useContext, useEffect,
|
|
10
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
10
11
|
import { scrollIntoView } from "@primer/behaviors";
|
|
11
12
|
import { announce } from "@primer/live-region-element";
|
|
12
13
|
import { isElement } from "react-is";
|
|
@@ -42,19 +43,34 @@ const debounceAnnouncement = debounce((announcement) => {
|
|
|
42
43
|
announce(announcement);
|
|
43
44
|
}, 250);
|
|
44
45
|
function AutocompleteMenu(props) {
|
|
46
|
+
const $ = c(78);
|
|
45
47
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
46
48
|
const deferredInputContext = useContext(AutocompleteDeferredInputContext);
|
|
47
49
|
if (autocompleteContext === null || deferredInputContext === null) throw new Error("AutocompleteContext returned null values");
|
|
48
50
|
const { activeDescendantRef, id, inputRef, scrollContainerRef, setAutocompleteSuggestion, setShowMenu, setInputValue, setIsMenuDirectlyActivated, setSelectedItemLength, showMenu } = autocompleteContext;
|
|
49
51
|
const { deferredInputValue } = deferredInputContext;
|
|
50
|
-
const { items, selectedItemIds, sortOnCloseFn, emptyStateText
|
|
52
|
+
const { items, selectedItemIds, sortOnCloseFn, emptyStateText: t0, addNewItem, loading, selectionVariant: t1, filterFn, "aria-labelledby": ariaLabelledBy, onOpenChange, onSelectedChange, customScrollContainerRef } = props;
|
|
53
|
+
const emptyStateText = t0 === void 0 ? "No selectable options" : t0;
|
|
54
|
+
const selectionVariant = t1 === void 0 ? "single" : t1;
|
|
51
55
|
const listContainerRef = useRef(null);
|
|
52
|
-
|
|
56
|
+
let t2;
|
|
57
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
58
|
+
t2 = [];
|
|
59
|
+
$[0] = t2;
|
|
60
|
+
} else t2 = $[0];
|
|
61
|
+
const allItemsToRenderRef = useRef(t2);
|
|
53
62
|
const [highlightedItem, setHighlightedItem] = useState();
|
|
54
|
-
|
|
63
|
+
let t3;
|
|
64
|
+
if ($[1] !== items) {
|
|
65
|
+
t3 = items.map(_temp);
|
|
66
|
+
$[1] = items;
|
|
67
|
+
$[2] = t3;
|
|
68
|
+
} else t3 = $[2];
|
|
69
|
+
const [sortedItemIds, setSortedItemIds] = useState(t3);
|
|
55
70
|
const generatedUniqueId = useId$1(id);
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[3] !== (highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) || $[4] !== inputRef || $[5] !== items || $[6] !== onSelectedChange || $[7] !== selectedItemIds || $[8] !== selectionVariant || $[9] !== setAutocompleteSuggestion || $[10] !== setInputValue || $[11] !== setShowMenu) {
|
|
73
|
+
t4 = items.map((selectableItem) => ({
|
|
58
74
|
...selectableItem,
|
|
59
75
|
role: "option",
|
|
60
76
|
id: selectableItem.id,
|
|
@@ -73,111 +89,219 @@ function AutocompleteMenu(props) {
|
|
|
73
89
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.setSelectionRange(inputRef.current.value.length, inputRef.current.value.length);
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
items
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
]
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
])
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
}));
|
|
93
|
+
$[3] = highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id;
|
|
94
|
+
$[4] = inputRef;
|
|
95
|
+
$[5] = items;
|
|
96
|
+
$[6] = onSelectedChange;
|
|
97
|
+
$[7] = selectedItemIds;
|
|
98
|
+
$[8] = selectionVariant;
|
|
99
|
+
$[9] = setAutocompleteSuggestion;
|
|
100
|
+
$[10] = setInputValue;
|
|
101
|
+
$[11] = setShowMenu;
|
|
102
|
+
$[12] = t4;
|
|
103
|
+
} else t4 = $[12];
|
|
104
|
+
const selectableItems = t4;
|
|
105
|
+
let t5;
|
|
106
|
+
if ($[13] !== sortedItemIds) {
|
|
107
|
+
t5 = sortedItemIds.reduce(_temp2, {});
|
|
108
|
+
$[13] = sortedItemIds;
|
|
109
|
+
$[14] = t5;
|
|
110
|
+
} else t5 = $[14];
|
|
111
|
+
const itemSortOrderData = t5;
|
|
112
|
+
let t6;
|
|
113
|
+
if ($[15] !== deferredInputValue || $[16] !== filterFn || $[17] !== itemSortOrderData || $[18] !== selectableItems) {
|
|
114
|
+
let t7;
|
|
115
|
+
if ($[20] !== itemSortOrderData) {
|
|
116
|
+
t7 = (a, b) => itemSortOrderData[a.id] - itemSortOrderData[b.id];
|
|
117
|
+
$[20] = itemSortOrderData;
|
|
118
|
+
$[21] = t7;
|
|
119
|
+
} else t7 = $[21];
|
|
120
|
+
t6 = selectableItems.filter(filterFn ? filterFn : getDefaultItemFilter(deferredInputValue)).sort(t7);
|
|
121
|
+
$[15] = deferredInputValue;
|
|
122
|
+
$[16] = filterFn;
|
|
123
|
+
$[17] = itemSortOrderData;
|
|
124
|
+
$[18] = selectableItems;
|
|
125
|
+
$[19] = t6;
|
|
126
|
+
} else t6 = $[19];
|
|
127
|
+
const sortedAndFilteredItemsToRender = t6;
|
|
128
|
+
let t7;
|
|
129
|
+
if ($[22] !== addNewItem || $[23] !== generatedUniqueId || $[24] !== (highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) || $[25] !== selectedItemIds || $[26] !== selectionVariant || $[27] !== setAutocompleteSuggestion || $[28] !== setInputValue) {
|
|
130
|
+
t7 = addNewItem ? [{
|
|
131
|
+
...addNewItem,
|
|
132
|
+
role: "option",
|
|
133
|
+
key: addNewItem.id,
|
|
134
|
+
active: (highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) === addNewItem.id,
|
|
135
|
+
selected: selectionVariant === "multiple" ? selectedItemIds.includes(addNewItem.id) : void 0,
|
|
136
|
+
leadingVisual: _temp3,
|
|
137
|
+
onAction: (item_0) => {
|
|
138
|
+
addNewItem.handleAddItem({
|
|
139
|
+
...item_0,
|
|
140
|
+
id: item_0.id || generatedUniqueId,
|
|
141
|
+
leadingVisual: void 0
|
|
142
|
+
});
|
|
143
|
+
if (selectionVariant === "multiple") {
|
|
144
|
+
setInputValue("");
|
|
145
|
+
setAutocompleteSuggestion("");
|
|
146
|
+
}
|
|
114
147
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
selectionVariant
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
}] : [];
|
|
149
|
+
$[22] = addNewItem;
|
|
150
|
+
$[23] = generatedUniqueId;
|
|
151
|
+
$[24] = highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id;
|
|
152
|
+
$[25] = selectedItemIds;
|
|
153
|
+
$[26] = selectionVariant;
|
|
154
|
+
$[27] = setAutocompleteSuggestion;
|
|
155
|
+
$[28] = setInputValue;
|
|
156
|
+
$[29] = t7;
|
|
157
|
+
} else t7 = $[29];
|
|
158
|
+
let t8;
|
|
159
|
+
if ($[30] !== sortedAndFilteredItemsToRender || $[31] !== t7) {
|
|
160
|
+
t8 = [...sortedAndFilteredItemsToRender, ...t7];
|
|
161
|
+
$[30] = sortedAndFilteredItemsToRender;
|
|
162
|
+
$[31] = t7;
|
|
163
|
+
$[32] = t8;
|
|
164
|
+
} else t8 = $[32];
|
|
165
|
+
const allItemsToRender = t8;
|
|
166
|
+
let t9;
|
|
167
|
+
if ($[33] !== allItemsToRender) {
|
|
168
|
+
t9 = () => {
|
|
169
|
+
allItemsToRenderRef.current = allItemsToRender;
|
|
170
|
+
};
|
|
171
|
+
$[33] = allItemsToRender;
|
|
172
|
+
$[34] = t9;
|
|
173
|
+
} else t9 = $[34];
|
|
174
|
+
React.useEffect(t9);
|
|
175
|
+
let t10;
|
|
176
|
+
let t11;
|
|
177
|
+
if ($[35] !== allItemsToRender || $[36] !== emptyStateText) {
|
|
178
|
+
t10 = () => {
|
|
179
|
+
if (allItemsToRender.length === 0) debounceAnnouncement(emptyStateText);
|
|
180
|
+
};
|
|
181
|
+
t11 = [allItemsToRender, emptyStateText];
|
|
182
|
+
$[35] = allItemsToRender;
|
|
183
|
+
$[36] = emptyStateText;
|
|
184
|
+
$[37] = t10;
|
|
185
|
+
$[38] = t11;
|
|
186
|
+
} else {
|
|
187
|
+
t10 = $[37];
|
|
188
|
+
t11 = $[38];
|
|
189
|
+
}
|
|
190
|
+
React.useEffect(t10, t11);
|
|
191
|
+
let t12;
|
|
192
|
+
if ($[39] !== activeDescendantRef || $[40] !== customScrollContainerRef || $[41] !== scrollContainerRef || $[42] !== setIsMenuDirectlyActivated) {
|
|
193
|
+
t12 = (current, _previous, directlyActivated) => {
|
|
140
194
|
activeDescendantRef.current = current || null;
|
|
141
195
|
if (current) {
|
|
142
|
-
setHighlightedItem(allItemsToRenderRef.current.find((
|
|
196
|
+
setHighlightedItem(allItemsToRenderRef.current.find((item_1) => {
|
|
143
197
|
var _current$closest;
|
|
144
|
-
return
|
|
198
|
+
return item_1.id === ((_current$closest = current.closest("li")) === null || _current$closest === void 0 ? void 0 : _current$closest.getAttribute("data-id"));
|
|
145
199
|
}));
|
|
146
200
|
setIsMenuDirectlyActivated(directlyActivated);
|
|
147
201
|
}
|
|
148
202
|
if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) scrollIntoView(current, customScrollContainerRef.current, menuScrollMargins);
|
|
149
203
|
else if (current && scrollContainerRef.current && directlyActivated) scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
204
|
+
};
|
|
205
|
+
$[39] = activeDescendantRef;
|
|
206
|
+
$[40] = customScrollContainerRef;
|
|
207
|
+
$[41] = scrollContainerRef;
|
|
208
|
+
$[42] = setIsMenuDirectlyActivated;
|
|
209
|
+
$[43] = t12;
|
|
210
|
+
} else t12 = $[43];
|
|
211
|
+
let t13;
|
|
212
|
+
if ($[44] !== inputRef || $[45] !== t12) {
|
|
213
|
+
t13 = {
|
|
214
|
+
containerRef: listContainerRef,
|
|
215
|
+
focusOutBehavior: "wrap",
|
|
216
|
+
focusableElementFilter: _temp4,
|
|
217
|
+
activeDescendantFocus: inputRef,
|
|
218
|
+
onActiveDescendantChanged: t12
|
|
219
|
+
};
|
|
220
|
+
$[44] = inputRef;
|
|
221
|
+
$[45] = t12;
|
|
222
|
+
$[46] = t13;
|
|
223
|
+
} else t13 = $[46];
|
|
224
|
+
let t14;
|
|
225
|
+
if ($[47] !== loading) {
|
|
226
|
+
t14 = [loading];
|
|
227
|
+
$[47] = loading;
|
|
228
|
+
$[48] = t14;
|
|
229
|
+
} else t14 = $[48];
|
|
230
|
+
useFocusZone(t13, t14);
|
|
231
|
+
let t15;
|
|
232
|
+
let t16;
|
|
233
|
+
if ($[49] !== deferredInputValue || $[50] !== highlightedItem || $[51] !== selectedItemIds || $[52] !== setAutocompleteSuggestion) {
|
|
234
|
+
t15 = () => {
|
|
235
|
+
var _highlightedItem$text;
|
|
236
|
+
if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(deferredInputValue) && !selectedItemIds.includes(highlightedItem.id)) setAutocompleteSuggestion(highlightedItem.text);
|
|
237
|
+
else setAutocompleteSuggestion("");
|
|
238
|
+
};
|
|
239
|
+
t16 = [
|
|
240
|
+
highlightedItem,
|
|
241
|
+
deferredInputValue,
|
|
242
|
+
selectedItemIds,
|
|
243
|
+
setAutocompleteSuggestion
|
|
244
|
+
];
|
|
245
|
+
$[49] = deferredInputValue;
|
|
246
|
+
$[50] = highlightedItem;
|
|
247
|
+
$[51] = selectedItemIds;
|
|
248
|
+
$[52] = setAutocompleteSuggestion;
|
|
249
|
+
$[53] = t15;
|
|
250
|
+
$[54] = t16;
|
|
251
|
+
} else {
|
|
252
|
+
t15 = $[53];
|
|
253
|
+
t16 = $[54];
|
|
254
|
+
}
|
|
255
|
+
useEffect(t15, t16);
|
|
256
|
+
let t17;
|
|
257
|
+
let t18;
|
|
258
|
+
if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
|
|
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);
|
|
263
|
+
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
264
|
+
};
|
|
265
|
+
t18 = [
|
|
266
|
+
showMenu,
|
|
267
|
+
onOpenChange,
|
|
268
|
+
selectedItemIds,
|
|
269
|
+
sortOnCloseFn,
|
|
270
|
+
sortedItemIds
|
|
271
|
+
];
|
|
272
|
+
$[55] = onOpenChange;
|
|
273
|
+
$[56] = selectedItemIds;
|
|
274
|
+
$[57] = showMenu;
|
|
275
|
+
$[58] = sortOnCloseFn;
|
|
276
|
+
$[59] = sortedItemIds;
|
|
277
|
+
$[60] = t17;
|
|
278
|
+
$[61] = t18;
|
|
279
|
+
} else {
|
|
280
|
+
t17 = $[60];
|
|
281
|
+
t18 = $[61];
|
|
282
|
+
}
|
|
283
|
+
useEffect(t17, t18);
|
|
284
|
+
let t19;
|
|
285
|
+
if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
|
|
286
|
+
t19 = () => {
|
|
287
|
+
if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
|
|
288
|
+
};
|
|
289
|
+
$[62] = selectedItemIds.length;
|
|
290
|
+
$[63] = setSelectedItemLength;
|
|
291
|
+
$[64] = t19;
|
|
292
|
+
} else t19 = $[64];
|
|
293
|
+
let t20;
|
|
294
|
+
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
295
|
+
t20 = [selectedItemIds, setSelectedItemLength];
|
|
296
|
+
$[65] = selectedItemIds;
|
|
297
|
+
$[66] = setSelectedItemLength;
|
|
298
|
+
$[67] = t20;
|
|
299
|
+
} else t20 = $[67];
|
|
300
|
+
useEffect(t19, t20);
|
|
177
301
|
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
302
|
+
let t21;
|
|
303
|
+
if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
|
|
304
|
+
t21 = loading ? /*#__PURE__*/ jsx("div", {
|
|
181
305
|
className: AutocompleteMenu_module_css_default.SpinnerWrapper,
|
|
182
306
|
children: /*#__PURE__*/ jsx(Spinner, {})
|
|
183
307
|
}) : /*#__PURE__*/ jsx("div", {
|
|
@@ -188,29 +312,63 @@ function AutocompleteMenu(props) {
|
|
|
188
312
|
role: "listbox",
|
|
189
313
|
id: `${id}-listbox`,
|
|
190
314
|
"aria-labelledby": ariaLabelledBy,
|
|
191
|
-
children: allItemsToRender.map(
|
|
192
|
-
const { id, onAction, children, text, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, key, role, ...itemProps } = item;
|
|
193
|
-
return /*#__PURE__*/ jsxs(ActionList.Item, {
|
|
194
|
-
onSelect: () => onAction(item),
|
|
195
|
-
...itemProps,
|
|
196
|
-
id,
|
|
197
|
-
"data-id": id,
|
|
198
|
-
role,
|
|
199
|
-
children: [
|
|
200
|
-
LeadingVisual && /*#__PURE__*/ jsx(ActionList.LeadingVisual, { children: isElement(LeadingVisual) ? LeadingVisual : /*#__PURE__*/ jsx(LeadingVisual, {}) }),
|
|
201
|
-
children !== null && children !== void 0 ? children : text,
|
|
202
|
-
TrailingVisual && /*#__PURE__*/ jsx(ActionList.TrailingVisual, { children: isElement(TrailingVisual) ? TrailingVisual : /*#__PURE__*/ jsx(TrailingVisual, {}) })
|
|
203
|
-
]
|
|
204
|
-
}, key !== null && key !== void 0 ? key : id);
|
|
205
|
-
})
|
|
315
|
+
children: allItemsToRender.map(_temp5)
|
|
206
316
|
}) : emptyStateText !== false && emptyStateText !== null ? /*#__PURE__*/ jsx("div", {
|
|
207
317
|
className: AutocompleteMenu_module_css_default.EmptyStateWrapper,
|
|
208
318
|
children: emptyStateText
|
|
209
319
|
}) : null
|
|
210
|
-
})
|
|
211
|
-
|
|
320
|
+
});
|
|
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];
|
|
329
|
+
let t22;
|
|
330
|
+
if ($[75] !== showMenu || $[76] !== t21) {
|
|
331
|
+
t22 = /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
332
|
+
isVisible: showMenu,
|
|
333
|
+
children: t21
|
|
334
|
+
});
|
|
335
|
+
$[75] = showMenu;
|
|
336
|
+
$[76] = t21;
|
|
337
|
+
$[77] = t22;
|
|
338
|
+
} else t22 = $[77];
|
|
339
|
+
return t22;
|
|
340
|
+
}
|
|
341
|
+
function _temp5(item_2) {
|
|
342
|
+
const { id: id_0, onAction, children, text, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, key, role, ...itemProps } = item_2;
|
|
343
|
+
return /*#__PURE__*/ jsxs(ActionList.Item, {
|
|
344
|
+
onSelect: () => onAction(item_2),
|
|
345
|
+
...itemProps,
|
|
346
|
+
id: id_0,
|
|
347
|
+
"data-id": id_0,
|
|
348
|
+
role,
|
|
349
|
+
children: [
|
|
350
|
+
LeadingVisual && /*#__PURE__*/ jsx(ActionList.LeadingVisual, { children: isElement(LeadingVisual) ? LeadingVisual : /*#__PURE__*/ jsx(LeadingVisual, {}) }),
|
|
351
|
+
children !== null && children !== void 0 ? children : text,
|
|
352
|
+
TrailingVisual && /*#__PURE__*/ jsx(ActionList.TrailingVisual, { children: isElement(TrailingVisual) ? TrailingVisual : /*#__PURE__*/ jsx(TrailingVisual, {}) })
|
|
353
|
+
]
|
|
354
|
+
}, key !== null && key !== void 0 ? key : id_0);
|
|
355
|
+
}
|
|
356
|
+
_temp5.displayName = "_temp5";
|
|
357
|
+
function _temp4(element) {
|
|
358
|
+
return !(element instanceof HTMLInputElement);
|
|
359
|
+
}
|
|
360
|
+
function _temp3() {
|
|
361
|
+
return /*#__PURE__*/ jsx(PlusIcon, {});
|
|
362
|
+
}
|
|
363
|
+
_temp3.displayName = "_temp3";
|
|
364
|
+
function _temp2(acc, curr, i) {
|
|
365
|
+
acc[curr] = i;
|
|
366
|
+
return acc;
|
|
367
|
+
}
|
|
368
|
+
function _temp(t0) {
|
|
369
|
+
const { id: itemId } = t0;
|
|
370
|
+
return itemId;
|
|
212
371
|
}
|
|
213
|
-
AutocompleteMenu.displayName = "AutocompleteMenu";
|
|
214
372
|
AutocompleteMenu.displayName = "AutocompleteMenu";
|
|
215
373
|
AutocompleteMenu.__SLOT__ = Symbol("Autocomplete.Menu");
|
|
216
374
|
//#endregion
|
|
@@ -4,52 +4,127 @@ import VisuallyHidden from "../_VisuallyHidden.js";
|
|
|
4
4
|
import Overlay from "../Overlay/Overlay.js";
|
|
5
5
|
import { AutocompleteContext } from "./AutocompleteContext.js";
|
|
6
6
|
import AutocompleteOverlay_module_css_default from "./AutocompleteOverlay.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
|
-
import {
|
|
10
|
+
import { useContext, useEffect, useRef } from "react";
|
|
10
11
|
//#region src/Autocomplete/AutocompleteOverlay.tsx
|
|
11
|
-
function AutocompleteOverlay(
|
|
12
|
+
function AutocompleteOverlay(t0) {
|
|
13
|
+
const $ = c(29);
|
|
14
|
+
let children;
|
|
15
|
+
let className;
|
|
16
|
+
let menuAnchorRef;
|
|
17
|
+
let newOverlayProps;
|
|
18
|
+
let oldOverlayProps;
|
|
19
|
+
if ($[0] !== t0) {
|
|
20
|
+
({menuAnchorRef, overlayProps: oldOverlayProps, children, className, ...newOverlayProps} = t0);
|
|
21
|
+
$[0] = t0;
|
|
22
|
+
$[1] = children;
|
|
23
|
+
$[2] = className;
|
|
24
|
+
$[3] = menuAnchorRef;
|
|
25
|
+
$[4] = newOverlayProps;
|
|
26
|
+
$[5] = oldOverlayProps;
|
|
27
|
+
} else {
|
|
28
|
+
children = $[1];
|
|
29
|
+
className = $[2];
|
|
30
|
+
menuAnchorRef = $[3];
|
|
31
|
+
newOverlayProps = $[4];
|
|
32
|
+
oldOverlayProps = $[5];
|
|
33
|
+
}
|
|
12
34
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
13
35
|
if (autocompleteContext === null) throw new Error("AutocompleteContext returned null values");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
let t1;
|
|
37
|
+
if ($[6] !== newOverlayProps || $[7] !== oldOverlayProps) {
|
|
38
|
+
t1 = {
|
|
39
|
+
...oldOverlayProps,
|
|
40
|
+
...newOverlayProps
|
|
41
|
+
};
|
|
42
|
+
$[6] = newOverlayProps;
|
|
43
|
+
$[7] = oldOverlayProps;
|
|
44
|
+
$[8] = t1;
|
|
45
|
+
} else t1 = $[8];
|
|
46
|
+
const overlayProps = t1;
|
|
47
|
+
const { inputRef, scrollContainerRef, selectedItemLength, setShowMenu, showMenu: t2 } = autocompleteContext;
|
|
48
|
+
const showMenu = t2 === void 0 ? false : t2;
|
|
19
49
|
const computedAnchorRef = useRef(null);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
let t3;
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[9] !== inputRef || $[10] !== menuAnchorRef) {
|
|
53
|
+
t3 = () => {
|
|
54
|
+
var _menuAnchorRef$curren, _menuAnchorRef, _tokensContainer$pare, _ref;
|
|
55
|
+
const explicit = (_menuAnchorRef$curren = (_menuAnchorRef = menuAnchorRef) === null || _menuAnchorRef === void 0 ? void 0 : _menuAnchorRef.current) !== null && _menuAnchorRef$curren !== void 0 ? _menuAnchorRef$curren : null;
|
|
56
|
+
const tokensContainer = inputRef.current ? inputRef.current.closest("[data-prevent-token-wrapping]") : null;
|
|
57
|
+
const tokensRoot = (_tokensContainer$pare = tokensContainer === null || tokensContainer === void 0 ? void 0 : tokensContainer.parentElement) !== null && _tokensContainer$pare !== void 0 ? _tokensContainer$pare : null;
|
|
58
|
+
computedAnchorRef.current = (_ref = explicit !== null && explicit !== void 0 ? explicit : tokensRoot) !== null && _ref !== void 0 ? _ref : inputRef.current;
|
|
59
|
+
};
|
|
60
|
+
t4 = [menuAnchorRef, inputRef];
|
|
61
|
+
$[9] = inputRef;
|
|
62
|
+
$[10] = menuAnchorRef;
|
|
63
|
+
$[11] = t3;
|
|
64
|
+
$[12] = t4;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[11];
|
|
67
|
+
t4 = $[12];
|
|
68
|
+
}
|
|
69
|
+
useEffect(t3, t4);
|
|
70
|
+
let t5;
|
|
71
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
72
|
+
t5 = {
|
|
73
|
+
side: "outside-bottom",
|
|
74
|
+
align: "start",
|
|
75
|
+
anchorElementRef: computedAnchorRef
|
|
76
|
+
};
|
|
77
|
+
$[13] = t5;
|
|
78
|
+
} else t5 = $[13];
|
|
79
|
+
let t6;
|
|
80
|
+
if ($[14] !== selectedItemLength || $[15] !== showMenu) {
|
|
81
|
+
t6 = [showMenu, selectedItemLength];
|
|
82
|
+
$[14] = selectedItemLength;
|
|
83
|
+
$[15] = showMenu;
|
|
84
|
+
$[16] = t6;
|
|
85
|
+
} else t6 = $[16];
|
|
86
|
+
const { floatingElementRef, position } = useAnchoredPosition(t5, t6);
|
|
32
87
|
const mergedScrollContainerRef = useMergedRefs(scrollContainerRef, floatingElementRef);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
88
|
+
let t7;
|
|
89
|
+
if ($[17] !== setShowMenu) {
|
|
90
|
+
t7 = () => {
|
|
91
|
+
setShowMenu(false);
|
|
92
|
+
};
|
|
93
|
+
$[17] = setShowMenu;
|
|
94
|
+
$[18] = t7;
|
|
95
|
+
} else t7 = $[18];
|
|
96
|
+
const closeOptionList = t7;
|
|
36
97
|
if (typeof window === "undefined") return null;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
98
|
+
let t8;
|
|
99
|
+
if ($[19] !== children || $[20] !== className || $[21] !== closeOptionList || $[22] !== inputRef || $[23] !== mergedScrollContainerRef || $[24] !== overlayProps || $[25] !== (position === null || position === void 0 ? void 0 : position.left) || $[26] !== (position === null || position === void 0 ? void 0 : position.top) || $[27] !== showMenu) {
|
|
100
|
+
t8 = showMenu ? /*#__PURE__*/ jsx(Overlay, {
|
|
101
|
+
returnFocusRef: inputRef,
|
|
102
|
+
preventFocusOnOpen: true,
|
|
103
|
+
onClickOutside: closeOptionList,
|
|
104
|
+
onEscape: closeOptionList,
|
|
105
|
+
ref: mergedScrollContainerRef,
|
|
106
|
+
top: position === null || position === void 0 ? void 0 : position.top,
|
|
107
|
+
left: position === null || position === void 0 ? void 0 : position.left,
|
|
108
|
+
className: clsx(AutocompleteOverlay_module_css_default.Overlay, className),
|
|
109
|
+
...overlayProps,
|
|
110
|
+
"data-component": "Autocomplete.Overlay",
|
|
111
|
+
children
|
|
112
|
+
}) : /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
113
|
+
"aria-hidden": "true",
|
|
114
|
+
children
|
|
115
|
+
});
|
|
116
|
+
$[19] = children;
|
|
117
|
+
$[20] = className;
|
|
118
|
+
$[21] = closeOptionList;
|
|
119
|
+
$[22] = inputRef;
|
|
120
|
+
$[23] = mergedScrollContainerRef;
|
|
121
|
+
$[24] = overlayProps;
|
|
122
|
+
$[25] = position === null || position === void 0 ? void 0 : position.left;
|
|
123
|
+
$[26] = position === null || position === void 0 ? void 0 : position.top;
|
|
124
|
+
$[27] = showMenu;
|
|
125
|
+
$[28] = t8;
|
|
126
|
+
} else t8 = $[28];
|
|
127
|
+
return t8;
|
|
53
128
|
}
|
|
54
129
|
AutocompleteOverlay.displayName = "AutocompleteOverlay";
|
|
55
130
|
AutocompleteOverlay.__SLOT__ = Symbol("Autocomplete.Overlay");
|