@oslokommune/punkt-elements 19.2.0 → 19.3.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 +13 -0
- package/dist/{accordion-BLMbI8SQ.cjs → accordion-CZ0O4c0_.cjs} +1 -1
- package/dist/{accordion-Bwka5Mxo.js → accordion-DFcdonl-.js} +5 -5
- package/dist/{alert-vIaasUjb.js → alert-BhvjSA5X.js} +7 -7
- package/dist/{alert-DsGNGcgd.cjs → alert-D1bQjZ7C.cjs} +2 -2
- package/dist/{async-directive-U0EE5r36.cjs → async-directive-BGoo_npW.cjs} +1 -1
- package/dist/{async-directive-C8UAk8Mv.js → async-directive-DsdqP_X7.js} +2 -2
- package/dist/{backlink-DM220m4q.cjs → backlink-Bw6IcRIo.cjs} +1 -1
- package/dist/{backlink-BjJwDjuP.js → backlink-DIdgvE2j.js} +3 -3
- package/dist/{breadcrumbs-B1pDtQy8.js → breadcrumbs-BfgCx3Xj.js} +2 -2
- package/dist/{breadcrumbs-BUmbj-hP.cjs → breadcrumbs-C10K1XLP.cjs} +1 -1
- package/dist/{button-BUl8uWWh.js → button-B5rWxfei.js} +5 -5
- package/dist/{button-CCR4eyt_.cjs → button-CmNrMH-c.cjs} +1 -1
- package/dist/{calendar-CtfdBqJN.cjs → calendar-D-Ow5DAp.cjs} +1 -1
- package/dist/{calendar-DWSW_GeN.js → calendar-U8xkRdgF.js} +3 -3
- package/dist/{card-27RxxKxW.js → card-D2YYPZr5.js} +23 -22
- package/dist/{card-B-RKnu_C.cjs → card-DW1uklP6.cjs} +6 -6
- package/dist/{checkbox-CTf4GatI.js → checkbox-B2O0fkh9.js} +25 -14
- package/dist/checkbox-C0zLtnCI.cjs +40 -0
- package/dist/{class-map-D5GHsely.js → class-map-C4hdfSfY.js} +1 -1
- package/dist/{class-map-B0FX3YsK.cjs → class-map-Drv0_anQ.cjs} +1 -1
- package/dist/{combobox-nqNZDvBR.cjs → combobox-BgduqUpf.cjs} +1 -1
- package/dist/{combobox-DHL_CGYv.js → combobox-DpXTwNr4.js} +12 -12
- package/dist/components/card/card.d.ts +2 -1
- package/dist/components/checkbox/checkbox.d.ts +3 -2
- package/dist/components/fileupload/fileupload-operations.d.ts +6 -3
- package/dist/components/fileupload/fileupload-renderers.d.ts +5 -3
- package/dist/{consent-BeoP4rOa.js → consent-BBxZkgCO.js} +2 -2
- package/dist/{consent-Cle1hkPg.cjs → consent-BjYaCbef.cjs} +1 -1
- package/dist/{datepicker-DvO3w0eM.cjs → datepicker-53rj_Qqx.cjs} +1 -1
- package/dist/{datepicker-BWp2PM9S.js → datepicker-BLBimRTT.js} +11 -11
- package/dist/{directive-helpers-BushnrQQ.cjs → directive-helpers-BRrz3Bcj.cjs} +1 -1
- package/dist/{directive-helpers-DpyLJPJm.js → directive-helpers-D96YEsht.js} +1 -1
- package/dist/{element-CewjrA4g.cjs → element-BOmr9YLv.cjs} +1 -1
- package/dist/{element-CqC-sGuC.js → element-mwwC2Rra.js} +37 -3
- package/dist/{element-with-slot-MCvSBwUv.cjs → element-with-slot-2PHu2w7O.cjs} +1 -1
- package/dist/{element-with-slot-D_OKDlYo.js → element-with-slot-FD826ooP.js} +2 -2
- package/dist/{fileupload-DDLvQaSS.cjs → fileupload-4wgr4iAi.cjs} +78 -76
- package/dist/{fileupload-DbtTD1aU.js → fileupload-BxfBFhFt.js} +120 -100
- package/dist/{footer-CupUAe8d.cjs → footer-BGj1uWwC.cjs} +1 -1
- package/dist/{footer-UT8MbnCT.js → footer-D_d5kq44.js} +4 -4
- package/dist/{header-BxgtAiNM.js → header-CF-Re0nT.js} +14 -13
- package/dist/{header-wdEiBTI9.cjs → header-Cs4t2XMM.cjs} +4 -3
- package/dist/{header-menu-DGywRJCx.cjs → header-menu-BnqZagI6.cjs} +3 -3
- package/dist/{header-menu-CTEPH4St.js → header-menu-C9k9xG9V.js} +6 -6
- package/dist/{heading-ELXWxyTv.js → heading-BRHCV_5J.js} +2 -2
- package/dist/{heading-BDdX4JiM.cjs → heading-u9Arof4p.cjs} +1 -1
- package/dist/{helptext-DQe6GO75.cjs → helptext-DYgeTMtA.cjs} +1 -1
- package/dist/{helptext-BQkrYsoV.js → helptext-sRC8EJqL.js} +4 -4
- package/dist/{icon-Clz68-Kz.cjs → icon-CoBsgGUR.cjs} +1 -1
- package/dist/{icon-B2v30QUk.js → icon-DmRyYNlY.js} +1 -1
- package/dist/if-defined-2mkIDgOm.cjs +1 -0
- package/dist/{if-defined-BNXGXCwT.js → if-defined-Bebu3LXY.js} +1 -1
- package/dist/{input-element-BTzuDh4h.js → input-element-B1BntJeJ.js} +2 -2
- package/dist/{input-element-BdIWsDl-.cjs → input-element-W6Gklt2E.cjs} +1 -1
- package/dist/{input-wrapper-B5GdwzAM.js → input-wrapper-C1zXIKBU.js} +6 -6
- package/dist/{input-wrapper-BmPdpY4N.cjs → input-wrapper-CSPPa4uc.cjs} +1 -1
- package/dist/{link-BxKWhYsn.js → link-DcxVUj8s.js} +4 -4
- package/dist/{link-1JEWpEDG.cjs → link-EMsHusF7.cjs} +1 -1
- package/dist/{linkcard-DXOkeQUy.cjs → linkcard-CWeR6t2a.cjs} +1 -1
- package/dist/{linkcard-CICSZ7pK.js → linkcard-MJFR7FLT.js} +4 -4
- package/dist/{listbox-3fi7wQz4.cjs → listbox-BoBwzL4p.cjs} +6 -6
- package/dist/{listbox-7pQ0UjKV.js → listbox-DEzd-dxF.js} +65 -61
- package/dist/{loader-nIl61aTv.js → loader-CqFQoJlM.js} +4 -4
- package/dist/{loader-BA__N62k.cjs → loader-SJ6NauNT.cjs} +1 -1
- package/dist/{messagebox-D2xvSYWI.cjs → messagebox-D5GYIdjE.cjs} +2 -2
- package/dist/{messagebox-E8W7RyAJ.js → messagebox-DsKi_rKn.js} +5 -5
- package/dist/{modal-D5tGq-nN.js → modal-CJqe6y-V.js} +7 -7
- package/dist/{modal-i3Qxv38H.cjs → modal-DaerHpVi.cjs} +3 -3
- 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-breadcrumbs.cjs +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.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-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +35 -35
- 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-BClk341e.cjs → pkt-options-controller-Dz-rYCG1.cjs} +1 -1
- package/dist/{pkt-options-controller-v2bPM9iU.js → pkt-options-controller-sUzxHa5A.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-4WyR4T72.js → progressbar-Bd0DjiAb.js} +5 -5
- package/dist/{progressbar-CJFGbev-.cjs → progressbar-BrVlAcQI.cjs} +1 -1
- package/dist/{radiobutton-D7308uCY.js → radiobutton-B0V-jSEX.js} +4 -4
- package/dist/{radiobutton-BQRtv7PK.cjs → radiobutton-Cv1BlwLV.cjs} +1 -1
- package/dist/{ref-37-yxmc4.js → ref-CCSGk4MP.js} +2 -2
- package/dist/{ref-HT6KRjxp.cjs → ref-Emu5PNxk.cjs} +1 -1
- package/dist/{repeat-DntD73oB.js → repeat-CdxGS-_3.js} +2 -2
- package/dist/{repeat-Ddge5HTp.cjs → repeat-Dh9YKoeV.cjs} +1 -1
- package/dist/{searchinput-D1cJ73Ki.cjs → searchinput-7-VVdkss.cjs} +1 -1
- package/dist/{searchinput-j4IvYRzj.js → searchinput-CgzigmiI.js} +4 -4
- package/dist/{select-CDoA2rpC.cjs → select---PCiwmy.cjs} +1 -1
- package/dist/{select-BhK8veJn.js → select-BbcGPmPs.js} +7 -7
- package/dist/shared-strings/nb.d.ts +34 -0
- package/dist/shared-types/checkbox.d.ts +52 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/{tabs-DexV26qJ.js → tabs-B134M9k2.js} +4 -4
- package/dist/{tabs-95BpwB6j.cjs → tabs-Dw9E06fL.cjs} +1 -1
- package/dist/{tag-CQEyjF32.cjs → tag-HTYKd-iG.cjs} +1 -1
- package/dist/{tag-DoUC99hn.js → tag-wYnHhHLK.js} +5 -5
- package/dist/{textarea-sulH-Yk7.js → textarea-BcgVLLTt.js} +9 -9
- package/dist/{textarea-BLVuKEng.cjs → textarea-pA_xv8lI.cjs} +1 -1
- package/dist/{textinput-CSrBua2N.cjs → textinput-Czz2affL.cjs} +1 -1
- package/dist/{textinput-Di2lAf2R.js → textinput-Dpj1X5yr.js} +8 -8
- package/dist/{timepicker-Iq1-vWRn.cjs → timepicker-BwDZkSpo.cjs} +1 -1
- package/dist/{timepicker-BaDGjuOR.js → timepicker-CfQMZlaP.js} +8 -8
- package/package.json +2 -2
- package/src/components/alert/alert.test.ts +1 -1
- package/src/components/alert/alert.ts +1 -1
- package/src/components/card/card.ts +7 -2
- package/src/components/checkbox/checkbox.ts +13 -8
- package/src/components/fileupload/fileupload-operations.ts +31 -22
- package/src/components/fileupload/fileupload-renderers.ts +28 -17
- package/src/components/fileupload/fileupload.ts +26 -9
- package/src/components/header/header-global.ts +2 -1
- package/src/components/header/header-service.test.ts +15 -0
- package/src/components/header/header-user-menu.ts +1 -1
- package/src/components/header-menu/header-menu.ts +2 -2
- package/src/components/listbox/listbox.ts +9 -4
- package/src/components/messagebox/messagebox.ts +1 -1
- package/src/components/modal/modal.ts +2 -2
- package/dist/checkbox-DlzVGBum.cjs +0 -40
- package/dist/if-defined-CjRKmMQs.cjs +0 -1
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),n=require("./if-defined-CjRKmMQs.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-DsGNGcgd.cjs"),require("./icon-Clz68-Kz.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-BmPdpY4N.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-i3Qxv38H.cjs"),require("./progressbar-CJFGbev-.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=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},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=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
2
|
-
<label for=${
|
|
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-D1bQjZ7C.cjs"),require("./icon-CoBsgGUR.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-CSPPa4uc.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-DaerHpVi.cjs"),require("./progressbar-BrVlAcQI.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._`
|
|
2
|
+
<label for=${i} class="pkt-sr-only">${t.renameInputLabel}</label>
|
|
3
3
|
<input
|
|
4
|
-
id=${
|
|
4
|
+
id=${i}
|
|
5
5
|
type="text"
|
|
6
6
|
class="pkt-fileupload__queue-display__item__rename-input"
|
|
7
|
-
?disabled=${
|
|
8
|
-
.value=${
|
|
9
|
-
@keydown=${e=>O(e,
|
|
7
|
+
?disabled=${n.disabled}
|
|
8
|
+
.value=${r}
|
|
9
|
+
@keydown=${e=>O(e,a,n.close)}
|
|
10
10
|
/>
|
|
11
11
|
<button
|
|
12
12
|
type="button"
|
|
13
13
|
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
14
|
-
?disabled=${
|
|
15
|
-
@click=${
|
|
14
|
+
?disabled=${n.disabled}
|
|
15
|
+
@click=${a}
|
|
16
16
|
>
|
|
17
|
-
|
|
17
|
+
${t.save}
|
|
18
18
|
</button>
|
|
19
19
|
<button
|
|
20
20
|
type="button"
|
|
21
21
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
22
|
-
?disabled=${
|
|
23
|
-
@click=${
|
|
22
|
+
?disabled=${n.disabled}
|
|
23
|
+
@click=${n.close}
|
|
24
24
|
>
|
|
25
|
-
|
|
25
|
+
${t.cancel}
|
|
26
26
|
</button>
|
|
27
27
|
`},renderHidden:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``;return e._`<input
|
|
28
28
|
type="hidden"
|
|
29
29
|
name=${`${t.inputName}-targetFilename`}
|
|
30
30
|
value=${n}
|
|
31
|
-
/>`}}),M=
|
|
32
|
-
<label for=${
|
|
33
|
-
${
|
|
31
|
+
/>`}}),M=t=>({id:`comment`,title:e=>(e.attributes?.[E]??[]).length>0?``:t.addComment,ariaLabel:t.addComment,renderExtendedUI:n=>{let r=(n.getAttribute(E)??[])[0],i=`pkt-fileupload-comment-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(E,[{text:e,timestamp:new Date().toISOString()}]),n.close()};return e._`
|
|
32
|
+
<label for=${i} class="pkt-fileupload__queue-display__item__comment-label">
|
|
33
|
+
${r?t.editComment:t.addComment}
|
|
34
34
|
</label>
|
|
35
35
|
<textarea
|
|
36
|
-
id=${
|
|
36
|
+
id=${i}
|
|
37
37
|
class="pkt-fileupload__queue-display__item__comment-input"
|
|
38
|
-
?disabled=${
|
|
39
|
-
.value=${
|
|
38
|
+
?disabled=${n.disabled}
|
|
39
|
+
.value=${r?.text??``}
|
|
40
40
|
rows="2"
|
|
41
|
-
placeholder
|
|
42
|
-
@keydown=${e=>k(e,
|
|
41
|
+
placeholder=${t.commentPlaceholder}
|
|
42
|
+
@keydown=${e=>k(e,a,n.close)}
|
|
43
43
|
></textarea>
|
|
44
44
|
<button
|
|
45
45
|
type="button"
|
|
46
46
|
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
47
|
-
?disabled=${
|
|
48
|
-
@click=${
|
|
47
|
+
?disabled=${n.disabled}
|
|
48
|
+
@click=${a}
|
|
49
49
|
>
|
|
50
|
-
${
|
|
50
|
+
${r?t.saveComment:t.addComment}
|
|
51
51
|
</button>
|
|
52
52
|
<button
|
|
53
53
|
type="button"
|
|
54
54
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
55
|
-
?disabled=${
|
|
56
|
-
@click=${
|
|
55
|
+
?disabled=${n.disabled}
|
|
56
|
+
@click=${n.close}
|
|
57
57
|
>
|
|
58
|
-
|
|
58
|
+
${t.cancel}
|
|
59
59
|
</button>
|
|
60
|
-
`},renderContent:
|
|
60
|
+
`},renderContent:n=>{if(n.isActive)return null;let r=n.getAttribute(E)??[];if(r.length===0)return null;let i=r[0];return e._`
|
|
61
61
|
<div class="pkt-fileupload__queue-display__item__comments">
|
|
62
62
|
<div class="pkt-fileupload__queue-display__item__comment">
|
|
63
63
|
<div class="pkt-fileupload__queue-display__item__comment__content">
|
|
64
|
-
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label
|
|
65
|
-
${
|
|
64
|
+
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label=${t.commentText}>
|
|
65
|
+
${i.text}
|
|
66
66
|
</span>
|
|
67
67
|
<time class="pkt-fileupload__queue-display__item__comment__time">
|
|
68
|
-
${D(
|
|
68
|
+
${D(i.timestamp,t)}
|
|
69
69
|
</time>
|
|
70
70
|
</div>
|
|
71
71
|
<div class="pkt-fileupload__queue-display__item__comment__actions">
|
|
72
72
|
<button
|
|
73
73
|
type="button"
|
|
74
74
|
class="pkt-fileupload__queue-display__item__comment__action"
|
|
75
|
-
aria-label
|
|
76
|
-
?disabled=${
|
|
77
|
-
@click=${
|
|
75
|
+
aria-label=${t.editComment}
|
|
76
|
+
?disabled=${n.disabled}
|
|
77
|
+
@click=${n.activate}
|
|
78
78
|
>
|
|
79
79
|
<pkt-icon name="edit"></pkt-icon>
|
|
80
80
|
</button>
|
|
81
81
|
<button
|
|
82
82
|
type="button"
|
|
83
83
|
class="pkt-fileupload__queue-display__item__comment__action"
|
|
84
|
-
aria-label
|
|
85
|
-
?disabled=${
|
|
86
|
-
@click=${()=>
|
|
84
|
+
aria-label=${t.deleteComment}
|
|
85
|
+
?disabled=${n.disabled}
|
|
86
|
+
@click=${()=>n.setAttribute(E,void 0)}
|
|
87
87
|
>
|
|
88
88
|
<pkt-icon name="trash-can"></pkt-icon>
|
|
89
89
|
</button>
|
|
@@ -106,9 +106,11 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
106
106
|
<p class="pkt-fileupload__queue-display__item__title">
|
|
107
107
|
${N(t,r)}${n?e._`<span class="pkt-fileupload__queue-display__item__filesize"> (${n})</span>`:null}
|
|
108
108
|
</p>
|
|
109
|
-
`,F=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,I=t=>e._`<span
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
`,F=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,I=t=>e._`<span
|
|
110
|
+
class="pkt-fileupload__queue-display__item__loading-text"
|
|
111
|
+
aria-label=${t.uploadingFile}
|
|
112
|
+
>${t.uploading}</span
|
|
113
|
+
>`,L=({operationId:e,file:t,inputName:n,disabled:r,isActive:i,onActivateOperation:a,onCloseOperation:o,getFileAttribute:s,setFileAttribute:c})=>({file:t,inputName:n,disabled:r,isActive:i,activate:()=>a(t.fileId,e),close:()=>o(t.fileId),getAttribute:e=>s(t.fileId,e),setAttribute:(e,n)=>c(t.fileId,e,n)}),R=({file:t,fileSize:n,disabled:r,transferProgress:i,transferShowProgress:a,strings:o,truncateTail:s,onCancel:c,iconName:l=`document-text`})=>{let u=w(t),d=a??i!==0;return e._`
|
|
112
114
|
<pkt-icon
|
|
113
115
|
name=${l}
|
|
114
116
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -118,11 +120,11 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
118
120
|
<button
|
|
119
121
|
type="button"
|
|
120
122
|
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
121
|
-
aria-label
|
|
123
|
+
aria-label=${o.cancelUpload}
|
|
122
124
|
?disabled=${r}
|
|
123
125
|
@click=${()=>c(t.fileId)}
|
|
124
126
|
>
|
|
125
|
-
|
|
127
|
+
${o.cancel}
|
|
126
128
|
</button>
|
|
127
129
|
${d?e._`
|
|
128
130
|
<pkt-progressbar
|
|
@@ -136,26 +138,26 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
136
138
|
>${Math.round(i*100)}%</span
|
|
137
139
|
>
|
|
138
140
|
`:I(o)}
|
|
139
|
-
`},z=({file:t,fileSize:n,disabled:r,transferShowProgress:i,transferLastProgress:a,transferErrorMessage:o,
|
|
141
|
+
`},z=({file:t,fileSize:n,disabled:r,transferShowProgress:i,transferLastProgress:a,transferErrorMessage:o,strings:s,truncateTail:c,onCancel:l})=>{let u=w(t),d=!!i,f=Math.round((a??1)*100);return e._`
|
|
140
142
|
<pkt-icon
|
|
141
143
|
name="alert-error"
|
|
142
144
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
143
145
|
aria-hidden="true"
|
|
144
146
|
></pkt-icon>
|
|
145
|
-
${P(
|
|
147
|
+
${P(u,n,c)}
|
|
146
148
|
<button
|
|
147
149
|
type="button"
|
|
148
150
|
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
149
|
-
aria-label
|
|
151
|
+
aria-label=${s.removeFailedFile}
|
|
150
152
|
?disabled=${r}
|
|
151
|
-
@click=${()=>
|
|
153
|
+
@click=${()=>l(t.fileId)}
|
|
152
154
|
>
|
|
153
|
-
|
|
155
|
+
${s.removeFailed}
|
|
154
156
|
</button>
|
|
155
|
-
${
|
|
157
|
+
${d?e._`
|
|
156
158
|
<pkt-progressbar
|
|
157
159
|
class="pkt-fileupload__queue-display__item__progress pkt-fileupload__queue-display__item__progress--error"
|
|
158
|
-
valueCurrent=${
|
|
160
|
+
valueCurrent=${f}
|
|
159
161
|
valueMax=${100}
|
|
160
162
|
statusType="none"
|
|
161
163
|
statusPlacement="following"
|
|
@@ -183,27 +185,27 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
183
185
|
aria-hidden="true"
|
|
184
186
|
></pkt-icon>
|
|
185
187
|
${P(i,n,r)}
|
|
186
|
-
`},G=({file:i,thumbnailUrl:a,previewEnabled:o,canOpenPreview:s,truncateTail:c,
|
|
188
|
+
`},G=({file:i,thumbnailUrl:a,previewEnabled:o,canOpenPreview:s,truncateTail:c,strings:l,onOpenPreview:u,onThumbnailImageError:d})=>{let f=w(i),p=!!a,m=!!o&&!!s,h=m&&!!u;return e._`
|
|
187
189
|
<div
|
|
188
|
-
class=${t.t({"pkt-fileupload__queue-display__item__thumbnail":!0,"pkt-fileupload__queue-display__item__thumbnail--fallback":!
|
|
190
|
+
class=${t.t({"pkt-fileupload__queue-display__item__thumbnail":!0,"pkt-fileupload__queue-display__item__thumbnail--fallback":!p})}
|
|
189
191
|
>
|
|
190
192
|
<button
|
|
191
193
|
type="button"
|
|
192
194
|
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
193
|
-
aria-label=${r.t(
|
|
194
|
-
?disabled=${!
|
|
195
|
-
@click=${()=>{!
|
|
195
|
+
aria-label=${r.t(l.previewImage,{filename:f})}
|
|
196
|
+
?disabled=${!h}
|
|
197
|
+
@click=${()=>{!h||!u||u(i.fileId)}}
|
|
196
198
|
>
|
|
197
199
|
<span class="pkt-btn__text">
|
|
198
|
-
${
|
|
200
|
+
${m?e._`<pkt-icon
|
|
199
201
|
name="expand"
|
|
200
202
|
class="pkt-fileupload__queue-display__item__thumbnail__expand-icon"
|
|
201
203
|
aria-hidden="true"
|
|
202
204
|
></pkt-icon>`:null}
|
|
203
|
-
${
|
|
205
|
+
${p?e._`<img
|
|
204
206
|
src=${n.t(a)}
|
|
205
|
-
alt=${
|
|
206
|
-
@error=${()=>
|
|
207
|
+
alt=${f}
|
|
208
|
+
@error=${()=>d?.(i.fileId)}
|
|
207
209
|
/>`:e._`<pkt-icon
|
|
208
210
|
name="document-text"
|
|
209
211
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -212,15 +214,15 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
212
214
|
</span>
|
|
213
215
|
</button>
|
|
214
216
|
<span class="pkt-fileupload__queue-display__item__thumbnail__title"
|
|
215
|
-
>${N(
|
|
217
|
+
>${N(f,c)}</span
|
|
216
218
|
>
|
|
217
219
|
</div>
|
|
218
|
-
`},K=({file:n,inputName:r,disabled:i,fileSize:a,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d,transferProgress:f,transferErrorMessage:p,transferShowProgress:m,transferLastProgress:h,
|
|
220
|
+
`},K=({file:n,inputName:r,disabled:i,fileSize:a,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d,transferProgress:f,transferErrorMessage:p,transferShowProgress:m,transferLastProgress:h,strings:g,truncateTail:_,onCancel:v})=>{let y=F(f),b=o.find(e=>e.id===s),x=b?.renderInlineUI?b.renderInlineUI(L({operationId:b.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})):null;return e._`
|
|
219
221
|
<li
|
|
220
222
|
class=${t.t({"pkt-fileupload__queue-display__item":!0,"pkt-fileupload__queue-display__item--in-progress":y===`in-progress`,"pkt-fileupload__queue-display__item--error":y===`error`,[`pkt-fileupload__queue-display__item--${f}`]:typeof f==`string`})}
|
|
221
223
|
>
|
|
222
224
|
${U({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})}
|
|
223
|
-
${y===`in-progress`?R({file:n,fileSize:a,disabled:i,transferProgress:f,transferShowProgress:m,
|
|
225
|
+
${y===`in-progress`?R({file:n,fileSize:a,disabled:i,transferProgress:f,transferShowProgress:m,strings:g,truncateTail:_,onCancel:v}):y===`error`?z({file:n,fileSize:a,disabled:i,transferShowProgress:m,transferLastProgress:h,transferErrorMessage:p,strings:g,truncateTail:_,onCancel:v}):x?e._`
|
|
224
226
|
<pkt-icon
|
|
225
227
|
name="document-text"
|
|
226
228
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -234,12 +236,12 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
234
236
|
${y===`idle`?V({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
235
237
|
${y===`idle`?H({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
236
238
|
</li>
|
|
237
|
-
`},q=({file:n,inputName:r,disabled:i,fileSize:a,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m,transferProgress:h,transferErrorMessage:g,transferShowProgress:_,transferLastProgress:v,
|
|
239
|
+
`},q=({file:n,inputName:r,disabled:i,fileSize:a,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m,transferProgress:h,transferErrorMessage:g,transferShowProgress:_,transferLastProgress:v,strings:y,truncateTail:b,onCancel:x,onOpenPreview:S,onThumbnailImageError:C})=>{let w=F(h),T=l.find(e=>e.id===u),E=T?.renderInlineUI?T.renderInlineUI(L({operationId:T.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})):null;return e._`
|
|
238
240
|
<li
|
|
239
241
|
class=${t.t({"pkt-fileupload__queue-display__item":!0,"pkt-fileupload__queue-display__item--in-progress":w===`in-progress`,"pkt-fileupload__queue-display__item--error":w===`error`,[`pkt-fileupload__queue-display__item--${h}`]:typeof h==`string`})}
|
|
240
242
|
>
|
|
241
243
|
${U({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})}
|
|
242
|
-
${w===`in-progress`?R({file:n,fileSize:a,disabled:i,transferProgress:h,transferShowProgress:_,
|
|
244
|
+
${w===`in-progress`?R({file:n,fileSize:a,disabled:i,transferProgress:h,transferShowProgress:_,strings:y,truncateTail:b,onCancel:x,iconName:`picture`}):w===`error`?z({file:n,fileSize:a,disabled:i,transferShowProgress:_,transferLastProgress:v,transferErrorMessage:g,strings:y,truncateTail:b,onCancel:x}):E?e._`
|
|
243
245
|
<pkt-icon
|
|
244
246
|
name="picture"
|
|
245
247
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -248,7 +250,7 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
248
250
|
<div class="pkt-fileupload__queue-display__item__inline-ui">
|
|
249
251
|
${E}
|
|
250
252
|
</div>
|
|
251
|
-
`:G({file:n,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,truncateTail:b,onOpenPreview:S,onThumbnailImageError:C})}
|
|
253
|
+
`:G({file:n,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,truncateTail:b,strings:y,onOpenPreview:S,onThumbnailImageError:C})}
|
|
252
254
|
${w===`idle`?B({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
253
255
|
${w===`idle`?V({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
254
256
|
${w===`idle`?H({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
@@ -300,7 +302,7 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
300
302
|
?disabled=${this.disabled}
|
|
301
303
|
?required=${this.required&&this.uploadStrategy===`form`}
|
|
302
304
|
accept=${this.getResolvedAcceptValue()}
|
|
303
|
-
aria-label=${n.t(this.label?void 0:this.multiple
|
|
305
|
+
aria-label=${n.t(this.label?void 0:this.multiple?this.pktStrings.get(`fileupload`).openFileDialogLabelMultiple:this.pktStrings.get(`fileupload`).openFileDialogLabelSingle)}
|
|
304
306
|
aria-required=${n.t(this.required?`true`:void 0)}
|
|
305
307
|
aria-invalid=${n.t(this.hasEffectiveError?`true`:void 0)}
|
|
306
308
|
aria-describedby=${n.t(s)}
|
|
@@ -350,20 +352,20 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
350
352
|
</ul>`:null}
|
|
351
353
|
${this.renderPreviewModal(i)}
|
|
352
354
|
</div>
|
|
353
|
-
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations();if(this.itemRenderer===`thumbnail`){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 n=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||n.previewFallbackName;return e._`
|
|
354
356
|
<pkt-modal
|
|
355
357
|
.open=${this.isPreviewModalOpen}
|
|
356
|
-
.headingText=${
|
|
358
|
+
.headingText=${c}
|
|
357
359
|
closeOnBackdropClick
|
|
358
360
|
class="pkt-fileupload__image-preview-modal"
|
|
359
361
|
@close=${this.closePreview}
|
|
360
362
|
@keydown=${e=>this.onPreviewKeyDown(e,t)}
|
|
361
363
|
>
|
|
362
364
|
<div class="pkt-fileupload__image-preview">
|
|
363
|
-
${
|
|
365
|
+
${a?e._`<button
|
|
364
366
|
type="button"
|
|
365
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"
|
|
366
|
-
aria-label=${
|
|
368
|
+
aria-label=${r.t(n.previewPrevious,{index:this.previewCurrentIndex,total:t.length})}
|
|
367
369
|
@click=${()=>this.navigatePreview(`prev`,t)}
|
|
368
370
|
>
|
|
369
371
|
<pkt-icon
|
|
@@ -375,11 +377,11 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
375
377
|
</button>`:null}
|
|
376
378
|
|
|
377
379
|
<div class="pkt-fileupload__image-preview__content">
|
|
378
|
-
${
|
|
379
|
-
src=${
|
|
380
|
-
alt=${
|
|
380
|
+
${s?e._`<img
|
|
381
|
+
src=${o}
|
|
382
|
+
alt=${r.t(n.previewImageAlt,{filename:c,index:this.previewCurrentIndex+1,total:t.length})}
|
|
381
383
|
class="pkt-fileupload__image-preview__image"
|
|
382
|
-
@error=${()=>this.markImageFailed(
|
|
384
|
+
@error=${()=>this.markImageFailed(i.fileId,`preview`)}
|
|
383
385
|
/>`:e._`<pkt-icon
|
|
384
386
|
name="picture"
|
|
385
387
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -387,13 +389,13 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
387
389
|
></pkt-icon>`}
|
|
388
390
|
</div>
|
|
389
391
|
|
|
390
|
-
${
|
|
392
|
+
${a?e._`<span class="pkt-fileupload__image-preview__counter">
|
|
391
393
|
${this.previewCurrentIndex+1} / ${t.length}
|
|
392
394
|
</span>`:null}
|
|
393
|
-
${
|
|
395
|
+
${a?e._`<button
|
|
394
396
|
type="button"
|
|
395
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"
|
|
396
|
-
aria-label=${
|
|
398
|
+
aria-label=${r.t(n.previewNext,{index:this.previewCurrentIndex+2,total:t.length})}
|
|
397
399
|
@click=${()=>this.navigatePreview(`next`,t)}
|
|
398
400
|
>
|
|
399
401
|
<pkt-icon
|
|
@@ -405,4 +407,4 @@ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),
|
|
|
405
407
|
</button>`:null}
|
|
406
408
|
</div>
|
|
407
409
|
</pkt-modal>
|
|
408
|
-
`}getQueueItemOperations(){let e=[];return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(j()),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(M()),e.push(...this.extraOperations),e.push(A(e=>this.removeFileItem(e))),e}activateOperation(e,t){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:t}}closeOperation(e){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:void 0}}getFileAttribute(e,t){let n=this.getCurrentFiles().find(t=>t.fileId===e);if(n)return n.attributes?.[t]??void 0}setFileAttribute(e,t,n){let r=this.getCurrentFiles().find(t=>t.fileId===e);if(!r)return;let i={...r.attributes,[t]:n};n===void 0&&delete i[t],this.updateFileItem(e,{attributes:i})}};e.n([e.l()],J.prototype,`activeOperationByFileId`,void 0),e.n([e.l()],J.prototype,`isPreviewModalOpen`,void 0),e.n([e.l()],J.prototype,`previewCurrentIndex`,void 0),e.n([e.l()],J.prototype,`failedImageFileIds`,void 0),J=e.n([e.d(`pkt-fileupload`)],J);var Y=J;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Y}});
|
|
410
|
+
`}getQueueItemOperations(){let e=[],t=this.pktStrings.get(`fileupload`);return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(j(t)),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(M(t)),e.push(...this.extraOperations),e.push(A(e=>this.removeFileItem(e),t)),e}activateOperation(e,t){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:t}}closeOperation(e){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:void 0}}getFileAttribute(e,t){let n=this.getCurrentFiles().find(t=>t.fileId===e);if(n)return n.attributes?.[t]??void 0}setFileAttribute(e,t,n){let r=this.getCurrentFiles().find(t=>t.fileId===e);if(!r)return;let i={...r.attributes,[t]:n};n===void 0&&delete i[t],this.updateFileItem(e,{attributes:i})}};e.n([e.l()],J.prototype,`activeOperationByFileId`,void 0),e.n([e.l()],J.prototype,`isPreviewModalOpen`,void 0),e.n([e.l()],J.prototype,`previewCurrentIndex`,void 0),e.n([e.l()],J.prototype,`failedImageFileIds`,void 0),J=e.n([e.d(`pkt-fileupload`)],J);var Y=J;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Y}});
|