@oslokommune/punkt-elements 19.18.3 → 19.18.4
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 +16 -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/base-elements/input-element.d.ts +3 -0
- 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-4dLJ_HTY.js → checkbox-group-BCtUOlZp.js} +1 -1
- package/dist/{checkbox-group-CREaHr24.cjs → checkbox-group-C3CwgQIq.cjs} +1 -1
- package/dist/{combobox-B-bdCNiE.cjs → combobox-Bfe2p8d8.cjs} +1 -1
- package/dist/{combobox-CVg5vs-l.js → combobox-CXdUSMaA.js} +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/progressbar/progressbar.d.ts +1 -0
- package/dist/components/select/select.d.ts +3 -1
- package/dist/{datepicker-DvI7BT4S.cjs → datepicker-CGpQOyQb.cjs} +3 -3
- package/dist/{datepicker-DeTZy8NM.js → datepicker-DQt_f4MP.js} +6 -3
- package/dist/{fileupload-pGOXdyL0.cjs → fileupload-BrDtkw2A.cjs} +1 -1
- package/dist/{fileupload-iGE2WK9e.js → fileupload-_v5x0RrP.js} +4 -4
- package/dist/{header-B3TDAMMX.cjs → header-BnyUkagz.cjs} +2 -2
- package/dist/{header-A70TKzPE.js → header-CZUjgMNP.js} +14 -5
- package/dist/{header-menu-BK36mG6a.js → header-menu-Bxuz8rw9.js} +1 -1
- package/dist/{header-menu-CWrw01rm.cjs → header-menu-D9ErtEEq.cjs} +1 -1
- 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/{modal-EjPYLhS-.js → modal-BV77IiGH.js} +29 -29
- package/dist/{modal--k988mEb.cjs → modal-i8CzjbyX.cjs} +2 -2
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.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-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-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-index.cjs +1 -1
- package/dist/pkt-index.js +16 -16
- 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-select.cjs +1 -1
- package/dist/pkt-select.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-BVeWeSLq.cjs → progressbar-Do0ZPeMk.cjs} +3 -2
- package/dist/{progressbar-BJswle17.js → progressbar-bamcqcZ2.js} +7 -3
- package/dist/{radio-group-CYEnKuIM.js → radio-group-Dz3a7Dgq.js} +1 -1
- package/dist/{radio-group-DI_5eAL4.cjs → radio-group-iv9QgcSe.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/{select-B2W70m_k.cjs → select-BuikSUfZ.cjs} +1 -1
- package/dist/{select-CeFVfjM-.js → select-CN3d9HWQ.js} +8 -5
- package/dist/{textarea-BBo8oZA-.cjs → textarea-Bb_DpiQc.cjs} +1 -1
- package/dist/{textarea-BOOFnUFu.js → textarea-BdeJyPFA.js} +2 -2
- package/dist/{textinput-wzBD3Tk1.js → textinput-B1fKltx7.js} +2 -2
- package/dist/{textinput-GRYgsT0X.cjs → textinput-B5xO_FmE.cjs} +1 -1
- package/dist/{timepicker-x0PuqU-M.js → timepicker-CUxP-zLZ.js} +1 -1
- package/dist/{timepicker-DLF0UN3M.cjs → timepicker-CmSgKlJ4.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/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
|
@@ -106,12 +106,15 @@ export class PktHeaderService extends PktElementWithSlot<IPktHeader> implements
|
|
|
106
106
|
this.chrome.observe(this.headerRef.value)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
super.
|
|
111
|
-
|
|
109
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
110
|
+
super.willUpdate(changedProperties)
|
|
112
111
|
if (changedProperties.has('openedMenu') && this.openedMenu !== this.openMenu) {
|
|
113
112
|
this.openMenu = this.openedMenu
|
|
114
113
|
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updated(changedProperties: PropertyValues) {
|
|
117
|
+
super.updated(changedProperties)
|
|
115
118
|
|
|
116
119
|
if (changedProperties.has('mobileBreakpoint') || changedProperties.has('tabletBreakpoint')) {
|
|
117
120
|
this.chrome.refreshBreakpoints()
|
|
@@ -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
|
}
|