@altinn/altinn-components 0.56.20 → 0.56.22

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.
Files changed (77) hide show
  1. package/dist/assets/AccountSelector.css +1 -1
  2. package/dist/assets/AccountSelectorButton.css +1 -0
  3. package/dist/assets/DatepickerFilter.css +1 -1
  4. package/dist/assets/Dropdown.css +1 -1
  5. package/dist/assets/GlobalHeader.css +1 -1
  6. package/dist/assets/GlobalMenuButton2.css +1 -1
  7. package/dist/assets/HeaderLogo2.css +1 -1
  8. package/dist/assets/LayoutGrid.css +1 -1
  9. package/dist/assets/ModalBase.css +1 -1
  10. package/dist/assets/ModalFooter.css +1 -0
  11. package/dist/assets/SettingsSection.css +1 -1
  12. package/dist/components/Account/AccountMenu.js +20 -20
  13. package/dist/components/Bookmarks/BookmarkSettingsList.js +41 -11
  14. package/dist/components/Dropdown/Dropdown.js +10 -10
  15. package/dist/components/DsComponents/index.js +20 -21
  16. package/dist/components/GlobalHeader/AccountSelector.js +64 -124
  17. package/dist/components/GlobalHeader/AccountSelectorButton.js +127 -0
  18. package/dist/components/GlobalHeader/DigdirLogomark.js +23 -109
  19. package/dist/components/GlobalHeader/GlobalHeader.js +84 -117
  20. package/dist/components/GlobalHeader/GlobalMenuButton.js +64 -0
  21. package/dist/components/GlobalHeader/HeaderLogo.js +20 -13
  22. package/dist/components/GlobalHeader/index.js +2 -2
  23. package/dist/components/GlobalMenu/GlobalMenu.js +11 -10
  24. package/dist/components/GlobalMenu/index.js +2 -4
  25. package/dist/components/Layout/Layout.js +30 -30
  26. package/dist/components/Layout/LayoutGrid.js +3 -3
  27. package/dist/components/Modal/ModalBase.js +35 -33
  28. package/dist/components/Modal/ModalFooter.js +7 -10
  29. package/dist/components/Modal/index.js +8 -6
  30. package/dist/components/Settings/SettingsItem.js +53 -35
  31. package/dist/components/Settings/SettingsItemBase.js +19 -20
  32. package/dist/components/Settings/SettingsSection.js +10 -10
  33. package/dist/components/index.js +89 -88
  34. package/dist/functions/index.js +6 -4
  35. package/dist/functions/orgno/index.js +4 -0
  36. package/dist/functions/orgno/orgno.js +4 -0
  37. package/dist/hooks/useAccountSelector.js +77 -75
  38. package/dist/index.js +88 -85
  39. package/dist/textfield-CNXt-27J.js +3403 -0
  40. package/dist/types/lib/components/Bookmarks/BookmarkSettingsItem.d.ts +2 -0
  41. package/dist/types/lib/components/Bookmarks/BookmarkSettingsList.d.ts +7 -1
  42. package/dist/types/lib/components/Bookmarks/BookmarkSettingsList.stories.d.ts +4 -1
  43. package/dist/types/lib/components/Dropdown/Dropdown.d.ts +1 -1
  44. package/dist/types/lib/components/{Account/AccountMenuButton.d.ts → GlobalHeader/AccountSelectorButton.d.ts} +2 -2
  45. package/dist/types/lib/components/{Account/AccountMenuButton.stories.d.ts → GlobalHeader/AccountSelectorButton.stories.d.ts} +1 -1
  46. package/dist/types/lib/components/GlobalHeader/DigdirLogomark.d.ts +1 -2
  47. package/dist/types/lib/components/GlobalHeader/GlobalHeader.d.ts +1 -3
  48. package/dist/types/lib/components/GlobalHeader/GlobalHeader.stories.d.ts +1 -1
  49. package/dist/types/lib/components/{GlobalMenu → GlobalHeader}/GlobalMenuButton.d.ts +2 -2
  50. package/dist/types/lib/components/{GlobalMenu → GlobalHeader}/GlobalMenuButton.stories.d.ts +1 -1
  51. package/dist/types/lib/components/GlobalHeader/index.d.ts +1 -1
  52. package/dist/types/lib/components/GlobalMenu/index.d.ts +0 -1
  53. package/dist/types/lib/components/Modal/ModalBase.d.ts +2 -1
  54. package/dist/types/lib/components/Modal/ModalFooter.d.ts +3 -3
  55. package/dist/types/lib/components/Modal/index.d.ts +1 -0
  56. package/dist/types/lib/components/Settings/SettingsModal.stories.d.ts +2 -1
  57. package/dist/types/lib/functions/index.d.ts +1 -0
  58. package/dist/types/lib/functions/orgno/index.d.ts +1 -0
  59. package/dist/types/lib/functions/orgno/orgno.d.ts +1 -0
  60. package/package.json +1 -1
  61. package/dist/assets/AccountMenuButton.css +0 -1
  62. package/dist/assets/GlobalHeaderBase.css +0 -1
  63. package/dist/assets/HeaderGroup2.css +0 -1
  64. package/dist/assets/globalSearch.css +0 -1
  65. package/dist/components/Account/AccountMenuButton.js +0 -134
  66. package/dist/components/GlobalHeader/GlobalHeaderBase.js +0 -24
  67. package/dist/components/GlobalHeader/GlobalSearch.js +0 -62
  68. package/dist/components/GlobalHeader/GlobalSearchButton.js +0 -54
  69. package/dist/components/GlobalHeader/HeaderGroup.js +0 -8
  70. package/dist/components/GlobalMenu/GlobalMenuButton.js +0 -83
  71. package/dist/globalSearch.module-DziLSGZg.js +0 -9
  72. package/dist/index--jNxJmA8.js +0 -2000
  73. package/dist/textfield-Drdr9bio.js +0 -1439
  74. package/dist/types/lib/components/GlobalHeader/GlobalHeaderBase.d.ts +0 -9
  75. package/dist/types/lib/components/GlobalHeader/GlobalSearch.d.ts +0 -4
  76. package/dist/types/lib/components/GlobalHeader/GlobalSearchButton.d.ts +0 -6
  77. package/dist/types/lib/components/GlobalHeader/HeaderGroup.d.ts +0 -6
@@ -1,1439 +0,0 @@
1
- "use client";
2
- import * as le from "react";
3
- import ye, { forwardRef as w, useState as A, useRef as F, useEffect as D, createContext as se, useContext as R, useMemo as J, useId as Q, isValidElement as Et, memo as It, useCallback as St, Children as Be, version as kt } from "react";
4
- import { jsx as c, jsxs as N, Fragment as Ie } from "react/jsx-runtime";
5
- import { c as E } from "./lite-1fxw3LjI.js";
6
- import { S as M, a as _t } from "./index-D7FJjvrv.js";
7
- import { C as q, u as Se, a as qe, o as ce, p as P, r as we, b as ke, i as Nt, c as Mt, f as zt, s as Tt, d as Rt, e as Pt, g as Dt, h as Ft, j as At, k as Lt, l as ae, F as Bt, m as Vt, n as $t } from "./index--jNxJmA8.js";
8
- import { flushSync as Ue } from "react-dom";
9
- import { S as jt, B as de, u as Wt } from "./button-BB5sYVKY.js";
10
- import { V as _e, u as Ne, F as Oe, a as Kt, b as Ht, c as Ve } from "./index-z82sbSVU.js";
11
- import { P as Ee } from "./paragraph-BRiIBpbY.js";
12
- import { I as Me } from "./input-wBv_FkEV.js";
13
- import { S as qt } from "./XMark-tKk6aExO.js";
14
- import { S as Ut, a as Xt } from "./ChevronUp-_BBfEirx.js";
15
- import { L as H } from "./label-xTmTyPhk.js";
16
- import { u as Yt } from "./useId-BVFxCjkq.js";
17
- import { S as Gt } from "./Checkmark-Byz_C9x4.js";
18
- import { a as Xe, c as Jt, o as Qt, f as Zt, s as en } from "./floating-ui.dom-bEgaHJCq.js";
19
- import { u as U } from "./use-merge-refs-Cj4kTYVj.js";
20
- import { T as tn } from "./textarea-BBstVlPT.js";
21
- var nn = function(o, s) {
22
- var e = {};
23
- for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && s.indexOf(t) < 0 && (e[t] = o[t]);
24
- if (o != null && typeof Object.getOwnPropertySymbols == "function")
25
- for (var n = 0, t = Object.getOwnPropertySymbols(o); n < t.length; n++)
26
- s.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[n]) && (e[t[n]] = o[t[n]]);
27
- return e;
28
- };
29
- const on = w((o, s) => {
30
- var { title: e, titleId: t } = o, n = nn(o, ["title", "titleId"]);
31
- let i = Yt();
32
- return i = e ? t || "title-" + i : void 0, ye.createElement(
33
- "svg",
34
- Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: s, "aria-labelledby": i }, n),
35
- e ? ye.createElement("title", { id: i }, e) : null,
36
- ye.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 2.25A4.75 4.75 0 0 0 7.25 7v2.25H7A1.75 1.75 0 0 0 5.25 11v9c0 .414.336.75.75.75h12a.75.75 0 0 0 .75-.75v-9A1.75 1.75 0 0 0 17 9.25h-.25V7A4.75 4.75 0 0 0 12 2.25m3.25 7V7a3.25 3.25 0 0 0-6.5 0v2.25zM12 13a1.5 1.5 0 0 0-.75 2.8V17a.75.75 0 0 0 1.5 0v-1.2A1.5 1.5 0 0 0 12 13", clipRule: "evenodd" })
37
- );
38
- }), Ye = se({
39
- elements: { current: /* @__PURE__ */ new Map() },
40
- getOrderedItems: () => [],
41
- setFocusableValue: () => {
42
- },
43
- onShiftTab: () => {
44
- },
45
- focusableValue: null,
46
- orientation: "horizontal"
47
- }), sn = w(({ activeValue: o, asChild: s, orientation: e = "horizontal", onBlur: t, onFocus: n, ...i }, r) => {
48
- const a = s ? M : "div", l = o ?? null, [d, h] = A(l), [p, u] = A(!1), f = F(/* @__PURE__ */ new Map()), g = F(null), y = U([r, g]), C = () => {
49
- if (!g.current)
50
- return [];
51
- const b = Array.from(g.current.querySelectorAll("[data-roving-tabindex-item]"));
52
- return Array.from(f.current).sort((m, v) => b.indexOf(m[1]) - b.indexOf(v[1])).map(([m, v]) => ({ value: m, element: v }));
53
- };
54
- return D(() => {
55
- h(l);
56
- }, [l]), c(Ye.Provider, { value: {
57
- elements: f,
58
- getOrderedItems: C,
59
- focusableValue: d,
60
- setFocusableValue: h,
61
- onShiftTab: () => {
62
- u(!0);
63
- },
64
- orientation: e
65
- }, children: c(a, { ...i, tabIndex: p ? -1 : 0, onBlur: (b) => {
66
- t?.(b), u(!1), h(o ?? null);
67
- }, onFocus: (b) => {
68
- if (n?.(b), b.target !== b.currentTarget)
69
- return;
70
- const m = C();
71
- m.length !== 0 && (d != null ? f.current.get(d)?.focus() : o != null ? f.current.get(o)?.focus() : m.at(0)?.element.focus());
72
- }, ref: y }) });
73
- }), rn = (o) => {
74
- const { elements: s, getOrderedItems: e, setFocusableValue: t, focusableValue: n, onShiftTab: i, orientation: r } = R(Ye);
75
- return {
76
- getOrderedItems: e,
77
- isFocusable: n === o,
78
- orientation: r,
79
- getRovingProps: (a) => ({
80
- ...a,
81
- ref: (l) => {
82
- l ? s.current.set(o, l) : s.current.delete(o);
83
- },
84
- onKeyDown: (l) => {
85
- if (a?.onKeyDown?.(l), l.shiftKey && l.key === "Tab") {
86
- i();
87
- return;
88
- }
89
- },
90
- onFocus: (l) => {
91
- a?.onFocus?.(l), t(o);
92
- },
93
- "data-roving-tabindex-item": !0,
94
- tabIndex: n === o ? 0 : -1
95
- })
96
- };
97
- };
98
- function Ce(o, s) {
99
- const e = o.findIndex((t) => t.value === s);
100
- return o.at(e === o.length - 1 ? 0 : e + 1);
101
- }
102
- function xe(o, s) {
103
- const e = o.findIndex((t) => t.value === s);
104
- return o.at(e === 0 ? -1 : e - 1);
105
- }
106
- const an = w(({ value: o, asChild: s, ...e }, t) => {
107
- const n = s ? M : "div", i = o ?? (typeof e.children == "string" ? e.children : ""), { getOrderedItems: r, getRovingProps: a, orientation: l } = rn(i), d = a({
108
- onKeyDown: (p) => {
109
- e?.onKeyDown?.(p);
110
- const u = r();
111
- let f;
112
- switch (l) {
113
- case "horizontal":
114
- p.key === "ArrowRight" && (f = Ce(u, i)), p.key === "ArrowLeft" && (f = xe(u, i));
115
- break;
116
- case "vertical":
117
- p.key === "ArrowDown" && (f = Ce(u, i)), p.key === "ArrowUp" && (f = xe(u, i));
118
- break;
119
- case "ambiguous":
120
- ["ArrowRight", "ArrowDown"].includes(p.key) && (f = Ce(u, i)), ["ArrowLeft", "ArrowUp"].includes(p.key) && (f = xe(u, i));
121
- }
122
- p.key === "Home" && (f = u[0]), p.key === "End" && (f = u[u.length - 1]), f && (p.preventDefault(), f.element.focus());
123
- }
124
- }), h = U([t, d.ref]);
125
- return c(n, { ...e, ...d, ref: h, children: e.children });
126
- }), ln = (o, s, e) => {
127
- const t = (e - 1) / 2, n = Math.max(1, Math.min(Math.max(o - Math.floor(t), 1), s - e + 1)), i = Math.min(Math.max(o + Math.ceil(t), e), s), r = Array.from({ length: i + 1 - n }, (a, l) => l + n);
128
- return e > 4 && n > 1 && r.splice(0, 2, 1, 0), e > 3 && i < s && r.splice(-2, 2, 0, s), r;
129
- }, po = ({ currentPage: o = 1, setCurrentPage: s, onChange: e, totalPages: t = 1, showPages: n = 7 }) => J(() => {
130
- const i = o < t, r = o !== 1, a = (l) => (d) => {
131
- if (l < 1 || l > t)
132
- return d.preventDefault();
133
- e?.(d, l), d.defaultPrevented || s?.(l);
134
- };
135
- return {
136
- /** Number of steps */
137
- pages: ln(o, t, n).map((l, d) => ({
138
- /**
139
- * Page number or "ellipsis" for the ellipsis item
140
- */
141
- page: l || "ellipsis",
142
- /**
143
- * Unique key for the item
144
- */
145
- itemKey: l ? `page-${l}` : `ellipsis-${d}`,
146
- // React key utility
147
- /**
148
- * Properties to spread on Pagination.Button
149
- */
150
- buttonProps: l ? {
151
- "aria-current": l === o ? "page" : void 0,
152
- onClick: a(l),
153
- variant: l === o ? "primary" : "tertiary"
154
- } : null
155
- })),
156
- /** Properties to spread on Pagination.Button used for previous naviagation */
157
- prevButtonProps: {
158
- "aria-hidden": !r,
159
- // Using aria-hidden to support all HTML elements because of potential asChild
160
- onClick: a(o - 1),
161
- variant: "tertiary"
162
- },
163
- /** Properties to spread on Pagination.Button used for next naviagation */
164
- nextButtonProps: {
165
- "aria-hidden": !i,
166
- // Using aria-hidden to support all HTML elements because of potential asChild
167
- onClick: a(o + 1),
168
- variant: "tertiary"
169
- },
170
- /** Indication if previous page action should be shown or not */
171
- hasPrev: r,
172
- /** Indication if next page action should be shown or not */
173
- hasNext: i
174
- };
175
- }, [o, t, n]), cn = w(function({ className: s, count: e, maxCount: t, variant: n = "base", ...i }, r) {
176
- return c("span", { className: E("ds-badge", s), "data-count": e && t && e > t ? `${t}+` : e, "data-variant": n, ref: r, ...i });
177
- }), dn = w(function({ className: s, overlap: e = "rectangle", placement: t = "top-right", ...n }, i) {
178
- return c("span", { className: E("ds-badge--position", s), "data-overlap": e, "data-placement": t, ref: i, ...n });
179
- }), un = Object.assign(cn, { Position: dn });
180
- un.Position.displayName = "Badge.Position";
181
- const hn = w(({ asChild: o, className: s, ...e }, t) => c(o ? M : "a", { className: E("ds-link", s), ref: t, ...e }));
182
- hn.displayName = "Link";
183
- function G(o, s, e) {
184
- let t = e.initialDeps ?? [], n, i = !0;
185
- function r() {
186
- var a, l, d;
187
- let h;
188
- e.key && ((a = e.debug) != null && a.call(e)) && (h = Date.now());
189
- const p = o();
190
- if (!(p.length !== t.length || p.some((g, y) => t[y] !== g)))
191
- return n;
192
- t = p;
193
- let f;
194
- if (e.key && ((l = e.debug) != null && l.call(e)) && (f = Date.now()), n = s(...p), e.key && ((d = e.debug) != null && d.call(e))) {
195
- const g = Math.round((Date.now() - h) * 100) / 100, y = Math.round((Date.now() - f) * 100) / 100, C = y / 16, b = (m, v) => {
196
- for (m = String(m); m.length < v; )
197
- m = " " + m;
198
- return m;
199
- };
200
- console.info(
201
- `%c⏱ ${b(y, 5)} /${b(g, 5)} ms`,
202
- `
203
- font-size: .6rem;
204
- font-weight: bold;
205
- color: hsl(${Math.max(
206
- 0,
207
- Math.min(120 - 120 * C, 120)
208
- )}deg 100% 31%);`,
209
- e?.key
210
- );
211
- }
212
- return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(n), i = !1, n;
213
- }
214
- return r.updateDeps = (a) => {
215
- t = a;
216
- }, r;
217
- }
218
- function $e(o, s) {
219
- if (o === void 0)
220
- throw new Error("Unexpected undefined");
221
- return o;
222
- }
223
- const fn = (o, s) => Math.abs(o - s) < 1.01, mn = (o, s, e) => {
224
- let t;
225
- return function(...n) {
226
- o.clearTimeout(t), t = o.setTimeout(() => s.apply(this, n), e);
227
- };
228
- }, je = (o) => {
229
- const { offsetWidth: s, offsetHeight: e } = o;
230
- return { width: s, height: e };
231
- }, pn = (o) => o, bn = (o) => {
232
- const s = Math.max(o.startIndex - o.overscan, 0), e = Math.min(o.endIndex + o.overscan, o.count - 1), t = [];
233
- for (let n = s; n <= e; n++)
234
- t.push(n);
235
- return t;
236
- }, gn = (o, s) => {
237
- const e = o.scrollElement;
238
- if (!e)
239
- return;
240
- const t = o.targetWindow;
241
- if (!t)
242
- return;
243
- const n = (r) => {
244
- const { width: a, height: l } = r;
245
- s({ width: Math.round(a), height: Math.round(l) });
246
- };
247
- if (n(je(e)), !t.ResizeObserver)
248
- return () => {
249
- };
250
- const i = new t.ResizeObserver((r) => {
251
- const a = () => {
252
- const l = r[0];
253
- if (l?.borderBoxSize) {
254
- const d = l.borderBoxSize[0];
255
- if (d) {
256
- n({ width: d.inlineSize, height: d.blockSize });
257
- return;
258
- }
259
- }
260
- n(je(e));
261
- };
262
- o.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
263
- });
264
- return i.observe(e, { box: "border-box" }), () => {
265
- i.unobserve(e);
266
- };
267
- }, We = {
268
- passive: !0
269
- }, Ke = typeof window > "u" ? !0 : "onscrollend" in window, vn = (o, s) => {
270
- const e = o.scrollElement;
271
- if (!e)
272
- return;
273
- const t = o.targetWindow;
274
- if (!t)
275
- return;
276
- let n = 0;
277
- const i = o.options.useScrollendEvent && Ke ? () => {
278
- } : mn(
279
- t,
280
- () => {
281
- s(n, !1);
282
- },
283
- o.options.isScrollingResetDelay
284
- ), r = (h) => () => {
285
- const { horizontal: p, isRtl: u } = o.options;
286
- n = p ? e.scrollLeft * (u && -1 || 1) : e.scrollTop, i(), s(n, h);
287
- }, a = r(!0), l = r(!1);
288
- e.addEventListener("scroll", a, We);
289
- const d = o.options.useScrollendEvent && Ke;
290
- return d && e.addEventListener("scrollend", l, We), () => {
291
- e.removeEventListener("scroll", a), d && e.removeEventListener("scrollend", l);
292
- };
293
- }, yn = (o, s, e) => {
294
- if (s?.borderBoxSize) {
295
- const t = s.borderBoxSize[0];
296
- if (t)
297
- return Math.round(
298
- t[e.options.horizontal ? "inlineSize" : "blockSize"]
299
- );
300
- }
301
- return o[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
302
- }, Cn = (o, {
303
- adjustments: s = 0,
304
- behavior: e
305
- }, t) => {
306
- var n, i;
307
- const r = o + s;
308
- (i = (n = t.scrollElement) == null ? void 0 : n.scrollTo) == null || i.call(n, {
309
- [t.options.horizontal ? "left" : "top"]: r,
310
- behavior: e
311
- });
312
- };
313
- class xn {
314
- constructor(s) {
315
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
316
- let e = null;
317
- const t = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((n) => {
318
- n.forEach((i) => {
319
- const r = () => {
320
- this._measureElement(i.target, i);
321
- };
322
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
323
- });
324
- }));
325
- return {
326
- disconnect: () => {
327
- var n;
328
- (n = t()) == null || n.disconnect(), e = null;
329
- },
330
- observe: (n) => {
331
- var i;
332
- return (i = t()) == null ? void 0 : i.observe(n, { box: "border-box" });
333
- },
334
- unobserve: (n) => {
335
- var i;
336
- return (i = t()) == null ? void 0 : i.unobserve(n);
337
- }
338
- };
339
- })(), this.range = null, this.setOptions = (e) => {
340
- Object.entries(e).forEach(([t, n]) => {
341
- typeof n > "u" && delete e[t];
342
- }), this.options = {
343
- debug: !1,
344
- initialOffset: 0,
345
- overscan: 1,
346
- paddingStart: 0,
347
- paddingEnd: 0,
348
- scrollPaddingStart: 0,
349
- scrollPaddingEnd: 0,
350
- horizontal: !1,
351
- getItemKey: pn,
352
- rangeExtractor: bn,
353
- onChange: () => {
354
- },
355
- measureElement: yn,
356
- initialRect: { width: 0, height: 0 },
357
- scrollMargin: 0,
358
- gap: 0,
359
- indexAttribute: "data-index",
360
- initialMeasurementsCache: [],
361
- lanes: 1,
362
- isScrollingResetDelay: 150,
363
- enabled: !0,
364
- isRtl: !1,
365
- useScrollendEvent: !1,
366
- useAnimationFrameWithResizeObserver: !1,
367
- ...e
368
- };
369
- }, this.notify = (e) => {
370
- var t, n;
371
- (n = (t = this.options).onChange) == null || n.call(t, this, e);
372
- }, this.maybeNotify = G(
373
- () => (this.calculateRange(), [
374
- this.isScrolling,
375
- this.range ? this.range.startIndex : null,
376
- this.range ? this.range.endIndex : null
377
- ]),
378
- (e) => {
379
- this.notify(e);
380
- },
381
- {
382
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
383
- debug: () => this.options.debug,
384
- initialDeps: [
385
- this.isScrolling,
386
- this.range ? this.range.startIndex : null,
387
- this.range ? this.range.endIndex : null
388
- ]
389
- }
390
- ), this.cleanup = () => {
391
- this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
392
- }, this._didMount = () => () => {
393
- this.cleanup();
394
- }, this._willUpdate = () => {
395
- var e;
396
- const t = this.options.enabled ? this.options.getScrollElement() : null;
397
- if (this.scrollElement !== t) {
398
- if (this.cleanup(), !t) {
399
- this.maybeNotify();
400
- return;
401
- }
402
- this.scrollElement = t, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((n) => {
403
- this.observer.observe(n);
404
- }), this.unsubs.push(
405
- this.options.observeElementRect(this, (n) => {
406
- this.scrollRect = n, this.maybeNotify();
407
- })
408
- ), this.unsubs.push(
409
- this.options.observeElementOffset(this, (n, i) => {
410
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < n ? "forward" : "backward" : null, this.scrollOffset = n, this.isScrolling = i, this.maybeNotify();
411
- })
412
- ), this._scrollToOffset(this.getScrollOffset(), {
413
- adjustments: void 0,
414
- behavior: void 0
415
- });
416
- }
417
- }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, t) => {
418
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
419
- for (let r = t - 1; r >= 0; r--) {
420
- const a = e[r];
421
- if (n.has(a.lane))
422
- continue;
423
- const l = i.get(
424
- a.lane
425
- );
426
- if (l == null || a.end > l.end ? i.set(a.lane, a) : a.end < l.end && n.set(a.lane, !0), n.size === this.options.lanes)
427
- break;
428
- }
429
- return i.size === this.options.lanes ? Array.from(i.values()).sort((r, a) => r.end === a.end ? r.index - a.index : r.end - a.end)[0] : void 0;
430
- }, this.getMeasurementOptions = G(
431
- () => [
432
- this.options.count,
433
- this.options.paddingStart,
434
- this.options.scrollMargin,
435
- this.options.getItemKey,
436
- this.options.enabled,
437
- this.options.lanes
438
- ],
439
- (e, t, n, i, r, a) => (this.prevLanes !== void 0 && this.prevLanes !== a && (this.lanesChangedFlag = !0), this.prevLanes = a, this.pendingMeasuredCacheIndexes = [], {
440
- count: e,
441
- paddingStart: t,
442
- scrollMargin: n,
443
- getItemKey: i,
444
- enabled: r,
445
- lanes: a
446
- }),
447
- {
448
- key: !1
449
- }
450
- ), this.getMeasurements = G(
451
- () => [this.getMeasurementOptions(), this.itemSizeCache],
452
- ({ count: e, paddingStart: t, scrollMargin: n, getItemKey: i, enabled: r, lanes: a }, l) => {
453
- if (!r)
454
- return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
455
- if (this.laneAssignments.size > e)
456
- for (const u of this.laneAssignments.keys())
457
- u >= e && this.laneAssignments.delete(u);
458
- this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((u) => {
459
- this.itemSizeCache.set(u.key, u.size);
460
- }));
461
- const d = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
462
- this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
463
- const h = this.measurementsCache.slice(0, d), p = new Array(a).fill(
464
- void 0
465
- );
466
- for (let u = 0; u < d; u++) {
467
- const f = h[u];
468
- f && (p[f.lane] = u);
469
- }
470
- for (let u = d; u < e; u++) {
471
- const f = i(u), g = this.laneAssignments.get(u);
472
- let y, C;
473
- if (g !== void 0 && this.options.lanes > 1) {
474
- y = g;
475
- const x = p[y], O = x !== void 0 ? h[x] : void 0;
476
- C = O ? O.end + this.options.gap : t + n;
477
- } else {
478
- const x = this.options.lanes === 1 ? h[u - 1] : this.getFurthestMeasurement(h, u);
479
- C = x ? x.end + this.options.gap : t + n, y = x ? x.lane : u % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(u, y);
480
- }
481
- const b = l.get(f), m = typeof b == "number" ? b : this.options.estimateSize(u), v = C + m;
482
- h[u] = {
483
- index: u,
484
- start: C,
485
- size: m,
486
- end: v,
487
- key: f,
488
- lane: y
489
- }, p[y] = u;
490
- }
491
- return this.measurementsCache = h, h;
492
- },
493
- {
494
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
495
- debug: () => this.options.debug
496
- }
497
- ), this.calculateRange = G(
498
- () => [
499
- this.getMeasurements(),
500
- this.getSize(),
501
- this.getScrollOffset(),
502
- this.options.lanes
503
- ],
504
- (e, t, n, i) => this.range = e.length > 0 && t > 0 ? wn({
505
- measurements: e,
506
- outerSize: t,
507
- scrollOffset: n,
508
- lanes: i
509
- }) : null,
510
- {
511
- key: process.env.NODE_ENV !== "production" && "calculateRange",
512
- debug: () => this.options.debug
513
- }
514
- ), this.getVirtualIndexes = G(
515
- () => {
516
- let e = null, t = null;
517
- const n = this.calculateRange();
518
- return n && (e = n.startIndex, t = n.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, t]), [
519
- this.options.rangeExtractor,
520
- this.options.overscan,
521
- this.options.count,
522
- e,
523
- t
524
- ];
525
- },
526
- (e, t, n, i, r) => i === null || r === null ? [] : e({
527
- startIndex: i,
528
- endIndex: r,
529
- overscan: t,
530
- count: n
531
- }),
532
- {
533
- key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
534
- debug: () => this.options.debug
535
- }
536
- ), this.indexFromElement = (e) => {
537
- const t = this.options.indexAttribute, n = e.getAttribute(t);
538
- return n ? parseInt(n, 10) : (console.warn(
539
- `Missing attribute name '${t}={index}' on measured element.`
540
- ), -1);
541
- }, this._measureElement = (e, t) => {
542
- const n = this.indexFromElement(e), i = this.measurementsCache[n];
543
- if (!i)
544
- return;
545
- const r = i.key, a = this.elementsCache.get(r);
546
- a !== e && (a && this.observer.unobserve(a), this.observer.observe(e), this.elementsCache.set(r, e)), e.isConnected && this.resizeItem(n, this.options.measureElement(e, t, this));
547
- }, this.resizeItem = (e, t) => {
548
- const n = this.measurementsCache[e];
549
- if (!n)
550
- return;
551
- const i = this.itemSizeCache.get(n.key) ?? n.size, r = t - i;
552
- r !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(n, r, this) : n.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", r), this._scrollToOffset(this.getScrollOffset(), {
553
- adjustments: this.scrollAdjustments += r,
554
- behavior: void 0
555
- })), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, t)), this.notify(!1));
556
- }, this.measureElement = (e) => {
557
- if (!e) {
558
- this.elementsCache.forEach((t, n) => {
559
- t.isConnected || (this.observer.unobserve(t), this.elementsCache.delete(n));
560
- });
561
- return;
562
- }
563
- this._measureElement(e, void 0);
564
- }, this.getVirtualItems = G(
565
- () => [this.getVirtualIndexes(), this.getMeasurements()],
566
- (e, t) => {
567
- const n = [];
568
- for (let i = 0, r = e.length; i < r; i++) {
569
- const a = e[i], l = t[a];
570
- n.push(l);
571
- }
572
- return n;
573
- },
574
- {
575
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
576
- debug: () => this.options.debug
577
- }
578
- ), this.getVirtualItemForOffset = (e) => {
579
- const t = this.getMeasurements();
580
- if (t.length !== 0)
581
- return $e(
582
- t[Ge(
583
- 0,
584
- t.length - 1,
585
- (n) => $e(t[n]).start,
586
- e
587
- )]
588
- );
589
- }, this.getMaxScrollOffset = () => {
590
- if (!this.scrollElement) return 0;
591
- if ("scrollHeight" in this.scrollElement)
592
- return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
593
- {
594
- const e = this.scrollElement.document.documentElement;
595
- return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
596
- }
597
- }, this.getOffsetForAlignment = (e, t, n = 0) => {
598
- if (!this.scrollElement) return 0;
599
- const i = this.getSize(), r = this.getScrollOffset();
600
- t === "auto" && (t = e >= r + i ? "end" : "start"), t === "center" ? e += (n - i) / 2 : t === "end" && (e -= i);
601
- const a = this.getMaxScrollOffset();
602
- return Math.max(Math.min(a, e), 0);
603
- }, this.getOffsetForIndex = (e, t = "auto") => {
604
- e = Math.max(0, Math.min(e, this.options.count - 1));
605
- const n = this.measurementsCache[e];
606
- if (!n)
607
- return;
608
- const i = this.getSize(), r = this.getScrollOffset();
609
- if (t === "auto")
610
- if (n.end >= r + i - this.options.scrollPaddingEnd)
611
- t = "end";
612
- else if (n.start <= r + this.options.scrollPaddingStart)
613
- t = "start";
614
- else
615
- return [r, t];
616
- if (t === "end" && e === this.options.count - 1)
617
- return [this.getMaxScrollOffset(), t];
618
- const a = t === "end" ? n.end + this.options.scrollPaddingEnd : n.start - this.options.scrollPaddingStart;
619
- return [
620
- this.getOffsetForAlignment(a, t, n.size),
621
- t
622
- ];
623
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: t = "start", behavior: n } = {}) => {
624
- n === "smooth" && this.isDynamicMode() && console.warn(
625
- "The `smooth` scroll behavior is not fully supported with dynamic size."
626
- ), this._scrollToOffset(this.getOffsetForAlignment(e, t), {
627
- adjustments: void 0,
628
- behavior: n
629
- });
630
- }, this.scrollToIndex = (e, { align: t = "auto", behavior: n } = {}) => {
631
- n === "smooth" && this.isDynamicMode() && console.warn(
632
- "The `smooth` scroll behavior is not fully supported with dynamic size."
633
- ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
634
- let i = 0;
635
- const r = 10, a = (d) => {
636
- if (!this.targetWindow) return;
637
- const h = this.getOffsetForIndex(e, d);
638
- if (!h) {
639
- console.warn("Failed to get offset for index:", e);
640
- return;
641
- }
642
- const [p, u] = h;
643
- this._scrollToOffset(p, { adjustments: void 0, behavior: n }), this.targetWindow.requestAnimationFrame(() => {
644
- const f = () => {
645
- if (this.currentScrollToIndex !== e) return;
646
- const g = this.getScrollOffset(), y = this.getOffsetForIndex(e, u);
647
- if (!y) {
648
- console.warn("Failed to get offset for index:", e);
649
- return;
650
- }
651
- fn(y[0], g) || l(u);
652
- };
653
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(f) : f();
654
- });
655
- }, l = (d) => {
656
- this.targetWindow && this.currentScrollToIndex === e && (i++, i < r ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, r), this.targetWindow.requestAnimationFrame(() => a(d))) : console.warn(
657
- `Failed to scroll to index ${e} after ${r} attempts.`
658
- ));
659
- };
660
- a(t);
661
- }, this.scrollBy = (e, { behavior: t } = {}) => {
662
- t === "smooth" && this.isDynamicMode() && console.warn(
663
- "The `smooth` scroll behavior is not fully supported with dynamic size."
664
- ), this._scrollToOffset(this.getScrollOffset() + e, {
665
- adjustments: void 0,
666
- behavior: t
667
- });
668
- }, this.getTotalSize = () => {
669
- var e;
670
- const t = this.getMeasurements();
671
- let n;
672
- if (t.length === 0)
673
- n = this.options.paddingStart;
674
- else if (this.options.lanes === 1)
675
- n = ((e = t[t.length - 1]) == null ? void 0 : e.end) ?? 0;
676
- else {
677
- const i = Array(this.options.lanes).fill(null);
678
- let r = t.length - 1;
679
- for (; r >= 0 && i.some((a) => a === null); ) {
680
- const a = t[r];
681
- i[a.lane] === null && (i[a.lane] = a.end), r--;
682
- }
683
- n = Math.max(...i.filter((a) => a !== null));
684
- }
685
- return Math.max(
686
- n - this.options.scrollMargin + this.options.paddingEnd,
687
- 0
688
- );
689
- }, this._scrollToOffset = (e, {
690
- adjustments: t,
691
- behavior: n
692
- }) => {
693
- this.options.scrollToFn(e, { behavior: n, adjustments: t }, this);
694
- }, this.measure = () => {
695
- this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
696
- }, this.setOptions(s);
697
- }
698
- }
699
- const Ge = (o, s, e, t) => {
700
- for (; o <= s; ) {
701
- const n = (o + s) / 2 | 0, i = e(n);
702
- if (i < t)
703
- o = n + 1;
704
- else if (i > t)
705
- s = n - 1;
706
- else
707
- return n;
708
- }
709
- return o > 0 ? o - 1 : 0;
710
- };
711
- function wn({
712
- measurements: o,
713
- outerSize: s,
714
- scrollOffset: e,
715
- lanes: t
716
- }) {
717
- const n = o.length - 1, i = (l) => o[l].start;
718
- if (o.length <= t)
719
- return {
720
- startIndex: 0,
721
- endIndex: n
722
- };
723
- let r = Ge(
724
- 0,
725
- n,
726
- i,
727
- e
728
- ), a = r;
729
- if (t === 1)
730
- for (; a < n && o[a].end < e + s; )
731
- a++;
732
- else if (t > 1) {
733
- const l = Array(t).fill(0);
734
- for (; a < n && l.some((h) => h < e + s); ) {
735
- const h = o[a];
736
- l[h.lane] = h.end, a++;
737
- }
738
- const d = Array(t).fill(e + s);
739
- for (; r >= 0 && d.some((h) => h >= e); ) {
740
- const h = o[r];
741
- d[h.lane] = h.start, r--;
742
- }
743
- r = Math.max(0, r - r % t), a = Math.min(n, a + (t - 1 - a % t));
744
- }
745
- return { startIndex: r, endIndex: a };
746
- }
747
- const He = typeof document < "u" ? le.useLayoutEffect : le.useEffect;
748
- function On({
749
- useFlushSync: o = !0,
750
- ...s
751
- }) {
752
- const e = le.useReducer(() => ({}), {})[1], t = {
753
- ...s,
754
- onChange: (i, r) => {
755
- var a;
756
- o && r ? Ue(e) : e(), (a = s.onChange) == null || a.call(s, i, r);
757
- }
758
- }, [n] = le.useState(
759
- () => new xn(t)
760
- );
761
- return n.setOptions(t), He(() => n._didMount(), []), He(() => n._willUpdate()), n;
762
- }
763
- function En(o) {
764
- return On({
765
- observeElementRect: gn,
766
- observeElementOffset: vn,
767
- scrollToFn: Cn,
768
- ...o
769
- });
770
- }
771
- const Je = ({ size: o, error: s, formFieldProps: e }) => c("div", { className: "ds-combobox__error-message", id: e.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: s && c(_e, { "data-size": o, children: s }) });
772
- Je.displayName = "ComboboxError";
773
- const Qe = w(function({ asChild: s, className: e, ...t }, n) {
774
- return c(s ? M : "button", { className: E("ds-chip", e), type: s ? void 0 : "button", ref: n, ...t });
775
- }), Ze = w(function(s, e) {
776
- return c(Qe, { "data-removable": !0, ref: e, ...s });
777
- }), et = w(function({ asChild: s, children: e, className: t, "data-size": n, "data-color": i, ...r }, a) {
778
- const l = r.type ?? "checkbox";
779
- return N(s ? M : "label", { className: E("ds-chip", t), "data-size": n, "data-color": i, ref: a, children: [c(Me, { ...r, type: l }), c(_t, { children: e })] });
780
- }), In = w(function(s, e) {
781
- return c(et, { ref: e, type: "radio", ...s });
782
- }), ue = {
783
- Button: Qe,
784
- Checkbox: et,
785
- Radio: In,
786
- Removable: Ze
787
- };
788
- ue.Button.displayName = "Chip.Button";
789
- ue.Checkbox.displayName = "Chip.Checkbox";
790
- ue.Radio.displayName = "Chip.Radio";
791
- ue.Removable.displayName = "Chip.Removable";
792
- const tt = () => {
793
- const o = R(q);
794
- if (!o)
795
- throw new Error("ComboboxContext is missing");
796
- const { size: s, readOnly: e, disabled: t, selectedOptions: n, chipSrLabel: i, handleSelectOption: r, inputRef: a } = o;
797
- return c(Ie, { children: Object.keys(n).map((l) => c(Ze, { "data-size": s, disabled: t, onKeyDown: (d) => {
798
- e || t || d.key === "Enter" && (d.stopPropagation(), r({
799
- option: n[l],
800
- remove: !0
801
- }), a?.current?.focus());
802
- }, onClick: () => {
803
- e || t || r({
804
- option: n[l],
805
- remove: !0
806
- });
807
- }, "aria-label": i(n[l]), children: n[l].label }, l)) });
808
- };
809
- tt.displayName = "ComboboxChips";
810
- const nt = w((o, s) => {
811
- const e = R(q);
812
- if (!e)
813
- throw new Error("ComboboxContext is missing");
814
- const { readOnly: t, disabled: n, clearButtonLabel: i, handleSelectOption: r } = e;
815
- return c("button", { ...o, ref: s, disabled: n, className: E("ds-combobox__clear-button", "ds-focus"), onClick: () => {
816
- t || n || r({ option: null, clear: !0 });
817
- }, onKeyDown: (a) => {
818
- t || n || a.key === "Enter" && (a.stopPropagation(), r({ option: null, clear: !0 }));
819
- }, type: "button", "aria-label": i, children: c(qt, { fontSize: "1.5em", title: "Clear selection" }) });
820
- });
821
- nt.displayName = "ComboboxClearButton";
822
- const ot = ({ hideClearButton: o, listId: s, error: e, hideChips: t, handleKeyDown: n, ...i }) => {
823
- const r = R(q), a = Se(), l = F(null);
824
- if (!r)
825
- throw new Error("ComboboxContext is missing");
826
- const d = (T) => {
827
- a?.({ type: "SET_ACTIVE_INDEX", payload: T });
828
- }, { forwareddRef: h, readOnly: p, disabled: u, open: f, inputRef: g, refs: y, inputValue: C, multiple: b, selectedOptions: m, formFieldProps: v, htmlSize: x, options: O, setOpen: S, getReferenceProps: k, setInputValue: B, handleSelectOption: L, size: $ } = r, V = qe([h, g]), ie = (T) => {
829
- const X = T.target.value;
830
- B(X), d(0);
831
- for (const Y of Object.values(O))
832
- if (Y.label.toLowerCase() === X.toLowerCase()) {
833
- if (m[P(Y.value)])
834
- continue;
835
- L({ option: Y });
836
- }
837
- }, z = !o && Object.keys(m).length > 0, Z = k({
838
- ref: y?.setReference,
839
- role: null,
840
- "aria-controls": null,
841
- "aria-expanded": null,
842
- "aria-haspopup": null,
843
- /* If we click the wrapper, toggle open, set index to first option, and focus the input */
844
- onClick(T) {
845
- u || p || l.current?.contains(T.target) || (S(!f), d(0), g.current?.focus());
846
- },
847
- /* Handles list navigation */
848
- onKeyDown: n,
849
- // preventDefault on keydown to avoid sending in form
850
- onKeyPress(T) {
851
- T.key === "Enter" && T.preventDefault();
852
- }
853
- });
854
- return c(Ee, { "data-size": $, asChild: !0, children: N("div", { ...Z, "aria-disabled": u ? "true" : void 0, className: E("ds-textfield__input", "ds-combobox__input__wrapper", p && "ds-combobox--readonly", e && "ds-combobox--error"), children: [N("div", { className: "ds-combobox__chip-and-input", children: [b && !t && c(tt, {}), c(Ee, { "data-size": $, asChild: !0, children: c("input", { ref: V, "aria-activedescendant": Z["aria-activedescendant"], readOnly: p, "aria-autocomplete": "list", role: "combobox", "aria-expanded": f, "aria-controls": f ? s : void 0, autoComplete: "off", size: x, value: C, ...ce(["style", "className"], i), ...v.inputProps, className: "ds-combobox__input", onChange: (T) => {
855
- ie(T), !f && S(!0), i.onChange?.(T);
856
- } }) })] }), z && c(nt, { ref: l }), c("div", { className: "ds-combobox__arrow", children: f ? c(Ut, { title: "arrow up", fontSize: "1.5em" }) : c(Xt, { title: "arrow down", fontSize: "1.5em" }) })] }) });
857
- };
858
- ot.displayName = "ComboboxInput";
859
- const st = ({ label: o, description: s, hideLabel: e, size: t, readOnly: n, formFieldProps: i }) => N(Ie, { children: [o && N(H, { "data-size": t, htmlFor: i.inputProps.id, className: E("ds-combobox__label", e && "ds-sr-only"), children: [n && c(on, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), o] }), s && c(Ee, { asChild: !0, "data-size": t, children: c("div", { id: i.descriptionId, className: E("ds-combobox__description", e && "ds-sr-only"), children: s }) })] });
860
- st.displayName = "ComboboxLabel";
861
- const it = ({ selectedOptions: o, multiple: s, name: e }) => {
862
- const t = Object.keys(o).map((n) => we(n));
863
- return c("select", { name: e, multiple: s, style: { display: "none" }, value: s ? t : t[0], onChange: () => {
864
- }, children: t.map((n) => c("option", { value: n }, n)) });
865
- };
866
- it.displayName = "ComboboxNative";
867
- const rt = w(({ children: o, className: s, ...e }, t) => c("span", { className: E("ds-combobox__option__description", s), ref: t, ...e, children: o }));
868
- rt.displayName = "ComboboxOptionDescription";
869
- const at = ({ multiple: o, selected: s }) => c("div", { className: E(o && "ds-combobox__option__icon-wrapper", s && "ds-combobox__option__icon-wrapper--selected"), children: s && c(Gt, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
870
- at.displayName = "SelectedIcon";
871
- const Sn = ({ id: o, ref: s, value: e }) => {
872
- const t = Q(), n = o || t, i = R(q), { activeIndex: r } = ke(), a = Se();
873
- if (!i)
874
- throw new Error("ComboboxOption must be used within a Combobox");
875
- const { selectedOptions: l, onOptionClick: d, setListRef: h, customIds: p, filteredOptions: u } = i, f = J(() => u.indexOf(P(String(e))) + p.length, [p.length, u, e]), g = qe([
876
- (m) => {
877
- h(f, m);
878
- },
879
- s
880
- ]);
881
- if (f === -1)
882
- throw new Error("Internal error: ComboboxOption did not find index");
883
- const y = l[P(e)], C = r === f;
884
- D(() => {
885
- C && a?.({ type: "SET_ACTIVE_INDEX", payload: f });
886
- }, [t, o, a, C, f]);
887
- const b = Ne(() => d(e), 50);
888
- return {
889
- id: n,
890
- ref: g,
891
- selected: y,
892
- active: C,
893
- onOptionClick: b
894
- };
895
- }, ze = It(w(({ value: o, description: s, children: e, className: t, ...n }, i) => {
896
- const r = Q(), { id: a, ref: l, selected: d, active: h, onOptionClick: p } = Sn({
897
- id: n.id,
898
- ref: i,
899
- value: o
900
- }), u = R(q);
901
- if (!u)
902
- throw new Error("ComboboxOption must be used within a Combobox");
903
- const { size: f, multiple: g, getItemProps: y } = u, C = y();
904
- return c(H, { "data-size": "md", asChild: !0, children: N("button", { ref: l, id: a, role: "option", type: "button", "aria-selected": !!d, "aria-labelledby": r, tabIndex: -1, onClick: (b) => {
905
- p(), n.onClick?.(b);
906
- }, className: E("ds-combobox__option", h && "ds-combobox__option--active", g && "ds-combobox__option--multiple", t), ...ce(["displayValue"], n), ...ce(["onClick", "onPointerLeave"], C), children: [c(H, { asChild: !0, "data-size": f, children: c("span", { children: c(at, { multiple: g, selected: !!d }) }) }), N(H, { className: "ds-combobox__option__label", "data-size": f, id: r, children: [e, s && c(rt, { children: s })] })] }) });
907
- }));
908
- ze.displayName = "ComboboxOption";
909
- function kn(o) {
910
- return Et(o) && o.type === ze;
911
- }
912
- const _n = (o) => !!o;
913
- function Nn({ children: o, inputValue: s, multiple: e, filter: t = (i, r) => r.label.toLowerCase().startsWith(i.toLowerCase()), initialValue: n }) {
914
- const i = St(t, [t]), { optionsChildren: r, customIds: a, restChildren: l, interactiveChildren: d } = J(() => Be.toArray(o).reduce((m, v) => {
915
- if (kn(v))
916
- m.optionsChildren.push(v);
917
- else if (m.restChildren.push(v), Nt(v)) {
918
- const x = v;
919
- if (m.interactiveChildren.push(x), !x.props.id)
920
- throw new Error("If ComboboxCustom is interactive, it must have an id");
921
- m.customIds.push(x.props.id);
922
- }
923
- return m;
924
- }, {
925
- optionsChildren: [],
926
- customIds: [],
927
- restChildren: [],
928
- interactiveChildren: []
929
- }), [o]), h = J(() => {
930
- const C = [], b = {};
931
- return r.map((m) => {
932
- const v = m.props;
933
- let x = v.displayValue || "";
934
- if (!v.displayValue) {
935
- let O = "";
936
- Be.forEach(v.children, (S) => {
937
- if (typeof S == "string")
938
- O += S;
939
- else
940
- throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
941
- }), x = O;
942
- }
943
- return C.includes(v.value) && console.warn(`Combobox has multiple options with the same value: ${v.value}`), C.push(v.value), b[P(String(v.value))] = {
944
- value: String(v.value),
945
- label: x,
946
- displayValue: v.displayValue,
947
- description: v.description
948
- }, null;
949
- }), b;
950
- }, [r]), p = J(() => (n?.map((C) => P(C)) || []).reduce((C, b) => {
951
- const m = h[b];
952
- return _n(m) && (C[b] = m), C;
953
- }, {}), [n, h]), [u, f] = A(p), { filteredOptions: g, filteredOptionsChildren: y } = J(() => {
954
- const C = [], b = Object.keys(h).map((m, v) => !e && Object.keys(u).length === 1 || e && u[m] || i(s, h[m]) ? (C.push(m), r[v]) : null).filter((m) => m);
955
- return { filteredOptions: C, filteredOptionsChildren: b };
956
- }, [
957
- i,
958
- s,
959
- e,
960
- h,
961
- r,
962
- u
963
- ]);
964
- return {
965
- filteredOptionsChildren: y,
966
- filteredOptions: g,
967
- restChildren: l,
968
- options: h,
969
- customIds: a,
970
- selectedOptions: u,
971
- interactiveChildren: d,
972
- setSelectedOptions: f
973
- };
974
- }
975
- const Mn = ({ readOnly: o, disabled: s, interactiveChildren: e, filteredOptions: t, inputValue: n, selectedOptions: i, multiple: r, open: a, options: l, setOpen: d, handleSelectOption: h }) => {
976
- const { activeIndex: p } = ke();
977
- return Ne((g) => {
978
- if (!(o || s) && g)
979
- switch (g.key) {
980
- case "ArrowDown":
981
- if (g.preventDefault(), a)
982
- break;
983
- d(!0);
984
- break;
985
- case "ArrowUp":
986
- if (g.preventDefault(), p !== 0)
987
- break;
988
- d(!1);
989
- break;
990
- case "Enter": {
991
- if (g.preventDefault(), !a)
992
- break;
993
- if (p <= e.length - 1) {
994
- const b = e[p];
995
- if (b.props.onSelect) {
996
- b?.props.onSelect();
997
- return;
998
- }
999
- }
1000
- const y = p - e.length, C = t[y];
1001
- h({ option: l[C] });
1002
- break;
1003
- }
1004
- case "Backspace":
1005
- if (!r) {
1006
- const y = Object.keys(i).pop();
1007
- y && h({
1008
- option: i[y],
1009
- remove: !0
1010
- });
1011
- break;
1012
- }
1013
- if (n === "" && r) {
1014
- const y = Object.keys(i).pop();
1015
- y && h({
1016
- option: i[y],
1017
- remove: !0
1018
- });
1019
- }
1020
- break;
1021
- }
1022
- }, 20);
1023
- }, zn = ({ listRef: o }) => {
1024
- const [s, e] = A(!1), { activeIndex: t } = ke(), n = Se(), { refs: i, floatingStyles: r, context: a } = Mt({
1025
- open: s,
1026
- onOpenChange: (g) => {
1027
- g || n?.({ type: "SET_ACTIVE_INDEX", payload: 0 }), Ue(() => {
1028
- i.floating.current && !g && (i.floating.current.scrollTop = 0), setTimeout(() => {
1029
- e(g);
1030
- }, 1);
1031
- });
1032
- },
1033
- whileElementsMounted: (g, y, C) => (Xe(g, y, C), () => {
1034
- y.scrollTop = 0;
1035
- }),
1036
- middleware: [
1037
- zt({ padding: 10 }),
1038
- Tt({
1039
- apply({ rects: g, elements: y }) {
1040
- requestAnimationFrame(() => {
1041
- Object.assign(y.floating.style, {
1042
- width: `${g.reference.width}px`,
1043
- maxHeight: "200px"
1044
- });
1045
- });
1046
- }
1047
- }),
1048
- Rt(10)
1049
- ]
1050
- }), l = Pt(a, { role: "listbox" }), d = Dt(a), h = Ft(a, {
1051
- listRef: o,
1052
- activeIndex: t,
1053
- virtual: !0,
1054
- scrollItemIntoView: !0,
1055
- enabled: s,
1056
- focusItemOnHover: !0,
1057
- onNavigate: (g) => {
1058
- n?.({ type: "SET_ACTIVE_INDEX", payload: g || 0 });
1059
- }
1060
- }), { getReferenceProps: p, getFloatingProps: u, getItemProps: f } = At([l, d, h]);
1061
- return {
1062
- open: s,
1063
- setOpen: e,
1064
- activeIndex: t,
1065
- refs: i,
1066
- floatingStyles: r,
1067
- context: a,
1068
- getReferenceProps: p,
1069
- getFloatingProps: u,
1070
- getItemProps: f
1071
- };
1072
- }, Tn = se(null), Rn = (o, s) => {
1073
- const e = R(Tn), t = Q(), n = o.id ?? `${s}-${t}`, i = o.errorId ?? `${s}-error-${t}`, r = `${s}-description-${t}`, a = o.size ?? e?.size ?? "md", l = e?.disabled || o?.disabled, d = !l && !!(o.error || e?.error);
1074
- return {
1075
- hasError: d,
1076
- errorId: i,
1077
- descriptionId: r,
1078
- size: a,
1079
- inputProps: {
1080
- id: n,
1081
- disabled: l,
1082
- "aria-invalid": d ? !0 : void 0,
1083
- "aria-describedby": E(o["aria-describedby"], !!o?.description && typeof o?.description == "string" && r, d && !e?.error && i, d && !!e?.error && e?.errorId) || void 0
1084
- }
1085
- };
1086
- }, Pn = w(({ value: o, initialValue: s = [], onValueChange: e, label: t, hideLabel: n = !1, description: i, multiple: r = !1, disabled: a = !1, readOnly: l = !1, hideChips: d = !1, clearButtonLabel: h = "Fjern alt", hideClearButton: p = !1, error: u, errorId: f, id: g, name: y, portal: C = !0, htmlSize: b = 0, virtual: m = !1, children: v, style: x, size: O = "md", loading: S, loadingLabel: k = "Laster...", filter: B, chipSrLabel: L = (z) => "Slett " + z.label, className: $, ...V }, ie) => {
1087
- const z = F(null), Z = F(null), T = F([]), [X, Y] = A(V.inputValue || "");
1088
- D(() => {
1089
- typeof V.inputValue == "string" && Y(V.inputValue);
1090
- }, [V.inputValue]);
1091
- const { selectedOptions: ee, options: j, restChildren: mt, interactiveChildren: pt, customIds: bt, filteredOptionsChildren: me, filteredOptions: Ae, setSelectedOptions: te } = Nn({
1092
- children: v,
1093
- inputValue: X,
1094
- filter: B,
1095
- multiple: r,
1096
- initialValue: s
1097
- }), { open: pe, setOpen: be, refs: re, floatingStyles: gt, context: Le, getReferenceProps: vt, getFloatingProps: yt, getItemProps: Ct } = zn({
1098
- listRef: T
1099
- }), ne = Rn({
1100
- disabled: a,
1101
- error: u,
1102
- errorId: f,
1103
- size: O,
1104
- description: i,
1105
- id: g
1106
- }, "combobox");
1107
- D(() => {
1108
- if (o && o.length > 0 && !r) {
1109
- const _ = j[P(o[0])];
1110
- z.current && ae(z.current, _?.label || "");
1111
- }
1112
- }, [r, o, j]), D(() => {
1113
- if (o && Object.keys(j).length >= 0) {
1114
- const _ = o.map((I) => j[P(I)]);
1115
- te(_.reduce((I, oe) => (I[P(oe.value)] = oe, I), {}));
1116
- }
1117
- }, [r, o, j, te]);
1118
- const ge = Ne((_) => {
1119
- const { option: I, clear: oe, remove: wt } = _;
1120
- if (oe) {
1121
- te({}), z.current && ae(z.current, ""), e?.([]);
1122
- return;
1123
- }
1124
- if (!I)
1125
- return;
1126
- if (wt) {
1127
- const K = { ...ee };
1128
- delete K[P(I.value)], te(K), e?.(Object.keys(K).map((Ot) => we(Ot)));
1129
- return;
1130
- }
1131
- const W = { ...ee };
1132
- if (r)
1133
- W[P(I.value)] ? delete W[P(I.value)] : W[P(I.value)] = I, z.current && ae(z.current, ""), z.current?.focus();
1134
- else {
1135
- for (const K of Object.keys(W))
1136
- delete W[K];
1137
- W[P(I.value)] = I, z.current && ae(z.current, I?.label || ""), setTimeout(() => {
1138
- z.current?.setSelectionRange(I?.label?.length || 0, I?.label?.length || 0);
1139
- }, 0);
1140
- }
1141
- te(W), e?.(Object.keys(W).map((K) => we(K))), !r && be(!1), re.domReference.current?.focus();
1142
- }, 50), xt = Mn({
1143
- filteredOptions: Ae,
1144
- selectedOptions: ee,
1145
- readOnly: ne.readOnly || !1,
1146
- disabled: a,
1147
- multiple: r,
1148
- inputValue: X,
1149
- options: j,
1150
- open: pe,
1151
- interactiveChildren: pt,
1152
- setOpen: be,
1153
- handleSelectOption: ge
1154
- }), ve = En({
1155
- count: Object.keys(me).length,
1156
- getScrollElement: () => m ? re.floating.current : null,
1157
- estimateSize: () => 70,
1158
- measureElement: (_) => _.getBoundingClientRect().height,
1159
- overscan: 7
1160
- });
1161
- return N(q.Provider, { value: {
1162
- size: O,
1163
- options: j,
1164
- selectedOptions: ee,
1165
- multiple: r,
1166
- disabled: a,
1167
- readOnly: l,
1168
- open: pe,
1169
- inputRef: z,
1170
- refs: re,
1171
- inputValue: X,
1172
- formFieldProps: ne,
1173
- htmlSize: b,
1174
- clearButtonLabel: h,
1175
- customIds: bt,
1176
- filteredOptions: Ae,
1177
- setInputValue: Y,
1178
- setOpen: be,
1179
- getReferenceProps: vt,
1180
- getItemProps: Ct,
1181
- /* Recieves the value of the option, and searches for it in our values lookup */
1182
- onOptionClick: (_) => {
1183
- if (l || a)
1184
- return;
1185
- const I = j[P(_)];
1186
- ge({ option: I });
1187
- },
1188
- handleSelectOption: ge,
1189
- chipSrLabel: L,
1190
- listRef: T,
1191
- forwareddRef: ie,
1192
- setListRef: (_, I) => {
1193
- T.current[_] = I;
1194
- }
1195
- }, children: [N("div", { className: E("ds-combobox", `ds-combobox--${O}`, a && "ds-combobox__disabled", $), style: x, ref: Z, children: [y && c(it, { name: y, selectedOptions: ee, multiple: r }), c(st, { label: t, description: i, size: O, readOnly: l, hideLabel: n, formFieldProps: ne }), c(ot, { ...ce(["inputValue"], V), hideClearButton: p, listId: Le.floatingId || "", error: u, hideChips: d, handleKeyDown: xt, "aria-busy": S }), c(Je, { size: O, error: u, formFieldProps: ne })] }), pe && c(Bt, { root: C ? null : Z, children: c(Vt, { context: Le, initialFocus: -1, visuallyHiddenDismiss: !0, children: N("div", { "aria-labelledby": ne.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...yt({
1196
- ref: re.setFloating,
1197
- style: {
1198
- ...gt
1199
- }
1200
- }), className: E("ds-combobox__options-wrapper", `ds-combobox--${O}`), children: [m && c("div", { style: {
1201
- height: `${ve.getTotalSize()}px`,
1202
- width: "100%",
1203
- position: "relative"
1204
- }, children: ve.getVirtualItems().map((_) => c("div", { ref: ve.measureElement, "data-index": _.index, style: {
1205
- position: "absolute",
1206
- top: 0,
1207
- left: 0,
1208
- width: "100%",
1209
- transform: `translateY(${_.start}px)`
1210
- }, children: me[_.index] }, _.index)) }), S ? N($t, { className: "ds-combobox__loading", children: [c(jt, { "aria-label": "Laster", "data-size": "sm" }), k] }) : N(Ie, { children: [mt, !m && me] })] }) }) })] });
1211
- }), lt = w((o, s) => c(Lt, { children: c(Pn, { ...o, ref: s }) }));
1212
- lt.displayName = "Combobox";
1213
- const ct = w(({ children: o, className: s, ...e }, t) => {
1214
- const n = R(q);
1215
- if (!n)
1216
- throw new Error("ComboboxEmpty must be used within a Combobox");
1217
- const { filteredOptions: i, size: r } = n;
1218
- return i.length === 0 && c(H, { "data-size": r, asChild: !0, children: c("div", { ref: t, className: E("ds-combobox__empty", s), ...e, children: o }) });
1219
- });
1220
- ct.displayName = "ComboboxEmpty";
1221
- const he = lt;
1222
- he.Option = ze;
1223
- he.Empty = ct;
1224
- he.Option.displayName = "Combobox.Option";
1225
- he.Empty.displayName = "Combobox.Empty";
1226
- const bo = w(function({ "data-size": s, className: e, style: t, children: n, label: i, description: r, error: a, ...l }, d) {
1227
- return N(Oe, { "data-size": s, className: e, style: t, children: [c(Me, { type: "checkbox", ref: d, ...l }), !!i && c(H, { weight: "regular", children: i }), !!r && c("div", { "data-field": "description", children: r }), !!a && c(_e, { children: a })] });
1228
- }), Te = se({
1229
- current: null
1230
- }), dt = ({ children: o }) => {
1231
- const s = F(null);
1232
- return c(Te.Provider, { value: s, children: o });
1233
- };
1234
- dt.displayName = "DialogTriggerContext";
1235
- const Dn = w(function({ asChild: s, children: e, className: t, placement: n = "center", closeButton: i = "Lukk dialogvindu", closedby: r = "closerequest", modal: a = !0, onClose: l, open: d, ...h }, p) {
1236
- const u = R(Te), f = F(null), g = s ? M : "dialog", y = U([u, p, f]), C = a ? "showModal" : "show";
1237
- return D(() => f.current?.[d ? C : "close"](), [d]), D(() => {
1238
- const b = f.current, m = (x) => {
1239
- if (x.defaultPrevented)
1240
- return;
1241
- const { clientY: O, clientX: S, target: k } = x;
1242
- if (k instanceof Element && x.type === "click" && k.closest('[data-command="close"]'))
1243
- return b?.close();
1244
- if (!(b && "closedBy" in b)) {
1245
- if (x instanceof KeyboardEvent)
1246
- return r === "none" && x.key === "Escape" && x.preventDefault();
1247
- if (!window.getSelection()?.toString() && b && k === b && r === "any") {
1248
- const { top: B, left: L, right: $, bottom: V } = b.getBoundingClientRect();
1249
- B <= O && O <= V && L <= S && S <= $ || b?.close();
1250
- }
1251
- }
1252
- }, v = () => {
1253
- const x = b?.querySelector("[autofocus]");
1254
- document.activeElement !== x && x?.focus();
1255
- };
1256
- return b?.addEventListener("animationend", v), b?.addEventListener("click", m), b?.addEventListener("keydown", m), () => {
1257
- b?.removeEventListener("animationend", v), b?.removeEventListener("click", m), b?.removeEventListener("keydown", m);
1258
- };
1259
- }, [r]), D(() => {
1260
- const b = (v) => l?.(v), m = f.current;
1261
- return m?.addEventListener("close", b), () => m?.removeEventListener("close", b);
1262
- }, [l]), N(g, { className: E("ds-dialog", t), ref: y, "data-placement": n, "data-modal": a, closedby: r, ...h, children: [i !== !1 && c(de, { "aria-label": i, "data-color": "neutral", icon: !0, variant: "tertiary", "data-command": "close" }), e] });
1263
- }), Fn = w(function({ asChild: s, className: e, ...t }, n) {
1264
- return c(s ? M : "div", { className: E("ds-dialog__block", e), ref: n, ...t });
1265
- }), An = w(function({ asChild: s, ...e }, t) {
1266
- const n = R(Te);
1267
- return c(s ? M : de, { "aria-haspopup": "dialog", onClick: () => {
1268
- n.current?.getAttribute("data-modal") === "true" ? n.current?.showModal() : n.current?.show();
1269
- }, ref: t, ...e });
1270
- }), Re = Object.assign(Dn, {
1271
- Block: Fn,
1272
- TriggerContext: dt,
1273
- Trigger: An
1274
- });
1275
- Re.Block.displayName = "Dialog.Block";
1276
- Re.TriggerContext.displayName = "Dialog.TriggerContext";
1277
- Re.Trigger.displayName = "Dialog.Trigger";
1278
- const ut = ({ children: o }) => {
1279
- const s = Q(), [e, t] = A(s);
1280
- return c(Pe.Provider, { value: { popoverId: e, setPopoverId: t }, children: o });
1281
- };
1282
- ut.displayName = "PopoverTriggerContext";
1283
- const Pe = se({}), Ln = w(function({ id: s, className: e, onClose: t, onOpen: n, open: i, variant: r = "default", placement: a = "top", autoPlacement: l = !0, asChild: d = !1, ...h }, p) {
1284
- const u = d ? M : "div", f = F(null), g = U([f, p]), { popoverId: y, setPopoverId: C } = R(Pe), [b, m] = A(!1), v = i ?? b;
1285
- return D(() => {
1286
- const x = f.current, O = (k) => {
1287
- const B = k.target, L = B?.closest?.(`[popovertarget="${x?.id}"]`), $ = !L && !x?.contains(B);
1288
- L && k.preventDefault(), v && (L || $) ? (m(!1), t?.()) : !v && L && (m(!0), n?.());
1289
- }, S = (k) => {
1290
- k.key !== "Escape" || !v || (k.preventDefault(), m(!1), t?.());
1291
- };
1292
- return x?.togglePopover?.(v), document.addEventListener("click", O, !0), document.addEventListener("keydown", S), () => {
1293
- document.removeEventListener("click", O, !0), document.removeEventListener("keydown", S);
1294
- };
1295
- }, [v]), D(() => {
1296
- const x = f.current, O = document.querySelector(`[popovertarget="${x?.id}"]`);
1297
- if (x && O && v)
1298
- return Xe(O, x, () => {
1299
- Jt(O, x, {
1300
- placement: a,
1301
- strategy: "fixed",
1302
- middleware: [
1303
- Qt((S) => {
1304
- const k = getComputedStyle(S.elements.floating, "::before");
1305
- return parseFloat(k.height);
1306
- }),
1307
- ...l ? [Zt({ fallbackAxisSideDirection: "start" }), en()] : [],
1308
- Bn
1309
- ]
1310
- }).then(({ x: S, y: k }) => {
1311
- x.style.translate = `${Math.round(S)}px ${Math.round(k)}px`;
1312
- });
1313
- });
1314
- }, [v, a, s, l]), D(() => {
1315
- s && C?.(s);
1316
- }, [s]), c(u, { className: E("ds-popover", e), id: s || y, popover: "manual", "data-variant": r, ref: g, ...h });
1317
- }), Bn = {
1318
- name: "ArrowPseudoElement",
1319
- fn(o) {
1320
- const { elements: s, rects: e, placement: t } = o;
1321
- let n = `${Math.round(e.reference.width / 2 + e.reference.x - o.x)}px`, i = `${Math.round(e.reference.height / 2 + e.reference.y - o.y)}px`;
1322
- switch (e.reference.width > e.floating.width && (n = `${Math.round(e.floating.width / 2)}px`), e.reference.height > e.floating.height && (i = `${Math.round(e.floating.height / 2)}px`), t.split("-")[0]) {
1323
- case "top":
1324
- i = "100%";
1325
- break;
1326
- case "right":
1327
- n = "0";
1328
- break;
1329
- case "bottom":
1330
- i = "0";
1331
- break;
1332
- case "left":
1333
- n = "100%";
1334
- break;
1335
- }
1336
- return s.floating.setAttribute("data-placement", t.split("-")[0]), s.floating.style.setProperty("--ds-popover-arrow-x", n), s.floating.style.setProperty("--ds-popover-arrow-y", i), o;
1337
- }
1338
- }, Vn = w(function({ id: s, inline: e, asChild: t, ...n }, i) {
1339
- const { popoverId: r } = R(Pe), a = t ? M : e ? "button" : de, l = Object.assign({
1340
- [kt.startsWith("19") ? "popoverTarget" : "popovertarget"]: r,
1341
- ...e ? {
1342
- "data-popover": "inline"
1343
- } : {}
1344
- }, n);
1345
- return c(a, { ref: i, ...l });
1346
- }), go = w(function({ asChild: s, ...e }, t) {
1347
- return c(s ? M : "li", { ...e, ref: t });
1348
- }), ht = (o, { asChild: s, className: e, ...t }, n) => c(s ? M : o, { className: E("ds-list", e), ref: n, ...t }), vo = w(function(s, e) {
1349
- return ht("ul", s, e);
1350
- });
1351
- w(function(s, e) {
1352
- return ht("ol", s, e);
1353
- });
1354
- const $n = w(function({ "aria-label": s = "Sidenavigering", asChild: e, className: t, ...n }, i) {
1355
- return c(e ? M : "nav", { "aria-label": s, className: E("ds-pagination", t), ref: i, ...n });
1356
- }), jn = w(function(s, e) {
1357
- return c(de, { ref: e, ...s });
1358
- }), Wn = w(function({ asChild: s, className: e, ...t }, n) {
1359
- return c(s ? M : "li", { ref: n, ...t });
1360
- }), Kn = w(function({ asChild: s, ...e }, t) {
1361
- return c(s ? M : "ul", { ref: t, ...e });
1362
- }), De = Object.assign($n, {
1363
- List: Kn,
1364
- Item: Wn,
1365
- Button: jn
1366
- });
1367
- De.List.displayName = "Pagination.List";
1368
- De.Item.displayName = "Pagination.Item";
1369
- De.Button.displayName = "Pagination.Button";
1370
- const ft = Object.assign(Ln, {
1371
- TriggerContext: ut,
1372
- Trigger: Vn
1373
- });
1374
- ft.TriggerContext.displayName = "Popover.TriggerContext";
1375
- ft.Trigger.displayName = "Popover.Trigger";
1376
- const yo = w(function({ asChild: s, className: e, height: t, style: n, variant: i = "rectangle", width: r, ...a }, l) {
1377
- const d = s ? M : "span", h = i === "text", p = Wt("ds-skeleton-opacity-fade"), u = U([p, l]);
1378
- return c(d, { "aria-hidden": "true", className: E("ds-skeleton", e), "data-text": h ? "-".repeat(Number(r) || 1) : void 0, "data-variant": i, ref: u, style: h ? n : { width: r, height: t, ...n }, ...a });
1379
- }), fe = se({}), Hn = w(function({ value: s, defaultValue: e, className: t, onChange: n, ...i }, r) {
1380
- const a = F(null), l = s !== void 0, [d, h] = A(e), [p, u] = A(/* @__PURE__ */ new Map());
1381
- let f = n;
1382
- return l || (f = (g) => {
1383
- h(g), n?.(g);
1384
- }, s = d), c(fe.Provider, { value: {
1385
- value: s,
1386
- defaultValue: e,
1387
- onChange: f,
1388
- tablistRef: a,
1389
- panelButtonMap: p,
1390
- setPanelButtonMap: u
1391
- }, children: c("div", { className: E("ds-tabs", t), ref: r, ...i }) });
1392
- }), qn = w(function({ children: s, ...e }, t) {
1393
- const { value: n, tablistRef: i } = R(fe), r = U([t, i]);
1394
- return c(sn, { role: "tablist", activeValue: n, orientation: "ambiguous", ref: r, ...e, children: s });
1395
- }), Un = w(function({ children: s, value: e, id: t, ...n }, i) {
1396
- const { value: r, tablistRef: a, setPanelButtonMap: l } = R(fe), d = e === r, h = Q(), p = t ?? `tabpanel-${h}`, [u, f] = A(!1), [g, y] = A(void 0), C = F(null), b = U([i, C]);
1397
- return D(() => {
1398
- if (!C.current)
1399
- return;
1400
- const m = C.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
1401
- f(m.length > 0);
1402
- }, [s]), D(() => {
1403
- if (!a)
1404
- return;
1405
- const m = a.current?.querySelector(`[role="tab"][data-value="${e}"]`);
1406
- y(m ? m.id : void 0), m && l?.((v) => new Map(v).set(m.id, p));
1407
- }, [a]), c("div", { ref: b, id: p, role: "tabpanel", tabIndex: u ? void 0 : 0, "aria-labelledby": g, hidden: !d, ...n, children: s });
1408
- }), Xn = w(function({ value: s, id: e, onClick: t, ...n }, i) {
1409
- const r = R(fe), a = Q(), l = e ?? `tab-${a}`;
1410
- return c(an, { value: s, ...n, asChild: !0, children: c("button", { ref: i, id: l, "aria-selected": r.value === s, "data-value": s, role: "tab", type: "button", onClick: (d) => {
1411
- r.onChange?.(s), t?.(d);
1412
- }, "aria-controls": r.panelButtonMap?.get(l), ...n }) });
1413
- }), Fe = Object.assign(Hn, {
1414
- List: qn,
1415
- Tab: Xn,
1416
- Panel: Un
1417
- });
1418
- Fe.Tab.displayName = "Tabs.Tab";
1419
- Fe.List.displayName = "Tabs.List";
1420
- Fe.Panel.displayName = "Tabs.Panel";
1421
- const Co = w(function({ label: s, description: e, error: t, multiline: n, prefix: i, suffix: r, "data-size": a, counter: l, style: d, className: h, ...p }, u) {
1422
- return N(Oe, { className: h, "data-size": a, style: d, children: [!!s && c(H, { children: s }), !!e && c(Kt, { children: e }), N(Ht, { children: [i === void 0 || c(Ve, { children: i }), n === !0 ? c(tn, { ref: u, "aria-invalid": !!t || void 0, ...p }) : c(Me, { ref: u, "aria-invalid": !!t || void 0, ...p }), r === void 0 || c(Ve, { children: r })] }), !!l && c(Oe.Counter, { ...typeof l == "number" ? { limit: l } : l }), !!t && c(_e, { children: t })] });
1423
- });
1424
- export {
1425
- un as B,
1426
- bo as C,
1427
- Re as D,
1428
- hn as L,
1429
- De as P,
1430
- yo as S,
1431
- Co as T,
1432
- ue as a,
1433
- he as b,
1434
- go as c,
1435
- vo as d,
1436
- ft as e,
1437
- Fe as f,
1438
- po as u
1439
- };