@oslokommune/punkt-elements 12.3.3 → 12.3.8
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/dist/{class-map-CEzmgstO.js → class-map-Cme3zDHv.js} +1 -1
- package/dist/{class-map-DfznHRRW.cjs → class-map-j1NPDnPL.cjs} +1 -1
- package/dist/{index-BCVyjeWS.cjs → index--Z_thODp.cjs} +1 -1
- package/dist/{index-CkBUiPHx.cjs → index-BoJqccWT.cjs} +6 -6
- package/dist/{index-C7OaW8f8.js → index-CQrIaUIc.js} +1 -1
- package/dist/{index-CINnuWkG.js → index-D16hQiYU.js} +80 -74
- package/dist/{index-BkKs8Yam.js → index-D1du6BqK.js} +101 -99
- package/dist/{index-BkqOsymS.cjs → index-xZNrDhoQ.cjs} +5 -5
- package/dist/index.d.ts +2 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +4 -4
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +4 -4
- package/dist/pkt-card.cjs +3 -3
- package/dist/pkt-card.js +9 -9
- package/dist/pkt-component-template.cjs +1 -1
- package/dist/pkt-component-template.js +3 -3
- package/dist/pkt-datepicker.cjs +31 -40
- package/dist/pkt-datepicker.js +72 -87
- package/dist/pkt-element.cjs +1 -1
- package/dist/pkt-element.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +2 -2
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +2 -2
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +4 -4
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +4 -4
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +4 -4
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +4 -4
- package/dist/{ref-BkUqMgQu.cjs → ref-B5fRDLdm.cjs} +1 -1
- package/dist/{ref-Cau3ksvI.js → ref-CC5SNvNX.js} +1 -1
- package/package.json +3 -3
- package/src/components/calendar/index.ts +19 -3
- package/src/components/card/index.ts +0 -1
- package/src/components/datepicker/index.ts +18 -21
- package/src/components/element/index.ts +22 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.8",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@oslokommune/punkt-assets": "^12.1.0",
|
|
31
|
-
"@oslokommune/punkt-css": "^12.3.
|
|
31
|
+
"@oslokommune/punkt-css": "^12.3.4",
|
|
32
32
|
"sass": "^1.78.0",
|
|
33
33
|
"typescript": "^5.6.2",
|
|
34
34
|
"vite": "^5.4.4",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
56
56
|
},
|
|
57
57
|
"license": "MIT",
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "be4a7ca19fb67b079fe05d9901f891a10ebd02d4"
|
|
59
59
|
}
|
|
@@ -32,9 +32,6 @@ export class PktCalendar extends PktElement {
|
|
|
32
32
|
@property({ type: Boolean, reflect: true })
|
|
33
33
|
withcontrols: boolean = specs.props.withcontrols.default
|
|
34
34
|
|
|
35
|
-
@property({ type: Boolean, reflect: true })
|
|
36
|
-
focused: boolean = false
|
|
37
|
-
|
|
38
35
|
@property({ converter: converters.csvToArray })
|
|
39
36
|
selected: string[] = []
|
|
40
37
|
|
|
@@ -102,6 +99,22 @@ export class PktCalendar extends PktElement {
|
|
|
102
99
|
super.disconnectedCallback()
|
|
103
100
|
}
|
|
104
101
|
|
|
102
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
103
|
+
if (name === 'currentmonth' && value) {
|
|
104
|
+
this.currentmonth = new Date(value)
|
|
105
|
+
this.year = this.currentmonth.getFullYear()
|
|
106
|
+
this.month = this.currentmonth.getMonth()
|
|
107
|
+
this.week = getWeek(new Date(this.year, this.month, 1, 12))
|
|
108
|
+
}
|
|
109
|
+
if (name === 'selected' && value) {
|
|
110
|
+
this._selected = []
|
|
111
|
+
this.selected.forEach((d: string) => {
|
|
112
|
+
this._selected.push(new Date(d))
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
super.attributeChangedCallback(name, _old, value)
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
updated(changedProperties: PropertyValues): void {
|
|
106
119
|
if (changedProperties.has('selected')) {
|
|
107
120
|
if (this.selected.length === 2) {
|
|
@@ -505,6 +518,9 @@ export class PktCalendar extends PktElement {
|
|
|
505
518
|
if (this.selected.includes(this.formatISODate(selectedDate))) return
|
|
506
519
|
this.selected = [...this.selected, this.formatISODate(selectedDate)]
|
|
507
520
|
this._selected = [...this._selected, selectedDate]
|
|
521
|
+
if (this.range && this.selected.length === 2) {
|
|
522
|
+
this.close()
|
|
523
|
+
}
|
|
508
524
|
}
|
|
509
525
|
|
|
510
526
|
public removeFromSelected(selectedDate: Date) {
|
|
@@ -133,17 +133,14 @@ export class PktDatepicker extends PktInputElement {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
136
|
-
super.attributeChangedCallback(name, _old, value)
|
|
137
136
|
if (name === 'value') {
|
|
138
|
-
if (this.value === '' || this.value.length === 0) {
|
|
137
|
+
if (this.value === '' || this.value.length === 0 || typeof this.value === 'undefined') {
|
|
139
138
|
this._value = []
|
|
140
139
|
} else if (this.value.length && this._value.length === 0) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (date && !this._value.includes(date)) {
|
|
144
|
-
this.calRef?.value?.handleDateSelect(this.fromISOToDate(date))
|
|
145
|
-
}
|
|
140
|
+
if (!Array.isArray(this.value) && this.value.includes(',')) {
|
|
141
|
+
this.value = this.value.split(',')
|
|
146
142
|
}
|
|
143
|
+
this._value = !Array.isArray(this.value) ? this.value.split(',') : this.value
|
|
147
144
|
}
|
|
148
145
|
}
|
|
149
146
|
|
|
@@ -154,6 +151,7 @@ export class PktDatepicker extends PktInputElement {
|
|
|
154
151
|
if (name === 'excludeweekdays' && typeof this.excludeweekdays === 'string') {
|
|
155
152
|
this.excludeweekdays = value?.split(',') ?? []
|
|
156
153
|
}
|
|
154
|
+
super.attributeChangedCallback(name, _old, value)
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
@@ -166,6 +164,9 @@ export class PktDatepicker extends PktInputElement {
|
|
|
166
164
|
if (this.range && this._value.length === 1) {
|
|
167
165
|
return
|
|
168
166
|
}
|
|
167
|
+
if (changedProperties.get('value')?.toString() === this.value.toString()) {
|
|
168
|
+
return
|
|
169
|
+
}
|
|
169
170
|
this.onInput(this.value)
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -239,13 +240,12 @@ export class PktDatepicker extends PktInputElement {
|
|
|
239
240
|
class="${classMap(this.inputClasses)}"
|
|
240
241
|
type="date"
|
|
241
242
|
id="${this.id}-input"
|
|
242
|
-
|
|
243
|
-
.value=${this.value}
|
|
243
|
+
value=${this.value}
|
|
244
244
|
min=${this.min}
|
|
245
245
|
max=${this.max}
|
|
246
|
-
@focus=${this.showCalendar}
|
|
247
246
|
@click=${(e: MouseEvent) => {
|
|
248
247
|
e.preventDefault()
|
|
248
|
+
this.showCalendar()
|
|
249
249
|
}}
|
|
250
250
|
?disabled=${this.disabled}
|
|
251
251
|
@blur=${(e: Event) => {
|
|
@@ -268,13 +268,12 @@ export class PktDatepicker extends PktInputElement {
|
|
|
268
268
|
class=${classMap(this.inputClasses)}
|
|
269
269
|
type="date"
|
|
270
270
|
id="${this.id}-input"
|
|
271
|
-
|
|
272
|
-
.value=${this._value[0] ?? ''}
|
|
271
|
+
value=${this._value[0] ?? ''}
|
|
273
272
|
min=${this.min}
|
|
274
273
|
max=${this.max}
|
|
275
|
-
@focus=${this.showCalendar}
|
|
276
274
|
@click=${(e: MouseEvent) => {
|
|
277
275
|
e.preventDefault()
|
|
276
|
+
this.showCalendar()
|
|
278
277
|
}}
|
|
279
278
|
?disabled=${this.disabled}
|
|
280
279
|
@blur=${(e: Event) => {
|
|
@@ -282,7 +281,9 @@ export class PktDatepicker extends PktInputElement {
|
|
|
282
281
|
this.manageValidity(e.target as HTMLInputElement)
|
|
283
282
|
const date = this.fromISOToDate((e.target as HTMLInputElement).value)
|
|
284
283
|
if (date) {
|
|
285
|
-
this.
|
|
284
|
+
if (this._value[0] !== (e.target as HTMLInputElement).value && this._value[1]) {
|
|
285
|
+
this.calRef?.value?.handleDateSelect(date)
|
|
286
|
+
}
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
}}
|
|
@@ -296,13 +297,12 @@ export class PktDatepicker extends PktInputElement {
|
|
|
296
297
|
class=${classMap(this.inputClasses)}
|
|
297
298
|
type="date"
|
|
298
299
|
id="${this.id}-to"
|
|
299
|
-
|
|
300
|
-
.value=${this._value[1] ?? ''}
|
|
300
|
+
value=${this._value[1] ?? ''}
|
|
301
301
|
min=${this.min}
|
|
302
302
|
max=${this.max}
|
|
303
|
-
@focus=${this.showCalendar}
|
|
304
303
|
@click=${(e: MouseEvent) => {
|
|
305
304
|
e.preventDefault()
|
|
305
|
+
this.showCalendar()
|
|
306
306
|
}}
|
|
307
307
|
?disabled=${this.disabled}
|
|
308
308
|
@blur=${(e: Event) => {
|
|
@@ -344,12 +344,11 @@ export class PktDatepicker extends PktInputElement {
|
|
|
344
344
|
class=${classMap(this.inputClasses)}
|
|
345
345
|
type="date"
|
|
346
346
|
id="${this.id}-input"
|
|
347
|
-
name="${this.name}"
|
|
348
347
|
min=${this.min}
|
|
349
348
|
max=${this.max}
|
|
350
|
-
@focus=${this.showCalendar}
|
|
351
349
|
@click=${(e: MouseEvent) => {
|
|
352
350
|
e.preventDefault()
|
|
351
|
+
this.showCalendar()
|
|
353
352
|
}}
|
|
354
353
|
@blur=${(e: Event) => {
|
|
355
354
|
this.addToSelected(e)
|
|
@@ -402,7 +401,6 @@ export class PktDatepicker extends PktInputElement {
|
|
|
402
401
|
?range=${this.range}
|
|
403
402
|
?weeknumbers=${this.weeknumbers}
|
|
404
403
|
?withcontrols=${this.withcontrols}
|
|
405
|
-
?focused=${this.calendarOpen}
|
|
406
404
|
.maxMultiple=${this.maxlength}
|
|
407
405
|
.selected=${this._value}
|
|
408
406
|
.earliest=${this.min}
|
|
@@ -522,7 +520,6 @@ export class PktDatepicker extends PktInputElement {
|
|
|
522
520
|
this.calRef.value.handleDateSelect(date)
|
|
523
521
|
}
|
|
524
522
|
target.value = ''
|
|
525
|
-
this.requestUpdate('value')
|
|
526
523
|
}
|
|
527
524
|
|
|
528
525
|
private handleFocusOut(e: FocusEvent) {
|
|
@@ -157,19 +157,32 @@ export class PktInputElement extends PktElement {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
protected setFormValue(value: string | string[]): void {
|
|
161
|
+
if (this.internals) {
|
|
162
|
+
if (Array.isArray(value)) {
|
|
163
|
+
const form = new FormData()
|
|
164
|
+
value.forEach((v) => {
|
|
165
|
+
form.append(this.name, v)
|
|
166
|
+
})
|
|
167
|
+
this.internals.setFormValue(form)
|
|
168
|
+
} else {
|
|
169
|
+
this.internals.setFormValue(value)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
160
174
|
// Trigger this when you want to set the value of the input out to the form
|
|
161
175
|
protected onInput(value: string | string[]): void {
|
|
162
176
|
if (!this.touched) {
|
|
163
177
|
this.touched = true
|
|
178
|
+
value && this.setFormValue(value)
|
|
164
179
|
return
|
|
165
180
|
}
|
|
166
|
-
console.log('onInput', value)
|
|
167
181
|
if (typeof value !== 'string' && !Array.isArray(value)) {
|
|
168
|
-
console.log('Value must be a string or an array')
|
|
169
182
|
return
|
|
170
183
|
}
|
|
171
184
|
|
|
172
|
-
if (!Array.isArray(value) && value.includes(',')) {
|
|
185
|
+
if ((this.range || this.multiple) && !Array.isArray(value) && value.includes(',')) {
|
|
173
186
|
value = value.split(',')
|
|
174
187
|
}
|
|
175
188
|
|
|
@@ -177,20 +190,21 @@ export class PktInputElement extends PktElement {
|
|
|
177
190
|
value = value[0]
|
|
178
191
|
}
|
|
179
192
|
|
|
193
|
+
this.setFormValue(value)
|
|
194
|
+
|
|
180
195
|
this.manageValidity(this.inputRef.value)
|
|
181
196
|
if (this.inputRef2) {
|
|
182
197
|
this.manageValidity(this.inputRef2.value)
|
|
183
198
|
}
|
|
184
199
|
|
|
185
|
-
|
|
186
|
-
|
|
200
|
+
// This should be moved to a separate trigger for text inputs
|
|
187
201
|
this.dispatchEvent(new Event('input'))
|
|
188
202
|
|
|
203
|
+
// Change events
|
|
189
204
|
this.dispatchEvent(new Event('change'))
|
|
190
|
-
|
|
191
205
|
this.dispatchEvent(
|
|
192
|
-
new CustomEvent('value-
|
|
193
|
-
detail:
|
|
206
|
+
new CustomEvent('value-change', {
|
|
207
|
+
detail: value,
|
|
194
208
|
bubbles: true,
|
|
195
209
|
composed: true,
|
|
196
210
|
}),
|