@oslokommune/punkt-elements 16.26.7 → 17.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/dist/accordion-CbXDxOho.cjs +47 -0
- package/dist/{accordion-CBdIk9gw.js → accordion-DEUHQ4JD.js} +45 -35
- package/dist/{alert-HHTGY0sp.js → alert-CbtVGrHD.js} +31 -17
- package/dist/{alert-B8dLsiTz.cjs → alert-CkUnbPdA.cjs} +5 -5
- package/dist/base-elements/input-element.d.ts +1 -0
- package/dist/button-Cod17rKo.js +115 -0
- package/dist/{button-B5tQpKeG.cjs → button-gvDXtBMC.cjs} +5 -2
- package/dist/{calendar-DIzGBdbh.cjs → calendar-BVXW8DqC.cjs} +1 -1
- package/dist/{calendar-CjlUA-Lb.js → calendar-CjC4qlh6.js} +1 -1
- package/dist/{checkbox-Bt_sC_90.cjs → checkbox-8uxbeU30.cjs} +1 -1
- package/dist/{checkbox-D03BC2Va.js → checkbox-DJDphhqz.js} +1 -1
- package/dist/{combobox-CoQBTWqL.js → combobox-Du5yr-xM.js} +16 -2
- package/dist/combobox-hKrbYLUe.cjs +136 -0
- package/dist/components/accordion/accordion-context.d.ts +7 -0
- package/dist/components/accordion/accordion.d.ts +2 -0
- package/dist/components/accordion/accordionitem.d.ts +1 -0
- package/dist/components/alert/alert.d.ts +5 -0
- package/dist/components/alert/alert.test.d.ts +1 -0
- package/dist/components/button/button.d.ts +4 -1
- package/dist/components/datepicker/datepicker-base.d.ts +2 -0
- package/dist/components/datepicker/datepicker-utils.d.ts +2 -2
- package/dist/components/footer/footer-base.d.ts +44 -0
- package/dist/components/footer/footer-simple.d.ts +20 -0
- package/dist/components/footer/footer.accessibility.test.d.ts +0 -0
- package/dist/components/footer/footer.d.ts +22 -0
- package/dist/components/footer/footer.test.d.ts +0 -0
- package/dist/components/footer/index.d.ts +3 -0
- package/dist/components/footer/types.d.ts +16 -0
- package/dist/components/header/header-chrome-controller.d.ts +44 -0
- package/dist/components/header/header-global.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-global.d.ts +78 -0
- package/dist/components/header/header-global.test.d.ts +0 -0
- package/dist/components/header/header-service.accessibility.test.d.ts +0 -0
- package/dist/components/header/header-service.d.ts +6 -21
- package/dist/components/header/header-service.test.d.ts +1 -1
- package/dist/components/header/header.d.ts +11 -3
- package/dist/components/header/header.test.d.ts +0 -0
- package/dist/components/header/index.d.ts +2 -1
- package/dist/components/header/types.d.ts +28 -2
- package/dist/components/header-menu/header-menu.d.ts +4 -5
- package/dist/components/header-menu/types.d.ts +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/input-wrapper/input-wrapper.d.ts +2 -0
- package/dist/components/input-wrapper/input-wrapper.test.d.ts +1 -0
- package/dist/components/searchinput/searchinput.d.ts +5 -0
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.test.d.ts +1 -0
- package/dist/components/textarea/textarea.test.d.ts +2 -0
- package/dist/components/textinput/textinput.test.d.ts +1 -0
- package/dist/components/timepicker/timepicker.d.ts +2 -0
- package/dist/components/timepicker/timepicker.test.d.ts +3 -0
- package/dist/consent--Nw43WFU.cjs +18 -0
- package/dist/{consent-D5sY6JK3.js → consent-B2hSTCGC.js} +14 -7
- package/dist/consume-BiOhrhEy.js +167 -0
- package/dist/consume-DKf5SmP9.cjs +1 -0
- package/dist/{converters-BKGBRBpS.js → converters-BBfsEJV5.js} +25 -25
- package/dist/{converters-9jHlXDyy.cjs → converters-Cd0fPEly.cjs} +1 -1
- package/dist/{datepicker-BE5Ll0W4.js → datepicker--Fq8q-J3.js} +30 -12
- package/dist/{datepicker-x4xM3KQz.cjs → datepicker-CEoBYTBU.cjs} +11 -7
- package/dist/docs/components/alert.d.ts +3 -0
- package/dist/docs/components/footer.d.ts +9 -0
- package/dist/docs/components/form-sizes.d.ts +10 -0
- package/dist/docs/components/header-global-full.d.ts +20 -0
- package/dist/docs/components/header-global.d.ts +14 -0
- package/dist/docs/components/searchinput.d.ts +6 -3
- package/dist/fetch-header-footer-data-Pc32etrk.js +88 -0
- package/dist/fetch-header-footer-data-xohWFmYC.cjs +1 -0
- package/dist/fileupload-CGKUJrlj.cjs +401 -0
- package/dist/{fileupload-2hf8YNhO.js → fileupload-D4gQN64T.js} +156 -176
- package/dist/focus-trap-DG3pEuyJ.js +60 -0
- package/dist/focus-trap-DSv4Ifqm.cjs +1 -0
- package/dist/footer-BIrJeRuZ.js +303 -0
- package/dist/footer-Ber-jqM1.cjs +114 -0
- package/dist/footer.d.ts +1 -0
- package/dist/header-BFk1an4z.cjs +465 -0
- package/dist/header-Deg_LGJo.js +1287 -0
- package/dist/header-menu-BHqK4QA6.cjs +126 -0
- package/dist/{header-menu-C8b5vd3n.js → header-menu-GFtJKM4j.js} +25 -97
- package/dist/{helptext-OfqH5npD.js → helptext-C_brWCIT.js} +1 -1
- package/dist/{helptext-eckq4JEX.cjs → helptext-Cq5rNaAC.cjs} +1 -1
- package/dist/{input-element-ZGOWsvKM.cjs → input-element-B0qLbEdF.cjs} +1 -1
- package/dist/{input-element-BFHpeoV8.js → input-element-C0RnXi-J.js} +5 -2
- package/dist/{input-wrapper-DwwE0JcO.js → input-wrapper-BweP6t3O.js} +12 -0
- package/dist/{input-wrapper-BRjQB4zM.cjs → input-wrapper-DPkkiG7S.cjs} +13 -11
- package/dist/{input-wrapper-DaA98B5l.js → input-wrapper-fWV5P4MN.js} +22 -15
- package/dist/{input-wrapper-LcZjpt0L.cjs → input-wrapper-wh3fWIhk.cjs} +1 -1
- package/dist/modal-CPnFteYS.cjs +35 -0
- package/dist/{modal-C6pScpdG.js → modal-xNK_wpHk.js} +11 -20
- 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-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-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 -0
- package/dist/pkt-footer.js +2 -0
- 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 +2 -2
- 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 +27 -26
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.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-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/{radiobutton-DGO6H2Ki.js → radiobutton-C6htwDrT.js} +1 -1
- package/dist/{radiobutton-DY1WWepJ.cjs → radiobutton-DjWBoSHv.cjs} +1 -1
- package/dist/scroll-lock-BN8lOhV5.cjs +1 -0
- package/dist/scroll-lock-DAbNKAUy.js +18 -0
- package/dist/searchinput-CfUVfpqL.js +156 -0
- package/dist/searchinput-DGjeN1YI.cjs +60 -0
- package/dist/{select-D4_HQFkh.cjs → select-CZvAW7W2.cjs} +2 -1
- package/dist/{select-BwHUIlwQ.js → select-CsBXXbLP.js} +4 -3
- package/dist/setupTests.d.ts +0 -0
- package/dist/shared-types/footer.d.ts +95 -0
- package/dist/shared-types/{header-menu.d.ts → header-footer.d.ts} +51 -4
- package/dist/shared-types/header.d.ts +1 -1
- package/dist/shared-types/index.d.ts +6 -4
- package/dist/shared-types/searchinput.d.ts +2 -0
- package/dist/shared-types/select.d.ts +3 -2
- package/dist/shared-types/size.d.ts +4 -0
- package/dist/shared-types/timepicker.d.ts +0 -6
- package/dist/shared-utils/datepicker-utils.d.ts +5 -4
- package/dist/shared-utils/fileupload/focus-trap.d.ts +4 -10
- package/dist/shared-utils/focus-trap/index.d.ts +22 -0
- package/dist/shared-utils/{header-menu → header-footer}/example-data.d.ts +5 -4
- package/dist/shared-utils/header-footer/external-domain.d.ts +26 -0
- package/dist/shared-utils/{header-menu → header-footer}/fetch-header-footer-data.d.ts +6 -2
- package/dist/shared-utils/{header-menu → header-footer}/index.d.ts +2 -1
- package/dist/shared-utils/{header-menu → header-footer}/select-megamenu.d.ts +1 -1
- package/dist/shared-utils/scroll-lock/index.d.ts +24 -0
- package/dist/tabs-BqrKLCjd.js +214 -0
- package/dist/tabs-q62MK_-r.cjs +40 -0
- package/dist/{textarea-D6M7ZhtA.js → textarea-Cm392CEI.js} +5 -3
- package/dist/{textarea-Bt_Zs8gq.cjs → textarea-sTcZxOIB.cjs} +3 -2
- package/dist/{textinput-EDKjcUdg.cjs → textinput-DqJbTglM.cjs} +3 -2
- package/dist/{textinput-oU2EvFsi.js → textinput-TSPcBcih.js} +5 -3
- package/dist/{timepicker-CgOL2sd9.cjs → timepicker-CqFYMV8q.cjs} +8 -7
- package/dist/{timepicker-_G0V_HV3.js → timepicker-DWbgTDKq.js} +10 -9
- package/package.json +3 -3
- package/src/components/accordion/accordion-context.ts +8 -0
- package/src/components/accordion/accordion.test.ts +44 -0
- package/src/components/accordion/accordion.ts +13 -3
- package/src/components/accordion/accordionitem.ts +9 -1
- package/src/components/alert/alert.test.ts +51 -2
- package/src/components/alert/alert.ts +11 -5
- package/src/components/breadcrumbs/breadcrumbs.test.ts +11 -3
- package/src/components/button/button.test.ts +23 -0
- package/src/components/button/button.ts +28 -3
- package/src/components/combobox/combobox.core.test.ts +20 -0
- package/src/components/combobox/combobox.ts +2 -0
- package/src/components/consent/consent.test.ts +6 -3
- package/src/components/consent/consent.ts +15 -7
- package/src/components/datepicker/datepicker-base.ts +5 -1
- package/src/components/datepicker/datepicker-utils.test.ts +10 -0
- package/src/components/datepicker/datepicker.core.test.ts +17 -0
- package/src/components/datepicker/datepicker.ts +8 -0
- package/src/components/footer/footer-base.ts +238 -0
- package/src/components/footer/footer-simple.ts +71 -0
- package/src/components/footer/footer.accessibility.test.ts +66 -0
- package/src/components/footer/footer.test.ts +238 -0
- package/src/components/footer/footer.ts +81 -0
- package/src/components/footer/index.ts +4 -0
- package/src/components/footer/types.ts +21 -0
- package/src/components/header/header-chrome-controller.ts +123 -0
- package/src/components/header/header-global.accessibility.test.ts +110 -0
- package/src/components/header/header-global.test.ts +329 -0
- package/src/components/header/header-global.ts +648 -0
- package/src/components/header/header-service.accessibility.test.ts +79 -0
- package/src/components/header/header-service.test.ts +32 -12
- package/src/components/header/header-service.ts +38 -162
- package/src/components/header/header-user-menu.ts +0 -1
- package/src/components/header/header.test.ts +84 -0
- package/src/components/header/header.ts +52 -5
- package/src/components/header/index.ts +6 -0
- package/src/components/header/types.ts +38 -0
- package/src/components/header-menu/header-menu.test.ts +131 -10
- package/src/components/header-menu/header-menu.ts +23 -24
- package/src/components/header-menu/types.ts +1 -1
- package/src/components/index.ts +18 -2
- package/src/components/input-wrapper/input-wrapper.test.ts +45 -0
- package/src/components/input-wrapper/input-wrapper.ts +17 -9
- package/src/components/modal/modal.ts +8 -9
- package/src/components/searchinput/searchinput.test.ts +43 -0
- package/src/components/searchinput/searchinput.ts +29 -12
- package/src/components/select/index.ts +1 -1
- package/src/components/select/select.test.ts +28 -0
- package/src/components/select/select.ts +4 -3
- package/src/components/textarea/textarea.test.ts +16 -0
- package/src/components/textarea/textarea.ts +3 -1
- package/src/components/textinput/textinput.test.ts +28 -0
- package/src/components/textinput/textinput.ts +3 -1
- package/src/components/timepicker/timepicker.test.ts +26 -0
- package/src/components/timepicker/timepicker.ts +12 -6
- package/dist/accordion-FISAiAbX.cjs +0 -47
- package/dist/button-C_YzTSuU.js +0 -96
- package/dist/combobox-D6H9rWPV.cjs +0 -135
- package/dist/consent-X3wvhteO.cjs +0 -10
- package/dist/fileupload-BLVrslUX.cjs +0 -401
- package/dist/header-CFrsaq0c.cjs +0 -310
- package/dist/header-D_xvPR4R.js +0 -801
- package/dist/header-menu-DMdP_c6X.cjs +0 -126
- package/dist/modal-DKU7PnjJ.cjs +0 -35
- package/dist/searchinput-CyO5k4Q4.js +0 -148
- package/dist/searchinput-DG6YetL1.cjs +0 -60
- package/dist/shared-utils/modal-scroll-lock.d.ts +0 -10
- package/dist/tabs-CGo0ODPa.cjs +0 -40
- package/dist/tabs-ChdR0D1C.js +0 -379
- /package/dist/shared-utils/{header-menu → header-footer}/icon-map.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PktElement } from '@/base-elements/element'
|
|
2
|
-
import { html, nothing } from 'lit'
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
2
|
+
import { html, nothing, type PropertyValues } from 'lit'
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js'
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
6
6
|
import { FocusModalityController } from '@/controllers/focus-modality-controller'
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
TPktSearchInputAppearance,
|
|
14
14
|
TPktSearchInputMethod,
|
|
15
15
|
} from 'shared-types/searchinput'
|
|
16
|
+
import type { TPktInputSize } from 'shared-types/size'
|
|
16
17
|
|
|
17
18
|
export type {
|
|
18
19
|
IPktSearchInput,
|
|
@@ -23,6 +24,7 @@ export type {
|
|
|
23
24
|
|
|
24
25
|
export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktSearchInput {
|
|
25
26
|
@property({ type: String }) appearance: TPktSearchInputAppearance = 'local'
|
|
27
|
+
@property({ type: String, attribute: 'input-size' }) inputSize: TPktInputSize = 'medium'
|
|
26
28
|
@property({ type: Boolean, reflect: true }) disabled: boolean = false
|
|
27
29
|
@property({ type: Boolean, reflect: true }) fullwidth: boolean = false
|
|
28
30
|
@property({ type: String, reflect: true }) id: string = ''
|
|
@@ -36,6 +38,17 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
36
38
|
|
|
37
39
|
focusModality = new FocusModalityController(this, '.pkt-searchinput')
|
|
38
40
|
|
|
41
|
+
@state() private inputAriaLabel?: string
|
|
42
|
+
|
|
43
|
+
override willUpdate(changed: PropertyValues): void {
|
|
44
|
+
super.willUpdate(changed)
|
|
45
|
+
const hostLabel = this.getAttribute('aria-label')
|
|
46
|
+
if (hostLabel) {
|
|
47
|
+
this.inputAriaLabel = hostLabel
|
|
48
|
+
this.removeAttribute('aria-label')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
private get suggestionsId() {
|
|
40
53
|
return `${this.id}-suggestions`
|
|
41
54
|
}
|
|
@@ -57,12 +70,14 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
57
70
|
|
|
58
71
|
private onInputKeydown(event: KeyboardEvent): void {
|
|
59
72
|
if (event.key !== 'Enter') return
|
|
60
|
-
|
|
73
|
+
// With an `action`, let the form submit natively (Enter triggers submit).
|
|
74
|
+
if (!this.action) event.preventDefault()
|
|
61
75
|
this.dispatchSearch()
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
private onSearchClick(event: Event): void {
|
|
65
|
-
|
|
79
|
+
// With an `action`, let the submit button submit the form natively.
|
|
80
|
+
if (!this.action) event.preventDefault()
|
|
66
81
|
this.dispatchSearch()
|
|
67
82
|
}
|
|
68
83
|
|
|
@@ -123,13 +138,14 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
123
138
|
const wrapperClasses = classMap({
|
|
124
139
|
'pkt-searchinput': true,
|
|
125
140
|
[`pkt-searchinput--${this.appearance}`]: true,
|
|
141
|
+
[`pkt-searchinput--${this.inputSize}`]: true,
|
|
126
142
|
'pkt-searchinput--fullwidth': this.fullwidth,
|
|
127
143
|
})
|
|
128
144
|
const buttonClasses = classMap({
|
|
129
145
|
'pkt-searchinput__button': true,
|
|
130
146
|
'pkt-input-icon': this.appearance === 'local',
|
|
131
147
|
'pkt-btn': true,
|
|
132
|
-
|
|
148
|
+
[`pkt-btn--${this.inputSize}`]: true,
|
|
133
149
|
'pkt-btn--icon-only': true,
|
|
134
150
|
'pkt-btn--tertiary': this.appearance === 'local',
|
|
135
151
|
'pkt-btn--primary': this.appearance === 'global' || this.appearance === 'local-with-button',
|
|
@@ -137,10 +153,13 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
137
153
|
})
|
|
138
154
|
const inputClasses = classMap({
|
|
139
155
|
'pkt-input': true,
|
|
156
|
+
[`pkt-input--${this.inputSize}`]: true,
|
|
140
157
|
'pkt-input--fullwidth': this.fullwidth,
|
|
141
158
|
})
|
|
142
159
|
const fieldClass =
|
|
143
|
-
this.appearance === 'local'
|
|
160
|
+
this.appearance === 'local'
|
|
161
|
+
? `pkt-input__container pkt-input__container--${this.inputSize}`
|
|
162
|
+
: 'pkt-searchinput__field'
|
|
144
163
|
|
|
145
164
|
const body = html`
|
|
146
165
|
${this.label
|
|
@@ -158,8 +177,9 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
158
177
|
.value=${this.value}
|
|
159
178
|
?disabled=${this.disabled}
|
|
160
179
|
autocomplete="off"
|
|
161
|
-
aria-
|
|
162
|
-
aria-
|
|
180
|
+
aria-label=${ifDefined(this.inputAriaLabel)}
|
|
181
|
+
aria-autocomplete=${this.suggestions ? 'list' : nothing}
|
|
182
|
+
aria-controls=${this.suggestions ? this.suggestionsId : nothing}
|
|
163
183
|
@input=${this.onInput}
|
|
164
184
|
@keydown=${this.onInputKeydown}
|
|
165
185
|
/>
|
|
@@ -169,7 +189,7 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
169
189
|
?disabled=${this.disabled}
|
|
170
190
|
@click=${this.onSearchClick}
|
|
171
191
|
>
|
|
172
|
-
<pkt-icon class="pkt-btn__icon" name="magnifying-glass-big"
|
|
192
|
+
<pkt-icon class="pkt-btn__icon" name="magnifying-glass-big"></pkt-icon>
|
|
173
193
|
<span class="pkt-btn__text">${this.label || this.placeholder || 'Søk…'}</span>
|
|
174
194
|
</button>
|
|
175
195
|
</div>
|
|
@@ -192,9 +212,6 @@ export class PktSearchInput extends PktElement<IPktSearchInput> implements IPktS
|
|
|
192
212
|
class=${wrapperClasses}
|
|
193
213
|
action=${this.action}
|
|
194
214
|
method=${ifDefined(this.method)}
|
|
195
|
-
@submit=${(event: Event) => {
|
|
196
|
-
event.preventDefault()
|
|
197
|
-
}}
|
|
198
215
|
>
|
|
199
216
|
${body}
|
|
200
217
|
</form>`
|
|
@@ -20,6 +20,7 @@ export interface SelectTestConfig extends Partial<IPktSelect>, BaseTestConfig {
|
|
|
20
20
|
counter?: boolean
|
|
21
21
|
inline?: boolean
|
|
22
22
|
useWrapper?: boolean | string
|
|
23
|
+
'input-size'?: string
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export const createSelectTest = async (config: SelectTestConfig = {}) => {
|
|
@@ -157,6 +158,33 @@ describe('pkt-select', () => {
|
|
|
157
158
|
expect(selectElement?.className).toContain('pkt-input--fullwidth')
|
|
158
159
|
})
|
|
159
160
|
|
|
161
|
+
test('applies pkt-input--medium class by default', async () => {
|
|
162
|
+
const { select } = await createSelectTest()
|
|
163
|
+
|
|
164
|
+
const selectElement = select.querySelector('select')
|
|
165
|
+
expect(selectElement?.classList.contains('pkt-input--medium')).toBe(true)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('applies pkt-input--small class for input-size="small"', async () => {
|
|
169
|
+
const { select } = await createSelectTest({ 'input-size': 'small' })
|
|
170
|
+
|
|
171
|
+
expect(select.inputSize).toBe('small')
|
|
172
|
+
|
|
173
|
+
const selectElement = select.querySelector('select')
|
|
174
|
+
expect(selectElement?.classList.contains('pkt-input--small')).toBe(true)
|
|
175
|
+
expect(selectElement?.classList.contains('pkt-input--medium')).toBe(false)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
test('applies pkt-input--xsmall class for input-size="xsmall"', async () => {
|
|
179
|
+
const { select } = await createSelectTest({ 'input-size': 'xsmall' })
|
|
180
|
+
|
|
181
|
+
expect(select.inputSize).toBe('xsmall')
|
|
182
|
+
|
|
183
|
+
const selectElement = select.querySelector('select')
|
|
184
|
+
expect(selectElement?.classList.contains('pkt-input--xsmall')).toBe(true)
|
|
185
|
+
expect(selectElement?.classList.contains('pkt-input--medium')).toBe(false)
|
|
186
|
+
})
|
|
187
|
+
|
|
160
188
|
test('manages focus events correctly', async () => {
|
|
161
189
|
const { select } = await createSelectTest()
|
|
162
190
|
|
|
@@ -5,10 +5,10 @@ import { ifDefined } from 'lit/directives/if-defined.js'
|
|
|
5
5
|
import { PktOptionsInputElement } from '@/base-elements/options-input-element'
|
|
6
6
|
import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
|
|
7
7
|
import { slotContent } from '@/directives/slot-content'
|
|
8
|
-
import type { TSelectOption } from 'shared-types'
|
|
8
|
+
import type { TSelectOption } from 'shared-types/select'
|
|
9
9
|
import '@/components/input-wrapper'
|
|
10
10
|
|
|
11
|
-
export type { TSelectOption }
|
|
11
|
+
export type { TSelectOption } from 'shared-types/select'
|
|
12
12
|
|
|
13
13
|
export interface IPktSelect {
|
|
14
14
|
options: TSelectOption[]
|
|
@@ -176,10 +176,11 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
render() {
|
|
179
|
-
const inputClass = `pkt-input ${this.fullwidth ? 'pkt-input--fullwidth' : ''}`
|
|
179
|
+
const inputClass = `pkt-input pkt-input--${this.inputSize} ${this.fullwidth ? 'pkt-input--fullwidth' : ''}`
|
|
180
180
|
|
|
181
181
|
return html`
|
|
182
182
|
<pkt-input-wrapper
|
|
183
|
+
.size=${this.inputSize}
|
|
183
184
|
?counter=${this.counter}
|
|
184
185
|
?disabled=${this.disabled}
|
|
185
186
|
?hasError=${this.hasError}
|
|
@@ -4,6 +4,7 @@ import { fireEvent } from '@testing-library/dom'
|
|
|
4
4
|
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
5
5
|
import { CustomElementFor } from '../../tests/component-registry'
|
|
6
6
|
import './textarea'
|
|
7
|
+
import { TPktInputSize } from 'shared-types/size'
|
|
7
8
|
|
|
8
9
|
export interface TextareaTestConfig extends BaseTestConfig {
|
|
9
10
|
// From PktTextarea specific properties
|
|
@@ -29,6 +30,7 @@ export interface TextareaTestConfig extends BaseTestConfig {
|
|
|
29
30
|
inline?: boolean
|
|
30
31
|
ariaLabelledby?: string | null
|
|
31
32
|
ariaDescribedBy?: string | null
|
|
33
|
+
inputSize?: TPktInputSize
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
// Use shared framework
|
|
@@ -156,9 +158,23 @@ describe('PktTextarea', () => {
|
|
|
156
158
|
test('handles fullwidth styling', async () => {
|
|
157
159
|
const { textarea } = await createTextareaTest({ fullwidth: true })
|
|
158
160
|
|
|
161
|
+
expect(textarea.hasAttribute('fullwidth')).toBe(true)
|
|
162
|
+
|
|
159
163
|
const textareaElement = textarea.querySelector('textarea')
|
|
160
164
|
expect(textareaElement?.className).toContain('pkt-input--fullwidth')
|
|
161
165
|
})
|
|
166
|
+
|
|
167
|
+
test('applies inputSize to textarea and wrapper', async () => {
|
|
168
|
+
const { textarea } = await createTextareaTest({ label: 'Sized textarea' })
|
|
169
|
+
textarea.inputSize = 'xsmall'
|
|
170
|
+
await textarea.updateComplete
|
|
171
|
+
|
|
172
|
+
const textareaElement = textarea.querySelector('textarea')
|
|
173
|
+
expect(textareaElement?.classList.contains('pkt-input--xsmall')).toBe(true)
|
|
174
|
+
|
|
175
|
+
const inputWrapper = textarea.querySelector('.pkt-inputwrapper')
|
|
176
|
+
expect(inputWrapper?.classList.contains('pkt-inputwrapper--xsmall')).toBe(true)
|
|
177
|
+
})
|
|
162
178
|
})
|
|
163
179
|
|
|
164
180
|
describe('Character Counter', () => {
|
|
@@ -44,6 +44,7 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
44
44
|
render() {
|
|
45
45
|
const inputClasses = classMap({
|
|
46
46
|
'pkt-input': true,
|
|
47
|
+
[`pkt-input--${this.inputSize}`]: true,
|
|
47
48
|
'pkt-input--fullwidth': this.fullwidth,
|
|
48
49
|
'pkt-input--counter-error':
|
|
49
50
|
this.counter &&
|
|
@@ -74,6 +75,7 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
74
75
|
.optionalText=${this.optionalText}
|
|
75
76
|
.requiredText=${this.requiredText}
|
|
76
77
|
.tagText=${this.tagText}
|
|
78
|
+
.size=${this.inputSize}
|
|
77
79
|
class="pkt-textarea"
|
|
78
80
|
>
|
|
79
81
|
<div class="pkt-contents" slot="helptext">${slotContent(this, 'helptext')}</div>
|
|
@@ -91,7 +93,7 @@ export class PktTextarea extends PktInputElement<Props> {
|
|
|
91
93
|
aria-labelledby=${labelledBy}
|
|
92
94
|
aria-invalid=${this.hasError}
|
|
93
95
|
aria-errormessage=${`${this.id}-error`}
|
|
94
|
-
rows=${this.rows}
|
|
96
|
+
rows=${ifDefined(this.rows ?? undefined)}
|
|
95
97
|
?disabled=${this.disabled}
|
|
96
98
|
@input=${(e: InputEvent) => {
|
|
97
99
|
this.value = (e.target as HTMLInputElement).value
|
|
@@ -15,6 +15,7 @@ export interface TextinputTestConfig extends BaseTestConfig {
|
|
|
15
15
|
suffix?: string | null
|
|
16
16
|
size?: number | null
|
|
17
17
|
omitSearchIcon?: boolean
|
|
18
|
+
'input-size'?: string
|
|
18
19
|
|
|
19
20
|
// From PktInputElement base class (commonly used ones)
|
|
20
21
|
id?: string
|
|
@@ -146,6 +147,33 @@ describe('PktTextinput', () => {
|
|
|
146
147
|
expect(inputElement?.hasAttribute('readonly')).toBe(true)
|
|
147
148
|
})
|
|
148
149
|
|
|
150
|
+
test('applies pkt-input--medium class by default', async () => {
|
|
151
|
+
const { textinput } = await createTextinputTest()
|
|
152
|
+
|
|
153
|
+
const inputElement = textinput.querySelector('input')
|
|
154
|
+
expect(inputElement?.classList.contains('pkt-input--medium')).toBe(true)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('applies pkt-input--small class for input-size="small"', async () => {
|
|
158
|
+
const { textinput } = await createTextinputTest({ 'input-size': 'small' })
|
|
159
|
+
|
|
160
|
+
expect(textinput.inputSize).toBe('small')
|
|
161
|
+
|
|
162
|
+
const inputElement = textinput.querySelector('input')
|
|
163
|
+
expect(inputElement?.classList.contains('pkt-input--small')).toBe(true)
|
|
164
|
+
expect(inputElement?.classList.contains('pkt-input--medium')).toBe(false)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
test('applies pkt-input--xsmall class for input-size="xsmall"', async () => {
|
|
168
|
+
const { textinput } = await createTextinputTest({ 'input-size': 'xsmall' })
|
|
169
|
+
|
|
170
|
+
expect(textinput.inputSize).toBe('xsmall')
|
|
171
|
+
|
|
172
|
+
const inputElement = textinput.querySelector('input')
|
|
173
|
+
expect(inputElement?.classList.contains('pkt-input--xsmall')).toBe(true)
|
|
174
|
+
expect(inputElement?.classList.contains('pkt-input--medium')).toBe(false)
|
|
175
|
+
})
|
|
176
|
+
|
|
149
177
|
test('handles required state', async () => {
|
|
150
178
|
const { textinput } = await createTextinputTest({ required: true })
|
|
151
179
|
|
|
@@ -60,6 +60,7 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
60
60
|
this.type === 'search' && !this.iconNameRight && !this.omitSearchIcon
|
|
61
61
|
const inputClasses = classMap({
|
|
62
62
|
'pkt-input': true,
|
|
63
|
+
[`pkt-input--${this.inputSize}`]: true,
|
|
63
64
|
'pkt-input--fullwidth': this.fullwidth,
|
|
64
65
|
'pkt-input--counter-error':
|
|
65
66
|
this.counter &&
|
|
@@ -92,10 +93,11 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
92
93
|
.optionalText=${this.optionalText}
|
|
93
94
|
.requiredText=${this.requiredText}
|
|
94
95
|
.tagText=${this.tagText}
|
|
96
|
+
.size=${this.inputSize}
|
|
95
97
|
class="pkt-textinput"
|
|
96
98
|
>
|
|
97
99
|
<div class="pkt-contents" slot="helptext">${slotContent(this, 'helptext')}</div>
|
|
98
|
-
<div class
|
|
100
|
+
<div class=${`pkt-input__container pkt-input__container--${this.inputSize}`}>
|
|
99
101
|
${this.prefix ? html`<div class="pkt-input-prefix">${this.prefix}</div>` : nothing}
|
|
100
102
|
<input
|
|
101
103
|
${ref(this.inputRef)}
|
|
@@ -5,6 +5,7 @@ import { vi } from 'vitest'
|
|
|
5
5
|
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
6
6
|
import { CustomElementFor } from '../../tests/component-registry'
|
|
7
7
|
import './timepicker'
|
|
8
|
+
import { TPktInputSize } from 'shared-types/size'
|
|
8
9
|
|
|
9
10
|
export interface TimepickerTestConfig extends BaseTestConfig {
|
|
10
11
|
value?: string
|
|
@@ -22,6 +23,8 @@ export interface TimepickerTestConfig extends BaseTestConfig {
|
|
|
22
23
|
helptext?: string
|
|
23
24
|
id?: string
|
|
24
25
|
name?: string
|
|
26
|
+
inputSize?: TPktInputSize
|
|
27
|
+
'input-size'?: TPktInputSize
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export const createTimepickerTest = async (config: TimepickerTestConfig = {}) => {
|
|
@@ -184,6 +187,29 @@ describe('PktTimepicker', () => {
|
|
|
184
187
|
expect(timepicker.classList.contains('pkt-timepicker--fullwidth')).toBe(true)
|
|
185
188
|
})
|
|
186
189
|
|
|
190
|
+
test.each([
|
|
191
|
+
['small', 'small'],
|
|
192
|
+
['xsmall', 'xsmall'],
|
|
193
|
+
] as const)(
|
|
194
|
+
'input-size="%s" applies size classes on host, container, inputs and clock button',
|
|
195
|
+
async (size, sizeClass) => {
|
|
196
|
+
const { timepicker } = await createTimepickerTest({
|
|
197
|
+
label: 'Tidspunkt',
|
|
198
|
+
id: 'test',
|
|
199
|
+
'input-size': size,
|
|
200
|
+
})
|
|
201
|
+
await timepicker.updateComplete
|
|
202
|
+
|
|
203
|
+
expect(timepicker.inputSize).toBe(size)
|
|
204
|
+
expect(timepicker.classList.contains(`pkt-timepicker--${sizeClass}`)).toBe(true)
|
|
205
|
+
expect(timepicker.querySelector(`.pkt-input__container--${sizeClass}`)).toBeTruthy()
|
|
206
|
+
expect(timepicker.querySelectorAll(`.pkt-input--${sizeClass}`)).toHaveLength(2)
|
|
207
|
+
expect(
|
|
208
|
+
timepicker.querySelector(`.pkt-timepicker__button.pkt-btn--${sizeClass}`),
|
|
209
|
+
).toBeTruthy()
|
|
210
|
+
},
|
|
211
|
+
)
|
|
212
|
+
|
|
187
213
|
test('min/max/step forwarded to hidden input', async () => {
|
|
188
214
|
const { timepicker } = await createTimepickerTest({
|
|
189
215
|
label: 'Tidspunkt',
|
|
@@ -12,6 +12,7 @@ import { getMinuteStep, getHourOptions, getMinuteOptions } from 'shared-utils/ti
|
|
|
12
12
|
import { stepTime } from 'shared-utils/timepicker/stepper'
|
|
13
13
|
import '@/components/icon'
|
|
14
14
|
import '@/components/input-wrapper'
|
|
15
|
+
import { TPktInputSize } from 'shared-types/size'
|
|
15
16
|
|
|
16
17
|
type Props = ElementProps<PktTimepicker, 'value' | 'hidePicker' | 'stepArrows'>
|
|
17
18
|
|
|
@@ -39,6 +40,7 @@ export interface IPktTimepicker {
|
|
|
39
40
|
optionalText?: string
|
|
40
41
|
tagText?: string | null
|
|
41
42
|
inline?: boolean
|
|
43
|
+
inputSize?: TPktInputSize
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export class PktTimepicker extends PktInputElement<Props> {
|
|
@@ -199,6 +201,9 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
199
201
|
super.updated(changedProperties)
|
|
200
202
|
this.classList.toggle('pkt-timepicker--stepper', this.stepArrows)
|
|
201
203
|
this.classList.toggle('pkt-timepicker--fullwidth', this.fullwidth)
|
|
204
|
+
this.classList.toggle('pkt-timepicker--medium', this.inputSize === 'medium')
|
|
205
|
+
this.classList.toggle('pkt-timepicker--small', this.inputSize === 'small')
|
|
206
|
+
this.classList.toggle('pkt-timepicker--xsmall', this.inputSize === 'xsmall')
|
|
202
207
|
if (changedProperties.has('step') && this.step !== null && !this._isValidStep(this.step)) {
|
|
203
208
|
// eslint-disable-next-line no-console
|
|
204
209
|
console.warn(
|
|
@@ -612,7 +617,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
612
617
|
const minutesAriaLabel = this.label ? `${minutesLabel}, ${this.label}` : minutesLabel
|
|
613
618
|
return html`
|
|
614
619
|
<div
|
|
615
|
-
class="pkt-input__container"
|
|
620
|
+
class="pkt-input__container pkt-input__container--${this.inputSize}"
|
|
616
621
|
@click=${(e: Event) => {
|
|
617
622
|
const target = e.target as HTMLElement
|
|
618
623
|
if (target.closest('button, input')) return
|
|
@@ -622,7 +627,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
622
627
|
${this.stepArrows
|
|
623
628
|
? html`
|
|
624
629
|
<button
|
|
625
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--prev"
|
|
630
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--prev"
|
|
626
631
|
type="button"
|
|
627
632
|
aria-label=${this.strings.timepicker?.prevTime ?? 'Forrige tidspunkt'}
|
|
628
633
|
?disabled=${this.disabled}
|
|
@@ -641,7 +646,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
641
646
|
inputmode="numeric"
|
|
642
647
|
maxlength="2"
|
|
643
648
|
size="2"
|
|
644
|
-
class="pkt-input pkt-timepicker__input"
|
|
649
|
+
class="pkt-input pkt-input--${this.inputSize} pkt-timepicker__input"
|
|
645
650
|
id=${this.id + '-hours'}
|
|
646
651
|
data-min="0"
|
|
647
652
|
data-max="23"
|
|
@@ -672,7 +677,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
672
677
|
inputmode="numeric"
|
|
673
678
|
maxlength="2"
|
|
674
679
|
size="2"
|
|
675
|
-
class="pkt-input pkt-timepicker__input"
|
|
680
|
+
class="pkt-input pkt-input--${this.inputSize} pkt-timepicker__input"
|
|
676
681
|
id=${this.id + '-minutes'}
|
|
677
682
|
data-min="0"
|
|
678
683
|
data-max="59"
|
|
@@ -707,7 +712,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
707
712
|
? html`
|
|
708
713
|
<button
|
|
709
714
|
${ref(this.buttonRef)}
|
|
710
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button"
|
|
715
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button"
|
|
711
716
|
type="button"
|
|
712
717
|
aria-label=${this.strings.timepicker?.openPicker ?? 'Åpne tidspunkt-velger'}
|
|
713
718
|
aria-haspopup="listbox"
|
|
@@ -726,7 +731,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
726
731
|
${this.stepArrows
|
|
727
732
|
? html`
|
|
728
733
|
<button
|
|
729
|
-
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-timepicker__button pkt-timepicker__button--next"
|
|
734
|
+
class="pkt-input-icon pkt-btn pkt-btn--icon-only pkt-btn--tertiary pkt-btn--${this.inputSize} pkt-timepicker__button pkt-timepicker__button--next"
|
|
730
735
|
type="button"
|
|
731
736
|
aria-label=${this.strings.timepicker?.nextTime ?? 'Neste tidspunkt'}
|
|
732
737
|
?disabled=${this.disabled}
|
|
@@ -778,6 +783,7 @@ export class PktTimepicker extends PktInputElement<Props> {
|
|
|
778
783
|
.optionalText=${this.optionalText}
|
|
779
784
|
.requiredText=${this.requiredText}
|
|
780
785
|
.tagText=${this.tagText}
|
|
786
|
+
.size=${this.inputSize}
|
|
781
787
|
>
|
|
782
788
|
<div class="pkt-contents" slot="helptext">${slotContent(this, 'helptext')}</div>
|
|
783
789
|
${!this.hidePicker && !this.stepArrows
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs"),n=require("./element-with-slot-BY7Jc-q8.cjs"),r=require("./if-defined-DrwbxQOj.cjs"),i=require("./ref-DO7TzO4O.cjs");var a=class extends e.i{constructor(...e){super(...e),this.ariaLabelledBy=``,this.compact=!1,this.skin=`borderless`,this.name=``}updated(e){e.has(`skin`)&&this.requestUpdate(),e.has(`name`)&&this.updateAccordionItemNames()}updateAccordionItemNames(){if(this.name){let e=this.renderRoot?.querySelector(`slot`);e&&e.assignedElements().forEach(e=>{e.tagName.toLowerCase()===`pkt-accordion-item`&&(e.hasAttribute(`name`)||e.setAttribute(`name`,this.name))})}}firstUpdated(){let e=this.renderRoot?.querySelector(`slot`);e&&e.addEventListener(`slotchange`,()=>{this.updateAccordionItemNames()})}render(){return e.p`
|
|
2
|
-
<div
|
|
3
|
-
part="container"
|
|
4
|
-
class=${t.t({"pkt-accordion":!0,"pkt-accordion--compact":this.compact,[`pkt-accordion--${this.skin}`]:this.skin})}
|
|
5
|
-
data-testid="pkt-accordion"
|
|
6
|
-
aria-labelledby=${this.ariaLabelledBy}
|
|
7
|
-
>
|
|
8
|
-
<slot></slot>
|
|
9
|
-
</div>
|
|
10
|
-
`}};e.n([e.o({type:String,reflect:!0,attribute:`aria-labelledby`})],a.prototype,`ariaLabelledBy`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`compact`})],a.prototype,`compact`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`skin`})],a.prototype,`skin`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`name`})],a.prototype,`name`,void 0);try{e.s(`pkt-accordion`)(a)}catch{console.warn(`Forsøker å definere <pkt-accordion>, men den er allerede definert`)}var o=class extends n.t{constructor(){super(),this.defaultOpen=!1,this.title=``,this.skin=void 0,this.compact=!1,this.isOpen=!1,this.name=void 0,this.accordionItemRef=i.t()}firstUpdated(e){this.defaultOpen&&(this.isOpen=!0)}render(){let a={"pkt-accordion-item":!0,"pkt-accordion-item--compact":this.compact,[`pkt-accordion-item--${this.skin}`]:!!this.skin},o=this.skin===`plus-minus`;return e.p`
|
|
11
|
-
<details
|
|
12
|
-
class=${t.t(a)}
|
|
13
|
-
id=${this.id}
|
|
14
|
-
?open=${this.isOpen}
|
|
15
|
-
${i.n(this.accordionItemRef)}
|
|
16
|
-
name=${r.t(this.name)}
|
|
17
|
-
>
|
|
18
|
-
<summary class="pkt-accordion-item__title" id=${`pkt-accordion-item-summary-${this.id}`}>
|
|
19
|
-
${this.title}
|
|
20
|
-
${o?e.p`
|
|
21
|
-
<pkt-icon
|
|
22
|
-
name="plus-sign"
|
|
23
|
-
class="pkt-accordion-item__icon pkt-accordion-item__icon--plus"
|
|
24
|
-
aria-hidden="true"
|
|
25
|
-
></pkt-icon>
|
|
26
|
-
<pkt-icon
|
|
27
|
-
name="minus-sign"
|
|
28
|
-
class="pkt-accordion-item__icon pkt-accordion-item__icon--minus"
|
|
29
|
-
aria-hidden="true"
|
|
30
|
-
></pkt-icon>
|
|
31
|
-
`:e.p`
|
|
32
|
-
<pkt-icon
|
|
33
|
-
name="chevron-thin-down"
|
|
34
|
-
class="pkt-accordion-item__icon"
|
|
35
|
-
aria-hidden="true"
|
|
36
|
-
></pkt-icon>
|
|
37
|
-
`}
|
|
38
|
-
</summary>
|
|
39
|
-
<div
|
|
40
|
-
class="pkt-accordion-item__content"
|
|
41
|
-
id="pkt-accordion-item__content-${this.id}"
|
|
42
|
-
role="region"
|
|
43
|
-
>
|
|
44
|
-
<div class="pkt-accordion-item__content-inner">${n.n(this)}</div>
|
|
45
|
-
</div>
|
|
46
|
-
</details>
|
|
47
|
-
`}};e.n([e.o({type:Boolean})],o.prototype,`defaultOpen`,void 0),e.n([e.o({type:String})],o.prototype,`title`,void 0),e.n([e.o({type:String,reflect:!0})],o.prototype,`skin`,void 0),e.n([e.o({type:Boolean,reflect:!0})],o.prototype,`compact`,void 0),e.n([e.o({type:Boolean,reflect:!0})],o.prototype,`isOpen`,void 0),e.n([e.o({type:String,reflect:!0})],o.prototype,`name`,void 0);try{e.s(`pkt-accordion-item`)(o)}catch{console.warn(`Forsøker å definere <pkt-accordion-item>, men den er allerede definert`)}var s=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
package/dist/button-C_YzTSuU.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { d as e, n as t, o as n, p as r, s as i } from "./element-BoJrqauR.js";
|
|
2
|
-
import { t as a } from "./class-map-CAQCRB1W.js";
|
|
3
|
-
import { n as o, t as s } from "./element-with-slot-mXLg8gg8.js";
|
|
4
|
-
import "./icon-DGFEIlco.js";
|
|
5
|
-
import { t as c } from "./if-defined-D0bnetLJ.js";
|
|
6
|
-
//#region src/components/button/button.ts
|
|
7
|
-
var l = "https://punkt-cdn.oslo.kommune.no/latest/animations/";
|
|
8
|
-
typeof window < "u" && (window.pktAnimationPath = window.pktAnimationPath || l);
|
|
9
|
-
var u = class extends s {
|
|
10
|
-
constructor(...e) {
|
|
11
|
-
super(...e), this.iconName = "user", this.secondIconName = "user", this.mode = "light", this.size = "medium", this.fullWidth = !1, this.fullWidthOnMobile = !1, this.skin = "primary", this.variant = "label-only", this.state = "normal", this.type = "button", this.form = void 0, this.isLoading = !1, this.disabled = !1, this.loadingAnimationPath = typeof window < "u" ? window.pktAnimationPath : l;
|
|
12
|
-
}
|
|
13
|
-
connectedCallback() {
|
|
14
|
-
super.connectedCallback(), this.addEventListener("click", (e) => {
|
|
15
|
-
(this.disabled || this.hasAttribute("disabled") || this.isLoading) && (e.preventDefault(), e.stopImmediatePropagation());
|
|
16
|
-
}, !0), this.addEventListener("keydown", (e) => {
|
|
17
|
-
(this.disabled || this.hasAttribute("disabled") || this.isLoading) && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopImmediatePropagation());
|
|
18
|
-
}, !0);
|
|
19
|
-
}
|
|
20
|
-
attributeChangedCallback(e, t, n) {
|
|
21
|
-
super.attributeChangedCallback(e, t, n), e === "disabled" && n === "false" && (this.disabled = !1), (e === "isloading" || e === "isLoading") && n === "false" && (this.isLoading = !1);
|
|
22
|
-
}
|
|
23
|
-
firstUpdated(e) {
|
|
24
|
-
super.firstUpdated(e), this.disabled === "false" && (this.disabled = !1), this.isLoading === "false" && (this.isLoading = !1);
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
27
|
-
let t = this.form ?? this.getAttribute("form") ?? void 0;
|
|
28
|
-
return r`
|
|
29
|
-
<button
|
|
30
|
-
class=${a({
|
|
31
|
-
"pkt-btn": !0,
|
|
32
|
-
[`pkt-btn--${this.size}`]: !!this.size,
|
|
33
|
-
[`pkt-btn--${this.skin}`]: !!this.skin,
|
|
34
|
-
[`pkt-btn--${this.variant}`]: !!this.variant,
|
|
35
|
-
[`pkt-btn--${this.color}`]: !!this.color,
|
|
36
|
-
[`pkt-btn--${this.state}`]: !!this.state,
|
|
37
|
-
"pkt-btn--full": !!this.fullWidth,
|
|
38
|
-
"pkt-btn--full-small": !!this.fullWidthOnMobile,
|
|
39
|
-
"pkt-btn--disabled": !!this.disabled,
|
|
40
|
-
"pkt-btn--isLoading": !!this.isLoading
|
|
41
|
-
})}
|
|
42
|
-
type=${this.type}
|
|
43
|
-
?disabled=${!!this.disabled}
|
|
44
|
-
aria-busy=${c(this.isLoading ? "true" : void 0)}
|
|
45
|
-
aria-disabled=${c(this.disabled || this.isLoading ? "true" : void 0)}
|
|
46
|
-
form=${c(t)}
|
|
47
|
-
>
|
|
48
|
-
${this.isLoading ? r`<pkt-icon
|
|
49
|
-
class="pkt-btn__icon pkt-btn__spinner"
|
|
50
|
-
name="spinner-blue"
|
|
51
|
-
path=${c(this.loadingAnimationPath)}
|
|
52
|
-
></pkt-icon>` : e}
|
|
53
|
-
${this.variant === "label-only" ? e : r`<pkt-icon
|
|
54
|
-
class="pkt-btn__icon pkt-icon"
|
|
55
|
-
name=${this.iconName}
|
|
56
|
-
path=${c(this.iconPath)}
|
|
57
|
-
></pkt-icon>`}
|
|
58
|
-
<span class="pkt-btn__text">${o(this)}</span>
|
|
59
|
-
${this.variant === "icons-right-and-left" ? r`<pkt-icon
|
|
60
|
-
class="pkt-btn__icon"
|
|
61
|
-
name=${this.secondIconName}
|
|
62
|
-
path=${c(this.secondIconPath)}
|
|
63
|
-
></pkt-icon>` : e}
|
|
64
|
-
</button>
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
t([n({ type: String })], u.prototype, "iconName", void 0), t([n({ type: String })], u.prototype, "secondIconName", void 0), t([n({ type: String })], u.prototype, "iconPath", void 0), t([n({ type: String })], u.prototype, "secondIconPath", void 0), t([n({ type: String })], u.prototype, "mode", void 0), t([n({ type: String })], u.prototype, "size", void 0), t([n({
|
|
69
|
-
type: Boolean,
|
|
70
|
-
attribute: "full-width"
|
|
71
|
-
})], u.prototype, "fullWidth", void 0), t([n({
|
|
72
|
-
type: Boolean,
|
|
73
|
-
attribute: "full-width-on-mobile"
|
|
74
|
-
})], u.prototype, "fullWidthOnMobile", void 0), t([n({ type: String })], u.prototype, "color", void 0), t([n({ type: String })], u.prototype, "skin", void 0), t([n({ type: String })], u.prototype, "variant", void 0), t([n({
|
|
75
|
-
type: String,
|
|
76
|
-
reflect: !0
|
|
77
|
-
})], u.prototype, "state", void 0), t([n({
|
|
78
|
-
type: String,
|
|
79
|
-
reflect: !0
|
|
80
|
-
})], u.prototype, "type", void 0), t([n({ type: String })], u.prototype, "form", void 0), t([n({
|
|
81
|
-
type: Boolean,
|
|
82
|
-
reflect: !0
|
|
83
|
-
})], u.prototype, "isLoading", void 0), t([n({
|
|
84
|
-
type: Boolean,
|
|
85
|
-
reflect: !0
|
|
86
|
-
})], u.prototype, "disabled", void 0), t([n({ type: String })], u.prototype, "loadingAnimationPath", void 0);
|
|
87
|
-
try {
|
|
88
|
-
i("pkt-button")(u);
|
|
89
|
-
} catch {
|
|
90
|
-
console.warn("Forsøker å definere <pkt-button>, men den er allerede definert");
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/components/button/index.ts
|
|
94
|
-
var d = u;
|
|
95
|
-
//#endregion
|
|
96
|
-
export { u as n, d as t };
|