@oslokommune/punkt-elements 18.3.1 → 18.5.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/CHANGELOG.md +42 -0
- package/dist/{accordion-4eAsO-Sr.js → accordion-D814csFx.js} +6 -6
- package/dist/{accordion-DOa5vubf.cjs → accordion-E0-pLzBq.cjs} +6 -6
- package/dist/{alert-DKNJTlMQ.js → alert-DNZtr3gd.js} +39 -31
- package/dist/alert-DqM9l5as.cjs +40 -0
- package/dist/{backlink-CA5R69FX.cjs → backlink-DYO8qA9C.cjs} +1 -1
- package/dist/{button-Dqolsuwj.js → button-Drwt7Qe5.js} +29 -26
- package/dist/button-jJfzE9C7.cjs +32 -0
- package/dist/{card-DgRvtnnk.js → card-BhmJZOGh.js} +90 -70
- package/dist/card-D-1JMn_h.cjs +64 -0
- package/dist/{combobox-q8kzy-S_.js → combobox-BNstYIC5.js} +20 -20
- package/dist/{combobox-D3zyAi_o.cjs → combobox-CRdBlMz1.cjs} +17 -17
- package/dist/components/alert/alert.d.ts +2 -0
- package/dist/components/button/button.d.ts +4 -21
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/card/card.d.ts +12 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/linkcard/linkcard.d.ts +1 -1
- package/dist/components/loader/loader.d.ts +2 -2
- package/dist/components/messagebox/messagebox.d.ts +1 -1
- package/dist/components/progressbar/progressbar.d.ts +2 -6
- package/dist/{consent-Cqetmc5Q.cjs → consent-DaOFbopy.cjs} +1 -1
- package/dist/{consent-Dkyp-UbI.js → consent-Yvw7gZI_.js} +1 -1
- package/dist/{datepicker-8KnaI9Xj.cjs → datepicker-DjvL_Nb8.cjs} +16 -16
- package/dist/{datepicker-9ulmApjN.js → datepicker-DzTdWHkX.js} +3 -3
- package/dist/docs/components/button.d.ts +0 -1
- package/dist/{fileupload-XQAilDRd.js → fileupload-B8Uhfx2d.js} +24 -24
- package/dist/{fileupload-EWBE4h3V.cjs → fileupload-BJVYPl8u.cjs} +15 -15
- package/dist/{footer-BpuYmm5V.cjs → footer-BGC5PkLa.cjs} +1 -1
- package/dist/{footer-BXmN43ol.js → footer-BPxKLaut.js} +2 -2
- package/dist/{header-BPQHiw4v.js → header-BPzlBRhY.js} +30 -30
- package/dist/{header-BQ32MqUl.cjs → header-CAqegPzW.cjs} +34 -34
- package/dist/{header-menu-DpQbRKcm.cjs → header-menu-DBy7Yrd_.cjs} +1 -1
- package/dist/{header-menu-Dgem4HO9.js → header-menu-DWiPoQ58.js} +1 -1
- package/dist/{helptext-Ds8Q9IGV.cjs → helptext-BwDhf6VB.cjs} +2 -2
- package/dist/{helptext-BzLJKMMO.js → helptext-mf-67-fv.js} +2 -2
- package/dist/{input-wrapper-DzEgz7nZ.js → input-wrapper-BetB7OLQ.js} +16 -15
- package/dist/{input-wrapper-B0eSdZs3.cjs → input-wrapper-CS0qrYcm.cjs} +8 -7
- package/dist/{link-CpwR3BLX.cjs → link-DXnoMJIo.cjs} +3 -3
- package/dist/{link-C9xAIILf.js → link-DkO7a3Fs.js} +3 -3
- package/dist/{linkcard-Bzv3CEw5.cjs → linkcard-2l6z1M2U.cjs} +3 -3
- package/dist/{linkcard-C6ljKc0B.js → linkcard-aVKL5JPP.js} +8 -8
- package/dist/{loader-D6dau_7w.js → loader-CRVUJ-HU.js} +1 -1
- package/dist/{loader-Bv-1vwju.cjs → loader-D23kzlaR.cjs} +1 -1
- package/dist/{messagebox-CmhjIh0n.js → messagebox-CqI6_Ah7.js} +2 -2
- package/dist/{messagebox-DNUfv2FN.cjs → messagebox-DP06cyqc.cjs} +1 -1
- 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-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.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-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +31 -31
- 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-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-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 +117 -0
- package/dist/progressbar-BpcsDCnG.cjs +31 -0
- package/dist/{radiobutton-B_j_nYCC.js → radiobutton-B2e9Vyp8.js} +0 -1
- package/dist/{radiobutton-DsL-FNDd.cjs → radiobutton-C3nmL9rA.cjs} +0 -1
- package/dist/{searchinput-Dm3T0tGS.cjs → searchinput-CiPB8xvh.cjs} +3 -2
- package/dist/{searchinput-D7Dd2W2z.js → searchinput-DrUcPajl.js} +14 -12
- package/dist/{select-BqAZsLKy.js → select-B7TvZGIL.js} +15 -16
- package/dist/{select-VqzZdE-T.cjs → select-qxjHJ8bu.cjs} +13 -14
- package/dist/shared-types/button.d.ts +45 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/{tabs-DPdDkHSk.js → tabs-C_tCCdBK.js} +18 -18
- package/dist/{tabs-nvIpMwHK.cjs → tabs-DBanbSG1.cjs} +15 -15
- package/dist/tag-BDlwKjgT.cjs +27 -0
- package/dist/{tag-DBCzfbPE.js → tag-CdiDs9zb.js} +10 -10
- package/dist/{textarea-D17CiySU.cjs → textarea-DgFwd2LY.cjs} +10 -10
- package/dist/{textarea-C0a-K05x.js → textarea-YL6JYsB5.js} +14 -14
- package/dist/{textinput-D0QasOZ9.cjs → textinput-CIxMtaIo.cjs} +10 -10
- package/dist/{textinput-DKl04Y3e.js → textinput-CrJYDOHb.js} +12 -12
- package/dist/{timepicker-DVvI4uEk.js → timepicker-BHWOqlr8.js} +11 -11
- package/dist/{timepicker-BcnFL6Bj.cjs → timepicker-avaMu1hN.cjs} +8 -8
- package/package.json +2 -2
- package/src/components/accordion/accordion.ts +2 -1
- package/src/components/alert/alert.test.ts +2 -1
- package/src/components/alert/alert.ts +21 -3
- package/src/components/button/button.test.ts +0 -3
- package/src/components/button/button.ts +57 -62
- package/src/components/button/index.ts +0 -2
- package/src/components/card/card.test.ts +7 -7
- package/src/components/card/card.ts +99 -80
- package/src/components/helptext/helptext.ts +2 -2
- package/src/components/index.ts +0 -2
- package/src/components/input-wrapper/input-wrapper.ts +1 -0
- package/src/components/link/link.ts +4 -2
- package/src/components/linkcard/linkcard.test.ts +3 -3
- package/src/components/linkcard/linkcard.ts +1 -1
- package/src/components/loader/loader.test.ts +1 -1
- package/src/components/loader/loader.ts +3 -3
- package/src/components/messagebox/messagebox.test.ts +1 -1
- package/src/components/messagebox/messagebox.ts +2 -2
- package/src/components/progressbar/progressbar.test.ts +10 -8
- package/src/components/progressbar/progressbar.ts +63 -84
- package/src/components/radiobutton/radiobutton.ts +0 -1
- package/src/components/searchinput/searchinput.ts +3 -1
- package/src/components/select/select.test.ts +2 -1
- package/src/components/select/select.ts +0 -1
- package/dist/alert-BlHM1zEi.cjs +0 -35
- package/dist/button-CVMhQT3X.cjs +0 -30
- package/dist/card-DMKvuvNv.cjs +0 -87
- package/dist/progressbar-Bk_RsEjW.js +0 -112
- package/dist/progressbar-T5_MpZGN.cjs +0 -17
- package/dist/tag-Bp9gJnYh.cjs +0 -27
- package/dist/{backlink-BYUtL8cO.js → backlink-BHtxOlTw.js} +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, n as r, u as i } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as a } from "./class-map-BL_YL_Ed.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as o } from "./if-defined-r8tKY4tG.js";
|
|
4
|
+
import { n as s, t as c } from "./element-with-slot-COOwQUxM.js";
|
|
4
5
|
import "./icon-jEFbKTB_.js";
|
|
5
|
-
import
|
|
6
|
-
import "./tag-DBCzfbPE.js";
|
|
7
|
-
import "./heading-NYqciBEJ.js";
|
|
6
|
+
import "./tag-CdiDs9zb.js";
|
|
8
7
|
var l = {
|
|
9
8
|
name: "pkt-card",
|
|
10
9
|
react: "PktCard",
|
|
@@ -108,6 +107,13 @@ var l = {
|
|
|
108
107
|
default: !0,
|
|
109
108
|
category: "ui"
|
|
110
109
|
},
|
|
110
|
+
zoom: {
|
|
111
|
+
name: "Zoom på bildet",
|
|
112
|
+
description: "Forstørrer bildet litt når man holder musepekeren over kortet",
|
|
113
|
+
type: "boolean",
|
|
114
|
+
category: "ui",
|
|
115
|
+
default: !1
|
|
116
|
+
},
|
|
111
117
|
image: {
|
|
112
118
|
type: "object",
|
|
113
119
|
name: "Bilde",
|
|
@@ -133,6 +139,26 @@ var l = {
|
|
|
133
139
|
default: "square",
|
|
134
140
|
category: "contents"
|
|
135
141
|
},
|
|
142
|
+
imageAspect: {
|
|
143
|
+
name: "Bildeformat",
|
|
144
|
+
description: "Overstyrer bildets sideforhold. Uten denne er det 1:1, eller 19:10 med padding «none» og stående kort.",
|
|
145
|
+
type: [
|
|
146
|
+
"auto",
|
|
147
|
+
"1-1",
|
|
148
|
+
"4-3",
|
|
149
|
+
"3-2",
|
|
150
|
+
"16-9",
|
|
151
|
+
"19-10"
|
|
152
|
+
],
|
|
153
|
+
category: "ui"
|
|
154
|
+
},
|
|
155
|
+
restrictImageHeight: {
|
|
156
|
+
name: "Lås bildehøyden",
|
|
157
|
+
description: "Låser bildehøyden i stedet for sideforholdet, og trapper den opp med skjermbredden: 12.5rem, 14.375rem fra tablet og 18.125rem fra tablet-big. Bildet beskjæres sentrert.",
|
|
158
|
+
type: "boolean",
|
|
159
|
+
category: "ui",
|
|
160
|
+
default: !1
|
|
161
|
+
},
|
|
136
162
|
tags: {
|
|
137
163
|
type: "array",
|
|
138
164
|
description: "Liste av tags på card. Tar inn et array med objekter med følgende stringproperties: skin, iconName, ariaLabel, text",
|
|
@@ -175,9 +201,9 @@ var l = {
|
|
|
175
201
|
}
|
|
176
202
|
},
|
|
177
203
|
slots: { default: { description: "Innholdet i card" } }
|
|
178
|
-
}, u = class extends
|
|
204
|
+
}, u = class extends c {
|
|
179
205
|
constructor(...e) {
|
|
180
|
-
super(...e), this.ariaLabel = "", this.metaLead = null, this.borderOnHover = !0, this.clickCardLink = null, this.metaTrail = null, this.layout = l.props.layout.default, this.heading = "", this.
|
|
206
|
+
super(...e), this.ariaLabel = "", this.metaLead = null, this.borderOnHover = !0, this.zoom = !1, this.imageAspect = null, this.restrictImageHeight = !1, this.clickCardLink = null, this.metaTrail = null, this.layout = l.props.layout.default, this.heading = "", this.headingLevel = 3, this.image = {
|
|
181
207
|
src: "",
|
|
182
208
|
alt: ""
|
|
183
209
|
}, this.imageShape = "square", this.openLinkInNewTab = !1, this.padding = l.props.padding.default, this.skin = l.props.skin.default, this.subheading = "", this.tagPosition = "top", this.tags = [];
|
|
@@ -191,12 +217,13 @@ var l = {
|
|
|
191
217
|
[`pkt-card--${this.skin}`]: this.skin,
|
|
192
218
|
[`pkt-card--${this.layout}`]: this.layout,
|
|
193
219
|
[`pkt-card--padding-${this.padding}`]: this.padding,
|
|
194
|
-
"pkt-card--border-on-hover": this.borderOnHover
|
|
220
|
+
"pkt-card--border-on-hover": this.borderOnHover,
|
|
221
|
+
"pkt-card--zoom": this.zoom
|
|
195
222
|
}, r = this.ariaLabel?.trim() || (this.heading ? `${this.heading} lenkekort` : "lenkekort"), i = this.ariaLabel?.trim() || (this.heading ? this.heading : "kort");
|
|
196
223
|
return e`
|
|
197
224
|
<article
|
|
198
225
|
class=${a(t)}
|
|
199
|
-
aria-label=${
|
|
226
|
+
aria-label=${o(this.clickCardLink ? r : i)}
|
|
200
227
|
>
|
|
201
228
|
${this.renderImage()}
|
|
202
229
|
<div class="pkt-card__wrapper">
|
|
@@ -212,50 +239,40 @@ var l = {
|
|
|
212
239
|
renderImage() {
|
|
213
240
|
let t = {
|
|
214
241
|
"pkt-card__image": !0,
|
|
215
|
-
[`pkt-card__image-${this.imageShape}`]: this.imageShape
|
|
242
|
+
[`pkt-card__image-${this.imageShape}`]: this.imageShape,
|
|
243
|
+
[`pkt-card__image-aspect-${this.imageAspect}`]: !!this.imageAspect,
|
|
244
|
+
"pkt-card__image-restricted": this.restrictImageHeight
|
|
216
245
|
};
|
|
217
246
|
return e`
|
|
218
247
|
${this.image.src && e`
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
248
|
+
<div class=${a(t)}>
|
|
249
|
+
<img src=${this.image.src} alt=${this.image.alt || ""} />
|
|
250
|
+
</div>
|
|
251
|
+
`}
|
|
223
252
|
`;
|
|
224
253
|
}
|
|
254
|
+
renderHeadingTag(t, n) {
|
|
255
|
+
let r = this.headingLevel && this.headingLevel >= 1 && this.headingLevel <= 6 ? this.headingLevel : 3, i = `pkt-heading pkt-heading--medium pkt-heading--fw-regular ${t}`;
|
|
256
|
+
switch (r) {
|
|
257
|
+
case 1: return e`<h1 class=${i}>${n}</h1>`;
|
|
258
|
+
case 2: return e`<h2 class=${i}>${n}</h2>`;
|
|
259
|
+
case 4: return e`<h4 class=${i}>${n}</h4>`;
|
|
260
|
+
case 5: return e`<h5 class=${i}>${n}</h5>`;
|
|
261
|
+
case 6: return e`<h6 class=${i}>${n}</h6>`;
|
|
262
|
+
default: return e`<h3 class=${i}>${n}</h3>`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
225
265
|
renderHeading() {
|
|
226
|
-
return
|
|
227
|
-
${this.heading && !this.clickCardLink ? e`
|
|
228
|
-
<pkt-heading
|
|
229
|
-
class="pkt-card__heading"
|
|
230
|
-
.level=${this.headinglevel || 3}
|
|
231
|
-
size="medium"
|
|
232
|
-
nospacing
|
|
233
|
-
weight="regular"
|
|
234
|
-
>
|
|
235
|
-
${this.heading}
|
|
236
|
-
</pkt-heading>
|
|
237
|
-
` : n}
|
|
238
|
-
`;
|
|
266
|
+
return !this.heading || this.clickCardLink ? n : this.renderHeadingTag("pkt-card__heading", this.heading);
|
|
239
267
|
}
|
|
240
268
|
renderLinkHeading() {
|
|
241
|
-
return e
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
nospacing
|
|
249
|
-
>
|
|
250
|
-
<a
|
|
251
|
-
class="pkt-card__link"
|
|
252
|
-
href=${this.clickCardLink}
|
|
253
|
-
target=${this.openLinkInNewTab ? "_blank" : "_self"}
|
|
254
|
-
>${this.heading}</a
|
|
255
|
-
>
|
|
256
|
-
</pkt-heading>
|
|
257
|
-
` : n}
|
|
258
|
-
`;
|
|
269
|
+
return this.clickCardLink ? this.renderHeadingTag("pkt-card__link-heading pkt-card__heading", e`<a
|
|
270
|
+
class="pkt-card__link"
|
|
271
|
+
href=${this.clickCardLink}
|
|
272
|
+
target=${this.openLinkInNewTab ? "_blank" : "_self"}
|
|
273
|
+
rel=${o(this.openLinkInNewTab ? "noopener noreferrer" : void 0)}
|
|
274
|
+
>${this.heading}</a
|
|
275
|
+
>`) : n;
|
|
259
276
|
}
|
|
260
277
|
renderSubheading() {
|
|
261
278
|
return e`
|
|
@@ -281,44 +298,47 @@ var l = {
|
|
|
281
298
|
};
|
|
282
299
|
return e`
|
|
283
300
|
${this.tags.length > 0 ? e`
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
301
|
+
<div
|
|
302
|
+
class=${a(t)}
|
|
303
|
+
role="list"
|
|
304
|
+
aria-label=${this.tags.length > 1 ? "merkelapper" : "merkelapp"}
|
|
305
|
+
>
|
|
306
|
+
${this.tags.map((t) => e`
|
|
307
|
+
<pkt-tag
|
|
308
|
+
role="listitem"
|
|
309
|
+
textStyle="normal-text"
|
|
310
|
+
size="medium"
|
|
311
|
+
skin=${o(t.skin)}
|
|
312
|
+
iconName=${o(t.iconName)}
|
|
313
|
+
>
|
|
314
|
+
<span>${t.text}</span>
|
|
315
|
+
</pkt-tag>
|
|
316
|
+
`)}
|
|
317
|
+
</div>
|
|
318
|
+
` : n}
|
|
302
319
|
`;
|
|
303
320
|
}
|
|
304
321
|
renderSlot() {
|
|
305
|
-
return e`<section class="pkt-card__content">${
|
|
322
|
+
return e`<section class="pkt-card__content">${s(this)}</section>`;
|
|
306
323
|
}
|
|
307
324
|
renderMetadata() {
|
|
308
325
|
return e`
|
|
309
326
|
${this.metaLead || this.metaTrail ? e`
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
327
|
+
<footer class="pkt-card__metadata">
|
|
328
|
+
${this.metaLead ? e`<span class="pkt-card__metadata-lead">${this.metaLead}</span>` : n}
|
|
329
|
+
${this.metaTrail ? e`<span class="pkt-card__metadata-trail">${this.metaTrail}</span>` : n}
|
|
330
|
+
</footer>
|
|
331
|
+
` : n}
|
|
315
332
|
`;
|
|
316
333
|
}
|
|
317
334
|
};
|
|
318
|
-
r([i({ type: String })], u.prototype, "ariaLabel", void 0), r([i({ type: String })], u.prototype, "metaLead", void 0), r([i({ type: Boolean })], u.prototype, "borderOnHover", void 0), r([i({
|
|
335
|
+
r([i({ type: String })], u.prototype, "ariaLabel", void 0), r([i({ type: String })], u.prototype, "metaLead", void 0), r([i({ type: Boolean })], u.prototype, "borderOnHover", void 0), r([i({ type: Boolean })], u.prototype, "zoom", void 0), r([i({ type: String })], u.prototype, "imageAspect", void 0), r([i({ type: Boolean })], u.prototype, "restrictImageHeight", void 0), r([i({
|
|
319
336
|
type: String,
|
|
320
337
|
reflect: !0
|
|
321
|
-
})], u.prototype, "clickCardLink", void 0), r([i({ type: String })], u.prototype, "metaTrail", void 0), r([i({ type: String })], u.prototype, "layout", void 0), r([i({ type: String })], u.prototype, "heading", void 0), r([i({
|
|
338
|
+
})], u.prototype, "clickCardLink", void 0), r([i({ type: String })], u.prototype, "metaTrail", void 0), r([i({ type: String })], u.prototype, "layout", void 0), r([i({ type: String })], u.prototype, "heading", void 0), r([i({
|
|
339
|
+
type: Number,
|
|
340
|
+
attribute: "headinglevel"
|
|
341
|
+
})], u.prototype, "headingLevel", void 0), r([i({ type: Object })], u.prototype, "image", void 0), r([i({ type: String })], u.prototype, "imageShape", void 0), r([i({ type: Boolean })], u.prototype, "openLinkInNewTab", void 0), r([i({ type: String })], u.prototype, "padding", void 0), r([i({
|
|
322
342
|
type: String,
|
|
323
343
|
converter: {
|
|
324
344
|
fromAttribute: (e) => {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs"),require("./tag-BDlwKjgT.cjs");var i={name:`pkt-card`,react:`PktCard`,"css-class":`pkt-card`,isElement:!0,isPureReact:!0,"dark-mode":!0,props:{heading:{type:`string`,name:`Overskrift`,description:`Tittel på card`,category:`contents`},headingLevel:{type:[1,2,3,4,5,6],name:`Overskriftsnivå`,description:`Nivået på headingen. Brukes for tilgjengelighet.`,default:3,category:`accessibility`},subheading:{type:`string`,name:`Undertittel`,description:`Undertittel på card`,category:`contents`},layout:{type:[`vertical`,`horizontal`],name:`Layout`,description:`Horisontal eller vertikal layout. Ved horisontal layout vil bildet være plassert til venstre for teksten på desktop, og over teksten på mobil.`,default:`vertical`,category:`ui`},skin:{type:[`outlined`,`outlined-beige`,`gray`,`blue`,`beige`,`green`],name:`Utseende`,description:`Fargen på card. Velg mellom outlined, outlined-beige, gray, blue, beige og green. Ved padding=none er det ikke mulighet for outlined-skin. Card med kombinasjonen av propsene padding=none + layout=vertical vil alltid være transparante.`,default:`outlined`,category:`ui`},padding:{type:[`none`,`default`],name:`Padding`,description:`Padding rundt card. Ved "none" strekker innholdet i card seg ut til kantene, og dette er derfor ikke mulig å kombinere med outlined skin.`,default:`default`,category:`ui`},metaLead:{type:`string`,name:`Forfatter eller annen metadata`,description:`Undertekst med fet skriftvekt`,default:!1,category:`contents`},metaTrail:{type:`string`,name:`Dato eller annen metadata`,description:`Undertekst med normal skriftvekt`,default:!1,category:`contents`},tagPosition:{type:[`top`,`bottom`],name:`Tagplassering`,description:`Plassering av tags i card`,default:`top`,category:`ui`},clickCardLink:{type:`string`,name:`Lenke for klikkbart card`,description:`Href sendes inn som streng for å gjøre card klikkbart. Ved bruk MÅ heading sendes inn da denne vil brukes som lenketekst i klikkbart card.`,category:`contents`},openLinkInNewTab:{type:`boolean`,name:`Åpne i ny fane`,description:`Velg denne dersom du ønsker at lenken i card skal åpnes i ny fane.`,default:!1,category:`tech`},borderOnHover:{type:`boolean`,name:`Hover border for klikkbart card`,description:`Vi anbefaler hoverborder på klikkbart card. Kan slås av ved behov.`,default:!0,category:`ui`},zoom:{name:`Zoom på bildet`,description:`Forstørrer bildet litt når man holder musepekeren over kortet`,type:`boolean`,category:`ui`,default:!1},image:{type:`object`,name:`Bilde`,description:`Bildet på card. Tar inn et objekt av typen {src: string, alt: string}.`,properties:{src:{type:`string`,description:`Stien til bildet`,required:!0},alt:{type:`string`,description:`Tekst til skjermleser. Skal kun sendes inn for bilder som ikke er dekorative`,required:!1}},category:`contents`},imageShape:{type:[`square`,`round`],name:`Bildeform`,description:`Valg for om bildet skal ha rektangulær eller rund form.`,default:`square`,category:`contents`},imageAspect:{name:`Bildeformat`,description:`Overstyrer bildets sideforhold. Uten denne er det 1:1, eller 19:10 med padding «none» og stående kort.`,type:[`auto`,`1-1`,`4-3`,`3-2`,`16-9`,`19-10`],category:`ui`},restrictImageHeight:{name:`Lås bildehøyden`,description:`Låser bildehøyden i stedet for sideforholdet, og trapper den opp med skjermbredden: 12.5rem, 14.375rem fra tablet og 18.125rem fra tablet-big. Bildet beskjæres sentrert.`,type:`boolean`,category:`ui`,default:!1},tags:{type:`array`,description:`Liste av tags på card. Tar inn et array med objekter med følgende stringproperties: skin, iconName, ariaLabel, text`,name:`Tags`,items:{type:`object`,name:`Tag`,properties:{skin:{type:[`blue`,`green`,`red`,`yellow`],description:`Farge på tag`},iconName:{type:`icon`,description:`Id på ikonet du ønsker å bruke til tag`},ariaLabel:{type:`string`,description:`Tekst for aria-label`},text:{type:`string`,description:`Tekst på tag`,required:!0}}},category:`contents`},ariaLabel:{type:`string`,name:`Aria-label for card`,description:`Tekst til skjermleser for aria-label på card. Settes automatisk til headingen, eller subheadingen der heading ikke eksisterer. Ved bruk av klikkbart card må heading alltid sendes inn da denne brukes som lenketekst.`,category:`accessibility`}},slots:{default:{description:`Innholdet i card`}}},a=class extends r.t{constructor(...e){super(...e),this.ariaLabel=``,this.metaLead=null,this.borderOnHover=!0,this.zoom=!1,this.imageAspect=null,this.restrictImageHeight=!1,this.clickCardLink=null,this.metaTrail=null,this.layout=i.props.layout.default,this.heading=``,this.headingLevel=3,this.image={src:``,alt:``},this.imageShape=`square`,this.openLinkInNewTab=!1,this.padding=i.props.padding.default,this.skin=i.props.skin.default,this.subheading=``,this.tagPosition=`top`,this.tags=[]}connectedCallback(){super.connectedCallback()}render(){let r={"pkt-card":!0,[`pkt-card--${this.skin}`]:this.skin,[`pkt-card--${this.layout}`]:this.layout,[`pkt-card--padding-${this.padding}`]:this.padding,"pkt-card--border-on-hover":this.borderOnHover,"pkt-card--zoom":this.zoom},i=this.ariaLabel?.trim()||(this.heading?`${this.heading} lenkekort`:`lenkekort`),a=this.ariaLabel?.trim()||(this.heading?this.heading:`kort`);return e._`
|
|
2
|
+
<article
|
|
3
|
+
class=${t.t(r)}
|
|
4
|
+
aria-label=${n.t(this.clickCardLink?i:a)}
|
|
5
|
+
>
|
|
6
|
+
${this.renderImage()}
|
|
7
|
+
<div class="pkt-card__wrapper">
|
|
8
|
+
${this.tagPosition===`top`?this.renderTags():e.h}
|
|
9
|
+
${this.renderHeader()}
|
|
10
|
+
${this.renderSlot()}
|
|
11
|
+
${this.tagPosition===`bottom`?this.renderTags():e.h}
|
|
12
|
+
${this.renderMetadata()}
|
|
13
|
+
</div>
|
|
14
|
+
</article>
|
|
15
|
+
`}renderImage(){let n={"pkt-card__image":!0,[`pkt-card__image-${this.imageShape}`]:this.imageShape,[`pkt-card__image-aspect-${this.imageAspect}`]:!!this.imageAspect,"pkt-card__image-restricted":this.restrictImageHeight};return e._`
|
|
16
|
+
${this.image.src&&e._`
|
|
17
|
+
<div class=${t.t(n)}>
|
|
18
|
+
<img src=${this.image.src} alt=${this.image.alt||``} />
|
|
19
|
+
</div>
|
|
20
|
+
`}
|
|
21
|
+
`}renderHeadingTag(t,n){let r=this.headingLevel&&this.headingLevel>=1&&this.headingLevel<=6?this.headingLevel:3,i=`pkt-heading pkt-heading--medium pkt-heading--fw-regular ${t}`;switch(r){case 1:return e._`<h1 class=${i}>${n}</h1>`;case 2:return e._`<h2 class=${i}>${n}</h2>`;case 4:return e._`<h4 class=${i}>${n}</h4>`;case 5:return e._`<h5 class=${i}>${n}</h5>`;case 6:return e._`<h6 class=${i}>${n}</h6>`;default:return e._`<h3 class=${i}>${n}</h3>`}}renderHeading(){return!this.heading||this.clickCardLink?e.h:this.renderHeadingTag(`pkt-card__heading`,this.heading)}renderLinkHeading(){return this.clickCardLink?this.renderHeadingTag(`pkt-card__link-heading pkt-card__heading`,e._`<a
|
|
22
|
+
class="pkt-card__link"
|
|
23
|
+
href=${this.clickCardLink}
|
|
24
|
+
target=${this.openLinkInNewTab?`_blank`:`_self`}
|
|
25
|
+
rel=${n.t(this.openLinkInNewTab?`noopener noreferrer`:void 0)}
|
|
26
|
+
>${this.heading}</a
|
|
27
|
+
>`):e.h}renderSubheading(){return e._`
|
|
28
|
+
${this.subheading?e._` <p class="pkt-card__subheading ">${this.subheading}</p> `:e.h}
|
|
29
|
+
`}renderHeader(){let t=!!this.heading||!!this.subheading;return e._`
|
|
30
|
+
${t?e._`
|
|
31
|
+
<header class="pkt-card__header">
|
|
32
|
+
${this.renderHeading()}
|
|
33
|
+
${this.renderLinkHeading()}
|
|
34
|
+
${this.renderSubheading()}
|
|
35
|
+
</header>
|
|
36
|
+
`:e.h}
|
|
37
|
+
`}renderTags(){let r={"pkt-card__tags":!0,[`pkt-card__tags-${this.tagPosition}`]:this.tagPosition};return e._`
|
|
38
|
+
${this.tags.length>0?e._`
|
|
39
|
+
<div
|
|
40
|
+
class=${t.t(r)}
|
|
41
|
+
role="list"
|
|
42
|
+
aria-label=${this.tags.length>1?`merkelapper`:`merkelapp`}
|
|
43
|
+
>
|
|
44
|
+
${this.tags.map(t=>e._`
|
|
45
|
+
<pkt-tag
|
|
46
|
+
role="listitem"
|
|
47
|
+
textStyle="normal-text"
|
|
48
|
+
size="medium"
|
|
49
|
+
skin=${n.t(t.skin)}
|
|
50
|
+
iconName=${n.t(t.iconName)}
|
|
51
|
+
>
|
|
52
|
+
<span>${t.text}</span>
|
|
53
|
+
</pkt-tag>
|
|
54
|
+
`)}
|
|
55
|
+
</div>
|
|
56
|
+
`:e.h}
|
|
57
|
+
`}renderSlot(){return e._`<section class="pkt-card__content">${r.n(this)}</section>`}renderMetadata(){return e._`
|
|
58
|
+
${this.metaLead||this.metaTrail?e._`
|
|
59
|
+
<footer class="pkt-card__metadata">
|
|
60
|
+
${this.metaLead?e._`<span class="pkt-card__metadata-lead">${this.metaLead}</span>`:e.h}
|
|
61
|
+
${this.metaTrail?e._`<span class="pkt-card__metadata-trail">${this.metaTrail}</span>`:e.h}
|
|
62
|
+
</footer>
|
|
63
|
+
`:e.h}
|
|
64
|
+
`}};e.n([e.u({type:String})],a.prototype,`ariaLabel`,void 0),e.n([e.u({type:String})],a.prototype,`metaLead`,void 0),e.n([e.u({type:Boolean})],a.prototype,`borderOnHover`,void 0),e.n([e.u({type:Boolean})],a.prototype,`zoom`,void 0),e.n([e.u({type:String})],a.prototype,`imageAspect`,void 0),e.n([e.u({type:Boolean})],a.prototype,`restrictImageHeight`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`clickCardLink`,void 0),e.n([e.u({type:String})],a.prototype,`metaTrail`,void 0),e.n([e.u({type:String})],a.prototype,`layout`,void 0),e.n([e.u({type:String})],a.prototype,`heading`,void 0),e.n([e.u({type:Number,attribute:`headinglevel`})],a.prototype,`headingLevel`,void 0),e.n([e.u({type:Object})],a.prototype,`image`,void 0),e.n([e.u({type:String})],a.prototype,`imageShape`,void 0),e.n([e.u({type:Boolean})],a.prototype,`openLinkInNewTab`,void 0),e.n([e.u({type:String})],a.prototype,`padding`,void 0),e.n([e.u({type:String,converter:{fromAttribute:e=>{let t=i.props.skin.type;return e&&t.includes(e)?e:(e&&!t.includes(e)&&console.warn(`Invalid skin value "${e}". Using default skin "${i.props.skin.default}".`),i.props.skin.default)},toAttribute:e=>e}})],a.prototype,`skin`,void 0),e.n([e.u({type:String})],a.prototype,`subheading`,void 0),e.n([e.u({type:String})],a.prototype,`tagPosition`,void 0),e.n([e.u({type:Array})],a.prototype,`tags`,void 0);try{e.d(`pkt-card`)(a)}catch{console.warn(`Forsøker å definere <pkt-card>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as o } from "./class-map-BL_YL_Ed.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as s } from "./if-defined-r8tKY4tG.js";
|
|
4
|
+
import { n as c } from "./element-with-slot-COOwQUxM.js";
|
|
4
5
|
import "./icon-jEFbKTB_.js";
|
|
5
|
-
import { t as c } from "./if-defined-r8tKY4tG.js";
|
|
6
6
|
import { n as l, t as u } from "./ref-lE1mGUOL.js";
|
|
7
|
-
import "./tag-
|
|
7
|
+
import "./tag-CdiDs9zb.js";
|
|
8
8
|
import { t as d } from "./repeat-CCnTfedv.js";
|
|
9
9
|
import { a as f, c as p, i as m, o as h, r as g, s as _ } from "./listbox-CsP0qbU1.js";
|
|
10
10
|
import { t as v } from "./input-element-DxHRTZ3K.js";
|
|
11
11
|
import { t as y } from "./pkt-options-controller-DNDUGQno.js";
|
|
12
|
-
import "./input-wrapper-
|
|
12
|
+
import "./input-wrapper-BetB7OLQ.js";
|
|
13
13
|
//#region ../../shared-utils/combobox/input-utils.ts
|
|
14
14
|
var b = (e, t, n) => {
|
|
15
15
|
switch (e) {
|
|
@@ -861,8 +861,8 @@ var k = class extends O {
|
|
|
861
861
|
.size=${this.inputSize}
|
|
862
862
|
.label=${this.label}
|
|
863
863
|
.helptext=${this.helptext}
|
|
864
|
-
.helptextDropdown=${
|
|
865
|
-
.helptextDropdownButton=${
|
|
864
|
+
.helptextDropdown=${s(this.helptextDropdown)}
|
|
865
|
+
.helptextDropdownButton=${s(this.helptextDropdownButton)}
|
|
866
866
|
?fullwidth=${this.fullwidth}
|
|
867
867
|
?counter=${this.effectiveCounter(!!this.multiple && this.maxlength != null)}
|
|
868
868
|
.counterCurrent=${this._value.length}
|
|
@@ -882,7 +882,7 @@ var k = class extends O {
|
|
|
882
882
|
class="pkt-combobox__wrapper"
|
|
883
883
|
@labelClick=${this.handleInputClick}
|
|
884
884
|
>
|
|
885
|
-
<div class="pkt-contents" slot="helptext">${
|
|
885
|
+
<div class="pkt-contents" slot="helptext">${c(this, "helptext")}</div>
|
|
886
886
|
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
887
887
|
<div
|
|
888
888
|
class=${o({
|
|
@@ -893,14 +893,14 @@ var k = class extends O {
|
|
|
893
893
|
"pkt-combobox__input--error": this.hasError,
|
|
894
894
|
"pkt-combobox__input--disabled": this.disabled
|
|
895
895
|
})}
|
|
896
|
-
id=${
|
|
897
|
-
role=${
|
|
898
|
-
aria-expanded=${
|
|
899
|
-
aria-controls=${
|
|
900
|
-
aria-haspopup=${
|
|
901
|
-
aria-labelledby=${
|
|
902
|
-
aria-activedescendant=${
|
|
903
|
-
aria-description=${
|
|
896
|
+
id=${s(this._hasTextInput ? void 0 : `${this.id}-combobox`)}
|
|
897
|
+
role=${s(this._hasTextInput ? void 0 : "combobox")}
|
|
898
|
+
aria-expanded=${s(this._hasTextInput ? void 0 : this._isOptionsOpen ? "true" : "false")}
|
|
899
|
+
aria-controls=${s(this._hasTextInput ? void 0 : `${this.id}-listbox`)}
|
|
900
|
+
aria-haspopup=${s(this._hasTextInput ? void 0 : "listbox")}
|
|
901
|
+
aria-labelledby=${s(this._hasTextInput ? void 0 : `${this.id}-combobox-label`)}
|
|
902
|
+
aria-activedescendant=${s(!this._hasTextInput && this._value[0] && m(this.options, this._value[0]) ? `${this.id}-listbox-${f(this._options, this._value[0])}` : void 0)}
|
|
903
|
+
aria-description=${s(this._selectionDescription || void 0)}
|
|
904
904
|
tabindex=${this._hasTextInput || this.disabled ? "-1" : "0"}
|
|
905
905
|
@click=${this.handleInputClick}
|
|
906
906
|
@keydown=${this._hasTextInput ? n : this.handleSelectOnlyKeydown}
|
|
@@ -930,7 +930,7 @@ var k = class extends O {
|
|
|
930
930
|
?is-multi-select=${this.multiple}
|
|
931
931
|
?allow-user-input=${this.allowUserInput && !this._maxIsReached}
|
|
932
932
|
?max-is-reached=${this._maxIsReached}
|
|
933
|
-
.customUserInput=${
|
|
933
|
+
.customUserInput=${s(this._addValueText)}
|
|
934
934
|
.userMessage=${this._userInfoMessage ? this.pktStrings.get("combobox")[this._userInfoMessage] : ""}
|
|
935
935
|
@search=${this.handleSearch}
|
|
936
936
|
@option-toggle=${this.handleOptionToggled}
|
|
@@ -956,7 +956,7 @@ var k = class extends O {
|
|
|
956
956
|
type="text"
|
|
957
957
|
id="${this.id}-input"
|
|
958
958
|
name=${(this.name || this.id) + "-input"}
|
|
959
|
-
placeholder=${
|
|
959
|
+
placeholder=${s(!this._value.length || this.multiple && this.tagPlacement === "outside" ? this.placeholder : void 0)}
|
|
960
960
|
@input=${this.handleInput}
|
|
961
961
|
@change=${(e) => {
|
|
962
962
|
e.stopPropagation(), e.stopImmediatePropagation();
|
|
@@ -967,11 +967,11 @@ var k = class extends O {
|
|
|
967
967
|
autocomplete="off"
|
|
968
968
|
role="combobox"
|
|
969
969
|
aria-expanded=${this._isOptionsOpen ? "true" : "false"}
|
|
970
|
-
aria-label=${
|
|
970
|
+
aria-label=${s(this.label)}
|
|
971
971
|
aria-autocomplete=${this.typeahead ? "both" : this.allowUserInput ? "list" : "none"}
|
|
972
972
|
aria-controls="${this.id}-listbox"
|
|
973
|
-
aria-activedescendant=${
|
|
974
|
-
aria-description=${
|
|
973
|
+
aria-activedescendant=${s(this._value[0] && m(this.options, this._value[0]) ? `${this.id}-listbox-${f(this._options, this._value[0])}` : void 0)}
|
|
974
|
+
aria-description=${s(this._selectionDescription || void 0)}
|
|
975
975
|
${l(this.inputRef)}
|
|
976
976
|
/>
|
|
977
977
|
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const r=require("./if-defined-BeVQnl3C.cjs"),i=require("./ref-BkV4Cd8U.cjs");require("./tag-Bp9gJnYh.cjs");const a=require("./repeat-uBgVG8Ch.cjs"),o=require("./listbox-D95b5zAd.cjs"),s=require("./input-element-KpXXnGi0.cjs"),c=require("./pkt-options-controller-CJPuBqvH.cjs");require("./input-wrapper-B0eSdZs3.cjs");var l=(e,t,n)=>{switch(e){case`,`:return n?`addValue`:null;case`Enter`:return`addValue`;case`Tab`:case`ArrowDown`:return t?null:`focusListbox`;case`Escape`:return`closeOptions`;default:return null}},u=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let a=o.i(n,e);return!t.includes(e)&&!a?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:a&&!t.includes(a.value)?{action:`selectOption`,value:a.value}:{action:`none`,value:null}},d=(e,t,n,r,i)=>e.trim().toLowerCase()?{...o.s(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},f=(e,t,n)=>{let r=o.i(t,e);return n===`label`&&r?.label?r.label:e},p={markOptionSelected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!0;break}}},markOptionDeselected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!1;break}}},markAllSelected(e){for(let t of e)t.selected=!0},markAllDeselected(e){for(let t of e)t.selected=!1},removeUserAddedOptions(e){return e.filter(e=>!e.userAdded)}},m={parseOptionsFromSlot(e){let t=[];return e.forEach(e=>{if(!e.textContent&&!e.getAttribute(`value`))return;let n={value:e.getAttribute(`value`)||e.textContent||``,label:e.textContent||e.getAttribute(`value`)||``};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=o.r(n),t.push(n)}),t}},h={syncOptionsWithValues(e,t){let n=[...t];return e.forEach(e=>{e.value&&!e.label&&(e.label=e.value),e.selected&&!n.includes(e.value)&&n.push(e.value),e.fulltext=o.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t){return[...t.filter(e=>e?.userAdded&&e.selected).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},g={name:`pkt-combobox`,react:`PktCombobox`,"css-class":`pkt-combobox`,isElement:!0,isPureReact:!0,props:{name:{type:`string`,name:`Navn`,description:`Navn som brukes i skjema ved innsending`,category:`tech`},id:{type:`string`,name:`ID`,description:`Unik ID for feltet`,category:`tech`},label:{type:`string`,name:`Etikett/label`,description:`Tekst som vises over feltet`,category:`contents`},placeholder:{name:`Hint`,description:`Spesifiserer en kort hint som beskriver forventet verdi av feltet.`,type:`string`,category:`contents`,required:!1},multiple:{type:`boolean`,name:`Flervalg`,default:!1,description:`Mulighet for å velge flere valg`,category:`functionality`},tagPlacement:{attribute:`tag-placement`,type:[`inside`,`outside`],name:`Plassering av tags i flervalg`,description:`Plassering av valgte verdier i feltet ved flervalg`,category:`functionality`,showIf:{multiple:!0}},maxlength:{type:`number`,name:`Maks antall i flervalg`,description:`Maks antall valg dersom flervalg er aktivert`,category:`functionality`,showIf:{multiple:!0}},typeahead:{type:`boolean`,name:`Typeahead`,default:!1,description:`Mulighet for automatisk utfylling av feltet fra listen over valg`,category:`functionality`},includeSearch:{attribute:`include-search`,type:`boolean`,name:`Inkluder søk`,description:`Mulighet for å søke etter valg inni dropdown`,category:`functionality`},allowUserInput:{attribute:`allow-user-input`,type:`boolean`,name:`Brukervalgte verdier`,description:`Mulighet for å skrive inn egne verdier`,category:`functionality`},searchPlaceholder:{attribute:`search-placeholder`,type:`string`,name:`Søke-plassholder`,description:`Plassholdertekst for søkefeltet i dropdown`,category:`contents`,showIf:{includeSearch:!0}},displayValueAs:{attribute:`display-value-as`,type:[`label`,`value`,`prefixAndValue`],name:`Visning av valgt verdi`,description:`Hvordan valgt verdi vises i feltet`,default:`label`,category:`ui`},inputSize:{name:`Størrelse`,description:`Visuell størrelse via input-wrapper. small: kompakt wrapper og felt (42px). xsmall: samme wrapper som small, felt 36px.`,attribute:`input-size`,type:[`small`,`medium`,`xsmall`],default:`medium`,category:`ui`},value:{name:`Verdi`,type:`string`,description:`Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.`,category:`tech`},helptext:{type:`string`,name:`Hjelpetekst`,description:`Hjelpetekst som vises over feltet`,category:`contents`},helptextDropdown:{type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{type:`string`,name:`Knappetekst for hjelpetekst`,description:`Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst`,category:`contents`,default:`Les mer`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Feltet er deaktivert`,category:`tech`},hasError:{type:`boolean`,name:`Feil`,description:`Feltet har en feil`,category:`ui`},errorMessage:{type:`string`,name:`Feilmelding`,description:`Tekst som vises under feltet ved feil`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:`Feltet må fylles ut`,category:`tech`},requiredTag:{type:`boolean`,name:`Påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,category:`ui`},requiredText:{type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,category:`contents`},optionalTag:{type:`boolean`,name:`Valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,category:`ui`},optionalText:{type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Skal feltet ta opp hele bredden?`,category:`ui`},defaultOptions:{attribute:`default-options`,name:`Initielle valg (default options)`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)`,type:`array`,default:[],previewDefault:[{value:`bfr`,label:`Frogner`},{value:`bgo`,label:`Gamle Oslo`},{value:`bgr`,label:`Grorud`},{value:`bxx`,label:`Andre bydeler`}],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},options:{name:`Valg`,type:`array`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter`,default:[],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},inline:{name:`Inline`,type:`boolean`,required:!1,default:!1,description:`Angir om feltet skal flyte med teksten`,category:`ui`},useWrapper:{name:`Bruk wrapper`,type:`boolean`,required:!1,displayAsFalse:!0,default:!0,description:`Indikerer om skjemaelementet skal bruke en wrapper`,category:`ui`},hasFieldset:{name:`Bruk fieldset`,type:`boolean`,required:!1,default:null,description:`Bruk fieldset og legend i stedet for label. Utledes automatisk når feltet ikke har en input.`,category:`ui`},counter:{name:`Teller`,type:`boolean`,required:!1,default:null,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.`,category:`ui`}},events:{change:{type:`Event`,description:`Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier.`},"value-change":{type:`CustomEvent`,description:`Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>.`},search:{type:`CustomEvent`,description:`Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet`},toggleHelpText:{type:`CustomEvent`,description:`Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes`}}},_=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder=``,this.multiple=!1,this.maxlength=null,this.displayValueAs=g.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=i.t(),this.triggerRef=i.t(),this.listboxRef=i.t(),this.optionsController=new c.t(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){this._hasTextInput?this.inputRef.value?.focus():this.triggerRef.value?.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(`,`):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=o.c(this._value.length,this.maxlength)}syncValueAndDispatch(e){let t=this._value,n=this.multiple?t.join(`,`):t[0]||``;if(n!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this._internalValueSync=!0,this.value=n),e?.join(`,`)!==t.join(`,`)){let e=this.multiple?[...t]:t[0]||``;this.onChange(e)}else t.length===0&&e&&e.length>0&&this.clearInputValue()}onChange(e){this.touched=!0,super.onChange(e)}valueChanged(){}};e.n([e.u({type:String,reflect:!0})],_.prototype,`value`,void 0),e.n([e.u({type:Array})],_.prototype,`options`,void 0),e.n([e.u({type:Array,attribute:`default-options`})],_.prototype,`defaultOptions`,void 0),e.n([e.u({type:Boolean,attribute:`allow-user-input`})],_.prototype,`allowUserInput`,void 0),e.n([e.u({type:Boolean})],_.prototype,`typeahead`,void 0),e.n([e.u({type:Boolean,attribute:`include-search`})],_.prototype,`includeSearch`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],_.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:Boolean})],_.prototype,`multiple`,void 0),e.n([e.u({type:Number})],_.prototype,`maxlength`,void 0),e.n([e.u({type:String,attribute:`display-value-as`})],_.prototype,`displayValueAs`,void 0),e.n([e.u({type:String,attribute:`tag-placement`})],_.prototype,`tagPlacement`,void 0),e.n([e.u({type:Boolean,attribute:`open`})],_.prototype,`isOpen`,void 0),e.n([e.l()],_.prototype,`_options`,void 0),e.n([e.l()],_.prototype,`_value`,void 0),e.n([e.l()],_.prototype,`_isOptionsOpen`,void 0),e.n([e.l()],_.prototype,`_userInfoMessage`,void 0),e.n([e.l()],_.prototype,`_addValueText`,void 0),e.n([e.l()],_.prototype,`_maxIsReached`,void 0),e.n([e.l()],_.prototype,`_search`,void 0),e.n([e.l()],_.prototype,`_inputFocus`,void 0);var v=class extends _{toggleValue(e){if(this.disabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=o.i(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(),s=!this.multiple,c=this.multiple,l=o.c(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=``;i||(!r&&this.allowUserInput&&!a?(this.addNewUserValue(e),f=`valueAdded`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`noResults`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):a&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`maxSelected`,d=!1,p=e):(s&&this.removeAllSelected(),f=`noValidValue`,d=!1,u=!0,p=e),this._isOptionsOpen=u,u||(s&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=f,this._search=p||``,this.resetComboboxInput(d),c&&this.updateMaxReached())}setSelected(e){if(!this._value.includes(e)){if(this.multiple&&o.c(this._value.length,this.maxlength)){this._userInfoMessage=`maxSelected`;return}!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,p.markOptionSelected(this._options,e),this.resetComboboxInput(!0)}}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=o.i(this.options,e);t&&(p.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]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage=`tooManySelected`;return}this._value=this._options.map(e=>e.value),p.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],p.markAllDeselected(this._options),this._options=p.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;if(this._search=e,e&&this._value.includes(e)){this.resetComboboxInput(!0),this._userInfoMessage=`alreadySelected`;return}this.toggleValue(e)}removeValue(e){this._value=this.multiple?this._value.filter(t=>t!==e):[],this.removeSelected(e)}addNewUserValue(e){if(!e||e.trim()===``)return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[e];else if(!o.i(this.options,e)){if(o.c(this._value.length,this.maxlength))return;this._value=[...this._value,e]}let t={value:e,label:e,userAdded:!0,selected:!0};this.options=[t,...this.options],this._options=[t,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(e=!0){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]?f(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this._options=[...this.options]}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},y=class extends v{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.disabled)return;this.touched=!0;let t=e.target;if(this._search=t.value,this.checkForMatches(),this.typeahead){if(this._search){let{filtered:n,suggestion:r}=o.o(this.options,this._search);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`)}else this._options=[...this.options]}}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(e){if(this.disabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id!==this.id&&e.target?.getAttribute(`data-focusfix`)!==this.id&&t!==this.inputRef.value&&t!==this.triggerRef.value&&this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage=``,this._search=``,this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this.inputRef.value.value;if(!this.multiple){if(!e)this._value[0]&&this.removeSelected(this._value[0]);else{let t=o.i(this.options,e);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))}}else if(e!==``){let{action:t,value:n}=u(e,this._value,this.options,this.allowUserInput,this.multiple);switch(t){case`addUserValue`:this.addNewUserValue(n);break;case`selectOption`:this.setSelected(n);break;case`removeValue`:this.removeValue(n)}}!this.multiple&&this._value[0]?this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}this._hasTextInput?(this.inputRef.value?.focus(),this.requestUpdate()):(e.stopImmediatePropagation(),e.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&this.listboxRef.value?.focusFirstOrSelectedOption())}handlePlaceholderClick(e){this.disabled||(e.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(e){if(!this.disabled)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,this.listboxRef.value?.focusFirstOrSelectedOption());break;case`Escape`:this._isOptionsOpen&&=(e.preventDefault(),!1);break;case`Home`:case`End`:e.preventDefault(),this._isOptionsOpen||=!0,this.listboxRef.value?.focusFirstOrSelectedOption();break;case`ArrowLeft`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.focusTag(this._value.length-1));break;case`Backspace`:case`Delete`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.removeSelected(this._value[this._value.length-1]))}}handleOptionToggled(e){this.toggleValue(e.detail)}handleSearch(e){e.stopPropagation(),this._search=e.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(e){if(e.key===`Backspace`){let t=!this.inputRef.value?.value;!this._search&&t&&this.multiple&&this._value.length>0&&this.removeLastValue(e);return}if(e.key===`ArrowLeft`&&this.multiple&&this._value.length>0){let t=this.inputRef.value;if(t&&t.selectionStart===0&&!t.value){e.preventDefault(),this.focusTag(this._value.length-1);return}}let t=l(e.key,e.shiftKey,this.multiple);if(t&&!(e.key===`Tab`&&!this._isOptionsOpen)){if(t===`focusListbox`&&e.key===`Tab`&&!this.listboxRef.value?.querySelector(`[role="option"]:not([data-disabled]), [data-type="new-option"]`)){this.closeAndProcessInput();return}switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1}}}handleTagRemove(e){this.removeSelected(e),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(`.pkt-combobox__input .pkt-combobox__tag-list pkt-tag`))}focusTag(e){let t=this.getInsideTags();t.forEach((t,n)=>{t.buttonTabindex=n===e?0:-1}),(t[e]?.querySelector(`button`))?.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(e,t){e.stopPropagation();let n=()=>{this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():this.triggerRef.value?.focus()};switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&this.focusTag(t-1);break;case`ArrowRight`:e.preventDefault(),t<this._value.length-1?this.focusTag(t+1):n();break;case`Backspace`:case`Delete`:e.preventDefault();{let e=this._value[t],r=t>=this._value.length-1?t-1:t;this.removeSelected(e),r>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(r))):n()}break;case`Tab`:this.resetTagTabindices();break;case`Escape`:e.preventDefault(),n()}}checkForMatches(){let e=d(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}},b=class extends y{constructor(...e){super(...e),this.handleBodyClick=e=>{this._isOptionsOpen&&!this.contains(e.target)&&this.closeAndProcessInput()}}connectedCallback(){if(super.connectedCallback(),document?.body.addEventListener(`click`,this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){let e=this.options?.filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(this.optionsController?.nodes&&this.optionsController.nodes.length){let e=m.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=m.parseOptionsFromSlot(this.optionsController.nodes),n=this._options.filter(e=>e.userAdded);this.options=[...n,...t]}}super.willUpdate(e)}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}updated(e){e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen);let t=e.has(`value`),n=e.has(`_value`);if(t&&this._internalValueSync)this._internalValueSync=!1,n&&this.syncValueAndDispatch(e.get(`_value`));else if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t,this.options.forEach(e=>e.selected=t.includes(e.value)),this._options.forEach(e=>e.selected=t.includes(e.value)),this._options=[...this._options]),this.updateMaxReached(),this.syncValueAndDispatch(e)}else n&&this.syncValueAndDispatch(e.get(`_value`));if(e.has(`defaultOptions`)&&this.defaultOptions.length){let e=(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(e.has(`options`)){let t=e.get(`options`)||this._options||[],n=h.mergeWithUserAdded(this.options,t);this._options=n,n.length>this.options.length&&(this.options=n);let r=h.syncOptionsWithValues(this._options,this._value);if(this._options=r.options,r.newValues.length>this._value.length){let e=[...this._value];this._value=r.newValues,this.syncValueAndDispatch(e)}}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=!this.multiple&&this._value[0]?f(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}this.classList.add(`pkt-combobox-component`),this.classList.toggle(`pkt-combobox-component--fullwidth`,!!this.fullwidth),super.updated(e)}formResetCallback(){this.touched=!1;let e=this.defaultValue||(this.multiple,``);this.value=e,this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search=``,this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``),this.internals.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=Array.isArray(this.options)?[...this.options]:[];let e=h.syncOptionsWithValues(this._options,this._value);this._options=e.options,e.newValues.length>this._value.length&&(this._value=e.newValues),this._search=``}super.attributeChangedCallback(e,t,n)}render(){return e._`
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./ref-BkV4Cd8U.cjs");require("./tag-BDlwKjgT.cjs");const a=require("./repeat-uBgVG8Ch.cjs"),o=require("./listbox-D95b5zAd.cjs"),s=require("./input-element-KpXXnGi0.cjs"),c=require("./pkt-options-controller-CJPuBqvH.cjs");require("./input-wrapper-CS0qrYcm.cjs");var l=(e,t,n)=>{switch(e){case`,`:return n?`addValue`:null;case`Enter`:return`addValue`;case`Tab`:case`ArrowDown`:return t?null:`focusListbox`;case`Escape`:return`closeOptions`;default:return null}},u=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let a=o.i(n,e);return!t.includes(e)&&!a?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:a&&!t.includes(a.value)?{action:`selectOption`,value:a.value}:{action:`none`,value:null}},d=(e,t,n,r,i)=>e.trim().toLowerCase()?{...o.s(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},f=(e,t,n)=>{let r=o.i(t,e);return n===`label`&&r?.label?r.label:e},p={markOptionSelected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!0;break}}},markOptionDeselected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!1;break}}},markAllSelected(e){for(let t of e)t.selected=!0},markAllDeselected(e){for(let t of e)t.selected=!1},removeUserAddedOptions(e){return e.filter(e=>!e.userAdded)}},m={parseOptionsFromSlot(e){let t=[];return e.forEach(e=>{if(!e.textContent&&!e.getAttribute(`value`))return;let n={value:e.getAttribute(`value`)||e.textContent||``,label:e.textContent||e.getAttribute(`value`)||``};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=o.r(n),t.push(n)}),t}},h={syncOptionsWithValues(e,t){let n=[...t];return e.forEach(e=>{e.value&&!e.label&&(e.label=e.value),e.selected&&!n.includes(e.value)&&n.push(e.value),e.fulltext=o.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t){return[...t.filter(e=>e?.userAdded&&e.selected).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},g={name:`pkt-combobox`,react:`PktCombobox`,"css-class":`pkt-combobox`,isElement:!0,isPureReact:!0,props:{name:{type:`string`,name:`Navn`,description:`Navn som brukes i skjema ved innsending`,category:`tech`},id:{type:`string`,name:`ID`,description:`Unik ID for feltet`,category:`tech`},label:{type:`string`,name:`Etikett/label`,description:`Tekst som vises over feltet`,category:`contents`},placeholder:{name:`Hint`,description:`Spesifiserer en kort hint som beskriver forventet verdi av feltet.`,type:`string`,category:`contents`,required:!1},multiple:{type:`boolean`,name:`Flervalg`,default:!1,description:`Mulighet for å velge flere valg`,category:`functionality`},tagPlacement:{attribute:`tag-placement`,type:[`inside`,`outside`],name:`Plassering av tags i flervalg`,description:`Plassering av valgte verdier i feltet ved flervalg`,category:`functionality`,showIf:{multiple:!0}},maxlength:{type:`number`,name:`Maks antall i flervalg`,description:`Maks antall valg dersom flervalg er aktivert`,category:`functionality`,showIf:{multiple:!0}},typeahead:{type:`boolean`,name:`Typeahead`,default:!1,description:`Mulighet for automatisk utfylling av feltet fra listen over valg`,category:`functionality`},includeSearch:{attribute:`include-search`,type:`boolean`,name:`Inkluder søk`,description:`Mulighet for å søke etter valg inni dropdown`,category:`functionality`},allowUserInput:{attribute:`allow-user-input`,type:`boolean`,name:`Brukervalgte verdier`,description:`Mulighet for å skrive inn egne verdier`,category:`functionality`},searchPlaceholder:{attribute:`search-placeholder`,type:`string`,name:`Søke-plassholder`,description:`Plassholdertekst for søkefeltet i dropdown`,category:`contents`,showIf:{includeSearch:!0}},displayValueAs:{attribute:`display-value-as`,type:[`label`,`value`,`prefixAndValue`],name:`Visning av valgt verdi`,description:`Hvordan valgt verdi vises i feltet`,default:`label`,category:`ui`},inputSize:{name:`Størrelse`,description:`Visuell størrelse via input-wrapper. small: kompakt wrapper og felt (42px). xsmall: samme wrapper som small, felt 36px.`,attribute:`input-size`,type:[`small`,`medium`,`xsmall`],default:`medium`,category:`ui`},value:{name:`Verdi`,type:`string`,description:`Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.`,category:`tech`},helptext:{type:`string`,name:`Hjelpetekst`,description:`Hjelpetekst som vises over feltet`,category:`contents`},helptextDropdown:{type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{type:`string`,name:`Knappetekst for hjelpetekst`,description:`Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst`,category:`contents`,default:`Les mer`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Feltet er deaktivert`,category:`tech`},hasError:{type:`boolean`,name:`Feil`,description:`Feltet har en feil`,category:`ui`},errorMessage:{type:`string`,name:`Feilmelding`,description:`Tekst som vises under feltet ved feil`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:`Feltet må fylles ut`,category:`tech`},requiredTag:{type:`boolean`,name:`Påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,category:`ui`},requiredText:{type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,category:`contents`},optionalTag:{type:`boolean`,name:`Valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,category:`ui`},optionalText:{type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Skal feltet ta opp hele bredden?`,category:`ui`},defaultOptions:{attribute:`default-options`,name:`Initielle valg (default options)`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)`,type:`array`,default:[],previewDefault:[{value:`bfr`,label:`Frogner`},{value:`bgo`,label:`Gamle Oslo`},{value:`bgr`,label:`Grorud`},{value:`bxx`,label:`Andre bydeler`}],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},options:{name:`Valg`,type:`array`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter`,default:[],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},inline:{name:`Inline`,type:`boolean`,required:!1,default:!1,description:`Angir om feltet skal flyte med teksten`,category:`ui`},useWrapper:{name:`Bruk wrapper`,type:`boolean`,required:!1,displayAsFalse:!0,default:!0,description:`Indikerer om skjemaelementet skal bruke en wrapper`,category:`ui`},hasFieldset:{name:`Bruk fieldset`,type:`boolean`,required:!1,default:null,description:`Bruk fieldset og legend i stedet for label. Utledes automatisk når feltet ikke har en input.`,category:`ui`},counter:{name:`Teller`,type:`boolean`,required:!1,default:null,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.`,category:`ui`}},events:{change:{type:`Event`,description:`Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier.`},"value-change":{type:`CustomEvent`,description:`Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>.`},search:{type:`CustomEvent`,description:`Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet`},toggleHelpText:{type:`CustomEvent`,description:`Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes`}}},_=class extends s.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder=``,this.multiple=!1,this.maxlength=null,this.displayValueAs=g.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=i.t(),this.triggerRef=i.t(),this.listboxRef=i.t(),this.optionsController=new c.t(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){this._hasTextInput?this.inputRef.value?.focus():this.triggerRef.value?.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(`,`):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=o.c(this._value.length,this.maxlength)}syncValueAndDispatch(e){let t=this._value,n=this.multiple?t.join(`,`):t[0]||``;if(n!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this._internalValueSync=!0,this.value=n),e?.join(`,`)!==t.join(`,`)){let e=this.multiple?[...t]:t[0]||``;this.onChange(e)}else t.length===0&&e&&e.length>0&&this.clearInputValue()}onChange(e){this.touched=!0,super.onChange(e)}valueChanged(){}};e.n([e.u({type:String,reflect:!0})],_.prototype,`value`,void 0),e.n([e.u({type:Array})],_.prototype,`options`,void 0),e.n([e.u({type:Array,attribute:`default-options`})],_.prototype,`defaultOptions`,void 0),e.n([e.u({type:Boolean,attribute:`allow-user-input`})],_.prototype,`allowUserInput`,void 0),e.n([e.u({type:Boolean})],_.prototype,`typeahead`,void 0),e.n([e.u({type:Boolean,attribute:`include-search`})],_.prototype,`includeSearch`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],_.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:Boolean})],_.prototype,`multiple`,void 0),e.n([e.u({type:Number})],_.prototype,`maxlength`,void 0),e.n([e.u({type:String,attribute:`display-value-as`})],_.prototype,`displayValueAs`,void 0),e.n([e.u({type:String,attribute:`tag-placement`})],_.prototype,`tagPlacement`,void 0),e.n([e.u({type:Boolean,attribute:`open`})],_.prototype,`isOpen`,void 0),e.n([e.l()],_.prototype,`_options`,void 0),e.n([e.l()],_.prototype,`_value`,void 0),e.n([e.l()],_.prototype,`_isOptionsOpen`,void 0),e.n([e.l()],_.prototype,`_userInfoMessage`,void 0),e.n([e.l()],_.prototype,`_addValueText`,void 0),e.n([e.l()],_.prototype,`_maxIsReached`,void 0),e.n([e.l()],_.prototype,`_search`,void 0),e.n([e.l()],_.prototype,`_inputFocus`,void 0);var v=class extends _{toggleValue(e){if(this.disabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=o.i(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(),s=!this.multiple,c=this.multiple,l=o.c(this._value.length,this.maxlength),u=!1,d=!0,f=``,p=``;i||(!r&&this.allowUserInput&&!a?(this.addNewUserValue(e),f=`valueAdded`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`noResults`):n?(this.removeValue(t),u=!0,s&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):a&&s?(this.removeAllSelected(),u=!0):s?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`maxSelected`,d=!1,p=e):(s&&this.removeAllSelected(),f=`noValidValue`,d=!1,u=!0,p=e),this._isOptionsOpen=u,u||(s&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=f,this._search=p||``,this.resetComboboxInput(d),c&&this.updateMaxReached())}setSelected(e){if(!this._value.includes(e)){if(this.multiple&&o.c(this._value.length,this.maxlength)){this._userInfoMessage=`maxSelected`;return}!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,p.markOptionSelected(this._options,e),this.resetComboboxInput(!0)}}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=o.i(this.options,e);t&&(p.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]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage=`tooManySelected`;return}this._value=this._options.map(e=>e.value),p.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],p.markAllDeselected(this._options),this._options=p.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;if(this._search=e,e&&this._value.includes(e)){this.resetComboboxInput(!0),this._userInfoMessage=`alreadySelected`;return}this.toggleValue(e)}removeValue(e){this._value=this.multiple?this._value.filter(t=>t!==e):[],this.removeSelected(e)}addNewUserValue(e){if(!e||e.trim()===``)return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[e];else if(!o.i(this.options,e)){if(o.c(this._value.length,this.maxlength))return;this._value=[...this._value,e]}let t={value:e,label:e,userAdded:!0,selected:!0};this.options=[t,...this.options],this._options=[t,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(e=!0){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]?f(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this._options=[...this.options]}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},y=class extends v{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.disabled)return;this.touched=!0;let t=e.target;if(this._search=t.value,this.checkForMatches(),this.typeahead){if(this._search){let{filtered:n,suggestion:r}=o.o(this.options,this._search);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`)}else this._options=[...this.options]}}handleFocus(){if(!this.disabled){if(this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(e){if(this.disabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id!==this.id&&e.target?.getAttribute(`data-focusfix`)!==this.id&&t!==this.inputRef.value&&t!==this.triggerRef.value&&this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage=``,this._search=``,this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this.inputRef.value.value;if(!this.multiple){if(!e)this._value[0]&&this.removeSelected(this._value[0]);else{let t=o.i(this.options,e);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))}}else if(e!==``){let{action:t,value:n}=u(e,this._value,this.options,this.allowUserInput,this.multiple);switch(t){case`addUserValue`:this.addNewUserValue(n);break;case`selectOption`:this.setSelected(n);break;case`removeValue`:this.removeValue(n)}}!this.multiple&&this._value[0]?this.inputRef.value.value=f(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}this._hasTextInput?(this.inputRef.value?.focus(),this.requestUpdate()):(e.stopImmediatePropagation(),e.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&this.listboxRef.value?.focusFirstOrSelectedOption())}handlePlaceholderClick(e){this.disabled||(e.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(e){if(!this.disabled)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,this.listboxRef.value?.focusFirstOrSelectedOption());break;case`Escape`:this._isOptionsOpen&&=(e.preventDefault(),!1);break;case`Home`:case`End`:e.preventDefault(),this._isOptionsOpen||=!0,this.listboxRef.value?.focusFirstOrSelectedOption();break;case`ArrowLeft`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.focusTag(this._value.length-1));break;case`Backspace`:case`Delete`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.removeSelected(this._value[this._value.length-1]))}}handleOptionToggled(e){this.toggleValue(e.detail)}handleSearch(e){e.stopPropagation(),this._search=e.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(e){if(e.key===`Backspace`){let t=!this.inputRef.value?.value;!this._search&&t&&this.multiple&&this._value.length>0&&this.removeLastValue(e);return}if(e.key===`ArrowLeft`&&this.multiple&&this._value.length>0){let t=this.inputRef.value;if(t&&t.selectionStart===0&&!t.value){e.preventDefault(),this.focusTag(this._value.length-1);return}}let t=l(e.key,e.shiftKey,this.multiple);if(t&&!(e.key===`Tab`&&!this._isOptionsOpen)){if(t===`focusListbox`&&e.key===`Tab`&&!this.listboxRef.value?.querySelector(`[role="option"]:not([data-disabled]), [data-type="new-option"]`)){this.closeAndProcessInput();return}switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1}}}handleTagRemove(e){this.removeSelected(e),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(`.pkt-combobox__input .pkt-combobox__tag-list pkt-tag`))}focusTag(e){let t=this.getInsideTags();t.forEach((t,n)=>{t.buttonTabindex=n===e?0:-1}),(t[e]?.querySelector(`button`))?.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(e,t){e.stopPropagation();let n=()=>{this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():this.triggerRef.value?.focus()};switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&this.focusTag(t-1);break;case`ArrowRight`:e.preventDefault(),t<this._value.length-1?this.focusTag(t+1):n();break;case`Backspace`:case`Delete`:e.preventDefault();{let e=this._value[t],r=t>=this._value.length-1?t-1:t;this.removeSelected(e),r>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(r))):n()}break;case`Tab`:this.resetTagTabindices();break;case`Escape`:e.preventDefault(),n()}}checkForMatches(){let e=d(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}},b=class extends y{constructor(...e){super(...e),this.handleBodyClick=e=>{this._isOptionsOpen&&!this.contains(e.target)&&this.closeAndProcessInput()}}connectedCallback(){if(super.connectedCallback(),document?.body.addEventListener(`click`,this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){let e=this.options?.filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(this.optionsController?.nodes&&this.optionsController.nodes.length){let e=m.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=m.parseOptionsFromSlot(this.optionsController.nodes),n=this._options.filter(e=>e.userAdded);this.options=[...n,...t]}}super.willUpdate(e)}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}updated(e){e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen);let t=e.has(`value`),n=e.has(`_value`);if(t&&this._internalValueSync)this._internalValueSync=!1,n&&this.syncValueAndDispatch(e.get(`_value`));else if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t,this.options.forEach(e=>e.selected=t.includes(e.value)),this._options.forEach(e=>e.selected=t.includes(e.value)),this._options=[...this._options]),this.updateMaxReached(),this.syncValueAndDispatch(e)}else n&&this.syncValueAndDispatch(e.get(`_value`));if(e.has(`defaultOptions`)&&this.defaultOptions.length){let e=(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(e.has(`options`)){let t=e.get(`options`)||this._options||[],n=h.mergeWithUserAdded(this.options,t);this._options=n,n.length>this.options.length&&(this.options=n);let r=h.syncOptionsWithValues(this._options,this._value);if(this._options=r.options,r.newValues.length>this._value.length){let e=[...this._value];this._value=r.newValues,this.syncValueAndDispatch(e)}}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=!this.multiple&&this._value[0]?f(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}this.classList.add(`pkt-combobox-component`),this.classList.toggle(`pkt-combobox-component--fullwidth`,!!this.fullwidth),super.updated(e)}formResetCallback(){this.touched=!1;let e=this.defaultValue||(this.multiple,``);this.value=e,this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search=``,this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``),this.internals.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=Array.isArray(this.options)?[...this.options]:[];let e=h.syncOptionsWithValues(this._options,this._value);this._options=e.options,e.newValues.length>this._value.length&&(this._value=e.newValues),this._search=``}super.attributeChangedCallback(e,t,n)}render(){return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.strings=${this.strings}
|
|
4
4
|
.size=${this.inputSize}
|
|
5
5
|
.label=${this.label}
|
|
6
6
|
.helptext=${this.helptext}
|
|
7
|
-
.helptextDropdown=${
|
|
8
|
-
.helptextDropdownButton=${
|
|
7
|
+
.helptextDropdown=${n.t(this.helptextDropdown)}
|
|
8
|
+
.helptextDropdownButton=${n.t(this.helptextDropdownButton)}
|
|
9
9
|
?fullwidth=${this.fullwidth}
|
|
10
10
|
?counter=${this.effectiveCounter(!!this.multiple&&this.maxlength!=null)}
|
|
11
11
|
.counterCurrent=${this._value.length}
|
|
@@ -25,18 +25,18 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
25
25
|
class="pkt-combobox__wrapper"
|
|
26
26
|
@labelClick=${this.handleInputClick}
|
|
27
27
|
>
|
|
28
|
-
<div class="pkt-contents" slot="helptext">${
|
|
28
|
+
<div class="pkt-contents" slot="helptext">${r.n(this,`helptext`)}</div>
|
|
29
29
|
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
30
30
|
<div
|
|
31
31
|
class=${t.t({"pkt-combobox__input":!0,[`pkt-combobox__input--${this.inputSize}`]:!0,"pkt-combobox__input--fullwidth":this.fullwidth,"pkt-combobox__input--open":this._isOptionsOpen,"pkt-combobox__input--error":this.hasError,"pkt-combobox__input--disabled":this.disabled})}
|
|
32
|
-
id=${
|
|
33
|
-
role=${
|
|
34
|
-
aria-expanded=${
|
|
35
|
-
aria-controls=${
|
|
36
|
-
aria-haspopup=${
|
|
37
|
-
aria-labelledby=${
|
|
38
|
-
aria-activedescendant=${
|
|
39
|
-
aria-description=${
|
|
32
|
+
id=${n.t(this._hasTextInput?void 0:`${this.id}-combobox`)}
|
|
33
|
+
role=${n.t(this._hasTextInput?void 0:`combobox`)}
|
|
34
|
+
aria-expanded=${n.t(this._hasTextInput?void 0:this._isOptionsOpen?`true`:`false`)}
|
|
35
|
+
aria-controls=${n.t(this._hasTextInput?void 0:`${this.id}-listbox`)}
|
|
36
|
+
aria-haspopup=${n.t(this._hasTextInput?void 0:`listbox`)}
|
|
37
|
+
aria-labelledby=${n.t(this._hasTextInput?void 0:`${this.id}-combobox-label`)}
|
|
38
|
+
aria-activedescendant=${n.t(!this._hasTextInput&&this._value[0]&&o.i(this.options,this._value[0])?`${this.id}-listbox-${o.a(this._options,this._value[0])}`:void 0)}
|
|
39
|
+
aria-description=${n.t(this._selectionDescription||void 0)}
|
|
40
40
|
tabindex=${this._hasTextInput||this.disabled?`-1`:`0`}
|
|
41
41
|
@click=${this.handleInputClick}
|
|
42
42
|
@keydown=${this._hasTextInput?e.h:this.handleSelectOnlyKeydown}
|
|
@@ -63,7 +63,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
63
63
|
?is-multi-select=${this.multiple}
|
|
64
64
|
?allow-user-input=${this.allowUserInput&&!this._maxIsReached}
|
|
65
65
|
?max-is-reached=${this._maxIsReached}
|
|
66
|
-
.customUserInput=${
|
|
66
|
+
.customUserInput=${n.t(this._addValueText)}
|
|
67
67
|
.userMessage=${this._userInfoMessage?this.pktStrings.get(`combobox`)[this._userInfoMessage]:``}
|
|
68
68
|
@search=${this.handleSearch}
|
|
69
69
|
@option-toggle=${this.handleOptionToggled}
|
|
@@ -86,7 +86,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
86
86
|
type="text"
|
|
87
87
|
id="${this.id}-input"
|
|
88
88
|
name=${(this.name||this.id)+`-input`}
|
|
89
|
-
placeholder=${
|
|
89
|
+
placeholder=${n.t(!this._value.length||this.multiple&&this.tagPlacement===`outside`?this.placeholder:void 0)}
|
|
90
90
|
@input=${this.handleInput}
|
|
91
91
|
@change=${e=>{e.stopPropagation(),e.stopImmediatePropagation()}}
|
|
92
92
|
@keydown=${this.handleInputKeydown}
|
|
@@ -95,11 +95,11 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
95
95
|
autocomplete="off"
|
|
96
96
|
role="combobox"
|
|
97
97
|
aria-expanded=${this._isOptionsOpen?`true`:`false`}
|
|
98
|
-
aria-label=${
|
|
98
|
+
aria-label=${n.t(this.label)}
|
|
99
99
|
aria-autocomplete=${this.typeahead?`both`:this.allowUserInput?`list`:`none`}
|
|
100
100
|
aria-controls="${this.id}-listbox"
|
|
101
|
-
aria-activedescendant=${
|
|
102
|
-
aria-description=${
|
|
101
|
+
aria-activedescendant=${n.t(this._value[0]&&o.i(this.options,this._value[0])?`${this.id}-listbox-${o.a(this._options,this._value[0])}`:void 0)}
|
|
102
|
+
aria-description=${n.t(this._selectionDescription||void 0)}
|
|
103
103
|
${i.n(this.inputRef)}
|
|
104
104
|
/>
|
|
105
105
|
</div>
|
|
@@ -26,9 +26,11 @@ export declare class PktAlert extends PktElementWithSlot<IPktAlert> implements I
|
|
|
26
26
|
closeAlert: boolean;
|
|
27
27
|
date: string | null;
|
|
28
28
|
role: string;
|
|
29
|
+
_hostId: string | null;
|
|
29
30
|
size?: 'medium' | 'small' | 'xsmall';
|
|
30
31
|
_isClosed: boolean;
|
|
31
32
|
connectedCallback(): void;
|
|
33
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
32
34
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
33
35
|
protected updated(_changedProperties: PropertyValues): void;
|
|
34
36
|
render(): import('lit-html').TemplateResult<1>;
|