@oslokommune/punkt-elements 18.6.0 → 18.6.1
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 +17 -0
- package/dist/{checkbox-D6j7amKX.cjs → checkbox-BxDlOeQR.cjs} +1 -1
- package/dist/{checkbox-DcvKYDU2.js → checkbox-U3KfKBLv.js} +1 -1
- package/dist/{combobox-CiT2YvLb.js → combobox-8YJJthxD.js} +1 -1
- package/dist/{combobox-BT1LB0gl.cjs → combobox-CjQiFSKd.cjs} +1 -1
- package/dist/components/datepicker/datepicker-base.d.ts +4 -0
- package/dist/components/datepicker/datepicker.d.ts +3 -1
- package/dist/{datepicker-CqWg6K2N.js → datepicker-9zom2dyI.js} +57 -28
- package/dist/{datepicker-DIgQrvbZ.cjs → datepicker-CN_9JAxo.cjs} +22 -5
- package/dist/{header-DybJSDQQ.cjs → header-D_UJ70pO.cjs} +1 -1
- package/dist/{header-DU10rGhU.js → header-NPxBtRhJ.js} +1 -1
- package/dist/{input-element-uajHIWAO.cjs → input-element-BaXrl0h5.cjs} +1 -1
- package/dist/{input-element-zXKo9jpe.js → input-element-DQri-M3O.js} +2 -2
- 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-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +9 -9
- 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/{radiobutton-BuOLykKo.cjs → radiobutton-DbHXj09u.cjs} +1 -1
- package/dist/{radiobutton-Dr5OQ0IY.js → radiobutton-Dm-IW6aF.js} +1 -1
- package/dist/{select-Cd_saUE7.js → select-B6ZUZ3tj.js} +1 -1
- package/dist/{select-Cc7c9dRd.cjs → select-ZlTO1P9_.cjs} +1 -1
- package/dist/{textarea-xTcafucE.cjs → textarea-BHISs7EC.cjs} +1 -1
- package/dist/{textarea-MJvpE_yV.js → textarea-CTlA6EGR.js} +1 -1
- package/dist/{textinput-B4VnZzsa.cjs → textinput-THsTffFY.cjs} +1 -1
- package/dist/{textinput-Cr7Z9ilH.js → textinput-kp1242Ci.js} +1 -1
- package/dist/{timepicker-srjt12dI.js → timepicker-BBaAVpH_.js} +1 -1
- package/dist/{timepicker-85ViMBd6.cjs → timepicker-Cwy8K6Af.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/datepicker/datepicker-base.ts +14 -0
- package/src/components/datepicker/datepicker-multiple.ts +3 -0
- package/src/components/datepicker/datepicker-range.ts +6 -0
- package/src/components/datepicker/datepicker-single.ts +3 -1
- package/src/components/datepicker/datepicker.accessibility.test.ts +24 -3
- package/src/components/datepicker/datepicker.ts +63 -63
|
@@ -58,7 +58,6 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
58
58
|
* Element attributes and properties
|
|
59
59
|
*/
|
|
60
60
|
private _valueProperty: string = ''
|
|
61
|
-
private _valueProcessing = false
|
|
62
61
|
datepickerPopupRef: Ref<PktDatepickerPopup> = createRef()
|
|
63
62
|
|
|
64
63
|
@property({ type: String, reflect: true })
|
|
@@ -68,8 +67,9 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
68
67
|
|
|
69
68
|
set value(newValue: string | string[]) {
|
|
70
69
|
const oldValue = this._valueProperty
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const raw = Array.isArray(newValue) ? newValue.join(',') : newValue || ''
|
|
71
|
+
if (raw === oldValue) return
|
|
72
|
+
this._valueProperty = raw
|
|
73
73
|
this.requestUpdate('value', oldValue)
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -152,45 +152,43 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
valueChanged(newValue: string | null, oldValue: string | null): void {
|
|
155
|
-
if (
|
|
156
|
-
this.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const parsedValueString = arrayToCsv(filteredValue)
|
|
183
|
-
if (this._valueProperty !== parsedValueString) {
|
|
184
|
-
this._valueProperty = parsedValueString
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// In range mode, don't dispatch events until both dates are selected
|
|
188
|
-
if (this.range && filteredValue.length < 2) return
|
|
189
|
-
|
|
190
|
-
super.valueChanged(parsedValueString, oldValue)
|
|
191
|
-
} finally {
|
|
192
|
-
this._valueProcessing = false
|
|
155
|
+
if (newValue === oldValue) return
|
|
156
|
+
this.value = newValue ?? ''
|
|
157
|
+
this.deriveValue(oldValue)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private deriveValue(oldValue: string | null): void {
|
|
161
|
+
const parsedValue = valueToArray(this._valueProperty)
|
|
162
|
+
|
|
163
|
+
// For multiple dates, filter out invalid ones to prevent accumulating bad dates
|
|
164
|
+
// For single/range dates, preserve user input for validation feedback
|
|
165
|
+
const filteredValue =
|
|
166
|
+
this.multiple && parsedValue.length > 1
|
|
167
|
+
? valueUtils.filterSelectableDates(
|
|
168
|
+
parsedValue,
|
|
169
|
+
this.min,
|
|
170
|
+
this.max,
|
|
171
|
+
this.excludedates,
|
|
172
|
+
this.excludeweekdays,
|
|
173
|
+
)
|
|
174
|
+
: parsedValue
|
|
175
|
+
|
|
176
|
+
if (this.range && !valueUtils.validateRangeOrder(filteredValue)) {
|
|
177
|
+
this._valueProperty = ''
|
|
178
|
+
super.valueChanged('', oldValue)
|
|
179
|
+
this._value = []
|
|
180
|
+
return
|
|
193
181
|
}
|
|
182
|
+
|
|
183
|
+
this._valueProperty = arrayToCsv(filteredValue)
|
|
184
|
+
|
|
185
|
+
// Én dato er ingen fullført periode. Tom er en fullført endring.
|
|
186
|
+
if (!(this.range && filteredValue.length === 1)) {
|
|
187
|
+
super.valueChanged(this._valueProperty, oldValue)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Etter super, som utleder _value fra strengen og gjør '' til [''].
|
|
191
|
+
this._value = filteredValue
|
|
194
192
|
}
|
|
195
193
|
|
|
196
194
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
@@ -204,30 +202,26 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
204
202
|
super.attributeChangedCallback(name, _old, value)
|
|
205
203
|
}
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
205
|
+
private static readonly DERIVED_FROM = [
|
|
206
|
+
'value',
|
|
207
|
+
'multiple',
|
|
208
|
+
'range',
|
|
209
|
+
'min',
|
|
210
|
+
'max',
|
|
211
|
+
'excludedates',
|
|
212
|
+
'excludeweekdays',
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
216
|
+
super.willUpdate(changedProperties)
|
|
217
|
+
|
|
218
|
+
if (PktDatepicker.DERIVED_FROM.some((prop) => changedProperties.has(prop))) {
|
|
217
219
|
const oldValue = changedProperties.get('value')
|
|
218
|
-
|
|
219
|
-
this.valueChanged(newValue, oldValueStr)
|
|
220
|
-
}
|
|
221
|
-
if (changedProperties.has('multiple')) {
|
|
222
|
-
if (this.multiple && !Array.isArray(this._value)) {
|
|
223
|
-
this._value = valueToArray(this.value)
|
|
224
|
-
} else if (!this.multiple && Array.isArray(this._value)) {
|
|
225
|
-
this._value = this._value.filter(Boolean)
|
|
226
|
-
}
|
|
227
|
-
if (!this.multiple && !this.range && Array.isArray(this._value)) {
|
|
228
|
-
this._value = [this._value[0] ?? '']
|
|
229
|
-
}
|
|
220
|
+
this.deriveValue(Array.isArray(oldValue) ? oldValue.join(',') : (oldValue ?? null))
|
|
230
221
|
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
updated(changedProperties: PropertyValues): void {
|
|
231
225
|
// Ytre boks, samme klasser og rolle som Reacts ytre div
|
|
232
226
|
this.classList.add('pkt-datepicker')
|
|
233
227
|
this.classList.toggle('pkt-datepicker--fullwidth', this.fullwidth)
|
|
@@ -311,6 +305,8 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
311
305
|
.inputClasses=${this.inputClasses}
|
|
312
306
|
.inputSize=${this.inputSize}
|
|
313
307
|
.internals=${this.internals}
|
|
308
|
+
.hasError=${this.hasError}
|
|
309
|
+
.hasHelptext=${Boolean(this.helptext || this.helptextDropdown)}
|
|
314
310
|
.strings=${this.strings}
|
|
315
311
|
@toggle-calendar=${(e: CustomEvent) => this.toggleCalendar(e.detail)}
|
|
316
312
|
@input-change=${() => this.onInput()}
|
|
@@ -348,6 +344,8 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
348
344
|
.inputClasses=${this.inputClasses}
|
|
349
345
|
.inputSize=${this.inputSize}
|
|
350
346
|
.internals=${this.internals}
|
|
347
|
+
.hasError=${this.hasError}
|
|
348
|
+
.hasHelptext=${Boolean(this.helptext || this.helptextDropdown)}
|
|
351
349
|
.strings=${this.strings}
|
|
352
350
|
@toggle-calendar=${(e: CustomEvent) => this.toggleCalendar(e.detail)}
|
|
353
351
|
@input-change=${() => this.onInput()}
|
|
@@ -434,6 +432,8 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
434
432
|
.inputClasses=${this.inputClasses}
|
|
435
433
|
.inputSize=${this.inputSize}
|
|
436
434
|
.internals=${this.internals}
|
|
435
|
+
.hasError=${this.hasError}
|
|
436
|
+
.hasHelptext=${Boolean(this.helptext || this.helptextDropdown)}
|
|
437
437
|
.strings=${this.strings}
|
|
438
438
|
@toggle-calendar=${(e: CustomEvent) => this.toggleCalendar(e.detail)}
|
|
439
439
|
@input-change=${() => this.onInput()}
|