@oslokommune/punkt-elements 19.5.0 → 19.5.1
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 +8 -0
- package/dist/{accordion-CZ0O4c0_.cjs → accordion-5lSFQToJ.cjs} +6 -6
- package/dist/{accordion-DFcdonl-.js → accordion-BJh6X1Ek.js} +6 -6
- package/dist/{alert-CUOWdvit.js → alert-C0PiYnot.js} +28 -35
- package/dist/alert-IaZzEgyI.cjs +39 -0
- package/dist/{backlink-vLhK1hsj.cjs → backlink-BRqhwUr2.cjs} +1 -1
- package/dist/{button-B0uSFQVn.js → button-B78im4wB.js} +15 -15
- package/dist/button-BNVTj7nB.cjs +32 -0
- package/dist/{card-CfFW7_-K.js → card-CYKhPUNI.js} +11 -11
- package/dist/{card-C15acwk4.cjs → card-CaLEuumN.cjs} +10 -10
- package/dist/{checkbox-C0zLtnCI.cjs → checkbox-DIyi1Cya.cjs} +1 -1
- package/dist/{checkbox-B2O0fkh9.js → checkbox-DKeErDb5.js} +1 -1
- package/dist/{combobox-Bhfh04Su.js → combobox-BKnHg_-E.js} +29 -29
- package/dist/{combobox-DvsnfA0c.cjs → combobox-C7FUvv5T.cjs} +22 -22
- package/dist/components/alert/alert.d.ts +0 -2
- package/dist/{consent-_DBvIRT2.js → consent-CleJMbVH.js} +1 -1
- package/dist/{consent-BfLkJbOk.cjs → consent-Dl-R0iC3.cjs} +1 -1
- package/dist/{datepicker-BY2IKrPk.js → datepicker-COFEJpB4.js} +9 -9
- package/dist/{datepicker-Cg-iueRC.cjs → datepicker-CeUpoQuG.cjs} +27 -27
- package/dist/directives/slot-content.d.ts +36 -1
- package/dist/element-with-slot-D7sTqOr3.cjs +1 -0
- package/dist/{element-with-slot-FD826ooP.js → element-with-slot-DQv0cbbD.js} +80 -21
- package/dist/{fileupload-iuXrgrog.js → fileupload-CUPl41uN.js} +31 -31
- package/dist/{fileupload-Djp6VJYY.cjs → fileupload-CaZGBvZr.cjs} +21 -21
- package/dist/{footer-BCdb0wlF.js → footer-DdLls3F-.js} +13 -13
- package/dist/{footer-bTpLxigB.cjs → footer-vy9NqT65.cjs} +9 -9
- package/dist/{header-DbSSOX-h.cjs → header-CgP3-6-b.cjs} +50 -50
- package/dist/{header-2fF-Zu5T.js → header-Cq6INZmI.js} +55 -55
- package/dist/{header-menu-DVYLZyez.js → header-menu-ANj5nL2M.js} +1 -1
- package/dist/{header-menu-ChDMnWhW.cjs → header-menu-BfkCp8jw.cjs} +1 -1
- package/dist/{heading-BRHCV_5J.js → heading-CUrZvkrM.js} +1 -1
- package/dist/{heading-u9Arof4p.cjs → heading-zoz-QZJ9.cjs} +1 -1
- package/dist/{helptext-CmsuAXSE.cjs → helptext-BCkwSz1m.cjs} +2 -2
- package/dist/{helptext-4TAHKV5_.js → helptext-DCT_9dw1.js} +1 -1
- package/dist/{input-element-B1BntJeJ.js → input-element-5hsxasU3.js} +1 -1
- package/dist/{input-element-W6Gklt2E.cjs → input-element-Ctkz5fQk.cjs} +1 -1
- package/dist/{input-wrapper-B5rqKWSB.cjs → input-wrapper-Cf__-4E-.cjs} +28 -28
- package/dist/{input-wrapper-CaMP5-Vm.js → input-wrapper-DACDx6Ie.js} +44 -44
- package/dist/{link-CCFAmhL5.js → link-CmZwAw5u.js} +1 -1
- package/dist/{link-Bo2o0Akv.cjs → link-LO_5_La8.cjs} +2 -2
- package/dist/{linkcard-9L6QF7US.js → linkcard-CQluSyJJ.js} +7 -7
- package/dist/{linkcard-D7NbrluR.cjs → linkcard-UKsxADrP.cjs} +3 -3
- package/dist/{listbox-DEzd-dxF.js → listbox-Ct9jIV_5.js} +8 -8
- package/dist/{listbox-BoBwzL4p.cjs → listbox-g-vHHLkD.cjs} +20 -20
- package/dist/{loader-CQaGvyF9.cjs → loader-C_PH05aw.cjs} +2 -2
- package/dist/{loader-RQQ_o2aR.js → loader-DzctJ9jW.js} +1 -1
- package/dist/{messagebox-C-BQREWz.js → messagebox-DPFBuisE.js} +1 -1
- package/dist/{messagebox-BRqI3DW2.cjs → messagebox-JWKMJEFc.cjs} +2 -2
- package/dist/{modal-BGTTVHeW.cjs → modal-BymjMIJi.cjs} +2 -2
- package/dist/{modal-DCwqqNQc.js → modal-CELmA0-8.js} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.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-consent.cjs +1 -1
- package/dist/pkt-consent.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-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.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 +30 -30
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-Dz-rYCG1.cjs → pkt-options-controller-CpEZcomb.cjs} +1 -1
- package/dist/{pkt-options-controller-sUzxHa5A.js → pkt-options-controller-D7l18Iw0.js} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.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-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.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-CAEQkFpP.cjs → progressbar-CIXNSwTy.cjs} +2 -3
- package/dist/{progressbar-DzX0p2vn.js → progressbar-DH5lIBpx.js} +6 -4
- package/dist/{radiobutton-B0V-jSEX.js → radiobutton-DP791tUe.js} +1 -1
- package/dist/{radiobutton-Cv1BlwLV.cjs → radiobutton-oEYrBiT6.cjs} +1 -1
- package/dist/{searchinput-D6vtMUHw.cjs → searchinput-CbClDE-d.cjs} +1 -1
- package/dist/{select-C0GafKtu.js → select-B97S4g1v.js} +18 -18
- package/dist/{select-Bd6Gg4Ar.cjs → select-QobXCtIL.cjs} +13 -13
- package/dist/{tabs-B134M9k2.js → tabs-B8blHQrL.js} +18 -18
- package/dist/{tabs-Dw9E06fL.cjs → tabs-CjX-GWvM.cjs} +15 -15
- package/dist/tag-B5dUg7AD.cjs +27 -0
- package/dist/{tag-CvFakm1k.js → tag-Bns7Xj1O.js} +10 -10
- package/dist/{textarea-BZ2ufamc.js → textarea-DgW0hRV5.js} +16 -16
- package/dist/{textarea-CeqScqQa.cjs → textarea-ZMbtZNp3.cjs} +10 -10
- package/dist/{textinput-L218fT2-.cjs → textinput-DfT_1aGb.cjs} +10 -10
- package/dist/{textinput-DI8Tgmep.js → textinput-s-qz2xSC.js} +14 -14
- package/dist/{timepicker-ZSHZt0aW.cjs → timepicker-BAa_VEnf.cjs} +10 -10
- package/dist/{timepicker-CgXpmG3h.js → timepicker-Crj4isb9.js} +15 -15
- package/package.json +2 -2
- package/src/components/alert/alert.test.ts +15 -0
- package/src/components/alert/alert.ts +0 -12
- package/src/components/combobox/combobox.ts +3 -3
- package/src/components/datepicker/datepicker.ts +5 -5
- package/src/components/helptext/helptext-association.test.ts +79 -0
- package/src/components/input-wrapper/input-wrapper.test.ts +49 -0
- package/src/components/input-wrapper/input-wrapper.ts +6 -4
- package/src/components/progressbar/progressbar.test.ts +19 -0
- package/src/components/progressbar/progressbar.ts +2 -6
- package/src/components/select/select.ts +3 -3
- package/src/components/textarea/textarea.ts +3 -3
- package/src/components/textinput/textinput.ts +3 -3
- package/src/components/timepicker/timepicker.ts +3 -3
- package/dist/alert-DcyO0WfW.cjs +0 -40
- package/dist/button-PcKtiNGS.cjs +0 -32
- package/dist/element-with-slot-2PHu2w7O.cjs +0 -1
- package/dist/tag--kFPXNaj.cjs +0 -27
- package/dist/{backlink-DdyQq62f.js → backlink-BslFewn-.js} +1 -1
- package/dist/{searchinput-DyjUl08X.js → searchinput-Co8tcq-l.js} +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-DcyO0WfW.cjs"),require("./icon-Dnv6LtPC.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-B5rqKWSB.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-BGTTVHeW.cjs"),require("./progressbar-CAEQkFpP.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.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),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))}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 n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.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(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}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 n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.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 n=new Date(e);if(Number.isNaN(n.getTime()))return e;let i=String(n.getDate()).padStart(2,`0`),a=String(n.getMonth()+1).padStart(2,`0`),o=n.getFullYear(),s=String(n.getHours()).padStart(2,`0`),c=String(n.getMinutes()).padStart(2,`0`);return r.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-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-IaZzEgyI.cjs"),require("./icon-Dnv6LtPC.cjs");const r=require("./if-defined-2mkIDgOm.cjs"),i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-Cf__-4E-.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-BymjMIJi.cjs"),require("./progressbar-CIXNSwTy.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.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),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))}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(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}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}
|
|
@@ -166,11 +166,11 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
166
166
|
${o?e._`<span class="pkt-fileupload__queue-display__item__error-message"
|
|
167
167
|
>${o}</span
|
|
168
168
|
>`:null}
|
|
169
|
-
`},B=({file:t,disabled:
|
|
169
|
+
`},B=({file:t,disabled:n,inputName:i,operations:a,activeOperationId:o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u})=>{let d=a.find(e=>e.id===o);if(d?.renderInlineUI||d?.renderExtendedUI)return null;let f=a.map(a=>{let d=L({operationId:a.id,file:t,inputName:i,disabled:n,isActive:a.id===o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u}),f=typeof a.title==`function`?a.title(t):a.title;if(!f)return null;let p=typeof a.ariaLabel==`function`?a.ariaLabel(t):a.ariaLabel;return e._`<button
|
|
170
170
|
type="button"
|
|
171
171
|
class="pkt-fileupload__queue-display__item__operation"
|
|
172
|
-
aria-label=${
|
|
173
|
-
?disabled=${
|
|
172
|
+
aria-label=${r.t(p)}
|
|
173
|
+
?disabled=${n}
|
|
174
174
|
@click=${()=>{(a.renderInlineUI||a.renderExtendedUI)&&d.activate(),a.onClick?.(d)}}
|
|
175
175
|
>
|
|
176
176
|
${f}
|
|
@@ -192,7 +192,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
192
192
|
<button
|
|
193
193
|
type="button"
|
|
194
194
|
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
195
|
-
aria-label=${
|
|
195
|
+
aria-label=${n.t(l.previewImage,{filename:f})}
|
|
196
196
|
?disabled=${!h}
|
|
197
197
|
@click=${()=>{!h||!u||u(i.fileId)}}
|
|
198
198
|
>
|
|
@@ -203,7 +203,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
203
203
|
aria-hidden="true"
|
|
204
204
|
></pkt-icon>`:null}
|
|
205
205
|
${p?e._`<img
|
|
206
|
-
src=${
|
|
206
|
+
src=${r.t(a)}
|
|
207
207
|
alt=${f}
|
|
208
208
|
@error=${()=>d?.(i.fileId)}
|
|
209
209
|
/>`:e._`<pkt-icon
|
|
@@ -274,7 +274,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
274
274
|
>
|
|
275
275
|
${n}
|
|
276
276
|
</pkt-input-wrapper>
|
|
277
|
-
`}renderContent(){let
|
|
277
|
+
`}renderContent(){let n=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(n),a=this.pktStrings.get(`fileupload`),o=this.getSupportedFormatsText(),s=[this.helptext?`${this.id}-input-helptext`:void 0,this.hasEffectiveError?`${this.id}-error`:void 0].filter(Boolean).join(` `)||void 0,c=this.itemRenderer===`thumbnail`?this.multiple?{dragInactive:a.dropZoneDragMultipleThumbnail,dragActive:a.dropZoneDragActiveMultipleThumbnail,openFileDialog:a.dropZoneOpenFileDialogMultipleThumbnail}:{dragInactive:a.dropZoneDragSingleThumbnail,dragActive:a.dropZoneDragActiveSingleThumbnail,openFileDialog:a.dropZoneOpenFileDialogSingleThumbnail}:this.multiple?{dragInactive:a.dropZoneDragMultiple,dragActive:a.dropZoneDragActiveMultiple,openFileDialog:a.dropZoneOpenFileDialogMultiple}:{dragInactive:a.dropZoneDragSingle,dragActive:a.dropZoneDragActiveSingle,openFileDialog:a.dropZoneOpenFileDialogSingle};return e._`
|
|
278
278
|
<div
|
|
279
279
|
class=${t.t({"pkt-fileupload":!0,"pkt-fileupload--full-width":this.fullwidth,"pkt-fileupload--error":this.hasEffectiveError,"pkt-fileupload--disabled":this.disabled})}
|
|
280
280
|
aria-disabled=${String(this.disabled)}
|
|
@@ -296,23 +296,23 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
296
296
|
<input
|
|
297
297
|
id=${`${this.id}-input`}
|
|
298
298
|
type="file"
|
|
299
|
-
name=${
|
|
300
|
-
form=${
|
|
299
|
+
name=${r.t(this.uploadStrategy===`form`?this.name:void 0)}
|
|
300
|
+
form=${r.t(this.form)}
|
|
301
301
|
?multiple=${this.multiple}
|
|
302
302
|
?disabled=${this.disabled}
|
|
303
303
|
?required=${this.required&&this.uploadStrategy===`form`}
|
|
304
304
|
accept=${this.getResolvedAcceptValue()}
|
|
305
|
-
aria-label=${
|
|
306
|
-
aria-required=${
|
|
307
|
-
aria-invalid=${
|
|
308
|
-
aria-describedby=${
|
|
305
|
+
aria-label=${r.t(this.label?void 0:this.multiple?this.pktStrings.get(`fileupload`).openFileDialogLabelMultiple:this.pktStrings.get(`fileupload`).openFileDialogLabelSingle)}
|
|
306
|
+
aria-required=${r.t(this.required?`true`:void 0)}
|
|
307
|
+
aria-invalid=${r.t(this.hasEffectiveError?`true`:void 0)}
|
|
308
|
+
aria-describedby=${r.t(s)}
|
|
309
309
|
@change=${this.onNativeFileChange}
|
|
310
310
|
/>
|
|
311
|
-
${this.uploadStrategy===`custom`?
|
|
311
|
+
${this.uploadStrategy===`custom`?n.map(t=>e._`<input
|
|
312
312
|
type="hidden"
|
|
313
313
|
name=${this.name}
|
|
314
314
|
value=${t.fileId}
|
|
315
|
-
form=${
|
|
315
|
+
form=${r.t(this.form)}
|
|
316
316
|
/>`):null}
|
|
317
317
|
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
318
318
|
<pkt-icon
|
|
@@ -347,12 +347,12 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
347
347
|
${this.effectiveErrorMessage}
|
|
348
348
|
</pkt-alert>
|
|
349
349
|
`:null}
|
|
350
|
-
${
|
|
351
|
-
${
|
|
350
|
+
${n.length>0?e._`<ul class="pkt-fileupload__queue-display">
|
|
351
|
+
${n.map(e=>this.renderQueueItem(e,i))}
|
|
352
352
|
</ul>`:null}
|
|
353
353
|
${this.renderPreviewModal(i)}
|
|
354
354
|
</div>
|
|
355
|
-
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations(),i=this.pktStrings.get(`fileupload`);if(this.itemRenderer===`thumbnail`){let a=this.canOpenPreview(e),o=this.failedImageFileIds[e.fileId]?.thumbnail?void 0:this.getThumbnailUrl(e);return q({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),thumbnailUrl:o,previewEnabled:this.enableImagePreview,canOpenPreview:a,transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,strings:i,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e),onOpenPreview:e=>this.openPreview(e,t),onThumbnailImageError:e=>this.markImageFailed(e,`thumbnail`)})}return K({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,strings:i,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e)})}markImageFailed(e,t){this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],[t]:!0}}}getPreviewableImages(e){return this.enableImagePreview?e.filter(e=>e.progress===`done`&&this.isImageFile(e)):[]}canOpenPreview(e){return this.enableImagePreview&&e.progress===`done`&&this.isImageFile(e)}openPreview(e,t){let n=t.findIndex(t=>t.fileId===e);n<0||(this.previewCurrentIndex=n,this.isPreviewModalOpen=!0,this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],preview:!1}})}navigatePreview(e,t){t.length!==0&&(this.previewCurrentIndex=S(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let
|
|
355
|
+
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations(),i=this.pktStrings.get(`fileupload`);if(this.itemRenderer===`thumbnail`){let a=this.canOpenPreview(e),o=this.failedImageFileIds[e.fileId]?.thumbnail?void 0:this.getThumbnailUrl(e);return q({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),thumbnailUrl:o,previewEnabled:this.enableImagePreview,canOpenPreview:a,transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,strings:i,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e),onOpenPreview:e=>this.openPreview(e,t),onThumbnailImageError:e=>this.markImageFailed(e,`thumbnail`)})}return K({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,strings:i,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e)})}markImageFailed(e,t){this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],[t]:!0}}}getPreviewableImages(e){return this.enableImagePreview?e.filter(e=>e.progress===`done`&&this.isImageFile(e)):[]}canOpenPreview(e){return this.enableImagePreview&&e.progress===`done`&&this.isImageFile(e)}openPreview(e,t){let n=t.findIndex(t=>t.fileId===e);n<0||(this.previewCurrentIndex=n,this.isPreviewModalOpen=!0,this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],preview:!1}})}navigatePreview(e,t){t.length!==0&&(this.previewCurrentIndex=S(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let r=this.pktStrings.get(`fileupload`),i=t[this.previewCurrentIndex];if(!i)return null;let a=t.length>1,o=this.getThumbnailUrl(i),s=!!o&&!this.failedImageFileIds[i.fileId]?.preview,c=i.attributes?.targetFilename||i.file?.name||r.previewFallbackName;return e._`
|
|
356
356
|
<pkt-modal
|
|
357
357
|
.open=${this.isPreviewModalOpen}
|
|
358
358
|
.headingText=${c}
|
|
@@ -365,7 +365,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
365
365
|
${a?e._`<button
|
|
366
366
|
type="button"
|
|
367
367
|
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--prev pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
368
|
-
aria-label=${
|
|
368
|
+
aria-label=${n.t(r.previewPrevious,{index:this.previewCurrentIndex,total:t.length})}
|
|
369
369
|
@click=${()=>this.navigatePreview(`prev`,t)}
|
|
370
370
|
>
|
|
371
371
|
<pkt-icon
|
|
@@ -379,7 +379,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
379
379
|
<div class="pkt-fileupload__image-preview__content">
|
|
380
380
|
${s?e._`<img
|
|
381
381
|
src=${o}
|
|
382
|
-
alt=${
|
|
382
|
+
alt=${n.t(r.previewImageAlt,{filename:c,index:this.previewCurrentIndex+1,total:t.length})}
|
|
383
383
|
class="pkt-fileupload__image-preview__image"
|
|
384
384
|
@error=${()=>this.markImageFailed(i.fileId,`preview`)}
|
|
385
385
|
/>`:e._`<pkt-icon
|
|
@@ -395,7 +395,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
|
|
|
395
395
|
${a?e._`<button
|
|
396
396
|
type="button"
|
|
397
397
|
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--next pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
398
|
-
aria-label=${
|
|
398
|
+
aria-label=${n.t(r.previewNext,{index:this.previewCurrentIndex+2,total:t.length})}
|
|
399
399
|
@click=${()=>this.navigatePreview(`next`,t)}
|
|
400
400
|
>
|
|
401
401
|
<pkt-icon
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-mwwC2Rra.js";
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
import { n as l, r as u, t as d } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
2
|
+
import "./consent-CleJMbVH.js";
|
|
3
|
+
import { t as s } from "./booleanish-OQJTYSrw.js";
|
|
4
|
+
import { n as c, r as l, t as u } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
6
5
|
import "./icon-JigbxxF7.js";
|
|
6
|
+
import { t as d } from "./if-defined-Bebu3LXY.js";
|
|
7
7
|
//#region ../../shared-utils/header-footer/external-domain.ts
|
|
8
8
|
var f = "oslo.kommune.no", p = /\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;
|
|
9
9
|
function m(e) {
|
|
@@ -50,7 +50,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
50
50
|
async loadData() {
|
|
51
51
|
this.abortController?.abort(), this.abortController = new AbortController();
|
|
52
52
|
try {
|
|
53
|
-
this.fetchedData = await
|
|
53
|
+
this.fetchedData = await u(this.dataUrl, this.abortController.signal);
|
|
54
54
|
} catch (e) {
|
|
55
55
|
if (e.name === "AbortError") return;
|
|
56
56
|
console.warn("Failed to fetch header/footer data:", e), this.dispatchEvent(new CustomEvent("data-error", {
|
|
@@ -61,7 +61,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
get globalFooterData() {
|
|
64
|
-
return
|
|
64
|
+
return c(this.data ?? this.fetchedData, this.locale)?.footer;
|
|
65
65
|
}
|
|
66
66
|
linkTarget(e) {
|
|
67
67
|
return e.openInNewTab || this.openLinksInNewTab ? {
|
|
@@ -77,7 +77,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
77
77
|
renderCustomLink(t) {
|
|
78
78
|
let { target: n, rel: r } = this.linkTarget(t);
|
|
79
79
|
return e`
|
|
80
|
-
<a href=${t.href} target=${n} rel=${
|
|
80
|
+
<a href=${t.href} target=${n} rel=${d(r)}
|
|
81
81
|
>${t.text}${this.renderLinkDomain(t)}</a
|
|
82
82
|
>
|
|
83
83
|
`;
|
|
@@ -130,7 +130,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
130
130
|
`;
|
|
131
131
|
}
|
|
132
132
|
renderSomeLink(t) {
|
|
133
|
-
let n =
|
|
133
|
+
let n = l(t.url, t.text);
|
|
134
134
|
return n ? e`
|
|
135
135
|
<li>
|
|
136
136
|
<a class="pkt-footer__some-link" href=${t.url} aria-label=${t.text}>
|
|
@@ -180,15 +180,15 @@ i([o({
|
|
|
180
180
|
})], v.prototype, "data", void 0), i([o({ type: String })], v.prototype, "locale", void 0), i([o({
|
|
181
181
|
type: Boolean,
|
|
182
182
|
attribute: "skip-global",
|
|
183
|
-
converter:
|
|
183
|
+
converter: s
|
|
184
184
|
})], v.prototype, "skipGlobal", void 0), i([o({
|
|
185
185
|
type: Boolean,
|
|
186
186
|
attribute: "open-links-in-new-tab",
|
|
187
|
-
converter:
|
|
187
|
+
converter: s
|
|
188
188
|
})], v.prototype, "openLinksInNewTab", void 0), i([o({
|
|
189
189
|
type: Boolean,
|
|
190
190
|
attribute: "include-consent",
|
|
191
|
-
converter:
|
|
191
|
+
converter: s
|
|
192
192
|
})], v.prototype, "includeConsent", void 0), i([o({
|
|
193
193
|
type: String,
|
|
194
194
|
attribute: "hotjar-id"
|
|
@@ -198,7 +198,7 @@ i([o({
|
|
|
198
198
|
})], v.prototype, "googleAnalyticsId", void 0), i([o({
|
|
199
199
|
type: Boolean,
|
|
200
200
|
attribute: "dev-mode",
|
|
201
|
-
converter:
|
|
201
|
+
converter: s
|
|
202
202
|
})], v.prototype, "devMode", void 0), i([o({
|
|
203
203
|
type: String,
|
|
204
204
|
attribute: "cookie-domain"
|
|
@@ -268,7 +268,7 @@ var b = class extends v {
|
|
|
268
268
|
renderLink(t) {
|
|
269
269
|
let { target: n, rel: r } = this.linkTarget(t);
|
|
270
270
|
return e`
|
|
271
|
-
<a class="pkt-footer-simple__link" href=${t.href} target=${n} rel=${
|
|
271
|
+
<a class="pkt-footer-simple__link" href=${t.href} target=${n} rel=${d(r)}>
|
|
272
272
|
<pkt-icon class="pkt-footer-simple__link-icon" name="arrow-link"></pkt-icon>
|
|
273
273
|
<span>${t.text}${this.renderLinkDomain(t, "pkt-footer-simple__link-domain")}</span>
|
|
274
274
|
</a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs")
|
|
2
|
-
<a href=${
|
|
3
|
-
>${
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs");require("./consent-Dl-R0iC3.cjs");const t=require("./booleanish-BF8l4scU.cjs"),n=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-Dnv6LtPC.cjs");const r=require("./if-defined-2mkIDgOm.cjs");var i=`oslo.kommune.no`,a=/\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;function o(e){let t=e.toLowerCase().replace(/\.$/,``),n=t.split(`.`);return n.length<=2?t:n.slice(a.test(t)?-3:-2).join(`.`)}function s(e){if(!e)return;let t;try{t=new URL(e)}catch{return}if(t.protocol===`http:`||t.protocol===`https:`)return o(t.hostname.toLowerCase().replace(/\.$/,``))}function c(e,t=i){if(!e)return;let n;try{n=new URL(e)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=n.hostname.toLowerCase().replace(/\.$/,``),a=t.toLowerCase();if(!(r===a||r.endsWith(`.${a}`)))return o(r)}var l=`#cb-trigger`,u=class extends e.t{constructor(...e){super(...e),this.locale=`nb-NO`,this.skipGlobal=!1,this.openLinksInNewTab=!1,this.includeConsent=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.devMode=!1,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null}connectedCallback(){super.connectedCallback(),!this.data&&!this.skipGlobal&&this.loadData()}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort()}updated(e){super.updated(e),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData()}async loadData(){this.abortController?.abort(),this.abortController=new AbortController;try{this.fetchedData=await n.t(this.dataUrl,this.abortController.signal)}catch(e){if(e.name===`AbortError`)return;console.warn(`Failed to fetch header/footer data:`,e),this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get globalFooterData(){return n.n(this.data??this.fetchedData,this.locale)?.footer}linkTarget(e){return e.openInNewTab||this.openLinksInNewTab?{target:`_blank`,rel:`noopener noreferrer`}:{target:`_self`}}renderLinkDomain(t,n=`pkt-footer__link-domain`){if(!t.external)return e.h;let r=s(t.href);return r?e._` <span class=${n}>(${r})</span>`:e.h}renderCustomLink(t){let{target:n,rel:i}=this.linkTarget(t);return e._`
|
|
2
|
+
<a href=${t.href} target=${n} rel=${r.t(i)}
|
|
3
|
+
>${t.text}${this.renderLinkDomain(t)}</a
|
|
4
4
|
>
|
|
5
5
|
`}renderConsent(){return this.includeConsent?e._`
|
|
6
6
|
<pkt-consent
|
|
@@ -38,10 +38,10 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs")
|
|
|
38
38
|
${t.links.map(e=>this.renderGlobalSectionLink(e))}
|
|
39
39
|
</ul>
|
|
40
40
|
</section>
|
|
41
|
-
`}renderSomeLink(t){let n
|
|
41
|
+
`}renderSomeLink(t){let r=n.r(t.url,t.text);return r?e._`
|
|
42
42
|
<li>
|
|
43
43
|
<a class="pkt-footer__some-link" href=${t.url} aria-label=${t.text}>
|
|
44
|
-
<pkt-icon class="pkt-footer__some-icon" name=${
|
|
44
|
+
<pkt-icon class="pkt-footer__some-icon" name=${r}></pkt-icon>
|
|
45
45
|
</a>
|
|
46
46
|
</li>
|
|
47
47
|
`:e._`<li><a href=${t.url}>${t.text}</a></li>`}renderGlobalBottom(t){let n=t.links?.length>0,r=t.some?.length>0;return!n&&!r?e.h:e._`
|
|
@@ -66,7 +66,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs")
|
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
68
68
|
</div>
|
|
69
|
-
`:e.h}};e.n([e.u({type:String,attribute:`data-url`})],u.prototype,`dataUrl`,void 0),e.n([e.u({type:Object,attribute:!1})],u.prototype,`data`,void 0),e.n([e.u({type:String})],u.prototype,`locale`,void 0),e.n([e.u({type:Boolean,attribute:`skip-global`,converter:
|
|
69
|
+
`:e.h}};e.n([e.u({type:String,attribute:`data-url`})],u.prototype,`dataUrl`,void 0),e.n([e.u({type:Object,attribute:!1})],u.prototype,`data`,void 0),e.n([e.u({type:String})],u.prototype,`locale`,void 0),e.n([e.u({type:Boolean,attribute:`skip-global`,converter:t.t})],u.prototype,`skipGlobal`,void 0),e.n([e.u({type:Boolean,attribute:`open-links-in-new-tab`,converter:t.t})],u.prototype,`openLinksInNewTab`,void 0),e.n([e.u({type:Boolean,attribute:`include-consent`,converter:t.t})],u.prototype,`includeConsent`,void 0),e.n([e.u({type:String,attribute:`hotjar-id`})],u.prototype,`hotjarId`,void 0),e.n([e.u({type:String,attribute:`google-analytics-id`})],u.prototype,`googleAnalyticsId`,void 0),e.n([e.u({type:Boolean,attribute:`dev-mode`,converter:t.t})],u.prototype,`devMode`,void 0),e.n([e.u({type:String,attribute:`cookie-domain`})],u.prototype,`cookieDomain`,void 0),e.n([e.u({type:String,attribute:`cookie-secure`})],u.prototype,`cookieSecure`,void 0),e.n([e.u({type:String,attribute:`cookie-expiry-days`})],u.prototype,`cookieExpiryDays`,void 0),e.n([e.l()],u.prototype,`fetchedData`,void 0);var d=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-host`)}renderColumn(t){return e._`
|
|
70
70
|
<section>
|
|
71
71
|
<h2>${t.title}</h2>
|
|
72
72
|
${t.text?e._`<p>${t.text}</p>`:e.h}
|
|
@@ -92,10 +92,10 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs")
|
|
|
92
92
|
${t||n?this.renderSecondary():e.h}
|
|
93
93
|
${this.renderGlobalFooter()}
|
|
94
94
|
</footer>
|
|
95
|
-
`}};e.n([e.u({type:Array})],d.prototype,`columns`,void 0);try{e.d(`pkt-footer`)(d)}catch{console.warn(`Forsøker å definere <pkt-footer>, men den er allerede definert`)}var f=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-simple-host`)}renderLink(
|
|
96
|
-
<a class="pkt-footer-simple__link" href=${
|
|
95
|
+
`}};e.n([e.u({type:Array})],d.prototype,`columns`,void 0);try{e.d(`pkt-footer`)(d)}catch{console.warn(`Forsøker å definere <pkt-footer>, men den er allerede definert`)}var f=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-simple-host`)}renderLink(t){let{target:n,rel:i}=this.linkTarget(t);return e._`
|
|
96
|
+
<a class="pkt-footer-simple__link" href=${t.href} target=${n} rel=${r.t(i)}>
|
|
97
97
|
<pkt-icon class="pkt-footer-simple__link-icon" name="arrow-link"></pkt-icon>
|
|
98
|
-
<span>${
|
|
98
|
+
<span>${t.text}${this.renderLinkDomain(t,`pkt-footer-simple__link-domain`)}</span>
|
|
99
99
|
</a>
|
|
100
100
|
`}render(){let t=!!this.links?.length,n=this.skipGlobal&&this.includeConsent;return e._`
|
|
101
101
|
<footer class="pkt-footer-simple">
|