@oslokommune/punkt-elements 12.34.2 → 12.34.4
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 +6 -0
- package/dist/accordion.d.ts +0 -46
- package/dist/{accordionitem-Cg-LZy7n.js → accordionitem-Db-3WiJS.js} +3 -3
- package/dist/{accordionitem-DDnUkCJP.cjs → accordionitem-cvsySqgK.cjs} +1 -1
- package/dist/{alert-BOvwM-m4.js → alert-B5lVS6Qs.js} +5 -5
- package/dist/{alert-B3HuK30R.cjs → alert-DWIElKEZ.cjs} +1 -1
- package/dist/alert.d.ts +0 -46
- package/dist/{backlink-1p-ADrG8.cjs → backlink-HHM21crL.cjs} +1 -1
- package/dist/{backlink-fjBQGFYt.js → backlink-hvyJmwrO.js} +2 -2
- package/dist/backlink.d.ts +0 -46
- package/dist/{button-Cl6psvlo.js → button-B6uRE7uT.js} +2 -2
- package/dist/{button-5tOMyPEx.cjs → button-BNdVIhUp.cjs} +1 -1
- package/dist/button.d.ts +0 -46
- package/dist/{calendar-Bi49Yxom.js → calendar-mTDcujoj.js} +4 -4
- package/dist/{calendar-BU7DqDLG.cjs → calendar-oX4HJomV.cjs} +1 -1
- package/dist/calendar.d.ts +0 -46
- package/dist/{card-Dphjc_iO.js → card-B5zTEmH1.js} +6 -6
- package/dist/{card-a_Cs18EQ.cjs → card-BDcr3PII.cjs} +1 -1
- package/dist/card.d.ts +0 -46
- package/dist/{checkbox-bsBqWqcn.cjs → checkbox-CqatE-eX.cjs} +1 -1
- package/dist/{checkbox-nAnAn0E5.js → checkbox-CyYfA2fu.js} +4 -4
- package/dist/checkbox.d.ts +0 -46
- package/dist/{class-map-BjTUtIEl.cjs → class-map-DCyaICmy.cjs} +1 -1
- package/dist/{class-map-D4QK1bDP.js → class-map-KyMqi0fa.js} +1 -1
- package/dist/{combobox-CKmkM6tY.js → combobox-CELUAZxF.js} +129 -125
- package/dist/combobox-D9NKnao2.cjs +115 -0
- package/dist/combobox.d.ts +0 -46
- package/dist/{datepicker-DarYkBIy.js → datepicker-B6qk_tTl.js} +11 -11
- package/dist/{datepicker-DW6AdQ9X.cjs → datepicker-CskZMUib.cjs} +1 -1
- package/dist/datepicker.d.ts +0 -46
- package/dist/{directive-helpers-CVAnO9Xf.js → directive-helpers-8uS_Izwn.js} +1 -1
- package/dist/{directive-helpers-CQimZ5PA.cjs → directive-helpers-CG7Oxal3.cjs} +1 -1
- package/dist/element-BSypUpzA.cjs +238 -0
- package/dist/{element-J964Wi0N.js → element-DjjF_tEh.js} +6679 -6673
- package/dist/{helptext-qBgH0lvl.js → helptext-BLHAJ1aC.js} +5 -5
- package/dist/{helptext-OW48aGy8.cjs → helptext-CCnYxYA9.cjs} +1 -1
- package/dist/helptext.d.ts +0 -46
- package/dist/{icon-kSv2VoAB.js → icon-Beoxup8E.js} +1 -1
- package/dist/{icon-Cc4gVHxd.cjs → icon-BnKGwYjj.cjs} +1 -1
- package/dist/icon.d.ts +0 -46
- package/dist/{if-defined-DEXc_i_J.js → if-defined-BErSJCeJ.js} +1 -1
- package/dist/{if-defined-ZR_9IQ1L.cjs → if-defined-a3sotaUr.cjs} +1 -1
- package/dist/index.d.ts +0 -46
- package/dist/{input-element-BoUU9kvo.js → input-element-Bic-t96S.js} +2 -2
- package/dist/{input-element-BYE0qiMh.cjs → input-element-C9ma8cdz.cjs} +1 -1
- package/dist/{input-wrapper-CZI_ibQL.js → input-wrapper-CeeNYbDA.js} +6 -6
- package/dist/{input-wrapper-DmVnotQ2.cjs → input-wrapper-Cn929YTV.cjs} +1 -1
- package/dist/input-wrapper.d.ts +0 -46
- package/dist/{link-D1Nr-VBI.js → link-BYI8VNGd.js} +4 -4
- package/dist/{link-3uccc2MM.cjs → link-CnibgS3c.cjs} +1 -1
- package/dist/link.d.ts +0 -46
- package/dist/{linkcard-CTNdTxvV.js → linkcard--zuuAt_v.js} +3 -3
- package/dist/{linkcard-P1I3dzQb.cjs → linkcard-DPGX1kb1.cjs} +1 -1
- package/dist/linkcard.d.ts +0 -46
- package/dist/{listbox-B4tiuVzB.js → listbox-C1oYnM-t.js} +5 -5
- package/dist/{listbox-BQu6MjAp.cjs → listbox-DqpGh7eq.cjs} +1 -1
- package/dist/listbox.d.ts +0 -46
- package/dist/{loader-CM7wLajY.cjs → loader-BN4q8pSl.cjs} +1 -1
- package/dist/{loader-C0zNKIJ0.js → loader-DgIiyYBl.js} +5 -5
- package/dist/loader.d.ts +0 -46
- package/dist/{messagebox-CD8fS0Ym.cjs → messagebox-BWJr42m9.cjs} +1 -1
- package/dist/{messagebox-DyLx08sr.js → messagebox-cme5VbUM.js} +5 -5
- package/dist/messagebox.d.ts +0 -46
- package/dist/{modal-Dnv6Y4Nv.js → modal-B-varrJT.js} +5 -5
- package/dist/{modal-DOCsiHGv.cjs → modal-cPcTJriW.cjs} +1 -1
- package/dist/modal.d.ts +0 -46
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -2
- 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-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-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.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 +27 -27
- 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-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -2
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.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/{progressbar-D3sqQ5g1.js → progressbar-BKt_aj7f.js} +5 -5
- package/dist/{progressbar-BmI-K95y.cjs → progressbar-DiRfScnB.cjs} +1 -1
- package/dist/progressbar.d.ts +0 -46
- package/dist/{radiobutton-CJYNTtFF.cjs → radiobutton-CIW0FvT8.cjs} +1 -1
- package/dist/{radiobutton-Bat-fmTh.js → radiobutton-DtHuz7qn.js} +5 -5
- package/dist/radiobutton.d.ts +0 -46
- package/dist/{ref-BbKbXwub.cjs → ref-BvbyvXRH.cjs} +2 -2
- package/dist/{ref-3rhflVgg.js → ref-iIffqQAI.js} +10 -10
- package/dist/{repeat-DK_E7chz.cjs → repeat-BnuruAat.cjs} +1 -1
- package/dist/{repeat-CTBD0h6a.js → repeat-D4kMediE.js} +2 -2
- package/dist/{select-Swc0c6lZ.cjs → select-BJziJVde.cjs} +1 -1
- package/dist/{select-CVWm9dL1.js → select-DbRLz-7l.js} +6 -6
- package/dist/select.d.ts +0 -46
- package/dist/{state-y7tCw3bg.cjs → state-B5KCNjEd.cjs} +1 -1
- package/dist/{state-fdb9lRrL.js → state-BtbpSrdV.js} +1 -1
- package/dist/{tag-Dizhf3tl.js → tag-CGnj4c1Z.js} +6 -6
- package/dist/{tag-Dg2-c_OZ.cjs → tag-CgkUxA5D.cjs} +1 -1
- package/dist/tag.d.ts +0 -46
- package/dist/{textarea-DkQfMu1d.js → textarea-CiA4IzMs.js} +9 -9
- package/dist/{textarea-go_AyeP-.cjs → textarea-qX4Inr1X.cjs} +1 -1
- package/dist/textarea.d.ts +0 -46
- package/dist/{textinput-FvLq5W70.cjs → textinput-BlsgLNwW.cjs} +1 -1
- package/dist/{textinput-CyJB8IDv.js → textinput-CrxjZNEq.js} +8 -8
- package/dist/textinput.d.ts +0 -46
- package/package.json +5 -5
- package/src/components/combobox/combobox.ts +17 -3
- package/dist/combobox-DqHwVglB.cjs +0 -115
- package/dist/element-BYpg5e6C.cjs +0 -238
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as n, x as r, n as s, a as d } from "./element-
|
|
2
|
-
import { P as k } from "./input-element-
|
|
3
|
-
import { e as b, n as f } from "./ref-
|
|
4
|
-
import { e as u } from "./class-map-
|
|
1
|
+
import { E as n, x as r, n as s, a as d } from "./element-DjjF_tEh.js";
|
|
2
|
+
import { P as k } from "./input-element-Bic-t96S.js";
|
|
3
|
+
import { e as b, n as f } from "./ref-iIffqQAI.js";
|
|
4
|
+
import { e as u } from "./class-map-KyMqi0fa.js";
|
|
5
5
|
var _ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, i = (e, h, c, l) => {
|
|
6
6
|
for (var p = l > 1 ? void 0 : l ? y(h, c) : h, a = e.length - 1, o; a >= 0; a--)
|
|
7
7
|
(o = e[a]) && (p = (l ? o(h, c, p) : o(p)) || p);
|
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,47 +1 @@
|
|
|
1
1
|
export { }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare global {
|
|
5
|
-
interface HTMLElementTagNameMap {
|
|
6
|
-
'pkt-icon': PktIcon;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare global {
|
|
12
|
-
interface HTMLElementTagNameMap {
|
|
13
|
-
'pkt-combobox': PktCombobox & HTMLSelectElement;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
declare global {
|
|
19
|
-
interface HTMLElementTagNameMap {
|
|
20
|
-
'pkt-listbox': PktListbox;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
27
|
-
*
|
|
28
|
-
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
29
|
-
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
30
|
-
*
|
|
31
|
-
* @slot (default) - Options to be rendered as children
|
|
32
|
-
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
declare global {
|
|
37
|
-
interface HTMLElementTagNameMap {
|
|
38
|
-
'pkt-select': PktSelect & HTMLSelectElement;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
declare global {
|
|
44
|
-
interface Window {
|
|
45
|
-
pktTz: string;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const a=require("./element-
|
|
1
|
+
"use strict";const a=require("./element-BSypUpzA.cjs"),r=require("./directive-C7oCP5Bh.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2018 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { E as y, x as d, n as r, a as O } from "./element-
|
|
2
|
-
import { o as f } from "./if-defined-
|
|
3
|
-
import { r as c } from "./state-
|
|
4
|
-
import { e as _, n as v } from "./ref-
|
|
5
|
-
import { e as k } from "./class-map-
|
|
6
|
-
import { c as R } from "./repeat-
|
|
7
|
-
import { P as V } from "./input-element-
|
|
1
|
+
import { E as y, x as d, n as r, a as O } from "./element-DjjF_tEh.js";
|
|
2
|
+
import { o as f } from "./if-defined-BErSJCeJ.js";
|
|
3
|
+
import { r as c } from "./state-BtbpSrdV.js";
|
|
4
|
+
import { e as _, n as v } from "./ref-iIffqQAI.js";
|
|
5
|
+
import { e as k } from "./class-map-KyMqi0fa.js";
|
|
6
|
+
import { c as R } from "./repeat-D4kMediE.js";
|
|
7
|
+
import { P as V } from "./input-element-Bic-t96S.js";
|
|
8
8
|
import { P as C } from "./pkt-options-controller-CFmzX4xL.js";
|
|
9
9
|
import { P as S } from "./pkt-slot-controller-DFrc5O93.js";
|
|
10
|
-
import "./input-wrapper-
|
|
11
|
-
import "./icon-
|
|
12
|
-
import "./tag-
|
|
13
|
-
import "./listbox-
|
|
10
|
+
import "./input-wrapper-CeeNYbDA.js";
|
|
11
|
+
import "./icon-Beoxup8E.js";
|
|
12
|
+
import "./tag-CGnj4c1Z.js";
|
|
13
|
+
import "./listbox-C1oYnM-t.js";
|
|
14
14
|
const T = {
|
|
15
15
|
displayValueAs: {
|
|
16
16
|
default: "label"
|
|
@@ -18,10 +18,10 @@ const T = {
|
|
|
18
18
|
}, A = {
|
|
19
19
|
props: T
|
|
20
20
|
};
|
|
21
|
-
var M = Object.defineProperty, F = Object.getOwnPropertyDescriptor, h = (
|
|
22
|
-
for (var
|
|
23
|
-
(l =
|
|
24
|
-
return i &&
|
|
21
|
+
var M = Object.defineProperty, F = Object.getOwnPropertyDescriptor, h = (e, t, s, i) => {
|
|
22
|
+
for (var n = i > 1 ? void 0 : i ? F(t, s) : t, o = e.length - 1, l; o >= 0; o--)
|
|
23
|
+
(l = e[o]) && (n = (i ? l(t, s, n) : l(n)) || n);
|
|
24
|
+
return i && n && M(t, s, n), n;
|
|
25
25
|
};
|
|
26
26
|
let a = class extends V {
|
|
27
27
|
constructor() {
|
|
@@ -29,34 +29,38 @@ let a = class extends V {
|
|
|
29
29
|
}
|
|
30
30
|
// Lifecycle methods
|
|
31
31
|
connectedCallback() {
|
|
32
|
-
if (super.connectedCallback(), document && document.body.addEventListener("click", (
|
|
33
|
-
this._isOptionsOpen && !this.contains(
|
|
32
|
+
if (super.connectedCallback(), document && document.body.addEventListener("click", (e) => {
|
|
33
|
+
this._isOptionsOpen && !this.contains(e.target) && this.handleFocusOut(e);
|
|
34
34
|
}), this._options = [], this.optionsController.nodes.length) {
|
|
35
|
-
const
|
|
36
|
-
this.optionsController.nodes.forEach((
|
|
37
|
-
if (!
|
|
35
|
+
const e = [];
|
|
36
|
+
this.optionsController.nodes.forEach((t) => {
|
|
37
|
+
if (!t.textContent && !t.getAttribute("value")) return null;
|
|
38
38
|
const s = {
|
|
39
|
-
value:
|
|
40
|
-
label:
|
|
39
|
+
value: t.getAttribute("value") || t.textContent || "",
|
|
40
|
+
label: t.textContent || t.getAttribute("value") || ""
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
}),
|
|
42
|
+
t.getAttribute("data-prefix") && (s.prefix = t.getAttribute("data-prefix") || void 0), t.getAttribute("tagskincolor") && (s.tagSkinColor = t.getAttribute("tagskincolor")), t.getAttribute("description") && (s.description = t.getAttribute("description") || void 0), s.fulltext = s.value + s.label + (s.prefix || ""), e.push(s);
|
|
43
|
+
}), e.length && (this.options = [...e], this._options = [...e]);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
updated(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
updated(e) {
|
|
47
|
+
e.has("_value") && this.valueChanged(this._value, e.get("_value")), e.has("value") && (this._value = Array.isArray(this.value) ? this.value : this.value ? this.value.split(",") : [], !this.multiple && this._value.length > 1 && (this._value = [this._value[0]]), this.isMaxItemsReached()), e.has("options") && this.options.length && (this._options = this.options, this._options.forEach((t) => {
|
|
48
|
+
if (t.value && !t.label && (t.label = t.value), t.selected && !this._value.includes(t.value)) {
|
|
49
|
+
const s = [...this._value];
|
|
50
|
+
this._value = [...this._value, t.value], this.valueChanged(this._value, s);
|
|
51
|
+
}
|
|
52
|
+
t.fulltext = t.value + t.label + (t.prefix || ""), t.selected = t.selected || this._value.includes(t.value);
|
|
53
|
+
})), e.has("_search") && this.dispatchEvent(
|
|
50
54
|
new CustomEvent("search", {
|
|
51
55
|
detail: this._search,
|
|
52
56
|
bubbles: !1
|
|
53
57
|
})
|
|
54
|
-
), super.updated(
|
|
58
|
+
), super.updated(e);
|
|
55
59
|
}
|
|
56
|
-
attributeChangedCallback(
|
|
57
|
-
|
|
58
|
-
i.fulltext = i.value + i.label + (i.prefix || "");
|
|
59
|
-
}), this._search = ""), super.attributeChangedCallback(
|
|
60
|
+
attributeChangedCallback(e, t, s) {
|
|
61
|
+
e === "value" && (this._value = Array.isArray(this.value) ? this.value : this.value ? this.value.split(",") : [], !this.multiple && this._value.length > 1 && (this._value = [this._value[0]])), e === "options" && (this._options = this.options, this._options.forEach((i) => {
|
|
62
|
+
i.value && !i.label && (i.label = i.value), i.selected && !this._value.includes(i.value) && (this._value = [...this._value, i.value]), i.fulltext = i.value + i.label + (i.prefix || "");
|
|
63
|
+
}), this._search = ""), super.attributeChangedCallback(e, t, s);
|
|
60
64
|
}
|
|
61
65
|
// Render methods
|
|
62
66
|
render() {
|
|
@@ -183,62 +187,62 @@ let a = class extends V {
|
|
|
183
187
|
`;
|
|
184
188
|
}
|
|
185
189
|
renderSingleOrMultipleValues() {
|
|
186
|
-
const
|
|
190
|
+
const e = !this.multiple, t = this._editingSingleValue ? null : this.renderValueTag(this.findValueInOptions(this._value[0])), s = R(
|
|
187
191
|
this._value,
|
|
188
192
|
(i) => i,
|
|
189
193
|
(i) => {
|
|
190
194
|
var l;
|
|
191
|
-
const
|
|
195
|
+
const n = this.findValueInOptions(i), o = (l = this.options.find((u) => u.value === i)) == null ? void 0 : l.tagSkinColor;
|
|
192
196
|
return d`
|
|
193
197
|
<pkt-tag
|
|
194
|
-
skin=${
|
|
198
|
+
skin=${o || "blue-dark"}
|
|
195
199
|
?closeTag=${!this.disabled}
|
|
196
200
|
@close=${() => this.handleTagRemove(i)}
|
|
197
201
|
>
|
|
198
|
-
${this.renderValueTag(
|
|
202
|
+
${this.renderValueTag(n)}
|
|
199
203
|
</pkt-tag>
|
|
200
204
|
`;
|
|
201
205
|
}
|
|
202
206
|
);
|
|
203
|
-
return
|
|
207
|
+
return e ? t : s;
|
|
204
208
|
}
|
|
205
|
-
renderValueTag(
|
|
206
|
-
if (!
|
|
209
|
+
renderValueTag(e) {
|
|
210
|
+
if (!e) return "";
|
|
207
211
|
switch (this.displayValueAs) {
|
|
208
212
|
case "prefixAndValue":
|
|
209
|
-
return d`<span data-focusfix=${this.id}>${
|
|
213
|
+
return d`<span data-focusfix=${this.id}>${e.prefix || ""} ${e.value}</span>`;
|
|
210
214
|
case "value":
|
|
211
|
-
return d`<span data-focusfix=${this.id}>${
|
|
215
|
+
return d`<span data-focusfix=${this.id}>${e.value}</span>`;
|
|
212
216
|
case "label":
|
|
213
217
|
default:
|
|
214
|
-
return d`<span data-focusfix=${this.id}>${
|
|
218
|
+
return d`<span data-focusfix=${this.id}>${e.label || e.value}</span>`;
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
// Event handlers
|
|
218
|
-
handleInput(
|
|
219
|
-
if (
|
|
222
|
+
handleInput(e) {
|
|
223
|
+
if (e.stopPropagation(), e.stopImmediatePropagation(), this.disabled) return;
|
|
220
224
|
this.touched = !0;
|
|
221
|
-
const
|
|
222
|
-
if (this._search =
|
|
225
|
+
const t = e.target;
|
|
226
|
+
if (this._search = t.value, this.checkForMatches(), this.typeahead)
|
|
223
227
|
if (this._search) {
|
|
224
228
|
if (this._options = this.options.filter(
|
|
225
229
|
(s) => {
|
|
226
230
|
var i;
|
|
227
231
|
return (i = s.fulltext) == null ? void 0 : i.toLowerCase().includes(this._search.toLowerCase());
|
|
228
232
|
}
|
|
229
|
-
),
|
|
233
|
+
), e.inputType !== "deleteContentBackward") {
|
|
230
234
|
const s = this._options.filter(
|
|
231
235
|
(i) => {
|
|
232
|
-
var
|
|
233
|
-
return !i.selected && ((
|
|
236
|
+
var n;
|
|
237
|
+
return !i.selected && ((n = i.label) == null ? void 0 : n.toLowerCase().startsWith(this._search.toLowerCase()));
|
|
234
238
|
}
|
|
235
239
|
);
|
|
236
240
|
if (s.length > 0 && this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
237
241
|
const i = s[0];
|
|
238
|
-
i != null && i.label && (
|
|
239
|
-
() =>
|
|
242
|
+
i != null && i.label && (t.value = i.label, window.setTimeout(
|
|
243
|
+
() => t.setSelectionRange(this._search.length, t.value.length),
|
|
240
244
|
0
|
|
241
|
-
),
|
|
245
|
+
), t.selectionDirection = "backward");
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
} else
|
|
@@ -247,15 +251,15 @@ let a = class extends V {
|
|
|
247
251
|
handleFocus() {
|
|
248
252
|
if (!this.disabled) {
|
|
249
253
|
if (!this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
250
|
-
const
|
|
251
|
-
this._editingSingleValue = !0, this.inputRef.value.value = this.displayValueAs === "label" && (
|
|
254
|
+
const e = this.findValueInOptions(this._value[0]);
|
|
255
|
+
this._editingSingleValue = !0, this.inputRef.value.value = this.displayValueAs === "label" && (e != null && e.label) ? e.label : this._value[0];
|
|
252
256
|
}
|
|
253
257
|
this._inputFocus = !0, this._search = "", this._options = [...this.options], this._isOptionsOpen = !0, this.onFocus(), this.requestUpdate();
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
|
-
handleFocusOut(
|
|
257
|
-
var
|
|
258
|
-
if (!this.disabled && ((s = (
|
|
260
|
+
handleFocusOut(e) {
|
|
261
|
+
var t, s, i, n, o;
|
|
262
|
+
if (!this.disabled && ((s = (t = e.relatedTarget) == null ? void 0 : t.closest("pkt-combobox")) == null ? void 0 : s.id) !== this.id && ((n = (i = e.relatedTarget) == null ? void 0 : i.closest("pkt-combobox")) == null ? void 0 : n.id) !== this.id && ((o = e.target) == null ? void 0 : o.getAttribute("data-focusfix")) !== this.id && e.relatedTarget !== this.focusRef.value && e.relatedTarget !== this.inputRef.value && e.relatedTarget !== this.arrowRef.value && this._isOptionsOpen) {
|
|
259
263
|
if (this._inputFocus = !1, this._addValueText = null, this._userInfoMessage = "", this._search = "", this.inputRef.value && this.inputRef.value.type !== "hidden" && this.inputRef.value.value !== "") {
|
|
260
264
|
const l = this.inputRef.value.value;
|
|
261
265
|
!this._value.includes(l) && !this._options.find((u) => u.label === l) ? this.allowUserInput ? this.addNewUserValue(l) : this.multiple || this.removeValue(this._value[0]) : this._value.includes(l) || this.setSelected(l), this.inputRef.value.value = "";
|
|
@@ -266,66 +270,66 @@ let a = class extends V {
|
|
|
266
270
|
handleBlur() {
|
|
267
271
|
this._inputFocus = !1, this._editingSingleValue = !1, this.onBlur();
|
|
268
272
|
}
|
|
269
|
-
handleInputClick(
|
|
270
|
-
var
|
|
271
|
-
this.disabled || (
|
|
273
|
+
handleInputClick(e) {
|
|
274
|
+
var t, s;
|
|
275
|
+
this.disabled || (e.currentTarget && e.currentTarget !== this.arrowRef.value && ((t = this.inputRef.value) == null ? void 0 : t.type) !== "hidden" ? (s = this.inputRef.value) == null || s.focus() : this.handleArrowClick(e));
|
|
272
276
|
}
|
|
273
|
-
handleArrowClick(
|
|
274
|
-
var
|
|
275
|
-
this.disabled ||
|
|
277
|
+
handleArrowClick(e) {
|
|
278
|
+
var t, s;
|
|
279
|
+
this.disabled || e instanceof KeyboardEvent && e.key && e.key !== "Enter" && e.key !== " " && e.key !== "ArrowDown" || (e.stopImmediatePropagation(), e.preventDefault(), this._isOptionsOpen = !this._isOptionsOpen, this._isOptionsOpen ? (t = this.listboxRef.value) == null || t.focusFirstOrSelectedOption() : (s = this.arrowRef.value) == null || s.focus());
|
|
276
280
|
}
|
|
277
|
-
handleOptionToggled(
|
|
278
|
-
this.toggleValue(
|
|
281
|
+
handleOptionToggled(e) {
|
|
282
|
+
this.toggleValue(e.detail);
|
|
279
283
|
}
|
|
280
|
-
handleSearch(
|
|
281
|
-
|
|
284
|
+
handleSearch(e) {
|
|
285
|
+
e.stopPropagation(), this._search = e.detail.toLowerCase();
|
|
282
286
|
}
|
|
283
|
-
handleInputKeydown(
|
|
284
|
-
var
|
|
285
|
-
switch (
|
|
287
|
+
handleInputKeydown(e) {
|
|
288
|
+
var t, s, i;
|
|
289
|
+
switch (e.key) {
|
|
286
290
|
case ",":
|
|
287
291
|
case "Enter":
|
|
288
|
-
|
|
292
|
+
e.preventDefault(), this.addValue();
|
|
289
293
|
break;
|
|
290
294
|
case "Backspace":
|
|
291
|
-
!this._search && ((
|
|
295
|
+
!this._search && ((t = this.inputRef.value) == null ? void 0 : t.type) === "hidden" && this.removeLastValue(e);
|
|
292
296
|
break;
|
|
293
297
|
case "Tab":
|
|
294
298
|
case "ArrowDown":
|
|
295
|
-
|
|
299
|
+
e.shiftKey || ((s = this.listboxRef.value) == null || s.focusFirstOrSelectedOption(), e.preventDefault());
|
|
296
300
|
break;
|
|
297
301
|
case "Escape":
|
|
298
|
-
this._isOptionsOpen = !1, (i = this.arrowRef.value) == null || i.focus(),
|
|
302
|
+
this._isOptionsOpen = !1, (i = this.arrowRef.value) == null || i.focus(), e.preventDefault();
|
|
299
303
|
break;
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
|
-
handleTagRemove(
|
|
303
|
-
this.removeSelected(
|
|
306
|
+
handleTagRemove(e) {
|
|
307
|
+
this.removeSelected(e);
|
|
304
308
|
}
|
|
305
309
|
blurInput() {
|
|
306
310
|
this.inputRef.value && this.inputRef.value.matches(":focus") && this.inputRef.value.blur();
|
|
307
311
|
}
|
|
308
312
|
checkForMatches() {
|
|
309
|
-
var
|
|
310
|
-
const
|
|
311
|
-
if (!
|
|
313
|
+
var o;
|
|
314
|
+
const e = ((o = this.inputRef.value) == null ? void 0 : o.value) || this._search || "", t = e.trim().toLowerCase() || "";
|
|
315
|
+
if (!t) {
|
|
312
316
|
!this.multiple && this._value[0] && this.removeValue(this._value[0]), this.resetComboboxInput(!1);
|
|
313
317
|
return;
|
|
314
318
|
}
|
|
315
|
-
const s = this._value.find((l) => l.toLowerCase() ===
|
|
319
|
+
const s = this._value.find((l) => l.toLowerCase() === t), i = this._options.filter(
|
|
316
320
|
(l) => {
|
|
317
321
|
var u;
|
|
318
|
-
return ((u = l.label) == null ? void 0 : u.toLowerCase().includes(
|
|
322
|
+
return ((u = l.label) == null ? void 0 : u.toLowerCase().includes(t)) ?? !1;
|
|
319
323
|
}
|
|
320
|
-
),
|
|
324
|
+
), n = i.find(
|
|
321
325
|
(l) => {
|
|
322
326
|
var u;
|
|
323
|
-
return ((u = l.label) == null ? void 0 : u.toLowerCase()) ===
|
|
327
|
+
return ((u = l.label) == null ? void 0 : u.toLowerCase()) === t || l.value.toLowerCase() === t;
|
|
324
328
|
}
|
|
325
329
|
);
|
|
326
330
|
switch (!0) {
|
|
327
|
-
case ((i.length === 0 || !
|
|
328
|
-
this._addValueText =
|
|
331
|
+
case ((i.length === 0 || !n) && this.allowUserInput):
|
|
332
|
+
this._addValueText = e, this._userInfoMessage = "";
|
|
329
333
|
break;
|
|
330
334
|
case (i.length === 0 && !this.allowUserInput):
|
|
331
335
|
this._addValueText = null, this._userInfoMessage = "Ingen match i søket";
|
|
@@ -340,41 +344,41 @@ let a = class extends V {
|
|
|
340
344
|
this._addValueText = null, this._userInfoMessage = "";
|
|
341
345
|
}
|
|
342
346
|
}
|
|
343
|
-
findValueInOptions(
|
|
344
|
-
return this.options.find((
|
|
347
|
+
findValueInOptions(e) {
|
|
348
|
+
return this.options.find((t) => t.value === e || t.label === e) || null;
|
|
345
349
|
}
|
|
346
|
-
findIndexInOptions(
|
|
347
|
-
return this._options.findIndex((
|
|
350
|
+
findIndexInOptions(e) {
|
|
351
|
+
return this._options.findIndex((t) => t.value === e || t.label === e);
|
|
348
352
|
}
|
|
349
353
|
isMaxItemsReached() {
|
|
350
|
-
const
|
|
351
|
-
return
|
|
354
|
+
const e = this.maxlength !== null && this._value.length >= this.maxlength;
|
|
355
|
+
return e ? this._maxIsReached = !0 : this._maxIsReached = !1, e;
|
|
352
356
|
}
|
|
353
|
-
toggleValue(
|
|
357
|
+
toggleValue(e) {
|
|
354
358
|
var I, w;
|
|
355
359
|
if (this.disabled) return;
|
|
356
360
|
this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
|
|
357
|
-
const
|
|
361
|
+
const t = ((I = this.findValueInOptions(e)) == null ? void 0 : I.value) || null, s = this._value.includes(e || t || ""), i = !!t, n = ((w = this._options.find((m) => m.value === e)) == null ? void 0 : w.disabled) || !1, o = !(e != null && e.trim()), l = !this.multiple, u = this.multiple, $ = this.isMaxItemsReached();
|
|
358
362
|
let p = !1, b = !0, g = "", x = "";
|
|
359
|
-
|
|
363
|
+
n || (!i && this.allowUserInput && !o ? (this.addNewUserValue(e), g = "Ny verdi lagt til", p = !u) : !i && !this.allowUserInput ? (l && this._value[0] && this.removeValue(this._value[0]), b = !1, p = !0, g = "Ingen treff i søket") : s ? (this.removeValue(t), p = !0) : o && l ? (this.removeAllSelected(), p = !0) : l ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t), p = !1, this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "", this.inputRef.value.blur())) : u && !$ ? (this.setSelected(t), p = !0) : u && $ ? (this._userInfoMessage = "Maks antall valg nådd", b = !1, x = e) : (l && this.removeAllSelected(), this._userInfoMessage = "Ingen gyldig verdi valgt", b = !1, p = !0, x = e), this._isOptionsOpen = p, p || window.setTimeout(() => {
|
|
360
364
|
var m;
|
|
361
365
|
(m = this.focusRef.value) == null || m.focus();
|
|
362
366
|
}, 0), this._userInfoMessage = g, this._search = x || "", this.resetComboboxInput(b), u && this.isMaxItemsReached());
|
|
363
367
|
}
|
|
364
|
-
setSelected(
|
|
365
|
-
if (!this._value.includes(
|
|
368
|
+
setSelected(e) {
|
|
369
|
+
if (!this._value.includes(e)) {
|
|
366
370
|
if (this.multiple && this.isMaxItemsReached()) {
|
|
367
371
|
this._userInfoMessage = "Maks antall valg nådd";
|
|
368
372
|
return;
|
|
369
373
|
}
|
|
370
|
-
!this.multiple && this.removeAllSelected(), this._value =
|
|
374
|
+
!this.multiple && this.removeAllSelected(), this._value = e ? [...this._value, e] : this._value, this._options = this._options.map((t) => (t.value === e && (t.selected = !0), t)), this.resetComboboxInput(!0);
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
|
-
removeSelected(
|
|
374
|
-
if (!
|
|
375
|
-
this._value = this._value.filter((s) => s !==
|
|
376
|
-
const
|
|
377
|
-
|
|
377
|
+
removeSelected(e) {
|
|
378
|
+
if (!e) return;
|
|
379
|
+
this._value = this._value.filter((s) => s !== e);
|
|
380
|
+
const t = this.findValueInOptions(e);
|
|
381
|
+
t ? (t.selected = !1, t.userAdded ? (this._options = [...this._options.filter((s) => s.value !== e)], this.options = [...this.options.filter((s) => s.value !== e)]) : this._options = [...this._options, t]) : !e && !this.multiple && (this._options = this._options.map((s) => (s.selected = !1, s)));
|
|
378
382
|
}
|
|
379
383
|
addAllOptions() {
|
|
380
384
|
if (this.multiple) {
|
|
@@ -382,48 +386,48 @@ let a = class extends V {
|
|
|
382
386
|
this._userInfoMessage = "For mange valgt";
|
|
383
387
|
return;
|
|
384
388
|
}
|
|
385
|
-
this._value = this._options.map((
|
|
389
|
+
this._value = this._options.map((e) => e.value), this._options = this._options.map((e) => (e.selected = !0, e)), this.requestUpdate();
|
|
386
390
|
}
|
|
387
391
|
}
|
|
388
392
|
removeAllSelected() {
|
|
389
|
-
this._value = [], this._options = this._options.map((
|
|
393
|
+
this._value = [], this._options = this._options.map((e) => (e.selected = !1, e)), this._options = this._options.filter((e) => !e.userAdded), this.requestUpdate();
|
|
390
394
|
}
|
|
391
395
|
addValue() {
|
|
392
|
-
var
|
|
393
|
-
const
|
|
394
|
-
this._search =
|
|
396
|
+
var t;
|
|
397
|
+
const e = ((t = this.inputRef.value) == null ? void 0 : t.value.trim()) || "";
|
|
398
|
+
this._search = e, this.toggleValue(e);
|
|
395
399
|
}
|
|
396
|
-
removeValue(
|
|
397
|
-
this._value = this.multiple ? this._value.filter((
|
|
400
|
+
removeValue(e) {
|
|
401
|
+
this._value = this.multiple ? this._value.filter((t) => t !== e) : [], this.removeSelected(e);
|
|
398
402
|
}
|
|
399
|
-
addNewUserValue(
|
|
400
|
-
if (!
|
|
403
|
+
addNewUserValue(e) {
|
|
404
|
+
if (!e || e.trim() === "") return;
|
|
401
405
|
if (!this.multiple)
|
|
402
|
-
this._value[0] && this.removeSelected(this._value[0]), this._value = [
|
|
403
|
-
else if (!this.findValueInOptions(
|
|
406
|
+
this._value[0] && this.removeSelected(this._value[0]), this._value = [e], this._isOptionsOpen = !1, this.blurInput();
|
|
407
|
+
else if (!this.findValueInOptions(e)) {
|
|
404
408
|
if (this.isMaxItemsReached()) return;
|
|
405
|
-
this._value = [...this._value,
|
|
409
|
+
this._value = [...this._value, e];
|
|
406
410
|
}
|
|
407
|
-
const
|
|
408
|
-
this.options = [
|
|
411
|
+
const t = { value: e, label: e, userAdded: !0 };
|
|
412
|
+
this.options = [t, ...this.options], this._options = [t, ...this._options], this.setSelected(e), this.requestUpdate();
|
|
409
413
|
}
|
|
410
|
-
resetComboboxInput(
|
|
411
|
-
if (this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" &&
|
|
414
|
+
resetComboboxInput(e = !0) {
|
|
415
|
+
if (this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && e)
|
|
412
416
|
if (this._search = "", this.multiple)
|
|
413
417
|
this.inputRef.value.value = "";
|
|
414
418
|
else {
|
|
415
|
-
const
|
|
419
|
+
const t = this.findValueInOptions(this._value[0]);
|
|
416
420
|
window.setTimeout(() => {
|
|
417
|
-
!this.inputRef.value || this.inputRef.value.type === "hidden" || (this.inputRef.value.value = this.displayValueAs === "label" && (
|
|
421
|
+
!this.inputRef.value || this.inputRef.value.type === "hidden" || (this.inputRef.value.value = this.displayValueAs === "label" && (t != null && t.label) ? t.label : this._value[0] || "");
|
|
418
422
|
}, 0), this._userInfoMessage = "";
|
|
419
423
|
}
|
|
420
424
|
this._options = [...this.options];
|
|
421
425
|
}
|
|
422
|
-
removeLastValue(
|
|
426
|
+
removeLastValue(e) {
|
|
423
427
|
if (this._value.length === 0) return;
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
|
|
428
|
+
e.preventDefault();
|
|
429
|
+
const t = this._value[this._value.length - 1];
|
|
430
|
+
t && this.removeSelected(t), this.isMaxItemsReached();
|
|
427
431
|
}
|
|
428
432
|
};
|
|
429
433
|
h([
|