@altinn/altinn-components 0.56.6 → 0.56.7
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/dist/SearchField-CqdLwxvV.js +685 -0
- package/dist/components/Account/AccountMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/Dialog/DialogActions.js +1 -1
- package/dist/components/Forms/SearchField.js +1 -1
- package/dist/components/Forms/index.js +1 -1
- package/dist/components/GlobalHeader/AccountSelector.js +1 -1
- package/dist/components/GlobalMenu/GlobalMenu.js +1 -1
- package/dist/components/GlobalMenu/LocaleSwitcher.js +1 -1
- package/dist/components/GlobalMenu_old/GlobalMenu.js +1 -1
- package/dist/components/Header/LocaleSwitcher.js +1 -1
- package/dist/components/Layout/Layout.js +1 -1
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/Menu/MenuItems.js +1 -1
- package/dist/components/Menu/MenuListSearch.js +1 -1
- package/dist/components/Menu/VirtualizedMenuItems.js +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Toolbar/SelectDateFilter.js +1 -1
- package/dist/components/Toolbar/ToolbarFilterAddMenu.js +1 -1
- package/dist/components/Toolbar/ToolbarFilterMenu.js +1 -1
- package/dist/components/Toolbar/ToolbarMenu.js +1 -1
- package/dist/components/Toolbar/ToolbarSearch.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/lib/components/Toolbar/Toolbar.stories.d.ts +1 -0
- package/package.json +1 -1
- package/dist/SearchField-d2UqvD48.js +0 -639
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as n, jsxs as W } from "react/jsx-runtime";
|
|
3
|
-
import { c as pe } from "./index-p1eeF8LQ.js";
|
|
4
|
-
import { useRef as j, useState as Q, useMemo as R, useEffect as G, Fragment as me, useLayoutEffect as oe, useId as ne } from "react";
|
|
5
|
-
import { Icon as he } from "./components/Icon/Icon.js";
|
|
6
|
-
import { Button as xe } from "./components/Button/Button.js";
|
|
7
|
-
import "./components/RootProvider/RootProvider.js";
|
|
8
|
-
import { useMenu as ie } from "./hooks/useMenu.js";
|
|
9
|
-
import { Input as ye } from "./components/Forms/Input.js";
|
|
10
|
-
import { FieldBase as ve } from "./components/Forms/FieldBase.js";
|
|
11
|
-
import "./components/Snackbar/useSnackbar.js";
|
|
12
|
-
import { S as ge } from "./MagnifyingGlass-bwVhw07z.js";
|
|
13
|
-
import { S as Ie } from "./XMark-tKk6aExO.js";
|
|
14
|
-
import { MenuItem as se } from "./components/Menu/MenuItem.js";
|
|
15
|
-
import { MenuList as Z } from "./components/Menu/MenuList.js";
|
|
16
|
-
import { MenuListItem as ae } from "./components/Menu/MenuListItem.js";
|
|
17
|
-
import { MenuListGroup as ce } from "./components/Menu/MenuListGroup.js";
|
|
18
|
-
import { MenuListDivider as le } from "./components/Menu/MenuListDivider.js";
|
|
19
|
-
import { MenuListHeading as ue } from "./components/Menu/MenuListHeading.js";
|
|
20
|
-
import { a as be } from "./useMenuVirtualization-Cs426RCN.js";
|
|
21
|
-
import { useMenuSearch as ke } from "./components/Menu/useMenuSearch.js";
|
|
22
|
-
import './assets/SearchField.css';const Ce = "_search_18jfe_1", _e = "_searchInput_18jfe_8", te = {
|
|
23
|
-
search: Ce,
|
|
24
|
-
searchInput: _e
|
|
25
|
-
}, de = ({
|
|
26
|
-
style: I,
|
|
27
|
-
index: b,
|
|
28
|
-
name: A,
|
|
29
|
-
value: _,
|
|
30
|
-
placeholder: f = "Search",
|
|
31
|
-
clearButtonAltText: i = "Clear search",
|
|
32
|
-
onChange: M,
|
|
33
|
-
onClear: B,
|
|
34
|
-
onNavigate: p,
|
|
35
|
-
combobox: c = !1,
|
|
36
|
-
listId: v,
|
|
37
|
-
"aria-activedescendant": D,
|
|
38
|
-
onKeyDown: h,
|
|
39
|
-
onInput: r,
|
|
40
|
-
onFocus: k,
|
|
41
|
-
...w
|
|
42
|
-
}) => /* @__PURE__ */ n("li", { className: te.search, style: I, "data-index": b, "data-menu-search": "true", children: c ? (
|
|
43
|
-
// biome-ignore lint/a11y/useFocusableInteractive: <explanation>
|
|
44
|
-
// biome-ignore lint/a11y/useAriaPropsForRole: <explanation>
|
|
45
|
-
// biome-ignore lint/a11y/useSemanticElements: <explanation>
|
|
46
|
-
/* @__PURE__ */ n("div", { role: "combobox", "aria-expanded": !0, "aria-haspopup": "listbox", "aria-owns": v, children: /* @__PURE__ */ n(
|
|
47
|
-
re,
|
|
48
|
-
{
|
|
49
|
-
size: "xs",
|
|
50
|
-
className: te.searchInput,
|
|
51
|
-
name: A,
|
|
52
|
-
value: _,
|
|
53
|
-
placeholder: f,
|
|
54
|
-
onChange: M,
|
|
55
|
-
onClear: B,
|
|
56
|
-
clearButtonAltText: i,
|
|
57
|
-
autoComplete: "off",
|
|
58
|
-
autoCorrect: "off",
|
|
59
|
-
autoCapitalize: "off",
|
|
60
|
-
"aria-autocomplete": "list",
|
|
61
|
-
"aria-controls": v,
|
|
62
|
-
"aria-activedescendant": D,
|
|
63
|
-
autoFocus: !0,
|
|
64
|
-
onKeyDown: (s) => {
|
|
65
|
-
(s.key === "ArrowUp" || s.key === "ArrowDown") && (s.preventDefault(), p?.()), h?.(s);
|
|
66
|
-
},
|
|
67
|
-
onInput: r,
|
|
68
|
-
onFocus: k,
|
|
69
|
-
...w
|
|
70
|
-
}
|
|
71
|
-
) })
|
|
72
|
-
) : /* @__PURE__ */ n(
|
|
73
|
-
re,
|
|
74
|
-
{
|
|
75
|
-
size: "xs",
|
|
76
|
-
className: te.searchInput,
|
|
77
|
-
name: A,
|
|
78
|
-
value: _,
|
|
79
|
-
placeholder: f,
|
|
80
|
-
onChange: M,
|
|
81
|
-
onClear: B,
|
|
82
|
-
clearButtonAltText: i,
|
|
83
|
-
autoComplete: "off",
|
|
84
|
-
autoCorrect: "off",
|
|
85
|
-
autoCapitalize: "off",
|
|
86
|
-
autoFocus: !0,
|
|
87
|
-
onKeyDown: (s) => {
|
|
88
|
-
(s.key === "ArrowUp" || s.key === "ArrowDown") && (s.preventDefault(), p?.()), h?.(s);
|
|
89
|
-
},
|
|
90
|
-
onInput: r,
|
|
91
|
-
onFocus: k,
|
|
92
|
-
...w
|
|
93
|
-
}
|
|
94
|
-
) }), fe = ({
|
|
95
|
-
level: I = 0,
|
|
96
|
-
maxLevels: b,
|
|
97
|
-
expanded: A,
|
|
98
|
-
a11yMode: _ = "menu",
|
|
99
|
-
open: f,
|
|
100
|
-
scrollToTopOnOpen: i = !1,
|
|
101
|
-
autoActivateFirstItem: M = !0,
|
|
102
|
-
autoFocusList: B = !0,
|
|
103
|
-
announceNoResults: p = !1,
|
|
104
|
-
search: c,
|
|
105
|
-
items: v,
|
|
106
|
-
groups: D = {},
|
|
107
|
-
size: h,
|
|
108
|
-
id: r,
|
|
109
|
-
color: k,
|
|
110
|
-
variant: w,
|
|
111
|
-
scrollRefStyles: s = {},
|
|
112
|
-
keyboardEvents: x = !1,
|
|
113
|
-
onSelect: P = () => {
|
|
114
|
-
},
|
|
115
|
-
onActiveItemIdChange: g
|
|
116
|
-
}) => {
|
|
117
|
-
if (b && I >= b)
|
|
118
|
-
return null;
|
|
119
|
-
const m = _ === "combobox", u = m && r ? `${r}-listbox` : r, F = j(f), O = j(f), [Y, C] = Q(!1), d = R(
|
|
120
|
-
() => v.map((o, y) => ({
|
|
121
|
-
...o,
|
|
122
|
-
id: o.id || `${r}-item-${y}`
|
|
123
|
-
})),
|
|
124
|
-
[v, r]
|
|
125
|
-
), N = j(null), { menu: E, setActiveIndex: H, activeItem: L } = ie({
|
|
126
|
-
items: d,
|
|
127
|
-
groups: D,
|
|
128
|
-
groupByKey: "groupId",
|
|
129
|
-
keyboardEvents: x,
|
|
130
|
-
autoActivateFirstItem: M,
|
|
131
|
-
onSelect: P,
|
|
132
|
-
ref: N
|
|
133
|
-
});
|
|
134
|
-
return G(() => {
|
|
135
|
-
g?.(L?.id);
|
|
136
|
-
}, [L?.id, g]), G(() => {
|
|
137
|
-
if (!i) {
|
|
138
|
-
F.current = f;
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const o = F.current;
|
|
142
|
-
F.current = f, f && !o && N.current?.scrollTo({ top: 0 });
|
|
143
|
-
}, [f, i]), G(() => {
|
|
144
|
-
const o = O.current;
|
|
145
|
-
O.current = f, !(!x || c || !B) && f && !o && requestAnimationFrame(() => N.current?.focus?.({ preventScroll: !0 }));
|
|
146
|
-
}, [f, x, c]), G(() => {
|
|
147
|
-
if (m && p) {
|
|
148
|
-
H(0), C(!0);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
}, [p, m, H]), /* @__PURE__ */ W(
|
|
152
|
-
Z,
|
|
153
|
-
{
|
|
154
|
-
variant: w,
|
|
155
|
-
expanded: A,
|
|
156
|
-
ref: N,
|
|
157
|
-
style: s,
|
|
158
|
-
id: u,
|
|
159
|
-
role: m ? "listbox" : void 0,
|
|
160
|
-
tabIndex: x ? -1 : void 0,
|
|
161
|
-
children: [
|
|
162
|
-
c && /* @__PURE__ */ n(
|
|
163
|
-
de,
|
|
164
|
-
{
|
|
165
|
-
...c,
|
|
166
|
-
combobox: m,
|
|
167
|
-
listId: u,
|
|
168
|
-
"aria-activedescendant": m && Y ? L?.id : void 0,
|
|
169
|
-
onNavigate: m ? () => C(!0) : void 0,
|
|
170
|
-
onChange: (o) => {
|
|
171
|
-
C(!1), c.onChange?.(o);
|
|
172
|
-
},
|
|
173
|
-
onFocus: (o) => {
|
|
174
|
-
C(!1), c.onFocus?.(o);
|
|
175
|
-
},
|
|
176
|
-
onInput: (o) => {
|
|
177
|
-
C(!1), c.onInput?.(o);
|
|
178
|
-
},
|
|
179
|
-
onKeyDown: (o) => {
|
|
180
|
-
const y = o.key === "ArrowUp" || o.key === "ArrowDown", K = o.key.length === 1 || o.key === "Backspace" || o.key === "Delete";
|
|
181
|
-
m && !y && K && C(!1), c.onKeyDown?.(o);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
),
|
|
185
|
-
E.map((o, y) => {
|
|
186
|
-
const K = o?.props || {}, { title: S, hidden: q = !1, divider: X = !0 } = K;
|
|
187
|
-
return /* @__PURE__ */ W(me, { children: [
|
|
188
|
-
(I > 0 || y) && X ? /* @__PURE__ */ n(le, {}) : "",
|
|
189
|
-
/* @__PURE__ */ n(ce, { hidden: q, children: /* @__PURE__ */ W(Z, { role: "presentation", children: [
|
|
190
|
-
S && /* @__PURE__ */ n(ue, { title: S, level: I }),
|
|
191
|
-
o?.items.filter((U) => !U.props?.hidden).map((U, e) => {
|
|
192
|
-
const { active: t, onMouseEnter: l } = U, { groupId: z, ...a } = U.props || {}, { expanded: T } = a, V = Array.isArray(a?.items) && a.items.length > 0, J = a.role === "checkbox" || a.role === "radio", ee = m && !J ? "option" : a.role;
|
|
193
|
-
return /* @__PURE__ */ W(
|
|
194
|
-
ae,
|
|
195
|
-
{
|
|
196
|
-
expanded: T,
|
|
197
|
-
onMouseLeave: () => H(-1),
|
|
198
|
-
role: m || J ? "presentation" : void 0,
|
|
199
|
-
children: [
|
|
200
|
-
/* @__PURE__ */ n(
|
|
201
|
-
se,
|
|
202
|
-
{
|
|
203
|
-
...a,
|
|
204
|
-
size: a?.size || K?.size || h,
|
|
205
|
-
color: a?.color || K?.color || k,
|
|
206
|
-
variant: a?.variant || K?.variant || w,
|
|
207
|
-
active: t,
|
|
208
|
-
role: ee,
|
|
209
|
-
selected: a.selected,
|
|
210
|
-
tabIndex: a?.disabled || x ? -1 : a.tabIndex ?? 0,
|
|
211
|
-
onMouseEnter: l,
|
|
212
|
-
"aria-haspopup": V ? "menu" : void 0,
|
|
213
|
-
"aria-expanded": V ? T : void 0,
|
|
214
|
-
"aria-controls": V ? a.id + "-menu" : void 0
|
|
215
|
-
}
|
|
216
|
-
),
|
|
217
|
-
T && a?.items && /* @__PURE__ */ n(
|
|
218
|
-
fe,
|
|
219
|
-
{
|
|
220
|
-
id: a.id + "-menu",
|
|
221
|
-
expanded: T,
|
|
222
|
-
level: I + 1,
|
|
223
|
-
maxLevels: b,
|
|
224
|
-
items: a?.items,
|
|
225
|
-
groups: D,
|
|
226
|
-
size: h,
|
|
227
|
-
color: k,
|
|
228
|
-
variant: w
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
]
|
|
232
|
-
},
|
|
233
|
-
e
|
|
234
|
-
);
|
|
235
|
-
})
|
|
236
|
-
] }) }, y)
|
|
237
|
-
] }, y);
|
|
238
|
-
})
|
|
239
|
-
]
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
}, we = (I) => {
|
|
243
|
-
const b = j(null), A = j(null), [_, f] = Q(0), {
|
|
244
|
-
search: i,
|
|
245
|
-
items: M,
|
|
246
|
-
groups: B = {},
|
|
247
|
-
size: p,
|
|
248
|
-
color: c,
|
|
249
|
-
variant: v,
|
|
250
|
-
keyboardEvents: D,
|
|
251
|
-
scrollRefStyles: h = {},
|
|
252
|
-
id: r,
|
|
253
|
-
expanded: k,
|
|
254
|
-
a11yMode: w = "menu",
|
|
255
|
-
open: s,
|
|
256
|
-
scrollToTopOnOpen: x = !1,
|
|
257
|
-
autoActivateFirstItem: P = !0,
|
|
258
|
-
announceNoResults: g = !1,
|
|
259
|
-
onActiveItemIdChange: m
|
|
260
|
-
} = I, u = w === "combobox", F = u && r ? `${r}-listbox` : r, O = j(s), [Y, C] = Q(!1), d = R(
|
|
261
|
-
() => M.map((e, t) => ({
|
|
262
|
-
...e,
|
|
263
|
-
id: e.id || `${r}-item-${t}`
|
|
264
|
-
})),
|
|
265
|
-
[M, r]
|
|
266
|
-
), { menu: N, activeItem: E, setActiveIndex: H, activeIndex: L } = ie({
|
|
267
|
-
items: d,
|
|
268
|
-
groups: B,
|
|
269
|
-
groupByKey: "groupId",
|
|
270
|
-
keyboardEvents: D,
|
|
271
|
-
autoActivateFirstItem: P,
|
|
272
|
-
ref: b
|
|
273
|
-
}), { flatMenu: o, virtualizer: y, scrollMaxHeight: K } = be({
|
|
274
|
-
menu: N,
|
|
275
|
-
scrollRef: b
|
|
276
|
-
});
|
|
277
|
-
oe(() => {
|
|
278
|
-
const e = A.current;
|
|
279
|
-
if (!e) return;
|
|
280
|
-
const t = Math.round(e.offsetTop);
|
|
281
|
-
f((l) => l === t ? l : t);
|
|
282
|
-
});
|
|
283
|
-
const S = R(() => {
|
|
284
|
-
const e = E?.id;
|
|
285
|
-
if (e)
|
|
286
|
-
return o.findIndex((l) => l.type === "item" && l.itemProps?.id === e);
|
|
287
|
-
if (L < 0) return -1;
|
|
288
|
-
let t = -1;
|
|
289
|
-
for (let l = 0; l < o.length; l++)
|
|
290
|
-
if (o[l]?.type === "item" && (t += 1, t === L))
|
|
291
|
-
return l;
|
|
292
|
-
return -1;
|
|
293
|
-
}, [E?.id, L, o]), q = j(null);
|
|
294
|
-
oe(() => {
|
|
295
|
-
const e = q?.current, t = typeof e == "number" ? S <= e : !1;
|
|
296
|
-
q.current = S;
|
|
297
|
-
const l = t ? S : S + 2;
|
|
298
|
-
if (!t) {
|
|
299
|
-
const V = y.getOffsetForIndex(l, "auto");
|
|
300
|
-
if (!V) return;
|
|
301
|
-
const [J, ee] = V;
|
|
302
|
-
if (ee === "auto") return;
|
|
303
|
-
y.scrollToOffset(J + _ + 10, { align: "start" });
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
if (S <= 3) {
|
|
307
|
-
y.scrollToOffset(0);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const z = y.getOffsetForIndex(S - 1, "auto");
|
|
311
|
-
if (!z) return;
|
|
312
|
-
const [a, T] = z;
|
|
313
|
-
T !== "auto" && y.scrollToOffset(a + _ + 10, { align: "start" });
|
|
314
|
-
}, [S, _, y, q]);
|
|
315
|
-
const X = R(() => {
|
|
316
|
-
const e = /* @__PURE__ */ new Map();
|
|
317
|
-
let t = 0;
|
|
318
|
-
return o.forEach((l, z) => {
|
|
319
|
-
l.type === "item" && (t += 1, e.set(z, t));
|
|
320
|
-
}), { positions: e, total: t };
|
|
321
|
-
}, [o]);
|
|
322
|
-
G(() => {
|
|
323
|
-
m?.(E?.id);
|
|
324
|
-
}, [E?.id, m]), G(() => {
|
|
325
|
-
if (u && g) {
|
|
326
|
-
H(0), C(!0);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
}, [g, u, H]), G(() => {
|
|
330
|
-
if (!x) {
|
|
331
|
-
O.current = s;
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const e = O.current;
|
|
335
|
-
O.current = s, s && !e && b.current?.scrollTo({ top: 0 });
|
|
336
|
-
}, [s, x]);
|
|
337
|
-
const U = {
|
|
338
|
-
position: "relative",
|
|
339
|
-
maxHeight: h?.maxHeight || K,
|
|
340
|
-
margin: "-0.5rem",
|
|
341
|
-
padding: "0.5rem",
|
|
342
|
-
minWidth: h?.minWidth ?? "20rem",
|
|
343
|
-
overflowY: "auto",
|
|
344
|
-
...h
|
|
345
|
-
};
|
|
346
|
-
return /* @__PURE__ */ W(
|
|
347
|
-
Z,
|
|
348
|
-
{
|
|
349
|
-
ref: b,
|
|
350
|
-
style: U,
|
|
351
|
-
variant: v,
|
|
352
|
-
color: c,
|
|
353
|
-
expanded: k,
|
|
354
|
-
id: F,
|
|
355
|
-
role: u ? "listbox" : void 0,
|
|
356
|
-
children: [
|
|
357
|
-
i && /* @__PURE__ */ n(
|
|
358
|
-
de,
|
|
359
|
-
{
|
|
360
|
-
...i,
|
|
361
|
-
combobox: u,
|
|
362
|
-
listId: F,
|
|
363
|
-
"aria-activedescendant": u && Y ? E?.id : void 0,
|
|
364
|
-
onNavigate: u ? () => C(!0) : void 0,
|
|
365
|
-
onChange: (e) => {
|
|
366
|
-
C(!1), i.onChange?.(e);
|
|
367
|
-
},
|
|
368
|
-
onFocus: (e) => {
|
|
369
|
-
C(!1), i.onFocus?.(e);
|
|
370
|
-
},
|
|
371
|
-
onInput: (e) => {
|
|
372
|
-
C(!1), i.onInput?.(e);
|
|
373
|
-
},
|
|
374
|
-
onKeyDown: (e) => {
|
|
375
|
-
const t = e.key === "ArrowUp" || e.key === "ArrowDown", l = e.key.length === 1 || e.key === "Backspace" || e.key === "Delete";
|
|
376
|
-
u && !t && l && C(!1), i.onKeyDown?.(e);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
),
|
|
380
|
-
/* @__PURE__ */ n(
|
|
381
|
-
ce,
|
|
382
|
-
{
|
|
383
|
-
ref: A,
|
|
384
|
-
style: {
|
|
385
|
-
position: "relative",
|
|
386
|
-
height: `${y.getTotalSize()}px`,
|
|
387
|
-
width: "100%"
|
|
388
|
-
},
|
|
389
|
-
children: /* @__PURE__ */ n(Z, { style: { width: "100%", minWidth: "100%" }, children: y.getVirtualItems().map((e) => {
|
|
390
|
-
const t = o[e.index];
|
|
391
|
-
if (!t) return null;
|
|
392
|
-
const l = {
|
|
393
|
-
position: "absolute",
|
|
394
|
-
top: 0,
|
|
395
|
-
left: 0,
|
|
396
|
-
width: "100%",
|
|
397
|
-
transform: `translateY(${e.start}px)`
|
|
398
|
-
}, z = {
|
|
399
|
-
style: l,
|
|
400
|
-
index: e.index,
|
|
401
|
-
"data-index": e.index,
|
|
402
|
-
ref: y.measureElement
|
|
403
|
-
};
|
|
404
|
-
switch (t.type) {
|
|
405
|
-
case "divider":
|
|
406
|
-
return /* @__PURE__ */ n(
|
|
407
|
-
le,
|
|
408
|
-
{
|
|
409
|
-
...z,
|
|
410
|
-
style: { ...l, padding: "0.25rem 0" }
|
|
411
|
-
},
|
|
412
|
-
e.key
|
|
413
|
-
);
|
|
414
|
-
case "header":
|
|
415
|
-
return /* @__PURE__ */ n(ue, { ...z, title: t.title || "", level: 1 }, e.key);
|
|
416
|
-
default: {
|
|
417
|
-
const a = t.itemProps?.role === "checkbox" || t.itemProps?.role === "radio", T = u && !a ? "option" : t.itemProps?.role;
|
|
418
|
-
return /* @__PURE__ */ n(
|
|
419
|
-
ae,
|
|
420
|
-
{
|
|
421
|
-
...z,
|
|
422
|
-
role: u || a ? "presentation" : "menuitem",
|
|
423
|
-
children: /* @__PURE__ */ n(
|
|
424
|
-
se,
|
|
425
|
-
{
|
|
426
|
-
...t.itemProps || {},
|
|
427
|
-
size: t.itemProps?.size || p,
|
|
428
|
-
color: t.itemProps?.color || c,
|
|
429
|
-
variant: t.itemProps?.variant || v,
|
|
430
|
-
active: t.active,
|
|
431
|
-
role: T,
|
|
432
|
-
selected: t.itemProps?.selected,
|
|
433
|
-
"aria-posinset": u ? X.positions.get(e.index) : void 0,
|
|
434
|
-
"aria-setsize": u ? X.total : void 0,
|
|
435
|
-
tabIndex: t.itemProps?.disabled || D ? -1 : 0
|
|
436
|
-
}
|
|
437
|
-
)
|
|
438
|
-
},
|
|
439
|
-
e.key
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}) })
|
|
444
|
-
}
|
|
445
|
-
)
|
|
446
|
-
]
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
}, Me = ({
|
|
450
|
-
searchable: I,
|
|
451
|
-
search: b,
|
|
452
|
-
items: A = [],
|
|
453
|
-
groups: _ = {},
|
|
454
|
-
variant: f = "default",
|
|
455
|
-
size: i,
|
|
456
|
-
level: M = 0,
|
|
457
|
-
maxLevels: B = 3,
|
|
458
|
-
virtualized: p = !1,
|
|
459
|
-
keyboardEvents: c = !1,
|
|
460
|
-
scrollRefStyles: v = {},
|
|
461
|
-
onActiveItemIdChange: D,
|
|
462
|
-
a11yMode: h = "menu",
|
|
463
|
-
open: r,
|
|
464
|
-
scrollToTopOnOpen: k,
|
|
465
|
-
autoFocusList: w,
|
|
466
|
-
id: s
|
|
467
|
-
}) => {
|
|
468
|
-
const x = ke({ ...b, items: A, groups: _ }), P = I ? x.search : b, g = I && x.hasQuery && x.resultCount === 0, m = I ? x.items : A, u = I ? { ..._, ...x.groups } : _, F = h !== "combobox";
|
|
469
|
-
return p ? /* @__PURE__ */ n(
|
|
470
|
-
we,
|
|
471
|
-
{
|
|
472
|
-
id: s,
|
|
473
|
-
search: P,
|
|
474
|
-
announceNoResults: g,
|
|
475
|
-
items: m,
|
|
476
|
-
groups: u,
|
|
477
|
-
variant: f,
|
|
478
|
-
size: i,
|
|
479
|
-
level: M,
|
|
480
|
-
maxLevels: B,
|
|
481
|
-
keyboardEvents: c,
|
|
482
|
-
scrollRefStyles: v,
|
|
483
|
-
onActiveItemIdChange: D,
|
|
484
|
-
a11yMode: h,
|
|
485
|
-
open: r,
|
|
486
|
-
scrollToTopOnOpen: k,
|
|
487
|
-
autoActivateFirstItem: F,
|
|
488
|
-
autoFocusList: w
|
|
489
|
-
}
|
|
490
|
-
) : /* @__PURE__ */ n(
|
|
491
|
-
fe,
|
|
492
|
-
{
|
|
493
|
-
id: s,
|
|
494
|
-
search: P,
|
|
495
|
-
announceNoResults: g,
|
|
496
|
-
items: m,
|
|
497
|
-
groups: u,
|
|
498
|
-
variant: f,
|
|
499
|
-
size: i,
|
|
500
|
-
level: M,
|
|
501
|
-
maxLevels: B,
|
|
502
|
-
keyboardEvents: c,
|
|
503
|
-
scrollRefStyles: v,
|
|
504
|
-
onActiveItemIdChange: D,
|
|
505
|
-
a11yMode: h,
|
|
506
|
-
open: r,
|
|
507
|
-
scrollToTopOnOpen: k,
|
|
508
|
-
autoActivateFirstItem: F,
|
|
509
|
-
autoFocusList: w
|
|
510
|
-
}
|
|
511
|
-
);
|
|
512
|
-
}, Ae = "_fieldContainer_1ekv9_1", De = "_field_1ekv9_1", Be = "_inputContainer_1ekv9_9", Fe = "_icon_1ekv9_15", Ne = "_input_1ekv9_9", Se = "_clear_1ekv9_58", Pe = "_clearButton_1ekv9_70", ze = "_autocomplete_1ekv9_99", $ = {
|
|
513
|
-
fieldContainer: Ae,
|
|
514
|
-
field: De,
|
|
515
|
-
inputContainer: Be,
|
|
516
|
-
icon: Fe,
|
|
517
|
-
input: Ne,
|
|
518
|
-
clear: Se,
|
|
519
|
-
clearButton: Pe,
|
|
520
|
-
autocomplete: ze
|
|
521
|
-
}, re = ({
|
|
522
|
-
className: I,
|
|
523
|
-
collapsible: b,
|
|
524
|
-
size: A,
|
|
525
|
-
color: _ = "neutral",
|
|
526
|
-
label: f,
|
|
527
|
-
value: i,
|
|
528
|
-
onClear: M,
|
|
529
|
-
clearButtonAltText: B = "Clear search",
|
|
530
|
-
menu: p,
|
|
531
|
-
minLength: c,
|
|
532
|
-
...v
|
|
533
|
-
}) => {
|
|
534
|
-
const D = ne(), [h, r] = Q(!1), k = v.id || `search-field-${D}`, w = `${k}-listbox`, [s, x] = Q(void 0), P = "searchfield-clear-button-" + ne(), g = R(() => !i || typeof c == "number" && typeof i == "string" && i.length < c ? !1 : h, [h, c, i]), m = R(() => (p?.items ?? []).map((d) => ({
|
|
535
|
-
...d,
|
|
536
|
-
onClick: () => {
|
|
537
|
-
d.onClick?.(), r(!1);
|
|
538
|
-
}
|
|
539
|
-
})), [p]), u = (d) => {
|
|
540
|
-
if (d.key === "Enter" && g) {
|
|
541
|
-
p?.items?.[0]?.onClick?.(), r(!1);
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
if (d.key === "Escape" && g) {
|
|
545
|
-
d.preventDefault(), d.stopPropagation(), r(!1), p?.onClose(), document.getElementById(k)?.focus();
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
v.onKeyDown?.(d), r(!0);
|
|
549
|
-
}, F = () => {
|
|
550
|
-
r(!0);
|
|
551
|
-
}, O = (d) => {
|
|
552
|
-
if (!h) return;
|
|
553
|
-
const N = d.relatedTarget;
|
|
554
|
-
N && d.currentTarget.contains(N) || r(!1);
|
|
555
|
-
}, Y = (d) => {
|
|
556
|
-
d.preventDefault();
|
|
557
|
-
}, C = (d) => {
|
|
558
|
-
d.relatedTarget?.id === P && x(void 0), v.onBlur?.(d);
|
|
559
|
-
};
|
|
560
|
-
return /* @__PURE__ */ W("div", { className: $.fieldContainer, children: [
|
|
561
|
-
/* @__PURE__ */ n(
|
|
562
|
-
ve,
|
|
563
|
-
{
|
|
564
|
-
size: A,
|
|
565
|
-
color: _,
|
|
566
|
-
label: f,
|
|
567
|
-
className: pe($.field, I),
|
|
568
|
-
onBlurCapture: O,
|
|
569
|
-
children: /* @__PURE__ */ W("div", { className: $.inputContainer, children: [
|
|
570
|
-
/* @__PURE__ */ n(
|
|
571
|
-
ye,
|
|
572
|
-
{
|
|
573
|
-
...v,
|
|
574
|
-
id: k,
|
|
575
|
-
type: "search",
|
|
576
|
-
value: i,
|
|
577
|
-
className: $.input,
|
|
578
|
-
"data-collapsible": b,
|
|
579
|
-
autoCapitalize: "off",
|
|
580
|
-
autoComplete: "off",
|
|
581
|
-
minLength: c,
|
|
582
|
-
onKeyDown: u,
|
|
583
|
-
onBlur: C,
|
|
584
|
-
...p && {
|
|
585
|
-
role: "combobox",
|
|
586
|
-
"aria-autocomplete": "list",
|
|
587
|
-
"aria-expanded": !!g,
|
|
588
|
-
"aria-haspopup": "listbox",
|
|
589
|
-
"aria-controls": w,
|
|
590
|
-
"aria-activedescendant": g ? s : void 0,
|
|
591
|
-
onFocus: F
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
),
|
|
595
|
-
/* @__PURE__ */ n(he, { svgElement: ge, className: $.icon }),
|
|
596
|
-
M && !!i && /* @__PURE__ */ n("span", { className: $.clear, children: /* @__PURE__ */ n(
|
|
597
|
-
xe,
|
|
598
|
-
{
|
|
599
|
-
id: P,
|
|
600
|
-
"data-testid": "clear-button",
|
|
601
|
-
size: "xs",
|
|
602
|
-
rounded: !0,
|
|
603
|
-
icon: !0,
|
|
604
|
-
variant: "tinted",
|
|
605
|
-
className: $.clearButton,
|
|
606
|
-
onClick: () => {
|
|
607
|
-
M?.(), document.getElementById(k)?.focus();
|
|
608
|
-
},
|
|
609
|
-
"aria-label": B,
|
|
610
|
-
"data-action": "clear-input",
|
|
611
|
-
children: /* @__PURE__ */ n(Ie, {})
|
|
612
|
-
}
|
|
613
|
-
) })
|
|
614
|
-
] })
|
|
615
|
-
}
|
|
616
|
-
),
|
|
617
|
-
p && g && /* @__PURE__ */ n("div", { className: $.autocomplete, "aria-hidden": !g, onMouseDown: Y, children: /* @__PURE__ */ n(
|
|
618
|
-
Me,
|
|
619
|
-
{
|
|
620
|
-
...p,
|
|
621
|
-
id: w,
|
|
622
|
-
items: m,
|
|
623
|
-
groups: p?.groups,
|
|
624
|
-
keyboardEvents: !0,
|
|
625
|
-
a11yMode: "combobox",
|
|
626
|
-
open: g,
|
|
627
|
-
autoFocusList: !1,
|
|
628
|
-
onActiveItemIdChange: x
|
|
629
|
-
}
|
|
630
|
-
) })
|
|
631
|
-
] });
|
|
632
|
-
};
|
|
633
|
-
export {
|
|
634
|
-
Me as M,
|
|
635
|
-
re as S,
|
|
636
|
-
we as V,
|
|
637
|
-
fe as a,
|
|
638
|
-
de as b
|
|
639
|
-
};
|