@oslokommune/punkt-elements 18.7.0 → 18.7.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/CHANGELOG.md +39 -0
- package/dist/{accordion-NO9LYXaN.cjs → accordion-CsrLQXEA.cjs} +1 -1
- package/dist/{accordion-BI-Qiznz.js → accordion-DoxhiwK-.js} +5 -5
- package/dist/{alert-HFqn-cvb.cjs → alert-DH3VqNqh.cjs} +1 -1
- package/dist/{alert-CayKowTW.js → alert-DxAGxSX_.js} +6 -6
- package/dist/{async-directive-CAZoZMez.js → async-directive-BSwJ8-GL.js} +2 -2
- package/dist/{async-directive-DlB0Sf4j.cjs → async-directive-CfPXShXu.cjs} +1 -1
- package/dist/{backlink-DYO8qA9C.cjs → backlink-CDH824db.cjs} +1 -1
- package/dist/{backlink-BHtxOlTw.js → backlink-CGc7r9CS.js} +3 -3
- package/dist/{breadcrumbs-HG9wzGtr.cjs → breadcrumbs-B37tsIoh.cjs} +1 -1
- package/dist/{breadcrumbs-BlRDuZbZ.js → breadcrumbs-DRGhIXmN.js} +2 -2
- package/dist/{button-CIb0IxTg.cjs → button-Cx6Xdp6t.cjs} +1 -1
- package/dist/{button-DWMHtdWk.js → button-D6QhHPWH.js} +5 -5
- package/dist/{calendar-CBghTpkZ.js → calendar-42o_q-jI.js} +3 -3
- package/dist/{calendar-CA1mz04B.cjs → calendar-CAwIY7x_.cjs} +1 -1
- package/dist/{card-CsSNvjZV.cjs → card-CB72gwBC.cjs} +1 -1
- package/dist/{card-PXDm9JXv.js → card-cyZE94EO.js} +6 -6
- package/dist/{checkbox-DReZOEy2.js → checkbox-C6JdANel.js} +4 -4
- package/dist/{checkbox-CMu4pF8-.cjs → checkbox-CddODhna.cjs} +1 -1
- package/dist/{class-map-BL_YL_Ed.js → class-map-DSoj1J68.js} +1 -1
- package/dist/{class-map-BEib48YL.cjs → class-map-DupQbnhE.cjs} +1 -1
- package/dist/{combobox-DcBFiuwP.js → combobox-Cqqokx73.js} +172 -128
- package/dist/combobox-N3NP77le.cjs +137 -0
- package/dist/components/combobox/combobox-base.d.ts +14 -12
- package/dist/components/combobox/combobox-handlers.d.ts +1 -0
- package/dist/components/combobox/combobox-utils.d.ts +3 -1
- package/dist/components/combobox/combobox-value.d.ts +5 -0
- package/dist/components/combobox/combobox.attributes.test.d.ts +0 -0
- package/dist/components/combobox/combobox.d.ts +31 -2
- package/dist/components/combobox/combobox.preselection.test.d.ts +0 -0
- package/dist/components/combobox/index.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/listbox/listbox.d.ts +3 -1
- package/dist/{consent-Yt1MpkUy.js → consent-CsgKWDsR.js} +2 -2
- package/dist/{consent-D1SMUJLs.cjs → consent-DnE6IPEj.cjs} +1 -1
- package/dist/{datepicker-NSWMVoGi.cjs → datepicker-BzRhOIkG.cjs} +1 -1
- package/dist/{datepicker-DboWQcrh.js → datepicker-CtSYgxMs.js} +11 -11
- package/dist/{directive-helpers-Ddr8wUxL.cjs → directive-helpers-2mcpDDv5.cjs} +1 -1
- package/dist/{directive-helpers-CohhRNQz.js → directive-helpers-ChEduoup.js} +1 -1
- package/dist/{element-DRc10X2R.cjs → element-D_mCyFeX.cjs} +1 -1
- package/dist/{element-e2MAMNEP.js → element-J8nynuVk.js} +1 -0
- package/dist/{element-with-slot-GwTT3WRD.js → element-with-slot-BOuXlWSY.js} +2 -2
- package/dist/{element-with-slot-DgtT8lCH.cjs → element-with-slot-C66Jck5e.cjs} +1 -1
- package/dist/{fileupload-BYVtnSaI.cjs → fileupload-3OtW4Xlo.cjs} +1 -1
- package/dist/{fileupload-CqxWUH0y.js → fileupload-PJWEBD88.js} +8 -8
- package/dist/{footer-YrlXRq7e.js → footer-ByAxlj9_.js} +4 -4
- package/dist/{footer-CLSihvYS.cjs → footer-Ca3DM544.cjs} +1 -1
- package/dist/{header-DsaPCLjJ.js → header-CxfDtS3Y.js} +11 -11
- package/dist/{header-DzVHM7gZ.cjs → header-D2SD2JLt.cjs} +1 -1
- package/dist/{header-menu-wcnhBSzs.cjs → header-menu-B9ABa0WW.cjs} +1 -1
- package/dist/{header-menu-DKAcUFzh.js → header-menu-CIuu8_UC.js} +4 -4
- package/dist/{heading-OfJKjUi2.cjs → heading-4ZHACOeL.cjs} +1 -1
- package/dist/{heading-C23xQS4l.js → heading-BHWdVbvN.js} +2 -2
- package/dist/{helptext-DyHzv2ZG.cjs → helptext-6HsH-I6a.cjs} +1 -1
- package/dist/{helptext-DqdOdYRj.js → helptext-BESB9Vlq.js} +4 -4
- package/dist/{icon-DBFTFd-J.cjs → icon-BzxBkRyE.cjs} +1 -1
- package/dist/{icon-jEFbKTB_.js → icon-DkVqRWbC.js} +1 -1
- package/dist/{if-defined-r8tKY4tG.js → if-defined-BILLSM7i.js} +1 -1
- package/dist/if-defined-BbUZeoaQ.cjs +1 -0
- package/dist/{input-element-kvI_5er5.cjs → input-element-DhIEFeuP.cjs} +1 -1
- package/dist/{input-element-BiUfK_gU.js → input-element-Qb0w3ChW.js} +2 -2
- package/dist/{input-wrapper-Bwh720ke.js → input-wrapper-Bg06k-cj.js} +6 -6
- package/dist/{input-wrapper-wyvCnWPp.cjs → input-wrapper-D64Qn-QH.cjs} +1 -1
- package/dist/{link-BWAhHUku.cjs → link-Bk7aDZCC.cjs} +1 -1
- package/dist/{link-BvjWWWlc.js → link-C7fOEv66.js} +4 -4
- package/dist/{linkcard-6CbGf4I_.js → linkcard-Bguo9oCv.js} +4 -4
- package/dist/{linkcard-D6fRaZSc.cjs → linkcard-rZpQuO1Z.cjs} +1 -1
- package/dist/{listbox-CsP0qbU1.js → listbox-CrQboPG6.js} +80 -63
- package/dist/listbox-kV4OO1Qa.cjs +111 -0
- package/dist/{loader-B5t78Yk7.cjs → loader-BAn68gBb.cjs} +1 -1
- package/dist/{loader-BS7EJqxD.js → loader-C3gwO0i3.js} +4 -4
- package/dist/{messagebox-Bt0IvUlD.js → messagebox-DAE59dMX.js} +4 -4
- package/dist/{messagebox-DBVUz-DN.cjs → messagebox-WH2HjT5I.cjs} +1 -1
- package/dist/{modal-C1g2fiUq.cjs → modal-DZm_fn3K.cjs} +1 -1
- package/dist/{modal-z5RzZ-fr.js → modal-DdC1_qT3.js} +5 -5
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +34 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-AFYyv3-b.cjs → pkt-options-controller-DXAAVcBJ.cjs} +1 -1
- package/dist/{pkt-options-controller-DKkmDDzT.js → pkt-options-controller-XcIgx_v1.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-BPHLC7ce.js → progressbar-D1x6MwdY.js} +5 -5
- package/dist/{progressbar-BpcsDCnG.cjs → progressbar-DsE4-qaW.cjs} +1 -1
- package/dist/{radiobutton-bGdAEz26.js → radiobutton-B2P48MMf.js} +4 -4
- package/dist/{radiobutton-B6pzZQZV.cjs → radiobutton-CdwYbHnx.cjs} +1 -1
- package/dist/{ref-BkV4Cd8U.cjs → ref-AuNEkS5a.cjs} +1 -1
- package/dist/{ref-lE1mGUOL.js → ref-DNowxdYH.js} +2 -2
- package/dist/{repeat-uBgVG8Ch.cjs → repeat-B3ksuY2F.cjs} +1 -1
- package/dist/{repeat-CCnTfedv.js → repeat-CZ1oMXnW.js} +2 -2
- package/dist/{searchinput-DrUcPajl.js → searchinput-CmyWnNr6.js} +4 -4
- package/dist/{searchinput-CiPB8xvh.cjs → searchinput-vi7twt5b.cjs} +1 -1
- package/dist/{select-ay8WHI7p.cjs → select-TAwBNhhf.cjs} +1 -1
- package/dist/{select-D7r2s7Cw.js → select-c15YAQbr.js} +7 -7
- package/dist/shared-strings/nb.d.ts +1 -0
- package/dist/{tabs-DqzPOdi9.cjs → tabs-hiTrWsXq.cjs} +1 -1
- package/dist/{tabs-DHvCjUi4.js → tabs-kxsX1ZEf.js} +4 -4
- package/dist/{tag-Cojf4jgA.cjs → tag-CGlxtBOH.cjs} +1 -1
- package/dist/{tag-D2Xvsy1i.js → tag-bztxjcF0.js} +5 -5
- package/dist/{textarea-s4IDLsBi.cjs → textarea-BHGZhMN4.cjs} +1 -1
- package/dist/{textarea-CzAL8e6L.js → textarea-BPQVrOp9.js} +9 -9
- package/dist/{textinput-B9w4jhIP.cjs → textinput-Cv4tal5W.cjs} +1 -1
- package/dist/{textinput-DT3HR9eU.js → textinput-DHGUOsIA.js} +8 -8
- package/dist/{timepicker-C-Ip5Jgl.cjs → timepicker-BBUYnYzM.cjs} +1 -1
- package/dist/{timepicker-BE0UouVr.js → timepicker-C8DHbOpM.js} +8 -8
- package/package.json +3 -3
- package/src/components/combobox/combobox-base.ts +42 -28
- package/src/components/combobox/combobox-handlers.ts +11 -5
- package/src/components/combobox/combobox-utils.ts +9 -1
- package/src/components/combobox/combobox-value.ts +32 -16
- package/src/components/combobox/combobox.accessibility.test.ts +29 -3
- package/src/components/combobox/combobox.attributes.test.ts +82 -0
- package/src/components/combobox/combobox.core.test.ts +46 -1
- package/src/components/combobox/combobox.interaction.test.ts +167 -0
- package/src/components/combobox/combobox.preselection.test.ts +271 -0
- package/src/components/combobox/combobox.ts +143 -79
- package/src/components/combobox/index.ts +6 -1
- package/src/components/index.ts +1 -0
- package/src/components/listbox/listbox.ts +56 -29
- package/dist/combobox-BZm_12qR.cjs +0 -140
- package/dist/if-defined-BeVQnl3C.cjs +0 -1
- package/dist/listbox-D95b5zAd.cjs +0 -106
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-
|
|
2
|
-
import { t as o } from "./class-map-
|
|
3
|
-
import { t as s } from "./if-defined-
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
6
|
-
import
|
|
7
|
-
import "./
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import "./
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-J8nynuVk.js";
|
|
2
|
+
import { t as o } from "./class-map-DSoj1J68.js";
|
|
3
|
+
import { t as s } from "./if-defined-BILLSM7i.js";
|
|
4
|
+
import { t as c } from "./format-BTeSVkED.js";
|
|
5
|
+
import { r as l } from "./element-with-slot-BOuXlWSY.js";
|
|
6
|
+
import "./icon-DkVqRWbC.js";
|
|
7
|
+
import { n as u, t as d } from "./ref-DNowxdYH.js";
|
|
8
|
+
import "./tag-bztxjcF0.js";
|
|
9
|
+
import { t as f } from "./repeat-CZ1oMXnW.js";
|
|
10
|
+
import { a as p, c as m, i as h, l as g, o as _, r as v, s as y } from "./listbox-CrQboPG6.js";
|
|
11
|
+
import { t as b } from "./input-element-Qb0w3ChW.js";
|
|
12
|
+
import { t as x } from "./pkt-options-controller-XcIgx_v1.js";
|
|
13
|
+
import "./input-wrapper-Bg06k-cj.js";
|
|
13
14
|
//#region ../../shared-utils/combobox/input-utils.ts
|
|
14
|
-
var
|
|
15
|
+
var S = (e, t, n) => {
|
|
15
16
|
switch (e) {
|
|
16
17
|
case ",": return n ? "addValue" : null;
|
|
17
18
|
case "Enter": return "addValue";
|
|
@@ -20,12 +21,12 @@ var b = (e, t, n) => {
|
|
|
20
21
|
case "Escape": return "closeOptions";
|
|
21
22
|
default: return null;
|
|
22
23
|
}
|
|
23
|
-
},
|
|
24
|
+
}, C = (e, t, n, r, i) => {
|
|
24
25
|
if (!e) return {
|
|
25
26
|
action: "none",
|
|
26
27
|
value: null
|
|
27
28
|
};
|
|
28
|
-
let a =
|
|
29
|
+
let a = h(n, e);
|
|
29
30
|
return !t.includes(e) && !a ? r ? {
|
|
30
31
|
action: "addUserValue",
|
|
31
32
|
value: e
|
|
@@ -42,8 +43,8 @@ var b = (e, t, n) => {
|
|
|
42
43
|
action: "none",
|
|
43
44
|
value: null
|
|
44
45
|
};
|
|
45
|
-
},
|
|
46
|
-
...
|
|
46
|
+
}, w = (e, t, n, r, i) => e.trim().toLowerCase() ? {
|
|
47
|
+
...m(e, t, n, r),
|
|
47
48
|
shouldRemoveValue: !1,
|
|
48
49
|
shouldResetInput: !1
|
|
49
50
|
} : {
|
|
@@ -51,10 +52,10 @@ var b = (e, t, n) => {
|
|
|
51
52
|
userInfoMessage: "",
|
|
52
53
|
shouldRemoveValue: !i && !!t[0],
|
|
53
54
|
shouldResetInput: !0
|
|
54
|
-
},
|
|
55
|
-
let r =
|
|
55
|
+
}, T = (e, t, n) => {
|
|
56
|
+
let r = h(t, e);
|
|
56
57
|
return n === "label" && r?.label ? r.label : e;
|
|
57
|
-
},
|
|
58
|
+
}, E = {
|
|
58
59
|
markOptionSelected(e, t) {
|
|
59
60
|
if (t) {
|
|
60
61
|
for (let n of e) if (n.value === t) {
|
|
@@ -80,7 +81,7 @@ var b = (e, t, n) => {
|
|
|
80
81
|
removeUserAddedOptions(e) {
|
|
81
82
|
return e.filter((e) => !e.userAdded);
|
|
82
83
|
}
|
|
83
|
-
},
|
|
84
|
+
}, D = { parseOptionsFromSlot(e) {
|
|
84
85
|
let t = [];
|
|
85
86
|
return e.forEach((e) => {
|
|
86
87
|
if (!e.textContent && !e.getAttribute("value")) return;
|
|
@@ -88,22 +89,25 @@ var b = (e, t, n) => {
|
|
|
88
89
|
value: e.getAttribute("value") || e.textContent || "",
|
|
89
90
|
label: e.textContent || e.getAttribute("value") || ""
|
|
90
91
|
};
|
|
91
|
-
e.getAttribute("data-prefix") && (n.prefix = e.getAttribute("data-prefix") || void 0), e.getAttribute("tagskincolor") && (n.tagSkinColor = e.getAttribute("tagskincolor")), e.getAttribute("description") && (n.description = e.getAttribute("description") || void 0), n.fulltext =
|
|
92
|
+
e.getAttribute("data-prefix") && (n.prefix = e.getAttribute("data-prefix") || void 0), e.getAttribute("tagskincolor") && (n.tagSkinColor = e.getAttribute("tagskincolor")), e.getAttribute("description") && (n.description = e.getAttribute("description") || void 0), n.fulltext = v(n), t.push(n);
|
|
92
93
|
}), t;
|
|
93
|
-
} },
|
|
94
|
+
} }, O = {
|
|
95
|
+
cloneOptions(e) {
|
|
96
|
+
return Array.isArray(e) ? e.map((e) => ({ ...e })) : [];
|
|
97
|
+
},
|
|
94
98
|
syncOptionsWithValues(e, t) {
|
|
95
99
|
let n = [...t];
|
|
96
100
|
return e.forEach((e) => {
|
|
97
|
-
e.value && !e.label && (e.label = e.value), e.selected && !n.includes(e.value) && n.push(e.value), e.fulltext =
|
|
101
|
+
e.value && !e.label && (e.label = e.value), e.selected && !n.includes(e.value) && n.push(e.value), e.fulltext = v(e), e.selected = e.selected || n.includes(e.value);
|
|
98
102
|
}), {
|
|
99
103
|
options: e,
|
|
100
104
|
newValues: n
|
|
101
105
|
};
|
|
102
106
|
},
|
|
103
|
-
mergeWithUserAdded(e, t) {
|
|
104
|
-
return [...t.filter((e) => e?.userAdded && e.
|
|
107
|
+
mergeWithUserAdded(e, t, n) {
|
|
108
|
+
return [...t.filter((e) => e?.userAdded && n.includes(e.value)).filter((t) => !(Array.isArray(e) ? e : []).some((e) => e.value === t.value)), ...e];
|
|
105
109
|
}
|
|
106
|
-
},
|
|
110
|
+
}, k = {
|
|
107
111
|
name: "pkt-combobox",
|
|
108
112
|
react: "PktCombobox",
|
|
109
113
|
"css-class": "pkt-combobox",
|
|
@@ -223,12 +227,14 @@ var b = (e, t, n) => {
|
|
|
223
227
|
category: "contents"
|
|
224
228
|
},
|
|
225
229
|
helptextDropdown: {
|
|
230
|
+
attribute: "helptextdropdown",
|
|
226
231
|
type: "string",
|
|
227
232
|
name: "Utvidet hjelpetekst",
|
|
228
233
|
description: "Hjelpetekst som vises i en lukket boks man kan åpne",
|
|
229
234
|
category: "contents"
|
|
230
235
|
},
|
|
231
236
|
helptextDropdownButton: {
|
|
237
|
+
attribute: "helptextdropdownbutton",
|
|
232
238
|
type: "string",
|
|
233
239
|
name: "Knappetekst for hjelpetekst",
|
|
234
240
|
description: "Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst",
|
|
@@ -242,12 +248,14 @@ var b = (e, t, n) => {
|
|
|
242
248
|
category: "tech"
|
|
243
249
|
},
|
|
244
250
|
hasError: {
|
|
251
|
+
attribute: "haserror",
|
|
245
252
|
type: "boolean",
|
|
246
253
|
name: "Feil",
|
|
247
254
|
description: "Feltet har en feil",
|
|
248
255
|
category: "ui"
|
|
249
256
|
},
|
|
250
257
|
errorMessage: {
|
|
258
|
+
attribute: "errormessage",
|
|
251
259
|
type: "string",
|
|
252
260
|
name: "Feilmelding",
|
|
253
261
|
description: "Tekst som vises under feltet ved feil",
|
|
@@ -260,30 +268,35 @@ var b = (e, t, n) => {
|
|
|
260
268
|
category: "tech"
|
|
261
269
|
},
|
|
262
270
|
requiredTag: {
|
|
271
|
+
attribute: "requiredtag",
|
|
263
272
|
type: "boolean",
|
|
264
273
|
name: "Påkrevd-merking",
|
|
265
274
|
description: "Viser en merking som indikerer at feltet er påkrevd",
|
|
266
275
|
category: "ui"
|
|
267
276
|
},
|
|
268
277
|
requiredText: {
|
|
278
|
+
attribute: "requiredtext",
|
|
269
279
|
type: "string",
|
|
270
280
|
name: "Påkrevd-tekst",
|
|
271
281
|
description: "Tekst som vises i påkrevd-merkingen",
|
|
272
282
|
category: "contents"
|
|
273
283
|
},
|
|
274
284
|
optionalTag: {
|
|
285
|
+
attribute: "optionaltag",
|
|
275
286
|
type: "boolean",
|
|
276
287
|
name: "Valgfritt-merking",
|
|
277
288
|
description: "Viser en merking som indikerer at feltet er valgfritt",
|
|
278
289
|
category: "ui"
|
|
279
290
|
},
|
|
280
291
|
optionalText: {
|
|
292
|
+
attribute: "optionaltext",
|
|
281
293
|
type: "string",
|
|
282
294
|
name: "Valgfritt-tekst",
|
|
283
295
|
description: "Tekst som vises i valgfritt-merkingen",
|
|
284
296
|
category: "contents"
|
|
285
297
|
},
|
|
286
298
|
tagText: {
|
|
299
|
+
attribute: "tagtext",
|
|
287
300
|
type: "string",
|
|
288
301
|
name: "Tag-tekst",
|
|
289
302
|
description: "Tekst som vises i en tag ved siden av label",
|
|
@@ -425,6 +438,7 @@ var b = (e, t, n) => {
|
|
|
425
438
|
category: "ui"
|
|
426
439
|
},
|
|
427
440
|
useWrapper: {
|
|
441
|
+
attribute: "usewrapper",
|
|
428
442
|
name: "Bruk wrapper",
|
|
429
443
|
type: "boolean",
|
|
430
444
|
required: !1,
|
|
@@ -434,6 +448,7 @@ var b = (e, t, n) => {
|
|
|
434
448
|
category: "ui"
|
|
435
449
|
},
|
|
436
450
|
hasFieldset: {
|
|
451
|
+
attribute: "hasfieldset",
|
|
437
452
|
name: "Bruk fieldset",
|
|
438
453
|
type: "boolean",
|
|
439
454
|
required: !1,
|
|
@@ -448,6 +463,13 @@ var b = (e, t, n) => {
|
|
|
448
463
|
default: null,
|
|
449
464
|
description: "Viser teller under feltet. Slås på av seg selv når det finnes en grense å telle mot; sett til false for å skru den av.",
|
|
450
465
|
category: "ui"
|
|
466
|
+
},
|
|
467
|
+
defaultValue: {
|
|
468
|
+
attribute: "defaultvalue",
|
|
469
|
+
type: "string | string[]",
|
|
470
|
+
name: "Standardverdi",
|
|
471
|
+
description: "Verdien feltet får ved oppstart og ved nullstilling av skjemaet",
|
|
472
|
+
category: "functionality"
|
|
451
473
|
}
|
|
452
474
|
},
|
|
453
475
|
events: {
|
|
@@ -468,9 +490,9 @@ var b = (e, t, n) => {
|
|
|
468
490
|
description: "Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes"
|
|
469
491
|
}
|
|
470
492
|
}
|
|
471
|
-
},
|
|
493
|
+
}, A = class extends b {
|
|
472
494
|
constructor() {
|
|
473
|
-
super(), this.value = "", this.options = [], this.defaultOptions = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder =
|
|
495
|
+
super(), this.value = "", this.options = [], this.defaultOptions = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder = null, this.multiple = !1, this.maxlength = null, this.displayValueAs = k.props.displayValueAs.default, this.tagPlacement = null, this.isOpen = !1, this._options = [], this._value = [], this._isOptionsOpen = !1, this._userInfoMessage = "", this._messageValue = null, this._addValueText = null, this._maxIsReached = !1, this._search = "", this._inputFocus = !1, this._skipInputTab = !1, this._optionsFromSlot = !1, this._lastSlotGeneration = 0, this._suppressNextOpen = !1, this.inputRef = d(), this.triggerRef = d(), this.listboxRef = d(), this._pendingDispatchFrom = null, this.optionsController = new x(this);
|
|
474
496
|
}
|
|
475
497
|
get _hasTextInput() {
|
|
476
498
|
return this.typeahead || this.allowUserInput;
|
|
@@ -481,15 +503,30 @@ var b = (e, t, n) => {
|
|
|
481
503
|
focusTrigger() {
|
|
482
504
|
this._hasTextInput ? this.inputRef.value?.focus() : this.triggerRef.value?.focus();
|
|
483
505
|
}
|
|
506
|
+
focusAfterCommit() {
|
|
507
|
+
this._skipInputTab = !0;
|
|
508
|
+
let e = this.inputRef.value;
|
|
509
|
+
e && e.type !== "hidden" && e.setAttribute("tabindex", "-1"), this.triggerRef.value?.focus();
|
|
510
|
+
}
|
|
511
|
+
restoreInputTab() {
|
|
512
|
+
this._skipInputTab = !1;
|
|
513
|
+
}
|
|
484
514
|
parseValue() {
|
|
485
|
-
return
|
|
515
|
+
return this.parseToValues(this.value);
|
|
516
|
+
}
|
|
517
|
+
parseToValues(e) {
|
|
518
|
+
return Array.isArray(e) ? this.multiple ? e : e.length > 0 ? [e[0]] : [] : e && this.multiple ? e.split(",") : e ? [e] : [];
|
|
486
519
|
}
|
|
487
520
|
updateMaxReached() {
|
|
488
|
-
this._maxIsReached =
|
|
521
|
+
this._maxIsReached = g(this._value.length, this.maxlength);
|
|
489
522
|
}
|
|
490
|
-
|
|
491
|
-
let
|
|
492
|
-
|
|
523
|
+
syncPublicValue() {
|
|
524
|
+
let e = this.multiple ? this._value.join(",") : this._value[0] || "";
|
|
525
|
+
e !== (Array.isArray(this.value) ? this.value.join(",") : String(this.value || "")) && (this.value = e);
|
|
526
|
+
}
|
|
527
|
+
dispatchValueChange(e) {
|
|
528
|
+
let t = this._value;
|
|
529
|
+
if (e?.join(",") !== t.join(",")) {
|
|
493
530
|
let e = this.multiple ? [...t] : t[0] || "";
|
|
494
531
|
this.onChange(e);
|
|
495
532
|
} else t.length === 0 && e && e.length > 0 && this.clearInputValue();
|
|
@@ -502,53 +539,53 @@ var b = (e, t, n) => {
|
|
|
502
539
|
i([a({
|
|
503
540
|
type: String,
|
|
504
541
|
reflect: !0
|
|
505
|
-
})],
|
|
542
|
+
})], A.prototype, "value", void 0), i([a({ type: Array })], A.prototype, "options", void 0), i([a({
|
|
506
543
|
type: Array,
|
|
507
544
|
attribute: "default-options"
|
|
508
|
-
})],
|
|
545
|
+
})], A.prototype, "defaultOptions", void 0), i([a({
|
|
509
546
|
type: Boolean,
|
|
510
547
|
attribute: "allow-user-input"
|
|
511
|
-
})],
|
|
548
|
+
})], A.prototype, "allowUserInput", void 0), i([a({ type: Boolean })], A.prototype, "typeahead", void 0), i([a({
|
|
512
549
|
type: Boolean,
|
|
513
550
|
attribute: "include-search"
|
|
514
|
-
})],
|
|
551
|
+
})], A.prototype, "includeSearch", void 0), i([a({
|
|
515
552
|
type: String,
|
|
516
553
|
attribute: "search-placeholder"
|
|
517
|
-
})],
|
|
554
|
+
})], A.prototype, "searchPlaceholder", void 0), i([a({ type: Boolean })], A.prototype, "multiple", void 0), i([a({ type: Number })], A.prototype, "maxlength", void 0), i([a({
|
|
518
555
|
type: String,
|
|
519
556
|
attribute: "display-value-as"
|
|
520
|
-
})],
|
|
557
|
+
})], A.prototype, "displayValueAs", void 0), i([a({
|
|
521
558
|
type: String,
|
|
522
559
|
attribute: "tag-placement"
|
|
523
|
-
})],
|
|
560
|
+
})], A.prototype, "tagPlacement", void 0), i([a({
|
|
524
561
|
type: Boolean,
|
|
525
562
|
attribute: "open"
|
|
526
|
-
})],
|
|
563
|
+
})], A.prototype, "isOpen", void 0), i([r()], A.prototype, "_options", void 0), i([r()], A.prototype, "_value", void 0), i([r()], A.prototype, "_isOptionsOpen", void 0), i([r()], A.prototype, "_userInfoMessage", void 0), i([r()], A.prototype, "_messageValue", void 0), i([r()], A.prototype, "_addValueText", void 0), i([r()], A.prototype, "_maxIsReached", void 0), i([r()], A.prototype, "_search", void 0), i([r()], A.prototype, "_inputFocus", void 0), i([r()], A.prototype, "_skipInputTab", void 0);
|
|
527
564
|
//#endregion
|
|
528
565
|
//#region src/components/combobox/combobox-value.ts
|
|
529
|
-
var
|
|
566
|
+
var j = class extends A {
|
|
530
567
|
toggleValue(e) {
|
|
531
568
|
if (this.disabled) return;
|
|
532
569
|
this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
|
|
533
|
-
let t =
|
|
534
|
-
i || (!r && this.allowUserInput && !a ? (this.addNewUserValue(e), d = "valueAdded", l = s) : !r && !this.allowUserInput ? (o && this._value[0] && this.removeValue(this._value[0]), u = !1, l = !0, d = "noResults") : n ? (this.removeValue(t), l = !0, o && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "")) : a && o ? (this.removeAllSelected(), l = !0) : o ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t), l = !1) : s && !c ? (this.setSelected(t), l = !0) : s && c ? (d = "maxSelected", u = !1,
|
|
535
|
-
this.
|
|
536
|
-
}, 0)
|
|
570
|
+
let t = h(this.options, e)?.value || null, n = this._value.includes(e || t || ""), r = !!t, i = this._options.find((t) => t.value === e)?.disabled || !1, a = !e?.trim(), o = !this.multiple, s = this.multiple, c = g(this._value.length, this.maxlength), l = !1, u = !0, d = "", f = null, p = "";
|
|
571
|
+
i || (!r && this.allowUserInput && !a ? (this.addNewUserValue(e), d = "valueAdded", l = s) : !r && !this.allowUserInput ? (o && this._value[0] && this.removeValue(this._value[0]), u = !1, l = !0, d = "noResults") : n ? (this.removeValue(t), l = !0, o && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "")) : a && o ? (this.removeAllSelected(), l = !0) : o ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t), l = !1, d = "valueSelected", f = this._hasTextInput ? T(t || "", this.options, this.displayValueAs) : y(h(this.options, t), this.displayValueAs)) : s && !c ? (this.setSelected(t), l = !0) : s && c ? (d = "maxSelected", u = !1, p = e) : (o && this.removeAllSelected(), d = "noValidValue", u = !1, l = !0, p = e), this._isOptionsOpen = l, l || window.setTimeout(() => {
|
|
572
|
+
this.focusAfterCommit();
|
|
573
|
+
}, 0), this._search = p || "", this.resetComboboxInput(u), this._userInfoMessage = d, this._messageValue = f, s && this.updateMaxReached());
|
|
537
574
|
}
|
|
538
575
|
setSelected(e) {
|
|
539
576
|
if (!this._value.includes(e)) {
|
|
540
|
-
if (this.multiple &&
|
|
577
|
+
if (this.multiple && g(this._value.length, this.maxlength)) {
|
|
541
578
|
this._userInfoMessage = "maxSelected";
|
|
542
579
|
return;
|
|
543
580
|
}
|
|
544
|
-
!this.multiple && this.removeAllSelected(), this._value = e ? [...this._value, e] : this._value,
|
|
581
|
+
!this.multiple && this.removeAllSelected(), this._value = e ? [...this._value, e] : this._value, E.markOptionSelected(this._options, e), this.resetComboboxInput(!0);
|
|
545
582
|
}
|
|
546
583
|
}
|
|
547
584
|
removeSelected(e) {
|
|
548
585
|
if (!e) return;
|
|
549
586
|
this._value = this._value.filter((t) => t !== e);
|
|
550
|
-
let t =
|
|
551
|
-
t && (
|
|
587
|
+
let t = h(this.options, e);
|
|
588
|
+
t && (E.markOptionDeselected(this.options, e), t.userAdded ? (this._options = [...this._options.filter((t) => t.value !== e)], this.options = [...this.options.filter((t) => t.value !== e)]) : this._options.some((t) => t.value === e) || (this._options = [...this._options, t]));
|
|
552
589
|
}
|
|
553
590
|
addAllOptions() {
|
|
554
591
|
if (this.multiple) {
|
|
@@ -556,11 +593,11 @@ var k = class extends O {
|
|
|
556
593
|
this._userInfoMessage = "tooManySelected";
|
|
557
594
|
return;
|
|
558
595
|
}
|
|
559
|
-
this._value = this._options.map((e) => e.value),
|
|
596
|
+
this._value = this._options.map((e) => e.value), E.markAllSelected(this._options), this.requestUpdate();
|
|
560
597
|
}
|
|
561
598
|
}
|
|
562
599
|
removeAllSelected() {
|
|
563
|
-
this._value = [],
|
|
600
|
+
this._value = [], E.markAllDeselected(this._options), this._options = E.removeUserAddedOptions(this._options), this.requestUpdate();
|
|
564
601
|
}
|
|
565
602
|
addValue() {
|
|
566
603
|
let e = this.inputRef.value?.value.trim() || "";
|
|
@@ -576,8 +613,8 @@ var k = class extends O {
|
|
|
576
613
|
addNewUserValue(e) {
|
|
577
614
|
if (!e || e.trim() === "") return;
|
|
578
615
|
if (!this.multiple) this._value[0] && this.removeSelected(this._value[0]), this._value = [e];
|
|
579
|
-
else if (!
|
|
580
|
-
if (
|
|
616
|
+
else if (!h(this.options, e)) {
|
|
617
|
+
if (g(this._value.length, this.maxlength)) return;
|
|
581
618
|
this._value = [...this._value, e];
|
|
582
619
|
}
|
|
583
620
|
let t = {
|
|
@@ -586,12 +623,16 @@ var k = class extends O {
|
|
|
586
623
|
userAdded: !0,
|
|
587
624
|
selected: !0
|
|
588
625
|
};
|
|
589
|
-
this.options = [t, ...this.options], this._options = [t, ...this._options], this.resetComboboxInput(!0), this.multiple || (this._isOptionsOpen = !1,
|
|
590
|
-
this.
|
|
626
|
+
this.options = [t, ...this.options], this._options = [t, ...this._options], this.resetComboboxInput(!0), this.multiple || (this._isOptionsOpen = !1, window.setTimeout(() => {
|
|
627
|
+
this.focusAfterCommit();
|
|
591
628
|
}, 0)), this.requestUpdate();
|
|
592
629
|
}
|
|
630
|
+
refreshOptionsFromValue() {
|
|
631
|
+
let e = O.cloneOptions(this.options);
|
|
632
|
+
e.forEach((e) => e.selected = this._value.includes(e.value)), this._options = O.syncOptionsWithValues(e, this._value).options;
|
|
633
|
+
}
|
|
593
634
|
resetComboboxInput(e = !0) {
|
|
594
|
-
this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && e && (this._search = "", this.multiple ? this.inputRef.value.value = "" : (this.inputRef.value.value = this._value[0] ?
|
|
635
|
+
this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && e && (this._search = "", this.multiple ? this.inputRef.value.value = "" : (this.inputRef.value.value = this._value[0] ? T(this._value[0], this.options, this.displayValueAs) : "", this._userInfoMessage = "")), this.refreshOptionsFromValue();
|
|
595
636
|
}
|
|
596
637
|
removeLastValue(e) {
|
|
597
638
|
if (this._value.length === 0) return;
|
|
@@ -599,31 +640,34 @@ var k = class extends O {
|
|
|
599
640
|
let t = this._value[this._value.length - 1];
|
|
600
641
|
t && this.removeSelected(t), this.updateMaxReached();
|
|
601
642
|
}
|
|
602
|
-
},
|
|
643
|
+
}, M = class extends j {
|
|
603
644
|
handleInput(e) {
|
|
604
645
|
if (e.stopPropagation(), e.stopImmediatePropagation(), this.disabled) return;
|
|
605
646
|
this.touched = !0;
|
|
606
647
|
let t = e.target;
|
|
607
648
|
if (this._search = t.value, this.checkForMatches(), this.typeahead) {
|
|
608
649
|
if (this._search) {
|
|
609
|
-
let { filtered: n, suggestion: r } =
|
|
650
|
+
let { filtered: n, suggestion: r } = _(this.options, this._search);
|
|
610
651
|
this._options = n, e.inputType !== "deleteContentBackward" && r?.label && this.inputRef.value && this.inputRef.value.type !== "hidden" && (t.value = r.label, window.setTimeout(() => t.setSelectionRange(this._search.length, t.value.length), 0), t.selectionDirection = "backward");
|
|
611
|
-
} else this.
|
|
652
|
+
} else this.refreshOptionsFromValue();
|
|
612
653
|
}
|
|
613
654
|
}
|
|
614
655
|
handleFocus() {
|
|
615
656
|
if (!this.disabled) {
|
|
616
|
-
if (this._suppressNextOpen) {
|
|
657
|
+
if (this._skipInputTab = !1, this._suppressNextOpen) {
|
|
617
658
|
this._suppressNextOpen = !1, this._inputFocus = !0, this.requestUpdate();
|
|
618
659
|
return;
|
|
619
660
|
}
|
|
620
|
-
!this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value =
|
|
661
|
+
!this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = T(this._value[0], this.options, this.displayValueAs)), this._inputFocus = !0, this._search = "", this.refreshOptionsFromValue(), this._isOptionsOpen = !0, this.onFocus(), this.requestUpdate();
|
|
621
662
|
}
|
|
622
663
|
}
|
|
664
|
+
handleCloseOptions() {
|
|
665
|
+
this._isOptionsOpen = !1, this._hasTextInput && (this._suppressNextOpen = !0), this.focusTrigger();
|
|
666
|
+
}
|
|
623
667
|
handleFocusOut(e) {
|
|
624
668
|
if (this.disabled || !this._isOptionsOpen) return;
|
|
625
669
|
let t = e.relatedTarget;
|
|
626
|
-
t?.closest("pkt-combobox")?.id
|
|
670
|
+
t?.closest("pkt-combobox")?.id === this.id || e.target?.classList?.contains("pkt-combobox__value") || t === this.inputRef.value || t === this.triggerRef.value || this.closeAndProcessInput();
|
|
627
671
|
}
|
|
628
672
|
closeAndProcessInput() {
|
|
629
673
|
if (this._inputFocus = !1, this._addValueText = null, this._userInfoMessage = "", this._search = "", this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
@@ -631,11 +675,11 @@ var k = class extends O {
|
|
|
631
675
|
if (!this.multiple) {
|
|
632
676
|
if (!e) this._value[0] && this.removeSelected(this._value[0]);
|
|
633
677
|
else {
|
|
634
|
-
let t =
|
|
678
|
+
let t = h(this.options, e);
|
|
635
679
|
t && t.value !== this._value[0] ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t.value)) : !t && this.allowUserInput && (this._value[0] && this.removeSelected(this._value[0]), this.addNewUserValue(e));
|
|
636
680
|
}
|
|
637
681
|
} else if (e !== "") {
|
|
638
|
-
let { action: t, value: n } =
|
|
682
|
+
let { action: t, value: n } = C(e, this._value, this.options, this.allowUserInput, this.multiple);
|
|
639
683
|
switch (t) {
|
|
640
684
|
case "addUserValue":
|
|
641
685
|
this.addNewUserValue(n);
|
|
@@ -646,7 +690,7 @@ var k = class extends O {
|
|
|
646
690
|
case "removeValue": this.removeValue(n);
|
|
647
691
|
}
|
|
648
692
|
}
|
|
649
|
-
!this.multiple && this._value[0] ? this.inputRef.value.value =
|
|
693
|
+
!this.multiple && this._value[0] ? this.inputRef.value.value = T(this._value[0], this.options, this.displayValueAs) : this.inputRef.value.value = "";
|
|
650
694
|
}
|
|
651
695
|
this._isOptionsOpen = !1, this.onBlur();
|
|
652
696
|
}
|
|
@@ -704,7 +748,7 @@ var k = class extends O {
|
|
|
704
748
|
return;
|
|
705
749
|
}
|
|
706
750
|
}
|
|
707
|
-
let t =
|
|
751
|
+
let t = S(e.key, e.shiftKey, this.multiple);
|
|
708
752
|
if (t && !(e.key === "Tab" && !this._isOptionsOpen)) {
|
|
709
753
|
if (t === "focusListbox" && e.key === "Tab" && !this.listboxRef.value?.querySelector("[role=\"option\"]:not([data-disabled]), [data-type=\"new-option\"]")) {
|
|
710
754
|
this.closeAndProcessInput();
|
|
@@ -765,14 +809,14 @@ var k = class extends O {
|
|
|
765
809
|
}
|
|
766
810
|
}
|
|
767
811
|
checkForMatches() {
|
|
768
|
-
let e =
|
|
812
|
+
let e = w(this.inputRef.value?.value || this._search || "", this._value, this.options, this.allowUserInput, this.multiple);
|
|
769
813
|
if (e.shouldRemoveValue && this.removeValue(this._value[0]), e.shouldResetInput) {
|
|
770
814
|
this.resetComboboxInput(!1);
|
|
771
815
|
return;
|
|
772
816
|
}
|
|
773
817
|
this._addValueText = e.addValueText, this._userInfoMessage = e.userInfoMessage;
|
|
774
818
|
}
|
|
775
|
-
},
|
|
819
|
+
}, N = class extends M {
|
|
776
820
|
constructor(...e) {
|
|
777
821
|
super(...e), this.handleBodyClick = (e) => {
|
|
778
822
|
this._isOptionsOpen && !this.contains(e.target) && this.closeAndProcessInput();
|
|
@@ -781,56 +825,59 @@ var k = class extends O {
|
|
|
781
825
|
connectedCallback() {
|
|
782
826
|
if (super.connectedCallback(), document?.body.addEventListener("click", this.handleBodyClick), this._options = [], this.defaultOptions && this.defaultOptions.length) {
|
|
783
827
|
let e = this.options?.filter((e) => e.userAdded) || [];
|
|
784
|
-
this.options = [...e, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options =
|
|
828
|
+
this.options = [...e, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = O.cloneOptions(this.options);
|
|
785
829
|
}
|
|
786
830
|
if (this.optionsController?.nodes && this.optionsController.nodes.length) {
|
|
787
|
-
let e =
|
|
831
|
+
let e = D.parseOptionsFromSlot(this.optionsController.nodes);
|
|
788
832
|
e.length && (this.options = [...e], this._options = [...e], this._optionsFromSlot = !0, this._lastSlotGeneration = this.optionsController.generation);
|
|
789
833
|
}
|
|
790
834
|
}
|
|
835
|
+
disconnectedCallback() {
|
|
836
|
+
super.disconnectedCallback(), document?.body.removeEventListener("click", this.handleBodyClick);
|
|
837
|
+
}
|
|
838
|
+
firstUpdated(e) {
|
|
839
|
+
this.defaultValue !== null && !this.value && (this.value = this.defaultValue), super.firstUpdated(e);
|
|
840
|
+
}
|
|
791
841
|
willUpdate(e) {
|
|
792
842
|
if (this._optionsFromSlot && this.optionsController) {
|
|
793
843
|
let e = this.optionsController.generation;
|
|
794
844
|
if (e !== this._lastSlotGeneration) {
|
|
795
845
|
this._lastSlotGeneration = e;
|
|
796
|
-
let t =
|
|
846
|
+
let t = D.parseOptionsFromSlot(this.optionsController.nodes), n = this._options.filter((e) => e.userAdded);
|
|
797
847
|
this.options = [...n, ...t];
|
|
798
848
|
}
|
|
799
849
|
}
|
|
800
|
-
super.willUpdate(e)
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
firstUpdated(e) {
|
|
806
|
-
this.defaultValue !== null && !this.value && (this.value = this.defaultValue), super.firstUpdated(e);
|
|
807
|
-
}
|
|
808
|
-
updated(e) {
|
|
809
|
-
e.has("isOpen") && (this._isOptionsOpen = this.isOpen);
|
|
850
|
+
if (super.willUpdate(e), e.has("isOpen") && (this._isOptionsOpen = this.isOpen), e.has("defaultOptions") && this.defaultOptions.length) {
|
|
851
|
+
let e = (Array.isArray(this.options) ? this.options : []).filter((e) => e.userAdded) || [];
|
|
852
|
+
this.options = [...e, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = O.cloneOptions(this.options);
|
|
853
|
+
}
|
|
810
854
|
let t = e.has("value"), n = e.has("_value");
|
|
811
|
-
if (t
|
|
812
|
-
else if (t) {
|
|
855
|
+
if (t) {
|
|
813
856
|
let e = [...this._value], t = this.parseValue();
|
|
814
|
-
t.join(",") !== this._value.join(",") && (this._value = t, this.
|
|
815
|
-
} else n && this.
|
|
816
|
-
if (e.has("
|
|
817
|
-
let e =
|
|
818
|
-
this.
|
|
857
|
+
t.join(",") !== this._value.join(",") && (this._value = t, this._options.forEach((e) => e.selected = t.includes(e.value)), this._options = [...this._options]), this._pendingDispatchFrom ??= e;
|
|
858
|
+
} else n && (this._pendingDispatchFrom ??= e.get("_value") ?? []);
|
|
859
|
+
if (e.has("defaultValue") && this.defaultValue != null && !this._value.length) {
|
|
860
|
+
let e = this.parseToValues(this.defaultValue);
|
|
861
|
+
e.length && (this._pendingDispatchFrom ??= [...this._value], this._value = e, this._options.forEach((t) => t.selected = e.includes(t.value)), this._options = [...this._options]);
|
|
819
862
|
}
|
|
820
863
|
if (e.has("options")) {
|
|
821
|
-
let t = e.get("options") || this._options || [], n =
|
|
864
|
+
let t = e.get("options") || this._options || [], n = O.mergeWithUserAdded(O.cloneOptions(this.options), t, this._value);
|
|
822
865
|
this._options = n, n.length > this.options.length && (this.options = n);
|
|
823
|
-
let r =
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
866
|
+
let r = O.syncOptionsWithValues(this._options, this._value);
|
|
867
|
+
this._options = r.options, r.newValues.length > this._value.length && (this._pendingDispatchFrom ??= [...this._value], this._value = r.newValues);
|
|
868
|
+
}
|
|
869
|
+
(t || n || e.has("options") || e.has("defaultValue")) && this.updateMaxReached(), this._pendingDispatchFrom && this.syncPublicValue();
|
|
870
|
+
}
|
|
871
|
+
updated(e) {
|
|
872
|
+
if (this._pendingDispatchFrom) {
|
|
873
|
+
let e = this._pendingDispatchFrom;
|
|
874
|
+
this._pendingDispatchFrom = null, this.dispatchValueChange(e);
|
|
828
875
|
}
|
|
829
876
|
if (e.has("_search") && this.dispatchEvent(new CustomEvent("search", {
|
|
830
877
|
detail: this._search,
|
|
831
878
|
bubbles: !1
|
|
832
879
|
})), !this._isOptionsOpen && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
833
|
-
let e = !this.multiple && this._value[0] ?
|
|
880
|
+
let e = !this.multiple && this._value[0] ? T(this._value[0], this.options, this.displayValueAs) : "";
|
|
834
881
|
this.inputRef.value.value !== e && (this.inputRef.value.value = e);
|
|
835
882
|
}
|
|
836
883
|
this.classList.add("pkt-combobox-component"), this.classList.toggle("pkt-combobox-component--fullwidth", !!this.fullwidth), super.updated(e);
|
|
@@ -848,8 +895,8 @@ var k = class extends O {
|
|
|
848
895
|
}
|
|
849
896
|
attributeChangedCallback(e, t, n) {
|
|
850
897
|
if (e === "options") {
|
|
851
|
-
this._options =
|
|
852
|
-
let e =
|
|
898
|
+
this._options = O.cloneOptions(this.options);
|
|
899
|
+
let e = O.syncOptionsWithValues(this._options, this._value);
|
|
853
900
|
this._options = e.options, e.newValues.length > this._value.length && (this._value = e.newValues), this._search = "";
|
|
854
901
|
}
|
|
855
902
|
super.attributeChangedCallback(e, t, n);
|
|
@@ -882,7 +929,7 @@ var k = class extends O {
|
|
|
882
929
|
class="pkt-combobox__wrapper"
|
|
883
930
|
@labelClick=${this.handleInputClick}
|
|
884
931
|
>
|
|
885
|
-
<div class="pkt-contents" slot="helptext">${
|
|
932
|
+
<div class="pkt-contents" slot="helptext">${l(this, "helptext")}</div>
|
|
886
933
|
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
887
934
|
<div
|
|
888
935
|
class=${o({
|
|
@@ -899,16 +946,17 @@ var k = class extends O {
|
|
|
899
946
|
aria-controls=${s(this._hasTextInput ? void 0 : `${this.id}-listbox`)}
|
|
900
947
|
aria-haspopup=${s(this._hasTextInput ? void 0 : "listbox")}
|
|
901
948
|
aria-labelledby=${s(this._hasTextInput ? void 0 : `${this.id}-combobox-label`)}
|
|
902
|
-
aria-activedescendant=${s(!this._hasTextInput && this._value[0] &&
|
|
949
|
+
aria-activedescendant=${s(!this._hasTextInput && this._isOptionsOpen && this._value[0] && h(this.options, this._value[0]) ? `${this.id}-listbox-${p(this._options, this._value[0])}` : void 0)}
|
|
903
950
|
aria-description=${s(this._selectionDescription || void 0)}
|
|
904
951
|
tabindex=${this._hasTextInput || this.disabled ? "-1" : "0"}
|
|
905
952
|
@click=${this.handleInputClick}
|
|
906
953
|
@keydown=${this._hasTextInput ? n : this.handleSelectOnlyKeydown}
|
|
907
|
-
|
|
954
|
+
@blur=${this.restoreInputTab}
|
|
955
|
+
${u(this.triggerRef)}
|
|
908
956
|
>
|
|
909
957
|
${!this._hasTextInput && this.placeholder && (!this._value.length || this.multiple && this.tagPlacement == "outside") && !this._inputFocus ? e`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
|
|
910
|
-
|
|
911
|
-
|
|
958
|
+
>${this.placeholder}</span
|
|
959
|
+
>` : this.tagPlacement === "outside" ? n : this.renderSingleOrMultipleValues()}
|
|
912
960
|
${this.renderInputField()}
|
|
913
961
|
<pkt-icon
|
|
914
962
|
class=${o({
|
|
@@ -926,26 +974,27 @@ var k = class extends O {
|
|
|
926
974
|
.isOpen=${this._isOptionsOpen}
|
|
927
975
|
.searchPlaceholder=${this.searchPlaceholder}
|
|
928
976
|
.label="Liste: ${this.label || ""}"
|
|
977
|
+
?disabled=${this.disabled}
|
|
929
978
|
?include-search=${this.includeSearch}
|
|
930
979
|
?is-multi-select=${this.multiple}
|
|
931
980
|
?allow-user-input=${this.allowUserInput && !this._maxIsReached}
|
|
932
981
|
?max-is-reached=${this._maxIsReached}
|
|
933
982
|
.customUserInput=${s(this._addValueText)}
|
|
934
|
-
.userMessage=${this._userInfoMessage ? this.pktStrings.get("combobox")[this._userInfoMessage] : ""}
|
|
983
|
+
.userMessage=${this._userInfoMessage ? c(this.pktStrings.get("combobox")[this._userInfoMessage], { value: this._messageValue ?? "" }) : ""}
|
|
935
984
|
@search=${this.handleSearch}
|
|
936
985
|
@option-toggle=${this.handleOptionToggled}
|
|
937
986
|
@select-all=${this.addAllOptions}
|
|
938
|
-
@close-options=${
|
|
987
|
+
@close-options=${this.handleCloseOptions}
|
|
939
988
|
@tab-close=${() => this.closeAndProcessInput()}
|
|
940
989
|
.searchValue=${this._search || null}
|
|
941
990
|
.maxLength=${this.maxlength || 0}
|
|
942
|
-
${
|
|
991
|
+
${u(this.listboxRef)}
|
|
943
992
|
></pkt-listbox>
|
|
944
993
|
</div>
|
|
945
994
|
|
|
946
995
|
${this.tagPlacement === "outside" && this.multiple ? e`<div class="pkt-combobox__tags-outside">
|
|
947
|
-
|
|
948
|
-
|
|
996
|
+
${this.renderSingleOrMultipleValues()}
|
|
997
|
+
</div>` : n}
|
|
949
998
|
</pkt-input-wrapper>
|
|
950
999
|
`;
|
|
951
1000
|
}
|
|
@@ -961,6 +1010,7 @@ var k = class extends O {
|
|
|
961
1010
|
@change=${(e) => {
|
|
962
1011
|
e.stopPropagation(), e.stopImmediatePropagation();
|
|
963
1012
|
}}
|
|
1013
|
+
tabindex=${s(this._skipInputTab ? "-1" : void 0)}
|
|
964
1014
|
@keydown=${this.handleInputKeydown}
|
|
965
1015
|
@focus=${this.handleFocus}
|
|
966
1016
|
@blur=${this.handleBlur}
|
|
@@ -970,9 +1020,9 @@ var k = class extends O {
|
|
|
970
1020
|
aria-label=${s(this.label)}
|
|
971
1021
|
aria-autocomplete=${this.typeahead ? "both" : this.allowUserInput ? "list" : "none"}
|
|
972
1022
|
aria-controls="${this.id}-listbox"
|
|
973
|
-
aria-activedescendant=${s(this._value[0] &&
|
|
1023
|
+
aria-activedescendant=${s(this._isOptionsOpen && this._value[0] && h(this.options, this._value[0]) ? `${this.id}-listbox-${p(this._options, this._value[0])}` : void 0)}
|
|
974
1024
|
aria-description=${s(this._selectionDescription || void 0)}
|
|
975
|
-
${
|
|
1025
|
+
${u(this.inputRef)}
|
|
976
1026
|
/>
|
|
977
1027
|
</div>
|
|
978
1028
|
` : e`
|
|
@@ -981,16 +1031,16 @@ var k = class extends O {
|
|
|
981
1031
|
id="${this.id}-input"
|
|
982
1032
|
name=${(this.name || this.id) + "-input"}
|
|
983
1033
|
.value=${this._value.join(",")}
|
|
984
|
-
${
|
|
1034
|
+
${u(this.inputRef)}
|
|
985
1035
|
/>
|
|
986
1036
|
`;
|
|
987
1037
|
}
|
|
988
1038
|
renderSingleOrMultipleValues() {
|
|
989
1039
|
if (!this.multiple && this._hasTextInput) return n;
|
|
990
|
-
let t = !this.multiple, r = this.renderValueTag(
|
|
1040
|
+
let t = !this.multiple, r = this.renderValueTag(h(this.options, this._value[0])), i = this.tagPlacement === "outside", a = e`
|
|
991
1041
|
<ul role="list" class="pkt-combobox__tag-list">
|
|
992
|
-
${
|
|
993
|
-
let a =
|
|
1042
|
+
${f(this._value, (e) => e, (t, r) => {
|
|
1043
|
+
let a = h(this.options, t), o = a?.tagSkinColor;
|
|
994
1044
|
return e`
|
|
995
1045
|
<li
|
|
996
1046
|
role="listitem"
|
|
@@ -1011,30 +1061,24 @@ var k = class extends O {
|
|
|
1011
1061
|
})}
|
|
1012
1062
|
</ul>
|
|
1013
1063
|
`;
|
|
1014
|
-
return t ? r : a;
|
|
1064
|
+
return !t && this._value.length === 0 ? n : t ? r : a;
|
|
1015
1065
|
}
|
|
1016
1066
|
renderValueTag(t) {
|
|
1017
1067
|
if (!t) return "";
|
|
1018
1068
|
switch (this.displayValueAs) {
|
|
1019
|
-
case "prefixAndValue": return e`<span class="pkt-combobox__value"
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
case "value": return e`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
1023
|
-
>${t.value}</span
|
|
1024
|
-
>`;
|
|
1025
|
-
default: return e`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
1026
|
-
>${t.label || t.value}</span
|
|
1027
|
-
>`;
|
|
1069
|
+
case "prefixAndValue": return e`<span class="pkt-combobox__value">${t.prefix || ""} ${t.value}</span>`;
|
|
1070
|
+
case "value": return e`<span class="pkt-combobox__value">${t.value}</span>`;
|
|
1071
|
+
default: return e`<span class="pkt-combobox__value">${t.label || t.value}</span>`;
|
|
1028
1072
|
}
|
|
1029
1073
|
}
|
|
1030
1074
|
};
|
|
1031
1075
|
try {
|
|
1032
|
-
t("pkt-combobox")(
|
|
1076
|
+
t("pkt-combobox")(N);
|
|
1033
1077
|
} catch {
|
|
1034
1078
|
console.warn("Forsøker å definere <pkt-combobox>, men den er allerede definert");
|
|
1035
1079
|
}
|
|
1036
1080
|
//#endregion
|
|
1037
1081
|
//#region src/components/combobox/index.ts
|
|
1038
|
-
var
|
|
1082
|
+
var P = N;
|
|
1039
1083
|
//#endregion
|
|
1040
|
-
export {
|
|
1084
|
+
export { N as n, P as t };
|