@oslokommune/punkt-elements 13.6.10 → 13.6.12

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{combobox-cK_746ek.cjs → combobox-BFOjlFIj.cjs} +1 -1
  3. package/dist/{combobox-DxNotM0u.js → combobox-DaiEdUKx.js} +1 -1
  4. package/dist/datepicker-C244h82t.cjs +190 -0
  5. package/dist/datepicker-DwOkktaP.js +859 -0
  6. package/dist/index.d.ts +48 -13
  7. package/dist/{input-wrapper-D_JdEqcO.js → input-wrapper-CQzXG44g.js} +22 -22
  8. package/dist/{input-wrapper-C9rZEgju.cjs → input-wrapper-DVjNwf8-.cjs} +11 -12
  9. package/dist/pkt-combobox.cjs +1 -1
  10. package/dist/pkt-combobox.js +1 -1
  11. package/dist/pkt-datepicker.cjs +1 -1
  12. package/dist/pkt-datepicker.js +1 -1
  13. package/dist/pkt-index.cjs +1 -1
  14. package/dist/pkt-index.js +6 -6
  15. package/dist/pkt-input-wrapper.cjs +1 -1
  16. package/dist/pkt-input-wrapper.js +1 -1
  17. package/dist/pkt-select.cjs +1 -1
  18. package/dist/pkt-select.js +1 -1
  19. package/dist/pkt-textarea.cjs +1 -1
  20. package/dist/pkt-textarea.js +1 -1
  21. package/dist/pkt-textinput.cjs +1 -1
  22. package/dist/pkt-textinput.js +1 -1
  23. package/dist/{select-D7OQaUrQ.js → select-DKkoxmgj.js} +1 -1
  24. package/dist/{select-Cf1RWSsI.cjs → select-DynzsPo0.cjs} +1 -1
  25. package/dist/{textarea-CXu8UUsY.cjs → textarea-BS1tgktz.cjs} +1 -1
  26. package/dist/{textarea-C0vTWTov.js → textarea-COG1CH_s.js} +1 -1
  27. package/dist/{textinput-C6wccDhZ.cjs → textinput-CCK8ti2y.cjs} +1 -1
  28. package/dist/{textinput-CmZrfH4A.js → textinput-CTOtfcTR.js} +1 -1
  29. package/package.json +2 -2
  30. package/src/components/checkbox/checkbox.ts +17 -1
  31. package/src/components/datepicker/datepicker-popup.test.ts +77 -0
  32. package/src/components/datepicker/datepicker-popup.ts +137 -0
  33. package/src/components/datepicker/datepicker-utils.ts +13 -8
  34. package/src/components/datepicker/datepicker.ts +64 -48
  35. package/src/components/input-wrapper/input-wrapper.ts +7 -7
  36. package/src/components/radiobutton/radiobutton.ts +14 -1
  37. package/src/components/textarea/textarea.ts +4 -1
  38. package/dist/datepicker-BEMo4X9s.js +0 -770
  39. package/dist/datepicker-n49TAIAt.cjs +0 -169
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [13.6.12](https://github.com/oslokommune/punkt/compare/13.6.11...13.6.12) (2025-10-06)
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
+
25
+ ## [13.6.11](https://github.com/oslokommune/punkt/compare/13.6.10...13.6.11) (2025-10-01)
26
+
27
+ ### ⚠ BREAKING CHANGES
28
+ Ingen
29
+
30
+ ### Features
31
+ Ingen
32
+
33
+ ### Bug Fixes
34
+ Ingen
35
+
36
+ ### Chores
37
+ Ingen
38
+
39
+ ---
40
+
41
+
8
42
  ## [13.6.8](https://github.com/oslokommune/punkt/compare/13.6.7...13.6.8) (2025-09-23)
9
43
 
10
44
  ### ⚠ BREAKING CHANGES
@@ -1,4 +1,4 @@
1
- "use strict";const a=require("./element-D62wHiNU.cjs"),c=require("./if-defined-CkVc_RJD.cjs"),d=require("./state-BkE_Rxl7.cjs"),r=require("./ref-BfgcOXko.cjs"),y=require("./class-map-CG3vIaNm.cjs"),O=require("./repeat-DzibMwhi.cjs"),$=require("./input-element-Y8sdrq9C.cjs"),I=require("./pkt-options-controller-CiuBG6Lt.cjs"),w=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-C9rZEgju.cjs");require("./icon-__Hjt2XZ.cjs");require("./tag-BKq07hGI.cjs");require("./listbox-L-iOSF7M.cjs");const C={displayValueAs:{default:"label"}},R={props:C};var V=Object.defineProperty,A=Object.getOwnPropertyDescriptor,h=(v,e,t,i)=>{for(var s=i>1?void 0:i?A(e,t):e,n=v.length-1,l;n>=0;n--)(l=v[n])&&(s=(i?l(e,t,s):l(s))||s);return i&&s&&V(e,t,s),s};exports.PktCombobox=class extends $.PktInputElement{constructor(){super(),this.helptextSlot=r.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=R.props.displayValueAs.default,this.tagPlacement=null,this._options=[],this._isOptionsOpen=!1,this._value=[],this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._editingSingleValue=!1,this.inputRef=r.e(),this.arrowRef=r.e(),this.listboxRef=r.e(),this.focusRef=r.e(),this.optionTagRef=r.e(),this.optionsController=new I.PktOptionsSlotController(this),this.slotController=new w.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){var e;if(super.connectedCallback(),document&&document.body.addEventListener("click",t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.handleFocusOut(t)}),this._options=[],this.defaultOptions&&this.defaultOptions.length){const t=((e=this.options)==null?void 0:e.filter(i=>i.userAdded))||[];this.options=[...t,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(this.optionsController.nodes.length){const t=[];this.optionsController.nodes.forEach(i=>{if(!i.textContent&&!i.getAttribute("value"))return null;const s={value:i.getAttribute("value")||i.textContent||"",label:i.textContent||i.getAttribute("value")||""};i.getAttribute("data-prefix")&&(s.prefix=i.getAttribute("data-prefix")||void 0),i.getAttribute("tagskincolor")&&(s.tagSkinColor=i.getAttribute("tagskincolor")),i.getAttribute("description")&&(s.description=i.getAttribute("description")||void 0),s.fulltext=s.value+s.label+(s.prefix||""),t.push(s)}),t.length&&(this.options=[...t],this._options=[...t])}}updated(e){if(e.has("_value")&&this.valueChanged(this._value,e.get("_value")),e.has("value")&&(Array.isArray(this.value)?this._value=this.value:this.value&&this.multiple?this._value=this.value.split(","):this.value?this._value=[this.value]:this._value=[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]]),this.isMaxItemsReached()),e.has("defaultOptions")&&this.defaultOptions.length){const t=(Array.isArray(this.options)?this.options:[]).filter(i=>i.userAdded)||[];this.options=[...t,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(e.has("options")){const s=(e.get("options")||this._options||[]).filter(l=>l&&l.userAdded).filter(l=>!(Array.isArray(this.options)?this.options:[]).some(o=>o.value===l.value)),n=[...s,...this.options];this._options=n,s.length>0&&(this.options=n),this._options.forEach(l=>{if(l.value&&!l.label&&(l.label=l.value),l.selected&&!this._value.includes(l.value)){const o=[...this._value];this._value=[...this._value,l.value],this.valueChanged(this._value,o)}l.fulltext=l.value+l.label+(l.prefix||""),l.selected=l.selected||this._value.includes(l.value)})}e.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),super.updated(e)}attributeChangedCallback(e,t,i){e==="value"&&(Array.isArray(this.value)?this._value=this.value:this.value&&this.multiple?this._value=this.value.split(","):this.value?this._value=[this.value]:this._value=[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]])),e==="options"&&(this._options=Array.isArray(this.options)?[...this.options]:[],this._options.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!this._value.includes(s.value)&&(this._value=[...this._value,s.value]),s.fulltext=s.value+s.label+(s.prefix||"")}),this._search=""),super.attributeChangedCallback(e,t,i)}render(){return a.x`
1
+ "use strict";const a=require("./element-D62wHiNU.cjs"),c=require("./if-defined-CkVc_RJD.cjs"),d=require("./state-BkE_Rxl7.cjs"),r=require("./ref-BfgcOXko.cjs"),y=require("./class-map-CG3vIaNm.cjs"),O=require("./repeat-DzibMwhi.cjs"),$=require("./input-element-Y8sdrq9C.cjs"),I=require("./pkt-options-controller-CiuBG6Lt.cjs"),w=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-DVjNwf8-.cjs");require("./icon-__Hjt2XZ.cjs");require("./tag-BKq07hGI.cjs");require("./listbox-L-iOSF7M.cjs");const C={displayValueAs:{default:"label"}},R={props:C};var V=Object.defineProperty,A=Object.getOwnPropertyDescriptor,h=(v,e,t,i)=>{for(var s=i>1?void 0:i?A(e,t):e,n=v.length-1,l;n>=0;n--)(l=v[n])&&(s=(i?l(e,t,s):l(s))||s);return i&&s&&V(e,t,s),s};exports.PktCombobox=class extends $.PktInputElement{constructor(){super(),this.helptextSlot=r.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=R.props.displayValueAs.default,this.tagPlacement=null,this._options=[],this._isOptionsOpen=!1,this._value=[],this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._editingSingleValue=!1,this.inputRef=r.e(),this.arrowRef=r.e(),this.listboxRef=r.e(),this.focusRef=r.e(),this.optionTagRef=r.e(),this.optionsController=new I.PktOptionsSlotController(this),this.slotController=new w.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){var e;if(super.connectedCallback(),document&&document.body.addEventListener("click",t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.handleFocusOut(t)}),this._options=[],this.defaultOptions&&this.defaultOptions.length){const t=((e=this.options)==null?void 0:e.filter(i=>i.userAdded))||[];this.options=[...t,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(this.optionsController.nodes.length){const t=[];this.optionsController.nodes.forEach(i=>{if(!i.textContent&&!i.getAttribute("value"))return null;const s={value:i.getAttribute("value")||i.textContent||"",label:i.textContent||i.getAttribute("value")||""};i.getAttribute("data-prefix")&&(s.prefix=i.getAttribute("data-prefix")||void 0),i.getAttribute("tagskincolor")&&(s.tagSkinColor=i.getAttribute("tagskincolor")),i.getAttribute("description")&&(s.description=i.getAttribute("description")||void 0),s.fulltext=s.value+s.label+(s.prefix||""),t.push(s)}),t.length&&(this.options=[...t],this._options=[...t])}}updated(e){if(e.has("_value")&&this.valueChanged(this._value,e.get("_value")),e.has("value")&&(Array.isArray(this.value)?this._value=this.value:this.value&&this.multiple?this._value=this.value.split(","):this.value?this._value=[this.value]:this._value=[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]]),this.isMaxItemsReached()),e.has("defaultOptions")&&this.defaultOptions.length){const t=(Array.isArray(this.options)?this.options:[]).filter(i=>i.userAdded)||[];this.options=[...t,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(e.has("options")){const s=(e.get("options")||this._options||[]).filter(l=>l&&l.userAdded).filter(l=>!(Array.isArray(this.options)?this.options:[]).some(o=>o.value===l.value)),n=[...s,...this.options];this._options=n,s.length>0&&(this.options=n),this._options.forEach(l=>{if(l.value&&!l.label&&(l.label=l.value),l.selected&&!this._value.includes(l.value)){const o=[...this._value];this._value=[...this._value,l.value],this.valueChanged(this._value,o)}l.fulltext=l.value+l.label+(l.prefix||""),l.selected=l.selected||this._value.includes(l.value)})}e.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),super.updated(e)}attributeChangedCallback(e,t,i){e==="value"&&(Array.isArray(this.value)?this._value=this.value:this.value&&this.multiple?this._value=this.value.split(","):this.value?this._value=[this.value]:this._value=[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]])),e==="options"&&(this._options=Array.isArray(this.options)?[...this.options]:[],this._options.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!this._value.includes(s.value)&&(this._value=[...this._value,s.value]),s.fulltext=s.value+s.label+(s.prefix||"")}),this._search=""),super.attributeChangedCallback(e,t,i)}render(){return a.x`
2
2
  <pkt-input-wrapper
3
3
  .label=${this.label}
4
4
  .helptext=${this.helptext}
@@ -7,7 +7,7 @@ import { c as R } from "./repeat-B6qPUgAq.js";
7
7
  import { P as V } from "./input-element-DQOVrqUZ.js";
8
8
  import { P as A } from "./pkt-options-controller-CZO1nxZ8.js";
9
9
  import { P as C } from "./pkt-slot-controller-BPGj-LC5.js";
10
- import "./input-wrapper-D_JdEqcO.js";
10
+ import "./input-wrapper-CQzXG44g.js";
11
11
  import "./icon-B1-mkmwB.js";
12
12
  import "./tag-NZ5oeGfw.js";
13
13
  import "./listbox-n4wjlLqD.js";
@@ -0,0 +1,190 @@
1
+ "use strict";const y=require("./class-map-CG3vIaNm.cjs"),f=require("./if-defined-CkVc_RJD.cjs"),r=require("./element-D62wHiNU.cjs"),S=require("./state-BkE_Rxl7.cjs"),p=require("./calendar-DH-fCGyW.cjs"),_=require("./input-element-Y8sdrq9C.cjs"),u=require("./ref-BfgcOXko.cjs");require("./icon-__Hjt2XZ.cjs");require("./input-wrapper-DVjNwf8-.cjs");const T=require("./repeat-DzibMwhi.cjs");require("./tag-BKq07hGI.cjs");const O=require("./stringutils-CkVRq4jP.cjs"),R=require("./pkt-slot-controller-BzddBp7z.cjs"),I=i=>new Promise(e=>setTimeout(e,i)),g={isIOS(){const i=navigator.userAgent;return!!(/iP(hone|od|ad)/.test(i)||/Macintosh/.test(i)&&"ontouchend"in document)}},m={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:p.isValidDateRange(i[0],i[1])},sortDates(i){return p.sortDateStrings(i)},filterSelectableDates(i,e,t,s,a){return p.filterSelectableDates(i,e,t,s,a)}},B={getInputType(){return g.isIOS()?"text":"date"}},v={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,a){var l,h,C,P;const n=i.value;n&&(t&&t>n?e.setValidity({rangeUnderflow:!0},((h=(l=a==null?void 0:a.forms)==null?void 0:l.messages)==null?void 0:h.rangeUnderflow)||"Value is below minimum",i):s&&s<n&&e.setValidity({rangeOverflow:!0},((P=(C=a==null?void 0:a.forms)==null?void 0:C.messages)==null?void 0:P.rangeOverflow)||"Value is above maximum",i))}},w={addToSelected(i,e,t,s){const a=i.target;if(!a.value)return;const n=t?p.newDate(t):null,l=s?p.newDate(s):null,h=p.newDate(a.value.split(",")[0]);h&&!isNaN(h.getTime())&&(!n||h>=n)&&(!l||h<=l)&&e.value&&e.value.handleDateSelect(h),a.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(),a=t?s.height+30:s.height,n=i.value.getBoundingClientRect().height;let l=t?"calc(100% - 30px)":"100%";s&&s.top+n>window.innerHeight&&s.top-n>0&&(l=`calc(100% - ${a}px - ${n}px)`),i.value.style.top=l}},D={getInputClasses(i,e,t,s){return{"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":i,"pkt-datepicker--hasrangelabels":e,"pkt-datepicker--multiple":t,"pkt-datepicker--range":s}},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}}},x={processDateSelection(i,e,t){return!e&&!t?i[0]||"":Array.isArray(i)?i.join(","):i},updateInputValues(i,e,t,s,a,n){i.value&&(s&&(e!=null&&e.value)?(i.value.value=t[0]??"",e.value.value=t[1]??"",n(i.value),n(e.value)):a||(i.value.value=t.length?t[0]:"",n(i.value)))},processRangeBlur(i,e,t,s,a){var l;const n=i.target;if(n.value){a(n);const h=p.fromISOToDate(n.value);h&&e[0]!==n.value&&e[1]&&(s(),(l=t==null?void 0:t.value)==null||l.handleDateSelect(h))}else e[0]&&s()}},k={handleInputKeydown(i,e,t,s,a,n){const{key:l}=i;l===","&&(i.preventDefault(),n?n(i):a&&a()),(l==="Space"||l===" ")&&(i.preventDefault(),e(i)),l==="Enter"&&(i.preventDefault(),t?t():s?s():a&&a())},handleButtonKeydown(i,e){const{key:t}=i;(t==="Enter"||t===" "||t==="Space")&&(i.preventDefault(),e(i))}};var A=Object.defineProperty,E=Object.getOwnPropertyDescriptor,b=(i,e,t,s)=>{for(var a=s>1?void 0:s?E(e,t):e,n=i.length-1,l;n>=0;n--)(l=i[n])&&(a=(s?l(e,t,a):l(a))||a);return s&&a&&A(e,t,a),a};exports.PktDateTags=class extends r.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},r.x`
2
+ <div class=${y.e(this.classes)} aria-live="polite">
3
+ ${Array.isArray(this.dates)&&this.dates[0]?T.c(m.sortDates((this.dates??[]).filter(Boolean)),e=>e,e=>{var t;return r.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} ${p.fromISOtoLocal(e,this.dateformat)}`}
8
+ >
9
+ <time datetime=${e}>${p.fromISOtoLocal(e,this.dateformat)}</time>
10
+ </pkt-tag>`}):r.E}
11
+ </div>
12
+ `}};b([r.n({type:Array})],exports.PktDateTags.prototype,"dates",2);b([r.n({type:String})],exports.PktDateTags.prototype,"dateformat",2);b([r.n({type:String,attribute:"class"})],exports.PktDateTags.prototype,"className",2);b([r.n({type:String,attribute:"id-base"})],exports.PktDateTags.prototype,"idBase",2);exports.PktDateTags=b([r.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}},$={props:q};var F=Object.defineProperty,M=Object.getOwnPropertyDescriptor,c=(i,e,t,s)=>{for(var a=s>1?void 0:s?M(e,t):e,n=i.length-1,l;n>=0;n--)(l=i[n])&&(a=(s?l(e,t,a):l(a))||a);return s&&a&&F(e,t,a),a};let d=class extends r.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=u.e(),this.calendarRef=u.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 w.addToSelected=="function")return w.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 r.x`
13
+ <div
14
+ class="${y.e(i)}"
15
+ ${u.n(this.popupRef)}
16
+ id="date-popup"
17
+ ?hidden=${!this.open}
18
+ aria-hidden="${!this.open}"
19
+ >
20
+ <pkt-calendar
21
+ ${u.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([r.n({type:Boolean,reflect:!0})],d.prototype,"open",2);c([r.n({type:Boolean})],d.prototype,"multiple",2);c([r.n({type:Boolean})],d.prototype,"range",2);c([r.n({type:Boolean})],d.prototype,"weeknumbers",2);c([r.n({type:Boolean})],d.prototype,"withcontrols",2);c([r.n({type:Number})],d.prototype,"maxMultiple",2);c([r.n({type:Array})],d.prototype,"selected",2);c([r.n({type:String})],d.prototype,"earliest",2);c([r.n({type:String})],d.prototype,"latest",2);c([r.n({type:Array})],d.prototype,"excludedates",2);c([r.n({type:Array})],d.prototype,"excludeweekdays",2);c([r.n({type:String})],d.prototype,"currentmonth",2);d=c([r.t("pkt-datepicker-popup")],d);var L=Object.defineProperty,V=Object.getOwnPropertyDescriptor,o=(i,e,t,s)=>{for(var a=s>1?void 0:s?V(e,t):e,n=i.length-1,l;n>=0;n--)(l=i[n])&&(a=(s?l(e,t,a):l(a))||a);return s&&a&&L(e,t,a),a};exports.PktDatepicker=class extends _.PktInputElement{constructor(){super(),this._valueProperty="",this.datepickerPopupRef=u.e(),this._value=[],this.label="Datovelger",this.dateformat=$.props.dateformat.default,this.multiple=$.props.multiple.default,this.maxlength=null,this.range=$.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=$.props.weeknumbers.default,this.withcontrols=$.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.buttonClasses={},this.inputRef=u.e(),this.inputRefTo=u.e(),this.btnRef=u.e(),this.calRef=u.e(),this.popupRef=u.e(),this.helptextSlot=u.e(),this.addToSelected=e=>{const t=this.datepickerPopupRef.value;return t&&typeof t.addToSelected=="function"?t.addToSelected(e,this.min,this.max):w.addToSelected(e,this.calRef,this.min,this.max)},this.slotController=new R.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 B.getInputType()}connectedCallback(){super.connectedCallback(),this.timezone&&this.timezone!==window.pktTz&&(window.pktTz=this.timezone),this.name=m.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=m.parseValue(e),a=this.multiple&&s.length>1?m.filterSelectableDates(s,this.min,this.max,this.excludedates,this.excludeweekdays):s;if(this.range&&!m.validateRangeOrder(a)){this._value=[],this._valueProperty="",super.valueChanged("",t);return}this._value=a;const n=m.formatValue(a);this._valueProperty!==n&&(this._valueProperty=n),super.valueChanged(n,t)}attributeChangedCallback(e,t,s){e==="value"&&this.value!==t&&this.valueChanged(s,t),e==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=m.normalizeStringArray(s||"")),e==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=m.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"),a=Array.isArray(s)?s.join(","):s;this.valueChanged(t,a)}(e.has("multiple")||e.has("range"))&&(this.name=m.normalizeNameForMultiple(this.name,this.multiple,this.range)||this.name),e.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=m.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)}renderInput(){return r.x`
38
+ <input
39
+ class="${y.e(this.inputClasses)}"
40
+ .type=${this.inputType}
41
+ id="${this.id}-input"
42
+ .value=${this._value[0]??""}
43
+ min=${f.o(this.min)}
44
+ max=${f.o(this.max)}
45
+ placeholder=${f.o(this.placeholder)}
46
+ ?readonly=${this.readonly}
47
+ aria-describedby="${this.id}-helptext"
48
+ @click=${e=>{e.preventDefault(),this.showCalendar()}}
49
+ ?disabled=${this.disabled}
50
+ @keydown=${e=>k.handleInputKeydown(e,t=>this.toggleCalendar(t),()=>v.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()})}
51
+ @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
52
+ @focus=${()=>{this.onFocus(),g.isIOS()&&this.showCalendar()}}
53
+ @blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.relatedTarget)||this.onBlur(),this.manageValidity(e.target),this.value=e.target.value}}
54
+ @change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
55
+ ${u.n(this.inputRef)}
56
+ />
57
+ `}renderRangeInput(){const e=D.getRangeLabelClasses(this.showRangeLabels);return r.x`
58
+ ${this.showRangeLabels?r.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:r.E}
59
+ <input
60
+ class=${y.e(this.inputClasses)}
61
+ .type=${this.inputType}
62
+ id="${this.id}-input"
63
+ .value=${this._value[0]??""}
64
+ min=${f.o(this.min)}
65
+ max=${f.o(this.max)}
66
+ placeholder=${f.o(this.placeholder)}
67
+ ?readonly=${this.readonly}
68
+ ?disabled=${this.disabled}
69
+ @click=${t=>{t.preventDefault(),this.showCalendar()}}
70
+ @keydown=${t=>k.handleInputKeydown(t,s=>this.toggleCalendar(s),()=>v.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()})}
71
+ @input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
72
+ @focus=${()=>{this.onFocus(),g.isIOS()&&this.showCalendar()}}
73
+ @blur=${t=>{x.processRangeBlur(t,this._value,this.calRef,()=>this.clearInputValue(),s=>this.manageValidity(s))}}
74
+ @change=${t=>{t.stopImmediatePropagation()}}
75
+ ${u.n(this.inputRef)}
76
+ />
77
+ <div class="${y.e(e)}" id="${this.id}-to-label">
78
+ ${this.strings.generic.to}
79
+ </div>
80
+ ${this.showRangeLabels?r.E:r.x` <div class="pkt-input-separator">–</div> `}
81
+ <input
82
+ class=${y.e(this.inputClasses)}
83
+ .type=${this.inputType}
84
+ id="${this.id}-to"
85
+ aria-labelledby="${this.id}-to-label"
86
+ .value=${this._value[1]??""}
87
+ min=${f.o(this.min)}
88
+ max=${f.o(this.max)}
89
+ placeholder=${f.o(this.placeholder)}
90
+ ?readonly=${this.readonly}
91
+ ?disabled=${this.disabled}
92
+ @click=${t=>{t.preventDefault(),this.showCalendar()}}
93
+ @keydown=${t=>k.handleInputKeydown(t,s=>this.toggleCalendar(s),()=>v.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()})}
94
+ @input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
95
+ @focus=${()=>{this.onFocus(),g.isIOS()&&this.showCalendar()}}
96
+ @blur=${t=>{var s,a,n;if((s=this.calRef.value)!=null&&s.contains(t.relatedTarget)||this.onBlur(),t.target.value){this.manageValidity(t.target),v.validateDateInput(t.target,this.internals,this.min,this.max,this.strings);const l=p.fromISOToDate(t.target.value);l&&this._value[1]!==p.formatISODate(l)&&((n=(a=this.calRef)==null?void 0:a.value)==null||n.handleDateSelect(l))}}}
97
+ @change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
98
+ ${u.n(this.inputRefTo)}
99
+ />
100
+ `}renderMultipleInput(){return r.x`
101
+ <input
102
+ class=${y.e(this.inputClasses)}
103
+ .type=${this.inputType}
104
+ id="${this.id}-input"
105
+ min=${f.o(this.min)}
106
+ max=${f.o(this.max)}
107
+ placeholder=${f.o(this.placeholder)}
108
+ ?readonly=${this.readonly}
109
+ ?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
110
+ @click=${e=>{e.preventDefault(),this.showCalendar()}}
111
+ @blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.relatedTarget)||this.onBlur(),this.addToSelected(e)}}
112
+ @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
113
+ @focus=${()=>{this.onFocus(),g.isIOS()&&this.showCalendar()}}
114
+ @keydown=${e=>k.handleInputKeydown(e,t=>this.toggleCalendar(t),()=>v.submitFormOrFallback(this.internals,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()}),void 0,void 0,t=>this.addToSelected(t))}
115
+ @change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
116
+ ${u.n(this.inputRef)}
117
+ />
118
+ `}renderCalendar(){return r.x`
119
+ <pkt-datepicker-popup
120
+ class="pkt-contents"
121
+ ?open=${this.calendarOpen}
122
+ ?multiple=${this.multiple}
123
+ ?range=${this.range}
124
+ ?weeknumbers=${this.weeknumbers}
125
+ ?withcontrols=${this.withcontrols}
126
+ .maxMultiple=${this.maxlength}
127
+ .selected=${this._value}
128
+ .earliest=${this.min}
129
+ .latest=${this.max}
130
+ .excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
131
+ .excludeweekdays=${this.excludeweekdays}
132
+ .currentmonth=${this.currentmonth?p.parseISODateString(this.currentmonth):null}
133
+ @date-selected=${e=>{this.value=x.processDateSelection(e.detail,this.multiple,this.range),this._value=e.detail,x.updateInputValues(this.inputRef,this.inputRefTo,this._value,this.range,this.multiple,t=>this.manageValidity(t))}}
134
+ @close=${()=>{this.onBlur(),this.hideCalendar()}}
135
+ ${u.n(this.datepickerPopupRef)}
136
+ ></pkt-datepicker-popup>
137
+ `}render(){return this.inputClasses=D.getInputClasses(this.fullwidth,this.showRangeLabels,this.multiple,this.range),this.buttonClasses=D.getButtonClasses(),r.x`
138
+ <pkt-input-wrapper
139
+ label="${this.label}"
140
+ forId="${this.id}-input"
141
+ ?counter=${this.multiple&&!!this.maxlength}
142
+ .counterCurrent=${this.value?this._value.length:0}
143
+ .counterMaxLength=${this.maxlength}
144
+ ?disabled=${this.disabled}
145
+ ?hasError=${this.hasError}
146
+ ?hasFieldset=${this.hasFieldset}
147
+ ?inline=${this.inline}
148
+ ?required=${this.required}
149
+ ?optionalTag=${this.optionalTag}
150
+ ?requiredTag=${this.requiredTag}
151
+ ?useWrapper=${this.useWrapper}
152
+ .optionalText=${this.optionalText}
153
+ .requiredText=${this.requiredText}
154
+ .tagText=${this.tagText}
155
+ .errorMessage=${this.errorMessage}
156
+ .helptext=${this.helptext}
157
+ .helptextDropdown=${this.helptextDropdown}
158
+ .helptextDropdownButton=${this.helptextDropdownButton}
159
+ .ariaDescribedBy=${this.ariaDescribedBy}
160
+ class="pkt-datepicker"
161
+ >
162
+ <div class="pkt-contents" ${u.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
163
+ ${this.multiple?r.x`<pkt-date-tags
164
+ .dates=${this._value}
165
+ dateformat=${this.dateformat}
166
+ strings=${this.strings}
167
+ id-base=${this.id}
168
+ @date-tag-removed=${e=>{var a;const t=this.datepickerPopupRef.value,s=p.fromISOToDate(e.detail);t&&s&&typeof t.handleDateSelect=="function"?t.handleDateSelect(s):(a=this.calRef.value)==null||a.handleDateSelect(s)}}
169
+ ></pkt-date-tags>`:r.E}
170
+ <div
171
+ class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
172
+ >
173
+ <div class="pkt-input__container">
174
+ ${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
175
+ <button
176
+ class="${y.e(this.buttonClasses)}"
177
+ type="button"
178
+ @click=${this.toggleCalendar}
179
+ @keydown=${e=>k.handleButtonKeydown(e,t=>this.toggleCalendar(t))}
180
+ ?disabled=${this.disabled}
181
+ ${u.n(this.btnRef)}
182
+ >
183
+ <pkt-icon name="calendar"></pkt-icon>
184
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
185
+ </button>
186
+ </div>
187
+ </div>
188
+ </pkt-input-wrapper>
189
+ ${this.renderCalendar()}
190
+ `}handleCalendarPosition(){const e=this.multiple&&!!this.maxlength;w.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(),g.isIOS()&&e.focusOnCurrentDate();return}await I(20),this.handleCalendarPosition(),g.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([r.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);o([r.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);o([r.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);o([r.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);o([r.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);o([r.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);o([r.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);o([r.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);o([r.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);o([r.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);o([r.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);o([r.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);o([r.n({converter:p.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);o([r.n({converter:p.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);o([r.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);o([r.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);o([r.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);o([S.r()],exports.PktDatepicker.prototype,"inputClasses",2);o([S.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=o([r.t("pkt-datepicker")],exports.PktDatepicker);