@oslokommune/punkt-elements 17.0.8 → 17.1.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 +35 -0
- package/dist/{accordion-DEUHQ4JD.js → accordion-DZq8Dnvh.js} +5 -5
- package/dist/{accordion-CbXDxOho.cjs → accordion-DlNfuooe.cjs} +1 -1
- package/dist/{alert-CbtVGrHD.js → alert-CbN5Bfdd.js} +5 -5
- package/dist/{alert-CkUnbPdA.cjs → alert-D7YR5Ru2.cjs} +1 -1
- package/dist/{async-directive-HLXOyE4A.cjs → async-directive-Cj6po9Zy.cjs} +1 -1
- package/dist/{async-directive-Cw_7VW_-.js → async-directive-DaiMzAU4.js} +2 -2
- package/dist/{backlink-DDGlLzk9.cjs → backlink-CxSKQSoA.cjs} +1 -1
- package/dist/{backlink-wMNLuQ0X.js → backlink-eAD8xH5b.js} +3 -3
- package/dist/base-elements/input-element.d.ts +9 -4
- package/dist/booleanish-BF8l4scU.cjs +1 -0
- package/dist/{booleanish-MfutDT_4.js → booleanish-OQJTYSrw.js} +8 -1
- package/dist/{breadcrumbs-CVTLNNsL.js → breadcrumbs-CJP75InB.js} +2 -2
- package/dist/{breadcrumbs-D3tfWqvC.cjs → breadcrumbs-CYKfjd4Q.cjs} +1 -1
- package/dist/{button-Cod17rKo.js → button-D_M6dpeU.js} +5 -5
- package/dist/{button-gvDXtBMC.cjs → button-o0BRKpis.cjs} +1 -1
- package/dist/{calendar-BVXW8DqC.cjs → calendar-7_ii5p5b.cjs} +1 -1
- package/dist/{calendar-CjC4qlh6.js → calendar-BCUnpa_x.js} +3 -3
- package/dist/{card-sydjK3Bb.cjs → card-Cf_jOdya.cjs} +1 -1
- package/dist/{card-sDOe54um.js → card-KB9C2f1R.js} +7 -7
- package/dist/{checkbox-DJDphhqz.js → checkbox-C2eVUk13.js} +4 -4
- package/dist/{checkbox-8uxbeU30.cjs → checkbox-Ch23npOC.cjs} +1 -1
- package/dist/{class-map-CAQCRB1W.js → class-map-BRV7-mcj.js} +1 -1
- package/dist/{class-map-CCZN5uS3.cjs → class-map-DzzW3MwB.cjs} +1 -1
- package/dist/combobox-Db1fB0K7.cjs +139 -0
- package/dist/{combobox-D_fReDgU.js → combobox-dSWHF8Ii.js} +52 -16
- package/dist/components/fileupload/fileupload.d.ts +2 -0
- package/dist/components/input-wrapper/tri-state.test.d.ts +0 -0
- package/dist/components/input-wrapper/wrapper-parity.test.d.ts +1 -0
- package/dist/components/select/select.test.d.ts +2 -2
- package/dist/components/textarea/textarea.d.ts +2 -1
- package/dist/components/textarea/textarea.test.d.ts +2 -2
- package/dist/components/textinput/textinput.test.d.ts +2 -2
- package/dist/{consent--Nw43WFU.cjs → consent-C57oumuq.cjs} +1 -1
- package/dist/{consent-B2hSTCGC.js → consent-CibGBVvV.js} +2 -2
- package/dist/{datepicker-DrB54Rhc.cjs → datepicker-Ci6Oj0YL.cjs} +6 -7
- package/dist/{datepicker-BMuplkDE.js → datepicker-D9Qr98VO.js} +39 -16
- package/dist/{directive-helpers-DIF5DwN4.js → directive-helpers-BXtu2yHt.js} +1 -1
- package/dist/{directive-helpers-BshFvt7A.cjs → directive-helpers-CEtfS19L.cjs} +1 -1
- package/dist/docs/components/verifisering.d.ts +15 -0
- package/dist/{element-BoJrqauR.js → element-8RsANDBG.js} +2 -1
- package/dist/{element-DJzurxgt.cjs → element-DCm4GU7z.cjs} +1 -1
- package/dist/{element-with-slot-mXLg8gg8.js → element-with-slot-DFNWwYys.js} +2 -2
- package/dist/{element-with-slot-BY7Jc-q8.cjs → element-with-slot-N79a3tub.cjs} +1 -1
- package/dist/{fileupload-D4gQN64T.js → fileupload-D008usH2.js} +11 -8
- package/dist/{fileupload-CGKUJrlj.cjs → fileupload-DtAujY-k.cjs} +2 -2
- package/dist/{footer-BIrJeRuZ.js → footer-05rSMBWl.js} +5 -5
- package/dist/{footer-Ber-jqM1.cjs → footer-DmBOxk43.cjs} +1 -1
- package/dist/{header-BFk1an4z.cjs → header-Dd8_GxXA.cjs} +1 -1
- package/dist/{header-Deg_LGJo.js → header-iug8KwEF.js} +12 -12
- package/dist/{header-menu-GFtJKM4j.js → header-menu-CcXQsag0.js} +5 -5
- package/dist/{header-menu-BHqK4QA6.cjs → header-menu-DEMDRByb.cjs} +1 -1
- package/dist/{heading-DyJpBFT2.cjs → heading-DbLmrGyU.cjs} +1 -1
- package/dist/{heading-CD0PhL8g.js → heading-V-gyod7_.js} +2 -2
- package/dist/{helptext-C_brWCIT.js → helptext-BFGNgeqw.js} +8 -5
- package/dist/{helptext-Cq5rNaAC.cjs → helptext-CpaW9Zwl.cjs} +4 -1
- package/dist/{icon-DGFEIlco.js → icon-8ZKcRaGi.js} +1 -1
- package/dist/{icon-B8PVq2O6.cjs → icon-BlJZpl2L.cjs} +1 -1
- package/dist/{if-defined-D0bnetLJ.js → if-defined-DfH9X3nd.js} +1 -1
- package/dist/if-defined-h7sbeYue.cjs +1 -0
- package/dist/{input-element-B0qLbEdF.cjs → input-element-CmFzbxiZ.cjs} +1 -1
- package/dist/{input-element-C0RnXi-J.js → input-element-DPXwOJeT.js} +147 -123
- package/dist/input-wrapper-CohL8Onb.cjs +54 -0
- package/dist/input-wrapper-CrJMQj_L.js +122 -0
- package/dist/{input-wrapper-BweP6t3O.js → input-wrapper-D-fPaTbY.js} +2 -2
- package/dist/{input-wrapper-wh3fWIhk.cjs → input-wrapper-D5PR0rJn.cjs} +1 -1
- package/dist/{link-Geze7498.cjs → link-BQXhsaBM.cjs} +1 -1
- package/dist/{link-FmkQvSQL.js → link-C-0YV0XX.js} +4 -4
- package/dist/{linkcard-6LCXRTR-.cjs → linkcard-BN34yjcT.cjs} +1 -1
- package/dist/{linkcard-BKdT0zU_.js → linkcard-DGHxt0ef.js} +4 -4
- package/dist/{listbox-LdyWPu7W.js → listbox-CMLqAc5-.js} +4 -4
- package/dist/{listbox-89wMuQVK.cjs → listbox-CgjhUALC.cjs} +1 -1
- package/dist/{loader-BA-i8CaQ.js → loader-CxcWuAB7.js} +4 -4
- package/dist/{loader-CgW4Vst3.cjs → loader-DFWbjQV5.cjs} +1 -1
- package/dist/{messagebox-VD5oEZ19.cjs → messagebox-D0kz1ic4.cjs} +1 -1
- package/dist/{messagebox-fiaAyHLG.js → messagebox-DvlF8XbD.js} +4 -4
- package/dist/{modal-CPnFteYS.cjs → modal-BQcORqnQ.cjs} +1 -1
- package/dist/{modal-xNK_wpHk.js → modal-C9pamgry.js} +5 -5
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +34 -34
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-CPrfqepu.cjs → pkt-options-controller-DeyC9FDP.cjs} +1 -1
- package/dist/{pkt-options-controller-DMxYwnnj.js → pkt-options-controller-sblvLBnq.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-mtjtbpCO.js → progressbar-DtmVoP1j.js} +4 -4
- package/dist/{progressbar-BN5y20CC.cjs → progressbar-fnJJsQkh.cjs} +1 -1
- package/dist/{radiobutton-DjWBoSHv.cjs → radiobutton-CGT4kJSf.cjs} +1 -1
- package/dist/{radiobutton-C6htwDrT.js → radiobutton-DZHVyjoe.js} +4 -4
- package/dist/{ref-DO7TzO4O.cjs → ref-CYXJQuCZ.cjs} +1 -1
- package/dist/{ref-WGS0u7i2.js → ref-CkGzlsAX.js} +2 -2
- package/dist/{repeat-DRnLAg0O.cjs → repeat-C_7HwdFQ.cjs} +1 -1
- package/dist/{repeat-BH0cL82q.js → repeat-CwZAKBjZ.js} +2 -2
- package/dist/{searchinput-DGjeN1YI.cjs → searchinput-1CESdZO9.cjs} +1 -1
- package/dist/{searchinput-CfUVfpqL.js → searchinput-Dw1LAHgD.js} +4 -4
- package/dist/{select-CsBXXbLP.js → select-Cb8RH7lk.js} +24 -20
- package/dist/select-Duav6lVT.cjs +49 -0
- package/dist/shared-types/booleanish.d.ts +11 -0
- package/dist/shared-types/index.d.ts +1 -1
- package/dist/shared-utils/forms/described-by.d.ts +24 -0
- package/dist/{tabs-q62MK_-r.cjs → tabs-A665GUTo.cjs} +1 -1
- package/dist/{tabs-BqrKLCjd.js → tabs-BV4w4QfM.js} +4 -4
- package/dist/{tag-XE-VRxT2.cjs → tag-DaRo48qb.cjs} +1 -1
- package/dist/{tag-BTiTXyf5.js → tag-rb23IBFT.js} +5 -5
- package/dist/textarea-bLTy-JGg.cjs +49 -0
- package/dist/{textarea-Cm392CEI.js → textarea-nyH0_IkD.js} +35 -28
- package/dist/{textinput-TSPcBcih.js → textinput-B5Gk13OB.js} +30 -25
- package/dist/{textinput-DqJbTglM.cjs → textinput-D3bL7BTc.cjs} +10 -10
- package/dist/{timepicker-DWbgTDKq.js → timepicker-BH9yjtLA.js} +18 -11
- package/dist/{timepicker-CqFYMV8q.cjs → timepicker-lv-CQ8of.cjs} +5 -2
- package/dist/translations/no.json.d.ts +2 -1
- package/package.json +2 -2
- package/src/components/combobox/combobox.core.test.ts +2 -2
- package/src/components/combobox/combobox.selection.test.ts +18 -0
- package/src/components/combobox/combobox.ts +11 -5
- package/src/components/datepicker/datepicker-single.ts +1 -1
- package/src/components/datepicker/datepicker.ts +5 -3
- package/src/components/fileupload/fileupload.ts +6 -1
- package/src/components/helptext/helptext.ts +3 -0
- package/src/components/input-wrapper/input-wrapper.test.ts +3 -3
- package/src/components/input-wrapper/input-wrapper.ts +31 -29
- package/src/components/input-wrapper/tri-state.test.ts +91 -0
- package/src/components/input-wrapper/wrapper-parity.test.ts +141 -0
- package/src/components/select/select.test.ts +8 -7
- package/src/components/select/select.ts +13 -5
- package/src/components/textarea/textarea.test.ts +6 -6
- package/src/components/textarea/textarea.ts +20 -11
- package/src/components/textinput/textinput.test.ts +6 -6
- package/src/components/textinput/textinput.ts +17 -11
- package/src/components/timepicker/timepicker.ts +12 -5
- package/dist/booleanish-B9Kf0nES.cjs +0 -1
- package/dist/combobox-IBOASGmG.cjs +0 -136
- package/dist/if-defined-DrwbxQOj.cjs +0 -1
- package/dist/input-wrapper-DPkkiG7S.cjs +0 -57
- package/dist/input-wrapper-fWV5P4MN.js +0 -126
- package/dist/select-CZvAW7W2.cjs +0 -50
- package/dist/textarea-sTcZxOIB.cjs +0 -47
|
@@ -10,8 +10,9 @@ import { slotContent } from '@/directives/slot-content'
|
|
|
10
10
|
import '@/components/input-wrapper'
|
|
11
11
|
import '@/components/icon'
|
|
12
12
|
import { ElementProps } from '@/types/typeUtils'
|
|
13
|
+
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
13
14
|
|
|
14
|
-
type Props = ElementProps<PktTextarea, 'autocomplete' | 'rows'>
|
|
15
|
+
type Props = ElementProps<PktTextarea, 'autocomplete' | 'rows' | 'cols'>
|
|
15
16
|
|
|
16
17
|
export class PktTextarea extends PktInputElement<Props> {
|
|
17
18
|
inputRef: Ref<HTMLTextAreaElement> = createRef()
|
|
@@ -19,11 +20,11 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
19
20
|
@property({ type: String, reflect: true }) value: string = ''
|
|
20
21
|
@property({ type: String }) autocomplete: string = 'off'
|
|
21
22
|
@property({ type: Number }) rows: number | null = null
|
|
23
|
+
@property({ type: Number }) cols: number | null = null
|
|
22
24
|
|
|
23
25
|
@state() counterCurrent = 0
|
|
24
26
|
|
|
25
27
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
26
|
-
// Only sync the counter here.
|
|
27
28
|
if (name === 'value' && this.value !== _old) {
|
|
28
29
|
this.counterCurrent = value ? value.length : 0
|
|
29
30
|
}
|
|
@@ -32,6 +33,7 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
32
33
|
|
|
33
34
|
updated(changedProperties: PropertyValues) {
|
|
34
35
|
super.updated(changedProperties)
|
|
36
|
+
this.classList.add('pkt-textinput', 'pkt-textarea')
|
|
35
37
|
if (changedProperties.has('value')) {
|
|
36
38
|
this.counterCurrent = this.value?.length || 0
|
|
37
39
|
this.valueChanged(this.value, changedProperties.get('value'))
|
|
@@ -42,21 +44,20 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
render() {
|
|
47
|
+
const showCounter = this.effectiveCounter(this.counterMaxLength > 0)
|
|
45
48
|
const inputClasses = classMap({
|
|
46
49
|
'pkt-input': true,
|
|
47
50
|
[`pkt-input--${this.inputSize}`]: true,
|
|
48
51
|
'pkt-input--fullwidth': this.fullwidth,
|
|
49
52
|
'pkt-input--counter-error':
|
|
50
|
-
this.
|
|
51
|
-
this.counterMaxLength &&
|
|
52
|
-
this.value.length &&
|
|
53
|
-
this.value.length > this.counterMaxLength,
|
|
53
|
+
showCounter && this.counterMaxLength > 0 && this.value.length > this.counterMaxLength,
|
|
54
54
|
})
|
|
55
55
|
const labelledBy = this.ariaLabelledby || `${this.id}-input-label`
|
|
56
56
|
|
|
57
57
|
return html`<pkt-input-wrapper
|
|
58
58
|
label=${this.label}
|
|
59
|
-
?counter=${
|
|
59
|
+
?counter=${showCounter}
|
|
60
|
+
?hasFieldset=${this.effectiveHasFieldset(false)}
|
|
60
61
|
?disabled=${this.disabled}
|
|
61
62
|
?hasError=${this.hasError}
|
|
62
63
|
?inline=${this.inline}
|
|
@@ -64,8 +65,8 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
64
65
|
?required=${this.required}
|
|
65
66
|
?requiredTag=${this.requiredTag}
|
|
66
67
|
useWrapper=${this.useWrapper}
|
|
67
|
-
.
|
|
68
|
-
.counterCurrent=${this.
|
|
68
|
+
.ariaDescribedby=${this.ariaDescribedby}
|
|
69
|
+
.counterCurrent=${this.value?.length ?? 0}
|
|
69
70
|
.counterMaxLength=${this.counterMaxLength}
|
|
70
71
|
.errorMessage=${this.errorMessage}
|
|
71
72
|
.forId="${this.id + '-input'}"
|
|
@@ -76,7 +77,6 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
76
77
|
.requiredText=${this.requiredText}
|
|
77
78
|
.tagText=${this.tagText}
|
|
78
79
|
.size=${this.inputSize}
|
|
79
|
-
class="pkt-textarea"
|
|
80
80
|
>
|
|
81
81
|
<div class="pkt-contents" slot="helptext">${slotContent(this, 'helptext')}</div>
|
|
82
82
|
<textarea
|
|
@@ -92,8 +92,17 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
92
92
|
autocomplete=${this.autocomplete}
|
|
93
93
|
aria-labelledby=${labelledBy}
|
|
94
94
|
aria-invalid=${this.hasError}
|
|
95
|
-
aria-errormessage=${`${this.id}-error`}
|
|
95
|
+
aria-errormessage=${ifDefined(this.hasError ? `${this.id}-input-error` : undefined)}
|
|
96
|
+
aria-describedby=${ifDefined(
|
|
97
|
+
describedByIds({
|
|
98
|
+
id: this.id + '-input',
|
|
99
|
+
hasHelptext: !!this.helptext,
|
|
100
|
+
hasCounter: showCounter,
|
|
101
|
+
ariaDescribedby: this.ariaDescribedby,
|
|
102
|
+
}),
|
|
103
|
+
)}
|
|
96
104
|
rows=${ifDefined(this.rows ?? undefined)}
|
|
105
|
+
cols=${ifDefined(this.cols ?? undefined)}
|
|
97
106
|
?disabled=${this.disabled}
|
|
98
107
|
@input=${(e: InputEvent) => {
|
|
99
108
|
this.value = (e.target as HTMLInputElement).value
|
|
@@ -33,8 +33,8 @@ export interface TextinputTestConfig extends BaseTestConfig {
|
|
|
33
33
|
fullwidth?: boolean
|
|
34
34
|
counter?: boolean
|
|
35
35
|
inline?: boolean
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
'aria-labelledby'?: string | null
|
|
37
|
+
'aria-describedby'?: string | null
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Use shared framework
|
|
@@ -387,15 +387,15 @@ describe('PktTextinput', () => {
|
|
|
387
387
|
describe('Accessibility', () => {
|
|
388
388
|
test('passes through accessibility attributes', async () => {
|
|
389
389
|
const { textinput } = await createTextinputTest({
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
'aria-labelledby': 'external-label',
|
|
391
|
+
'aria-describedby': 'external-description',
|
|
392
392
|
})
|
|
393
393
|
|
|
394
394
|
const inputElement = textinput.querySelector('input')
|
|
395
395
|
expect(inputElement?.getAttribute('aria-labelledby')).toBe('external-label')
|
|
396
396
|
|
|
397
|
-
//
|
|
398
|
-
expect(textinput.
|
|
397
|
+
// ariaDescribedby videresendes som property til input-wrapper
|
|
398
|
+
expect(textinput.ariaDescribedby).toBe('external-description')
|
|
399
399
|
})
|
|
400
400
|
|
|
401
401
|
test('textinput is accessible', async () => {
|
|
@@ -9,6 +9,7 @@ import { slotContent } from '@/directives/slot-content'
|
|
|
9
9
|
|
|
10
10
|
import '@/components/input-wrapper'
|
|
11
11
|
import '@/components/icon'
|
|
12
|
+
import { describedByIds } from 'shared-utils/forms/described-by'
|
|
12
13
|
|
|
13
14
|
type Props = ElementProps<
|
|
14
15
|
PktTextinput,
|
|
@@ -37,7 +38,6 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
37
38
|
@state() counterCurrent = 0
|
|
38
39
|
|
|
39
40
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
40
|
-
// Only sync the counter here.
|
|
41
41
|
if (name === 'value' && this.value !== _old) {
|
|
42
42
|
this.counterCurrent = value ? value.length : 0
|
|
43
43
|
}
|
|
@@ -46,6 +46,7 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
46
46
|
|
|
47
47
|
updated(changedProperties: PropertyValues) {
|
|
48
48
|
super.updated(changedProperties)
|
|
49
|
+
this.classList.add('pkt-textinput')
|
|
49
50
|
if (changedProperties.has('value')) {
|
|
50
51
|
this.counterCurrent = this.value?.length || 0
|
|
51
52
|
this.valueChanged(this.value, changedProperties.get('value'))
|
|
@@ -58,32 +59,30 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
58
59
|
render() {
|
|
59
60
|
const shouldShowSearchIcon =
|
|
60
61
|
this.type === 'search' && !this.iconNameRight && !this.omitSearchIcon
|
|
62
|
+
const showCounter = this.effectiveCounter(this.counterMaxLength > 0)
|
|
61
63
|
const inputClasses = classMap({
|
|
62
64
|
'pkt-input': true,
|
|
63
65
|
[`pkt-input--${this.inputSize}`]: true,
|
|
64
66
|
'pkt-input--fullwidth': this.fullwidth,
|
|
65
67
|
'pkt-input--counter-error':
|
|
66
|
-
this.
|
|
67
|
-
this.counterMaxLength &&
|
|
68
|
-
this.value.length &&
|
|
69
|
-
this.value.length > this.counterMaxLength,
|
|
68
|
+
showCounter && this.counterMaxLength > 0 && this.value.length > this.counterMaxLength,
|
|
70
69
|
})
|
|
71
70
|
const labelledBy = this.ariaLabelledby || `${this.id}-input-label`
|
|
72
71
|
|
|
73
72
|
return html`
|
|
74
73
|
<pkt-input-wrapper
|
|
75
74
|
label="${this.label}"
|
|
76
|
-
?counter=${
|
|
75
|
+
?counter=${showCounter}
|
|
76
|
+
?hasFieldset=${this.effectiveHasFieldset(false)}
|
|
77
77
|
?disabled=${this.disabled}
|
|
78
78
|
?hasError=${this.hasError}
|
|
79
|
-
?hasFieldset=${this.hasFieldset}
|
|
80
79
|
?inline=${this.inline}
|
|
81
80
|
?optionalTag=${this.optionalTag}
|
|
82
81
|
?required=${this.required}
|
|
83
82
|
?requiredTag=${this.requiredTag}
|
|
84
83
|
useWrapper=${this.useWrapper}
|
|
85
|
-
.
|
|
86
|
-
.counterCurrent=${this.
|
|
84
|
+
.ariaDescribedby=${this.ariaDescribedby}
|
|
85
|
+
.counterCurrent=${this.value?.length ?? 0}
|
|
87
86
|
.counterMaxLength=${this.counterMaxLength}
|
|
88
87
|
.errorMessage=${this.errorMessage}
|
|
89
88
|
.forId="${this.id + '-input'}"
|
|
@@ -94,7 +93,6 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
94
93
|
.requiredText=${this.requiredText}
|
|
95
94
|
.tagText=${this.tagText}
|
|
96
95
|
.size=${this.inputSize}
|
|
97
|
-
class="pkt-textinput"
|
|
98
96
|
>
|
|
99
97
|
<div class="pkt-contents" slot="helptext">${slotContent(this, 'helptext')}</div>
|
|
100
98
|
<div class=${`pkt-input__container pkt-input__container--${this.inputSize}`}>
|
|
@@ -118,7 +116,15 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
118
116
|
.value=${this.value}
|
|
119
117
|
?disabled=${this.disabled}
|
|
120
118
|
aria-invalid=${this.hasError}
|
|
121
|
-
aria-errormessage=${`${this.id}-error`}
|
|
119
|
+
aria-errormessage=${ifDefined(this.hasError ? `${this.id}-input-error` : undefined)}
|
|
120
|
+
aria-describedby=${ifDefined(
|
|
121
|
+
describedByIds({
|
|
122
|
+
id: this.id + '-input',
|
|
123
|
+
hasHelptext: !!this.helptext,
|
|
124
|
+
hasCounter: showCounter,
|
|
125
|
+
ariaDescribedby: this.ariaDescribedby,
|
|
126
|
+
}),
|
|
127
|
+
)}
|
|
122
128
|
@input=${(e: InputEvent) => {
|
|
123
129
|
this.value = (e.target as HTMLInputElement).value
|
|
124
130
|
this.onInput()
|
|
@@ -151,6 +151,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
151
151
|
hours?.setAttribute('aria-invalid', 'true')
|
|
152
152
|
minutes?.setAttribute('aria-invalid', 'true')
|
|
153
153
|
} else {
|
|
154
|
+
if (this.hasError) return
|
|
154
155
|
hours?.removeAttribute('aria-invalid')
|
|
155
156
|
minutes?.removeAttribute('aria-invalid')
|
|
156
157
|
}
|
|
@@ -199,13 +200,13 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
199
200
|
|
|
200
201
|
protected updated(changedProperties: PropertyValues): void {
|
|
201
202
|
super.updated(changedProperties)
|
|
203
|
+
this.classList.add('pkt-timepicker')
|
|
202
204
|
this.classList.toggle('pkt-timepicker--stepper', this.stepArrows)
|
|
203
205
|
this.classList.toggle('pkt-timepicker--fullwidth', this.fullwidth)
|
|
204
206
|
this.classList.toggle('pkt-timepicker--medium', this.inputSize === 'medium')
|
|
205
207
|
this.classList.toggle('pkt-timepicker--small', this.inputSize === 'small')
|
|
206
208
|
this.classList.toggle('pkt-timepicker--xsmall', this.inputSize === 'xsmall')
|
|
207
209
|
if (changedProperties.has('step') && this.step !== null && !this._isValidStep(this.step)) {
|
|
208
|
-
// eslint-disable-next-line no-console
|
|
209
210
|
console.warn(
|
|
210
211
|
`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`,
|
|
211
212
|
)
|
|
@@ -627,7 +628,8 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
627
628
|
${this.stepArrows
|
|
628
629
|
? html`
|
|
629
630
|
<button
|
|
630
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
631
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
632
|
+
.inputSize} pkt-timepicker__button pkt-timepicker__button--prev"
|
|
631
633
|
type="button"
|
|
632
634
|
aria-label=${this.strings.timepicker?.prevTime ?? 'Forrige tidspunkt'}
|
|
633
635
|
?disabled=${this.disabled}
|
|
@@ -655,6 +657,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
655
657
|
aria-label=${hoursAriaLabel}
|
|
656
658
|
role="spinbutton"
|
|
657
659
|
aria-invalid=${this.hasError ? 'true' : nothing}
|
|
660
|
+
aria-errormessage=${this.hasError ? `${this.id}-hours-error` : nothing}
|
|
658
661
|
aria-valuemin="0"
|
|
659
662
|
aria-valuemax="23"
|
|
660
663
|
aria-valuenow=${this._hours !== '' ? this._hours : nothing}
|
|
@@ -686,6 +689,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
686
689
|
aria-label=${minutesAriaLabel}
|
|
687
690
|
role="spinbutton"
|
|
688
691
|
aria-invalid=${this.hasError ? 'true' : nothing}
|
|
692
|
+
aria-errormessage=${this.hasError ? `${this.id}-hours-error` : nothing}
|
|
689
693
|
aria-valuemin="0"
|
|
690
694
|
aria-valuemax="59"
|
|
691
695
|
aria-valuenow=${this._minutes !== '' ? this._minutes : nothing}
|
|
@@ -712,7 +716,8 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
712
716
|
? html`
|
|
713
717
|
<button
|
|
714
718
|
${ref(this.buttonRef)}
|
|
715
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
719
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
720
|
+
.inputSize} pkt-timepicker__button"
|
|
716
721
|
type="button"
|
|
717
722
|
aria-label=${this.strings.timepicker?.openPicker ?? 'Åpne tidspunkt-velger'}
|
|
718
723
|
aria-haspopup="listbox"
|
|
@@ -731,7 +736,8 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
731
736
|
${this.stepArrows
|
|
732
737
|
? html`
|
|
733
738
|
<button
|
|
734
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
739
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this
|
|
740
|
+
.inputSize} pkt-timepicker__button pkt-timepicker__button--next"
|
|
735
741
|
type="button"
|
|
736
742
|
aria-label=${this.strings.timepicker?.nextTime ?? 'Neste tidspunkt'}
|
|
737
743
|
?disabled=${this.disabled}
|
|
@@ -769,12 +775,13 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
769
775
|
?disabled=${this.disabled}
|
|
770
776
|
?fullwidth=${this.fullwidth}
|
|
771
777
|
?hasError=${this.hasError}
|
|
778
|
+
?hasFieldset=${this.effectiveHasFieldset(false)}
|
|
772
779
|
?inline=${this.inline}
|
|
773
780
|
?optionalTag=${this.optionalTag}
|
|
774
781
|
?required=${this.required}
|
|
775
782
|
?requiredTag=${this.requiredTag}
|
|
776
783
|
useWrapper=${this.useWrapper}
|
|
777
|
-
.
|
|
784
|
+
.ariaDescribedby=${this.ariaDescribedby}
|
|
778
785
|
.errorMessage=${this.errorMessage}
|
|
779
786
|
.forId="${this.id + '-hours'}"
|
|
780
787
|
.helptext=${this.helptext}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e={fromAttribute(e){return e==null?!1:e===``||e===`true`||e===!0?!0:e===`false`||e===!1?!1:!!e},toAttribute(e){return e?`true`:`false`}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs"),n=require("./element-with-slot-BY7Jc-q8.cjs");require("./icon-B8PVq2O6.cjs");const r=require("./if-defined-DrwbxQOj.cjs"),i=require("./ref-DO7TzO4O.cjs");require("./tag-XE-VRxT2.cjs");const a=require("./repeat-DRnLAg0O.cjs"),o=require("./listbox-89wMuQVK.cjs"),s=require("./input-element-B0qLbEdF.cjs"),c=require("./pkt-options-controller-CPrfqepu.cjs");require("./input-wrapper-DPkkiG7S.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`}},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.o({type:String,reflect:!0})],_.prototype,`value`,void 0),e.n([e.o({type:Array})],_.prototype,`options`,void 0),e.n([e.o({type:Array,attribute:`default-options`})],_.prototype,`defaultOptions`,void 0),e.n([e.o({type:Boolean,attribute:`allow-user-input`})],_.prototype,`allowUserInput`,void 0),e.n([e.o({type:Boolean})],_.prototype,`typeahead`,void 0),e.n([e.o({type:Boolean,attribute:`include-search`})],_.prototype,`includeSearch`,void 0),e.n([e.o({type:String,attribute:`search-placeholder`})],_.prototype,`searchPlaceholder`,void 0),e.n([e.o({type:Boolean})],_.prototype,`multiple`,void 0),e.n([e.o({type:Number})],_.prototype,`maxlength`,void 0),e.n([e.o({type:String,attribute:`display-value-as`})],_.prototype,`displayValueAs`,void 0),e.n([e.o({type:String,attribute:`tag-placement`})],_.prototype,`tagPlacement`,void 0),e.n([e.o({type:Boolean,attribute:`open`})],_.prototype,`isOpen`,void 0),e.n([e.a()],_.prototype,`_options`,void 0),e.n([e.a()],_.prototype,`_value`,void 0),e.n([e.a()],_.prototype,`_isOptionsOpen`,void 0),e.n([e.a()],_.prototype,`_userInfoMessage`,void 0),e.n([e.a()],_.prototype,`_addValueText`,void 0),e.n([e.a()],_.prototype,`_maxIsReached`,void 0),e.n([e.a()],_.prototype,`_search`,void 0),e.n([e.a()],_.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=`Ny verdi lagt til`,u=c):!r&&!this.allowUserInput?(s&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`Ingen treff i søket`):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=`Maks antall valg nådd`,d=!1,p=e):(s&&this.removeAllSelected(),f=`Ingen gyldig verdi valgt`,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=`Maks antall valg nådd`;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=`For mange valgt`;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=`Verdien er allerede valgt`;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);break}}!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]));break}}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;break}}}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();break}}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.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this._value[0]?f(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}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.p`
|
|
2
|
-
<pkt-input-wrapper
|
|
3
|
-
.size=${this.inputSize}
|
|
4
|
-
.label=${this.label}
|
|
5
|
-
.helptext=${this.helptext}
|
|
6
|
-
.helptextDropdown=${r.t(this.helptextDropdown)}
|
|
7
|
-
.helptextDropdownButton=${r.t(this.helptextDropdownButton)}
|
|
8
|
-
?fullwidth=${this.fullwidth}
|
|
9
|
-
?hasError=${this.hasError}
|
|
10
|
-
?inline=${this.inline}
|
|
11
|
-
?disabled=${this.disabled}
|
|
12
|
-
.errorMessage=${this.errorMessage}
|
|
13
|
-
?optionalTag=${this.optionalTag}
|
|
14
|
-
.optionalText=${this.optionalText}
|
|
15
|
-
?requiredTag=${this.requiredTag}
|
|
16
|
-
.requiredText=${this.requiredText}
|
|
17
|
-
.tagText=${this.tagText}
|
|
18
|
-
useWrapper=${this.useWrapper}
|
|
19
|
-
.forId=${this._hasTextInput?this.id+`-input`:this.id+`-combobox`}
|
|
20
|
-
?hasFieldset=${!this._hasTextInput}
|
|
21
|
-
class="pkt-combobox__wrapper"
|
|
22
|
-
@labelClick=${this.handleInputClick}
|
|
23
|
-
>
|
|
24
|
-
<div class="pkt-contents" slot="helptext">${n.n(this,`helptext`)}</div>
|
|
25
|
-
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
26
|
-
<div
|
|
27
|
-
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})}
|
|
28
|
-
id=${r.t(this._hasTextInput?void 0:`${this.id}-combobox`)}
|
|
29
|
-
role=${r.t(this._hasTextInput?void 0:`combobox`)}
|
|
30
|
-
aria-expanded=${r.t(this._hasTextInput?void 0:this._isOptionsOpen?`true`:`false`)}
|
|
31
|
-
aria-controls=${r.t(this._hasTextInput?void 0:`${this.id}-listbox`)}
|
|
32
|
-
aria-haspopup=${r.t(this._hasTextInput?void 0:`listbox`)}
|
|
33
|
-
aria-labelledby=${r.t(this._hasTextInput?void 0:`${this.id}-combobox-label`)}
|
|
34
|
-
aria-activedescendant=${r.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)}
|
|
35
|
-
aria-description=${r.t(this._selectionDescription||void 0)}
|
|
36
|
-
tabindex=${this._hasTextInput||this.disabled?`-1`:`0`}
|
|
37
|
-
@click=${this.handleInputClick}
|
|
38
|
-
@keydown=${this._hasTextInput?e.d:this.handleSelectOnlyKeydown}
|
|
39
|
-
${i.n(this.triggerRef)}
|
|
40
|
-
>
|
|
41
|
-
${!this._hasTextInput&&this.placeholder&&(!this._value.length||this.multiple&&this.tagPlacement==`outside`)&&!this._inputFocus?e.p`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
|
|
42
|
-
>${this.placeholder}</span
|
|
43
|
-
>`:this.tagPlacement===`outside`?e.d:this.renderSingleOrMultipleValues()}
|
|
44
|
-
${this.renderInputField()}
|
|
45
|
-
<pkt-icon
|
|
46
|
-
class=${t.t({"pkt-combobox__arrow-icon":!0,"pkt-combobox__arrow-icon--open":this._isOptionsOpen})}
|
|
47
|
-
name="chevron-thin-down"
|
|
48
|
-
aria-hidden="true"
|
|
49
|
-
></pkt-icon>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<pkt-listbox
|
|
53
|
-
id="${this.id}-listbox"
|
|
54
|
-
.options=${this._options}
|
|
55
|
-
.isOpen=${this._isOptionsOpen}
|
|
56
|
-
.searchPlaceholder=${this.searchPlaceholder}
|
|
57
|
-
.label="Liste: ${this.label||``}"
|
|
58
|
-
?include-search=${this.includeSearch}
|
|
59
|
-
?is-multi-select=${this.multiple}
|
|
60
|
-
?allow-user-input=${this.allowUserInput&&!this._maxIsReached}
|
|
61
|
-
?max-is-reached=${this._maxIsReached}
|
|
62
|
-
.customUserInput=${r.t(this._addValueText)}
|
|
63
|
-
.userMessage=${this._userInfoMessage}
|
|
64
|
-
@search=${this.handleSearch}
|
|
65
|
-
@option-toggle=${this.handleOptionToggled}
|
|
66
|
-
@select-all=${this.addAllOptions}
|
|
67
|
-
@close-options=${()=>this._isOptionsOpen=!1}
|
|
68
|
-
@tab-close=${()=>this.closeAndProcessInput()}
|
|
69
|
-
.searchValue=${this._search||null}
|
|
70
|
-
.maxLength=${this.maxlength||0}
|
|
71
|
-
${i.n(this.listboxRef)}
|
|
72
|
-
></pkt-listbox>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
${this.tagPlacement===`outside`&&this.multiple?e.p`<div class="pkt-combobox__tags-outside">
|
|
76
|
-
${this.renderSingleOrMultipleValues()}
|
|
77
|
-
</div>`:e.d}
|
|
78
|
-
</pkt-input-wrapper>
|
|
79
|
-
`}renderInputField(){return this.typeahead||this.allowUserInput?e.p`
|
|
80
|
-
<div class="pkt-combobox__input-div combobox__input">
|
|
81
|
-
<input
|
|
82
|
-
type="text"
|
|
83
|
-
id="${this.id}-input"
|
|
84
|
-
name=${(this.name||this.id)+`-input`}
|
|
85
|
-
placeholder=${r.t(!this._value.length||this.multiple&&this.tagPlacement===`outside`?this.placeholder:void 0)}
|
|
86
|
-
@input=${this.handleInput}
|
|
87
|
-
@change=${e=>{e.stopPropagation(),e.stopImmediatePropagation()}}
|
|
88
|
-
@keydown=${this.handleInputKeydown}
|
|
89
|
-
@focus=${this.handleFocus}
|
|
90
|
-
@blur=${this.handleBlur}
|
|
91
|
-
autocomplete="off"
|
|
92
|
-
role="combobox"
|
|
93
|
-
aria-expanded=${this._isOptionsOpen?`true`:`false`}
|
|
94
|
-
aria-label=${r.t(this.label)}
|
|
95
|
-
aria-autocomplete=${this.typeahead?`both`:this.allowUserInput?`list`:`none`}
|
|
96
|
-
aria-controls="${this.id}-listbox"
|
|
97
|
-
aria-activedescendant=${r.t(this._value[0]&&o.i(this.options,this._value[0])?`${this.id}-listbox-${o.a(this._options,this._value[0])}`:void 0)}
|
|
98
|
-
aria-description=${r.t(this._selectionDescription||void 0)}
|
|
99
|
-
${i.n(this.inputRef)}
|
|
100
|
-
/>
|
|
101
|
-
</div>
|
|
102
|
-
`:e.p`
|
|
103
|
-
<input
|
|
104
|
-
type="hidden"
|
|
105
|
-
id="${this.id}-input"
|
|
106
|
-
name=${(this.name||this.id)+`-input`}
|
|
107
|
-
.value=${this._value.join(`,`)}
|
|
108
|
-
${i.n(this.inputRef)}
|
|
109
|
-
/>
|
|
110
|
-
`}renderSingleOrMultipleValues(){if(!this.multiple&&this._hasTextInput)return e.d;let t=!this.multiple,n=this.renderValueTag(o.i(this.options,this._value[0])),r=this.tagPlacement===`outside`,i=e.p`
|
|
111
|
-
<ul role="list" class="pkt-combobox__tag-list">
|
|
112
|
-
${a.t(this._value,e=>e,(t,n)=>{let i=o.i(this.options,t),a=i?.tagSkinColor;return e.p`
|
|
113
|
-
<li
|
|
114
|
-
role="listitem"
|
|
115
|
-
@click=${r?e.d:e=>e.stopPropagation()}
|
|
116
|
-
@mousedown=${r?e.d:e=>e.preventDefault()}
|
|
117
|
-
>
|
|
118
|
-
<pkt-tag
|
|
119
|
-
skin=${a||`blue-dark`}
|
|
120
|
-
?closeTag=${!this.disabled}
|
|
121
|
-
.buttonTabindex=${r?void 0:-1}
|
|
122
|
-
@close=${()=>this.handleTagRemove(t)}
|
|
123
|
-
@keydown=${r?e.d:e=>this.handleTagKeydown(e,n)}
|
|
124
|
-
>
|
|
125
|
-
${this.renderValueTag(i)}
|
|
126
|
-
</pkt-tag>
|
|
127
|
-
</li>
|
|
128
|
-
`})}
|
|
129
|
-
</ul>
|
|
130
|
-
`;return t?n:i}renderValueTag(t){if(!t)return``;switch(this.displayValueAs){case`prefixAndValue`:return e.p`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
131
|
-
>${t.prefix||``} ${t.value}</span
|
|
132
|
-
>`;case`value`:return e.p`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
133
|
-
>${t.value}</span
|
|
134
|
-
>`;default:return e.p`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
135
|
-
>${t.label||t.value}</span
|
|
136
|
-
>`}}};try{e.s(`pkt-combobox`)(b)}catch{console.warn(`Forsøker å definere <pkt-combobox>, men den er allerede definert`)}var x=b;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DJzurxgt.cjs");var t=t=>t??e.d;Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs"),n=require("./element-with-slot-BY7Jc-q8.cjs");require("./alert-CkUnbPdA.cjs");const r=require("./icon-B8PVq2O6.cjs"),i=require("./if-defined-DrwbxQOj.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./booleanish-B9Kf0nES.cjs"),s=require("./input-wrapper-wh3fWIhk.cjs");require("./helptext-Cq5rNaAC.cjs");const c=require("./focus-modality-controller-C1ocyv2J.cjs");var l=class extends n.t{constructor(...e){super(...e),this.forId=a.n(),this.label=``,this.helptext=null,this.helptextDropdown=null,this.helptextDropdownButton=null,this.counter=s.t.props.counter.default,this.counterCurrent=0,this.counterMaxLength=0,this.counterError=null,this.counterPosition=`bottom`,this.optionalTag=s.t.props.optionalTag.default,this.optionalText=s.t.props.optionalText.default,this.requiredTag=s.t.props.requiredTag.default,this.requiredText=s.t.props.requiredText.default,this.tagText=null,this.hasError=s.t.props.hasError.default,this.errorMessage=``,this.disabled=s.t.props.disabled.default,this.inline=s.t.props.inline.default,this.ariaDescribedby=void 0,this.hasFieldset=s.t.props.hasFieldset.default,this.role=`group`,this.useWrapper=s.t.props.useWrapper.default,this.size=`medium`,this.focusModality=new c.t(this,`.pkt-inputwrapper`)}updated(e){super.updated(e)}render(){let a={"pkt-inputwrapper":!0,"pkt-inputwrapper--error":this.hasError,"pkt-inputwrapper--disabled":this.disabled,"pkt-inputwrapper--inline":this.inline,"pkt-inputwrapper--small":this.size===`small`,"pkt-inputwrapper--xsmall":this.size===`xsmall`},o=this.ariaDescribedby?this.ariaDescribedby:this.helptext?`${this.forId}-helptext`:e.d,c=()=>e.p`
|
|
2
|
-
${this.tagText?e.p`<span class=${`pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--gray`}>${this.tagText}</span>`:e.d}
|
|
3
|
-
${this.optionalTag?e.p`<span class=${`pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--blue-light`}>${this.optionalText}</span>`:e.d}
|
|
4
|
-
${this.requiredTag?e.p`<span class=${`pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--beige`}>${this.requiredText}</span>`:e.d}
|
|
5
|
-
`,l=()=>this.useWrapper?this.hasFieldset?e.p`<legend
|
|
6
|
-
class="pkt-inputwrapper__legend"
|
|
7
|
-
id="${this.forId}-label"
|
|
8
|
-
@click=${this.handleLabelClick}
|
|
9
|
-
>
|
|
10
|
-
${this.label} ${c()}
|
|
11
|
-
</legend>`:e.p`<label
|
|
12
|
-
class="pkt-inputwrapper__label"
|
|
13
|
-
for="${this.forId}"
|
|
14
|
-
aria-describedby="${o}"
|
|
15
|
-
id="${this.forId}-label"
|
|
16
|
-
@click=${this.handleLabelClick}
|
|
17
|
-
>${this.label}${c()}</label
|
|
18
|
-
>`:e.p`<label
|
|
19
|
-
for="${this.forId}"
|
|
20
|
-
class="pkt-sr-only"
|
|
21
|
-
aria-describedby="${o}"
|
|
22
|
-
id="${this.forId}-label"
|
|
23
|
-
>
|
|
24
|
-
${this.label}
|
|
25
|
-
</label>`,u=()=>e.p`
|
|
26
|
-
<pkt-helptext
|
|
27
|
-
class="${i.t(this.useWrapper?void 0:`pkt-hide`)}"
|
|
28
|
-
.forId=${this.forId}
|
|
29
|
-
.helptext=${this.helptext}
|
|
30
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
31
|
-
.helptextDropdownButton=${this.helptextDropdownButton||s.t.props.helptextDropdownButton.default}
|
|
32
|
-
@toggleHelpText=${e=>{this.toggleDropdown(e)}}
|
|
33
|
-
>${n.n(this,`helptext`)}</pkt-helptext
|
|
34
|
-
>
|
|
35
|
-
`,d=()=>this.counter?e.p`<div class="pkt-input__counter" aria-live="polite" aria-atomic="true">
|
|
36
|
-
${this.counterError?this.counterError:e.d} ${this.counterCurrent||0}
|
|
37
|
-
${this.counterMaxLength?`/${this.counterMaxLength}`:e.d}
|
|
38
|
-
</div>`:e.d,f=()=>this.hasError&&this.errorMessage?e.p`<div class="pkt-inputwrapper__alert-wrapper">
|
|
39
|
-
<pkt-alert
|
|
40
|
-
skin="error"
|
|
41
|
-
.size=${this.size===`medium`?`small`:`xsmall`}
|
|
42
|
-
id=${`${this.forId}-error`}
|
|
43
|
-
aria-live="assertive"
|
|
44
|
-
aria-atomic="true"
|
|
45
|
-
>
|
|
46
|
-
${r.r(this.errorMessage)}
|
|
47
|
-
</pkt-alert>
|
|
48
|
-
</div>`:e.d,p=()=>e.p`
|
|
49
|
-
${l()}
|
|
50
|
-
${u()}
|
|
51
|
-
${this.counterPosition===`top`?d():e.d}
|
|
52
|
-
<div class="pkt-contents">${n.n(this)}</div>
|
|
53
|
-
${this.counterPosition===`bottom`?d():e.d}
|
|
54
|
-
${f()}
|
|
55
|
-
`;return e.p`<div class=${t.t(a)}>${this.hasFieldset?e.p`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${o}">
|
|
56
|
-
${p()}
|
|
57
|
-
</fieldset>`:e.p`<div class="pkt-inputwrapper__fieldset">${p()}</div>`}</div> `}toggleDropdown(e){this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!1,detail:{isOpen:e.detail.isOpen}}))}handleLabelClick(){this.dispatchEvent(new CustomEvent(`labelClick`,{bubbles:!0,composed:!0,detail:`label clicked`}))}};e.n([e.o({type:String})],l.prototype,`forId`,void 0),e.n([e.o({type:String})],l.prototype,`label`,void 0),e.n([e.o({type:String})],l.prototype,`helptext`,void 0),e.n([e.o({type:String})],l.prototype,`helptextDropdown`,void 0),e.n([e.o({type:String})],l.prototype,`helptextDropdownButton`,void 0),e.n([e.o({type:Boolean})],l.prototype,`counter`,void 0),e.n([e.o({type:Number})],l.prototype,`counterCurrent`,void 0),e.n([e.o({type:Number})],l.prototype,`counterMaxLength`,void 0),e.n([e.o({type:String})],l.prototype,`counterError`,void 0),e.n([e.o({type:String,reflect:!1})],l.prototype,`counterPosition`,void 0),e.n([e.o({type:Boolean})],l.prototype,`optionalTag`,void 0),e.n([e.o({type:String})],l.prototype,`optionalText`,void 0),e.n([e.o({type:Boolean})],l.prototype,`requiredTag`,void 0),e.n([e.o({type:String})],l.prototype,`requiredText`,void 0),e.n([e.o({type:String})],l.prototype,`tagText`,void 0),e.n([e.o({type:Boolean})],l.prototype,`hasError`,void 0),e.n([e.o({type:String})],l.prototype,`errorMessage`,void 0),e.n([e.o({type:Boolean})],l.prototype,`disabled`,void 0),e.n([e.o({type:Boolean})],l.prototype,`inline`,void 0),e.n([e.o({type:String})],l.prototype,`ariaDescribedby`,void 0),e.n([e.o({type:Boolean})],l.prototype,`hasFieldset`,void 0),e.n([e.o({type:String,reflect:!0})],l.prototype,`role`,void 0),e.n([e.o({type:Boolean,reflect:!0,converter:o.t})],l.prototype,`useWrapper`,void 0),e.n([e.o({type:String,attribute:`input-wrapper-size`})],l.prototype,`size`,void 0);try{e.s(`pkt-input-wrapper`)(l)}catch{console.warn(`Forsøker å definere <pkt-input-wrapper>, men den er allerede definert`)}var u=l;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|