@oslokommune/punkt-elements 20.1.0 → 20.1.3
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 +31 -0
- package/dist/{calendar-xYEsKilS.cjs → calendar-KZlln5k8.cjs} +2 -2
- package/dist/{calendar-CkAAgviq.js → calendar-T_iFl5mR.js} +2 -2
- package/dist/{checkbox-Cg7wnn8U.cjs → checkbox-BS0iHeSP.cjs} +1 -1
- package/dist/{checkbox-XvlUQmg5.js → checkbox-DCaSNEjy.js} +1 -1
- package/dist/{checkbox-group-BF29zyLd.cjs → checkbox-group-BZhrLn4e.cjs} +1 -1
- package/dist/{checkbox-group-CRIV5CX0.js → checkbox-group-GsfZSfMs.js} +2 -2
- package/dist/{combobox-DuXavWEY.cjs → combobox-DoUwp_6k.cjs} +2 -1
- package/dist/{combobox-CDJcIkNJ.js → combobox-_2jd4CHR.js} +4 -3
- package/dist/components/datepicker/datepicker-popup.d.ts +0 -1
- package/dist/components/datepicker/datepicker-utils.d.ts +2 -13
- package/dist/components/datepicker/datepicker.d.ts +32 -4
- package/dist/components/datepicker/index.d.ts +1 -0
- package/dist/{datepicker-DHdFA8Dx.js → datepicker-D60fq9D5.js} +227 -472
- package/dist/datepicker-DErgngTf.cjs +286 -0
- package/dist/{fileupload-Cjde62AR.cjs → fileupload-Cn7CvQtX.cjs} +1 -1
- package/dist/{fileupload-BQw5nlzQ.js → fileupload-dmzxRqGF.js} +4 -4
- package/dist/{header-YbbGgmsD.cjs → header-BQCGdOPT.cjs} +1 -1
- package/dist/{header-CZnKVVt4.js → header-Djjhqu7w.js} +2 -2
- package/dist/{helptext-CQaNvbiv.cjs → helptext-4xBIABJJ.cjs} +1 -1
- package/dist/{helptext-kKmVQkwo.js → helptext-CNg695BI.js} +1 -1
- package/dist/{input-element-CfZIyfon.cjs → input-element-BPzDBWdd.cjs} +1 -1
- package/dist/{input-element-DE0FzjgP.js → input-element-DsWlt-6T.js} +1 -1
- package/dist/{input-wrapper-DYg1VHPv.js → input-wrapper-BBUcHEKx.js} +2 -2
- package/dist/{input-wrapper-CbYMk21W.cjs → input-wrapper-EKGhSUKU.cjs} +1 -1
- package/dist/{listbox-df8gHweY.js → listbox-BcJbeoAT.js} +1 -1
- package/dist/{listbox-Du8llYth.cjs → listbox-gjzS_z0P.cjs} +1 -1
- package/dist/{modal-SBJ8aGvM.js → modal-CvqH9R3w.js} +1 -1
- package/dist/{modal-B3rnE83a.cjs → modal-Du-2AmLz.cjs} +1 -1
- package/dist/{option-group-element-dN0ntPZk.cjs → option-group-element-DgqdU9HX.cjs} +1 -1
- package/dist/{option-group-element-DtSw52Dr.js → option-group-element-Dr2FR6v7.js} +2 -2
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +18 -18
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-Wyq_Q1Ur.cjs → progressbar-BKA9zFnE.cjs} +1 -1
- package/dist/{progressbar-DlbkKRgP.js → progressbar-aKjj5VZg.js} +1 -1
- package/dist/{radio-group-u1IH7g-4.cjs → radio-group-BLVe7aMS.cjs} +1 -1
- package/dist/{radio-group-bRF8fnPW.js → radio-group-DDymupLt.js} +2 -2
- package/dist/{radiobutton-Bf6aFfYt.js → radiobutton-CnExI3Vj.js} +1 -1
- package/dist/{radiobutton-86ZvvDmJ.cjs → radiobutton-XX3zhblA.cjs} +1 -1
- package/dist/{searchinput-D5l64Mkb.cjs → searchinput-C8UHexyf.cjs} +1 -1
- package/dist/{searchinput-DN8kDZQ1.js → searchinput-DUJlxKHH.js} +1 -1
- package/dist/{select-CXIEM2qY.js → select-C4RDEc9h.js} +2 -2
- package/dist/{select-C7kAlSxs.cjs → select-CbVmSYmi.cjs} +1 -1
- package/dist/shared-types/datepicker.d.ts +76 -0
- package/dist/shared-types/index.d.ts +2 -2
- package/dist/shared-utils/datepicker-utils.d.ts +18 -0
- package/dist/shared-utils/forms/focus-within.d.ts +13 -0
- package/dist/{textarea-CRcSfWgX.cjs → textarea-D4yCdiFY.cjs} +1 -1
- package/dist/{textarea-12le8b4I.js → textarea-WktT3N3w.js} +2 -2
- package/dist/{textinput-CC0zxUBT.js → textinput-BPrC2neL.js} +2 -2
- package/dist/{textinput-Dooq2n8W.cjs → textinput-C6AcbxnQ.cjs} +1 -1
- package/dist/{timepicker-Cz81VQu3.js → timepicker-D77gssQg.js} +2 -2
- package/dist/{timepicker-BM4I5w-i.cjs → timepicker-DaqrwM-g.cjs} +1 -1
- package/dist/{utils-Dn5ykFtS.js → utils-BtXhdgpe.js} +2 -2
- package/dist/utils-dl1XA5EE.cjs +1 -0
- package/package.json +2 -2
- package/src/components/calendar/calendar.selection.test.ts +16 -0
- package/src/components/calendar/calendar.ts +4 -3
- package/src/components/combobox/combobox.interaction.test.ts +23 -0
- package/src/components/combobox/combobox.ts +1 -0
- package/src/components/datepicker/datepicker-multiple.ts +2 -6
- package/src/components/datepicker/datepicker-popup.ts +3 -6
- package/src/components/datepicker/datepicker-utils.test.ts +40 -203
- package/src/components/datepicker/datepicker-utils.ts +3 -94
- package/src/components/datepicker/datepicker.accessibility.test.ts +2 -2
- package/src/components/datepicker/datepicker.core.test.ts +236 -0
- package/src/components/datepicker/datepicker.ts +179 -115
- package/src/components/datepicker/index.ts +1 -0
- package/dist/datepicker-Cnrbqm62.cjs +0 -294
- package/dist/utils-63cRpWut.cjs +0 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./element-with-slot-D_8fAzCW.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-EKGhSUKU.cjs"),require("./tag-BAikRN2Y.cjs");const r=require("./calendar-KZlln5k8.cjs"),i=require("./if-defined-Ci4ZQsgL.cjs"),a=require("./ref-C6VUWwmF.cjs"),o=require("./converters-Dp64-kF1.cjs"),s=require("./repeat-CjvNrcUr.cjs"),c=require("./utils-dl1XA5EE.cjs"),l=require("./input-element-BPzDBWdd.cjs");var u={dateformat:`dd.MM.yyyy`,multiple:!1,range:!1,showRangeLabels:!1,weeknumbers:!1,withcontrols:!1,calendarOpen:!1,required:!1,requiredTag:!1,optionalTag:!1,hasError:!1,disabled:!1,inline:!1,fullwidth:!1,useWrapper:!0,inputSize:`medium`},d=class extends e.t{constructor(...e){super(...e),this.dates=[],this.dateformat=`dd.MM.yyyy`,this.className=`pkt-datepicker__tags`,this.idBase=c.t()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},e._`
|
|
2
|
+
<div class=${t.t(this.classes)} aria-live="polite">
|
|
3
|
+
${Array.isArray(this.dates)&&this.dates[0]?s.t(o.h((this.dates??[]).filter(Boolean)),e=>e,t=>e._` <pkt-tag
|
|
4
|
+
id=${this.idBase+t+`-tag`}
|
|
5
|
+
closeTag
|
|
6
|
+
@close=${()=>{this.dispatchEvent(new CustomEvent(`date-tag-removed`,{detail:t}))}}
|
|
7
|
+
.ariaLabel=${`${this.pktStrings.get(`datepicker`).deleteDate} ${o.c(t,this.dateformat)}`}
|
|
8
|
+
>
|
|
9
|
+
<time datetime=${t}>${o.c(t,this.dateformat)}</time>
|
|
10
|
+
</pkt-tag>`):e.h}
|
|
11
|
+
</div>
|
|
12
|
+
`}};e.n([e.u({type:Array})],d.prototype,`dates`,void 0),e.n([e.u({type:String})],d.prototype,`dateformat`,void 0),e.n([e.u({type:String,attribute:`class`})],d.prototype,`className`,void 0),e.n([e.u({type:String,attribute:`id-base`})],d.prototype,`idBase`,void 0);try{e.d(`pkt-date-tags`)(d)}catch{console.warn(`Forsøker å definere <pkt-date-tags>, men den er allerede definert`)}var f=()=>{let e=navigator.userAgent;return!!(/iP(hone|od|ad)/.test(e)||/Macintosh/.test(e)&&`ontouchend`in document)},p=()=>f()?`text`:`date`,m=e=>!e||e.length!==2||o.u(e[0],e[1]),h=e=>o.h(e),g=(e,t,n,r,i)=>o.i(e,t,n,r,i),_=(e,t,n,r,i,a,o=`medium`)=>({"pkt-input":!0,"pkt-datepicker__input":!0,[`pkt-input--${o}`]:!0,"pkt-input--fullwidth":e,"pkt-datepicker--hasrangelabels":t,"pkt-datepicker--multiple":n,"pkt-datepicker--range":r,"ios-readonly-hack":i===!1&&a===`text`}),v=(e=`medium`)=>({"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,[`pkt-btn--${e}`]:!0,"pkt-datepicker__calendar-button":!0}),y=(e,t,n)=>e??(t&&!!n&&n>0),b=(e,t)=>!!e&&e>0&&t>=e,x=(e,t,n=[],i=[])=>{if(!t||e.length!==1||e[0]>t)return e;let[a,o]=r.r([e[0],t]);return r.i(o,[a],r.r(n),i)?[e[0],t]:e},S=(e,t)=>e?t&&t>=e?[e,t]:[e]:[],C=e=>({"pkt-input-prefix":e,"pkt-hide":!e}),w=(e,t,n)=>!t&&!n?Array.isArray(e)?e[0]||``:e:Array.isArray(e)?e.join(`,`):e,T=(e,t,n=!1)=>{if(!e||!t)return;let r=t.parentElement?.getBoundingClientRect()||t.getBoundingClientRect(),i=n?r.height+30:r.height,a=e.getBoundingClientRect().height,o=e instanceof Element&&parseFloat(getComputedStyle(e).marginTop)||0,s=n?`calc(100% - 30px)`:`100%`;if(typeof window<`u`){let e=r.top+r.height+o+a<=window.innerHeight,t=r.top-o-a>=0;!e&&t&&(s=`calc(100% - ${i}px - ${a}px - ${2*o}px)`)}e.style.top=s},E=(e,t,n,r,i,a)=>{let{key:o}=e;o===`,`&&(e.preventDefault(),a?a(e):i&&i()),(o===`Space`||o===` `)&&(e.preventDefault(),t(e)),o===`Enter`&&(e.preventDefault(),n?n():r?r():i&&i())},D=(e,t)=>{let{key:n}=e;(n===`Enter`||n===` `||n===`Space`)&&(e.preventDefault(),t(e))},O={validateRangeOrder:m,sortDates:h,filterSelectableDates:g},k={getInputType:p},A={submitForm(e){let t=e.internals?.form;t&&t.requestSubmit()},submitFormOrFallback(e,t){let n=e?.form;n?n.requestSubmit():t()}},j={addToSelected(e,t,n,r){let i=e.target;if(!i.value)return;let a=n?o.d(n):null,s=r?o.d(r):null,c=o.d(i.value.split(`,`)[0]);c&&!isNaN(c.getTime())&&(!a||c>=a)&&(!s||c<=s)&&t.value&&t.value.handleDateSelect(c),i.value=``},handleCalendarPosition(e,t,n=!1){T(e.value??null,t.value??null,n)}},M={getInputClasses:_,getButtonClasses:v,getRangeLabelClasses:C},N={processDateSelection:w,updateInputValues(e,t,n,r,i,a){e.value&&(r&&t?.value?(e.value.value=n[0]??``,t.value.value=n[1]??``,a(e.value),a(t.value)):i||(e.value.value=n.length?n[0]:``,a(e.value)))}},P={handleInputKeydown:E,handleButtonKeydown:D},F=class extends e.t{constructor(...e){super(...e),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.today=null,this._hasBeenOpened=!1,this.popupRef=a.t(),this.calendarRef=a.t(),this.handleDocumentClick=e=>{if(!this.open)return;let t=e.composedPath(),n=this.parentElement,r=this.popupRef.value;t.includes(this)||t.includes(r)||n&&t.includes(n)||(this.hide(),this.dispatchEvent(new CustomEvent(`close`,{bubbles:!0,composed:!0})))},this.handleDocumentKeydown=e=>{this.open&&e.key===`Escape`&&(this.hide(),this.dispatchEvent(new CustomEvent(`close`,{bubbles:!0,composed:!0})))}}willUpdate(e){super.willUpdate(e),e.has(`open`)&&this.open&&(this._hasBeenOpened=!0)}updated(e){super.updated(e),e.has(`open`)&&(this.open?(document.addEventListener(`keydown`,this.handleDocumentKeydown),document.addEventListener(`click`,this.handleDocumentClick)):(document.removeEventListener(`click`,this.handleDocumentClick),document.removeEventListener(`keydown`,this.handleDocumentKeydown)))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.handleDocumentClick),document.removeEventListener(`keydown`,this.handleDocumentKeydown)}show(){this.open=!0,this.calendarRef.value?.focus()}hide(){this.open=!1}toggle(){this.open?this.hide():this.show()}contains(e){return!!e&&!!this.popupRef.value?.contains(e)}focusOnCurrentDate(){let e=this.calendarRef.value;e&&typeof e.focusOnCurrentDate==`function`&&e.focusOnCurrentDate()}addToSelected(e,t,n){if(this.calendarRef.value&&typeof j.addToSelected==`function`)return j.addToSelected(e,this.calendarRef,t,n);let r=e.target;if(!r.value)return;let i=t?o.d(t):null,a=n?o.d(n):null,s=o.d(r.value.split(`,`)[0]);s&&!isNaN(s.getTime())&&(!i||s>=i)&&(!a||s<=a)&&this.handleDateSelect(s),r.value=``}handleDateSelect(e){let t=this.calendarRef.value;if(t&&typeof t.handleDateSelect==`function`)return t.handleDateSelect(e);let n=o.a(e),r=this.selected.indexOf(n)>=0?this.selected.filter(e=>e!==n):[...this.selected,n];this.selected=r,this.dispatchEvent(new CustomEvent(`date-selected`,{detail:r,bubbles:!0,composed:!0}))}render(){let n={"pkt-calendar-popup":!0,show:this.open,hide:!this.open};return e._`
|
|
13
|
+
<div
|
|
14
|
+
class="${t.t(n)}"
|
|
15
|
+
${a.n(this.popupRef)}
|
|
16
|
+
id="date-popup"
|
|
17
|
+
?hidden=${!this.open}
|
|
18
|
+
aria-hidden="${!this.open}"
|
|
19
|
+
>
|
|
20
|
+
${this.open||this._hasBeenOpened?e._`<pkt-calendar
|
|
21
|
+
${a.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
|
+
.today=${this.today}
|
|
34
|
+
@date-selected=${e=>{e.stopPropagation(),this.selected=e.detail,this.dispatchEvent(new CustomEvent(`date-selected`,{detail:e.detail,bubbles:!0,composed:!0}))}}
|
|
35
|
+
@close=${e=>{e.stopPropagation(),this.hide(),this.dispatchEvent(new CustomEvent(`close`,{bubbles:!0,composed:!0}))}}
|
|
36
|
+
></pkt-calendar>`:e.h}
|
|
37
|
+
</div>
|
|
38
|
+
`}};e.n([e.u({type:Boolean,reflect:!0})],F.prototype,`open`,void 0),e.n([e.u({type:Boolean})],F.prototype,`multiple`,void 0),e.n([e.u({type:Boolean})],F.prototype,`range`,void 0),e.n([e.u({type:Boolean})],F.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean})],F.prototype,`withcontrols`,void 0),e.n([e.u({type:Number})],F.prototype,`maxMultiple`,void 0),e.n([e.u({type:Array})],F.prototype,`selected`,void 0),e.n([e.u({type:String})],F.prototype,`earliest`,void 0),e.n([e.u({type:String})],F.prototype,`latest`,void 0),e.n([e.u({type:Array})],F.prototype,`excludedates`,void 0),e.n([e.u({type:Array})],F.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],F.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],F.prototype,`today`,void 0),e.n([e.l()],F.prototype,`_hasBeenOpened`,void 0);try{e.d(`pkt-datepicker-popup`)(F)}catch{console.warn(`Forsøker å definere <pkt-datepicker-popup>, men den er allerede definert`)}var I=class extends e.t{constructor(...e){super(...e),this.inputType=`date`,this.id=``,this.readonly=!1,this.disabled=!1,this.inputClasses={},this.inputSize=`medium`,this.hasError=!1,this.hasHelptext=!1,this.inputRef=a.t(),this.btnRef=a.t()}get describedBy(){return this.hasHelptext?`${this.id}-input-helptext`:void 0}get errorMessageId(){return this.hasError?`${this.id}-input-error`:void 0}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}))}renderCalendarButton(){return e._`
|
|
39
|
+
<button
|
|
40
|
+
class="${t.t(M.getButtonClasses(this.inputSize))}"
|
|
41
|
+
type="button"
|
|
42
|
+
@click=${e=>this.dispatchToggleCalendar(e)}
|
|
43
|
+
@keydown=${e=>{let{key:t}=e;(t===`Enter`||t===` `||t===`Space`)&&(e.preventDefault(),this.dispatchToggleCalendar(e))}}
|
|
44
|
+
?disabled=${this.disabled}
|
|
45
|
+
${this.btnRef}
|
|
46
|
+
>
|
|
47
|
+
<pkt-icon name="calendar"></pkt-icon>
|
|
48
|
+
<span class="pkt-btn__text">${this.pktStrings.get(`datepicker`).openPicker}</span>
|
|
49
|
+
</button>
|
|
50
|
+
`}createRenderRoot(){return this}};e.n([e.u({type:String})],I.prototype,`inputType`,void 0),e.n([e.u({type:String})],I.prototype,`id`,void 0),e.n([e.u({type:String})],I.prototype,`min`,void 0),e.n([e.u({type:String})],I.prototype,`max`,void 0),e.n([e.u({type:String})],I.prototype,`placeholder`,void 0),e.n([e.u({type:Boolean})],I.prototype,`readonly`,void 0),e.n([e.u({type:Boolean})],I.prototype,`disabled`,void 0),e.n([e.u({type:Object})],I.prototype,`inputClasses`,void 0),e.n([e.u({type:String})],I.prototype,`inputSize`,void 0),e.n([e.u({type:Object})],I.prototype,`internals`,void 0),e.n([e.u({type:Boolean})],I.prototype,`hasError`,void 0),e.n([e.u({type:Boolean})],I.prototype,`hasHelptext`,void 0);var L=class extends I{constructor(...e){super(...e),this.value=``}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent(`manage-validity`,{detail:e,bubbles:!0,composed:!0}))}render(){return e._`
|
|
51
|
+
<div class="pkt-input__container">
|
|
52
|
+
<input
|
|
53
|
+
class="${t.t(this.inputClasses)}"
|
|
54
|
+
.type=${this.inputType}
|
|
55
|
+
id="${this.id}-input"
|
|
56
|
+
.value=${this.value}
|
|
57
|
+
min=${i.t(this.min)}
|
|
58
|
+
max=${i.t(this.max)}
|
|
59
|
+
placeholder=${i.t(this.placeholder)}
|
|
60
|
+
?readonly=${this.isInputReadonly}
|
|
61
|
+
aria-describedby=${i.t(this.describedBy)}
|
|
62
|
+
aria-invalid=${this.hasError}
|
|
63
|
+
aria-errormessage=${i.t(this.errorMessageId)}
|
|
64
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
65
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
66
|
+
?disabled=${this.disabled}
|
|
67
|
+
@keydown=${e=>P.handleInputKeydown(e,e=>this.dispatchToggleCalendar(e),()=>A.submitFormOrFallback(this.internals,()=>this.inputRef.value?.blur()),void 0,()=>this.inputRef.value?.blur())}
|
|
68
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
69
|
+
@focus=${()=>{this.dispatchFocus(),f()&&this.dispatchToggleCalendar(new Event(`focus`))}}
|
|
70
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchManageValidity(e.target),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e.target.value,bubbles:!0,composed:!0}))}}
|
|
71
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
72
|
+
${a.n(this.inputRef)}
|
|
73
|
+
/>
|
|
74
|
+
${this.renderCalendarButton()}
|
|
75
|
+
</div>
|
|
76
|
+
`}};e.n([e.u({type:String})],L.prototype,`value`,void 0);try{e.d(`pkt-datepicker-single`)(L)}catch{console.warn(`Forsøker å definere <pkt-datepicker-single>, men den er allerede definert`)}var R=class extends I{constructor(...e){super(...e),this.value=[],this.label=``,this.showRangeLabels=!1,this.inputRefTo=a.t()}get inputElementTo(){return this.inputRefTo.value}render(){let n=M.getRangeLabelClasses(this.showRangeLabels);return e._`
|
|
77
|
+
<div class="pkt-input__container">
|
|
78
|
+
${this.showRangeLabels?e._` <div class="pkt-input-prefix">${this.pktStrings.get(`generic`).from}</div> `:e.h}
|
|
79
|
+
<input
|
|
80
|
+
aria-describedby=${i.t(this.describedBy)}
|
|
81
|
+
aria-invalid=${this.hasError}
|
|
82
|
+
aria-errormessage=${i.t(this.errorMessageId)}
|
|
83
|
+
class=${t.t(this.inputClasses)}
|
|
84
|
+
.type=${this.inputType}
|
|
85
|
+
id="${this.id}-input"
|
|
86
|
+
aria-label="${this.label} ${this.pktStrings.get(`generic`).from}"
|
|
87
|
+
.value=${this.value[0]??``}
|
|
88
|
+
min=${i.t(this.min)}
|
|
89
|
+
max=${i.t(this.max)}
|
|
90
|
+
placeholder=${i.t(this.placeholder)}
|
|
91
|
+
?readonly=${this.isInputReadonly}
|
|
92
|
+
?disabled=${this.disabled}
|
|
93
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
94
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
95
|
+
@keydown=${e=>P.handleInputKeydown(e,e=>this.dispatchToggleCalendar(e),()=>A.submitFormOrFallback(this.internals,()=>this.inputRefTo.value?.focus()),()=>this.inputRefTo.value?.focus(),()=>this.inputRef.value?.blur())}
|
|
96
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
97
|
+
@focus=${()=>{this.dispatchFocus(),f()&&this.dispatchToggleCalendar(new Event(`focus`))}}
|
|
98
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchEvent(new CustomEvent(`range-blur`,{detail:{event:e,values:this.value,inputType:`from`},bubbles:!0,composed:!0}))}}
|
|
99
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
100
|
+
${a.n(this.inputRef)}
|
|
101
|
+
/>
|
|
102
|
+
<div class="${t.t(n)}" id="${this.id}-to-label">
|
|
103
|
+
${this.pktStrings.get(`generic`).to}
|
|
104
|
+
</div>
|
|
105
|
+
${this.showRangeLabels?e.h:e._` <div class="pkt-input-separator">–</div> `}
|
|
106
|
+
<input
|
|
107
|
+
aria-describedby=${i.t(this.describedBy)}
|
|
108
|
+
aria-invalid=${this.hasError}
|
|
109
|
+
aria-errormessage=${i.t(this.errorMessageId)}
|
|
110
|
+
class=${t.t(this.inputClasses)}
|
|
111
|
+
.type=${this.inputType}
|
|
112
|
+
id="${this.id}-to"
|
|
113
|
+
aria-label="${this.label} ${this.pktStrings.get(`generic`).to}"
|
|
114
|
+
.value=${this.value[1]??``}
|
|
115
|
+
min=${i.t(this.min)}
|
|
116
|
+
max=${i.t(this.max)}
|
|
117
|
+
placeholder=${i.t(this.placeholder)}
|
|
118
|
+
?readonly=${this.isInputReadonly}
|
|
119
|
+
?disabled=${this.disabled}
|
|
120
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
121
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
122
|
+
@keydown=${e=>P.handleInputKeydown(e,e=>this.dispatchToggleCalendar(e),()=>A.submitFormOrFallback(this.internals,()=>this.inputRefTo.value?.blur()),void 0,()=>this.inputRefTo.value?.blur())}
|
|
123
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
124
|
+
@focus=${()=>{this.dispatchFocus(),f()&&this.dispatchToggleCalendar(new Event(`focus`))}}
|
|
125
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchEvent(new CustomEvent(`range-blur`,{detail:{event:e,values:this.value,inputType:`to`},bubbles:!0,composed:!0}))}}
|
|
126
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
127
|
+
${a.n(this.inputRefTo)}
|
|
128
|
+
/>
|
|
129
|
+
${this.renderCalendarButton()}
|
|
130
|
+
</div>
|
|
131
|
+
`}};e.n([e.u({type:Array})],R.prototype,`value`,void 0),e.n([e.u({type:String})],R.prototype,`label`,void 0),e.n([e.u({type:Boolean})],R.prototype,`showRangeLabels`,void 0);try{e.d(`pkt-datepicker-range`)(R)}catch{console.warn(`Forsøker å definere <pkt-datepicker-range>, men den er allerede definert`)}var z=class extends I{constructor(...e){super(...e),this.value=[]}get isInputDisabled(){return this.disabled||b(this.maxlength,this.value.length)}dispatchAddToSelected(e){this.dispatchEvent(new CustomEvent(`add-to-selected`,{detail:e,bubbles:!0,composed:!0}))}render(){return e._`
|
|
132
|
+
<div class="pkt-input__container">
|
|
133
|
+
<input
|
|
134
|
+
aria-describedby=${i.t(this.describedBy)}
|
|
135
|
+
aria-invalid=${this.hasError}
|
|
136
|
+
aria-errormessage=${i.t(this.errorMessageId)}
|
|
137
|
+
class=${t.t(this.inputClasses)}
|
|
138
|
+
.type=${this.inputType}
|
|
139
|
+
id="${this.id}-input"
|
|
140
|
+
min=${i.t(this.min)}
|
|
141
|
+
max=${i.t(this.max)}
|
|
142
|
+
placeholder=${i.t(this.placeholder)}
|
|
143
|
+
?readonly=${this.isInputReadonly}
|
|
144
|
+
?disabled=${this.isInputDisabled}
|
|
145
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
146
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
147
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchAddToSelected(e)}}
|
|
148
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
149
|
+
@focus=${()=>{this.dispatchFocus(),f()&&this.dispatchToggleCalendar(new Event(`focus`))}}
|
|
150
|
+
@keydown=${e=>P.handleInputKeydown(e,e=>this.dispatchToggleCalendar(e),()=>A.submitFormOrFallback(this.internals,()=>this.inputRef.value?.blur()),void 0,void 0,e=>this.dispatchAddToSelected(e))}
|
|
151
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
152
|
+
${a.n(this.inputRef)}
|
|
153
|
+
/>
|
|
154
|
+
${this.renderCalendarButton()}
|
|
155
|
+
</div>
|
|
156
|
+
`}};e.n([e.u({type:Array})],z.prototype,`value`,void 0),e.n([e.u({type:Number})],z.prototype,`maxlength`,void 0);try{e.d(`pkt-datepicker-multiple`)(z)}catch{console.warn(`Forsøker å definere <pkt-datepicker-multiple>, men den er allerede definert`)}var B=(e,t)=>{let n=!1,r=t=>typeof Node<`u`&&t instanceof Node&&t.isConnected&&e(t);return{focusin(e){n||r(e)?n=!0:(n=!0,t(`focus`,e))},focusout(e){r(e)||(n=!1,t(`blur`,e))},reset(){n=!1}}},V,H=class t extends l.t{constructor(...e){super(...e),this._valueProperty=``,this.datepickerPopupRef=a.t(),this._value=[],this.label=`Datovelger`,this.dateformat=u.dateformat,this.multiple=u.multiple,this.maxlength=null,this.range=u.range,this.showRangeLabels=u.showRangeLabels,this.min=null,this.max=null,this.weeknumbers=u.weeknumbers,this.withcontrols=u.withcontrols,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.today=null,this.calendarOpen=u.calendarOpen,this.timezone=`Europe/Oslo`,this.inputClasses={},this.toWithoutFrom=null,this.editedRangeFields=null,this.focusTracker=B(e=>this.contains(e),(e,t)=>{e===`blur`&&this.dropToWithoutFrom(),this.dispatchEvent(new FocusEvent(e,{bubbles:!0,composed:!0,relatedTarget:t}))}),this.lastCalendarSelected=[],this.handleFocusIn=e=>this.focusTracker.focusin(e.relatedTarget),this.handleFocusOut=e=>this.focusTracker.focusout(e.relatedTarget),this.popupRef=a.t(),this.singleInputRef=a.t(),this.rangeInputRef=a.t(),this.multipleInputRef=a.t(),this.addToSelected=e=>this.datepickerPopupRef.value?.addToSelected(e,this.min,this.max)}get value(){return this._valueProperty}set value(e){let t=this._valueProperty,n=Array.isArray(e)?e.join(`,`):e||``;n!==t&&(this._valueProperty=n,this.requestUpdate(`value`,t))}get inputType(){return k.getInputType()}get hasCounter(){return y(this.counter,this.multiple,this.maxlength)}connectedCallback(){super.connectedCallback(),this.timezone&&this.timezone!==window.pktTz&&(window.pktTz=this.timezone),this.addEventListener(`focusin`,this.handleFocusIn),this.addEventListener(`focusout`,this.handleFocusOut)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this.handleFocusIn),this.removeEventListener(`focusout`,this.handleFocusOut),this.focusTracker.reset()}get rangeFieldValues(){return this._value[0]?this._value:[``,this.toWithoutFrom??``]}get calendarSelected(){if(!this.range)return this._value;let[e,t]=this.editedRangeFields??this._value,n=S(e,t);return o.n(n)!==o.n(this.lastCalendarSelected)&&(this.lastCalendarSelected=n),this.lastCalendarSelected}trackRangeFields(){this.editedRangeFields=[this.currentInputElement?.value??``,this.currentInputElementTo?.value??``]}syncRangeFromFields(e){let t=this.currentInputElement,n=this.currentInputElementTo;if(!t||!n)return;let r=t.value;r&&n.value&&r>n.value&&(n.value=``);let i=n.value;this.toWithoutFrom=r?null:i||null,this.editedRangeFields=null,e.target instanceof HTMLInputElement&&e.target.value&&this.manageValidity(e.target),this.value=r?[r,i].filter(Boolean).join(`,`):``}dropToWithoutFrom(){let e=this.currentInputElementTo;this.range&&e&&!this.currentInputElement?.value&&(e.value=``),this.toWithoutFrom=null,this.editedRangeFields=null}formResetCallback(){this.toWithoutFrom=null,this.editedRangeFields=null,super.formResetCallback()}setFormValue(e){super.setFormValue(this.multiple||this.range?o.r(e):e)}focusField(){this.currentInputElement?.focus()}get focusIsInPopup(){let e=this.datepickerPopupRef.value?.popupRef.value;return!!e&&e.contains(document.activeElement)}onInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}valueChanged(e,t){e!==t&&(this.value=e??``,this.deriveValue(t))}deriveValue(e){let t=o.r(this._valueProperty),n=this.multiple&&t.length>1?O.filterSelectableDates(t,this.min,this.max,this.excludedates,this.excludeweekdays):t;this.range&&!O.validateRangeOrder(n)?(this._valueProperty=``,this.getAttribute(`value`)&&this.setAttribute(`value`,``),super.valueChanged(``,e),this._value=[]):(this._valueProperty=o.n(n),this.range&&n.length===1?(this.setFormValue(this._valueProperty),this.hasUpdated&&this._valueProperty!==e&&this.dispatchEvent(new CustomEvent(`value-change`,{detail:n,bubbles:!0,composed:!0}))):super.valueChanged(this._valueProperty,e),this._value=n)}attributeChangedCallback(e,t,n){e===`excludedates`&&typeof this.excludedates==`string`&&(this.excludedates=o.r(n||``)),e===`excludeweekdays`&&typeof this.excludeweekdays==`string`&&(this.excludeweekdays=o.r(n||``)),super.attributeChangedCallback(e,t,n)}willUpdate(e){if(super.willUpdate(e),t.DERIVED_FROM.some(t=>e.has(t))){let t=e.get(`value`);this.deriveValue(Array.isArray(t)?t.join(`,`):t??null)}}updated(e){this.classList.add(`pkt-datepicker`),this.classList.toggle(`pkt-datepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-datepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-datepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-datepicker--xsmall`,this.inputSize===`xsmall`),super.updated(e),this.calendarOpen&&t.POSITIONED_BY.some(t=>e.has(t))&&this.positionOpenCalendar()}get inputRef(){return{value:this.currentInputElement}}get inputRefTo(){return{value:this.currentInputElementTo}}get currentInputElement(){return this.multiple?this.multipleInputRef.value?.inputElement:this.range?this.rangeInputRef.value?.inputElement:this.singleInputRef.value?.inputElement}get currentInputElementTo(){if(this.range)return this.rangeInputRef.value?.inputElementTo}get currentButtonElement(){return this.multiple?this.multipleInputRef.value?.buttonElement:this.range?this.rangeInputRef.value?.buttonElement:this.singleInputRef.value?.buttonElement}get btnRef(){return{value:this.currentButtonElement}}renderInput(){return e._`
|
|
157
|
+
<pkt-datepicker-single
|
|
158
|
+
.value=${this._value[0]??``}
|
|
159
|
+
.inputType=${this.inputType}
|
|
160
|
+
.id=${this.id}
|
|
161
|
+
.min=${this.min}
|
|
162
|
+
.max=${this.max}
|
|
163
|
+
.placeholder=${this.placeholder}
|
|
164
|
+
.readonly=${this.readonly}
|
|
165
|
+
.disabled=${this.isDisabled}
|
|
166
|
+
.inputClasses=${this.inputClasses}
|
|
167
|
+
.inputSize=${this.inputSize}
|
|
168
|
+
.internals=${this.internals}
|
|
169
|
+
.hasError=${this.hasError}
|
|
170
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown||this.hasSlotContent(`helptext`))}
|
|
171
|
+
.strings=${this.strings}
|
|
172
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
173
|
+
@input-change=${()=>this.onInput()}
|
|
174
|
+
@manage-validity=${e=>this.manageValidity(e.detail)}
|
|
175
|
+
@value-change=${e=>{this.value=e.detail}}
|
|
176
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
177
|
+
${a.n(this.singleInputRef)}
|
|
178
|
+
></pkt-datepicker-single>
|
|
179
|
+
`}renderRangeInput(){return e._`
|
|
180
|
+
<pkt-datepicker-range
|
|
181
|
+
.value=${this.rangeFieldValues}
|
|
182
|
+
.inputType=${this.inputType}
|
|
183
|
+
.id=${this.id}
|
|
184
|
+
.label=${this.label}
|
|
185
|
+
.min=${this.min}
|
|
186
|
+
.max=${this.max}
|
|
187
|
+
.placeholder=${this.placeholder}
|
|
188
|
+
.readonly=${this.readonly}
|
|
189
|
+
.disabled=${this.isDisabled}
|
|
190
|
+
.showRangeLabels=${this.showRangeLabels}
|
|
191
|
+
.inputClasses=${this.inputClasses}
|
|
192
|
+
.inputSize=${this.inputSize}
|
|
193
|
+
.internals=${this.internals}
|
|
194
|
+
.hasError=${this.hasError}
|
|
195
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown||this.hasSlotContent(`helptext`))}
|
|
196
|
+
.strings=${this.strings}
|
|
197
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
198
|
+
@input-change=${()=>{this.trackRangeFields(),this.onInput()}}
|
|
199
|
+
@range-blur=${e=>this.syncRangeFromFields(e.detail.event)}
|
|
200
|
+
@manage-validity=${e=>this.manageValidity(e.detail)}
|
|
201
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
202
|
+
${a.n(this.rangeInputRef)}
|
|
203
|
+
></pkt-datepicker-range>
|
|
204
|
+
`}renderMultipleInput(){return e._`
|
|
205
|
+
<pkt-datepicker-multiple
|
|
206
|
+
.value=${this._value}
|
|
207
|
+
.inputType=${this.inputType}
|
|
208
|
+
.id=${this.id}
|
|
209
|
+
.min=${this.min}
|
|
210
|
+
.max=${this.max}
|
|
211
|
+
.placeholder=${this.placeholder}
|
|
212
|
+
.readonly=${this.readonly}
|
|
213
|
+
.disabled=${this.isDisabled}
|
|
214
|
+
.maxlength=${this.maxlength}
|
|
215
|
+
.inputClasses=${this.inputClasses}
|
|
216
|
+
.inputSize=${this.inputSize}
|
|
217
|
+
.internals=${this.internals}
|
|
218
|
+
.hasError=${this.hasError}
|
|
219
|
+
.hasHelptext=${!!(this.helptext||this.helptextDropdown||this.hasSlotContent(`helptext`))}
|
|
220
|
+
.strings=${this.strings}
|
|
221
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
222
|
+
@input-change=${()=>this.onInput()}
|
|
223
|
+
@add-to-selected=${e=>this.addToSelected(e.detail)}
|
|
224
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
225
|
+
${a.n(this.multipleInputRef)}
|
|
226
|
+
></pkt-datepicker-multiple>
|
|
227
|
+
`}renderCalendar(){return e._`
|
|
228
|
+
<pkt-datepicker-popup
|
|
229
|
+
class="pkt-contents"
|
|
230
|
+
?open=${this.calendarOpen}
|
|
231
|
+
?multiple=${this.multiple}
|
|
232
|
+
?range=${this.range}
|
|
233
|
+
?weeknumbers=${this.weeknumbers}
|
|
234
|
+
?withcontrols=${this.withcontrols}
|
|
235
|
+
.maxMultiple=${this.maxlength}
|
|
236
|
+
.selected=${this.calendarSelected}
|
|
237
|
+
.earliest=${this.min}
|
|
238
|
+
.latest=${this.max}
|
|
239
|
+
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(`,`)}
|
|
240
|
+
.excludeweekdays=${this.excludeweekdays}
|
|
241
|
+
.currentmonth=${this.currentmonth?o.m(this.currentmonth):null}
|
|
242
|
+
.today=${this.today}
|
|
243
|
+
@date-selected=${e=>{let t=this.range?x(e.detail,this._value[0]?null:this.toWithoutFrom,o.r(this.excludedates),this.excludeweekdays):e.detail;this.toWithoutFrom=null,this.editedRangeFields=null,this.value=N.processDateSelection(t,this.multiple,this.range),this._value=t,N.updateInputValues(this.inputRef,this.inputRefTo,this._value,this.range,this.multiple,e=>this.manageValidity(e)),this.multiple||this.range&&this._value.length!==2||this.focusField(),t!==e.detail&&this.hideCalendar()}}
|
|
244
|
+
@close=${()=>{this.focusIsInPopup&&this.focusField(),this.hideCalendar()}}
|
|
245
|
+
${a.n(this.datepickerPopupRef)}
|
|
246
|
+
></pkt-datepicker-popup>
|
|
247
|
+
`}render(){return this.inputClasses=M.getInputClasses(this.fullwidth,this.showRangeLabels,this.multiple,this.range,this.readonly,this.inputType,this.inputSize),e._`
|
|
248
|
+
<pkt-input-wrapper
|
|
249
|
+
${n.n(this,[`helptext`])}
|
|
250
|
+
.strings=${this.strings}
|
|
251
|
+
label="${this.label}"
|
|
252
|
+
forId="${this.id}-input"
|
|
253
|
+
?counter=${this.hasCounter}
|
|
254
|
+
.counterCurrent=${this.value?this._value.length:0}
|
|
255
|
+
.counterMaxLength=${this.maxlength}
|
|
256
|
+
?disabled=${this.isDisabled}
|
|
257
|
+
?hasError=${this.hasError}
|
|
258
|
+
?hasFieldset=${this.effectiveHasFieldset(!1)}
|
|
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
|
+
.size=${this.inputSize}
|
|
273
|
+
>
|
|
274
|
+
${this.multiple?e._`<pkt-date-tags
|
|
275
|
+
.dates=${this._value}
|
|
276
|
+
dateformat=${this.dateformat}
|
|
277
|
+
strings=${this.strings}
|
|
278
|
+
id-base=${this.id}
|
|
279
|
+
@date-tag-removed=${e=>{let t=o.s(e.detail);t&&this.datepickerPopupRef.value?.handleDateSelect(t)}}
|
|
280
|
+
></pkt-date-tags>`:e.h}
|
|
281
|
+
<div class="pkt-datepicker__inputs ${this.range?`pkt-input__range-inputs`:``}">
|
|
282
|
+
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
283
|
+
</div>
|
|
284
|
+
</pkt-input-wrapper>
|
|
285
|
+
${this.renderCalendar()}
|
|
286
|
+
`}handleCalendarPosition(){T(this.datepickerPopupRef.value?.popupRef.value??null,this.currentInputElement??null,this.hasCounter)}async positionOpenCalendar(){let e=this.datepickerPopupRef.value;await e?.updateComplete,await e?.calendarRef.value?.updateComplete,this.calendarOpen&&this.handleCalendarPosition()}async showCalendar(){let e=this.datepickerPopupRef.value;this.calendarOpen=!0,e&&(e.show(),f()&&e.focusOnCurrentDate())}hideCalendar(){let e=this.datepickerPopupRef.value;if(this.calendarOpen=!1,e&&typeof e.hide==`function`)return e.hide()}async toggleCalendar(e){e.preventDefault();let t=this.datepickerPopupRef.value;if(t&&typeof t.toggle==`function`){let e=!!t.open;t.toggle(),this.calendarOpen=!e}else this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value=``,this.setFormValue(this.value),this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:this._value,bubbles:!0,composed:!0}))}};V=H,V.DERIVED_FROM=[`value`,`multiple`,`range`,`min`,`max`,`excludedates`,`excludeweekdays`],V.POSITIONED_BY=[`calendarOpen`,`counter`,`multiple`,`maxlength`],e.n([e.u({type:String,reflect:!0})],H.prototype,`value`,null),e.n([e.l()],H.prototype,`_value`,void 0),e.n([e.u({type:String,reflect:!0})],H.prototype,`label`,void 0),e.n([e.u({type:String})],H.prototype,`dateformat`,void 0),e.n([e.u({type:Boolean,reflect:!0})],H.prototype,`multiple`,void 0),e.n([e.u({type:Number,reflect:!0})],H.prototype,`maxlength`,void 0),e.n([e.u({type:Boolean,reflect:!0})],H.prototype,`range`,void 0),e.n([e.u({type:Boolean,attribute:`show-range-labels`})],H.prototype,`showRangeLabels`,void 0),e.n([e.u({type:String,reflect:!0})],H.prototype,`min`,void 0),e.n([e.u({type:String,reflect:!0})],H.prototype,`max`,void 0),e.n([e.u({type:Boolean})],H.prototype,`weeknumbers`,void 0),e.n([e.u({type:Boolean,reflect:!0})],H.prototype,`withcontrols`,void 0),e.n([e.u({converter:o.t.csvToArray})],H.prototype,`excludedates`,void 0),e.n([e.u({converter:o.t.csvToArray})],H.prototype,`excludeweekdays`,void 0),e.n([e.u({type:String})],H.prototype,`currentmonth`,void 0),e.n([e.u({type:String})],H.prototype,`today`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`calendar-open`})],H.prototype,`calendarOpen`,void 0),e.n([e.u({type:String})],H.prototype,`timezone`,void 0),e.n([e.l()],H.prototype,`inputClasses`,void 0),e.n([e.l()],H.prototype,`toWithoutFrom`,void 0),e.n([e.l()],H.prototype,`editedRangeFields`,void 0);try{e.d(`pkt-datepicker`)(H)}catch{console.warn(`Forsøker å definere <pkt-datepicker>, men den er allerede definert`)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return H}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-0a5lX0pL.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-CbYMk21W.cjs"),require("./progressbar-Wyq_Q1Ur.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-Dp64-kF1.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-C9tsr-xL.cjs");require("./modal-B3rnE83a.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),this.disabled||(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue?this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-0a5lX0pL.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-EKGhSUKU.cjs"),require("./progressbar-BKA9zFnE.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-Dp64-kF1.cjs"),a=require("./utils-dl1XA5EE.cjs"),o=require("./focus-trap-C9tsr-xL.cjs");require("./modal-Du-2AmLz.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.t()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),this.disabled||(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue?this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.t(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
2
2
|
<label for=${i} class="pkt-sr-only">${t.renameInputLabel}</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${i}
|
|
@@ -3,13 +3,13 @@ import { t as s } from "./class-map-C9n5CNC8.js";
|
|
|
3
3
|
import { n as c, t as l } from "./format-DwjTfa9h.js";
|
|
4
4
|
import "./alert-ZrB-P881.js";
|
|
5
5
|
import "./icon-CZDw42U7.js";
|
|
6
|
-
import "./input-wrapper-
|
|
7
|
-
import "./progressbar-
|
|
6
|
+
import "./input-wrapper-BBUcHEKx.js";
|
|
7
|
+
import "./progressbar-aKjj5VZg.js";
|
|
8
8
|
import { t as u } from "./if-defined-B3pYog2C.js";
|
|
9
9
|
import { t as d } from "./converters-v_GK06o3.js";
|
|
10
|
-
import {
|
|
10
|
+
import { t as f } from "./utils-BtXhdgpe.js";
|
|
11
11
|
import { r as p } from "./focus-trap-C-PcFOw6.js";
|
|
12
|
-
import "./modal-
|
|
12
|
+
import "./modal-CvqH9R3w.js";
|
|
13
13
|
// ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
15
15
|
if (e == null || e === "") return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D_8fAzCW.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-5A378_yh.cjs"),require("./button-DHVRpzpS.cjs"),require("./textinput-
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D_8fAzCW.cjs"),i=require("./booleanish-BF8l4scU.cjs");require("./shared-types-BvRk9kiK.cjs");const a=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-5A378_yh.cjs"),require("./button-DHVRpzpS.cjs"),require("./textinput-C6AcbxnQ.cjs");const o=require("./if-defined-Ci4ZQsgL.cjs"),s=require("./ref-C6VUWwmF.cjs"),c=require("./focus-trap-C9tsr-xL.cjs"),l=require("./scroll-lock-x0VxhKWZ.cjs");require("./link-lPrxhYq0.cjs"),require("./searchinput-C8UHexyf.cjs"),require("./header-menu-BJMMwrCR.cjs");var u=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},d=e=>u(e),f=e=>{if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!isNaN(t.getTime()))return t.toLocaleDateString(`nb-NO`,{day:`numeric`,month:`long`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})},p=class{constructor(e,t){this.isMobile=!1,this.isTablet=!1,this.isHidden=!1,this.pauseScrollHide=!1,this.componentWidth=typeof window<`u`?window.innerWidth:0,this.lastScrollPosition=0,this.scrollLockToken=l.t(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1,this.initialWidthEstimated=!1,this.handleScroll=()=>{if(this.getOptions().scrollBehavior!==`hide`||this.pauseScrollHide)return;let e=window.pageYOffset||document.documentElement.scrollTop;if(e<0||Math.abs(e-this.lastScrollPosition)<60)return;let t=e>this.lastScrollPosition;this.lastScrollPosition=e,t!==this.isHidden&&(this.isHidden=t,this.host.requestUpdate())},this.host=e,this.getOptions=t,e.addController(this)}hostConnected(){window.addEventListener(`scroll`,this.handleScroll)}hostUpdate(){this.initialWidthEstimated||(this.initialWidthEstimated=!0,this.componentWidth=this.host.offsetWidth,this.applyBreakpoints())}hostDisconnected(){this.resizeObserver?.disconnect(),window.removeEventListener(`scroll`,this.handleScroll),l.n(this.scrollLockToken,!1)}observe(e){e&&(this.componentWidth=e.offsetWidth,this.refreshBreakpoints(),this.resizeObserver=new ResizeObserver(e=>{for(let t of e)this.componentWidth=t.borderBoxSize&&t.borderBoxSize.length>0?t.borderBoxSize[0].inlineSize:t.contentRect.width,this.refreshBreakpoints()}),this.resizeObserver.observe(e))}refreshBreakpoints(){this.applyBreakpoints()&&this.host.requestUpdate()}applyBreakpoints(){let{mobileBreakpoint:e,tabletBreakpoint:t}=this.getOptions(),n=this.componentWidth<e,r=this.componentWidth<t;return n===this.isMobile&&r===this.isTablet?!1:(this.isMobile=n,this.isTablet=r,!0)}setScrollLock(e){l.n(this.scrollLockToken,e)}captureFocus(){this.lastFocusedElement=document.activeElement}flagRestoreFocus(){this.shouldRestoreFocus=!0}restoreFocus(){this.shouldRestoreFocus&&this.lastFocusedElement&&document.contains(this.lastFocusedElement)&&this.lastFocusedElement.focus(),this.lastFocusedElement=null,this.shouldRestoreFocus=!1}},m=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e._`
|
|
2
2
|
<pkt-link
|
|
3
3
|
iconName=${n.iconName||e.h}
|
|
4
4
|
href=${n.href}
|
|
@@ -7,13 +7,13 @@ import "./shared-types-BvRk9kiK.js";
|
|
|
7
7
|
import { n as f, o as p, t as m } from "./fetch-header-footer-data-CPVt_P8s.js";
|
|
8
8
|
import "./icon-CZDw42U7.js";
|
|
9
9
|
import "./button-CJzu0l5A.js";
|
|
10
|
-
import "./textinput-
|
|
10
|
+
import "./textinput-BPrC2neL.js";
|
|
11
11
|
import { t as h } from "./if-defined-B3pYog2C.js";
|
|
12
12
|
import { n as g, t as _ } from "./ref-qE1RBrI7.js";
|
|
13
13
|
import { n as v, t as y } from "./focus-trap-C-PcFOw6.js";
|
|
14
14
|
import { n as b, t as x } from "./scroll-lock-C9jzbJ4E.js";
|
|
15
15
|
import "./link-Bc4zf-Dj.js";
|
|
16
|
-
import "./searchinput-
|
|
16
|
+
import "./searchinput-DUJlxKHH.js";
|
|
17
17
|
import "./header-menu-k2ACrfOv.js";
|
|
18
18
|
// ../../shared-types/header.ts
|
|
19
19
|
var S = (e) => typeof e.target == "string" ? {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-with-slot-D_8fAzCW.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./icon-5A378_yh.cjs"),r=require("./class-map-C82GtM1w.cjs"),i=require("./utils-
|
|
1
|
+
const e=require("./element-with-slot-D_8fAzCW.cjs"),t=require("./element-CEarCnHH.cjs"),n=require("./icon-5A378_yh.cjs"),r=require("./class-map-C82GtM1w.cjs"),i=require("./utils-dl1XA5EE.cjs");var a=class extends e.t{constructor(...e){super(...e),this.forId=i.t(),this.helptext=``,this.helptextDropdown=``,this.isHelpTextOpen=!1}render(){let i=()=>{let e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!0,detail:{isOpen:e}}))},a=r.t({"pkt-inputwrapper__helptext-container":!0,"pkt-inputwrapper__has-helptext":this.helptext||this.helptextDropdown||this.hasSlotContent()});return t._`${t._`<div class="${a}">
|
|
2
2
|
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
3
3
|
<div class="pkt-contents">${e.i(this)}</div>
|
|
4
4
|
${this.helptext?t._`<span>${n.r(this.helptext)}</span>`:t.h}
|
|
@@ -2,7 +2,7 @@ import { i as e, t } from "./element-with-slot-47quDZRt.js";
|
|
|
2
2
|
import { _ as n, d as r, h as i, l as a, n as o, u as s } from "./element-Bwc-likm.js";
|
|
3
3
|
import { r as c } from "./icon-CZDw42U7.js";
|
|
4
4
|
import { t as l } from "./class-map-C9n5CNC8.js";
|
|
5
|
-
import {
|
|
5
|
+
import { t as u } from "./utils-BtXhdgpe.js";
|
|
6
6
|
// src/components/helptext/helptext.ts
|
|
7
7
|
var d = class extends t {
|
|
8
8
|
constructor(...e) {
|