@oslokommune/punkt-elements 19.18.3 → 19.18.5
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 +21 -0
- package/dist/{accordion-D-mcyw_S.js → accordion-BHVzR-6Z.js} +2 -2
- package/dist/{accordion-t9p3qgCp.cjs → accordion-Bg4CMrUM.cjs} +1 -1
- package/dist/{alert-CdfTJcT2.js → alert-BAaZIR3e.js} +2 -2
- package/dist/{alert-CBW94-ku.cjs → alert-Dy5N7qK-.cjs} +1 -1
- package/dist/{backlink-GIyyoDoi.cjs → backlink-BnWruRuj.cjs} +1 -1
- package/dist/{backlink-D3rkJWkd.js → backlink-Dlkyj0ns.js} +1 -1
- package/dist/base-elements/input-element.d.ts +3 -0
- package/dist/{breadcrumbs-B4WdX4QR.js → breadcrumbs-Bfv8W2CF.js} +1 -1
- package/dist/{breadcrumbs-B7U57Zey.cjs → breadcrumbs-CyWtnx2B.cjs} +1 -1
- package/dist/{button-DdR_XzMY.cjs → button-BBFI3FuT.cjs} +1 -1
- package/dist/{button-DwcFG7bU.js → button-CF9k3ARf.js} +1 -1
- package/dist/{calendar-DGOwyX3o.js → calendar-BX3n3vhs.js} +1 -1
- package/dist/{calendar-DcenMWOQ.cjs → calendar-Dds9KFiE.cjs} +1 -1
- package/dist/{card-D4rpTD_e.js → card-Ddu0sQ0f.js} +2 -2
- package/dist/{card-CizBnD59.cjs → card-mi3VKIoy.cjs} +1 -1
- package/dist/{checkbox-B6BVu9BZ.cjs → checkbox-B8foyiOW.cjs} +1 -1
- package/dist/{checkbox-BTD7bz3U.js → checkbox-D9-KugOh.js} +1 -1
- package/dist/{checkbox-group-CREaHr24.cjs → checkbox-group-BlBgrzKG.cjs} +1 -1
- package/dist/{checkbox-group-4dLJ_HTY.js → checkbox-group-Dz1ypmbU.js} +2 -2
- package/dist/{combobox-CVg5vs-l.js → combobox-BAkblu9M.js} +4 -4
- package/dist/{combobox-B-bdCNiE.cjs → combobox-DLDvyuDh.cjs} +1 -1
- package/dist/components/accordion/accordionitem.d.ts +1 -1
- package/dist/components/datepicker/datepicker-popup.d.ts +1 -0
- package/dist/components/header/header-chrome-controller.d.ts +5 -0
- package/dist/components/header/header-service.d.ts +1 -0
- package/dist/components/loader/loader.d.ts +5 -36
- package/dist/components/progressbar/progressbar.d.ts +1 -0
- package/dist/components/select/select.d.ts +3 -1
- package/dist/{consent-Chtz1yL0.js → consent-BTw6uqFf.js} +1 -1
- package/dist/{consent-Dhh207Zz.cjs → consent-DNHRe0zV.cjs} +1 -1
- package/dist/{datepicker-DeTZy8NM.js → datepicker-9dmdHweu.js} +10 -7
- package/dist/{datepicker-DvI7BT4S.cjs → datepicker-C7F1Yc5N.cjs} +3 -3
- package/dist/{fileupload-pGOXdyL0.cjs → fileupload-BLAQqG3-.cjs} +1 -1
- package/dist/{fileupload-iGE2WK9e.js → fileupload-D7nEdIgL.js} +7 -7
- package/dist/{footer-D4R-9si6.js → footer-DZ4aA6fj.js} +2 -2
- package/dist/{footer-QGnujLm9.cjs → footer-HFL2sjAY.cjs} +1 -1
- package/dist/{header-B3TDAMMX.cjs → header-Cj08flhl.cjs} +2 -2
- package/dist/{header-A70TKzPE.js → header-Cptdf4fW.js} +18 -9
- package/dist/{header-menu-CWrw01rm.cjs → header-menu-De2DNAXd.cjs} +1 -1
- package/dist/{header-menu-BK36mG6a.js → header-menu-DxOSBiTJ.js} +2 -2
- package/dist/{helptext-BXryqHy5.js → helptext-BVYv8Lm9.js} +1 -1
- package/dist/{helptext-KrtUyA7H.cjs → helptext-BbrFE48Y.cjs} +1 -1
- package/dist/{icon-BVSiUQSL.js → icon-CUU42bZ0.js} +29 -28
- package/dist/icon-CrG6o7ZE.cjs +1 -0
- package/dist/{input-element-a5dcxOzs.cjs → input-element-D82laWtR.cjs} +1 -1
- package/dist/{input-element-8mrCxToc.js → input-element-DczlJQb1.js} +11 -8
- package/dist/{input-wrapper-7RSISZu6.js → input-wrapper-CHwWQgZP.js} +3 -3
- package/dist/{input-wrapper-DT9h0n2i.cjs → input-wrapper-QzdntWJX.cjs} +1 -1
- package/dist/{link-DL4dZoI5.js → link-BU6t5Tt9.js} +1 -1
- package/dist/{link-u69d_-Zh.cjs → link-a1ZK4J1j.cjs} +1 -1
- package/dist/{linkcard-B6N7xChn.cjs → linkcard-Cu4Rh71U.cjs} +1 -1
- package/dist/{linkcard-C_9NCgkD.js → linkcard-DM0CQbwD.js} +1 -1
- package/dist/loader-DwGMavG7.cjs +16 -0
- package/dist/{loader-DJGAd8c-.js → loader-Y8V3Q82X.js} +37 -9
- package/dist/{messagebox-YkknrtEM.cjs → messagebox-DR-s6tyr.cjs} +1 -1
- package/dist/{messagebox-V1Kszdop.js → messagebox-wJcXW5hI.js} +1 -1
- package/dist/{modal-EjPYLhS-.js → modal-Dt35SMQH.js} +30 -30
- package/dist/{modal--k988mEb.cjs → modal-DyaAoMeB.cjs} +2 -2
- package/dist/{option-group-element-BEGRouXw.cjs → option-group-element-CWjgrFwS.cjs} +1 -1
- package/dist/{option-group-element-CQViBzca.js → option-group-element-ZNyUoLcm.js} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-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-group.cjs +1 -1
- package/dist/pkt-checkbox-group.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-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 +36 -36
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.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-BJswle17.js → progressbar-BukfOcRk.js} +8 -4
- package/dist/{progressbar-BVeWeSLq.cjs → progressbar-YfHSPmqI.cjs} +3 -2
- package/dist/{radio-group-CYEnKuIM.js → radio-group-Bg6ODpT3.js} +2 -2
- package/dist/{radio-group-DI_5eAL4.cjs → radio-group-bpIEEMdL.cjs} +1 -1
- package/dist/{radiobutton-DY3tXJ8Z.js → radiobutton-DMvVv81Y.js} +1 -1
- package/dist/{radiobutton-Cf3ROHzB.cjs → radiobutton-IcDc6ze2.cjs} +1 -1
- package/dist/{searchinput-zxHqZ-jG.js → searchinput-BV2C1VbN.js} +1 -1
- package/dist/{searchinput-B1m241pF.cjs → searchinput-DqD_iLxV.cjs} +1 -1
- package/dist/{select-B2W70m_k.cjs → select-CHqM6kI-.cjs} +1 -1
- package/dist/{select-CeFVfjM-.js → select-DKBfPgJB.js} +9 -6
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-types/loader.d.ts +48 -0
- package/dist/{tabs-ZhYxE5fX.js → tabs-B2RjklQl.js} +1 -1
- package/dist/{tabs-fXlMzPFJ.cjs → tabs-BcnYrmjU.cjs} +1 -1
- package/dist/{tag-Bv5JRS69.js → tag-BOTH9kMz.js} +1 -1
- package/dist/{tag-B2EEjkjD.cjs → tag-DrFK8Wq3.cjs} +1 -1
- package/dist/{textarea-BBo8oZA-.cjs → textarea-B5OfR-QI.cjs} +1 -1
- package/dist/{textarea-BOOFnUFu.js → textarea-Du1Z9JUu.js} +4 -4
- package/dist/{textinput-GRYgsT0X.cjs → textinput-75MKBqas.cjs} +1 -1
- package/dist/{textinput-wzBD3Tk1.js → textinput-D_V3b327.js} +4 -4
- package/dist/{timepicker-x0PuqU-M.js → timepicker-DVqTAxt0.js} +3 -3
- package/dist/{timepicker-DLF0UN3M.cjs → timepicker-RxsG0mCF.cjs} +1 -1
- package/package.json +2 -3
- package/src/components/accordion/accordionitem.ts +3 -2
- package/src/components/datepicker/datepicker-popup.ts +5 -1
- package/src/components/datepicker/datepicker.ts +1 -0
- package/src/components/fileupload/fileupload-base.ts +6 -6
- package/src/components/header/header-chrome-controller.ts +18 -5
- package/src/components/header/header-service.ts +6 -3
- package/src/components/loader/loader.test.ts +32 -0
- package/src/components/loader/loader.ts +41 -48
- package/src/components/modal/modal.ts +2 -5
- package/src/components/progressbar/progressbar.ts +8 -2
- package/src/components/select/select.ts +22 -19
- package/src/components/textarea/textarea.ts +3 -0
- package/src/components/textinput/textinput.ts +3 -0
- package/dist/icon-BsRlhXU2.cjs +0 -1
- package/dist/loader-l7CLjzgI.cjs +0 -16
|
@@ -3,65 +3,58 @@ import { classMap } from 'lit/directives/class-map.js'
|
|
|
3
3
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
4
|
import { html, nothing } from 'lit'
|
|
5
5
|
import { slotContent } from '@/directives/slot-content'
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
ANIMATION_DEFAULT_PATH,
|
|
8
|
+
booleanishConverter,
|
|
9
|
+
LOADER_DEFAULTS,
|
|
10
|
+
type IPktLoaderBase,
|
|
11
|
+
type TPktLoaderVariant,
|
|
12
|
+
type TPktSizeBase,
|
|
13
|
+
} from 'shared-types'
|
|
7
14
|
import '@/components/icon'
|
|
8
15
|
|
|
9
|
-
const defaultAnimationPath = 'https://punkt-cdn.oslo.kommune.no/latest/animations/'
|
|
10
|
-
|
|
11
16
|
// Allow global override of animation assets path
|
|
12
17
|
if (typeof window !== 'undefined') {
|
|
13
|
-
window.pktAnimationPath = window.pktAnimationPath ||
|
|
18
|
+
window.pktAnimationPath = window.pktAnimationPath || ANIMATION_DEFAULT_PATH
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
export type TPktLoaderVariant
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Delay time is in milliseconds.
|
|
23
|
-
*/
|
|
24
|
-
delay?: number
|
|
25
|
-
/**
|
|
26
|
-
* The `inline` prop decides whether the loader should be displayed inline or not.
|
|
27
|
-
*/
|
|
28
|
-
inline?: boolean
|
|
29
|
-
/**
|
|
30
|
-
* The boolean 'isLoading' decides whether the loader or the children will be displayed.
|
|
31
|
-
* If set to false, the children will be displayed.
|
|
32
|
-
*/
|
|
33
|
-
isLoading?: boolean
|
|
34
|
-
/**
|
|
35
|
-
* The message to display when the loader is loading.
|
|
36
|
-
*/
|
|
37
|
-
message?: string | null
|
|
38
|
-
/**
|
|
39
|
-
* The size of the loader. Default is "medium".
|
|
40
|
-
*/
|
|
41
|
-
size?: TPktSizeBase
|
|
42
|
-
/**
|
|
43
|
-
* The variant of the loader. Default is "rainbow".
|
|
44
|
-
* "shapes" is the OSLO wave loader, "blue" a blue spinner.
|
|
45
|
-
*/
|
|
46
|
-
variant?: TPktLoaderVariant
|
|
47
|
-
/**
|
|
48
|
-
* Override path to loading animations.
|
|
49
|
-
*/
|
|
50
|
-
loadingAnimationPath?: string
|
|
51
|
-
}
|
|
21
|
+
export type { TPktLoaderVariant }
|
|
22
|
+
export type IPktLoader = IPktLoaderBase
|
|
23
|
+
|
|
24
|
+
// Lowercase names Lit generated before the kebab-case attributes existed.
|
|
25
|
+
const LEGACY_IS_LOADING = 'isloading'
|
|
26
|
+
const LEGACY_LOADING_ANIMATION_PATH = 'loadinganimationpath'
|
|
52
27
|
|
|
53
28
|
export class PktLoader extends PktElementWithSlot implements IPktLoader {
|
|
54
|
-
@property({ type: Number }) delay: number =
|
|
55
|
-
@property({ type: Boolean }) inline: boolean =
|
|
56
|
-
@property({ type: Boolean
|
|
57
|
-
|
|
58
|
-
@property({ type: String })
|
|
59
|
-
@property({ type: String })
|
|
60
|
-
@property({ type: String })
|
|
61
|
-
|
|
29
|
+
@property({ type: Number }) delay: number = LOADER_DEFAULTS.delay
|
|
30
|
+
@property({ type: Boolean }) inline: boolean = LOADER_DEFAULTS.inline
|
|
31
|
+
@property({ type: Boolean, attribute: 'is-loading', converter: booleanishConverter })
|
|
32
|
+
isLoading: boolean = LOADER_DEFAULTS.isLoading
|
|
33
|
+
@property({ type: String }) message: string | null = LOADER_DEFAULTS.message
|
|
34
|
+
@property({ type: String }) size: TPktSizeBase = LOADER_DEFAULTS.size
|
|
35
|
+
@property({ type: String }) variant: TPktLoaderVariant = LOADER_DEFAULTS.variant
|
|
36
|
+
@property({ type: String, attribute: 'loading-animation-path' })
|
|
37
|
+
loadingAnimationPath: string | undefined =
|
|
38
|
+
typeof window !== 'undefined' ? window.pktAnimationPath : ANIMATION_DEFAULT_PATH
|
|
62
39
|
|
|
63
40
|
@state() private _shouldDisplayLoader: boolean = false
|
|
64
41
|
|
|
42
|
+
static get observedAttributes(): string[] {
|
|
43
|
+
return [...super.observedAttributes, LEGACY_IS_LOADING, LEGACY_LOADING_ANIMATION_PATH]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
47
|
+
if (name === LEGACY_IS_LOADING) {
|
|
48
|
+
this.isLoading = booleanishConverter.fromAttribute(value)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
if (name === LEGACY_LOADING_ANIMATION_PATH) {
|
|
52
|
+
this.loadingAnimationPath = value ?? undefined
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
super.attributeChangedCallback(name, _old, value)
|
|
56
|
+
}
|
|
57
|
+
|
|
65
58
|
connectedCallback() {
|
|
66
59
|
super.connectedCallback()
|
|
67
60
|
this._shouldDisplayLoader = this.delay === 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { classMap } from 'lit/directives/class-map.js'
|
|
2
2
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
3
|
-
import { customElement, property
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
4
4
|
import { html, nothing, PropertyValues } from 'lit'
|
|
5
5
|
import { PktElementWithSlot } from '@/base-elements/element-with-slot'
|
|
6
6
|
import { slotContent } from '@/directives/slot-content'
|
|
@@ -57,7 +57,7 @@ export class PktModal extends PktElementWithSlot implements IPktModal {
|
|
|
57
57
|
private readonly _headingId = `pkt-modal__headingText-${this._idSuffix}`
|
|
58
58
|
private readonly _contentId = `pkt-modal__content-${this._idSuffix}`
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
_isOpen: boolean = false
|
|
61
61
|
|
|
62
62
|
constructor() {
|
|
63
63
|
super()
|
|
@@ -143,8 +143,6 @@ export class PktModal extends PktElementWithSlot implements IPktModal {
|
|
|
143
143
|
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
144
144
|
)
|
|
145
145
|
if (!bypassNativeClose) this.dialogRef.value?.close()
|
|
146
|
-
|
|
147
|
-
this.requestUpdate()
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
public showModal = (event: Event | null = null) => {
|
|
@@ -156,7 +154,6 @@ export class PktModal extends PktElementWithSlot implements IPktModal {
|
|
|
156
154
|
this.dispatchEvent(
|
|
157
155
|
new CustomEvent('showModal', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
158
156
|
)
|
|
159
|
-
this.requestUpdate()
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
render() {
|
|
@@ -57,13 +57,14 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
|
57
57
|
@property({ type: Number }) valueMin = 0
|
|
58
58
|
|
|
59
59
|
// State
|
|
60
|
-
|
|
60
|
+
private labelWidth = 0
|
|
61
61
|
@state() private progressbarId: string = this.id
|
|
62
62
|
@state() private resolvedRole: TProgressbarRole = 'progressbar'
|
|
63
63
|
|
|
64
64
|
// Private refs
|
|
65
65
|
private labelRef: Ref<HTMLSpanElement> = createRef()
|
|
66
66
|
private progressBarRef: Ref<HTMLDivElement> = createRef()
|
|
67
|
+
private containerRef: Ref<HTMLDivElement> = createRef()
|
|
67
68
|
|
|
68
69
|
protected willUpdate(changedProperties: Map<string | number | symbol, unknown>) {
|
|
69
70
|
super.willUpdate(changedProperties)
|
|
@@ -85,7 +86,11 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
|
85
86
|
super.updated(changedProperties)
|
|
86
87
|
|
|
87
88
|
if (changedProperties.has('valueCurrent') && this.labelRef.value) {
|
|
88
|
-
|
|
89
|
+
const width = this.labelRef.value.getBoundingClientRect().width || 0
|
|
90
|
+
if (width !== this.labelWidth) {
|
|
91
|
+
this.labelWidth = width
|
|
92
|
+
this.containerRef.value?.style.setProperty('--pkt-progress-label-width', `${width}px`)
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
|
|
@@ -140,6 +145,7 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
|
140
145
|
class="pkt-progressbar"
|
|
141
146
|
>
|
|
142
147
|
<div
|
|
148
|
+
${ref(this.containerRef)}
|
|
143
149
|
class="pkt-progressbar__container"
|
|
144
150
|
style=${styleMap({
|
|
145
151
|
'--pkt-progress-label-width': `${this.labelWidth}px`,
|
|
@@ -50,6 +50,7 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
|
|
|
50
50
|
|
|
51
51
|
public selectedIndex: number | null = -1
|
|
52
52
|
public selectedOptions: HTMLCollectionOf<HTMLOptionElement> | undefined = undefined
|
|
53
|
+
private defaultedToFirstOption = false
|
|
53
54
|
|
|
54
55
|
constructor() {
|
|
55
56
|
super()
|
|
@@ -145,19 +146,31 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
|
|
|
145
146
|
super.attributeChangedCallback(name, _old, value)
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
super.update(changedProperties)
|
|
149
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
150
150
|
if (changedProperties.has('_optionsProp') && this._optionsProp.length > 0) {
|
|
151
151
|
this._options = this._optionsProp
|
|
152
|
-
this.requestUpdate('_options')
|
|
153
|
-
|
|
154
|
-
// If no value is set and we have options, set to first option
|
|
155
152
|
if (!this.value && this._options.length > 0) {
|
|
156
|
-
// eslint-disable-next-line lit/no-property-change-update -- Initial value setup is intentional
|
|
157
153
|
this.value = this._options[0].value
|
|
158
154
|
this.selectedIndex = 0
|
|
159
155
|
}
|
|
160
156
|
}
|
|
157
|
+
super.willUpdate(changedProperties)
|
|
158
|
+
if (!this.hasUpdated) {
|
|
159
|
+
if (!this.value && this._options.length > 0) {
|
|
160
|
+
this.value = this._options[0].value
|
|
161
|
+
this.selectedIndex = 0
|
|
162
|
+
this.defaultedToFirstOption = true
|
|
163
|
+
} else {
|
|
164
|
+
this.selectedIndex = this._options.findIndex((option) => option.value === this.value)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (changedProperties.has('id')) {
|
|
168
|
+
!this.name && this.id && (this.name = this.id)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected updated(changedProperties: PropertyValues): void {
|
|
173
|
+
super.updated(changedProperties)
|
|
161
174
|
if (changedProperties.has('value') && this.value !== changedProperties.get('value')) {
|
|
162
175
|
this.selectedIndex = this.touched
|
|
163
176
|
? this.returnNumberOrNull(this.inputRef.value?.selectedIndex)
|
|
@@ -165,25 +178,15 @@ export class PktSelect extends PktOptionsInputElement<{}, TSelectOption> impleme
|
|
|
165
178
|
this.selectedOptions = this.inputRef.value?.selectedOptions
|
|
166
179
|
this.valueChanged(this.value, changedProperties.get('value'))
|
|
167
180
|
}
|
|
168
|
-
if (changedProperties.has('id')) {
|
|
169
|
-
!this.name && this.id && (this.name = this.id)
|
|
170
|
-
}
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
174
184
|
super.firstUpdated(_changedProperties)
|
|
175
185
|
this.classList.add('pkt-select')
|
|
176
|
-
if (this._optionsProp.length) {
|
|
177
|
-
this._options = this._optionsProp
|
|
178
|
-
}
|
|
179
|
-
// If no options are selected, set value and selectedIndex to the first option
|
|
180
|
-
if (!this.value && this._options.length > 0) {
|
|
181
|
-
this.value = this._options[0].value
|
|
182
|
-
this.selectedIndex = 0
|
|
183
|
-
} else {
|
|
184
|
-
this.selectedIndex = this._options.findIndex((option) => option.value === this.value)
|
|
185
|
-
}
|
|
186
186
|
this.selectedOptions = this.inputRef.value?.selectedOptions
|
|
187
|
+
if (this.defaultedToFirstOption) {
|
|
188
|
+
this.updateComplete.then(() => this.dispatchChangeEvents(this.value))
|
|
189
|
+
}
|
|
187
190
|
}
|
|
188
191
|
|
|
189
192
|
render() {
|
|
@@ -65,6 +65,9 @@ export class PktTextarea extends PktInputElement<Props> implements IPktTextarea
|
|
|
65
65
|
|
|
66
66
|
protected willUpdate(changedProperties: PropertyValues) {
|
|
67
67
|
super.willUpdate(changedProperties)
|
|
68
|
+
if (changedProperties.has('value') && typeof this.value !== 'string' && !Array.isArray(this.value)) {
|
|
69
|
+
this.value = this.coerceToString(this.value)
|
|
70
|
+
}
|
|
68
71
|
if (changedProperties.has('value')) {
|
|
69
72
|
this.counterCurrent = this.value?.length || 0
|
|
70
73
|
}
|
|
@@ -46,6 +46,9 @@ export class PktTextinput extends PktInputElement<Props> {
|
|
|
46
46
|
|
|
47
47
|
protected willUpdate(changedProperties: PropertyValues) {
|
|
48
48
|
super.willUpdate(changedProperties)
|
|
49
|
+
if (changedProperties.has('value') && typeof this.value !== 'string' && !Array.isArray(this.value)) {
|
|
50
|
+
this.value = this.coerceToString(this.value)
|
|
51
|
+
}
|
|
49
52
|
if (changedProperties.has('value')) {
|
|
50
53
|
this.counterCurrent = this.value?.length || 0
|
|
51
54
|
}
|
package/dist/icon-BsRlhXU2.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs");require("./shared-types-BvRk9kiK.cjs");var t={name:``,path:`https://punkt-cdn.oslo.kommune.no/latest/icons/`},n=class extends e.p{constructor(t){if(super(t),this.it=e.h,t.type!==e.m.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(t){if(t===e.h||t==null)return this._t=void 0,this.it=t;if(t===e.g)return t;if(typeof t!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(t===this.it)return this._t;this.it=t;let n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};n.directiveName=`unsafeHTML`,n.resultType=1;var r=e.f(n),i=class extends n{};i.directiveName=`unsafeSVG`,i.resultType=2;var a=e.f(i);typeof window<`u`&&(window.pktFetch=window.pktFetch===void 0?fetch:window.pktFetch,window.pktIconPath=window.pktIconPath||t.path);var o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>`,s={},c=2,l=1500,u=(()=>{try{return typeof Storage<`u`&&typeof sessionStorage<`u`}catch{return!1}})(),d=e=>window.pktFetch(e).then(t=>{if(!t.ok)throw Error(`Missing icon: `+e);return t.text()}),f=async(e,t=c)=>{try{return await d(e)}catch{return t>0?(await new Promise(e=>setTimeout(e,l)),f(e,t-1)):(console.error(`Failed to fetch icon: `+e),o)}},p=async(e,t)=>{let n=t+e+`.svg`;return u&&sessionStorage.getItem(n)?sessionStorage.getItem(n):n in s?s[n]:typeof window<`u`&&typeof window.pktFetch==`function`?(s[n]=f(n).then(e=>(e!==o&&u&&sessionStorage.setItem(n,e),delete s[n],e)),s[n]):o},m=class extends e.t{constructor(...e){super(...e),this.path=typeof window<`u`?window.pktIconPath:t.path,this.name=t.name,this.ariaHidden=null,this.ariaLabel=null,this.icon=a(o),this._updatedProps=[]}get effectiveAriaHidden(){return this.ariaHidden!==null&&this.ariaHidden!==void 0?this.ariaHidden===``||this.ariaHidden===`true`:!this.ariaLabel}get effectiveAriaLabel(){return this.effectiveAriaHidden?null:this.ariaLabel||this.name||null}connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-icon`)}async attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),(e===`name`||e===`path`)&&this.getIcon(this.name)}async updated(e){super.updated(e),(e.has(`name`)||e.has(`path`))&&this.getIcon(this.name),this.applyAriaToSvg()}applyAriaToSvg(){let e=this.querySelector(`svg`);if(!e)return;e.setAttribute(`aria-hidden`,String(this.effectiveAriaHidden));let t=this.effectiveAriaLabel;t?e.setAttribute(`aria-label`,t):e.removeAttribute(`aria-label`)}async getIcon(e=``){if(this._updatedProps.length>0){this.path||=typeof window<`u`?window.pktIconPath:t.path;try{this.icon=a(await p(this.name||``,this.path))}catch{this.icon=a(o)}this._updatedProps=[]}else this._updatedProps.includes(e)||this._updatedProps.push(e)}render(){return e._`${this.name&&this.icon}`}};e.n([e.u({type:String,reflect:!1})],m.prototype,`path`,void 0),e.n([e.u({type:String,reflect:!0})],m.prototype,`name`,void 0),e.n([e.u({type:String,attribute:`aria-hidden`,reflect:!0})],m.prototype,`ariaHidden`,void 0),e.n([e.u({type:String,attribute:`aria-label`,reflect:!0})],m.prototype,`ariaLabel`,void 0),e.n([e.u({type:SVGElement})],m.prototype,`icon`,void 0),e.n([e.u({type:Array,noAccessor:!0})],m.prototype,`_updatedProps`,void 0);try{e.d(`pkt-icon`)(m)}catch{console.warn(`Forsøker å definere <pkt-icon>, men den er allerede definert`)}var h=m;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
package/dist/loader-l7CLjzgI.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-B0Vp_OuR.cjs");require("./icon-BsRlhXU2.cjs");var r=`https://punkt-cdn.oslo.kommune.no/latest/animations/`;typeof window<`u`&&(window.pktAnimationPath=window.pktAnimationPath||r);var i=class extends n.t{constructor(...e){super(...e),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size=`medium`,this.variant=`rainbow`,this.loadingAnimationPath=typeof window<`u`?window.pktAnimationPath:r,this._shouldDisplayLoader=!1}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(e){e.has(`delay`)&&this.setupLoader()}render(){let r=t.t({"pkt-loader":!0,[`pkt-loader--${this.inline?`inline`:`box`}`]:!0,[`pkt-loader--${this.size}`]:!0}),i=t.t({"pkt-contents":!0,"pkt-hide":this.isLoading});return e._`<div
|
|
2
|
-
role="status"
|
|
3
|
-
aria-live="polite"
|
|
4
|
-
aria-busy=${this.isLoading?`true`:`false`}
|
|
5
|
-
class=${r}
|
|
6
|
-
>
|
|
7
|
-
${this.isLoading&&this._shouldDisplayLoader?e._`<div class="pkt-loader__spinner">
|
|
8
|
-
<pkt-icon
|
|
9
|
-
name=${this.getVariant(this.variant)}
|
|
10
|
-
path=${this.loadingAnimationPath}
|
|
11
|
-
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
12
|
-
></pkt-icon>
|
|
13
|
-
${this.message&&e._`<p>${this.message}</p>`}
|
|
14
|
-
</div>`:e.h}
|
|
15
|
-
<div class=${i}>${n.i(this)}</div>
|
|
16
|
-
</div>`}getVariant(e){switch(e){case`blue`:return`spinner-blue`;case`rainbow`:return`spinner`;default:return`loader`}}setupLoader(){this.delay>0&&(this._shouldDisplayLoader=!1,setTimeout(()=>{this._shouldDisplayLoader=!0,this.requestUpdate()},this.delay))}};e.n([e.u({type:Number})],i.prototype,`delay`,void 0),e.n([e.u({type:Boolean})],i.prototype,`inline`,void 0),e.n([e.u({type:Boolean})],i.prototype,`isLoading`,void 0),e.n([e.u({type:String})],i.prototype,`message`,void 0),e.n([e.u({type:String})],i.prototype,`size`,void 0),e.n([e.u({type:String})],i.prototype,`variant`,void 0),e.n([e.u({type:String})],i.prototype,`loadingAnimationPath`,void 0),e.n([e.l()],i.prototype,`_shouldDisplayLoader`,void 0);try{e.d(`pkt-loader`)(i)}catch{console.warn(`Forsøker å definere <pkt-loader>, men den er allerede definert`)}var a=i;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|