@oslokommune/punkt-elements 13.6.12 → 13.6.15

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 CHANGED
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [13.6.15](https://github.com/oslokommune/punkt/compare/13.6.14...13.6.15) (2025-10-09)
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.6.12](https://github.com/oslokommune/punkt/compare/13.6.11...13.6.12) (2025-10-06)
9
26
 
10
27
  ### ⚠ BREAKING CHANGES
@@ -0,0 +1,289 @@
1
+ "use strict";const a=require("./element-D62wHiNU.cjs"),S=require("./state-BkE_Rxl7.cjs"),u=require("./calendar-DH-fCGyW.cjs"),_=require("./input-element-Y8sdrq9C.cjs"),p=require("./ref-BfgcOXko.cjs");require("./icon-__Hjt2XZ.cjs");require("./input-wrapper-DVjNwf8-.cjs");const k=require("./class-map-CG3vIaNm.cjs"),I=require("./repeat-DzibMwhi.cjs");require("./tag-BKq07hGI.cjs");const O=require("./stringutils-CkVRq4jP.cjs"),f=require("./if-defined-CkVc_RJD.cjs"),B=require("./pkt-slot-controller-BzddBp7z.cjs"),A=i=>new Promise(e=>setTimeout(e,i)),$={isIOS(){const i=navigator.userAgent;return!!(/iP(hone|od|ad)/.test(i)||/Macintosh/.test(i)&&"ontouchend"in document)}},v={parseValue(i){return i?Array.isArray(i)?i.filter(Boolean):typeof i=="string"?i.split(",").filter(Boolean):String(i).split(",").filter(Boolean):[]},formatValue(i){return i.join(",")},normalizeNameForMultiple(i,e,t){return i?(e||t)&&!i.endsWith("[]")?i+"[]":i:null},normalizeStringArray(i){return typeof i=="string"?i.split(",").filter(Boolean):Array.isArray(i)?i:[]},validateRangeOrder(i){return!i||i.length!==2?!0:u.isValidDateRange(i[0],i[1])},sortDates(i){return u.sortDateStrings(i)},filterSelectableDates(i,e,t,s,n){return u.filterSelectableDates(i,e,t,s,n)}},M={getInputType(){return $.isIOS()?"text":"date"}},w={submitForm(i){var t;const e=(t=i.internals)==null?void 0:t.form;e&&e.requestSubmit()},submitFormOrFallback(i,e){const t=i==null?void 0:i.form;t?t.requestSubmit():e()},validateDateInput(i,e,t,s,n){var l,h,T,E;const r=i.value;r&&(t&&t>r?e.setValidity({rangeUnderflow:!0},((h=(l=n==null?void 0:n.forms)==null?void 0:l.messages)==null?void 0:h.rangeUnderflow)||"Value is below minimum",i):s&&s<r&&e.setValidity({rangeOverflow:!0},((E=(T=n==null?void 0:n.forms)==null?void 0:T.messages)==null?void 0:E.rangeOverflow)||"Value is above maximum",i))}},x={addToSelected(i,e,t,s){const n=i.target;if(!n.value)return;const r=t?u.newDate(t):null,l=s?u.newDate(s):null,h=u.newDate(n.value.split(",")[0]);h&&!isNaN(h.getTime())&&(!r||h>=r)&&(!l||h<=l)&&e.value&&e.value.handleDateSelect(h),n.value=""},handleCalendarPosition(i,e,t=!1){var h;if(!i.value||!e.value)return;const s=((h=e.value.parentElement)==null?void 0:h.getBoundingClientRect())||e.value.getBoundingClientRect(),n=t?s.height+30:s.height,r=i.value.getBoundingClientRect().height;let l=t?"calc(100% - 30px)":"100%";s&&s.top+r>window.innerHeight&&s.top-r>0&&(l=`calc(100% - ${n}px - ${r}px)`),i.value.style.top=l}},C={getInputClasses(i,e,t,s,n,r){return{"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":i,"pkt-datepicker--hasrangelabels":e,"pkt-datepicker--multiple":t,"pkt-datepicker--range":s,"ios-readonly-hack":n===!1&&r==="text"}},getButtonClasses(){return{"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0}},getRangeLabelClasses(i){return{"pkt-input-prefix":i,"pkt-hide":!i}}},R={processDateSelection(i,e,t){return!e&&!t?i[0]||"":Array.isArray(i)?i.join(","):i},updateInputValues(i,e,t,s,n,r){i.value&&(s&&(e!=null&&e.value)?(i.value.value=t[0]??"",e.value.value=t[1]??"",r(i.value),r(e.value)):n||(i.value.value=t.length?t[0]:"",r(i.value)))},processRangeBlur(i,e,t,s,n){var l;const r=i.target;if(r.value){n(r);const h=u.fromISOToDate(r.value);h&&e[0]!==r.value&&e[1]&&(s(),(l=t==null?void 0:t.value)==null||l.handleDateSelect(h))}else e[0]&&s()}},b={handleInputKeydown(i,e,t,s,n,r){const{key:l}=i;l===","&&(i.preventDefault(),r?r(i):n&&n()),(l==="Space"||l===" ")&&(i.preventDefault(),e(i)),l==="Enter"&&(i.preventDefault(),t?t():s?s():n&&n())},handleButtonKeydown(i,e){const{key:t}=i;(t==="Enter"||t===" "||t==="Space")&&(i.preventDefault(),e(i))}};var j=Object.defineProperty,F=Object.getOwnPropertyDescriptor,P=(i,e,t,s)=>{for(var n=s>1?void 0:s?F(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&j(e,t,n),n};exports.PktDateTags=class extends a.PktElement{constructor(){super(...arguments),this.dates=[],this.dateformat="dd.MM.yyyy",this.className="pkt-datepicker__tags",this.idBase=O.uuidish()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},a.x`
2
+ <div class=${k.e(this.classes)} aria-live="polite">
3
+ ${Array.isArray(this.dates)&&this.dates[0]?I.c(v.sortDates((this.dates??[]).filter(Boolean)),e=>e,e=>{var t;return a.x` <pkt-tag
4
+ id=${this.idBase+e+"-tag"}
5
+ closeTag
6
+ @close=${()=>{this.dispatchEvent(new CustomEvent("date-tag-removed",{detail:e}))}}
7
+ .ariaLabel=${`${(t=this.strings)==null?void 0:t.calendar.deleteDate} ${u.fromISOtoLocal(e,this.dateformat)}`}
8
+ >
9
+ <time datetime=${e}>${u.fromISOtoLocal(e,this.dateformat)}</time>
10
+ </pkt-tag>`}):a.E}
11
+ </div>
12
+ `}};P([a.n({type:Array})],exports.PktDateTags.prototype,"dates",2);P([a.n({type:String})],exports.PktDateTags.prototype,"dateformat",2);P([a.n({type:String,attribute:"class"})],exports.PktDateTags.prototype,"className",2);P([a.n({type:String,attribute:"id-base"})],exports.PktDateTags.prototype,"idBase",2);exports.PktDateTags=P([a.t("pkt-date-tags")],exports.PktDateTags);const q={dateformat:{default:"dd.MM.yyyy"},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},D={props:q};var L=Object.defineProperty,V=Object.getOwnPropertyDescriptor,c=(i,e,t,s)=>{for(var n=s>1?void 0:s?V(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&L(e,t,n),n};let d=class extends a.PktElement{constructor(){super(...arguments),this.open=!1,this.multiple=!1,this.range=!1,this.weeknumbers=!1,this.withcontrols=!1,this.maxMultiple=null,this.selected=[],this.earliest=null,this.latest=null,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.popupRef=p.e(),this.calendarRef=p.e(),this.handleDocumentClick=i=>{if(!this.open)return;const e=i.composedPath(),t=this.parentElement,s=this.popupRef.value;!e.includes(this)&&!e.includes(s)&&!(t&&e.includes(t))&&(this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))},this.handleDocumentKeydown=i=>{this.open&&i.key==="Escape"&&(this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))}}firstUpdated(){this.calRef=this.calendarRef,document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("click",this.handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("keydown",this.handleDocumentKeydown)}show(){var i;this.open=!0,(i=this.calendarRef.value)==null||i.focus()}hide(){this.open=!1}toggle(){this.open?this.hide():this.show()}contains(i){var e;return!!i&&!!((e=this.popupRef.value)!=null&&e.contains(i))}focusOnCurrentDate(){const i=this.calendarRef.value;i&&typeof i.focusOnCurrentDate=="function"&&i.focusOnCurrentDate()}addToSelected(i,e,t){if(typeof x.addToSelected=="function")return x.addToSelected(i,this.calendarRef,e,t)}handleDateSelect(i){const e=this.calendarRef.value;if(e&&typeof e.handleDateSelect=="function")return e.handleDateSelect(i)}render(){const i={"pkt-calendar-popup":!0,show:this.open,hide:!this.open};return a.x`
13
+ <div
14
+ class="${k.e(i)}"
15
+ ${p.n(this.popupRef)}
16
+ id="date-popup"
17
+ ?hidden=${!this.open}
18
+ aria-hidden="${!this.open}"
19
+ >
20
+ <pkt-calendar
21
+ ${p.n(this.calendarRef)}
22
+ ?multiple=${this.multiple}
23
+ ?range=${this.range}
24
+ ?weeknumbers=${this.weeknumbers}
25
+ ?withcontrols=${this.withcontrols}
26
+ .maxMultiple=${this.maxMultiple}
27
+ .selected=${this.selected}
28
+ .earliest=${this.earliest}
29
+ .latest=${this.latest}
30
+ .excludedates=${this.excludedates}
31
+ .excludeweekdays=${this.excludeweekdays}
32
+ .currentmonth=${this.currentmonth}
33
+ @date-selected=${e=>{this.selected=e.detail,this.dispatchEvent(new CustomEvent("date-selected",{detail:e.detail,bubbles:!0,composed:!0}))}}
34
+ @close=${()=>{this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}
35
+ ></pkt-calendar>
36
+ </div>
37
+ `}};c([a.n({type:Boolean,reflect:!0})],d.prototype,"open",2);c([a.n({type:Boolean})],d.prototype,"multiple",2);c([a.n({type:Boolean})],d.prototype,"range",2);c([a.n({type:Boolean})],d.prototype,"weeknumbers",2);c([a.n({type:Boolean})],d.prototype,"withcontrols",2);c([a.n({type:Number})],d.prototype,"maxMultiple",2);c([a.n({type:Array})],d.prototype,"selected",2);c([a.n({type:String})],d.prototype,"earliest",2);c([a.n({type:String})],d.prototype,"latest",2);c([a.n({type:Array})],d.prototype,"excludedates",2);c([a.n({type:Array})],d.prototype,"excludeweekdays",2);c([a.n({type:String})],d.prototype,"currentmonth",2);d=c([a.t("pkt-datepicker-popup")],d);var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,y=(i,e,t,s)=>{for(var n=s>1?void 0:s?K(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&z(e,t,n),n};exports.PktDatepickerSingle=class extends a.PktElement{constructor(){super(...arguments),this.value="",this.inputType="date",this.id="",this.readonly=!1,this.disabled=!1,this.inputClasses={},this.strings={calendar:{buttonAltText:"Åpne kalender"}},this.inputRef=p.e(),this.btnRef=p.e()}get inputElement(){return this.inputRef.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType==="text"}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent("toggle-calendar",{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent("input-change",{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent("input-focus",{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent("input-blur",{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent("input-changed",{detail:e,bubbles:!0,composed:!0}))}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent("manage-validity",{detail:e,bubbles:!0,composed:!0}))}createRenderRoot(){return this}render(){return a.x`
38
+ <div class="pkt-input__container">
39
+ <input
40
+ class="${k.e(this.inputClasses)}"
41
+ .type=${this.inputType}
42
+ id="${this.id}-input"
43
+ .value=${this.value}
44
+ min=${f.o(this.min)}
45
+ max=${f.o(this.max)}
46
+ placeholder=${f.o(this.placeholder)}
47
+ ?readonly=${this.isInputReadonly}
48
+ aria-describedby="${this.id}-helptext"
49
+ @click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
50
+ @touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
51
+ ?disabled=${this.disabled}
52
+ @keydown=${e=>b.handleInputKeydown(e,t=>this.dispatchToggleCalendar(t),()=>w.submitFormOrFallback(this.internals,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()}),void 0,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()})}
53
+ @input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
54
+ @focus=${()=>{this.dispatchFocus(),$.isIOS()&&this.dispatchToggleCalendar(new Event("focus"))}}
55
+ @blur=${e=>{this.dispatchBlur(e),this.dispatchManageValidity(e.target),this.dispatchEvent(new CustomEvent("value-change",{detail:e.target.value,bubbles:!0,composed:!0}))}}
56
+ @change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
57
+ ${p.n(this.inputRef)}
58
+ />
59
+ <button
60
+ class="${k.e(C.getButtonClasses())}"
61
+ type="button"
62
+ @click=${e=>this.dispatchToggleCalendar(e)}
63
+ @keydown=${e=>b.handleButtonKeydown(e,t=>this.dispatchToggleCalendar(t))}
64
+ ?disabled=${this.disabled}
65
+ ${p.n(this.btnRef)}
66
+ >
67
+ <pkt-icon name="calendar"></pkt-icon>
68
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
69
+ </button>
70
+ </div>
71
+ `}};y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"value",2);y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"inputType",2);y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"id",2);y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"min",2);y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"max",2);y([a.n({type:String})],exports.PktDatepickerSingle.prototype,"placeholder",2);y([a.n({type:Boolean})],exports.PktDatepickerSingle.prototype,"readonly",2);y([a.n({type:Boolean})],exports.PktDatepickerSingle.prototype,"disabled",2);y([a.n({type:Object})],exports.PktDatepickerSingle.prototype,"inputClasses",2);y([a.n({type:Object})],exports.PktDatepickerSingle.prototype,"internals",2);y([a.n({type:Object})],exports.PktDatepickerSingle.prototype,"strings",2);exports.PktDatepickerSingle=y([a.t("pkt-datepicker-single")],exports.PktDatepickerSingle);var N=Object.defineProperty,U=Object.getOwnPropertyDescriptor,g=(i,e,t,s)=>{for(var n=s>1?void 0:s?U(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&N(e,t,n),n};exports.PktDatepickerRange=class extends a.PktElement{constructor(){super(...arguments),this.value=[],this.inputType="date",this.id="",this.readonly=!1,this.disabled=!1,this.showRangeLabels=!1,this.inputClasses={},this.strings={generic:{from:"Fra",to:"Til"}},this.inputRef=p.e(),this.inputRefTo=p.e(),this.btnRef=p.e()}get inputElement(){return this.inputRef.value}get inputElementTo(){return this.inputRefTo.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType==="text"}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent("toggle-calendar",{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent("input-change",{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent("input-focus",{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent("input-blur",{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent("input-changed",{detail:e,bubbles:!0,composed:!0}))}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent("manage-validity",{detail:e,bubbles:!0,composed:!0}))}createRenderRoot(){return this}render(){const e=C.getRangeLabelClasses(this.showRangeLabels);return a.x`
72
+ <div class="pkt-input__container">
73
+ ${this.showRangeLabels?a.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:a.E}
74
+ <input
75
+ class=${k.e(this.inputClasses)}
76
+ .type=${this.inputType}
77
+ id="${this.id}-input"
78
+ .value=${this.value[0]??""}
79
+ min=${f.o(this.min)}
80
+ max=${f.o(this.max)}
81
+ placeholder=${f.o(this.placeholder)}
82
+ ?readonly=${this.isInputReadonly}
83
+ ?disabled=${this.disabled}
84
+ @click=${t=>{t.preventDefault(),this.dispatchToggleCalendar(t)}}
85
+ @touchend=${t=>{t.preventDefault(),this.dispatchToggleCalendar(t)}}
86
+ @keydown=${t=>b.handleInputKeydown(t,s=>this.dispatchToggleCalendar(s),()=>w.submitFormOrFallback(this.internals,()=>{var s;return(s=this.inputRefTo.value)==null?void 0:s.focus()}),()=>{var s;return(s=this.inputRefTo.value)==null?void 0:s.focus()},()=>{var s;return(s=this.inputRef.value)==null?void 0:s.blur()})}
87
+ @input=${t=>{this.dispatchInput(t),t.stopImmediatePropagation()}}
88
+ @focus=${()=>{this.dispatchFocus(),$.isIOS()&&this.dispatchToggleCalendar(new Event("focus"))}}
89
+ @blur=${t=>{this.dispatchEvent(new CustomEvent("range-blur",{detail:{event:t,values:this.value,inputType:"from"},bubbles:!0,composed:!0}))}}
90
+ @change=${t=>{t.stopImmediatePropagation()}}
91
+ ${p.n(this.inputRef)}
92
+ />
93
+ <div class="${k.e(e)}" id="${this.id}-to-label">
94
+ ${this.strings.generic.to}
95
+ </div>
96
+ ${this.showRangeLabels?a.E:a.x` <div class="pkt-input-separator">–</div> `}
97
+ <input
98
+ class=${k.e(this.inputClasses)}
99
+ .type=${this.inputType}
100
+ id="${this.id}-to"
101
+ aria-labelledby="${this.id}-to-label"
102
+ .value=${this.value[1]??""}
103
+ min=${f.o(this.min)}
104
+ max=${f.o(this.max)}
105
+ placeholder=${f.o(this.placeholder)}
106
+ ?readonly=${this.isInputReadonly}
107
+ ?disabled=${this.disabled}
108
+ @click=${t=>{t.preventDefault(),this.dispatchToggleCalendar(t)}}
109
+ @touchend=${t=>{t.preventDefault(),this.dispatchToggleCalendar(t)}}
110
+ @keydown=${t=>b.handleInputKeydown(t,s=>this.dispatchToggleCalendar(s),()=>w.submitFormOrFallback(this.internals,()=>{var s;return(s=this.inputRefTo.value)==null?void 0:s.blur()}),void 0,()=>{var s;return(s=this.inputRefTo.value)==null?void 0:s.blur()})}
111
+ @input=${t=>{this.dispatchInput(t),t.stopImmediatePropagation()}}
112
+ @focus=${()=>{this.dispatchFocus(),$.isIOS()&&this.dispatchToggleCalendar(new Event("focus"))}}
113
+ @blur=${t=>{this.dispatchBlur(t),t.target.value&&(this.dispatchManageValidity(t.target),this.dispatchEvent(new CustomEvent("validate-date-input",{detail:t.target,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("handle-date-select",{detail:t.target.value,bubbles:!0,composed:!0})))}}
114
+ @change=${t=>{this.dispatchChange(t),t.stopImmediatePropagation()}}
115
+ ${p.n(this.inputRefTo)}
116
+ />
117
+ <button
118
+ class="${k.e(C.getButtonClasses())}"
119
+ type="button"
120
+ @click=${t=>this.dispatchToggleCalendar(t)}
121
+ @keydown=${t=>b.handleButtonKeydown(t,s=>this.dispatchToggleCalendar(s))}
122
+ ?disabled=${this.disabled}
123
+ ${p.n(this.btnRef)}
124
+ >
125
+ <pkt-icon name="calendar"></pkt-icon>
126
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
127
+ </button>
128
+ </div>
129
+ `}};g([a.n({type:Array})],exports.PktDatepickerRange.prototype,"value",2);g([a.n({type:String})],exports.PktDatepickerRange.prototype,"inputType",2);g([a.n({type:String})],exports.PktDatepickerRange.prototype,"id",2);g([a.n({type:String})],exports.PktDatepickerRange.prototype,"min",2);g([a.n({type:String})],exports.PktDatepickerRange.prototype,"max",2);g([a.n({type:String})],exports.PktDatepickerRange.prototype,"placeholder",2);g([a.n({type:Boolean})],exports.PktDatepickerRange.prototype,"readonly",2);g([a.n({type:Boolean})],exports.PktDatepickerRange.prototype,"disabled",2);g([a.n({type:Boolean})],exports.PktDatepickerRange.prototype,"showRangeLabels",2);g([a.n({type:Object})],exports.PktDatepickerRange.prototype,"inputClasses",2);g([a.n({type:Object})],exports.PktDatepickerRange.prototype,"internals",2);g([a.n({type:Object})],exports.PktDatepickerRange.prototype,"strings",2);exports.PktDatepickerRange=g([a.t("pkt-datepicker-range")],exports.PktDatepickerRange);var W=Object.defineProperty,H=Object.getOwnPropertyDescriptor,m=(i,e,t,s)=>{for(var n=s>1?void 0:s?H(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&W(e,t,n),n};exports.PktDatepickerMultiple=class extends a.PktElement{constructor(){super(...arguments),this.value=[],this.inputType="date",this.id="",this.readonly=!1,this.disabled=!1,this.inputClasses={},this.strings={calendar:{buttonAltText:"Åpne kalender"}},this.inputRef=p.e(),this.btnRef=p.e()}get inputElement(){return this.inputRef.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType==="text"}get isInputDisabled(){return this.disabled||this.maxlength!==void 0&&this.maxlength!==null&&this.value.length>=this.maxlength}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent("toggle-calendar",{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent("input-change",{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent("input-focus",{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent("input-blur",{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent("input-changed",{detail:e,bubbles:!0,composed:!0}))}dispatchAddToSelected(e){this.dispatchEvent(new CustomEvent("add-to-selected",{detail:e,bubbles:!0,composed:!0}))}createRenderRoot(){return this}render(){return a.x`
130
+ <div class="pkt-input__container">
131
+ <input
132
+ class=${k.e(this.inputClasses)}
133
+ .type=${this.inputType}
134
+ id="${this.id}-input"
135
+ min=${f.o(this.min)}
136
+ max=${f.o(this.max)}
137
+ placeholder=${f.o(this.placeholder)}
138
+ ?readonly=${this.isInputReadonly}
139
+ ?disabled=${this.isInputDisabled}
140
+ @click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
141
+ @touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
142
+ @blur=${e=>{this.dispatchBlur(e),this.dispatchAddToSelected(e)}}
143
+ @input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
144
+ @focus=${()=>{this.dispatchFocus(),$.isIOS()&&this.dispatchToggleCalendar(new Event("focus"))}}
145
+ @keydown=${e=>b.handleInputKeydown(e,t=>this.dispatchToggleCalendar(t),()=>w.submitFormOrFallback(this.internals,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()}),void 0,void 0,t=>this.dispatchAddToSelected(t))}
146
+ @change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
147
+ ${p.n(this.inputRef)}
148
+ />
149
+ <button
150
+ class="${k.e(C.getButtonClasses())}"
151
+ type="button"
152
+ @click=${e=>this.dispatchToggleCalendar(e)}
153
+ @keydown=${e=>b.handleButtonKeydown(e,t=>this.dispatchToggleCalendar(t))}
154
+ ?disabled=${this.disabled}
155
+ ${p.n(this.btnRef)}
156
+ >
157
+ <pkt-icon name="calendar"></pkt-icon>
158
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
159
+ </button>
160
+ </div>
161
+ `}};m([a.n({type:Array})],exports.PktDatepickerMultiple.prototype,"value",2);m([a.n({type:String})],exports.PktDatepickerMultiple.prototype,"inputType",2);m([a.n({type:String})],exports.PktDatepickerMultiple.prototype,"id",2);m([a.n({type:String})],exports.PktDatepickerMultiple.prototype,"min",2);m([a.n({type:String})],exports.PktDatepickerMultiple.prototype,"max",2);m([a.n({type:String})],exports.PktDatepickerMultiple.prototype,"placeholder",2);m([a.n({type:Boolean})],exports.PktDatepickerMultiple.prototype,"readonly",2);m([a.n({type:Boolean})],exports.PktDatepickerMultiple.prototype,"disabled",2);m([a.n({type:Number})],exports.PktDatepickerMultiple.prototype,"maxlength",2);m([a.n({type:Object})],exports.PktDatepickerMultiple.prototype,"inputClasses",2);m([a.n({type:Object})],exports.PktDatepickerMultiple.prototype,"internals",2);m([a.n({type:Object})],exports.PktDatepickerMultiple.prototype,"strings",2);exports.PktDatepickerMultiple=m([a.t("pkt-datepicker-multiple")],exports.PktDatepickerMultiple);var G=Object.defineProperty,J=Object.getOwnPropertyDescriptor,o=(i,e,t,s)=>{for(var n=s>1?void 0:s?J(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&G(e,t,n),n};exports.PktDatepicker=class extends _.PktInputElement{constructor(){super(),this._valueProperty="",this.datepickerPopupRef=p.e(),this._value=[],this.label="Datovelger",this.dateformat=D.props.dateformat.default,this.multiple=D.props.multiple.default,this.maxlength=null,this.range=D.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=D.props.weeknumbers.default,this.withcontrols=D.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.calRef=p.e(),this.popupRef=p.e(),this.helptextSlot=p.e(),this.singleInputRef=p.e(),this.rangeInputRef=p.e(),this.multipleInputRef=p.e(),this.addToSelected=e=>{const t=this.datepickerPopupRef.value;return t&&typeof t.addToSelected=="function"?t.addToSelected(e,this.min,this.max):x.addToSelected(e,this.calRef,this.min,this.max)},this.slotController=new B.PktSlotController(this,this.helptextSlot)}get value(){return this._valueProperty}set value(e){const t=this._valueProperty;this._valueProperty=Array.isArray(e)?e.join(","):e||"",this.valueChanged(this._valueProperty,t),this.requestUpdate("value",t)}get inputType(){return M.getInputType()}connectedCallback(){super.connectedCallback(),this.timezone&&this.timezone!==window.pktTz&&(window.pktTz=this.timezone),this.name=v.normalizeNameForMultiple(this.name,this.multiple,this.range)||this.name}disconnectedCallback(){super.disconnectedCallback()}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(e,t){if(e===t)return;const s=v.parseValue(e),n=this.multiple&&s.length>1?v.filterSelectableDates(s,this.min,this.max,this.excludedates,this.excludeweekdays):s;if(this.range&&!v.validateRangeOrder(n)){this._value=[],this._valueProperty="",super.valueChanged("",t);return}this._value=n;const r=v.formatValue(n);this._valueProperty!==r&&(this._valueProperty=r),super.valueChanged(r,t)}attributeChangedCallback(e,t,s){e==="value"&&this.value!==t&&this.valueChanged(s,t),e==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=v.normalizeStringArray(s||"")),e==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=v.normalizeStringArray(s||"")),super.attributeChangedCallback(e,t,s)}updated(e){if(e.has("value")){const t=Array.isArray(this.value)?this.value.join(","):this.value,s=e.get("value"),n=Array.isArray(s)?s.join(","):s;this.valueChanged(t,n)}(e.has("multiple")||e.has("range"))&&(this.name=v.normalizeNameForMultiple(this.name,this.multiple,this.range)||this.name),e.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=v.parseValue(this.value):!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(e)}get inputRef(){return{value:this.currentInputElement}}get inputRefTo(){return{value:this.currentInputElementTo}}get currentInputElement(){var e,t,s;return this.multiple?(e=this.multipleInputRef.value)==null?void 0:e.inputElement:this.range?(t=this.rangeInputRef.value)==null?void 0:t.inputElement:(s=this.singleInputRef.value)==null?void 0:s.inputElement}get currentInputElementTo(){var e;if(this.range)return(e=this.rangeInputRef.value)==null?void 0:e.inputElementTo}get currentButtonElement(){var e,t,s;return this.multiple?(e=this.multipleInputRef.value)==null?void 0:e.buttonElement:this.range?(t=this.rangeInputRef.value)==null?void 0:t.buttonElement:(s=this.singleInputRef.value)==null?void 0:s.buttonElement}get btnRef(){return{value:this.currentButtonElement}}renderInput(){return a.x`
162
+ <pkt-datepicker-single
163
+ .value=${this._value[0]??""}
164
+ .inputType=${this.inputType}
165
+ .id=${this.id}
166
+ .min=${this.min}
167
+ .max=${this.max}
168
+ .placeholder=${this.placeholder}
169
+ .readonly=${this.readonly}
170
+ .disabled=${this.disabled}
171
+ .inputClasses=${this.inputClasses}
172
+ .internals=${this.internals}
173
+ .strings=${this.strings}
174
+ @toggle-calendar=${e=>this.toggleCalendar(e.detail)}
175
+ @input-change=${()=>this.onInput()}
176
+ @input-focus=${()=>this.onFocus()}
177
+ @input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
178
+ @manage-validity=${e=>this.manageValidity(e.detail)}
179
+ @value-change=${e=>{this.value=e.detail}}
180
+ @input-changed=${()=>{this.touched=!0}}
181
+ ${p.n(this.singleInputRef)}
182
+ ></pkt-datepicker-single>
183
+ `}renderRangeInput(){return a.x`
184
+ <pkt-datepicker-range
185
+ .value=${this._value}
186
+ .inputType=${this.inputType}
187
+ .id=${this.id}
188
+ .min=${this.min}
189
+ .max=${this.max}
190
+ .placeholder=${this.placeholder}
191
+ .readonly=${this.readonly}
192
+ .disabled=${this.disabled}
193
+ .showRangeLabels=${this.showRangeLabels}
194
+ .inputClasses=${this.inputClasses}
195
+ .internals=${this.internals}
196
+ .strings=${this.strings}
197
+ @toggle-calendar=${e=>this.toggleCalendar(e.detail)}
198
+ @input-change=${()=>this.onInput()}
199
+ @input-focus=${()=>this.onFocus()}
200
+ @input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
201
+ @range-blur=${e=>{R.processRangeBlur(e.detail.event,e.detail.values,this.calRef,()=>this.clearInputValue(),t=>this.manageValidity(t))}}
202
+ @manage-validity=${e=>this.manageValidity(e.detail)}
203
+ @validate-date-input=${e=>{w.validateDateInput(e.detail,this.internals,this.min,this.max,this.strings)}}
204
+ @handle-date-select=${e=>{var s,n;const t=u.fromISOToDate(e.detail);t&&this._value[1]!==u.formatISODate(t)&&((n=(s=this.calRef)==null?void 0:s.value)==null||n.handleDateSelect(t))}}
205
+ @input-changed=${()=>{this.touched=!0}}
206
+ ${p.n(this.rangeInputRef)}
207
+ ></pkt-datepicker-range>
208
+ `}renderMultipleInput(){return a.x`
209
+ <pkt-datepicker-multiple
210
+ .value=${this._value}
211
+ .inputType=${this.inputType}
212
+ .id=${this.id}
213
+ .min=${this.min}
214
+ .max=${this.max}
215
+ .placeholder=${this.placeholder}
216
+ .readonly=${this.readonly}
217
+ .disabled=${this.disabled}
218
+ .maxlength=${this.maxlength}
219
+ .inputClasses=${this.inputClasses}
220
+ .internals=${this.internals}
221
+ .strings=${this.strings}
222
+ @toggle-calendar=${e=>this.toggleCalendar(e.detail)}
223
+ @input-change=${()=>this.onInput()}
224
+ @input-focus=${()=>this.onFocus()}
225
+ @input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
226
+ @add-to-selected=${e=>this.addToSelected(e.detail)}
227
+ @input-changed=${()=>{this.touched=!0}}
228
+ ${p.n(this.multipleInputRef)}
229
+ ></pkt-datepicker-multiple>
230
+ `}renderCalendar(){return a.x`
231
+ <pkt-datepicker-popup
232
+ class="pkt-contents"
233
+ ?open=${this.calendarOpen}
234
+ ?multiple=${this.multiple}
235
+ ?range=${this.range}
236
+ ?weeknumbers=${this.weeknumbers}
237
+ ?withcontrols=${this.withcontrols}
238
+ .maxMultiple=${this.maxlength}
239
+ .selected=${this._value}
240
+ .earliest=${this.min}
241
+ .latest=${this.max}
242
+ .excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
243
+ .excludeweekdays=${this.excludeweekdays}
244
+ .currentmonth=${this.currentmonth?u.parseISODateString(this.currentmonth):null}
245
+ @date-selected=${e=>{this.value=R.processDateSelection(e.detail,this.multiple,this.range),this._value=e.detail,R.updateInputValues(this.inputRef,this.inputRefTo,this._value,this.range,this.multiple,t=>this.manageValidity(t))}}
246
+ @close=${()=>{this.onBlur(),this.hideCalendar()}}
247
+ ${p.n(this.datepickerPopupRef)}
248
+ ></pkt-datepicker-popup>
249
+ `}render(){return this.inputClasses=C.getInputClasses(this.fullwidth,this.showRangeLabels,this.multiple,this.range,this.readonly,this.inputType),a.x`
250
+ <pkt-input-wrapper
251
+ label="${this.label}"
252
+ forId="${this.id}-input"
253
+ ?counter=${this.multiple&&!!this.maxlength}
254
+ .counterCurrent=${this.value?this._value.length:0}
255
+ .counterMaxLength=${this.maxlength}
256
+ ?disabled=${this.disabled}
257
+ ?hasError=${this.hasError}
258
+ ?hasFieldset=${this.hasFieldset}
259
+ ?inline=${this.inline}
260
+ ?required=${this.required}
261
+ ?optionalTag=${this.optionalTag}
262
+ ?requiredTag=${this.requiredTag}
263
+ ?useWrapper=${this.useWrapper}
264
+ .optionalText=${this.optionalText}
265
+ .requiredText=${this.requiredText}
266
+ .tagText=${this.tagText}
267
+ .errorMessage=${this.errorMessage}
268
+ .helptext=${this.helptext}
269
+ .helptextDropdown=${this.helptextDropdown}
270
+ .helptextDropdownButton=${this.helptextDropdownButton}
271
+ .ariaDescribedBy=${this.ariaDescribedBy}
272
+ class="pkt-datepicker"
273
+ >
274
+ <div class="pkt-contents" ${p.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
275
+ ${this.multiple?a.x`<pkt-date-tags
276
+ .dates=${this._value}
277
+ dateformat=${this.dateformat}
278
+ strings=${this.strings}
279
+ id-base=${this.id}
280
+ @date-tag-removed=${e=>{var n;const t=this.datepickerPopupRef.value,s=u.fromISOToDate(e.detail);t&&s&&typeof t.handleDateSelect=="function"?t.handleDateSelect(s):(n=this.calRef.value)==null||n.handleDateSelect(s)}}
281
+ ></pkt-date-tags>`:a.E}
282
+ <div
283
+ class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
284
+ >
285
+ ${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
286
+ </div>
287
+ </pkt-input-wrapper>
288
+ ${this.renderCalendar()}
289
+ `}handleCalendarPosition(){const e=this.multiple&&!!this.maxlength;x.handleCalendarPosition(this.popupRef,this.inputRef,e)}async showCalendar(){var t;const e=this.datepickerPopupRef.value;if(this.calendarOpen=!0,e&&typeof e.show=="function"){e.show(),$.isIOS()&&e.focusOnCurrentDate();return}await A(20),this.handleCalendarPosition(),$.isIOS()&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){const e=this.datepickerPopupRef.value;if(this.calendarOpen=!1,e&&typeof e.hide=="function")return e.hide()}async toggleCalendar(e){e.preventDefault();const t=this.datepickerPopupRef.value;if(t&&typeof t.toggle=="function"){const s=!!t.open;t.toggle(),this.calendarOpen=!s;return}this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=""}};o([a.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);o([a.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);o([a.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);o([a.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);o([a.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);o([a.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);o([a.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);o([a.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);o([a.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);o([a.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);o([a.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);o([a.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);o([a.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);o([a.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);o([a.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);o([a.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);o([a.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);o([S.r()],exports.PktDatepicker.prototype,"inputClasses",2);exports.PktDatepicker=o([a.t("pkt-datepicker")],exports.PktDatepicker);