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