@oslokommune/punkt-elements 13.5.9 → 13.5.10
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/{datepicker-CmTrG5GE.cjs → datepicker-DonUad47.cjs} +28 -28
- package/dist/{datepicker-BJKJBoy_.js → datepicker-F3TwE9o7.js} +88 -96
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +1 -1
- package/package.json +2 -2
- package/src/components/datepicker/datepicker.ts +15 -34
- package/src/components/datepicker/datepicker.validation.test.ts +21 -29
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [13.5.10](https://github.com/oslokommune/punkt/compare/13.5.9...13.5.10) (2025-09-11)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
8
25
|
## [13.5.9](https://github.com/oslokommune/punkt/compare/13.5.8...13.5.9) (2025-09-11)
|
|
9
26
|
|
|
10
27
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-BBG2gMX4.cjs"),
|
|
1
|
+
"use strict";const d=require("./class-map-BBG2gMX4.cjs"),h=require("./if-defined-Cni-RHLS.cjs"),s=require("./element-6DBpyGQm.cjs"),v=require("./state-DPobt-Yz.cjs"),o=require("./calendar-32W9p9uc.cjs"),m=require("./input-element-C4xJoM-X.cjs"),r=require("./ref-iJtiv3o2.cjs"),y=require("./repeat-CDsZqct8.cjs");require("./icon-B_ryAy4Q.cjs");require("./input-wrapper-CZ-a00V7.cjs");require("./tag-Bbs0U_Au.cjs");const k=require("./pkt-slot-controller-BzddBp7z.cjs"),$={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},p={props:$};var b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(c,t,e,i)=>{for(var a=i>1?void 0:i?x(t,e):t,l=c.length-1,u;l>=0;l--)(u=c[l])&&(a=(i?u(t,e,a):u(a))||a);return i&&a&&b(t,e,a),a};const g=c=>new Promise(t=>setTimeout(t,c));exports.PktDatepicker=class extends m.PktInputElement{constructor(){super(),this._valueProperty="",this._value=[],this.label="Datovelger",this.dateformat=p.props.dateformat.default,this.multiple=p.props.multiple.default,this.maxlength=null,this.range=p.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=p.props.weeknumbers.default,this.withcontrols=p.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=r.e(),this.inputRefTo=r.e(),this.btnRef=r.e(),this.calRef=r.e(),this.popupRef=r.e(),this.helptextSlot=r.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?o.newDate(this.min):null,a=this.max?o.newDate(this.max):null,l=o.newDate(e.value.split(",")[0]);l&&!isNaN(l.getTime())&&(!i||l>=i)&&(!a||l<=a)&&this.calRef.value&&this.calRef.value.handleDateSelect(l),e.value=""},this.slotController=new k.PktSlotController(this,this.helptextSlot)}get value(){return this._valueProperty}set value(t){const e=this._valueProperty;this._valueProperty=Array.isArray(t)?t.join(","):t||"",this.valueChanged(this._valueProperty,e),this.requestUpdate("value",e)}async connectedCallback(){super.connectedCallback();const t=navigator.userAgent,e=/iP(hone|od|ad)/.test(t);this.inputType=e?"text":"date",document&&document.body.addEventListener("click",i=>{var a,l;(a=this.inputRef)!=null&&a.value&&((l=this.btnRef)!=null&&l.value)&&!this.inputRef.value.contains(i.target)&&!(this.inputRefTo.value&&this.inputRefTo.value.contains(i.target))&&!this.btnRef.value.contains(i.target)&&!i.target.closest(".pkt-calendar-popup")&&this.calendarOpen&&(this.onBlur(),this.hideCalendar())}),document&&document.body.addEventListener("keydown",i=>{i.key==="Escape"&&this.calendarOpen&&this.hideCalendar()}),this.value&&(this._value=Array.isArray(this.value)?this.value.filter(Boolean):this.value.split(",").filter(Boolean)),this.min=this.min||p.props.min.default,this.max=this.max||p.props.max.default,typeof this.excludedates=="string"&&(this.excludedates=this.excludedates.split(",")),typeof this.excludeweekdays=="string"&&(this.excludeweekdays=this.excludeweekdays.split(",")),(this.multiple||this.range)&&this.name&&!this.name.endsWith("[]")&&(this.name=this.name+"[]"),this.calendarOpen&&(await g(20),this.handleCalendarPosition())}disconnectedCallback(){super.disconnectedCallback(),document&&document.body.removeEventListener("click",t=>{var e,i;(e=this.inputRef)!=null&&e.value&&((i=this.btnRef)!=null&&i.value)&&!this.inputRef.value.contains(t.target)&&!this.btnRef.value.contains(t.target)&&this.hideCalendar()})}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(t,e){if(t===e)return;let i=[];t&&(typeof t=="string"?i=t.split(",").filter(Boolean):i=String(t).split(",").filter(Boolean)),this._value=i;const a=i.join(",");this._valueProperty!==a&&(this._valueProperty=a),super.valueChanged(a,e)}attributeChangedCallback(t,e,i){t==="value"&&this.value!==e&&this.valueChanged(i,e),t==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=(i==null?void 0:i.split(","))??[]),t==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=(i==null?void 0:i.split(","))??[]),super.attributeChangedCallback(t,e,i)}updated(t){if(t.has("value")){const e=Array.isArray(this.value)?this.value.join(","):this.value,i=t.get("value"),a=Array.isArray(i)?i.join(","):i;this.valueChanged(e,a)}t.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=typeof this.value=="string"?this.value?this.value.split(",").filter(Boolean):[]:[]:!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(t)}renderInput(){return s.x`
|
|
2
2
|
<input
|
|
3
3
|
class="${d.e(this.inputClasses)}"
|
|
4
4
|
.type=${this.inputType}
|
|
5
5
|
id="${this.id}-input"
|
|
6
6
|
.value=${this._value[0]??""}
|
|
7
|
-
min=${
|
|
8
|
-
max=${
|
|
9
|
-
placeholder=${
|
|
7
|
+
min=${h.o(this.min)}
|
|
8
|
+
max=${h.o(this.max)}
|
|
9
|
+
placeholder=${h.o(this.placeholder)}
|
|
10
10
|
?readonly=${this.readonly}
|
|
11
11
|
aria-describedby="${this.id}-helptext"
|
|
12
12
|
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
@@ -18,57 +18,57 @@
|
|
|
18
18
|
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
19
19
|
${r.n(this.inputRef)}
|
|
20
20
|
/>
|
|
21
|
-
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return
|
|
22
|
-
${this.showRangeLabels?
|
|
21
|
+
`}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
|
|
22
|
+
${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
|
|
23
23
|
<input
|
|
24
24
|
class=${d.e(this.inputClasses)}
|
|
25
25
|
.type=${this.inputType}
|
|
26
26
|
id="${this.id}-input"
|
|
27
27
|
.value=${this._value[0]??""}
|
|
28
|
-
min=${
|
|
29
|
-
max=${
|
|
30
|
-
placeholder=${
|
|
28
|
+
min=${h.o(this.min)}
|
|
29
|
+
max=${h.o(this.max)}
|
|
30
|
+
placeholder=${h.o(this.placeholder)}
|
|
31
31
|
?readonly=${this.readonly}
|
|
32
32
|
?disabled=${this.disabled}
|
|
33
33
|
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
34
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRef.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const
|
|
34
|
+
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRef.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.focus()}}}
|
|
35
35
|
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
36
36
|
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
37
|
-
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const
|
|
37
|
+
@blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=o.fromISOToDate(e.target.value);l&&this._value[0]!==e.target.value&&this._value[1]&&(this.clearInputValue(),(a=(i=this.calRef)==null?void 0:i.value)==null||a.handleDateSelect(l))}else this._value[0]&&this.clearInputValue()}}
|
|
38
38
|
@change=${e=>{e.stopImmediatePropagation()}}
|
|
39
39
|
${r.n(this.inputRef)}
|
|
40
40
|
/>
|
|
41
41
|
<div class="${d.e(t)}" id="${this.id}-to-label">
|
|
42
42
|
${this.strings.generic.to}
|
|
43
43
|
</div>
|
|
44
|
-
${this.showRangeLabels?
|
|
44
|
+
${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
|
|
45
45
|
<input
|
|
46
46
|
class=${d.e(this.inputClasses)}
|
|
47
47
|
.type=${this.inputType}
|
|
48
48
|
id="${this.id}-to"
|
|
49
49
|
aria-labelledby="${this.id}-to-label"
|
|
50
50
|
.value=${this._value[1]??""}
|
|
51
|
-
min=${
|
|
52
|
-
max=${
|
|
53
|
-
placeholder=${
|
|
51
|
+
min=${h.o(this.min)}
|
|
52
|
+
max=${h.o(this.max)}
|
|
53
|
+
placeholder=${h.o(this.placeholder)}
|
|
54
54
|
?readonly=${this.readonly}
|
|
55
55
|
?disabled=${this.disabled}
|
|
56
56
|
@click=${e=>{e.preventDefault(),this.showCalendar()}}
|
|
57
|
-
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRefTo.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const
|
|
57
|
+
@keydown=${e=>{var i,a;if(e.key===","&&((i=this.inputRefTo.value)==null||i.blur()),(e.key==="Space"||e.key===" ")&&(e.preventDefault(),this.toggleCalendar(e)),e.key==="Enter"){const l=this.internals.form;l?l.requestSubmit():(a=this.inputRefTo.value)==null||a.blur()}}}
|
|
58
58
|
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
59
59
|
@focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
|
|
60
|
-
@blur=${e=>{var i,a,
|
|
60
|
+
@blur=${e=>{var i,a,l;if((i=this.calRef.value)!=null&&i.contains(e.relatedTarget)||this.onBlur(),e.target.value){this.manageValidity(e.target);const u=e.target.value;this.min&&this.min>u?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<u&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const f=o.fromISOToDate(e.target.value);f&&this._value[1]!==o.formatISODate(f)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(f))}}}
|
|
61
61
|
@change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
|
|
62
62
|
${r.n(this.inputRefTo)}
|
|
63
63
|
/>
|
|
64
|
-
`}renderMultipleInput(){return
|
|
64
|
+
`}renderMultipleInput(){return s.x`
|
|
65
65
|
<input
|
|
66
66
|
class=${d.e(this.inputClasses)}
|
|
67
67
|
.type=${this.inputType}
|
|
68
68
|
id="${this.id}-input"
|
|
69
|
-
min=${
|
|
70
|
-
max=${
|
|
71
|
-
placeholder=${
|
|
69
|
+
min=${h.o(this.min)}
|
|
70
|
+
max=${h.o(this.max)}
|
|
71
|
+
placeholder=${h.o(this.placeholder)}
|
|
72
72
|
?readonly=${this.readonly}
|
|
73
73
|
?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
|
|
74
74
|
@click=${t=>{t.preventDefault(),this.showCalendar()}}
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
@change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
|
|
80
80
|
${r.n(this.inputRef)}
|
|
81
81
|
/>
|
|
82
|
-
`}renderTags(){return
|
|
82
|
+
`}renderTags(){return s.x`
|
|
83
83
|
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
84
|
-
${this._value[0]?
|
|
84
|
+
${this._value[0]?y.c((this._value??[]).filter(Boolean).sort(),t=>t,t=>s.x`
|
|
85
85
|
<pkt-tag
|
|
86
86
|
.id="${this.id+t+"-tag"}"
|
|
87
87
|
closeTag
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
@close=${()=>{var e;return(e=this.calRef.value)==null?void 0:e.handleDateSelect(o.fromISOToDate(t))}}
|
|
90
90
|
><time datetime="${t}">${o.fromISOtoLocal(t,this.dateformat)}</time></pkt-tag
|
|
91
91
|
>
|
|
92
|
-
`):
|
|
92
|
+
`):s.E}
|
|
93
93
|
</div>
|
|
94
|
-
`}renderCalendar(){return
|
|
94
|
+
`}renderCalendar(){return s.x`<div
|
|
95
95
|
class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
|
|
96
96
|
@focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
|
|
97
97
|
id="${this.id}-popup"
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
115
115
|
${r.n(this.calRef)}
|
|
116
116
|
></pkt-calendar>
|
|
117
|
-
</div>`}render(){return this.inputClasses={"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-datepicker--hasrangelabels":this.showRangeLabels,"pkt-datepicker--multiple":this.multiple,"pkt-datepicker--range":this.range},this.buttonClasses={"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0},
|
|
117
|
+
</div>`}render(){return this.inputClasses={"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-datepicker--hasrangelabels":this.showRangeLabels,"pkt-datepicker--multiple":this.multiple,"pkt-datepicker--range":this.range},this.buttonClasses={"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0},s.x`
|
|
118
118
|
<pkt-input-wrapper
|
|
119
119
|
label="${this.label}"
|
|
120
120
|
forId="${this.id}-input"
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
class="pkt-datepicker"
|
|
141
141
|
>
|
|
142
142
|
<div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
143
|
-
${this.multiple?this.renderTags():
|
|
143
|
+
${this.multiple?this.renderTags():s.E}
|
|
144
144
|
<div
|
|
145
145
|
class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
|
|
146
146
|
>
|
|
@@ -161,4 +161,4 @@
|
|
|
161
161
|
</div>
|
|
162
162
|
</pkt-input-wrapper>
|
|
163
163
|
${this.renderCalendar()}
|
|
164
|
-
`}handleCalendarPosition(){var t;if(this.popupRef.value&&this.inputRef.value){const e=this.multiple&&!!this.maxlength,i=((t=this.inputRef.value.parentElement)==null?void 0:t.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),a=e?i.height+30:i.height,
|
|
164
|
+
`}handleCalendarPosition(){var t;if(this.popupRef.value&&this.inputRef.value){const e=this.multiple&&!!this.maxlength,i=((t=this.inputRef.value.parentElement)==null?void 0:t.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),a=e?i.height+30:i.height,l=this.popupRef.value.getBoundingClientRect().height;let u=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(u=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=u}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await g(20),this.handleCalendarPosition(),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(t){t.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=""}};n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);n([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);n([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);n([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);n([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);n([s.n({converter:o.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);n([s.n({converter:o.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);n([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);n([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);n([v.r()],exports.PktDatepicker.prototype,"inputClasses",2);n([v.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=n([s.t("pkt-datepicker")],exports.PktDatepicker);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { e as f } from "./class-map-BpTj9gtz.js";
|
|
2
|
-
import { o } from "./if-defined-CmuO4Vz9.js";
|
|
3
|
-
import { x as
|
|
4
|
-
import { r as
|
|
5
|
-
import { n as
|
|
6
|
-
import { P as
|
|
7
|
-
import { e as m, n as
|
|
8
|
-
import { c as
|
|
2
|
+
import { o as h } from "./if-defined-CmuO4Vz9.js";
|
|
3
|
+
import { x as u, E as g, n as r, a as R } from "./element-CgEWt74-.js";
|
|
4
|
+
import { r as k } from "./state-Bo2bck5_.js";
|
|
5
|
+
import { n as v, f as y, a as w, b as $, p as C, d as x } from "./calendar-CJSxvwAq.js";
|
|
6
|
+
import { P as _ } from "./input-element-NnrDmp4r.js";
|
|
7
|
+
import { e as m, n as p } from "./ref-BBYSqgeW.js";
|
|
8
|
+
import { c as S } from "./repeat-C8BeHwYx.js";
|
|
9
9
|
import "./icon-CC1js8eR.js";
|
|
10
10
|
import "./input-wrapper-Dr__Sxql.js";
|
|
11
11
|
import "./tag-DyXzTY68.js";
|
|
12
|
-
import { P as
|
|
13
|
-
const
|
|
12
|
+
import { P as T } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
13
|
+
const D = {
|
|
14
14
|
dateformat: {
|
|
15
15
|
default: "dd.MM.yyyy"
|
|
16
16
|
},
|
|
@@ -33,15 +33,15 @@ const I = {
|
|
|
33
33
|
default: !1
|
|
34
34
|
}
|
|
35
35
|
}, c = {
|
|
36
|
-
props:
|
|
36
|
+
props: D
|
|
37
37
|
};
|
|
38
|
-
var
|
|
39
|
-
for (var
|
|
40
|
-
(
|
|
41
|
-
return
|
|
38
|
+
var I = Object.defineProperty, P = Object.getOwnPropertyDescriptor, n = (t, e, i, s) => {
|
|
39
|
+
for (var a = s > 1 ? void 0 : s ? P(e, i) : e, o = t.length - 1, d; o >= 0; o--)
|
|
40
|
+
(d = t[o]) && (a = (s ? d(e, i, a) : d(a)) || a);
|
|
41
|
+
return s && a && I(e, i, a), a;
|
|
42
42
|
};
|
|
43
|
-
const
|
|
44
|
-
let l = class extends
|
|
43
|
+
const b = (t) => new Promise((e) => setTimeout(e, t));
|
|
44
|
+
let l = class extends _ {
|
|
45
45
|
/**
|
|
46
46
|
* Housekeeping / lifecycle methods
|
|
47
47
|
*/
|
|
@@ -49,9 +49,9 @@ let l = class extends S {
|
|
|
49
49
|
super(), this._valueProperty = "", this._value = [], this.label = "Datovelger", this.dateformat = c.props.dateformat.default, this.multiple = c.props.multiple.default, this.maxlength = null, this.range = c.props.range.default, this.showRangeLabels = !1, this.min = null, this.max = null, this.weeknumbers = c.props.weeknumbers.default, this.withcontrols = c.props.withcontrols.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.buttonClasses = {}, this.inputRef = m(), this.inputRefTo = m(), this.btnRef = m(), this.calRef = m(), this.popupRef = m(), this.helptextSlot = m(), this.addToSelected = (t) => {
|
|
50
50
|
const e = t.target;
|
|
51
51
|
if (!e.value) return;
|
|
52
|
-
const i = this.min ?
|
|
53
|
-
|
|
54
|
-
}, this.slotController = new
|
|
52
|
+
const i = this.min ? v(this.min) : null, s = this.max ? v(this.max) : null, a = v(e.value.split(",")[0]);
|
|
53
|
+
a && !isNaN(a.getTime()) && (!i || a >= i) && (!s || a <= s) && this.calRef.value && this.calRef.value.handleDateSelect(a), e.value = "";
|
|
54
|
+
}, this.slotController = new T(this, this.helptextSlot);
|
|
55
55
|
}
|
|
56
56
|
get value() {
|
|
57
57
|
return this._valueProperty;
|
|
@@ -64,11 +64,11 @@ let l = class extends S {
|
|
|
64
64
|
super.connectedCallback();
|
|
65
65
|
const t = navigator.userAgent, e = /iP(hone|od|ad)/.test(t);
|
|
66
66
|
this.inputType = e ? "text" : "date", document && document.body.addEventListener("click", (i) => {
|
|
67
|
-
var
|
|
68
|
-
(
|
|
67
|
+
var s, a;
|
|
68
|
+
(s = this.inputRef) != null && s.value && ((a = this.btnRef) != null && a.value) && !this.inputRef.value.contains(i.target) && !(this.inputRefTo.value && this.inputRefTo.value.contains(i.target)) && !this.btnRef.value.contains(i.target) && !i.target.closest(".pkt-calendar-popup") && this.calendarOpen && (this.onBlur(), this.hideCalendar());
|
|
69
69
|
}), document && document.body.addEventListener("keydown", (i) => {
|
|
70
70
|
i.key === "Escape" && this.calendarOpen && this.hideCalendar();
|
|
71
|
-
}), this.value && (this._value = Array.isArray(this.value) ? this.value.filter(Boolean) : this.value.split(",").filter(Boolean)), this.min = this.min || c.props.min.default, this.max = this.max || c.props.max.default, typeof this.excludedates == "string" && (this.excludedates = this.excludedates.split(",")), typeof this.excludeweekdays == "string" && (this.excludeweekdays = this.excludeweekdays.split(",")), (this.multiple || this.range) && this.name && !this.name.endsWith("[]") && (this.name = this.name + "[]"), this.calendarOpen && (await
|
|
71
|
+
}), this.value && (this._value = Array.isArray(this.value) ? this.value.filter(Boolean) : this.value.split(",").filter(Boolean)), this.min = this.min || c.props.min.default, this.max = this.max || c.props.max.default, typeof this.excludedates == "string" && (this.excludedates = this.excludedates.split(",")), typeof this.excludeweekdays == "string" && (this.excludeweekdays = this.excludeweekdays.split(",")), (this.multiple || this.range) && this.name && !this.name.endsWith("[]") && (this.name = this.name + "[]"), this.calendarOpen && (await b(20), this.handleCalendarPosition());
|
|
72
72
|
}
|
|
73
73
|
disconnectedCallback() {
|
|
74
74
|
super.disconnectedCallback(), document && document.body.removeEventListener("click", (t) => {
|
|
@@ -80,27 +80,19 @@ let l = class extends S {
|
|
|
80
80
|
this.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
81
81
|
}
|
|
82
82
|
valueChanged(t, e) {
|
|
83
|
-
if (t
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const v = new Date(u);
|
|
89
|
-
return !(isNaN(v.getTime()) || s && v < s || h && v > h);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
this._value = i;
|
|
93
|
-
const a = i.join(",");
|
|
94
|
-
this._valueProperty !== a && (this._valueProperty = a), super.valueChanged(a, e);
|
|
95
|
-
}
|
|
83
|
+
if (t === e) return;
|
|
84
|
+
let i = [];
|
|
85
|
+
t && (typeof t == "string" ? i = t.split(",").filter(Boolean) : i = String(t).split(",").filter(Boolean)), this._value = i;
|
|
86
|
+
const s = i.join(",");
|
|
87
|
+
this._valueProperty !== s && (this._valueProperty = s), super.valueChanged(s, e);
|
|
96
88
|
}
|
|
97
89
|
attributeChangedCallback(t, e, i) {
|
|
98
90
|
t === "value" && this.value !== e && this.valueChanged(i, e), t === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = (i == null ? void 0 : i.split(",")) ?? []), t === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = (i == null ? void 0 : i.split(",")) ?? []), super.attributeChangedCallback(t, e, i);
|
|
99
91
|
}
|
|
100
92
|
updated(t) {
|
|
101
93
|
if (t.has("value")) {
|
|
102
|
-
const e = Array.isArray(this.value) ? this.value.join(",") : this.value, i = t.get("value"),
|
|
103
|
-
this.valueChanged(e,
|
|
94
|
+
const e = Array.isArray(this.value) ? this.value.join(",") : this.value, i = t.get("value"), s = Array.isArray(i) ? i.join(",") : i;
|
|
95
|
+
this.valueChanged(e, s);
|
|
104
96
|
}
|
|
105
97
|
t.has("multiple") && (this.multiple && !Array.isArray(this._value) ? this._value = typeof this.value == "string" ? this.value ? this.value.split(",").filter(Boolean) : [] : [] : !this.multiple && Array.isArray(this._value) && (this._value = this._value.filter(Boolean)), !this.multiple && !this.range && Array.isArray(this._value) && (this._value = [this._value[0] ?? ""])), super.updated(t);
|
|
106
98
|
}
|
|
@@ -108,15 +100,15 @@ let l = class extends S {
|
|
|
108
100
|
* Rendering
|
|
109
101
|
*/
|
|
110
102
|
renderInput() {
|
|
111
|
-
return
|
|
103
|
+
return u`
|
|
112
104
|
<input
|
|
113
105
|
class="${f(this.inputClasses)}"
|
|
114
106
|
.type=${this.inputType}
|
|
115
107
|
id="${this.id}-input"
|
|
116
108
|
.value=${this._value[0] ?? ""}
|
|
117
|
-
min=${
|
|
118
|
-
max=${
|
|
119
|
-
placeholder=${
|
|
109
|
+
min=${h(this.min)}
|
|
110
|
+
max=${h(this.max)}
|
|
111
|
+
placeholder=${h(this.placeholder)}
|
|
120
112
|
?readonly=${this.readonly}
|
|
121
113
|
aria-describedby="${this.id}-helptext"
|
|
122
114
|
@click=${(t) => {
|
|
@@ -126,8 +118,8 @@ let l = class extends S {
|
|
|
126
118
|
@keydown=${(t) => {
|
|
127
119
|
var e, i;
|
|
128
120
|
if (t.key === "," && ((e = this.inputRef.value) == null || e.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t)), t.key === "Enter") {
|
|
129
|
-
const
|
|
130
|
-
|
|
121
|
+
const s = this.internals.form;
|
|
122
|
+
s ? s.requestSubmit() : (i = this.inputRef.value) == null || i.blur();
|
|
131
123
|
}
|
|
132
124
|
}}
|
|
133
125
|
@input=${(t) => {
|
|
@@ -143,7 +135,7 @@ let l = class extends S {
|
|
|
143
135
|
@change=${(t) => {
|
|
144
136
|
this.touched = !0, t.stopImmediatePropagation();
|
|
145
137
|
}}
|
|
146
|
-
${
|
|
138
|
+
${p(this.inputRef)}
|
|
147
139
|
/>
|
|
148
140
|
`;
|
|
149
141
|
}
|
|
@@ -152,26 +144,26 @@ let l = class extends S {
|
|
|
152
144
|
"pkt-input-prefix": this.showRangeLabels,
|
|
153
145
|
"pkt-hide": !this.showRangeLabels
|
|
154
146
|
};
|
|
155
|
-
return
|
|
156
|
-
${this.showRangeLabels ?
|
|
147
|
+
return u`
|
|
148
|
+
${this.showRangeLabels ? u` <div class="pkt-input-prefix">${this.strings.generic.from}</div> ` : g}
|
|
157
149
|
<input
|
|
158
150
|
class=${f(this.inputClasses)}
|
|
159
151
|
.type=${this.inputType}
|
|
160
152
|
id="${this.id}-input"
|
|
161
153
|
.value=${this._value[0] ?? ""}
|
|
162
|
-
min=${
|
|
163
|
-
max=${
|
|
164
|
-
placeholder=${
|
|
154
|
+
min=${h(this.min)}
|
|
155
|
+
max=${h(this.max)}
|
|
156
|
+
placeholder=${h(this.placeholder)}
|
|
165
157
|
?readonly=${this.readonly}
|
|
166
158
|
?disabled=${this.disabled}
|
|
167
159
|
@click=${(e) => {
|
|
168
160
|
e.preventDefault(), this.showCalendar();
|
|
169
161
|
}}
|
|
170
162
|
@keydown=${(e) => {
|
|
171
|
-
var i,
|
|
163
|
+
var i, s;
|
|
172
164
|
if (e.key === "," && ((i = this.inputRef.value) == null || i.blur()), (e.key === "Space" || e.key === " ") && (e.preventDefault(), this.toggleCalendar(e)), e.key === "Enter") {
|
|
173
|
-
const
|
|
174
|
-
|
|
165
|
+
const a = this.internals.form;
|
|
166
|
+
a ? a.requestSubmit() : (s = this.inputRefTo.value) == null || s.focus();
|
|
175
167
|
}
|
|
176
168
|
}}
|
|
177
169
|
@input=${(e) => {
|
|
@@ -181,41 +173,41 @@ let l = class extends S {
|
|
|
181
173
|
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
182
174
|
}}
|
|
183
175
|
@blur=${(e) => {
|
|
184
|
-
var i,
|
|
176
|
+
var i, s;
|
|
185
177
|
if (e.target.value) {
|
|
186
178
|
this.manageValidity(e.target);
|
|
187
|
-
const
|
|
188
|
-
|
|
179
|
+
const a = y(e.target.value);
|
|
180
|
+
a && this._value[0] !== e.target.value && this._value[1] && (this.clearInputValue(), (s = (i = this.calRef) == null ? void 0 : i.value) == null || s.handleDateSelect(a));
|
|
189
181
|
} else this._value[0] && this.clearInputValue();
|
|
190
182
|
}}
|
|
191
183
|
@change=${(e) => {
|
|
192
184
|
e.stopImmediatePropagation();
|
|
193
185
|
}}
|
|
194
|
-
${
|
|
186
|
+
${p(this.inputRef)}
|
|
195
187
|
/>
|
|
196
188
|
<div class="${f(t)}" id="${this.id}-to-label">
|
|
197
189
|
${this.strings.generic.to}
|
|
198
190
|
</div>
|
|
199
|
-
${this.showRangeLabels ? g :
|
|
191
|
+
${this.showRangeLabels ? g : u` <div class="pkt-input-separator">–</div> `}
|
|
200
192
|
<input
|
|
201
193
|
class=${f(this.inputClasses)}
|
|
202
194
|
.type=${this.inputType}
|
|
203
195
|
id="${this.id}-to"
|
|
204
196
|
aria-labelledby="${this.id}-to-label"
|
|
205
197
|
.value=${this._value[1] ?? ""}
|
|
206
|
-
min=${
|
|
207
|
-
max=${
|
|
208
|
-
placeholder=${
|
|
198
|
+
min=${h(this.min)}
|
|
199
|
+
max=${h(this.max)}
|
|
200
|
+
placeholder=${h(this.placeholder)}
|
|
209
201
|
?readonly=${this.readonly}
|
|
210
202
|
?disabled=${this.disabled}
|
|
211
203
|
@click=${(e) => {
|
|
212
204
|
e.preventDefault(), this.showCalendar();
|
|
213
205
|
}}
|
|
214
206
|
@keydown=${(e) => {
|
|
215
|
-
var i,
|
|
207
|
+
var i, s;
|
|
216
208
|
if (e.key === "," && ((i = this.inputRefTo.value) == null || i.blur()), (e.key === "Space" || e.key === " ") && (e.preventDefault(), this.toggleCalendar(e)), e.key === "Enter") {
|
|
217
|
-
const
|
|
218
|
-
|
|
209
|
+
const a = this.internals.form;
|
|
210
|
+
a ? a.requestSubmit() : (s = this.inputRefTo.value) == null || s.blur();
|
|
219
211
|
}
|
|
220
212
|
}}
|
|
221
213
|
@input=${(e) => {
|
|
@@ -225,39 +217,39 @@ let l = class extends S {
|
|
|
225
217
|
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
226
218
|
}}
|
|
227
219
|
@blur=${(e) => {
|
|
228
|
-
var i,
|
|
220
|
+
var i, s, a;
|
|
229
221
|
if ((i = this.calRef.value) != null && i.contains(e.relatedTarget) || this.onBlur(), e.target.value) {
|
|
230
222
|
this.manageValidity(e.target);
|
|
231
|
-
const
|
|
232
|
-
this.min && this.min >
|
|
223
|
+
const o = e.target.value;
|
|
224
|
+
this.min && this.min > o ? this.internals.setValidity(
|
|
233
225
|
{ rangeUnderflow: !0 },
|
|
234
226
|
this.strings.forms.messages.rangeUnderflow,
|
|
235
227
|
e.target
|
|
236
|
-
) : this.max && this.max <
|
|
228
|
+
) : this.max && this.max < o && this.internals.setValidity(
|
|
237
229
|
{ rangeOverflow: !0 },
|
|
238
230
|
this.strings.forms.messages.rangeOverflow,
|
|
239
231
|
e.target
|
|
240
232
|
);
|
|
241
|
-
const
|
|
242
|
-
|
|
233
|
+
const d = y(e.target.value);
|
|
234
|
+
d && this._value[1] !== w(d) && ((a = (s = this.calRef) == null ? void 0 : s.value) == null || a.handleDateSelect(d));
|
|
243
235
|
}
|
|
244
236
|
}}
|
|
245
237
|
@change=${(e) => {
|
|
246
238
|
this.touched = !0, e.stopImmediatePropagation();
|
|
247
239
|
}}
|
|
248
|
-
${
|
|
240
|
+
${p(this.inputRefTo)}
|
|
249
241
|
/>
|
|
250
242
|
`;
|
|
251
243
|
}
|
|
252
244
|
renderMultipleInput() {
|
|
253
|
-
return
|
|
245
|
+
return u`
|
|
254
246
|
<input
|
|
255
247
|
class=${f(this.inputClasses)}
|
|
256
248
|
.type=${this.inputType}
|
|
257
249
|
id="${this.id}-input"
|
|
258
|
-
min=${
|
|
259
|
-
max=${
|
|
260
|
-
placeholder=${
|
|
250
|
+
min=${h(this.min)}
|
|
251
|
+
max=${h(this.max)}
|
|
252
|
+
placeholder=${h(this.placeholder)}
|
|
261
253
|
?readonly=${this.readonly}
|
|
262
254
|
?disabled=${this.disabled || this.maxlength && this._value.length >= this.maxlength}
|
|
263
255
|
@click=${(t) => {
|
|
@@ -283,29 +275,29 @@ let l = class extends S {
|
|
|
283
275
|
@change=${(t) => {
|
|
284
276
|
this.touched = !0, t.stopImmediatePropagation();
|
|
285
277
|
}}
|
|
286
|
-
${
|
|
278
|
+
${p(this.inputRef)}
|
|
287
279
|
/>
|
|
288
280
|
`;
|
|
289
281
|
}
|
|
290
282
|
renderTags() {
|
|
291
|
-
return
|
|
283
|
+
return u`
|
|
292
284
|
<div class="pkt-datepicker__tags" aria-live="polite">
|
|
293
|
-
${this._value[0] ?
|
|
285
|
+
${this._value[0] ? S(
|
|
294
286
|
(this._value ?? []).filter(Boolean).sort(),
|
|
295
287
|
(t) => t,
|
|
296
|
-
(t) =>
|
|
288
|
+
(t) => u`
|
|
297
289
|
<pkt-tag
|
|
298
290
|
.id="${this.id + t + "-tag"}"
|
|
299
291
|
closeTag
|
|
300
|
-
ariaLabel="${this.strings.calendar.deleteDate} ${
|
|
292
|
+
ariaLabel="${this.strings.calendar.deleteDate} ${$(
|
|
301
293
|
t,
|
|
302
294
|
this.dateformat
|
|
303
295
|
)}"
|
|
304
296
|
@close=${() => {
|
|
305
297
|
var e;
|
|
306
|
-
return (e = this.calRef.value) == null ? void 0 : e.handleDateSelect(
|
|
298
|
+
return (e = this.calRef.value) == null ? void 0 : e.handleDateSelect(y(t));
|
|
307
299
|
}}
|
|
308
|
-
><time datetime="${t}">${
|
|
300
|
+
><time datetime="${t}">${$(t, this.dateformat)}</time></pkt-tag
|
|
309
301
|
>
|
|
310
302
|
`
|
|
311
303
|
) : g}
|
|
@@ -313,13 +305,13 @@ let l = class extends S {
|
|
|
313
305
|
`;
|
|
314
306
|
}
|
|
315
307
|
renderCalendar() {
|
|
316
|
-
return
|
|
308
|
+
return u`<div
|
|
317
309
|
class="pkt-calendar-popup pkt-${this.calendarOpen ? "show" : "hide"}"
|
|
318
310
|
@focusout=${(t) => {
|
|
319
311
|
this.calendarOpen && this.handleFocusOut(t);
|
|
320
312
|
}}
|
|
321
313
|
id="${this.id}-popup"
|
|
322
|
-
${
|
|
314
|
+
${p(this.popupRef)}
|
|
323
315
|
>
|
|
324
316
|
<pkt-calendar
|
|
325
317
|
id="${this.id}-calendar"
|
|
@@ -333,14 +325,14 @@ let l = class extends S {
|
|
|
333
325
|
.latest=${this.max}
|
|
334
326
|
.excludedates=${Array.isArray(this.excludedates) ? this.excludedates : this.excludedates.split(",")}
|
|
335
327
|
.excludeweekdays=${this.excludeweekdays}
|
|
336
|
-
.currentmonth=${this.currentmonth ?
|
|
328
|
+
.currentmonth=${this.currentmonth ? C(this.currentmonth) : null}
|
|
337
329
|
@date-selected=${(t) => {
|
|
338
330
|
this.value = !this.multiple && !this.range ? t.detail[0] : Array.isArray(t.detail) ? t.detail.join(",") : t.detail, this._value = t.detail, this.inputRef.value && (this.range && this.inputRefTo.value ? (this.inputRef.value.value = this._value[0] ?? "", this.inputRefTo.value.value = this._value[1] ?? "", this.manageValidity(this.inputRef.value), this.manageValidity(this.inputRefTo.value)) : this.multiple || (this.inputRef.value.value = this._value.length ? this._value[0] : "", this.manageValidity(this.inputRef.value)));
|
|
339
331
|
}}
|
|
340
332
|
@close=${() => {
|
|
341
333
|
this.onBlur(), this.hideCalendar();
|
|
342
334
|
}}
|
|
343
|
-
${
|
|
335
|
+
${p(this.calRef)}
|
|
344
336
|
></pkt-calendar>
|
|
345
337
|
</div>`;
|
|
346
338
|
}
|
|
@@ -358,7 +350,7 @@ let l = class extends S {
|
|
|
358
350
|
"pkt-btn--icon-only": !0,
|
|
359
351
|
"pkt-btn--tertiary": !0,
|
|
360
352
|
"pkt-datepicker__calendar-button": !0
|
|
361
|
-
},
|
|
353
|
+
}, u`
|
|
362
354
|
<pkt-input-wrapper
|
|
363
355
|
label="${this.label}"
|
|
364
356
|
forId="${this.id}-input"
|
|
@@ -383,7 +375,7 @@ let l = class extends S {
|
|
|
383
375
|
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
384
376
|
class="pkt-datepicker"
|
|
385
377
|
>
|
|
386
|
-
<div class="pkt-contents" ${
|
|
378
|
+
<div class="pkt-contents" ${p(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
387
379
|
${this.multiple ? this.renderTags() : g}
|
|
388
380
|
<div
|
|
389
381
|
class="pkt-datepicker__inputs ${this.range && this.showRangeLabels ? "pkt-input__range-inputs" : ""}"
|
|
@@ -398,7 +390,7 @@ let l = class extends S {
|
|
|
398
390
|
(t.key === "Enter" || t.key === " " || t.key === "Space") && (t.preventDefault(), this.toggleCalendar(t));
|
|
399
391
|
}}
|
|
400
392
|
?disabled=${this.disabled}
|
|
401
|
-
${
|
|
393
|
+
${p(this.btnRef)}
|
|
402
394
|
>
|
|
403
395
|
<pkt-icon name="calendar"></pkt-icon>
|
|
404
396
|
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
@@ -415,9 +407,9 @@ let l = class extends S {
|
|
|
415
407
|
handleCalendarPosition() {
|
|
416
408
|
var t;
|
|
417
409
|
if (this.popupRef.value && this.inputRef.value) {
|
|
418
|
-
const e = this.multiple && !!this.maxlength, i = ((t = this.inputRef.value.parentElement) == null ? void 0 : t.getBoundingClientRect()) || this.inputRef.value.getBoundingClientRect(),
|
|
419
|
-
let
|
|
420
|
-
i && i.top +
|
|
410
|
+
const e = this.multiple && !!this.maxlength, i = ((t = this.inputRef.value.parentElement) == null ? void 0 : t.getBoundingClientRect()) || this.inputRef.value.getBoundingClientRect(), s = e ? i.height + 30 : i.height, a = this.popupRef.value.getBoundingClientRect().height;
|
|
411
|
+
let o = e ? "calc(100% - 30px)" : "100%";
|
|
412
|
+
i && i.top + a > window.innerHeight && i.top - a > 0 && (o = `calc(100% - ${s}px - ${a}px)`), this.popupRef.value.style.top = o;
|
|
421
413
|
}
|
|
422
414
|
}
|
|
423
415
|
handleFocusOut(t) {
|
|
@@ -425,7 +417,7 @@ let l = class extends S {
|
|
|
425
417
|
}
|
|
426
418
|
async showCalendar() {
|
|
427
419
|
var t;
|
|
428
|
-
this.calendarOpen = !0, await
|
|
420
|
+
this.calendarOpen = !0, await b(20), this.handleCalendarPosition(), this.isMobileSafari && ((t = this.calRef.value) == null || t.focusOnCurrentDate());
|
|
429
421
|
}
|
|
430
422
|
hideCalendar() {
|
|
431
423
|
this.calendarOpen = !1;
|
|
@@ -474,10 +466,10 @@ n([
|
|
|
474
466
|
r({ type: Boolean, reflect: !0 })
|
|
475
467
|
], l.prototype, "withcontrols", 2);
|
|
476
468
|
n([
|
|
477
|
-
r({ converter:
|
|
469
|
+
r({ converter: x.csvToArray })
|
|
478
470
|
], l.prototype, "excludedates", 2);
|
|
479
471
|
n([
|
|
480
|
-
r({ converter:
|
|
472
|
+
r({ converter: x.csvToArray })
|
|
481
473
|
], l.prototype, "excludeweekdays", 2);
|
|
482
474
|
n([
|
|
483
475
|
r({ type: String })
|
|
@@ -489,10 +481,10 @@ n([
|
|
|
489
481
|
r({ type: String })
|
|
490
482
|
], l.prototype, "timezone", 2);
|
|
491
483
|
n([
|
|
492
|
-
|
|
484
|
+
k()
|
|
493
485
|
], l.prototype, "inputClasses", 2);
|
|
494
486
|
n([
|
|
495
|
-
|
|
487
|
+
k()
|
|
496
488
|
], l.prototype, "buttonClasses", 2);
|
|
497
489
|
l = n([
|
|
498
490
|
R("pkt-datepicker")
|
package/dist/pkt-datepicker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-DonUad47.cjs"),t=e.PktDatepicker;Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>e.PktDatepicker});exports.default=t;
|
package/dist/pkt-datepicker.js
CHANGED
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-DonUad47.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-DNidjwH-.cjs"),_=require("./messagebox-CjPtPPrW.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-CD6Zn8YH.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
2
|
<div class="${O.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
package/dist/pkt-index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { P as k, t as h, x as P, n, a as c } from "./element-CgEWt74-.js";
|
|
|
12
12
|
import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
13
13
|
import { e as m, n as d } from "./ref-BBYSqgeW.js";
|
|
14
14
|
import { e as u } from "./class-map-BpTj9gtz.js";
|
|
15
|
-
import { P as F } from "./datepicker-
|
|
15
|
+
import { P as F } from "./datepicker-F3TwE9o7.js";
|
|
16
16
|
import { P as Q } from "./helptext-B7eI0iBQ.js";
|
|
17
17
|
import { P as X } from "./heading-Bdh9absf.js";
|
|
18
18
|
import { P as Z } from "./icon-CC1js8eR.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.10",
|
|
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",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
74
74
|
},
|
|
75
75
|
"license": "MIT",
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "620a533438712c433484060ce628f538354c2c55"
|
|
77
77
|
}
|
|
@@ -179,44 +179,25 @@ export class PktDatepicker extends PktInputElement {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
valueChanged(newValue: string | null, oldValue: string | null): void {
|
|
182
|
-
if (newValue
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// If not a string, convert to string first
|
|
191
|
-
validatedValue = String(newValue).split(',').filter(Boolean)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Validate dates against min/max boundaries
|
|
196
|
-
if (this.min || this.max) {
|
|
197
|
-
const minDate = this.min ? new Date(this.min) : null
|
|
198
|
-
const maxDate = this.max ? new Date(this.max) : null
|
|
199
|
-
|
|
200
|
-
validatedValue = validatedValue.filter((dateStr) => {
|
|
201
|
-
const date = new Date(dateStr)
|
|
202
|
-
if (isNaN(date.getTime())) return false
|
|
203
|
-
if (minDate && date < minDate) return false
|
|
204
|
-
if (maxDate && date > maxDate) return false
|
|
205
|
-
return true
|
|
206
|
-
})
|
|
182
|
+
if (newValue === oldValue) return
|
|
183
|
+
|
|
184
|
+
let parsedValue: string[] = []
|
|
185
|
+
if (newValue) {
|
|
186
|
+
if (typeof newValue === 'string') {
|
|
187
|
+
parsedValue = newValue.split(',').filter(Boolean)
|
|
188
|
+
} else {
|
|
189
|
+
parsedValue = String(newValue).split(',').filter(Boolean)
|
|
207
190
|
}
|
|
191
|
+
}
|
|
208
192
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// Update the public value property to reflect validated value
|
|
212
|
-
const validatedValueString = validatedValue.join(',')
|
|
213
|
-
if (this._valueProperty !== validatedValueString) {
|
|
214
|
-
this._valueProperty = validatedValueString
|
|
215
|
-
}
|
|
193
|
+
this._value = parsedValue
|
|
216
194
|
|
|
217
|
-
|
|
218
|
-
|
|
195
|
+
const parsedValueString = parsedValue.join(',')
|
|
196
|
+
if (this._valueProperty !== parsedValueString) {
|
|
197
|
+
this._valueProperty = parsedValueString
|
|
219
198
|
}
|
|
199
|
+
|
|
200
|
+
super.valueChanged(parsedValueString, oldValue)
|
|
220
201
|
}
|
|
221
202
|
|
|
222
203
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
@@ -79,39 +79,31 @@ describe('PktDatepicker', () => {
|
|
|
79
79
|
}
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
test
|
|
83
|
-
|
|
82
|
+
test.each`
|
|
83
|
+
description | value | expectedRangeUnderflow | expectedValid
|
|
84
|
+
${'Test date before min - component should mark it invalid'} | ${'2024-06-05'} | ${true} | ${false}
|
|
85
|
+
${'Test date after max - component should mark it invalid'} | ${'2024-06-25'} | ${false} | ${false}
|
|
86
|
+
${'Test valid date - should be accepted and marked valid'} | ${'2024-06-15'} | ${false} | ${true}
|
|
87
|
+
`(
|
|
88
|
+
'validates dates against earliest/latest boundaries - $description',
|
|
89
|
+
async ({ value, expectedRangeUnderflow, expectedValid }) => {
|
|
90
|
+
const container = await createDatepicker('min="2024-06-10" max="2024-06-20"')
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const input = datepicker.querySelector('input') as HTMLInputElement
|
|
89
|
-
|
|
90
|
-
// Test date before min - component should filter it out
|
|
91
|
-
datepicker.value = '2024-06-05'
|
|
92
|
-
await datepicker.updateComplete
|
|
93
|
-
|
|
94
|
-
// Component should reject invalid date (filter it out)
|
|
95
|
-
expect(datepicker.value).toBe('')
|
|
96
|
-
expect(input.value).toBe('')
|
|
97
|
-
|
|
98
|
-
// Test date after max - component should filter it out
|
|
99
|
-
datepicker.value = '2024-06-25'
|
|
100
|
-
await datepicker.updateComplete
|
|
92
|
+
const datepicker = container.querySelector('pkt-datepicker') as PktDatepicker
|
|
93
|
+
await datepicker.updateComplete
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
expect(datepicker.value).toBe('')
|
|
104
|
-
expect(input.value).toBe('')
|
|
95
|
+
const input = datepicker.querySelector('input') as HTMLInputElement
|
|
105
96
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
await datepicker.updateComplete
|
|
97
|
+
datepicker.value = value
|
|
98
|
+
await datepicker.updateComplete
|
|
109
99
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
expect(datepicker.value).toBe(value)
|
|
101
|
+
expect(input.value).toBe(value)
|
|
102
|
+
expect(datepicker._value).toEqual([value])
|
|
103
|
+
expect(input.validity.rangeUnderflow).toBe(expectedRangeUnderflow)
|
|
104
|
+
expect(input.validity.valid).toBe(expectedValid)
|
|
105
|
+
},
|
|
106
|
+
)
|
|
115
107
|
})
|
|
116
108
|
|
|
117
109
|
describe('Error handling and edge cases', () => {
|