@oslokommune/punkt-elements 12.31.2 → 12.32.0
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/{alert-BDxxRqgi.cjs → alert-D5G5UJuo.cjs} +1 -1
- package/dist/{alert-D0S57u0r.js → alert-gERpVuB7.js} +6 -6
- package/dist/alert.d.ts +32 -0
- package/dist/{backlink-CzpB-ih9.js → backlink-DdNgqA56.js} +2 -2
- package/dist/{backlink-Dn4DfWVR.cjs → backlink-Q2HTG9jm.cjs} +1 -1
- package/dist/backlink.d.ts +32 -0
- package/dist/{button-Beo3c7cx.cjs → button-BPyZeW73.cjs} +1 -1
- package/dist/{button-9NwGr-OS.js → button-rArIL0-j.js} +3 -3
- package/dist/button.d.ts +32 -0
- package/dist/{calendar-BbZNxsKY.js → calendar-1ryAEdX3.js} +4 -4
- package/dist/{calendar-CxBo98iI.cjs → calendar-2DqPLXdD.cjs} +1 -1
- package/dist/calendar.d.ts +32 -0
- package/dist/{card-DQfNKnKl.js → card-BbMBpvJt.js} +7 -7
- package/dist/{card-C63x_nll.cjs → card-ZX09f_ka.cjs} +1 -1
- package/dist/card.d.ts +32 -0
- package/dist/{checkbox-9Zjy_NU7.cjs → checkbox-BnDG6wIO.cjs} +1 -1
- package/dist/{checkbox-CzDpR6_8.js → checkbox-Ceui2TLp.js} +4 -4
- package/dist/checkbox.d.ts +32 -0
- package/dist/{class-map-DWtqmIRS.js → class-map-ChuDQU5C.js} +1 -1
- package/dist/{class-map-Dj5mbCUg.cjs → class-map-D4rXyUxT.cjs} +1 -1
- package/dist/combobox-DH-YlbNh.cjs +115 -0
- package/dist/combobox-DbO6I0GT.js +694 -0
- package/dist/combobox.d.ts +47 -0
- package/dist/{datepicker-CYUvRGhE.js → datepicker-8MOgQsyL.js} +144 -196
- package/dist/datepicker-BRH-59Q9.cjs +153 -0
- package/dist/datepicker.d.ts +32 -0
- package/dist/directive-helpers-D7XIyCQ_.js +45 -0
- package/dist/directive-helpers-mGjAtADc.cjs +5 -0
- package/dist/{element-CzFXQBoS.cjs → element-BBo3JZk5.cjs} +1 -1
- package/dist/{element-C7XjZtLU.js → element-G8JoS0Lj.js} +6 -0
- package/dist/{helptext-B9kxDc2b.cjs → helptext-B4Uc-d56.cjs} +2 -2
- package/dist/{helptext-CqnoPodd.js → helptext-Y4cSgTkd.js} +10 -10
- package/dist/helptext.d.ts +32 -0
- package/dist/{icon-BEUgV9Wo.js → icon-BJnwW0eh.js} +1 -1
- package/dist/{icon-BOKusjAA.cjs → icon-BTUCDPN5.cjs} +1 -1
- package/dist/icon.d.ts +32 -0
- package/dist/{if-defined-CpIkv1A4.cjs → if-defined-C1ZDVzYn.cjs} +1 -1
- package/dist/{if-defined-eRX4e5zO.js → if-defined-rCqT8Od1.js} +1 -1
- package/dist/index.d.ts +208 -14
- package/dist/input-element-AhnBdCb8.cjs +1 -0
- package/dist/{input-element-BK8UkQli.js → input-element-DM2uSYaW.js} +22 -19
- package/dist/input-wrapper-BdZxmQyO.cjs +52 -0
- package/dist/input-wrapper-DQmYzhcy.js +185 -0
- package/dist/input-wrapper.d.ts +32 -0
- package/dist/{link-D3U0Jkz8.js → link-C3lW3z8X.js} +5 -5
- package/dist/{link-1iq0Pmuf.cjs → link-DOVlsg2S.cjs} +1 -1
- package/dist/link.d.ts +32 -0
- package/dist/{linkcard-CRpo3tiw.js → linkcard-CvqqyHVW.js} +4 -4
- package/dist/{linkcard-2WzDJPZz.cjs → linkcard-DDD92XfD.cjs} +1 -1
- package/dist/linkcard.d.ts +32 -0
- package/dist/listbox-BTVnrHWv.cjs +95 -0
- package/dist/listbox-DX-Euxdm.js +360 -0
- package/dist/listbox.d.ts +47 -0
- package/dist/{loader-B1edLWTg.js → loader-BudoV0yd.js} +6 -6
- package/dist/{loader-DI74pe25.cjs → loader-Csq0Yd1k.cjs} +1 -1
- package/dist/loader.d.ts +32 -0
- package/dist/{messagebox-DQpEMkS2.cjs → messagebox-8GwnNqb0.cjs} +1 -1
- package/dist/{messagebox-KP-8-tA9.js → messagebox-D6uexEhg.js} +6 -6
- package/dist/messagebox.d.ts +32 -0
- package/dist/{modal-ytIJwfr3.cjs → modal-CLixB4Dz.cjs} +1 -1
- package/dist/{modal-kPX8nO_L.js → modal-DnYn2Rlg.js} +6 -6
- package/dist/modal.d.ts +32 -0
- 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 -0
- package/dist/pkt-combobox.js +6 -0
- 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 +3 -3
- package/dist/pkt-index.js +45 -43
- 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 -0
- package/dist/pkt-listbox.js +6 -0
- 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-BtU1zEtG.cjs +1 -0
- package/dist/pkt-options-controller-CZplGTgu.js +38 -0
- 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-slot-controller-CqNvEpFd.cjs +1 -0
- package/dist/{pkt-slot-controller-Clbye6cM.js → pkt-slot-controller-D1DakVrU.js} +17 -7
- 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-B6A9UVXS.cjs → progressbar-BW_icNId.cjs} +1 -1
- package/dist/{progressbar-D0nxLqHu.js → progressbar-czvExwTL.js} +5 -5
- package/dist/progressbar.d.ts +32 -0
- package/dist/{radiobutton-BWyQgR_x.cjs → radiobutton-BeSuCrbp.cjs} +1 -1
- package/dist/{radiobutton-DLWjvLBO.js → radiobutton-DKo27Stm.js} +5 -5
- package/dist/radiobutton.d.ts +32 -0
- package/dist/ref-DsoUUoPU.cjs +9 -0
- package/dist/ref-cRTOoM4R.js +102 -0
- package/dist/repeat-CArTw6-s.js +61 -0
- package/dist/repeat-kruY8poV.cjs +5 -0
- package/dist/select-DxHhPEgD.js +118 -0
- package/dist/select-lvFnhEVg.cjs +49 -0
- package/dist/select.d.ts +32 -0
- package/dist/{state-HNj0_316.cjs → state-BILlRnrD.cjs} +1 -1
- package/dist/{state-CDQk0DFQ.js → state-gfUuUqVg.js} +1 -1
- package/dist/{tag-CmFcSdOV.js → tag-CWx1XsGR.js} +7 -7
- package/dist/{tag-BeLSOjNh.cjs → tag-DThwKsrg.cjs} +1 -1
- package/dist/tag.d.ts +32 -0
- package/dist/{textarea-BPqWCymU.js → textarea-BNNDbxxO.js} +18 -17
- package/dist/{textarea-VG-UTMLP.cjs → textarea-CDsLbogK.cjs} +6 -6
- package/dist/textarea.d.ts +32 -0
- package/dist/{textinput-CEP7QA3E.cjs → textinput-C3C088Ki.cjs} +5 -4
- package/dist/{textinput-VD74aGzx.js → textinput-M8I4dfoP.js} +25 -24
- package/dist/textinput.d.ts +32 -0
- package/package.json +3 -3
- package/src/components/combobox/combobox.ts +873 -0
- package/src/components/combobox/countrycodes.json +927 -0
- package/src/components/combobox/index.ts +6 -0
- package/src/components/datepicker/datepicker.ts +2 -0
- package/src/components/helptext/helptext.ts +1 -1
- package/src/components/index.ts +7 -0
- package/src/components/input-wrapper/input-wrapper.ts +42 -34
- package/src/components/listbox/index.ts +4 -0
- package/src/components/listbox/listbox.ts +474 -0
- package/src/components/select/select.ts +7 -0
- package/src/components/textinput/textinput.ts +3 -2
- package/dist/datepicker-FuAL0uNU.cjs +0 -155
- package/dist/input-element-Dtyuf6s8.cjs +0 -1
- package/dist/input-wrapper-Bo2_t6pA.cjs +0 -50
- package/dist/input-wrapper-DaZZq8c0.js +0 -172
- package/dist/pkt-slot-controller-Oc32unDk.cjs +0 -1
- package/dist/ref-2anvRHT4.cjs +0 -13
- package/dist/ref-DbOSDQbk.js +0 -143
- package/dist/select-CzuxXKll.js +0 -150
- package/dist/select-DZL6aa2s.cjs +0 -48
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { x as d, E as $, n as u, a as O } from "./element-G8JoS0Lj.js";
|
|
2
|
+
import { o as f } from "./if-defined-rCqT8Od1.js";
|
|
3
|
+
import { r as c } from "./state-gfUuUqVg.js";
|
|
4
|
+
import { e as v, n as m } from "./ref-cRTOoM4R.js";
|
|
5
|
+
import { e as w } from "./class-map-ChuDQU5C.js";
|
|
6
|
+
import { c as V } from "./repeat-CArTw6-s.js";
|
|
7
|
+
import { P as R } from "./input-element-DM2uSYaW.js";
|
|
8
|
+
import { P as S } from "./pkt-options-controller-CZplGTgu.js";
|
|
9
|
+
import { P as T } from "./pkt-slot-controller-D1DakVrU.js";
|
|
10
|
+
import "./input-wrapper-DQmYzhcy.js";
|
|
11
|
+
import "./icon-BJnwW0eh.js";
|
|
12
|
+
import "./tag-CWx1XsGR.js";
|
|
13
|
+
import "./listbox-DX-Euxdm.js";
|
|
14
|
+
const C = "pkt-combobox", M = !0, A = {
|
|
15
|
+
name: {
|
|
16
|
+
type: "string",
|
|
17
|
+
name: "Navn",
|
|
18
|
+
description: "Navn som brukes i skjema ved innsending"
|
|
19
|
+
},
|
|
20
|
+
id: {
|
|
21
|
+
type: "string",
|
|
22
|
+
name: "ID",
|
|
23
|
+
description: "Unik ID for feltet"
|
|
24
|
+
},
|
|
25
|
+
label: {
|
|
26
|
+
type: "string",
|
|
27
|
+
name: "Etikett",
|
|
28
|
+
description: "Tekst som vises over feltet"
|
|
29
|
+
},
|
|
30
|
+
placeholder: {
|
|
31
|
+
name: "Hint",
|
|
32
|
+
description: "Spesifiserer en kort hint som beskriver forventet verdi av feltet.",
|
|
33
|
+
type: "string",
|
|
34
|
+
required: !1
|
|
35
|
+
},
|
|
36
|
+
multiple: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
name: "Flervalg",
|
|
39
|
+
default: !0,
|
|
40
|
+
description: "Mulighet for å velge flere valg"
|
|
41
|
+
},
|
|
42
|
+
typeahead: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
name: "Typeahead",
|
|
45
|
+
default: !0,
|
|
46
|
+
description: "Mulighet for automatisk utfylling av feltet fra listen over valg"
|
|
47
|
+
},
|
|
48
|
+
includeSearch: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
name: "Inkluder søk",
|
|
51
|
+
description: "Mulighet for å søke etter valg inni dropdown"
|
|
52
|
+
},
|
|
53
|
+
allowUserInput: {
|
|
54
|
+
type: "boolean",
|
|
55
|
+
name: "Brukervalgte verdier",
|
|
56
|
+
description: "Mulighet for å skrive inn egne verdier"
|
|
57
|
+
},
|
|
58
|
+
displayValueAs: {
|
|
59
|
+
type: [
|
|
60
|
+
"label",
|
|
61
|
+
"value",
|
|
62
|
+
"prefixAndValue"
|
|
63
|
+
],
|
|
64
|
+
name: "Visning av valgt verdi",
|
|
65
|
+
description: "Hvordan valgt verdi vises i feltet",
|
|
66
|
+
default: "label"
|
|
67
|
+
},
|
|
68
|
+
maxlength: {
|
|
69
|
+
type: "number",
|
|
70
|
+
name: "Maks lengde",
|
|
71
|
+
description: "Maks antall valg dersom flervalg er aktivert"
|
|
72
|
+
},
|
|
73
|
+
tagPlacement: {
|
|
74
|
+
type: [
|
|
75
|
+
"inside",
|
|
76
|
+
"outside"
|
|
77
|
+
],
|
|
78
|
+
name: "Plassering av tags",
|
|
79
|
+
description: "Plassering av valgte verdier i feltet ved flervalg",
|
|
80
|
+
default: "top"
|
|
81
|
+
},
|
|
82
|
+
value: {
|
|
83
|
+
name: "Verdi",
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg."
|
|
86
|
+
},
|
|
87
|
+
helptext: {
|
|
88
|
+
type: "string",
|
|
89
|
+
name: "Hjelpetekst",
|
|
90
|
+
description: "Hjelpetekst som vises over feltet"
|
|
91
|
+
},
|
|
92
|
+
helptextDropdown: {
|
|
93
|
+
type: "string",
|
|
94
|
+
name: "Utvidet hjelpetekst",
|
|
95
|
+
description: "Hjelpetekst som vises over feltet"
|
|
96
|
+
},
|
|
97
|
+
helptextDropdownButton: {
|
|
98
|
+
type: "string",
|
|
99
|
+
name: "Knappetekst for hjelpetekst",
|
|
100
|
+
description: "Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst",
|
|
101
|
+
default: "Les mer"
|
|
102
|
+
},
|
|
103
|
+
disabled: {
|
|
104
|
+
type: "boolean",
|
|
105
|
+
name: "Deaktivert",
|
|
106
|
+
description: "Feltet er deaktivert"
|
|
107
|
+
},
|
|
108
|
+
hasError: {
|
|
109
|
+
type: "boolean",
|
|
110
|
+
name: "Feil",
|
|
111
|
+
description: "Feltet har en feil"
|
|
112
|
+
},
|
|
113
|
+
errorMessage: {
|
|
114
|
+
type: "string",
|
|
115
|
+
name: "Feilmelding",
|
|
116
|
+
description: "Tekst som vises under feltet ved feil"
|
|
117
|
+
},
|
|
118
|
+
required: {
|
|
119
|
+
type: "boolean",
|
|
120
|
+
name: "Påkrevd",
|
|
121
|
+
description: "Feltet må fylles ut"
|
|
122
|
+
},
|
|
123
|
+
requiredTag: {
|
|
124
|
+
type: "boolean",
|
|
125
|
+
name: "Påkrevd-merking",
|
|
126
|
+
description: "Viser en merking som indikerer at feltet er påkrevd"
|
|
127
|
+
},
|
|
128
|
+
requiredText: {
|
|
129
|
+
type: "string",
|
|
130
|
+
name: "Påkrevd-tekst",
|
|
131
|
+
description: "Tekst som vises i påkrevd-merkingen"
|
|
132
|
+
},
|
|
133
|
+
optionalTag: {
|
|
134
|
+
type: "boolean",
|
|
135
|
+
name: "Valgfritt-merking",
|
|
136
|
+
description: "Viser en merking som indikerer at feltet er valgfritt"
|
|
137
|
+
},
|
|
138
|
+
optionalText: {
|
|
139
|
+
type: "string",
|
|
140
|
+
name: "Valgfritt-tekst",
|
|
141
|
+
description: "Tekst som vises i valgfritt-merkingen"
|
|
142
|
+
},
|
|
143
|
+
fullwidth: {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
name: "Full bredde",
|
|
146
|
+
description: "Skal feltet ta opp hele bredden?"
|
|
147
|
+
},
|
|
148
|
+
options: {
|
|
149
|
+
name: "Valg",
|
|
150
|
+
type: "array",
|
|
151
|
+
description: "Liste over valg som kan velges, om options sendes inn som array med objekter",
|
|
152
|
+
default: [],
|
|
153
|
+
previewDefault: [
|
|
154
|
+
{
|
|
155
|
+
value: "bfr",
|
|
156
|
+
label: "Frogner"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
value: "bgo",
|
|
160
|
+
label: "Gamle Oslo"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
value: "bgr",
|
|
164
|
+
label: "Grorud"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
value: "bxx",
|
|
168
|
+
label: "Andre bydeler"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
items: {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {
|
|
174
|
+
value: {
|
|
175
|
+
type: "string",
|
|
176
|
+
description: "Verdi som sendes ved valg"
|
|
177
|
+
},
|
|
178
|
+
label: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Tekst som vises for valget"
|
|
181
|
+
},
|
|
182
|
+
prefix: {
|
|
183
|
+
type: "string",
|
|
184
|
+
description: "Tekst som vises før valget"
|
|
185
|
+
},
|
|
186
|
+
description: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: "Beskrivelse av valget"
|
|
189
|
+
},
|
|
190
|
+
disabled: {
|
|
191
|
+
type: "boolean",
|
|
192
|
+
description: "Valget er deaktivert"
|
|
193
|
+
},
|
|
194
|
+
selected: {
|
|
195
|
+
type: "boolean",
|
|
196
|
+
description: "Valget er valgt"
|
|
197
|
+
},
|
|
198
|
+
tagSkinColor: {
|
|
199
|
+
type: [
|
|
200
|
+
"blue",
|
|
201
|
+
"blue-dark",
|
|
202
|
+
"blue-light",
|
|
203
|
+
"green",
|
|
204
|
+
"red",
|
|
205
|
+
"yellow",
|
|
206
|
+
"beige",
|
|
207
|
+
"gray",
|
|
208
|
+
"grey"
|
|
209
|
+
],
|
|
210
|
+
description: "Farge på tag"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
required: [
|
|
214
|
+
"value"
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}, F = {
|
|
219
|
+
name: C,
|
|
220
|
+
"css-class": "pkt-combobox",
|
|
221
|
+
isElement: M,
|
|
222
|
+
props: A
|
|
223
|
+
};
|
|
224
|
+
var P = Object.defineProperty, D = Object.getOwnPropertyDescriptor, n = (e, t, i, s) => {
|
|
225
|
+
for (var o = s > 1 ? void 0 : s ? D(t, i) : t, r = e.length - 1, l; r >= 0; r--)
|
|
226
|
+
(l = e[r]) && (o = (s ? l(t, i, o) : l(o)) || o);
|
|
227
|
+
return s && o && P(t, i, o), o;
|
|
228
|
+
};
|
|
229
|
+
let a = class extends R {
|
|
230
|
+
constructor() {
|
|
231
|
+
super(), this.helptextSlot = v(), this.value = "", this.options = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder = "", this.multiple = !1, this.maxlength = null, this.displayValueAs = F.props.displayValueAs.default, this.tagPlacement = null, this._options = [], this._isOptionsOpen = !1, this._value = [], this._userInfoMessage = "", this._addValueText = null, this._maxIsReached = !1, this._search = "", this._inputFocus = !1, this._editingSingleValue = !1, this.inputRef = v(), this.arrowRef = v(), this.listboxRef = v(), this.focusRef = v(), this.optionTagRef = v(), this.optionsController = new S(this), this.slotController = new T(this, this.helptextSlot), this.slotController.skipOptions = !0;
|
|
232
|
+
}
|
|
233
|
+
// Lifecycle methods
|
|
234
|
+
connectedCallback() {
|
|
235
|
+
if (super.connectedCallback(), document && document.body.addEventListener("click", (e) => {
|
|
236
|
+
this._isOptionsOpen && !this.contains(e.target) && this.handleFocusOut(e);
|
|
237
|
+
}), this._options = [], this.optionsController.nodes.length) {
|
|
238
|
+
const e = [];
|
|
239
|
+
this.optionsController.nodes.forEach((t) => {
|
|
240
|
+
if (!t.textContent && !t.getAttribute("value")) return null;
|
|
241
|
+
const i = {
|
|
242
|
+
value: t.getAttribute("value") || t.textContent || "",
|
|
243
|
+
label: t.textContent || t.getAttribute("value") || ""
|
|
244
|
+
};
|
|
245
|
+
t.getAttribute("data-prefix") && (i.prefix = t.getAttribute("data-prefix") || void 0), t.getAttribute("tagskincolor") && (i.tagSkinColor = t.getAttribute("tagskincolor")), t.getAttribute("description") && (i.description = t.getAttribute("description") || void 0), i.fulltext = i.value + i.label + (i.prefix || ""), e.push(i);
|
|
246
|
+
}), e.length && (this.options = [...e], this._options = [...e]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
updated(e) {
|
|
250
|
+
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) => {
|
|
251
|
+
t.fulltext = t.value + t.label + (t.prefix || ""), t.selected = this._value.includes(t.value);
|
|
252
|
+
})), e.has("_search") && this.dispatchEvent(
|
|
253
|
+
new CustomEvent("search", {
|
|
254
|
+
detail: this._search,
|
|
255
|
+
bubbles: !1
|
|
256
|
+
})
|
|
257
|
+
), super.updated(e);
|
|
258
|
+
}
|
|
259
|
+
attributeChangedCallback(e, t, i) {
|
|
260
|
+
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((s) => {
|
|
261
|
+
s.fulltext = s.value + s.label + (s.prefix || "");
|
|
262
|
+
}), this._search = ""), super.attributeChangedCallback(e, t, i);
|
|
263
|
+
}
|
|
264
|
+
// Render methods
|
|
265
|
+
render() {
|
|
266
|
+
return d`
|
|
267
|
+
<pkt-input-wrapper
|
|
268
|
+
.label=${this.label}
|
|
269
|
+
.helptext=${this.helptext}
|
|
270
|
+
.helptextDropdown=${f(this.helptextDropdown)}
|
|
271
|
+
.helptextDropdownButton=${f(this.helptextDropdownButton)}
|
|
272
|
+
?fullwidth=${this.fullwidth}
|
|
273
|
+
?hasError=${this.hasError}
|
|
274
|
+
?inline=${this.inline}
|
|
275
|
+
?disabled=${this.disabled}
|
|
276
|
+
.errorMessage=${this.errorMessage}
|
|
277
|
+
?optionalTag=${this.optionalTag}
|
|
278
|
+
.optionalText=${this.optionalText}
|
|
279
|
+
?requiredTag=${this.requiredTag}
|
|
280
|
+
.requiredText=${this.requiredText}
|
|
281
|
+
?useWrapper=${this.useWrapper}
|
|
282
|
+
.forId=${this.allowUserInput || this.typeahead ? this.id + "-input" : this.id + "-arrow"}
|
|
283
|
+
class="pkt-combobox__wrapper"
|
|
284
|
+
@labelClick=${this.handleInputClick}
|
|
285
|
+
>
|
|
286
|
+
<div class="pkt-contents" ${m(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
287
|
+
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
288
|
+
<div
|
|
289
|
+
class=${w({
|
|
290
|
+
"pkt-combobox__input": !0,
|
|
291
|
+
"pkt-combobox__input--fullwidth": this.fullwidth,
|
|
292
|
+
"pkt-combobox__input--open": this._isOptionsOpen,
|
|
293
|
+
"pkt-combobox__input--error": this.hasError,
|
|
294
|
+
"pkt-combobox__input--disabled": this.disabled
|
|
295
|
+
})}
|
|
296
|
+
tabindex="-1"
|
|
297
|
+
@click=${this.handleInputClick}
|
|
298
|
+
>
|
|
299
|
+
${this.placeholder && (!this._value.length || this.multiple && this.tagPlacement == "outside") && !this._inputFocus ? d`<span class="pkt-combobox__placeholder">${this.placeholder}</span>` : this.tagPlacement !== "outside" ? this.renderSingleOrMultipleValues() : $}
|
|
300
|
+
${this.renderInputField()}
|
|
301
|
+
<div
|
|
302
|
+
class="pkt-btn pkt-btn--tertiary pkt-combobox__arrow"
|
|
303
|
+
@click=${this.handleArrowClick}
|
|
304
|
+
@keydown=${this.handleArrowClick}
|
|
305
|
+
id="${this.id}-arrow"
|
|
306
|
+
${m(this.arrowRef)}
|
|
307
|
+
aria-expanded=${this._isOptionsOpen}
|
|
308
|
+
aria-controls="${this.id}-listbox"
|
|
309
|
+
aria-haspopup="listbox"
|
|
310
|
+
aria-label="Åpne liste"
|
|
311
|
+
?disabled=${this.disabled}
|
|
312
|
+
?data-disabled=${this.disabled}
|
|
313
|
+
role="button"
|
|
314
|
+
tabindex="${this.disabled ? "-1" : "0"}"
|
|
315
|
+
>
|
|
316
|
+
<pkt-icon
|
|
317
|
+
class=${w({
|
|
318
|
+
"pkt-combobox__arrow-icon": !0,
|
|
319
|
+
"pkt-combobox__arrow-icon--open": this._isOptionsOpen
|
|
320
|
+
})}
|
|
321
|
+
name="chevron-thin-down"
|
|
322
|
+
></pkt-icon>
|
|
323
|
+
</div>
|
|
324
|
+
<div ${m(this.focusRef)} tabindex="-1" @keydown=${this.handleArrowClick}></div>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<pkt-listbox
|
|
328
|
+
id="${this.id}-listbox"
|
|
329
|
+
.options=${this._options}
|
|
330
|
+
.isOpen=${this._isOptionsOpen}
|
|
331
|
+
.searchPlaceholder=${this.searchPlaceholder}
|
|
332
|
+
.label="Liste: ${this.label || ""}"
|
|
333
|
+
?includeSearch=${this.includeSearch}
|
|
334
|
+
?isMultiSelect=${this.multiple}
|
|
335
|
+
?allowUserInput=${this.allowUserInput && !this._maxIsReached}
|
|
336
|
+
?maxIsReached=${this._maxIsReached}
|
|
337
|
+
.customUserInput=${f(this._addValueText)}
|
|
338
|
+
.userMessage=${this._userInfoMessage}
|
|
339
|
+
@search=${this.handleSearch}
|
|
340
|
+
@option-toggle=${this.handleOptionToggled}
|
|
341
|
+
@select-all=${this.addAllOptions}
|
|
342
|
+
@close-options=${() => this._isOptionsOpen = !1}
|
|
343
|
+
.searchValue=${this._search || null}
|
|
344
|
+
.maxLength=${this.maxlength || 0}
|
|
345
|
+
${m(this.listboxRef)}
|
|
346
|
+
></pkt-listbox>
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
${this.tagPlacement === "outside" && this.multiple ? d`<div class="pkt-combobox__tags-outside">
|
|
350
|
+
${this.renderSingleOrMultipleValues()}
|
|
351
|
+
</div>` : $}
|
|
352
|
+
</pkt-input-wrapper>
|
|
353
|
+
`;
|
|
354
|
+
}
|
|
355
|
+
renderInputField() {
|
|
356
|
+
return this.typeahead || this.allowUserInput ? d`
|
|
357
|
+
<div class="pkt-combobox__input-div combobox__input">
|
|
358
|
+
<input
|
|
359
|
+
type="text"
|
|
360
|
+
id="${this.id}-input"
|
|
361
|
+
name=${(this.name || this.id) + "-input"}
|
|
362
|
+
@input=${this.handleInput}
|
|
363
|
+
@keydown=${this.handleInputKeydown}
|
|
364
|
+
@focus=${this.handleFocus}
|
|
365
|
+
@blur=${this.handleBlur}
|
|
366
|
+
autocomplete="off"
|
|
367
|
+
role="combobox"
|
|
368
|
+
aria-label=${f(this.label)}
|
|
369
|
+
aria-autocomplete=${this.typeahead ? "both" : "list"}
|
|
370
|
+
aria-controls="${this.id}-listbox"
|
|
371
|
+
aria-multiselectable=${f(this.multiple ? "true" : void 0)}
|
|
372
|
+
aria-activedescendant=${f(
|
|
373
|
+
this._value[0] && this.findValueInOptions(this._value[0]) ? `${this.id}-listbox-${this.findIndexInOptions(this._value[0])}` : void 0
|
|
374
|
+
)}
|
|
375
|
+
${m(this.inputRef)}
|
|
376
|
+
/>
|
|
377
|
+
</div>
|
|
378
|
+
` : d`
|
|
379
|
+
<input
|
|
380
|
+
type="hidden"
|
|
381
|
+
id="${this.id}-input"
|
|
382
|
+
name=${(this.name || this.id) + "-input"}
|
|
383
|
+
.value=${this._value.join(",")}
|
|
384
|
+
${m(this.inputRef)}
|
|
385
|
+
/>
|
|
386
|
+
`;
|
|
387
|
+
}
|
|
388
|
+
renderSingleOrMultipleValues() {
|
|
389
|
+
const e = !this.multiple, t = this._editingSingleValue ? null : this.renderValueTag(this.findValueInOptions(this._value[0])), i = V(
|
|
390
|
+
this._value,
|
|
391
|
+
(s) => s,
|
|
392
|
+
(s) => {
|
|
393
|
+
var l;
|
|
394
|
+
const o = this.findValueInOptions(s), r = (l = this.options.find((h) => h.value === s)) == null ? void 0 : l.tagSkinColor;
|
|
395
|
+
return d`
|
|
396
|
+
<pkt-tag
|
|
397
|
+
skin=${r || "blue-dark"}
|
|
398
|
+
?closeTag=${!this.disabled}
|
|
399
|
+
@close=${() => this.handleTagRemove(s)}
|
|
400
|
+
>
|
|
401
|
+
${this.renderValueTag(o)}
|
|
402
|
+
</pkt-tag>
|
|
403
|
+
`;
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
return e ? t : i;
|
|
407
|
+
}
|
|
408
|
+
renderValueTag(e) {
|
|
409
|
+
if (!e) return "";
|
|
410
|
+
switch (this.displayValueAs) {
|
|
411
|
+
case "prefixAndValue":
|
|
412
|
+
return d`<span data-focusfix=${this.id}>${e.prefix || ""} ${e.value}</span>`;
|
|
413
|
+
case "value":
|
|
414
|
+
return d`<span data-focusfix=${this.id}>${e.value}</span>`;
|
|
415
|
+
case "label":
|
|
416
|
+
default:
|
|
417
|
+
return d`<span data-focusfix=${this.id}>${e.label || e.value}</span>`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// Event handlers
|
|
421
|
+
handleInput(e) {
|
|
422
|
+
if (e.stopPropagation(), e.stopImmediatePropagation(), this.disabled) return;
|
|
423
|
+
this.touched = !0;
|
|
424
|
+
const t = e.target;
|
|
425
|
+
if (this._search = t.value, this.checkForMatches(), this.typeahead)
|
|
426
|
+
if (this._search) {
|
|
427
|
+
if (this._options = this.options.filter(
|
|
428
|
+
(i) => {
|
|
429
|
+
var s;
|
|
430
|
+
return (s = i.fulltext) == null ? void 0 : s.toLowerCase().includes(this._search.toLowerCase());
|
|
431
|
+
}
|
|
432
|
+
), e.inputType !== "deleteContentBackward") {
|
|
433
|
+
const i = this._options.filter(
|
|
434
|
+
(s) => {
|
|
435
|
+
var o;
|
|
436
|
+
return !s.selected && ((o = s.label) == null ? void 0 : o.toLowerCase().startsWith(this._search.toLowerCase()));
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
if (i.length > 0 && this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
440
|
+
const s = i[0];
|
|
441
|
+
s != null && s.label && (t.value = s.label, window.setTimeout(
|
|
442
|
+
() => t.setSelectionRange(this._search.length, t.value.length),
|
|
443
|
+
0
|
|
444
|
+
), t.selectionDirection = "backward");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
} else
|
|
448
|
+
this._options = [...this.options];
|
|
449
|
+
}
|
|
450
|
+
handleFocus() {
|
|
451
|
+
if (!this.disabled) {
|
|
452
|
+
if (!this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden") {
|
|
453
|
+
const e = this.findValueInOptions(this._value[0]);
|
|
454
|
+
this._editingSingleValue = !0, this.inputRef.value.value = this.displayValueAs === "label" && (e != null && e.label) ? e.label : this._value[0];
|
|
455
|
+
}
|
|
456
|
+
this._inputFocus = !0, this._search = "", this._options = [...this.options], this._isOptionsOpen = !0, this.onFocus(), this.requestUpdate();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
handleFocusOut(e) {
|
|
460
|
+
var t, i, s, o, r;
|
|
461
|
+
if (!this.disabled && ((i = (t = e.relatedTarget) == null ? void 0 : t.closest("pkt-combobox")) == null ? void 0 : i.id) !== this.id && ((o = (s = e.relatedTarget) == null ? void 0 : s.closest("pkt-combobox")) == null ? void 0 : o.id) !== this.id && ((r = e.target) == null ? void 0 : r.getAttribute("data-focusfix")) !== this.id && e.relatedTarget !== this.focusRef.value && e.relatedTarget !== this.inputRef.value && e.relatedTarget !== this.arrowRef.value && this._isOptionsOpen) {
|
|
462
|
+
if (this._inputFocus = !1, this._addValueText = null, this._userInfoMessage = "", this._search = "", this.inputRef.value && this.inputRef.value.type !== "hidden" && this.inputRef.value.value !== "") {
|
|
463
|
+
const l = this.inputRef.value.value;
|
|
464
|
+
!this._value.includes(l) && !this._options.find((h) => h.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 = "";
|
|
465
|
+
}
|
|
466
|
+
this._isOptionsOpen = !1, this.onBlur();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
handleBlur() {
|
|
470
|
+
this._inputFocus = !1, this._editingSingleValue = !1, this.onBlur();
|
|
471
|
+
}
|
|
472
|
+
handleInputClick(e) {
|
|
473
|
+
var t, i;
|
|
474
|
+
this.disabled || (e.currentTarget && e.currentTarget !== this.arrowRef.value && ((t = this.inputRef.value) == null ? void 0 : t.type) !== "hidden" ? (i = this.inputRef.value) == null || i.focus() : this.handleArrowClick(e));
|
|
475
|
+
}
|
|
476
|
+
handleArrowClick(e) {
|
|
477
|
+
var t, i;
|
|
478
|
+
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() : (i = this.arrowRef.value) == null || i.focus());
|
|
479
|
+
}
|
|
480
|
+
handleOptionToggled(e) {
|
|
481
|
+
this.toggleValue(e.detail);
|
|
482
|
+
}
|
|
483
|
+
handleSearch(e) {
|
|
484
|
+
e.stopPropagation(), this._search = e.detail.toLowerCase();
|
|
485
|
+
}
|
|
486
|
+
handleInputKeydown(e) {
|
|
487
|
+
var t, i, s;
|
|
488
|
+
switch (e.key) {
|
|
489
|
+
case ",":
|
|
490
|
+
case "Enter":
|
|
491
|
+
e.preventDefault(), this.addValue();
|
|
492
|
+
break;
|
|
493
|
+
case "Backspace":
|
|
494
|
+
!this._search && ((t = this.inputRef.value) == null ? void 0 : t.type) === "hidden" && this.removeLastValue(e);
|
|
495
|
+
break;
|
|
496
|
+
case "Tab":
|
|
497
|
+
case "ArrowDown":
|
|
498
|
+
e.shiftKey || ((i = this.listboxRef.value) == null || i.focusFirstOrSelectedOption(), e.preventDefault());
|
|
499
|
+
break;
|
|
500
|
+
case "Escape":
|
|
501
|
+
this._isOptionsOpen = !1, (s = this.arrowRef.value) == null || s.focus(), e.preventDefault();
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
handleTagRemove(e) {
|
|
506
|
+
this.removeSelected(e);
|
|
507
|
+
}
|
|
508
|
+
blurInput() {
|
|
509
|
+
this.inputRef.value && this.inputRef.value.matches(":focus") && this.inputRef.value.blur();
|
|
510
|
+
}
|
|
511
|
+
checkForMatches() {
|
|
512
|
+
var r;
|
|
513
|
+
const e = ((r = this.inputRef.value) == null ? void 0 : r.value) || this._search || "", t = e.trim().toLowerCase() || "";
|
|
514
|
+
if (!t) {
|
|
515
|
+
!this.multiple && this._value[0] && this.removeValue(this._value[0]), this.resetComboboxInput(!1);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const i = this._value.find((l) => l.toLowerCase() === t), s = this._options.filter(
|
|
519
|
+
(l) => {
|
|
520
|
+
var h;
|
|
521
|
+
return ((h = l.label) == null ? void 0 : h.toLowerCase().includes(t)) ?? !1;
|
|
522
|
+
}
|
|
523
|
+
), o = s.find(
|
|
524
|
+
(l) => {
|
|
525
|
+
var h;
|
|
526
|
+
return ((h = l.label) == null ? void 0 : h.toLowerCase()) === t || l.value.toLowerCase() === t;
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
switch (!0) {
|
|
530
|
+
case ((s.length === 0 || !o) && this.allowUserInput):
|
|
531
|
+
this._addValueText = e, this._userInfoMessage = "";
|
|
532
|
+
break;
|
|
533
|
+
case (s.length === 0 && !this.allowUserInput):
|
|
534
|
+
this._addValueText = null, this._userInfoMessage = "Ingen match i søket";
|
|
535
|
+
break;
|
|
536
|
+
case !!i:
|
|
537
|
+
this._addValueText = null, this._userInfoMessage = "Verdien er allerede valgt";
|
|
538
|
+
break;
|
|
539
|
+
case s.length > 1:
|
|
540
|
+
this._addValueText = null, this._userInfoMessage = "";
|
|
541
|
+
break;
|
|
542
|
+
default:
|
|
543
|
+
this._addValueText = null, this._userInfoMessage = "";
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
findValueInOptions(e) {
|
|
547
|
+
return this.options.find((t) => t.value === e || t.label === e) || null;
|
|
548
|
+
}
|
|
549
|
+
findIndexInOptions(e) {
|
|
550
|
+
return this._options.findIndex((t) => t.value === e || t.label === e);
|
|
551
|
+
}
|
|
552
|
+
isMaxItemsReached() {
|
|
553
|
+
const e = this.maxlength !== null && this._value.length >= this.maxlength;
|
|
554
|
+
return e ? this._maxIsReached = !0 : this._maxIsReached = !1, e;
|
|
555
|
+
}
|
|
556
|
+
toggleValue(e) {
|
|
557
|
+
var y, I;
|
|
558
|
+
if (this.disabled) return;
|
|
559
|
+
this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
|
|
560
|
+
const t = ((y = this.findValueInOptions(e)) == null ? void 0 : y.value) || null, i = this._value.includes(e || t || ""), s = !!t, o = ((I = this._options.find((_) => _.value === e)) == null ? void 0 : I.disabled) || !1, r = !(e != null && e.trim()), l = !this.multiple, h = this.multiple, x = this.isMaxItemsReached();
|
|
561
|
+
let p = !1, g = !0, b = "", k = "";
|
|
562
|
+
o || (!s && this.allowUserInput && !r ? (this.addNewUserValue(e), b = "Ny verdi lagt til", p = !h) : !s && !this.allowUserInput ? (l && this._value[0] && this.removeValue(this._value[0]), g = !1, p = !0, b = "Ingen treff i søket") : i ? (this.removeValue(t), p = !0) : r && 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())) : h && !x ? (this.setSelected(t), p = !0) : h && x ? (this._userInfoMessage = "Maks antall valg nådd", g = !1, k = e) : (l && this.removeAllSelected(), this._userInfoMessage = "Ingen gyldig verdi valgt", g = !1, p = !0, k = e), this._isOptionsOpen = p, p || window.setTimeout(() => {
|
|
563
|
+
var _;
|
|
564
|
+
(_ = this.focusRef.value) == null || _.focus();
|
|
565
|
+
}, 0), this._userInfoMessage = b, this._search = k || "", this.resetComboboxInput(g), h && this.isMaxItemsReached());
|
|
566
|
+
}
|
|
567
|
+
setSelected(e) {
|
|
568
|
+
if (!this._value.includes(e)) {
|
|
569
|
+
if (this.multiple && this.isMaxItemsReached()) {
|
|
570
|
+
this._userInfoMessage = "Maks antall valg nådd";
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
!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);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
removeSelected(e) {
|
|
577
|
+
if (!e) return;
|
|
578
|
+
this._value = this._value.filter((i) => i !== e);
|
|
579
|
+
const t = this.findValueInOptions(e);
|
|
580
|
+
t ? (t.selected = !1, t.userAdded ? (this._options = [...this._options.filter((i) => i.value !== e)], this.options = [...this.options.filter((i) => i.value !== e)]) : this._options = [...this._options, t]) : !e && !this.multiple && (this._options = this._options.map((i) => (i.selected = !1, i)));
|
|
581
|
+
}
|
|
582
|
+
addAllOptions() {
|
|
583
|
+
if (this.multiple) {
|
|
584
|
+
if (this.maxlength && this._options.length > this.maxlength) {
|
|
585
|
+
this._userInfoMessage = "For mange valgt";
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
this._value = this._options.map((e) => e.value), this._options = this._options.map((e) => (e.selected = !0, e)), this.requestUpdate();
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
removeAllSelected() {
|
|
592
|
+
this._value = [], this._options = this._options.map((e) => (e.selected = !1, e)), this._options = this._options.filter((e) => !e.userAdded), this.requestUpdate();
|
|
593
|
+
}
|
|
594
|
+
addValue() {
|
|
595
|
+
var t;
|
|
596
|
+
const e = ((t = this.inputRef.value) == null ? void 0 : t.value.trim()) || "";
|
|
597
|
+
this._search = e, this.toggleValue(e);
|
|
598
|
+
}
|
|
599
|
+
removeValue(e) {
|
|
600
|
+
this._value = this.multiple ? this._value.filter((t) => t !== e) : [], this.removeSelected(e);
|
|
601
|
+
}
|
|
602
|
+
addNewUserValue(e) {
|
|
603
|
+
if (!e || e.trim() === "") return;
|
|
604
|
+
if (!this.multiple)
|
|
605
|
+
this._value[0] && this.removeSelected(this._value[0]), this._value = [e], this._isOptionsOpen = !1, this.blurInput();
|
|
606
|
+
else if (!this.findValueInOptions(e)) {
|
|
607
|
+
if (this.isMaxItemsReached()) return;
|
|
608
|
+
this._value = [...this._value, e];
|
|
609
|
+
}
|
|
610
|
+
const t = { value: e, label: e, userAdded: !0 };
|
|
611
|
+
this.options = [t, ...this.options], this._options = [t, ...this._options], this.setSelected(e), this.requestUpdate();
|
|
612
|
+
}
|
|
613
|
+
resetComboboxInput(e = !0) {
|
|
614
|
+
if (this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && e)
|
|
615
|
+
if (this._search = "", this.multiple)
|
|
616
|
+
this.inputRef.value.value = "";
|
|
617
|
+
else {
|
|
618
|
+
const t = this.findValueInOptions(this._value[0]);
|
|
619
|
+
window.setTimeout(() => {
|
|
620
|
+
!this.inputRef.value || this.inputRef.value.type === "hidden" || (this.inputRef.value.value = this.displayValueAs === "label" && (t != null && t.label) ? t.label : this._value[0] || "");
|
|
621
|
+
}, 0), this._userInfoMessage = "";
|
|
622
|
+
}
|
|
623
|
+
this._options = [...this.options];
|
|
624
|
+
}
|
|
625
|
+
removeLastValue(e) {
|
|
626
|
+
if (this._value.length === 0) return;
|
|
627
|
+
e.preventDefault();
|
|
628
|
+
const t = this._value[this._value.length - 1];
|
|
629
|
+
t && this.removeSelected(t), this.isMaxItemsReached();
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
n([
|
|
633
|
+
u({ type: String, reflect: !0 })
|
|
634
|
+
], a.prototype, "value", 2);
|
|
635
|
+
n([
|
|
636
|
+
u({ type: Array })
|
|
637
|
+
], a.prototype, "options", 2);
|
|
638
|
+
n([
|
|
639
|
+
u({ type: Boolean })
|
|
640
|
+
], a.prototype, "allowUserInput", 2);
|
|
641
|
+
n([
|
|
642
|
+
u({ type: Boolean })
|
|
643
|
+
], a.prototype, "typeahead", 2);
|
|
644
|
+
n([
|
|
645
|
+
u({ type: Boolean })
|
|
646
|
+
], a.prototype, "includeSearch", 2);
|
|
647
|
+
n([
|
|
648
|
+
u({ type: String })
|
|
649
|
+
], a.prototype, "searchPlaceholder", 2);
|
|
650
|
+
n([
|
|
651
|
+
u({ type: Boolean })
|
|
652
|
+
], a.prototype, "multiple", 2);
|
|
653
|
+
n([
|
|
654
|
+
u({ type: Number })
|
|
655
|
+
], a.prototype, "maxlength", 2);
|
|
656
|
+
n([
|
|
657
|
+
u({ type: String })
|
|
658
|
+
], a.prototype, "displayValueAs", 2);
|
|
659
|
+
n([
|
|
660
|
+
u({ type: String })
|
|
661
|
+
], a.prototype, "tagPlacement", 2);
|
|
662
|
+
n([
|
|
663
|
+
c()
|
|
664
|
+
], a.prototype, "_options", 2);
|
|
665
|
+
n([
|
|
666
|
+
c()
|
|
667
|
+
], a.prototype, "_isOptionsOpen", 2);
|
|
668
|
+
n([
|
|
669
|
+
c()
|
|
670
|
+
], a.prototype, "_value", 2);
|
|
671
|
+
n([
|
|
672
|
+
c()
|
|
673
|
+
], a.prototype, "_userInfoMessage", 2);
|
|
674
|
+
n([
|
|
675
|
+
c()
|
|
676
|
+
], a.prototype, "_addValueText", 2);
|
|
677
|
+
n([
|
|
678
|
+
c()
|
|
679
|
+
], a.prototype, "_maxIsReached", 2);
|
|
680
|
+
n([
|
|
681
|
+
c()
|
|
682
|
+
], a.prototype, "_search", 2);
|
|
683
|
+
n([
|
|
684
|
+
c()
|
|
685
|
+
], a.prototype, "_inputFocus", 2);
|
|
686
|
+
n([
|
|
687
|
+
c()
|
|
688
|
+
], a.prototype, "_editingSingleValue", 2);
|
|
689
|
+
a = n([
|
|
690
|
+
O("pkt-combobox")
|
|
691
|
+
], a);
|
|
692
|
+
export {
|
|
693
|
+
a as P
|
|
694
|
+
};
|