@oslokommune/punkt-elements 13.5.13 → 13.6.0

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.0](https://github.com/oslokommune/punkt/compare/13.5.13...13.6.0) (2025-09-18)
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.13](https://github.com/oslokommune/punkt/compare/13.5.12...13.5.13) (2025-09-12)
9
26
 
10
27
  ### ⚠ BREAKING CHANGES
@@ -1940,11 +1940,11 @@ h = d([
1940
1940
  ], h);
1941
1941
  export {
1942
1942
  h as P,
1943
- y as a,
1944
- He as b,
1943
+ Ae as a,
1944
+ y as b,
1945
1945
  Oe as c,
1946
1946
  L as d,
1947
- Ae as f,
1947
+ He as f,
1948
1948
  T as n,
1949
1949
  N as p
1950
1950
  };
@@ -0,0 +1,169 @@
1
+ "use strict";const c=require("./class-map-BBG2gMX4.cjs"),o=require("./if-defined-Cni-RHLS.cjs"),s=require("./element-6DBpyGQm.cjs"),m=require("./state-DPobt-Yz.cjs"),u=require("./calendar-32W9p9uc.cjs"),y=require("./input-element-C4xJoM-X.cjs"),n=require("./ref-iJtiv3o2.cjs");require("./icon-B_ryAy4Q.cjs");require("./input-wrapper-CZ-a00V7.cjs");const k=require("./repeat-CDsZqct8.cjs");require("./tag-Bbs0U_Au.cjs");const $=require("./stringutils-CkVRq4jP.cjs"),b=require("./pkt-slot-controller-BzddBp7z.cjs");var x=Object.defineProperty,D=Object.getOwnPropertyDescriptor,f=(p,t,e,i)=>{for(var a=i>1?void 0:i?D(t,e):t,l=p.length-1,h;l>=0;l--)(h=p[l])&&(a=(i?h(t,e,a):h(a))||a);return i&&a&&x(t,e,a),a};exports.PktDateTags=class extends s.PktElement{constructor(){super(...arguments),this.dates=[],this.dateformat="dd.MM.yyyy",this.className="pkt-datepicker__tags",this.idBase=$.uuidish()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},s.x`
2
+ <div class=${c.e(this.classes)} aria-live="polite">
3
+ ${Array.isArray(this.dates)&&this.dates[0]?k.c((this.dates??[]).filter(Boolean).sort(),t=>t,t=>{var e;return s.x` <pkt-tag
4
+ id=${this.idBase+t+"-tag"}
5
+ closeTag
6
+ @close=${()=>{this.dispatchEvent(new CustomEvent("date-tag-removed",{detail:t}))}}
7
+ .ariaLabel=${`${(e=this.strings)==null?void 0:e.calendar.deleteDate} ${u.fromISOtoLocal(t,this.dateformat)}`}
8
+ >
9
+ <time datetime=${t}>${u.fromISOtoLocal(t,this.dateformat)}</time>
10
+ </pkt-tag>`}):s.E}
11
+ </div>
12
+ `}};f([s.n({type:Array})],exports.PktDateTags.prototype,"dates",2);f([s.n({type:String})],exports.PktDateTags.prototype,"dateformat",2);f([s.n({type:String,attribute:"class"})],exports.PktDateTags.prototype,"className",2);f([s.n({type:String,attribute:"id-base"})],exports.PktDateTags.prototype,"idBase",2);exports.PktDateTags=f([s.t("pkt-date-tags")],exports.PktDateTags);const w={dateformat:{default:"dd.MM.yyyy"},min:{default:null},max:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},d={props:w};var R=Object.defineProperty,C=Object.getOwnPropertyDescriptor,r=(p,t,e,i)=>{for(var a=i>1?void 0:i?C(t,e):t,l=p.length-1,h;l>=0;l--)(h=p[l])&&(a=(i?h(t,e,a):h(a))||a);return i&&a&&R(t,e,a),a};const v=p=>new Promise(t=>setTimeout(t,p));exports.PktDatepicker=class extends y.PktInputElement{constructor(){super(),this._valueProperty="",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.buttonClasses={},this.inputRef=n.e(),this.inputRefTo=n.e(),this.btnRef=n.e(),this.calRef=n.e(),this.popupRef=n.e(),this.helptextSlot=n.e(),this.addToSelected=t=>{const e=t.target;if(!e.value)return;const i=this.min?u.newDate(this.min):null,a=this.max?u.newDate(this.max):null,l=u.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 b.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||d.props.min.default,this.max=this.max||d.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 v(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`
13
+ <input
14
+ class="${c.e(this.inputClasses)}"
15
+ .type=${this.inputType}
16
+ id="${this.id}-input"
17
+ .value=${this._value[0]??""}
18
+ min=${o.o(this.min)}
19
+ max=${o.o(this.max)}
20
+ placeholder=${o.o(this.placeholder)}
21
+ ?readonly=${this.readonly}
22
+ aria-describedby="${this.id}-helptext"
23
+ @click=${t=>{t.preventDefault(),this.showCalendar()}}
24
+ ?disabled=${this.disabled}
25
+ @keydown=${t=>{var e,i;if(t.key===","&&((e=this.inputRef.value)==null||e.blur()),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const a=this.internals.form;a?a.requestSubmit():(i=this.inputRef.value)==null||i.blur()}}}
26
+ @input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
27
+ @focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
28
+ @blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.manageValidity(t.target),this.value=t.target.value}}
29
+ @change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
30
+ ${n.n(this.inputRef)}
31
+ />
32
+ `}renderRangeInput(){const t={"pkt-input-prefix":this.showRangeLabels,"pkt-hide":!this.showRangeLabels};return s.x`
33
+ ${this.showRangeLabels?s.x` <div class="pkt-input-prefix">${this.strings.generic.from}</div> `:s.E}
34
+ <input
35
+ class=${c.e(this.inputClasses)}
36
+ .type=${this.inputType}
37
+ id="${this.id}-input"
38
+ .value=${this._value[0]??""}
39
+ min=${o.o(this.min)}
40
+ max=${o.o(this.max)}
41
+ placeholder=${o.o(this.placeholder)}
42
+ ?readonly=${this.readonly}
43
+ ?disabled=${this.disabled}
44
+ @click=${e=>{e.preventDefault(),this.showCalendar()}}
45
+ @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()}}}
46
+ @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
47
+ @focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
48
+ @blur=${e=>{var i,a;if(e.target.value){this.manageValidity(e.target);const l=u.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()}}
49
+ @change=${e=>{e.stopImmediatePropagation()}}
50
+ ${n.n(this.inputRef)}
51
+ />
52
+ <div class="${c.e(t)}" id="${this.id}-to-label">
53
+ ${this.strings.generic.to}
54
+ </div>
55
+ ${this.showRangeLabels?s.E:s.x` <div class="pkt-input-separator">–</div> `}
56
+ <input
57
+ class=${c.e(this.inputClasses)}
58
+ .type=${this.inputType}
59
+ id="${this.id}-to"
60
+ aria-labelledby="${this.id}-to-label"
61
+ .value=${this._value[1]??""}
62
+ min=${o.o(this.min)}
63
+ max=${o.o(this.max)}
64
+ placeholder=${o.o(this.placeholder)}
65
+ ?readonly=${this.readonly}
66
+ ?disabled=${this.disabled}
67
+ @click=${e=>{e.preventDefault(),this.showCalendar()}}
68
+ @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()}}}
69
+ @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
70
+ @focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
71
+ @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 h=e.target.value;this.min&&this.min>h?this.internals.setValidity({rangeUnderflow:!0},this.strings.forms.messages.rangeUnderflow,e.target):this.max&&this.max<h&&this.internals.setValidity({rangeOverflow:!0},this.strings.forms.messages.rangeOverflow,e.target);const g=u.fromISOToDate(e.target.value);g&&this._value[1]!==u.formatISODate(g)&&((l=(a=this.calRef)==null?void 0:a.value)==null||l.handleDateSelect(g))}}}
72
+ @change=${e=>{this.touched=!0,e.stopImmediatePropagation()}}
73
+ ${n.n(this.inputRefTo)}
74
+ />
75
+ `}renderMultipleInput(){return s.x`
76
+ <input
77
+ class=${c.e(this.inputClasses)}
78
+ .type=${this.inputType}
79
+ id="${this.id}-input"
80
+ min=${o.o(this.min)}
81
+ max=${o.o(this.max)}
82
+ placeholder=${o.o(this.placeholder)}
83
+ ?readonly=${this.readonly}
84
+ ?disabled=${this.disabled||this.maxlength&&this._value.length>=this.maxlength}
85
+ @click=${t=>{t.preventDefault(),this.showCalendar()}}
86
+ @blur=${t=>{var e;(e=this.calRef.value)!=null&&e.contains(t.relatedTarget)||this.onBlur(),this.addToSelected(t)}}
87
+ @input=${t=>{this.onInput(),t.stopImmediatePropagation()}}
88
+ @focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
89
+ @keydown=${t=>{var e;if(t.key===","&&(t.preventDefault(),this.addToSelected(t)),(t.key==="Space"||t.key===" ")&&(t.preventDefault(),this.toggleCalendar(t)),t.key==="Enter"){const i=this.internals.form;i?i.requestSubmit():(e=this.inputRef.value)==null||e.blur()}}}
90
+ @change=${t=>{this.touched=!0,t.stopImmediatePropagation()}}
91
+ ${n.n(this.inputRef)}
92
+ />
93
+ `}renderCalendar(){return s.x`<div
94
+ class="pkt-calendar-popup pkt-${this.calendarOpen?"show":"hide"}"
95
+ @focusout=${t=>{this.calendarOpen&&this.handleFocusOut(t)}}
96
+ id="${this.id}-popup"
97
+ ${n.n(this.popupRef)}
98
+ >
99
+ <pkt-calendar
100
+ id="${this.id}-calendar"
101
+ ?multiple=${this.multiple}
102
+ ?range=${this.range}
103
+ ?weeknumbers=${this.weeknumbers}
104
+ ?withcontrols=${this.withcontrols}
105
+ .maxMultiple=${this.maxlength}
106
+ .selected=${this._value}
107
+ .earliest=${this.min}
108
+ .latest=${this.max}
109
+ .excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
110
+ .excludeweekdays=${this.excludeweekdays}
111
+ .currentmonth=${this.currentmonth?u.parseISODateString(this.currentmonth):null}
112
+ @date-selected=${t=>{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)))}}
113
+ @close=${()=>{this.onBlur(),this.hideCalendar()}}
114
+ ${n.n(this.calRef)}
115
+ ></pkt-calendar>
116
+ </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`
117
+ <pkt-input-wrapper
118
+ label="${this.label}"
119
+ forId="${this.id}-input"
120
+ ?counter=${this.multiple&&!!this.maxlength}
121
+ .counterCurrent=${this.value?this._value.length:0}
122
+ .counterMaxLength=${this.maxlength}
123
+ ?disabled=${this.disabled}
124
+ ?hasError=${this.hasError}
125
+ ?hasFieldset=${this.hasFieldset}
126
+ ?inline=${this.inline}
127
+ ?required=${this.required}
128
+ ?optionalTag=${this.optionalTag}
129
+ ?requiredTag=${this.requiredTag}
130
+ ?useWrapper=${this.useWrapper}
131
+ .optionalText=${this.optionalText}
132
+ .requiredText=${this.requiredText}
133
+ .tagText=${this.tagText}
134
+ .errorMessage=${this.errorMessage}
135
+ .helptext=${this.helptext}
136
+ .helptextDropdown=${this.helptextDropdown}
137
+ .helptextDropdownButton=${this.helptextDropdownButton}
138
+ .ariaDescribedBy=${this.ariaDescribedBy}
139
+ class="pkt-datepicker"
140
+ >
141
+ <div class="pkt-contents" ${n.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
142
+ ${this.multiple?s.x`<pkt-date-tags
143
+ .dates=${this._value}
144
+ dateformat=${this.dateformat}
145
+ strings=${this.strings}
146
+ id-base=${this.id}
147
+ @date-tag-removed=${t=>{var e;(e=this.calRef.value)==null||e.handleDateSelect(u.fromISOToDate(t.detail))}}
148
+ ></pkt-date-tags>`:s.E}
149
+ <div
150
+ class="pkt-datepicker__inputs ${this.range&&this.showRangeLabels?"pkt-input__range-inputs":""}"
151
+ >
152
+ <div class="pkt-input__container">
153
+ ${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
154
+ <button
155
+ class="${c.e(this.buttonClasses)}"
156
+ type="button"
157
+ @click=${this.toggleCalendar}
158
+ @keydown=${t=>{(t.key==="Enter"||t.key===" "||t.key==="Space")&&(t.preventDefault(),this.toggleCalendar(t))}}
159
+ ?disabled=${this.disabled}
160
+ ${n.n(this.btnRef)}
161
+ >
162
+ <pkt-icon name="calendar"></pkt-icon>
163
+ <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
164
+ </button>
165
+ </div>
166
+ </div>
167
+ </pkt-input-wrapper>
168
+ ${this.renderCalendar()}
169
+ `}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 h=e?"calc(100% - 30px)":"100%";i&&i.top+l>window.innerHeight&&i.top-l>0&&(h=`calc(100% - ${a}px - ${l}px)`),this.popupRef.value.style.top=h}}handleFocusOut(t){this.contains(t.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var t;this.calendarOpen=!0,await v(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=""}};r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",1);r([s.n({type:Array})],exports.PktDatepicker.prototype,"_value",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"label",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);r([s.n({type:Number,reflect:!0})],exports.PktDatepicker.prototype,"maxlength",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);r([s.n({type:Boolean})],exports.PktDatepicker.prototype,"showRangeLabels",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"min",2);r([s.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"max",2);r([s.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"withcontrols",2);r([s.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);r([s.n({converter:u.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);r([s.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);r([s.n({type:String})],exports.PktDatepicker.prototype,"timezone",2);r([m.r()],exports.PktDatepicker.prototype,"inputClasses",2);r([m.r()],exports.PktDatepicker.prototype,"buttonClasses",2);exports.PktDatepicker=r([s.t("pkt-datepicker")],exports.PktDatepicker);