@altinn/altinn-components 0.26.1 → 0.27.1
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/FieldsetLegend-Dwb3U0vQ.js +10 -0
- package/dist/Input-B_w6SBmg.js +12 -0
- package/dist/Label-DjSEhgyW.js +11 -0
- package/dist/Paragraph-CFjOkbXa.js +11 -0
- package/dist/Textarea-BBstVlPT.js +10 -0
- package/dist/altinn-ds-overrides.css +2 -2
- package/dist/altinn-ds.css +47 -101
- package/dist/assets/Button.css +1 -1
- package/dist/assets/ButtonBase.css +1 -1
- package/dist/assets/ButtonIcon.css +1 -1
- package/dist/assets/ButtonLabel.css +1 -1
- package/dist/assets/ComboButton.css +1 -1
- package/dist/assets/IconButton.css +1 -1
- package/dist/assets/ListItemHeader.css +1 -1
- package/dist/assets/MenuItemLabel.css +1 -1
- package/dist/components/Bookmarks/EditableBookmark.js +31 -30
- package/dist/components/Button/Button.js +41 -43
- package/dist/components/Button/ButtonBase.js +28 -26
- package/dist/components/Button/ButtonIcon.js +3 -3
- package/dist/components/Button/ButtonLabel.js +3 -3
- package/dist/components/Button/ComboButton.js +30 -28
- package/dist/components/Button/IconButton.js +24 -25
- package/dist/components/ContextMenu/ContextMenu.js +5 -6
- package/dist/components/Dialog/DialogActions.js +22 -21
- package/dist/components/Dialog/DialogListItem.js +65 -62
- package/dist/components/DsComponents/index.js +23 -21
- package/dist/components/Forms/Checkbox.js +16 -0
- package/dist/components/Forms/CheckboxOptions.js +12 -0
- package/dist/components/Forms/Field.js +6 -0
- package/dist/components/Forms/FieldBase.js +17 -0
- package/dist/components/Forms/Fieldset.js +28 -0
- package/dist/components/Forms/FieldsetBase.js +15 -0
- package/dist/components/Forms/Input.js +14 -0
- package/dist/components/Forms/Label.js +6 -0
- package/dist/components/Forms/Legend.js +14 -0
- package/dist/components/Forms/OptionsBase.js +18 -0
- package/dist/components/Forms/Radio.js +16 -0
- package/dist/components/Forms/RadioOptions.js +12 -0
- package/dist/components/Forms/Select.js +25 -0
- package/dist/components/Forms/SelectField.js +12 -0
- package/dist/components/Forms/Switch.js +16 -0
- package/dist/components/Forms/SwitchOptions.js +12 -0
- package/dist/components/Forms/TextField.js +12 -0
- package/dist/components/Forms/Textarea.js +6 -0
- package/dist/components/Forms/TextareaField.js +12 -0
- package/dist/components/Forms/index.js +40 -0
- package/dist/components/GlobalMenu/AccountMenu.js +2 -2
- package/dist/components/GlobalMenu/GlobalMenu.js +72 -65
- package/dist/components/List/ListItem.js +15 -13
- package/dist/components/List/ListItemBase.js +18 -16
- package/dist/components/List/ListItemHeader.js +30 -30
- package/dist/components/Menu/Menu.js +42 -38
- package/dist/components/Menu/MenuItemLabel.js +10 -10
- package/dist/components/Menu/MenuItemsVirtual.js +28 -27
- package/dist/components/Page/DashboardCard.js +10 -9
- package/dist/components/Page/PageDetails.js +1 -1
- package/dist/components/Page/PageNav.js +6 -6
- package/dist/components/Toolbar/ToolbarButton.js +23 -21
- package/dist/components/Toolbar/ToolbarFilter.js +27 -26
- package/dist/components/index.js +147 -113
- package/dist/{floating-ui.react-BQwG1HOM.js → floating-ui.react-DpzNAs2N.js} +26 -31
- package/dist/{index-DcykCrjD.js → index-B7UjMwQm.js} +13 -12
- package/dist/index-Bq6w9CqA.js +81 -0
- package/dist/index.js +177 -143
- package/dist/lite-1fxw3LjI.js +7 -0
- package/dist/tokens/README.md +1 -1
- package/dist/tokens/altinn-ds.css +48 -102
- package/dist/tokens/design-tokens-build/altinn-ds.css +48 -102
- package/dist/types/fields.js +1 -0
- package/dist/types/lib/components/Bookmarks/BookmarksSection.stories.d.ts +0 -1
- package/dist/types/lib/components/Button/Button.d.ts +1 -2
- package/dist/types/lib/components/Button/Button.stories.d.ts +5 -1
- package/dist/types/lib/components/Button/ButtonBase.d.ts +3 -2
- package/dist/types/lib/components/Button/ComboButton.d.ts +1 -1
- package/dist/types/lib/components/Dialog/DialogActions.d.ts +2 -1
- package/dist/types/lib/components/Dialog/DialogActions.stories.d.ts +1 -1
- package/dist/types/lib/components/Dialog/DialogListItem.d.ts +1 -1
- package/dist/types/lib/components/Forms/Checkbox.d.ts +7 -0
- package/dist/types/lib/components/Forms/Checkbox.stories.d.ts +15 -0
- package/dist/types/lib/components/Forms/CheckboxOptions.d.ts +5 -0
- package/dist/types/lib/components/Forms/CheckboxOptions.stories.d.ts +18 -0
- package/dist/types/lib/components/Forms/Field.d.ts +7 -0
- package/dist/types/lib/components/Forms/FieldBase.d.ts +8 -0
- package/dist/types/lib/components/Forms/Fieldset.d.ts +7 -0
- package/dist/types/lib/components/Forms/FieldsetBase.d.ts +8 -0
- package/dist/types/lib/components/Forms/Forms.stories.d.ts +7 -0
- package/dist/types/lib/components/Forms/Input.d.ts +10 -0
- package/dist/types/lib/components/Forms/Label.d.ts +7 -0
- package/dist/types/lib/components/Forms/Legend.d.ts +7 -0
- package/dist/types/lib/components/Forms/OptionsBase.d.ts +9 -0
- package/dist/types/lib/components/Forms/Radio.d.ts +7 -0
- package/dist/types/lib/components/Forms/Radio.stories.d.ts +15 -0
- package/dist/types/lib/components/Forms/RadioOptions.d.ts +6 -0
- package/dist/types/lib/components/Forms/RadioOptions.stories.d.ts +18 -0
- package/dist/types/lib/components/Forms/Select.d.ts +9 -0
- package/dist/types/lib/components/Forms/SelectField.d.ts +8 -0
- package/dist/types/lib/components/Forms/SelectField.stories.d.ts +14 -0
- package/dist/types/lib/components/Forms/Switch.d.ts +7 -0
- package/dist/types/lib/components/Forms/Switch.stories.d.ts +15 -0
- package/dist/types/lib/components/Forms/SwitchOptions.d.ts +6 -0
- package/dist/types/lib/components/Forms/SwitchOptions.stories.d.ts +18 -0
- package/dist/types/lib/components/Forms/TextField.d.ts +6 -0
- package/dist/types/lib/components/Forms/TextField.stories.d.ts +15 -0
- package/dist/types/lib/components/Forms/Textarea.d.ts +7 -0
- package/dist/types/lib/components/Forms/TextareaField.d.ts +6 -0
- package/dist/types/lib/components/Forms/TextareaField.stories.d.ts +15 -0
- package/dist/types/lib/components/Forms/index.d.ts +19 -0
- package/dist/types/lib/components/GlobalMenu/AccountMenu.d.ts +4 -2
- package/dist/types/lib/components/GlobalMenu/AccountMenu.stories.d.ts +3 -2
- package/dist/types/lib/components/GlobalMenu/GlobalMenu.d.ts +1 -1
- package/dist/types/lib/components/GlobalMenu/GlobalMenu.stories.d.ts +3 -2
- package/dist/types/lib/components/Header/Header.stories.d.ts +1 -0
- package/dist/types/lib/components/List/ListItem.d.ts +1 -1
- package/dist/types/lib/components/List/ListItem.stories.d.ts +1 -1
- package/dist/types/lib/components/List/ListItemBase.d.ts +3 -1
- package/dist/types/lib/components/List/Specimens.stories.d.ts +1 -1
- package/dist/types/lib/components/Menu/Examples.stories.d.ts +6 -6
- package/dist/types/lib/components/Menu/Menu.d.ts +3 -3
- package/dist/types/lib/components/Menu/Menu.stories.d.ts +1 -1
- package/dist/types/lib/components/Menu/MenuItems.d.ts +4 -0
- package/dist/types/lib/components/Menu/MenuItemsVirtual.d.ts +5 -1
- package/dist/types/lib/components/Page/DashboardHeader.stories.d.ts +12 -0
- package/dist/types/lib/components/Page/{Patterns.stories.d.ts → Examples.stories.d.ts} +2 -0
- package/dist/types/lib/components/Toolbar/ToolbarButton.d.ts +2 -1
- package/dist/types/lib/components/Toolbar/ToolbarButton.stories.d.ts +1 -1
- package/dist/types/lib/components/index.d.ts +1 -1
- package/dist/types/lib/types/fields.d.ts +2 -0
- package/dist/usePagination-B4GfH2GQ.js +1026 -0
- package/package.json +1 -1
- package/dist/assets/FieldBase.css +0 -1
- package/dist/assets/InputBase.css +0 -1
- package/dist/components/TextField/FieldBase.js +0 -16
- package/dist/components/TextField/InputBase.js +0 -33
- package/dist/components/TextField/TextField.js +0 -7
- package/dist/components/TextField/index.js +0 -8
- package/dist/types/lib/components/Button/Buttons.stories.d.ts +0 -18
- package/dist/types/lib/components/TextField/FieldBase.d.ts +0 -11
- package/dist/types/lib/components/TextField/InputBase.d.ts +0 -14
- package/dist/types/lib/components/TextField/TextField.d.ts +0 -7
- package/dist/types/lib/components/TextField/index.d.ts +0 -3
- package/dist/usePagination-BJD-uxk9.js +0 -1098
|
@@ -1,1098 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs as S, jsx as a, Fragment as le } from "react/jsx-runtime";
|
|
3
|
-
import { u as M, c as C, a as Ge, b as Rt, o as Dt, f as At, s as Ft, d as Bt, e as $t, g as zt, h as jt, i as Mt, j as Vt, k as Kt, l as Ht, F as qt, m as Ut } from "./floating-ui.react-BQwG1HOM.js";
|
|
4
|
-
import * as ke from "react";
|
|
5
|
-
import { forwardRef as p, useLayoutEffect as Xt, useEffect as L, useRef as A, useState as K, createContext as G, useContext as T, useId as te, version as Wt, useReducer as Yt, useMemo as Z, isValidElement as Je, memo as Gt, useCallback as Jt, Children as We } from "react";
|
|
6
|
-
import { a as Qe, S as k } from "./index-C8BS_2GY.js";
|
|
7
|
-
import { u as Qt } from "./index-DyDqjche.js";
|
|
8
|
-
import { S as Zt } from "./XMark-Bv1I87Ev.js";
|
|
9
|
-
import { S as en } from "./ChevronUp-H8Nuww4h.js";
|
|
10
|
-
import { S as tn } from "./ChevronDown-CRAwzuD3.js";
|
|
11
|
-
import { u as nn } from "./useId-CsCRkvK3.js";
|
|
12
|
-
import { S as on } from "./Checkmark-RgzvRNxP.js";
|
|
13
|
-
import { flushSync as rn } from "react-dom";
|
|
14
|
-
var sn = function(t, n) {
|
|
15
|
-
var e = {};
|
|
16
|
-
for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && n.indexOf(o) < 0 && (e[o] = t[o]);
|
|
17
|
-
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
18
|
-
for (var r = 0, o = Object.getOwnPropertySymbols(t); r < o.length; r++)
|
|
19
|
-
n.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[r]) && (e[o[r]] = t[o[r]]);
|
|
20
|
-
return e;
|
|
21
|
-
};
|
|
22
|
-
const an = p((t, n) => {
|
|
23
|
-
var { title: e, titleId: o } = t, r = sn(t, ["title", "titleId"]);
|
|
24
|
-
let i = nn();
|
|
25
|
-
return i = e ? o || "title-" + i : void 0, ke.createElement(
|
|
26
|
-
"svg",
|
|
27
|
-
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: n, "aria-labelledby": i }, r),
|
|
28
|
-
e ? ke.createElement("title", { id: i }, e) : null,
|
|
29
|
-
ke.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" })
|
|
30
|
-
);
|
|
31
|
-
}), cn = typeof window < "u" ? Xt : L;
|
|
32
|
-
function _e(t) {
|
|
33
|
-
const n = A(null);
|
|
34
|
-
return cn(() => {
|
|
35
|
-
const e = document.getAnimations().filter((i) => "animationName" in i && i.animationName === t), o = e.find((i) => "animationName" in i && i.animationName === t), r = e.find((i) => {
|
|
36
|
-
var s;
|
|
37
|
-
return ((s = i.effect) == null ? void 0 : s.target) === n.current;
|
|
38
|
-
});
|
|
39
|
-
return r && r === o && (r.currentTime = 0), r && (o != null && o.currentTime) && r !== o && (r.currentTime = o.currentTime), () => {
|
|
40
|
-
r && (o != null && o.currentTime) && (r.currentTime = o.currentTime);
|
|
41
|
-
};
|
|
42
|
-
}, [t]), n;
|
|
43
|
-
}
|
|
44
|
-
const Ze = p(function({ "aria-label": n, className: e, ...o }, r) {
|
|
45
|
-
const i = _e("ds-spinner-rotate-animation"), s = _e("ds-spinner-stroke-animation"), c = M([i, r]);
|
|
46
|
-
return S("svg", { "aria-label": n, className: C("ds-spinner", e), ref: c, role: "img", viewBox: "0 0 50 50", ...o, children: [a("circle", { className: C("ds-spinner__background"), cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5" }), a("circle", { className: C("ds-spinner__circle"), cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5", ref: s })] });
|
|
47
|
-
}), ne = p(function({ asChild: n, className: e, children: o, icon: r = !1, loading: i = !1, variant: s = "primary", ...c }, l) {
|
|
48
|
-
return S(n ? k : "button", {
|
|
49
|
-
"aria-busy": !!i || void 0,
|
|
50
|
-
"aria-disabled": !!i || void 0,
|
|
51
|
-
className: C("ds-button", e),
|
|
52
|
-
"data-icon": r || void 0,
|
|
53
|
-
"data-variant": s,
|
|
54
|
-
ref: l,
|
|
55
|
-
/* don't set type when we use `asChild` */
|
|
56
|
-
type: n ? void 0 : "button",
|
|
57
|
-
...c,
|
|
58
|
-
children: [i === !0 ? a(Ze, { "aria-hidden": "true" }) : i, a(Qe, { children: o })]
|
|
59
|
-
});
|
|
60
|
-
}), ln = p(function({ className: n, count: e, maxCount: o, variant: r = "base", ...i }, s) {
|
|
61
|
-
return a("span", { className: C("ds-badge", n), "data-count": e && o && e > o ? `${o}+` : e, "data-variant": r, ref: s, ...i });
|
|
62
|
-
}), dn = p(function({ className: n, overlap: e = "rectangle", placement: o = "top-right", ...r }, i) {
|
|
63
|
-
return a("span", { className: C("ds-badge--position", n), "data-overlap": e, "data-placement": o, ref: i, ...r });
|
|
64
|
-
}), un = Object.assign(ln, { Position: dn });
|
|
65
|
-
un.Position.displayName = "Badge.Position";
|
|
66
|
-
const fn = p(({ asChild: t, className: n, ...e }, o) => a(t ? k : "a", { className: C("ds-link", n), ref: o, ...e }));
|
|
67
|
-
fn.displayName = "Link";
|
|
68
|
-
const mo = p(function({ asChild: n, className: e, height: o, style: r, variant: i = "rectangle", width: s, ...c }, l) {
|
|
69
|
-
const u = n ? k : "span", b = i === "text", m = _e("ds-skeleton-opacity-fade"), d = M([m, l]);
|
|
70
|
-
return a(u, { "aria-hidden": "true", className: C("ds-skeleton", e), "data-text": b ? "-".repeat(Number(s) || 1) : void 0, "data-variant": i, ref: d, style: b ? r : { width: s, height: o, ...r }, ...c });
|
|
71
|
-
}), po = p(function({ asChild: n, ...e }, o) {
|
|
72
|
-
return a(n ? k : "li", { ...e, ref: o });
|
|
73
|
-
}), et = (t, { asChild: n, className: e, ...o }, r) => a(n ? k : t, { className: C("ds-list", e), ref: r, ...o }), bo = p(function(n, e) {
|
|
74
|
-
return et("ul", n, e);
|
|
75
|
-
});
|
|
76
|
-
p(function(n, e) {
|
|
77
|
-
return et("ol", n, e);
|
|
78
|
-
});
|
|
79
|
-
const U = p(function({ className: n, weight: e = "medium", asChild: o, ...r }, i) {
|
|
80
|
-
return a(o ? k : "label", { ref: i, className: C("ds-label", n), "data-weight": e, ...r });
|
|
81
|
-
}), ho = p(function({ level: n = 2, className: e, asChild: o, ...r }, i) {
|
|
82
|
-
const s = o ? k : `h${n}`;
|
|
83
|
-
return a(s, { className: C("ds-heading", e), ref: i, ...r });
|
|
84
|
-
}), pe = p(function({ className: n, asChild: e, variant: o = "default", ...r }, i) {
|
|
85
|
-
return a(e ? k : "p", { ref: i, className: C("ds-paragraph", n), "data-variant": o, ...r });
|
|
86
|
-
}), be = p(function({ className: n, asChild: e, ...o }, r) {
|
|
87
|
-
return a(e ? k : "p", { className: C("ds-validation-message", n), "data-field": "validation", ref: r, ...o });
|
|
88
|
-
}), go = p(function({ "data-color": n = "info", className: e, ...o }, r) {
|
|
89
|
-
return a("div", { className: C("ds-alert", e), "data-color": n, ref: r, ...o });
|
|
90
|
-
}), de = p(function({ type: n = "text", className: e, onChange: o, onClick: r, ...i }, s) {
|
|
91
|
-
return a("input", { className: C("ds-input", e), ref: s, type: n, onChange: (c) => i.readOnly || (o == null ? void 0 : o(c)), onClick: (c) => {
|
|
92
|
-
i.readOnly && c.preventDefault(), r == null || r(c);
|
|
93
|
-
}, ...i });
|
|
94
|
-
}), tt = p(function({ asChild: n, className: e, ...o }, r) {
|
|
95
|
-
return a(n ? k : "button", { className: C("ds-chip", e), type: n ? void 0 : "button", ref: r, ...o });
|
|
96
|
-
}), nt = p(function(n, e) {
|
|
97
|
-
return a(tt, { "data-removable": !0, ref: e, ...n });
|
|
98
|
-
}), ot = p(function({ asChild: n, children: e, className: o, "data-size": r, "data-color": i, ...s }, c) {
|
|
99
|
-
const l = s.type ?? "checkbox";
|
|
100
|
-
return S(n ? k : "label", { className: C("ds-chip", o), "data-size": r, "data-color": i, ref: c, children: [a(de, { ...s, type: l }), a(Qe, { children: e })] });
|
|
101
|
-
}), mn = p(function(n, e) {
|
|
102
|
-
return a(ot, { ref: e, type: "radio", ...n });
|
|
103
|
-
}), he = {
|
|
104
|
-
Button: tt,
|
|
105
|
-
Checkbox: ot,
|
|
106
|
-
Radio: mn,
|
|
107
|
-
Removable: nt
|
|
108
|
-
};
|
|
109
|
-
he.Button.displayName = "Chip.Button";
|
|
110
|
-
he.Checkbox.displayName = "Chip.Checkbox";
|
|
111
|
-
he.Radio.displayName = "Chip.Radio";
|
|
112
|
-
he.Removable.displayName = "Chip.Removable";
|
|
113
|
-
const pn = p(function({ "aria-label": n = "Sidenavigering", asChild: e, className: o, ...r }, i) {
|
|
114
|
-
return a(e ? k : "nav", { "aria-label": n, className: C("ds-pagination", o), ref: i, ...r });
|
|
115
|
-
}), bn = p(function(n, e) {
|
|
116
|
-
return a(ne, { ref: e, ...n });
|
|
117
|
-
}), hn = p(function({ asChild: n, className: e, ...o }, r) {
|
|
118
|
-
return a(n ? k : "li", { ref: r, ...o });
|
|
119
|
-
}), gn = p(function({ asChild: n, ...e }, o) {
|
|
120
|
-
return a(n ? k : "ul", { ref: o, ...e });
|
|
121
|
-
}), De = Object.assign(pn, {
|
|
122
|
-
List: gn,
|
|
123
|
-
Item: hn,
|
|
124
|
-
Button: bn
|
|
125
|
-
});
|
|
126
|
-
De.List.displayName = "Pagination.List";
|
|
127
|
-
De.Item.displayName = "Pagination.Item";
|
|
128
|
-
De.Button.displayName = "Pagination.Button";
|
|
129
|
-
function yn(t) {
|
|
130
|
-
if (!t)
|
|
131
|
-
return;
|
|
132
|
-
const n = /* @__PURE__ */ new Map(), e = `:${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
133
|
-
let o = null, r = "";
|
|
134
|
-
const i = (c) => {
|
|
135
|
-
const l = [], u = [];
|
|
136
|
-
for (const d of c)
|
|
137
|
-
d.attributeName && l.push(d.target ?? t), l.push(...d.addedNodes || []), u.push(...d.removedNodes || []);
|
|
138
|
-
for (const d of l)
|
|
139
|
-
Ye(d) && (Oe(d) ? n.set(d, d.htmlFor) : d.hasAttribute("data-field") ? n.set(d, d.id) : Pe(d) && (o = d, r = d.getAttribute("aria-describedby") || ""));
|
|
140
|
-
for (const d of u)
|
|
141
|
-
Ye(d) && (o === d && (o = null), n.has(d) && (me(d, Oe(d) ? "for" : "id", n.get(d)), n.delete(d)));
|
|
142
|
-
const b = [r], m = (o == null ? void 0 : o.id) || e;
|
|
143
|
-
for (const [d, h] of n) {
|
|
144
|
-
const y = d.getAttribute("data-field"), v = y ? `${m}:${y}` : m;
|
|
145
|
-
h || me(d, Oe(d) ? "for" : "id", v), y === "validation" ? b.unshift(d.id) : y && b.push(d.id);
|
|
146
|
-
}
|
|
147
|
-
me(o, "id", m), me(o, "aria-describedby", b.join(" ").trim());
|
|
148
|
-
}, s = xn(i);
|
|
149
|
-
return s.observe(t, {
|
|
150
|
-
attributeFilter: ["id", "for", "aria-describedby"],
|
|
151
|
-
attributes: !0,
|
|
152
|
-
childList: !0,
|
|
153
|
-
subtree: !0
|
|
154
|
-
}), i([{ addedNodes: t.querySelectorAll("*") }]), s.takeRecords(), () => s.disconnect();
|
|
155
|
-
}
|
|
156
|
-
const Ye = (t) => t instanceof Element, Oe = (t) => t instanceof HTMLLabelElement, Pe = (t) => t instanceof HTMLElement && "validity" in t && !(t instanceof HTMLButtonElement), me = (t, n, e) => e ? t == null ? void 0 : t.setAttribute(n, e) : t == null ? void 0 : t.removeAttribute(n);
|
|
157
|
-
function xn(t) {
|
|
158
|
-
const n = [], e = new MutationObserver((r) => {
|
|
159
|
-
n.length || requestAnimationFrame(o), n.push(...r);
|
|
160
|
-
}), o = () => {
|
|
161
|
-
t(n, e), n.length = 0, e.takeRecords();
|
|
162
|
-
};
|
|
163
|
-
return e;
|
|
164
|
-
}
|
|
165
|
-
const vn = p(function({ className: n, position: e, ...o }, r) {
|
|
166
|
-
const i = A(null), s = M([i, r]);
|
|
167
|
-
return L(() => yn(i.current), []), a("div", { className: C("ds-field", n), "data-position": e, ref: s, ...o });
|
|
168
|
-
}), rt = p(function({ className: n, ...e }, o) {
|
|
169
|
-
return a("div", { className: C("ds-field-affixes", n), ref: o, ...e });
|
|
170
|
-
}), Le = p(function({ className: n, ...e }, o) {
|
|
171
|
-
return a("span", { className: C("ds-field-affix", n), "aria-hidden": "true", ref: o, ...e });
|
|
172
|
-
}), Se = (t, n) => t.replace("%d", Math.abs(n).toString()), Cn = p(function({ limit: n, under: e = "%d tegn igjen", over: o = "%d tegn for mye", ...r }, i) {
|
|
173
|
-
const [s, c] = K(0), l = A(null), u = s > n, b = n - s;
|
|
174
|
-
return L(() => {
|
|
175
|
-
var y;
|
|
176
|
-
const m = (y = l.current) == null ? void 0 : y.closest(".ds-field"), d = Array.from((m == null ? void 0 : m.getElementsByTagName("*")) || []).find(Pe), h = ({ target: v }) => {
|
|
177
|
-
Pe(v) && c(v.value.length);
|
|
178
|
-
};
|
|
179
|
-
return d && h({ target: d }), m == null || m.addEventListener("input", h), () => m == null ? void 0 : m.removeEventListener("input", h);
|
|
180
|
-
}, [c]), S(le, { children: [a("div", { "data-field": "description", className: "ds-sr-only", "aria-live": "polite", ref: l, children: u && Se(o, b) }), u ? a(be, { ref: i, ...r, children: Se(o, b) }) : a(pe, { ref: i, ...r, "data-field": "validation", children: Se(e, b) })] });
|
|
181
|
-
}), it = p(function(n, e) {
|
|
182
|
-
return a("div", { "data-field": "description", ref: e, ...n });
|
|
183
|
-
}), Y = Object.assign(vn, {
|
|
184
|
-
Description: it,
|
|
185
|
-
Affixes: rt,
|
|
186
|
-
Affix: Le,
|
|
187
|
-
Counter: Cn
|
|
188
|
-
});
|
|
189
|
-
Y.Description.displayName = "Field.Description";
|
|
190
|
-
Y.Affixes.displayName = "Field.Affixes";
|
|
191
|
-
Y.Affix.displayName = "Field.Affix";
|
|
192
|
-
Y.Counter.displayName = "Field.Counter";
|
|
193
|
-
const yo = p(function({ "data-size": n, className: e, style: o, children: r, label: i, description: s, error: c, ...l }, u) {
|
|
194
|
-
return S(Y, { "data-size": n, className: e, style: o, children: [a(de, { type: "checkbox", ref: u, ...l }), !!i && a(U, { weight: "regular", children: i }), !!s && a("div", { "data-field": "description", children: s }), !!c && a(be, { children: c })] });
|
|
195
|
-
}), xo = p(function({ "data-size": n, children: e, className: o, description: r, label: i, position: s, style: c, ...l }, u) {
|
|
196
|
-
return S(Y, { className: o, "data-position": s, "data-size": n, style: c, children: [a(de, { type: "checkbox", role: "switch", ref: u, ...l }), !!i && a(U, { weight: "regular", children: i }), !!r && a("div", { "data-field": "description", children: r })] });
|
|
197
|
-
}), wn = p(function({ className: n, ...e }, o) {
|
|
198
|
-
return a("textarea", { className: C("ds-input", n), ref: o, ...e });
|
|
199
|
-
}), vo = p(function({ label: n, description: e, error: o, multiline: r, prefix: i, suffix: s, "data-size": c, counter: l, style: u, className: b, ...m }, d) {
|
|
200
|
-
return S(Y, { className: b, "data-size": c, style: u, children: [!!n && a(U, { children: n }), !!e && a(it, { children: e }), S(rt, { children: [i === void 0 || a(Le, { children: i }), r === !0 ? a(wn, { ref: d, "aria-invalid": !!o || void 0, ...m }) : a(de, { ref: d, "aria-invalid": !!o || void 0, ...m }), s === void 0 || a(Le, { children: s })] }), !!o && a(be, { children: o }), !!l && a(Y.Counter, { ...typeof l == "number" ? { limit: l } : l })] });
|
|
201
|
-
}), ge = G({}), In = p(function({ value: n, defaultValue: e, className: o, onChange: r, ...i }, s) {
|
|
202
|
-
const c = n !== void 0, [l, u] = K(e);
|
|
203
|
-
let b = r;
|
|
204
|
-
return c || (b = (m) => {
|
|
205
|
-
u(m), r == null || r(m);
|
|
206
|
-
}, n = l), a(ge.Provider, { value: {
|
|
207
|
-
value: n,
|
|
208
|
-
defaultValue: e,
|
|
209
|
-
onChange: b
|
|
210
|
-
}, children: a("div", { className: C("ds-tabs", o), ref: s, ...i }) });
|
|
211
|
-
}), st = G({
|
|
212
|
-
elements: { current: /* @__PURE__ */ new Map() },
|
|
213
|
-
getOrderedItems: () => [],
|
|
214
|
-
setFocusableValue: () => {
|
|
215
|
-
},
|
|
216
|
-
onShiftTab: () => {
|
|
217
|
-
},
|
|
218
|
-
focusableValue: null,
|
|
219
|
-
orientation: "horizontal"
|
|
220
|
-
}), Nn = p(({ activeValue: t, asChild: n, orientation: e = "horizontal", onBlur: o, onFocus: r, ...i }, s) => {
|
|
221
|
-
const c = n ? k : "div", [l, u] = K(null), [b, m] = K(!1), d = A(/* @__PURE__ */ new Map()), h = A(null), y = M([s, h]), v = () => {
|
|
222
|
-
if (!h.current)
|
|
223
|
-
return [];
|
|
224
|
-
const f = Array.from(h.current.querySelectorAll("[data-roving-tabindex-item]"));
|
|
225
|
-
return Array.from(d.current).sort((w, g) => f.indexOf(w[1]) - f.indexOf(g[1])).map(([w, g]) => ({ value: w, element: g }));
|
|
226
|
-
};
|
|
227
|
-
return L(() => {
|
|
228
|
-
u(t ?? null);
|
|
229
|
-
}, [t]), a(st.Provider, { value: {
|
|
230
|
-
elements: d,
|
|
231
|
-
getOrderedItems: v,
|
|
232
|
-
focusableValue: l,
|
|
233
|
-
setFocusableValue: u,
|
|
234
|
-
onShiftTab: () => {
|
|
235
|
-
m(!0);
|
|
236
|
-
},
|
|
237
|
-
orientation: e
|
|
238
|
-
}, children: a(c, { ...i, tabIndex: b ? -1 : 0, onBlur: (f) => {
|
|
239
|
-
o == null || o(f), m(!1), u(t ?? null);
|
|
240
|
-
}, onFocus: (f) => {
|
|
241
|
-
var g, x, I;
|
|
242
|
-
if (r == null || r(f), f.target !== f.currentTarget)
|
|
243
|
-
return;
|
|
244
|
-
const w = v();
|
|
245
|
-
w.length !== 0 && (l != null ? (g = d.current.get(l)) == null || g.focus() : t != null ? (x = d.current.get(t)) == null || x.focus() : (I = w.at(0)) == null || I.element.focus());
|
|
246
|
-
}, ref: y }) });
|
|
247
|
-
}), kn = p(function({ children: n, ...e }, o) {
|
|
248
|
-
const { value: r } = T(ge);
|
|
249
|
-
return a(Nn, { role: "tablist", activeValue: r, orientation: "ambiguous", ref: o, ...e, children: n });
|
|
250
|
-
}), On = p(function({ children: n, value: e, ...o }, r) {
|
|
251
|
-
const { value: i } = T(ge), s = e === i, [c, l] = K(!1), u = A(null), b = M([r, u]);
|
|
252
|
-
return L(() => {
|
|
253
|
-
if (!u.current)
|
|
254
|
-
return;
|
|
255
|
-
const m = u.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
256
|
-
l(m.length > 0);
|
|
257
|
-
}, [n]), a(le, { children: s && a("div", { ref: b, role: "tabpanel", tabIndex: c ? void 0 : 0, ...o, children: n }) });
|
|
258
|
-
}), Sn = (t) => {
|
|
259
|
-
const { elements: n, getOrderedItems: e, setFocusableValue: o, focusableValue: r, onShiftTab: i, orientation: s } = T(st);
|
|
260
|
-
return {
|
|
261
|
-
getOrderedItems: e,
|
|
262
|
-
isFocusable: r === t,
|
|
263
|
-
orientation: s,
|
|
264
|
-
getRovingProps: (c) => ({
|
|
265
|
-
...c,
|
|
266
|
-
ref: (l) => {
|
|
267
|
-
l ? n.current.set(t, l) : n.current.delete(t);
|
|
268
|
-
},
|
|
269
|
-
onKeyDown: (l) => {
|
|
270
|
-
var u;
|
|
271
|
-
if ((u = c == null ? void 0 : c.onKeyDown) == null || u.call(c, l), l.shiftKey && l.key === "Tab") {
|
|
272
|
-
i();
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
onFocus: (l) => {
|
|
277
|
-
var u;
|
|
278
|
-
(u = c == null ? void 0 : c.onFocus) == null || u.call(c, l), o(t);
|
|
279
|
-
},
|
|
280
|
-
"data-roving-tabindex-item": !0,
|
|
281
|
-
tabIndex: r === t ? 0 : -1
|
|
282
|
-
})
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
function Ee(t, n) {
|
|
286
|
-
const e = t.findIndex((o) => o.value === n);
|
|
287
|
-
return t.at(e === t.length - 1 ? 0 : e + 1);
|
|
288
|
-
}
|
|
289
|
-
function Te(t, n) {
|
|
290
|
-
const e = t.findIndex((o) => o.value === n);
|
|
291
|
-
return t.at(e === 0 ? -1 : e - 1);
|
|
292
|
-
}
|
|
293
|
-
const En = p(({ value: t, asChild: n, ...e }, o) => {
|
|
294
|
-
const r = n ? k : "div", i = t ?? (typeof e.children == "string" ? e.children : ""), { getOrderedItems: s, getRovingProps: c, orientation: l } = Sn(i), u = c({
|
|
295
|
-
onKeyDown: (m) => {
|
|
296
|
-
var y;
|
|
297
|
-
(y = e == null ? void 0 : e.onKeyDown) == null || y.call(e, m);
|
|
298
|
-
const d = s();
|
|
299
|
-
let h;
|
|
300
|
-
switch (l) {
|
|
301
|
-
case "horizontal":
|
|
302
|
-
m.key === "ArrowRight" && (h = Ee(d, i)), m.key === "ArrowLeft" && (h = Te(d, i));
|
|
303
|
-
break;
|
|
304
|
-
case "vertical":
|
|
305
|
-
m.key === "ArrowDown" && (h = Ee(d, i)), m.key === "ArrowUp" && (h = Te(d, i));
|
|
306
|
-
break;
|
|
307
|
-
case "ambiguous":
|
|
308
|
-
["ArrowRight", "ArrowDown"].includes(m.key) && (h = Ee(d, i)), ["ArrowLeft", "ArrowUp"].includes(m.key) && (h = Te(d, i));
|
|
309
|
-
}
|
|
310
|
-
m.key === "Home" && (h = d[0]), m.key === "End" && (h = d[d.length - 1]), h && (m.preventDefault(), h.element.focus());
|
|
311
|
-
}
|
|
312
|
-
}), b = M([o, u.ref]);
|
|
313
|
-
return a(r, { ...e, ...u, ref: b, children: e.children });
|
|
314
|
-
}), Tn = p(function({ value: n, id: e, ...o }, r) {
|
|
315
|
-
const i = T(ge), s = e ?? `tab-${te()}`;
|
|
316
|
-
return a(En, { value: n, ...o, asChild: !0, children: a("button", { ...o, "aria-selected": i.value === n, id: s, onClick: () => {
|
|
317
|
-
var c;
|
|
318
|
-
return (c = i.onChange) == null ? void 0 : c.call(i, n);
|
|
319
|
-
}, ref: r, role: "tab", type: "button" }) });
|
|
320
|
-
}), Ae = Object.assign(In, {
|
|
321
|
-
List: kn,
|
|
322
|
-
Tab: Tn,
|
|
323
|
-
Panel: On
|
|
324
|
-
});
|
|
325
|
-
Ae.Tab.displayName = "Tabs.Tab";
|
|
326
|
-
Ae.List.displayName = "Tabs.List";
|
|
327
|
-
Ae.Panel.displayName = "Tabs.Panel";
|
|
328
|
-
const at = ({ children: t }) => {
|
|
329
|
-
const n = te(), [e, o] = K(n);
|
|
330
|
-
return a(Fe.Provider, { value: { popoverId: e, setPopoverId: o }, children: t });
|
|
331
|
-
};
|
|
332
|
-
at.displayName = "PopoverTriggerContext";
|
|
333
|
-
const Fe = G({}), _n = p(function({ id: n, className: e, onClose: o, onOpen: r, open: i, variant: s = "default", placement: c = "top", autoPlacement: l = !0, asChild: u = !1, ...b }, m) {
|
|
334
|
-
const d = u ? k : "div", h = A(null), y = M([h, m]), { popoverId: v, setPopoverId: f } = T(Fe), [w, g] = K(!1), x = i ?? w;
|
|
335
|
-
return L(() => {
|
|
336
|
-
var F;
|
|
337
|
-
const I = h.current, O = (z) => {
|
|
338
|
-
var Q;
|
|
339
|
-
const B = z.target, H = (Q = B == null ? void 0 : B.closest) == null ? void 0 : Q.call(B, `[popovertarget="${I == null ? void 0 : I.id}"]`), j = !H && !(I != null && I.contains(B));
|
|
340
|
-
H && (z.preventDefault(), g((P) => !P), r == null || r()), j && (g(!1), o == null || o());
|
|
341
|
-
}, _ = (z) => {
|
|
342
|
-
z.key !== "Escape" || !x || (z.preventDefault(), g(!1), o == null || o());
|
|
343
|
-
};
|
|
344
|
-
return (F = I == null ? void 0 : I.togglePopover) == null || F.call(I, x), document.addEventListener("click", O, !0), document.addEventListener("keydown", _), () => {
|
|
345
|
-
document.removeEventListener("click", O, !0), document.removeEventListener("keydown", _);
|
|
346
|
-
};
|
|
347
|
-
}, [x]), L(() => {
|
|
348
|
-
const I = h.current, O = document.querySelector(`[popovertarget="${I == null ? void 0 : I.id}"]`);
|
|
349
|
-
if (I && O && x)
|
|
350
|
-
return Ge(O, I, () => {
|
|
351
|
-
Rt(O, I, {
|
|
352
|
-
placement: c,
|
|
353
|
-
strategy: "fixed",
|
|
354
|
-
middleware: [
|
|
355
|
-
Dt((_) => {
|
|
356
|
-
const F = getComputedStyle(_.elements.floating, "::before");
|
|
357
|
-
return parseFloat(F.height);
|
|
358
|
-
}),
|
|
359
|
-
...l ? [At({ fallbackAxisSideDirection: "start" }), Ft()] : [],
|
|
360
|
-
Pn
|
|
361
|
-
]
|
|
362
|
-
}).then(({ x: _, y: F }) => {
|
|
363
|
-
I.style.translate = `${_}px ${F}px`;
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
}, [x, c, n, l]), L(() => {
|
|
367
|
-
n && (f == null || f(n));
|
|
368
|
-
}, [n]), a(d, {
|
|
369
|
-
className: C("ds-popover", e),
|
|
370
|
-
id: n || v,
|
|
371
|
-
// @ts-ignore @types/react-dom does not understand popover yet
|
|
372
|
-
popover: "manual",
|
|
373
|
-
"data-variant": s,
|
|
374
|
-
ref: y,
|
|
375
|
-
...b
|
|
376
|
-
});
|
|
377
|
-
}), Pn = {
|
|
378
|
-
name: "ArrowPseudoElement",
|
|
379
|
-
fn(t) {
|
|
380
|
-
const { elements: n, rects: e, placement: o } = t;
|
|
381
|
-
let r = `${Math.round(e.reference.width / 2 + e.reference.x - t.x)}px`, i = `${Math.round(e.reference.height / 2 + e.reference.y - t.y)}px`;
|
|
382
|
-
switch (e.reference.width > e.floating.width && (r = `${Math.round(e.floating.width / 2)}px`), e.reference.height > e.floating.height && (i = `${Math.round(e.floating.height / 2)}px`), o.split("-")[0]) {
|
|
383
|
-
case "top":
|
|
384
|
-
i = "100%";
|
|
385
|
-
break;
|
|
386
|
-
case "right":
|
|
387
|
-
r = "0";
|
|
388
|
-
break;
|
|
389
|
-
case "bottom":
|
|
390
|
-
i = "0";
|
|
391
|
-
break;
|
|
392
|
-
case "left":
|
|
393
|
-
r = "100%";
|
|
394
|
-
break;
|
|
395
|
-
}
|
|
396
|
-
return n.floating.setAttribute("data-placement", o.split("-")[0]), n.floating.style.setProperty("--ds-popover-arrow-x", r), n.floating.style.setProperty("--ds-popover-arrow-y", i), t;
|
|
397
|
-
}
|
|
398
|
-
}, Ln = p(function({ id: n, inline: e, asChild: o, ...r }, i) {
|
|
399
|
-
const { popoverId: s } = T(Fe), c = o ? k : e ? "button" : ne, l = Object.assign({
|
|
400
|
-
[Wt.startsWith("19") ? "popoverTarget" : "popovertarget"]: s,
|
|
401
|
-
...e ? {
|
|
402
|
-
"data-popover": "inline"
|
|
403
|
-
} : {}
|
|
404
|
-
}, r);
|
|
405
|
-
return a(c, { ref: i, ...l });
|
|
406
|
-
}), ct = Object.assign(_n, {
|
|
407
|
-
TriggerContext: at,
|
|
408
|
-
Trigger: Ln
|
|
409
|
-
});
|
|
410
|
-
ct.TriggerContext.displayName = "Popover.TriggerContext";
|
|
411
|
-
ct.Trigger.displayName = "Popover.Trigger";
|
|
412
|
-
const Be = G({
|
|
413
|
-
current: null
|
|
414
|
-
}), lt = ({ children: t }) => {
|
|
415
|
-
const n = A(null);
|
|
416
|
-
return a(Be.Provider, { value: n, children: t });
|
|
417
|
-
};
|
|
418
|
-
lt.displayName = "DialogTriggerContext";
|
|
419
|
-
const Rn = p(function({ asChild: n, children: e, className: o, closeButton: r = "Lukk dialogvindu", closedby: i = "closerequest", modal: s = !0, onClose: c, open: l, ...u }, b) {
|
|
420
|
-
const m = T(Be), d = A(null), h = n ? k : "dialog", y = M([m, b, d]), v = s ? "showModal" : "show";
|
|
421
|
-
return L(() => {
|
|
422
|
-
var f;
|
|
423
|
-
return (f = d.current) == null ? void 0 : f[l ? v : "close"]();
|
|
424
|
-
}, [l]), L(() => {
|
|
425
|
-
const f = d.current, w = (x) => {
|
|
426
|
-
var F;
|
|
427
|
-
const { clientY: I, clientX: O, target: _ } = x;
|
|
428
|
-
if (x instanceof KeyboardEvent)
|
|
429
|
-
return i === "none" && x.key === "Escape" && x.preventDefault();
|
|
430
|
-
if (!((F = window.getSelection()) != null && F.toString()) && f && _ === f && i === "any") {
|
|
431
|
-
const { top: z, left: B, right: H, bottom: j } = f.getBoundingClientRect();
|
|
432
|
-
z <= I && I <= j && B <= O && O <= H || f == null || f.close();
|
|
433
|
-
}
|
|
434
|
-
}, g = () => {
|
|
435
|
-
const x = f == null ? void 0 : f.querySelector("[autofocus]");
|
|
436
|
-
document.activeElement !== x && (x == null || x.focus());
|
|
437
|
-
};
|
|
438
|
-
return f == null || f.addEventListener("animationend", g), f == null || f.addEventListener("click", w), f == null || f.addEventListener("keydown", w), () => {
|
|
439
|
-
f == null || f.removeEventListener("animationend", g), f == null || f.removeEventListener("click", w), f == null || f.removeEventListener("keydown", w);
|
|
440
|
-
};
|
|
441
|
-
}, [i]), L(() => {
|
|
442
|
-
var w;
|
|
443
|
-
const f = (g) => c == null ? void 0 : c(g);
|
|
444
|
-
return (w = d.current) == null || w.addEventListener("close", f), () => {
|
|
445
|
-
var g;
|
|
446
|
-
return (g = d.current) == null ? void 0 : g.removeEventListener("close", f);
|
|
447
|
-
};
|
|
448
|
-
}, [c]), S(h, { className: C("ds-dialog", o), ref: y, "data-modal": s, ...u, children: [r !== !1 && a("form", { method: "dialog", children: a(ne, { "aria-label": r, autoFocus: !0, "data-color": "neutral", icon: !0, name: "close", type: "submit", variant: "tertiary" }) }), e] });
|
|
449
|
-
}), Dn = p(function({ asChild: n, className: e, ...o }, r) {
|
|
450
|
-
return a(n ? k : "div", { className: C("ds-dialog__block", e), ref: r, ...o });
|
|
451
|
-
}), An = p(function({ asChild: n, ...e }, o) {
|
|
452
|
-
const r = T(Be);
|
|
453
|
-
return a(n ? k : ne, { "aria-haspopup": "dialog", onClick: () => {
|
|
454
|
-
var c, l, u;
|
|
455
|
-
((c = r.current) == null ? void 0 : c.getAttribute("data-modal")) === "true" ? (l = r.current) == null || l.showModal() : (u = r.current) == null || u.show();
|
|
456
|
-
}, ref: o, ...e });
|
|
457
|
-
}), $e = Object.assign(Rn, {
|
|
458
|
-
Block: Dn,
|
|
459
|
-
TriggerContext: lt,
|
|
460
|
-
Trigger: An
|
|
461
|
-
});
|
|
462
|
-
$e.Block.displayName = "Dialog.Block";
|
|
463
|
-
$e.TriggerContext.displayName = "Dialog.TriggerContext";
|
|
464
|
-
$e.Trigger.displayName = "Dialog.Trigger";
|
|
465
|
-
const J = G(void 0), dt = G({
|
|
466
|
-
activeIndex: 0
|
|
467
|
-
}), Fn = (t, n) => {
|
|
468
|
-
switch (n.type) {
|
|
469
|
-
case "SET_ACTIVE_INDEX":
|
|
470
|
-
return {
|
|
471
|
-
...t,
|
|
472
|
-
activeIndex: n.payload
|
|
473
|
-
};
|
|
474
|
-
default:
|
|
475
|
-
return t;
|
|
476
|
-
}
|
|
477
|
-
}, ut = G(() => {
|
|
478
|
-
throw new Error("ComboboxIdDispatch must be used within a provider");
|
|
479
|
-
}), Bn = ({ children: t }) => {
|
|
480
|
-
const [n, e] = Yt(Fn, {
|
|
481
|
-
activeIndex: 0
|
|
482
|
-
});
|
|
483
|
-
return a(dt.Provider, { value: n, children: a(ut.Provider, { value: e, children: t }) });
|
|
484
|
-
};
|
|
485
|
-
function ze() {
|
|
486
|
-
return T(ut);
|
|
487
|
-
}
|
|
488
|
-
function ye() {
|
|
489
|
-
return T(dt);
|
|
490
|
-
}
|
|
491
|
-
const ee = (t, n) => {
|
|
492
|
-
const e = {}, o = {};
|
|
493
|
-
let r = 0;
|
|
494
|
-
const i = t.length;
|
|
495
|
-
for (; r < i; )
|
|
496
|
-
o[t[r]] = 1, r += 1;
|
|
497
|
-
for (const s in n)
|
|
498
|
-
Object.prototype.hasOwnProperty.call(o, s) || (e[s] = n[s]);
|
|
499
|
-
return e;
|
|
500
|
-
}, ft = p(({ asChild: t, interactive: n, id: e, className: o, ...r }, i) => {
|
|
501
|
-
if (n && !e)
|
|
502
|
-
throw new Error("If ComboboxCustom is interactive, it must have an id");
|
|
503
|
-
const s = t ? k : "div", c = te(), { activeIndex: l } = ye(), u = T(J);
|
|
504
|
-
if (!u)
|
|
505
|
-
throw new Error("ComboboxCustom must be used within a Combobox");
|
|
506
|
-
const { customIds: b, setListRef: m, getItemProps: d, size: h } = u, y = Z(() => e && b.indexOf(e) || 0, [e, b]), v = M([
|
|
507
|
-
(f) => {
|
|
508
|
-
m(y, f);
|
|
509
|
-
},
|
|
510
|
-
i
|
|
511
|
-
]);
|
|
512
|
-
return a(U, { "data-size": h, asChild: !0, children: a(s, { ref: v, tabIndex: -1, className: C("ds-combobox__custom", o), id: e || c, role: "option", "aria-selected": l === y, "data-active": l === y, ...ee(["interactive"], r), ...ee(["onClick", "onPointerLeave"], d()) }) });
|
|
513
|
-
});
|
|
514
|
-
function $n(t) {
|
|
515
|
-
return Je(t) && t.type === ft;
|
|
516
|
-
}
|
|
517
|
-
function zn(t) {
|
|
518
|
-
return $n(t) && t.props.interactive === !0;
|
|
519
|
-
}
|
|
520
|
-
const mt = "internal-option-", D = (t) => mt + t, Re = (t) => t.slice(mt.length), ce = (t, n) => {
|
|
521
|
-
const e = t.value;
|
|
522
|
-
t.value = n;
|
|
523
|
-
const o = t._valueTracker;
|
|
524
|
-
typeof o < "u" && o.setValue(e), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
525
|
-
}, jn = p(function({ "aria-label": n = "Tøm", onClick: e, ...o }, r) {
|
|
526
|
-
return a(ne, { ref: r, variant: "tertiary", type: "reset", "aria-label": n, onClick: (s) => {
|
|
527
|
-
var u;
|
|
528
|
-
const c = s.target;
|
|
529
|
-
let l = null;
|
|
530
|
-
if (c instanceof HTMLElement && (l = (u = c.closest(".ds-search")) == null ? void 0 : u.querySelector("input")), !l)
|
|
531
|
-
throw new Error("Input is missing");
|
|
532
|
-
if (!(l instanceof HTMLInputElement))
|
|
533
|
-
throw new Error("Input is not an input element");
|
|
534
|
-
s.preventDefault(), ce(l, ""), l.focus(), e == null || e(s);
|
|
535
|
-
}, icon: !0, ...o });
|
|
536
|
-
}), Mn = p(function({ children: n = "Søk", ...e }, o) {
|
|
537
|
-
return a(ne, { ref: o, type: "submit", ...e, children: n });
|
|
538
|
-
}), Vn = p(function({ ...n }, e) {
|
|
539
|
-
return a(de, {
|
|
540
|
-
ref: e,
|
|
541
|
-
type: "search",
|
|
542
|
-
/* We need an empty placeholder for the clear button to be able to show/hide */
|
|
543
|
-
placeholder: "",
|
|
544
|
-
...n
|
|
545
|
-
});
|
|
546
|
-
}), Kn = p(function({ className: n, ...e }, o) {
|
|
547
|
-
return a("div", { ref: o, className: C("ds-search", n), ...e });
|
|
548
|
-
}), je = Object.assign(Kn, {
|
|
549
|
-
Clear: jn,
|
|
550
|
-
Button: Mn,
|
|
551
|
-
Input: Vn
|
|
552
|
-
});
|
|
553
|
-
je.Clear.displayName = "Search.Clear";
|
|
554
|
-
je.Button.displayName = "Search.Button";
|
|
555
|
-
je.Input.displayName = "Search.Input";
|
|
556
|
-
const Hn = G(null), qn = (t, n) => {
|
|
557
|
-
const e = T(Hn), o = te(), r = t.id ?? `${n}-${o}`, i = t.errorId ?? `${n}-error-${o}`, s = `${n}-description-${o}`, c = t.size ?? (e == null ? void 0 : e.size) ?? "md", l = (e == null ? void 0 : e.disabled) || (t == null ? void 0 : t.disabled), u = !l && !!(t.error || e != null && e.error);
|
|
558
|
-
return {
|
|
559
|
-
hasError: u,
|
|
560
|
-
errorId: i,
|
|
561
|
-
descriptionId: s,
|
|
562
|
-
size: c,
|
|
563
|
-
inputProps: {
|
|
564
|
-
id: r,
|
|
565
|
-
disabled: l,
|
|
566
|
-
"aria-invalid": u ? !0 : void 0,
|
|
567
|
-
"aria-describedby": C(t["aria-describedby"], !!(t != null && t.description) && typeof (t == null ? void 0 : t.description) == "string" && s, u && !(e != null && e.error) && i, u && !!(e != null && e.error) && (e == null ? void 0 : e.errorId)) || void 0
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
}, pt = ({ size: t, error: n, formFieldProps: e }) => a("div", { className: "ds-combobox__error-message", id: e.errorId, "aria-live": "polite", "aria-relevant": "additions removals", children: n && a(be, { "data-size": t, children: n }) });
|
|
571
|
-
pt.displayName = "ComboboxError";
|
|
572
|
-
const bt = () => {
|
|
573
|
-
const t = T(J);
|
|
574
|
-
if (!t)
|
|
575
|
-
throw new Error("ComboboxContext is missing");
|
|
576
|
-
const { size: n, readOnly: e, disabled: o, selectedOptions: r, chipSrLabel: i, handleSelectOption: s, inputRef: c } = t;
|
|
577
|
-
return a(le, { children: Object.keys(r).map((l) => a(nt, { "data-size": n, disabled: o, onKeyDown: (u) => {
|
|
578
|
-
var b;
|
|
579
|
-
e || o || u.key === "Enter" && (u.stopPropagation(), s({
|
|
580
|
-
option: r[l],
|
|
581
|
-
remove: !0
|
|
582
|
-
}), (b = c == null ? void 0 : c.current) == null || b.focus());
|
|
583
|
-
}, onClick: () => {
|
|
584
|
-
e || o || s({
|
|
585
|
-
option: r[l],
|
|
586
|
-
remove: !0
|
|
587
|
-
});
|
|
588
|
-
}, "aria-label": i(r[l]), children: r[l].label }, l)) });
|
|
589
|
-
};
|
|
590
|
-
bt.displayName = "ComboboxChips";
|
|
591
|
-
const ht = p((t, n) => {
|
|
592
|
-
const e = T(J);
|
|
593
|
-
if (!e)
|
|
594
|
-
throw new Error("ComboboxContext is missing");
|
|
595
|
-
const { readOnly: o, disabled: r, clearButtonLabel: i, handleSelectOption: s } = e;
|
|
596
|
-
return a("button", { ...t, ref: n, disabled: r, className: C("ds-combobox__clear-button", "ds-focus"), onClick: () => {
|
|
597
|
-
o || r || s({ option: null, clear: !0 });
|
|
598
|
-
}, onKeyDown: (c) => {
|
|
599
|
-
o || r || c.key === "Enter" && (c.stopPropagation(), s({ option: null, clear: !0 }));
|
|
600
|
-
}, type: "button", "aria-label": i, children: a(Zt, { fontSize: "1.5em", title: "Clear selection" }) });
|
|
601
|
-
});
|
|
602
|
-
ht.displayName = "ComboboxClearButton";
|
|
603
|
-
const gt = ({ hideClearButton: t, listId: n, error: e, hideChips: o, handleKeyDown: r, ...i }) => {
|
|
604
|
-
const s = T(J), c = ze(), l = A(null);
|
|
605
|
-
if (!s)
|
|
606
|
-
throw new Error("ComboboxContext is missing");
|
|
607
|
-
const u = (R) => {
|
|
608
|
-
c == null || c({ type: "SET_ACTIVE_INDEX", payload: R });
|
|
609
|
-
}, { forwareddRef: b, readOnly: m, disabled: d, open: h, inputRef: y, refs: v, inputValue: f, multiple: w, selectedOptions: g, formFieldProps: x, htmlSize: I, options: O, setOpen: _, getReferenceProps: F, setInputValue: z, handleSelectOption: B, size: H } = s, j = M([b, y]), Q = (R) => {
|
|
610
|
-
const $ = R.target.value;
|
|
611
|
-
z($), u(0);
|
|
612
|
-
for (const q of Object.values(O))
|
|
613
|
-
if (q.label.toLowerCase() === $.toLowerCase()) {
|
|
614
|
-
if (g[D(q.value)])
|
|
615
|
-
continue;
|
|
616
|
-
B({ option: q });
|
|
617
|
-
}
|
|
618
|
-
}, P = !t && Object.keys(g).length > 0, oe = F({
|
|
619
|
-
ref: v == null ? void 0 : v.setReference,
|
|
620
|
-
role: null,
|
|
621
|
-
"aria-controls": null,
|
|
622
|
-
"aria-expanded": null,
|
|
623
|
-
"aria-haspopup": null,
|
|
624
|
-
/* If we click the wrapper, toggle open, set index to first option, and focus the input */
|
|
625
|
-
onClick(R) {
|
|
626
|
-
var $, q;
|
|
627
|
-
d || m || ($ = l.current) != null && $.contains(R.target) || (_(!h), u(0), (q = y.current) == null || q.focus());
|
|
628
|
-
},
|
|
629
|
-
/* Handles list navigation */
|
|
630
|
-
onKeyDown: r,
|
|
631
|
-
// preventDefault on keydown to avoid sending in form
|
|
632
|
-
onKeyPress(R) {
|
|
633
|
-
R.key === "Enter" && R.preventDefault();
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
return a(pe, { "data-size": H, asChild: !0, children: S("div", { ...oe, "aria-disabled": d ? "true" : void 0, className: C("ds-textfield__input", "ds-combobox__input__wrapper", m && "ds-combobox--readonly", e && "ds-combobox--error"), children: [S("div", { className: "ds-combobox__chip-and-input", children: [w && !o && a(bt, {}), a(pe, { "data-size": H, asChild: !0, children: a("input", { ref: j, "aria-activedescendant": oe["aria-activedescendant"], readOnly: m, "aria-autocomplete": "list", role: "combobox", "aria-expanded": h, "aria-controls": h ? n : void 0, autoComplete: "off", size: I, value: f, ...ee(["style", "className"], i), ...x.inputProps, className: "ds-combobox__input", onChange: (R) => {
|
|
637
|
-
var $;
|
|
638
|
-
Q(R), !h && _(!0), ($ = i.onChange) == null || $.call(i, R);
|
|
639
|
-
} }) })] }), P && a(ht, { ref: l }), a("div", { className: "ds-combobox__arrow", children: h ? a(en, { title: "arrow up", fontSize: "1.5em" }) : a(tn, { title: "arrow down", fontSize: "1.5em" }) })] }) });
|
|
640
|
-
};
|
|
641
|
-
gt.displayName = "ComboboxInput";
|
|
642
|
-
const yt = ({ label: t, description: n, hideLabel: e, size: o, readOnly: r, formFieldProps: i }) => S(le, { children: [t && S(U, { "data-size": o, htmlFor: i.inputProps.id, className: C("ds-combobox__label", e && "ds-sr-only"), children: [r && a(an, { "aria-hidden": !0, className: "ds-combobox__readonly__icon" }), t] }), n && a(pe, { asChild: !0, "data-size": o, children: a("div", { id: i.descriptionId, className: C("ds-combobox__description", e && "ds-sr-only"), children: n }) })] });
|
|
643
|
-
yt.displayName = "ComboboxLabel";
|
|
644
|
-
const xt = ({ selectedOptions: t, multiple: n, name: e }) => {
|
|
645
|
-
const o = Object.keys(t).map((r) => Re(r));
|
|
646
|
-
return a("select", { name: e, multiple: n, style: { display: "none" }, value: n ? o : o[0], onChange: () => {
|
|
647
|
-
}, children: o.map((r) => a("option", { value: r }, r)) });
|
|
648
|
-
};
|
|
649
|
-
xt.displayName = "ComboboxNative";
|
|
650
|
-
const vt = p(({ children: t, className: n, ...e }, o) => a("span", { className: C("ds-combobox__option__description", n), ref: o, ...e, children: t }));
|
|
651
|
-
vt.displayName = "ComboboxOptionDescription";
|
|
652
|
-
const Ct = ({ multiple: t, selected: n }) => a("div", { className: C(t && "ds-combobox__option__icon-wrapper", n && "ds-combobox__option__icon-wrapper--selected"), children: n && a(on, { className: "ds-combobox__option__icon-wrapper__icon", "aria-hidden": !0 }) });
|
|
653
|
-
Ct.displayName = "SelectedIcon";
|
|
654
|
-
function Me(t, n = 50) {
|
|
655
|
-
const e = A(null);
|
|
656
|
-
return L(() => () => {
|
|
657
|
-
e.current && clearTimeout(e.current);
|
|
658
|
-
}, []), (...r) => {
|
|
659
|
-
e.current && clearTimeout(e.current), e.current = window.setTimeout(() => {
|
|
660
|
-
t(...r);
|
|
661
|
-
}, n);
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
const Un = ({ id: t, ref: n, value: e }) => {
|
|
665
|
-
const o = te(), r = t || o, i = T(J), { activeIndex: s } = ye(), c = ze();
|
|
666
|
-
if (!i)
|
|
667
|
-
throw new Error("ComboboxOption must be used within a Combobox");
|
|
668
|
-
const { selectedOptions: l, onOptionClick: u, setListRef: b, customIds: m, filteredOptions: d } = i, h = Z(() => d.indexOf(D(String(e))) + m.length, [m.length, d, e]), y = M([
|
|
669
|
-
(g) => {
|
|
670
|
-
b(h, g);
|
|
671
|
-
},
|
|
672
|
-
n
|
|
673
|
-
]);
|
|
674
|
-
if (h === -1)
|
|
675
|
-
throw new Error("Internal error: ComboboxOption did not find index");
|
|
676
|
-
const v = l[D(e)], f = s === h;
|
|
677
|
-
L(() => {
|
|
678
|
-
f && (c == null || c({ type: "SET_ACTIVE_INDEX", payload: h }));
|
|
679
|
-
}, [o, t, c, f, h]);
|
|
680
|
-
const w = Me(() => u(e), 50);
|
|
681
|
-
return {
|
|
682
|
-
id: r,
|
|
683
|
-
ref: y,
|
|
684
|
-
selected: v,
|
|
685
|
-
active: f,
|
|
686
|
-
onOptionClick: w
|
|
687
|
-
};
|
|
688
|
-
}, Ve = Gt(p(({ value: t, description: n, children: e, className: o, ...r }, i) => {
|
|
689
|
-
const s = te(), { id: c, ref: l, selected: u, active: b, onOptionClick: m } = Un({
|
|
690
|
-
id: r.id,
|
|
691
|
-
ref: i,
|
|
692
|
-
value: t
|
|
693
|
-
}), d = T(J);
|
|
694
|
-
if (!d)
|
|
695
|
-
throw new Error("ComboboxOption must be used within a Combobox");
|
|
696
|
-
const { size: h, multiple: y, getItemProps: v } = d, f = v();
|
|
697
|
-
return a(U, { "data-size": "md", asChild: !0, children: S("button", {
|
|
698
|
-
ref: l,
|
|
699
|
-
id: c,
|
|
700
|
-
// biome-ignore lint/a11y/useSemanticElements: biome wants me to use the <option> element
|
|
701
|
-
role: "option",
|
|
702
|
-
type: "button",
|
|
703
|
-
"aria-selected": !!u,
|
|
704
|
-
"aria-labelledby": s,
|
|
705
|
-
tabIndex: -1,
|
|
706
|
-
onClick: (w) => {
|
|
707
|
-
var g;
|
|
708
|
-
m(), (g = r.onClick) == null || g.call(r, w);
|
|
709
|
-
},
|
|
710
|
-
className: C("ds-combobox__option", b && "ds-combobox__option--active", y && "ds-combobox__option--multiple", o),
|
|
711
|
-
...ee(["displayValue"], r),
|
|
712
|
-
...ee(["onClick", "onPointerLeave"], f),
|
|
713
|
-
children: [a(U, { asChild: !0, "data-size": h, children: a("span", { children: a(Ct, { multiple: y, selected: !!u }) }) }), S(U, { className: "ds-combobox__option__label", "data-size": h, id: s, children: [e, n && a(vt, { children: n })] })]
|
|
714
|
-
}) });
|
|
715
|
-
}));
|
|
716
|
-
Ve.displayName = "ComboboxOption";
|
|
717
|
-
function Xn(t) {
|
|
718
|
-
return Je(t) && t.type === Ve;
|
|
719
|
-
}
|
|
720
|
-
const Wn = (t) => !!t;
|
|
721
|
-
function Yn({ children: t, inputValue: n, multiple: e, filter: o = (i, s) => s.label.toLowerCase().startsWith(i.toLowerCase()), initialValue: r }) {
|
|
722
|
-
const i = Jt(o, [o]), { optionsChildren: s, customIds: c, restChildren: l, interactiveChildren: u } = Z(() => We.toArray(t).reduce((g, x) => {
|
|
723
|
-
if (Xn(x))
|
|
724
|
-
g.optionsChildren.push(x);
|
|
725
|
-
else if (g.restChildren.push(x), zn(x)) {
|
|
726
|
-
const I = x;
|
|
727
|
-
if (g.interactiveChildren.push(I), !I.props.id)
|
|
728
|
-
throw new Error("If ComboboxCustom is interactive, it must have an id");
|
|
729
|
-
g.customIds.push(I.props.id);
|
|
730
|
-
}
|
|
731
|
-
return g;
|
|
732
|
-
}, {
|
|
733
|
-
optionsChildren: [],
|
|
734
|
-
customIds: [],
|
|
735
|
-
restChildren: [],
|
|
736
|
-
interactiveChildren: []
|
|
737
|
-
}), [t]), b = Z(() => {
|
|
738
|
-
const f = [], w = {};
|
|
739
|
-
return s.map((g) => {
|
|
740
|
-
const x = g.props;
|
|
741
|
-
let I = x.displayValue || "";
|
|
742
|
-
if (!x.displayValue) {
|
|
743
|
-
let O = "";
|
|
744
|
-
We.forEach(x.children, (_) => {
|
|
745
|
-
if (typeof _ == "string")
|
|
746
|
-
O += _;
|
|
747
|
-
else
|
|
748
|
-
throw new Error("If ComboboxOption is not a string, it must have a displayValue prop");
|
|
749
|
-
}), I = O;
|
|
750
|
-
}
|
|
751
|
-
f.includes(x.value) && console.warn(`Combobox has multiple options with the same value: ${x.value}`), f.push(x.value), w[D(String(x.value))] = {
|
|
752
|
-
value: String(x.value),
|
|
753
|
-
label: I,
|
|
754
|
-
displayValue: x.displayValue,
|
|
755
|
-
description: x.description
|
|
756
|
-
};
|
|
757
|
-
}), w;
|
|
758
|
-
}, [s]), m = Z(() => ((r == null ? void 0 : r.map((f) => D(f))) || []).reduce((f, w) => {
|
|
759
|
-
const g = b[w];
|
|
760
|
-
return Wn(g) && (f[w] = g), f;
|
|
761
|
-
}, {}), [r, b]), [d, h] = K(m), { filteredOptions: y, filteredOptionsChildren: v } = Z(() => {
|
|
762
|
-
const f = [], w = Object.keys(b).map((g, x) => {
|
|
763
|
-
if (!e && Object.keys(d).length === 1 || e && d[g] || i(n, b[g]))
|
|
764
|
-
return f.push(g), s[x];
|
|
765
|
-
}).filter((g) => g);
|
|
766
|
-
return { filteredOptions: f, filteredOptionsChildren: w };
|
|
767
|
-
}, [
|
|
768
|
-
i,
|
|
769
|
-
n,
|
|
770
|
-
e,
|
|
771
|
-
b,
|
|
772
|
-
s,
|
|
773
|
-
d
|
|
774
|
-
]);
|
|
775
|
-
return {
|
|
776
|
-
filteredOptionsChildren: v,
|
|
777
|
-
filteredOptions: y,
|
|
778
|
-
restChildren: l,
|
|
779
|
-
options: b,
|
|
780
|
-
customIds: c,
|
|
781
|
-
selectedOptions: d,
|
|
782
|
-
interactiveChildren: u,
|
|
783
|
-
setSelectedOptions: h
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
const Gn = ({ readOnly: t, disabled: n, interactiveChildren: e, filteredOptions: o, inputValue: r, selectedOptions: i, multiple: s, open: c, options: l, setOpen: u, handleSelectOption: b }) => {
|
|
787
|
-
const { activeIndex: m } = ye();
|
|
788
|
-
return Me((y) => {
|
|
789
|
-
if (!(t || n) && y)
|
|
790
|
-
switch (y.key) {
|
|
791
|
-
case "ArrowDown":
|
|
792
|
-
if (y.preventDefault(), c)
|
|
793
|
-
break;
|
|
794
|
-
u(!0);
|
|
795
|
-
break;
|
|
796
|
-
case "ArrowUp":
|
|
797
|
-
if (y.preventDefault(), m !== 0)
|
|
798
|
-
break;
|
|
799
|
-
u(!1);
|
|
800
|
-
break;
|
|
801
|
-
case "Enter": {
|
|
802
|
-
if (y.preventDefault(), !c)
|
|
803
|
-
break;
|
|
804
|
-
if (m <= e.length - 1) {
|
|
805
|
-
const w = e[m];
|
|
806
|
-
if (w.props.onSelect) {
|
|
807
|
-
w == null || w.props.onSelect();
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
const v = m - e.length, f = o[v];
|
|
812
|
-
b({ option: l[f] });
|
|
813
|
-
break;
|
|
814
|
-
}
|
|
815
|
-
case "Backspace":
|
|
816
|
-
if (!s) {
|
|
817
|
-
const v = Object.keys(i).pop();
|
|
818
|
-
v && b({
|
|
819
|
-
option: i[v],
|
|
820
|
-
remove: !0
|
|
821
|
-
});
|
|
822
|
-
break;
|
|
823
|
-
}
|
|
824
|
-
if (r === "" && s) {
|
|
825
|
-
const v = Object.keys(i).pop();
|
|
826
|
-
v && b({
|
|
827
|
-
option: i[v],
|
|
828
|
-
remove: !0
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
break;
|
|
832
|
-
}
|
|
833
|
-
}, 20);
|
|
834
|
-
}, Jn = ({ listRef: t }) => {
|
|
835
|
-
const [n, e] = K(!1), { activeIndex: o } = ye(), r = ze(), { refs: i, floatingStyles: s, context: c } = Bt({
|
|
836
|
-
open: n,
|
|
837
|
-
onOpenChange: (y) => {
|
|
838
|
-
y || r == null || r({ type: "SET_ACTIVE_INDEX", payload: 0 }), rn(() => {
|
|
839
|
-
i.floating.current && !y && (i.floating.current.scrollTop = 0), setTimeout(() => {
|
|
840
|
-
e(y);
|
|
841
|
-
}, 1);
|
|
842
|
-
});
|
|
843
|
-
},
|
|
844
|
-
whileElementsMounted: (y, v, f) => (Ge(y, v, f), () => {
|
|
845
|
-
v.scrollTop = 0;
|
|
846
|
-
}),
|
|
847
|
-
middleware: [
|
|
848
|
-
$t({ padding: 10 }),
|
|
849
|
-
zt({
|
|
850
|
-
apply({ rects: y, elements: v }) {
|
|
851
|
-
requestAnimationFrame(() => {
|
|
852
|
-
Object.assign(v.floating.style, {
|
|
853
|
-
width: `${y.reference.width}px`,
|
|
854
|
-
maxHeight: "200px"
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
}),
|
|
859
|
-
jt(10)
|
|
860
|
-
]
|
|
861
|
-
}), l = Mt(c, { role: "listbox" }), u = Vt(c), b = Kt(c, {
|
|
862
|
-
listRef: t,
|
|
863
|
-
activeIndex: o,
|
|
864
|
-
virtual: !0,
|
|
865
|
-
scrollItemIntoView: !0,
|
|
866
|
-
enabled: n,
|
|
867
|
-
focusItemOnHover: !0,
|
|
868
|
-
onNavigate: (y) => {
|
|
869
|
-
r == null || r({ type: "SET_ACTIVE_INDEX", payload: y || 0 });
|
|
870
|
-
}
|
|
871
|
-
}), { getReferenceProps: m, getFloatingProps: d, getItemProps: h } = Ht([l, u, b]);
|
|
872
|
-
return {
|
|
873
|
-
open: n,
|
|
874
|
-
setOpen: e,
|
|
875
|
-
activeIndex: o,
|
|
876
|
-
refs: i,
|
|
877
|
-
floatingStyles: s,
|
|
878
|
-
context: c,
|
|
879
|
-
getReferenceProps: m,
|
|
880
|
-
getFloatingProps: d,
|
|
881
|
-
getItemProps: h
|
|
882
|
-
};
|
|
883
|
-
}, Qn = p(({ value: t, initialValue: n = [], onValueChange: e, label: o, hideLabel: r = !1, description: i, multiple: s = !1, disabled: c = !1, readOnly: l = !1, hideChips: u = !1, clearButtonLabel: b = "Fjern alt", hideClearButton: m = !1, error: d, errorId: h, id: y, name: v, portal: f = !0, htmlSize: w = 0, virtual: g = !1, children: x, style: I, size: O = "md", loading: _, loadingLabel: F = "Laster...", filter: z, chipSrLabel: B = (P) => "Slett " + P.label, className: H, ...j }, Q) => {
|
|
884
|
-
const P = A(null), oe = A(null), R = A([]), [$, q] = K(j.inputValue || "");
|
|
885
|
-
L(() => {
|
|
886
|
-
typeof j.inputValue == "string" && q(j.inputValue);
|
|
887
|
-
}, [j.inputValue]);
|
|
888
|
-
const { selectedOptions: re, options: X, restChildren: Nt, interactiveChildren: kt, customIds: Ot, filteredOptionsChildren: ve, filteredOptions: Ke, setSelectedOptions: ie } = Yn({
|
|
889
|
-
children: x,
|
|
890
|
-
inputValue: $,
|
|
891
|
-
filter: z,
|
|
892
|
-
multiple: s,
|
|
893
|
-
initialValue: n
|
|
894
|
-
}), { open: Ce, setOpen: we, refs: ue, floatingStyles: St, context: He, getReferenceProps: Et, getFloatingProps: Tt, getItemProps: _t } = Jn({
|
|
895
|
-
listRef: R
|
|
896
|
-
}), se = qn({
|
|
897
|
-
disabled: c,
|
|
898
|
-
error: d,
|
|
899
|
-
errorId: h,
|
|
900
|
-
size: O,
|
|
901
|
-
description: i,
|
|
902
|
-
id: y
|
|
903
|
-
}, "combobox");
|
|
904
|
-
L(() => {
|
|
905
|
-
if (t && t.length > 0 && !s) {
|
|
906
|
-
const E = X[D(t[0])];
|
|
907
|
-
P.current && ce(P.current, (E == null ? void 0 : E.label) || "");
|
|
908
|
-
}
|
|
909
|
-
}, [s, t, X]), L(() => {
|
|
910
|
-
if (t && Object.keys(X).length >= 0) {
|
|
911
|
-
const E = t.map((N) => X[D(N)]);
|
|
912
|
-
ie(E.reduce((N, ae) => (N[D(ae.value)] = ae, N), {}));
|
|
913
|
-
}
|
|
914
|
-
}, [s, t, X, ie]);
|
|
915
|
-
const Ie = Me((E) => {
|
|
916
|
-
var qe, Ue;
|
|
917
|
-
const { option: N, clear: ae, remove: Lt } = E;
|
|
918
|
-
if (ae) {
|
|
919
|
-
ie({}), P.current && ce(P.current, ""), e == null || e([]);
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
if (!N)
|
|
923
|
-
return;
|
|
924
|
-
if (Lt) {
|
|
925
|
-
const V = { ...re };
|
|
926
|
-
delete V[D(N.value)], ie(V), e == null || e(Object.keys(V).map((fe) => Re(fe)));
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
const W = { ...re };
|
|
930
|
-
if (s)
|
|
931
|
-
W[D(N.value)] ? delete W[D(N.value)] : W[D(N.value)] = N, P.current && ce(P.current, ""), (qe = P.current) == null || qe.focus();
|
|
932
|
-
else {
|
|
933
|
-
for (const V of Object.keys(W))
|
|
934
|
-
delete W[V];
|
|
935
|
-
W[D(N.value)] = N, P.current && ce(P.current, (N == null ? void 0 : N.label) || ""), setTimeout(() => {
|
|
936
|
-
var V, fe, Xe;
|
|
937
|
-
(Xe = P.current) == null || Xe.setSelectionRange(((V = N == null ? void 0 : N.label) == null ? void 0 : V.length) || 0, ((fe = N == null ? void 0 : N.label) == null ? void 0 : fe.length) || 0);
|
|
938
|
-
}, 0);
|
|
939
|
-
}
|
|
940
|
-
ie(W), e == null || e(Object.keys(W).map((V) => Re(V))), !s && we(!1), (Ue = ue.domReference.current) == null || Ue.focus();
|
|
941
|
-
}, 50), Pt = Gn({
|
|
942
|
-
filteredOptions: Ke,
|
|
943
|
-
selectedOptions: re,
|
|
944
|
-
readOnly: se.readOnly || !1,
|
|
945
|
-
disabled: c,
|
|
946
|
-
multiple: s,
|
|
947
|
-
inputValue: $,
|
|
948
|
-
options: X,
|
|
949
|
-
open: Ce,
|
|
950
|
-
interactiveChildren: kt,
|
|
951
|
-
setOpen: we,
|
|
952
|
-
handleSelectOption: Ie
|
|
953
|
-
}), Ne = Qt({
|
|
954
|
-
count: Object.keys(ve).length,
|
|
955
|
-
getScrollElement: () => g ? ue.floating.current : null,
|
|
956
|
-
estimateSize: () => 70,
|
|
957
|
-
measureElement: (E) => E.getBoundingClientRect().height,
|
|
958
|
-
overscan: 7
|
|
959
|
-
});
|
|
960
|
-
return S(J.Provider, { value: {
|
|
961
|
-
size: O,
|
|
962
|
-
options: X,
|
|
963
|
-
selectedOptions: re,
|
|
964
|
-
multiple: s,
|
|
965
|
-
disabled: c,
|
|
966
|
-
readOnly: l,
|
|
967
|
-
open: Ce,
|
|
968
|
-
inputRef: P,
|
|
969
|
-
refs: ue,
|
|
970
|
-
inputValue: $,
|
|
971
|
-
formFieldProps: se,
|
|
972
|
-
htmlSize: w,
|
|
973
|
-
clearButtonLabel: b,
|
|
974
|
-
customIds: Ot,
|
|
975
|
-
filteredOptions: Ke,
|
|
976
|
-
setInputValue: q,
|
|
977
|
-
setOpen: we,
|
|
978
|
-
getReferenceProps: Et,
|
|
979
|
-
getItemProps: _t,
|
|
980
|
-
/* Recieves the value of the option, and searches for it in our values lookup */
|
|
981
|
-
onOptionClick: (E) => {
|
|
982
|
-
if (l || c)
|
|
983
|
-
return;
|
|
984
|
-
const N = X[D(E)];
|
|
985
|
-
Ie({ option: N });
|
|
986
|
-
},
|
|
987
|
-
handleSelectOption: Ie,
|
|
988
|
-
chipSrLabel: B,
|
|
989
|
-
listRef: R,
|
|
990
|
-
forwareddRef: Q,
|
|
991
|
-
setListRef: (E, N) => {
|
|
992
|
-
R.current[E] = N;
|
|
993
|
-
}
|
|
994
|
-
}, children: [S("div", { className: C("ds-combobox", `ds-combobox--${O}`, c && "ds-combobox__disabled", H), style: I, ref: oe, children: [v && a(xt, { name: v, selectedOptions: re, multiple: s }), a(yt, { label: o, description: i, size: O, readOnly: l, hideLabel: r, formFieldProps: se }), a(gt, { ...ee(["inputValue"], j), hideClearButton: m, listId: He.floatingId || "", error: d, hideChips: u, handleKeyDown: Pt, "aria-busy": _ }), a(pt, { size: O, error: d, formFieldProps: se })] }), Ce && a(qt, { root: f ? null : oe, children: a(Ut, { context: He, initialFocus: -1, visuallyHiddenDismiss: !0, children: S("div", { "aria-labelledby": se.inputProps.id, "aria-autocomplete": "list", tabIndex: -1, ...Tt({
|
|
995
|
-
ref: ue.setFloating,
|
|
996
|
-
style: {
|
|
997
|
-
...St
|
|
998
|
-
}
|
|
999
|
-
}), className: C("ds-combobox__options-wrapper", `ds-combobox--${O}`), children: [g && a("div", { style: {
|
|
1000
|
-
height: `${Ne.getTotalSize()}px`,
|
|
1001
|
-
width: "100%",
|
|
1002
|
-
position: "relative"
|
|
1003
|
-
}, children: Ne.getVirtualItems().map((E) => a("div", { ref: Ne.measureElement, "data-index": E.index, style: {
|
|
1004
|
-
position: "absolute",
|
|
1005
|
-
top: 0,
|
|
1006
|
-
left: 0,
|
|
1007
|
-
width: "100%",
|
|
1008
|
-
transform: `translateY(${E.start}px)`
|
|
1009
|
-
}, children: ve[E.index] }, E.index)) }), _ ? S(ft, { className: "ds-combobox__loading", children: [a(Ze, { "aria-label": "Laster", "data-size": "sm" }), F] }) : S(le, { children: [Nt, !g && ve] })] }) }) })] });
|
|
1010
|
-
}), wt = p((t, n) => a(Bn, { children: a(Qn, { ...t, ref: n }) }));
|
|
1011
|
-
wt.displayName = "Combobox";
|
|
1012
|
-
const It = p(({ children: t, className: n, ...e }, o) => {
|
|
1013
|
-
const r = T(J);
|
|
1014
|
-
if (!r)
|
|
1015
|
-
throw new Error("ComboboxEmpty must be used within a Combobox");
|
|
1016
|
-
const { filteredOptions: i, size: s } = r;
|
|
1017
|
-
return i.length === 0 && a(U, { "data-size": s, asChild: !0, children: a("div", { ref: o, className: C("ds-combobox__empty", n), ...e, children: t }) });
|
|
1018
|
-
});
|
|
1019
|
-
It.displayName = "ComboboxEmpty";
|
|
1020
|
-
const xe = wt;
|
|
1021
|
-
xe.Option = Ve;
|
|
1022
|
-
xe.Empty = It;
|
|
1023
|
-
xe.Option.displayName = "Combobox.Option";
|
|
1024
|
-
xe.Empty.displayName = "Combobox.Empty";
|
|
1025
|
-
const Zn = (t, n, e) => {
|
|
1026
|
-
const o = (e - 1) / 2, r = Math.min(Math.max(t - Math.floor(o), 1), n - e + 1), i = Math.min(Math.max(t + Math.ceil(o), e), n), s = Array.from({ length: i + 1 - r }, (c, l) => l + r);
|
|
1027
|
-
return e > 4 && r > 1 && s.splice(0, 2, 1, 0), e > 3 && i < n && s.splice(-2, 2, 0, n), s;
|
|
1028
|
-
}, Co = ({ currentPage: t = 1, setCurrentPage: n, onChange: e, totalPages: o = 1, showPages: r = 7 }) => Z(() => {
|
|
1029
|
-
const i = t < o, s = t !== 1, c = (l) => (u) => {
|
|
1030
|
-
if (l < 1 || l > o)
|
|
1031
|
-
return u.preventDefault();
|
|
1032
|
-
e == null || e(u, l), u.defaultPrevented || n == null || n(l);
|
|
1033
|
-
};
|
|
1034
|
-
return {
|
|
1035
|
-
/** Number of steps */
|
|
1036
|
-
pages: Zn(t, o, r).map((l, u) => ({
|
|
1037
|
-
/**
|
|
1038
|
-
* Page number or "ellipsis" for the ellipsis item
|
|
1039
|
-
*/
|
|
1040
|
-
page: l || "ellipsis",
|
|
1041
|
-
/**
|
|
1042
|
-
* Unique key for the item
|
|
1043
|
-
*/
|
|
1044
|
-
itemKey: l ? `page-${l}` : `ellipsis-${u}`,
|
|
1045
|
-
// React key utility
|
|
1046
|
-
/**
|
|
1047
|
-
* Properties to spread on Pagination.Button
|
|
1048
|
-
*/
|
|
1049
|
-
buttonProps: l ? {
|
|
1050
|
-
"aria-current": l === t ? "page" : void 0,
|
|
1051
|
-
onClick: c(l),
|
|
1052
|
-
variant: l === t ? "primary" : "tertiary"
|
|
1053
|
-
} : null
|
|
1054
|
-
})),
|
|
1055
|
-
/** Properties to spread on Pagination.Button used for previous naviagation */
|
|
1056
|
-
prevButtonProps: {
|
|
1057
|
-
"aria-disabled": !s,
|
|
1058
|
-
// Using aria-disabled to support all HTML elements because of potential asChild
|
|
1059
|
-
onClick: c(t - 1),
|
|
1060
|
-
variant: "tertiary"
|
|
1061
|
-
},
|
|
1062
|
-
/** Properties to spread on Pagination.Button used for next naviagation */
|
|
1063
|
-
nextButtonProps: {
|
|
1064
|
-
"aria-disabled": !i,
|
|
1065
|
-
// Using aria-disabled to support all HTML elements because of potential asChild
|
|
1066
|
-
onClick: c(t + 1),
|
|
1067
|
-
variant: "tertiary"
|
|
1068
|
-
},
|
|
1069
|
-
/** Indication if previous page action should be shown or not */
|
|
1070
|
-
hasPrev: s,
|
|
1071
|
-
/** Indication if next page action should be shown or not */
|
|
1072
|
-
hasNext: i
|
|
1073
|
-
};
|
|
1074
|
-
}, [t, o, r]);
|
|
1075
|
-
export {
|
|
1076
|
-
go as A,
|
|
1077
|
-
un as B,
|
|
1078
|
-
yo as C,
|
|
1079
|
-
$e as D,
|
|
1080
|
-
ho as H,
|
|
1081
|
-
fn as L,
|
|
1082
|
-
De as P,
|
|
1083
|
-
xo as S,
|
|
1084
|
-
vo as T,
|
|
1085
|
-
be as V,
|
|
1086
|
-
ne as a,
|
|
1087
|
-
he as b,
|
|
1088
|
-
xe as c,
|
|
1089
|
-
po as d,
|
|
1090
|
-
bo as e,
|
|
1091
|
-
pe as f,
|
|
1092
|
-
ct as g,
|
|
1093
|
-
je as h,
|
|
1094
|
-
mo as i,
|
|
1095
|
-
Ze as j,
|
|
1096
|
-
Ae as k,
|
|
1097
|
-
Co as u
|
|
1098
|
-
};
|