@oslokommune/punkt-elements 16.18.0 → 16.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/{accordion-CU2tJ5vn.js → accordion-BjYsEbSM.js} +19 -19
- package/dist/{accordion-DDZkjXFb.cjs → accordion-DaeWPWod.cjs} +5 -5
- package/dist/{alert-D_eXGOez.js → alert-BkzC5mVu.js} +22 -22
- package/dist/{alert-NyLr62jZ.cjs → alert-D_45dWPn.cjs} +6 -6
- package/dist/{async-directive-CaQiqjyV.js → async-directive-Cz6tcqge.js} +2 -2
- package/dist/async-directive-DO1QtVmf.cjs +1 -0
- package/dist/{backlink-CTu44BHn.js → backlink-BXAdgAte.js} +6 -6
- package/dist/{backlink-BsQ0Rmxj.cjs → backlink-C42-3OG3.cjs} +2 -2
- package/dist/{breadcrumbs-BNZ1L-0q.cjs → breadcrumbs-CkjeLh3U.cjs} +6 -6
- package/dist/{breadcrumbs-DPnoURvl.js → breadcrumbs-Dkb9TxMp.js} +15 -15
- package/dist/{button-ZYlrRRfu.js → button-CR-KWhTT.js} +21 -21
- package/dist/{button-DsGvcLIn.cjs → button-Dwv11n6R.cjs} +7 -7
- package/dist/{calendar-CDDVoUby.cjs → calendar-Buvxe4l_.cjs} +11 -11
- package/dist/{calendar-VOqO5um6.js → calendar-DAq6iJdx.js} +50 -50
- package/dist/{card-B4oDGIRP.js → card-5PydU247.js} +43 -43
- package/dist/{card-DZuZy0ay.cjs → card-C__IlsUa.cjs} +26 -26
- package/dist/{checkbox-CF5mSBR5.js → checkbox-CC1X7fw4.js} +23 -23
- package/dist/{checkbox-BerAYcfK.cjs → checkbox-DzMc0AJX.cjs} +10 -10
- package/dist/class-map-B8Ja0q7n.cjs +1 -0
- package/dist/{class-map-C8HuhNzZ.js → class-map-DH9hlJny.js} +7 -8
- package/dist/{combobox-BDYoPZmg.js → combobox-D-DY7YcW.js} +42 -42
- package/dist/{combobox-Ct9gCFa1.cjs → combobox-x4tBGP3F.cjs} +17 -17
- package/dist/components/heading/heading.d.ts +5 -8
- package/dist/{consent-BME_rQ2w.cjs → consent-BB3g_ByO.cjs} +3 -3
- package/dist/{consent-1IUuWZAh.js → consent-Y14WZ0JS.js} +8 -8
- package/dist/{datepicker-ByqXCpCd.cjs → datepicker-BFI-3stE.cjs} +20 -20
- package/dist/{datepicker-BGpoabCM.js → datepicker-CRk7aiwH.js} +57 -57
- package/dist/{directive-helpers-Dkv2gKgs.js → directive-helpers-Cep_4cpj.js} +1 -1
- package/dist/{directive-helpers-D1QSxY17.cjs → directive-helpers-f36YZFOG.cjs} +1 -1
- package/dist/docs/components/loader.d.ts +6 -0
- package/dist/element-CXAtr6Gu.cjs +2 -0
- package/dist/{element-cZ85T_aa.js → element-CduG0XyF.js} +47 -23
- package/dist/{element-with-slot-4J2o3SeU.js → element-with-slot-BVj9MXzi.js} +5 -6
- package/dist/element-with-slot-Cmxb9h4H.cjs +1 -0
- package/dist/{fileupload-B6W7qOQT.js → fileupload-C8muj8qd.js} +149 -149
- package/dist/{fileupload-a2OL3dzG.cjs → fileupload-YtsrgQTY.cjs} +40 -40
- package/dist/{header-BZFSan0_.cjs → header-CjBip0zj.cjs} +57 -57
- package/dist/{header-BgVpJMHQ.js → header-DONTGbD9.js} +130 -130
- package/dist/{header-menu-BXzVVOHq.js → header-menu-BU-ylGrJ.js} +45 -45
- package/dist/{header-menu-BLngov1D.cjs → header-menu-CnW7nzmF.cjs} +24 -24
- package/dist/heading-3o4Dk0Wn.js +80 -0
- package/dist/heading-C40-NX0r.cjs +1 -0
- package/dist/{helptext-BeU-enix.js → helptext-C2aQBBo_.js} +12 -12
- package/dist/{helptext-DWMFqMnV.cjs → helptext-DNLg43eI.cjs} +4 -4
- package/dist/icon-Dw6I0HDV.cjs +1 -0
- package/dist/{icon-CZQkrK6B.js → icon-LaKyBKON.js} +18 -19
- package/dist/if-defined-LTjAScFG.cjs +1 -0
- package/dist/{if-defined-Cjj8qN-Z.js → if-defined-VShASPdu.js} +1 -1
- package/dist/{input-element-D0egtEnr.cjs → input-element-BHQVt4Q9.cjs} +1 -1
- package/dist/{input-element-B1ciW1N2.js → input-element-BrmkXIXi.js} +30 -30
- package/dist/{input-wrapper-oYcbCFow.js → input-wrapper-B6WowlWG.js} +33 -33
- package/dist/{input-wrapper-Y98KV-sy.cjs → input-wrapper-Dhkt20WW.cjs} +17 -17
- package/dist/{link-BMMIjg50.cjs → link-B5ur0Rym.cjs} +4 -4
- package/dist/{link-CT0LB3S7.js → link-ClUNY__5.js} +13 -13
- package/dist/linkcard-BIcCW-qw.cjs +13 -0
- package/dist/{linkcard-Bz5zb69P.js → linkcard-DNJm5FvA.js} +15 -15
- package/dist/{listbox-0NHJvNjz.js → listbox-DXMIBv3y.js} +35 -35
- package/dist/{listbox-CcThiNBY.cjs → listbox-DbEobJNx.cjs} +14 -14
- package/dist/{loader-8T6M0FCQ.cjs → loader-Uap9qDsV.cjs} +5 -5
- package/dist/{loader-Cbrc4FFx.js → loader-gKdQpOOQ.js} +12 -12
- package/dist/{messagebox-C6LHT78_.cjs → messagebox-BqBxXK8c.cjs} +5 -5
- package/dist/{messagebox-TKKUVTo4.js → messagebox-XRFecqyS.js} +15 -15
- package/dist/{modal-BVHH8koz.js → modal-CWgeT-RP.js} +19 -19
- package/dist/{modal-CRzbtqL3.cjs → modal-CrYHKOmr.cjs} +8 -8
- 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-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 +32 -32
- 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-CCB15L_G.js → pkt-options-controller-BTNtjEIS.js} +1 -1
- package/dist/{pkt-options-controller-CeAQ-D-i.cjs → pkt-options-controller-CBM8xHwR.cjs} +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-C-5oESiB.js → progressbar-B0P_vmGD.js} +23 -24
- package/dist/progressbar-DADdvDl5.cjs +17 -0
- package/dist/{radiobutton-B1Xg6XzP.cjs → radiobutton-BfURufrZ.cjs} +8 -8
- package/dist/{radiobutton-BAn1V_mQ.js → radiobutton-C6zERHoy.js} +20 -20
- package/dist/{ref-RS8Uv6uC.js → ref-BgoHEsEt.js} +7 -8
- package/dist/ref-CBdWMlde.cjs +1 -0
- package/dist/{repeat-DV1O43YU.js → repeat-CKIii8Mi.js} +15 -16
- package/dist/repeat-CRRgmzVn.cjs +1 -0
- package/dist/{searchinput-DUgZb_zm.cjs → searchinput-BrxfRzez.cjs} +13 -13
- package/dist/{searchinput-C9FP89qD.js → searchinput-fPvXHu2O.js} +31 -31
- package/dist/{select-DkKIW7zD.js → select-BIgFPp42.js} +13 -13
- package/dist/{select-DAs8kzN4.cjs → select-DzZHv6Bz.cjs} +3 -3
- package/dist/{tabs-ClI1XQDt.js → tabs-BJx6wwXD.js} +29 -29
- package/dist/{tabs-CN_RIMWg.cjs → tabs-DxQy8U-0.cjs} +7 -7
- package/dist/{tag-vgKH9B4k.cjs → tag-CBFz0R9N.cjs} +5 -5
- package/dist/{tag-DSZ-czu-.js → tag-CzlnHhho.js} +19 -19
- package/dist/textarea-M_S9WK7s.cjs +46 -0
- package/dist/{textarea-BfjI6d7Q.js → textarea-qHtkhelz.js} +24 -25
- package/dist/{textinput-DhoupEyI.js → textinput-CZrBM-Fj.js} +26 -26
- package/dist/{textinput-BM66vo5e.cjs → textinput-C_6kvf87.cjs} +12 -12
- package/dist/{timepicker-CtRGbypF.js → timepicker-O0iCeJyW.js} +51 -51
- package/dist/{timepicker-C4oRmmRd.cjs → timepicker-WiYLAncb.cjs} +20 -20
- package/package.json +2 -2
- package/src/components/card/card.ts +1 -1
- package/src/components/heading/heading.test.ts +79 -70
- package/src/components/heading/heading.ts +40 -78
- package/dist/async-directive-B9P1Qa0k.cjs +0 -1
- package/dist/class-map-CJ-msbHs.cjs +0 -1
- package/dist/directive-3THFsVew.js +0 -28
- package/dist/directive-CJ2giQBZ.cjs +0 -1
- package/dist/element-DjtxO-1r.cjs +0 -2
- package/dist/element-with-slot-CWoTGA1B.cjs +0 -1
- package/dist/heading-BxvE80bb.js +0 -73
- package/dist/heading-DRJTS27k.cjs +0 -1
- package/dist/icon-PbaC9uUg.cjs +0 -1
- package/dist/if-defined-XKOD_t_V.cjs +0 -1
- package/dist/linkcard-CupEMkvj.cjs +0 -13
- package/dist/progressbar-C0g830Tk.cjs +0 -17
- package/dist/ref-BaJ0mBT_.cjs +0 -1
- package/dist/repeat-DaDFvx86.cjs +0 -1
- package/dist/textarea-C7YiheLo.cjs +0 -46
- /package/dist/{booleanish-CRaKZ75t.js → booleanish-BmcOU-43.js} +0 -0
- /package/dist/{booleanish-B5EFqFpJ.cjs → booleanish-jJLlnr6-.cjs} +0 -0
- /package/dist/{classutils-z8YsPlOf.cjs → classutils-CVTzKF0J.cjs} +0 -0
- /package/dist/{classutils-DEL164Ur.js → classutils-lVbGcvjN.js} +0 -0
- /package/dist/{converters-Bffq_YDm.cjs → converters-C_66kHUN.cjs} +0 -0
- /package/dist/{converters-jauYkvNh.js → converters-DSQXaDQ_.js} +0 -0
- /package/dist/{dialog-polyfill.esm-B7W3teD0.js → dialog-polyfill.esm-0dVT8G1o.js} +0 -0
- /package/dist/{dialog-polyfill.esm-BnAQvMQO.cjs → dialog-polyfill.esm-CYs2AHP1.cjs} +0 -0
- /package/dist/{focus-modality-controller-pzSZkDkH.js → focus-modality-controller-CaUqYdk0.js} +0 -0
- /package/dist/{focus-modality-controller-BSZAQk8y.cjs → focus-modality-controller-wI5SR8wH.cjs} +0 -0
- /package/dist/{input-wrapper-CQGoyLdZ.cjs → input-wrapper-CYCCx8MP.cjs} +0 -0
- /package/dist/{input-wrapper-DwSsP39J.js → input-wrapper-kw2y6Jp_.js} +0 -0
- /package/dist/{utils-BOOZ0ppt.js → utils-CUqCKGvp.js} +0 -0
- /package/dist/{utils-CM67Oudc.cjs → utils-CjAbIttF.cjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);require(`./alert-NyLr62jZ.cjs`),require(`./icon-PbaC9uUg.cjs`);const n=require(`./if-defined-XKOD_t_V.cjs`),r=require(`./converters-Bffq_YDm.cjs`),i=require(`./utils-CM67Oudc.cjs`);require(`./input-wrapper-Y98KV-sy.cjs`),require(`./modal-CRzbtqL3.cjs`),require(`./progressbar-C0g830Tk.cjs`);var a={dropZoneDragMultiple:`Dra filer hit for å laste dem opp eller`,dropZoneDragSingle:`Dra en fil hit for å laste den opp eller`,dropZoneDragMultipleThumbnail:`Dra bilder hit for å laste dem opp eller`,dropZoneDragSingleThumbnail:`Dra et bilde hit for å laste det opp eller`,dropZoneDragActiveMultiple:`Slipp filene her`,dropZoneDragActiveSingle:`Slipp filen her`,dropZoneDragActiveMultipleThumbnail:`Slipp bildene her`,dropZoneDragActiveSingleThumbnail:`Slipp bildet her`,dropZoneOpenFileDialogMultiple:`velg filer`,dropZoneOpenFileDialogSingle:`velg en fil`,dropZoneOpenFileDialogMultipleThumbnail:`velg fra kamerarull`,dropZoneOpenFileDialogSingleThumbnail:`velg fra kamerarull`,supportedFormatsPrefix:`Format:`,invalidFormatDefault:e=>`Ugyldig filtype. Tillatte formater: ${e}`,sizeTooLargeDefault:e=>`Filen er for stor. Maks størrelse er ${e}.`,requiredMissing:`Du må laste opp minst én fil.`,genericValidationRejection:`Filen ble avvist av validering.`,unknownFilename:`Ukjent fil`,fileLabel:e=>e===1?`fil`:`filer`,srFileAdded:e=>`Filen «${e}» er lagt til`,srFilesAdded:e=>`${e} filer er lagt til`,srFilesUploadedOfTotal:(e,t,n)=>`${e} av ${t} ${n} lastet opp`,srFilesFailedOfTotal:(e,t,n)=>`Feil ved opplasting: ${e} av ${t} ${n} feilet`};function o(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 s(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${Math.round(e/(1024*1024))} MB`:`${Math.round(e/(1024*1024*1024))} GB`}function c(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function l(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function u(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 d(e,t){let n=c(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>u(e,r,i))}function f(e,t){let n=(e??``).trim();if(n)return n;let r=c(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function p(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function m(e,t){let n=c(e);if(n.length>0)return n.map(p).join(`, `);let r=l(t);return r.length>0?r.map(p).join(`, `):``}function h(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function g(e,t){let n=c(t.allowedFormats);if(n.length>0&&!d(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return h(t.formatErrorMessage,r,{formats:e})}let r=o(t.maxFileSize);if(r!==void 0&&e.size>r){let e=s(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return h(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function _(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 v(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function y(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[v(e.progress)]-r[v(t.progress)])}function b(e){if(!e)return[];let t=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);return Array.from(e.querySelectorAll(t)).filter(e=>!e.hasAttribute(`inert`))}function x(e,t){if(e.key!==`Tab`)return!1;let n=b(t);if(n.length===0)return e.preventDefault(),!0;let r=n[0],i=n[n.length-1],a=(t?.ownerDocument??document).activeElement,o=!!a&&n.includes(a);return e.shiftKey?!o||a===r?(e.preventDefault(),i.focus(),!0):!1:!o||a===i?(e.preventDefault(),r.focus(),!0):!1}function S(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function C(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function w(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 T(e,t=a.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var E=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,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.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.requiredSelectionMessage=a.requiredMissing,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 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`))&&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:i.n(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?a.srFileAdded(n[0].attributes.targetFilename):a.srFilesAdded(n.length));let r=this.getCurrentFiles(),o=this.multiple?[...r,...n]:[n[0]];this.commitFiles(o,`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 _(e)}formatFileSize(e){return s(e)}getResolvedAcceptValue(){return f(this.accept,this.allowedFormats)}getSupportedFormatsText(){return m(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return y(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=g(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?a.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}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesUploadedOfTotal(t,e,a.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesFailedOfTotal(t,e,a.fileLabel(e))}syncFormSubmitListener(){let e=this.closest(`form`);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.r([e.s({type:String})],E.prototype,`id`,void 0),e.r([e.s({type:String})],E.prototype,`name`,void 0),e.r([e.s({type:String})],E.prototype,`label`,void 0),e.r([e.s({type:String})],E.prototype,`helptext`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`required`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`multiple`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`disabled`,void 0),e.r([e.s({type:Boolean,reflect:!0,attribute:`fullwidth`})],E.prototype,`fullwidth`,void 0),e.r([e.s({type:String,reflect:!0,attribute:`upload-strategy`})],E.prototype,`uploadStrategy`,void 0),e.r([e.s({type:String,reflect:!0,attribute:`item-renderer`})],E.prototype,`itemRenderer`,void 0),e.r([e.s({type:String})],E.prototype,`accept`,void 0),e.r([e.s({converter:r.t.csvToArray,attribute:`allowed-formats`})],E.prototype,`allowedFormats`,void 0),e.r([e.s({type:String,attribute:`format-error-message`})],E.prototype,`formatErrorMessage`,void 0),e.r([e.s({attribute:`max-file-size`})],E.prototype,`maxFileSize`,void 0),e.r([e.s({type:String,attribute:`size-error-message`})],E.prototype,`sizeErrorMessage`,void 0),e.r([e.s({attribute:!1})],E.prototype,`onFileValidation`,void 0),e.r([e.s({attribute:!1})],E.prototype,`transfers`,void 0),e.r([e.s({type:Boolean,attribute:`add-comments-enabled`})],E.prototype,`addCommentsEnabled`,void 0),e.r([e.s({type:Boolean,attribute:`rename-files-enabled`})],E.prototype,`renameFilesEnabled`,void 0),e.r([e.s({attribute:!1})],E.prototype,`extraOperations`,void 0),e.r([e.s({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],E.prototype,`enableImagePreview`,void 0),e.r([e.s({type:Boolean,attribute:`has-error`})],E.prototype,`hasError`,void 0),e.r([e.s({type:String,attribute:`error-message`})],E.prototype,`errorMessage`,void 0),e.r([e.s({type:Boolean,attribute:`optional-tag`})],E.prototype,`optionalTag`,void 0),e.r([e.s({type:Boolean,attribute:`required-tag`})],E.prototype,`requiredTag`,void 0),e.r([e.s({type:Number,attribute:`truncate-tail`})],E.prototype,`truncateTail`,void 0),e.r([e.s({attribute:!1})],E.prototype,`value`,void 0),e.r([e.s({attribute:!1})],E.prototype,`defaultValue`,void 0),e.r([e.o()],E.prototype,`files`,void 0),e.r([e.o()],E.prototype,`isDragActive`,void 0),e.r([e.o()],E.prototype,`validationErrorMessage`,void 0),e.r([e.o()],E.prototype,`addedAnnouncement`,void 0),e.r([e.o()],E.prototype,`thumbnailUrls`,void 0);var D=`comments`,O=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`)}`},k=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},A=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},j=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),M=()=>({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.d`
|
|
1
|
+
const e=require(`./element-CXAtr6Gu.cjs`),t=require(`./class-map-B8Ja0q7n.cjs`);require(`./alert-D_45dWPn.cjs`),require(`./icon-Dw6I0HDV.cjs`);const n=require(`./if-defined-LTjAScFG.cjs`),r=require(`./converters-C_66kHUN.cjs`),i=require(`./utils-CjAbIttF.cjs`);require(`./input-wrapper-Dhkt20WW.cjs`),require(`./modal-CrYHKOmr.cjs`),require(`./progressbar-DADdvDl5.cjs`);var a={dropZoneDragMultiple:`Dra filer hit for å laste dem opp eller`,dropZoneDragSingle:`Dra en fil hit for å laste den opp eller`,dropZoneDragMultipleThumbnail:`Dra bilder hit for å laste dem opp eller`,dropZoneDragSingleThumbnail:`Dra et bilde hit for å laste det opp eller`,dropZoneDragActiveMultiple:`Slipp filene her`,dropZoneDragActiveSingle:`Slipp filen her`,dropZoneDragActiveMultipleThumbnail:`Slipp bildene her`,dropZoneDragActiveSingleThumbnail:`Slipp bildet her`,dropZoneOpenFileDialogMultiple:`velg filer`,dropZoneOpenFileDialogSingle:`velg en fil`,dropZoneOpenFileDialogMultipleThumbnail:`velg fra kamerarull`,dropZoneOpenFileDialogSingleThumbnail:`velg fra kamerarull`,supportedFormatsPrefix:`Format:`,invalidFormatDefault:e=>`Ugyldig filtype. Tillatte formater: ${e}`,sizeTooLargeDefault:e=>`Filen er for stor. Maks størrelse er ${e}.`,requiredMissing:`Du må laste opp minst én fil.`,genericValidationRejection:`Filen ble avvist av validering.`,unknownFilename:`Ukjent fil`,fileLabel:e=>e===1?`fil`:`filer`,srFileAdded:e=>`Filen «${e}» er lagt til`,srFilesAdded:e=>`${e} filer er lagt til`,srFilesUploadedOfTotal:(e,t,n)=>`${e} av ${t} ${n} lastet opp`,srFilesFailedOfTotal:(e,t,n)=>`Feil ved opplasting: ${e} av ${t} ${n} feilet`};function o(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 s(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${Math.round(e/(1024*1024))} MB`:`${Math.round(e/(1024*1024*1024))} GB`}function c(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function l(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function u(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 d(e,t){let n=c(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>u(e,r,i))}function f(e,t){let n=(e??``).trim();if(n)return n;let r=c(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function p(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function m(e,t){let n=c(e);if(n.length>0)return n.map(p).join(`, `);let r=l(t);return r.length>0?r.map(p).join(`, `):``}function h(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function g(e,t){let n=c(t.allowedFormats);if(n.length>0&&!d(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return h(t.formatErrorMessage,r,{formats:e})}let r=o(t.maxFileSize);if(r!==void 0&&e.size>r){let e=s(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return h(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function _(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 v(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function y(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[v(e.progress)]-r[v(t.progress)])}function b(e){if(!e)return[];let t=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);return Array.from(e.querySelectorAll(t)).filter(e=>!e.hasAttribute(`inert`))}function x(e,t){if(e.key!==`Tab`)return!1;let n=b(t);if(n.length===0)return e.preventDefault(),!0;let r=n[0],i=n[n.length-1],a=(t?.ownerDocument??document).activeElement,o=!!a&&n.includes(a);return e.shiftKey?!o||a===r?(e.preventDefault(),i.focus(),!0):!1:!o||a===i?(e.preventDefault(),r.focus(),!0):!1}function S(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function C(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function w(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 T(e,t=a.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var E=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,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.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.requiredSelectionMessage=a.requiredMissing,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 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`))&&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:i.n(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?a.srFileAdded(n[0].attributes.targetFilename):a.srFilesAdded(n.length));let r=this.getCurrentFiles(),o=this.multiple?[...r,...n]:[n[0]];this.commitFiles(o,`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 _(e)}formatFileSize(e){return s(e)}getResolvedAcceptValue(){return f(this.accept,this.allowedFormats)}getSupportedFormatsText(){return m(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return y(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=g(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?a.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}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesUploadedOfTotal(t,e,a.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesFailedOfTotal(t,e,a.fileLabel(e))}syncFormSubmitListener(){let e=this.closest(`form`);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.o({type:String})],E.prototype,`id`,void 0),e.n([e.o({type:String})],E.prototype,`name`,void 0),e.n([e.o({type:String})],E.prototype,`label`,void 0),e.n([e.o({type:String})],E.prototype,`helptext`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`required`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`multiple`,void 0),e.n([e.o({type:Boolean,reflect:!0})],E.prototype,`disabled`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`fullwidth`})],E.prototype,`fullwidth`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`upload-strategy`})],E.prototype,`uploadStrategy`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`item-renderer`})],E.prototype,`itemRenderer`,void 0),e.n([e.o({type:String})],E.prototype,`accept`,void 0),e.n([e.o({converter:r.t.csvToArray,attribute:`allowed-formats`})],E.prototype,`allowedFormats`,void 0),e.n([e.o({type:String,attribute:`format-error-message`})],E.prototype,`formatErrorMessage`,void 0),e.n([e.o({attribute:`max-file-size`})],E.prototype,`maxFileSize`,void 0),e.n([e.o({type:String,attribute:`size-error-message`})],E.prototype,`sizeErrorMessage`,void 0),e.n([e.o({attribute:!1})],E.prototype,`onFileValidation`,void 0),e.n([e.o({attribute:!1})],E.prototype,`transfers`,void 0),e.n([e.o({type:Boolean,attribute:`add-comments-enabled`})],E.prototype,`addCommentsEnabled`,void 0),e.n([e.o({type:Boolean,attribute:`rename-files-enabled`})],E.prototype,`renameFilesEnabled`,void 0),e.n([e.o({attribute:!1})],E.prototype,`extraOperations`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],E.prototype,`enableImagePreview`,void 0),e.n([e.o({type:Boolean,attribute:`has-error`})],E.prototype,`hasError`,void 0),e.n([e.o({type:String,attribute:`error-message`})],E.prototype,`errorMessage`,void 0),e.n([e.o({type:Boolean,attribute:`optional-tag`})],E.prototype,`optionalTag`,void 0),e.n([e.o({type:Boolean,attribute:`required-tag`})],E.prototype,`requiredTag`,void 0),e.n([e.o({type:Number,attribute:`truncate-tail`})],E.prototype,`truncateTail`,void 0),e.n([e.o({attribute:!1})],E.prototype,`value`,void 0),e.n([e.o({attribute:!1})],E.prototype,`defaultValue`,void 0),e.n([e.a()],E.prototype,`files`,void 0),e.n([e.a()],E.prototype,`isDragActive`,void 0),e.n([e.a()],E.prototype,`validationErrorMessage`,void 0),e.n([e.a()],E.prototype,`addedAnnouncement`,void 0),e.n([e.a()],E.prototype,`thumbnailUrls`,void 0);var D=`comments`,O=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`)}`},k=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},A=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},j=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),M=()=>({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.p`
|
|
2
2
|
<label for=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${r}
|
|
@@ -24,11 +24,11 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
24
24
|
>
|
|
25
25
|
Avbryt
|
|
26
26
|
</button>
|
|
27
|
-
`},renderHidden:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``;return e.
|
|
27
|
+
`},renderHidden:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``;return e.p`<input
|
|
28
28
|
type="hidden"
|
|
29
29
|
name=${`${t.inputName}-targetFilename`}
|
|
30
30
|
value=${n}
|
|
31
|
-
/>`}}),N=()=>({id:`comment`,title:e=>(e.attributes?.[D]??[]).length>0?``:`Legg til kommentar`,ariaLabel:`Legg til kommentar`,renderExtendedUI:t=>{let n=(t.getAttribute(D)??[])[0],r=`pkt-fileupload-comment-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(D,[{text:e,timestamp:new Date().toISOString()}]),t.close()};return e.
|
|
31
|
+
/>`}}),N=()=>({id:`comment`,title:e=>(e.attributes?.[D]??[]).length>0?``:`Legg til kommentar`,ariaLabel:`Legg til kommentar`,renderExtendedUI:t=>{let n=(t.getAttribute(D)??[])[0],r=`pkt-fileupload-comment-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(D,[{text:e,timestamp:new Date().toISOString()}]),t.close()};return e.p`
|
|
32
32
|
<label for=${r} class="pkt-fileupload__queue-display__item__comment-label">
|
|
33
33
|
${n?`Rediger kommentar`:`Legg til kommentar`}
|
|
34
34
|
</label>
|
|
@@ -57,7 +57,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
57
57
|
>
|
|
58
58
|
Avbryt
|
|
59
59
|
</button>
|
|
60
|
-
`},renderContent:t=>{if(t.isActive)return null;let n=t.getAttribute(D)??[];if(n.length===0)return null;let r=n[0];return e.
|
|
60
|
+
`},renderContent:t=>{if(t.isActive)return null;let n=t.getAttribute(D)??[];if(n.length===0)return null;let r=n[0];return e.p`
|
|
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">
|
|
@@ -90,11 +90,11 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
90
90
|
</div>
|
|
91
91
|
</div>
|
|
92
92
|
</div>
|
|
93
|
-
`},renderHidden:t=>{let n=t.getAttribute(D);return e.
|
|
93
|
+
`},renderHidden:t=>{let n=t.getAttribute(D);return e.p`<input
|
|
94
94
|
type="hidden"
|
|
95
95
|
name=${`${t.inputName}-comments`}
|
|
96
96
|
value=${n?JSON.stringify(n):``}
|
|
97
|
-
/>`}}),P=(t,n)=>{let r=S(t,n);return r?e.
|
|
97
|
+
/>`}}),P=(t,n)=>{let r=S(t,n);return r?e.p`<span
|
|
98
98
|
class="pkt-fileupload__queue-display__item__title__head"
|
|
99
99
|
data-pkt-truncate-part="first"
|
|
100
100
|
>${r.head}</span
|
|
@@ -102,13 +102,13 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
102
102
|
class="pkt-fileupload__queue-display__item__title__tail"
|
|
103
103
|
data-pkt-truncate-part="tail"
|
|
104
104
|
>${r.tail}</span
|
|
105
|
-
>`:e.
|
|
105
|
+
>`:e.p`<span data-pkt-truncate-part="first">${t}</span>`},F=(t,n,r)=>e.p`
|
|
106
106
|
<p class="pkt-fileupload__queue-display__item__title">
|
|
107
|
-
${P(t,r)}${n?e.
|
|
107
|
+
${P(t,r)}${n?e.p`<span class="pkt-fileupload__queue-display__item__filesize"> (${n})</span>`:null}
|
|
108
108
|
</p>
|
|
109
|
-
`,I=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,L=t=>e.
|
|
109
|
+
`,I=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,L=t=>e.p`<span class="pkt-fileupload__queue-display__item__loading-text" aria-label="Laster opp fil"
|
|
110
110
|
>${t??`Laster opp...`}</span
|
|
111
|
-
>`,R=({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)}),z=({file:t,fileSize:n,disabled:r,transferProgress:i,transferShowProgress:a,loadingText:o,truncateTail:s,onCancel:c,iconName:l=`document-text`})=>{let u=T(t),d=a??i!==0;return e.
|
|
111
|
+
>`,R=({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)}),z=({file:t,fileSize:n,disabled:r,transferProgress:i,transferShowProgress:a,loadingText:o,truncateTail:s,onCancel:c,iconName:l=`document-text`})=>{let u=T(t),d=a??i!==0;return e.p`
|
|
112
112
|
<pkt-icon
|
|
113
113
|
name=${l}
|
|
114
114
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -124,7 +124,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
124
124
|
>
|
|
125
125
|
Avbryt
|
|
126
126
|
</button>
|
|
127
|
-
${d?e.
|
|
127
|
+
${d?e.p`
|
|
128
128
|
<pkt-progressbar
|
|
129
129
|
class="pkt-fileupload__queue-display__item__progress"
|
|
130
130
|
valueCurrent=${Math.round(i*100)}
|
|
@@ -136,7 +136,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
136
136
|
>${Math.round(i*100)}%</span
|
|
137
137
|
>
|
|
138
138
|
`:L(o)}
|
|
139
|
-
`},B=({file:t,fileSize:n,disabled:r,transferShowProgress:i,transferLastProgress:a,transferErrorMessage:o,truncateTail:s,onCancel:c})=>{let l=T(t),u=!!i,d=Math.round((a??1)*100);return e.
|
|
139
|
+
`},B=({file:t,fileSize:n,disabled:r,transferShowProgress:i,transferLastProgress:a,transferErrorMessage:o,truncateTail:s,onCancel:c})=>{let l=T(t),u=!!i,d=Math.round((a??1)*100);return e.p`
|
|
140
140
|
<pkt-icon
|
|
141
141
|
name="alert-error"
|
|
142
142
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -152,7 +152,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
152
152
|
>
|
|
153
153
|
Fjern
|
|
154
154
|
</button>
|
|
155
|
-
${u?e.
|
|
155
|
+
${u?e.p`
|
|
156
156
|
<pkt-progressbar
|
|
157
157
|
class="pkt-fileupload__queue-display__item__progress pkt-fileupload__queue-display__item__progress--error"
|
|
158
158
|
valueCurrent=${d}
|
|
@@ -161,10 +161,10 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
161
161
|
statusPlacement="following"
|
|
162
162
|
></pkt-progressbar>
|
|
163
163
|
`:null}
|
|
164
|
-
${o?e.
|
|
164
|
+
${o?e.p`<span class="pkt-fileupload__queue-display__item__error-message"
|
|
165
165
|
>${o}</span
|
|
166
166
|
>`:null}
|
|
167
|
-
`},V=({file:t,disabled:r,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=R({operationId:a.id,file:t,inputName:i,disabled:r,isActive:a.id===o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u}),f=typeof a.title==`function`?a.title(t):a.title;return f?e.
|
|
167
|
+
`},V=({file:t,disabled:r,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=R({operationId:a.id,file:t,inputName:i,disabled:r,isActive:a.id===o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u}),f=typeof a.title==`function`?a.title(t):a.title;return f?e.p`<button
|
|
168
168
|
type="button"
|
|
169
169
|
class="pkt-fileupload__queue-display__item__operation"
|
|
170
170
|
aria-label=${n.t(typeof a.ariaLabel==`function`?a.ariaLabel(t):a.ariaLabel)}
|
|
@@ -172,18 +172,18 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
172
172
|
@click=${()=>{(a.renderInlineUI||a.renderExtendedUI)&&d.activate(),a.onClick?.(d)}}
|
|
173
173
|
>
|
|
174
174
|
${f}
|
|
175
|
-
</button>`:null}).filter(Boolean);return f.length===0?null:e.
|
|
175
|
+
</button>`:null}).filter(Boolean);return f.length===0?null:e.p`<div class="pkt-fileupload__queue-display__item__actions">${f}</div>`},H=({file:t,disabled:n,inputName:r,operations:i,activeOperationId:a,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l})=>i.map(i=>{if(!i.renderContent)return null;let u=R({operationId:i.id,file:t,inputName:r,disabled:n,isActive:i.id===a,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l}),d=i.renderContent(u);return d==null?null:e.p`<div class="pkt-fileupload__queue-display__item__operation-content">
|
|
176
176
|
${d}
|
|
177
|
-
</div>`}),U=({file:t,disabled:n,inputName:r,operations:i,activeOperationId:a,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l})=>{if(!a)return null;let u=i.find(e=>e.id===a);if(!u?.renderExtendedUI)return null;let d=R({operationId:u.id,file:t,inputName:r,disabled:n,isActive:!0,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l});return e.
|
|
177
|
+
</div>`}),U=({file:t,disabled:n,inputName:r,operations:i,activeOperationId:a,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l})=>{if(!a)return null;let u=i.find(e=>e.id===a);if(!u?.renderExtendedUI)return null;let d=R({operationId:u.id,file:t,inputName:r,disabled:n,isActive:!0,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l});return e.p`<div class="pkt-fileupload__queue-display__item__expanded-operation-ui">
|
|
178
178
|
${u.renderExtendedUI(d)}
|
|
179
|
-
</div>`},W=({file:e,disabled:t,inputName:n,operations:r,activeOperationId:i,onActivateOperation:a,onCloseOperation:o,getFileAttribute:s,setFileAttribute:c})=>r.map(r=>{if(!r.renderHidden)return null;let l=R({operationId:r.id,file:e,inputName:n,disabled:t,isActive:r.id===i,onActivateOperation:a,onCloseOperation:o,getFileAttribute:s,setFileAttribute:c});return r.renderHidden(l)}),G=(t,n,r)=>e.
|
|
179
|
+
</div>`},W=({file:e,disabled:t,inputName:n,operations:r,activeOperationId:i,onActivateOperation:a,onCloseOperation:o,getFileAttribute:s,setFileAttribute:c})=>r.map(r=>{if(!r.renderHidden)return null;let l=R({operationId:r.id,file:e,inputName:n,disabled:t,isActive:r.id===i,onActivateOperation:a,onCloseOperation:o,getFileAttribute:s,setFileAttribute:c});return r.renderHidden(l)}),G=(t,n,r)=>e.p`
|
|
180
180
|
<pkt-icon
|
|
181
181
|
name="document-text"
|
|
182
182
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
183
183
|
aria-hidden="true"
|
|
184
184
|
></pkt-icon>
|
|
185
185
|
${F(T(t),n,r)}
|
|
186
|
-
`,K=({file:r,thumbnailUrl:i,previewEnabled:a,canOpenPreview:o,truncateTail:s,onOpenPreview:c,onThumbnailImageError:l})=>{let u=T(r),d=!!i,f=!!a&&!!o,p=f&&!!c;return e.
|
|
186
|
+
`,K=({file:r,thumbnailUrl:i,previewEnabled:a,canOpenPreview:o,truncateTail:s,onOpenPreview:c,onThumbnailImageError:l})=>{let u=T(r),d=!!i,f=!!a&&!!o,p=f&&!!c;return e.p`
|
|
187
187
|
<div
|
|
188
188
|
class=${t.t({"pkt-fileupload__queue-display__item__thumbnail":!0,"pkt-fileupload__queue-display__item__thumbnail--fallback":!d})}
|
|
189
189
|
>
|
|
@@ -195,16 +195,16 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
195
195
|
@click=${()=>{!p||!c||c(r.fileId)}}
|
|
196
196
|
>
|
|
197
197
|
<span class="pkt-btn__text">
|
|
198
|
-
${f?e.
|
|
198
|
+
${f?e.p`<pkt-icon
|
|
199
199
|
name="expand"
|
|
200
200
|
class="pkt-fileupload__queue-display__item__thumbnail__expand-icon"
|
|
201
201
|
aria-hidden="true"
|
|
202
202
|
></pkt-icon>`:null}
|
|
203
|
-
${d?e.
|
|
203
|
+
${d?e.p`<img
|
|
204
204
|
src=${n.t(i)}
|
|
205
205
|
alt=${u}
|
|
206
206
|
@error=${()=>l?.(r.fileId)}
|
|
207
|
-
/>`:e.
|
|
207
|
+
/>`:e.p`<pkt-icon
|
|
208
208
|
name="document-text"
|
|
209
209
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
210
210
|
aria-hidden="true"
|
|
@@ -215,12 +215,12 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
215
215
|
>${P(u,s)}</span
|
|
216
216
|
>
|
|
217
217
|
</div>
|
|
218
|
-
`},q=({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,loadingText:g,truncateTail:_,onCancel:v})=>{let y=I(f),b=o.find(e=>e.id===s),x=b?.renderInlineUI?b.renderInlineUI(R({operationId:b.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})):null;return e.
|
|
218
|
+
`},q=({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,loadingText:g,truncateTail:_,onCancel:v})=>{let y=I(f),b=o.find(e=>e.id===s),x=b?.renderInlineUI?b.renderInlineUI(R({operationId:b.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})):null;return e.p`
|
|
219
219
|
<li
|
|
220
220
|
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
221
|
>
|
|
222
222
|
${W({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})}
|
|
223
|
-
${y===`in-progress`?z({file:n,fileSize:a,disabled:i,transferProgress:f,transferShowProgress:m,loadingText:g,truncateTail:_,onCancel:v}):y===`error`?B({file:n,fileSize:a,disabled:i,transferShowProgress:m,transferLastProgress:h,transferErrorMessage:p,truncateTail:_,onCancel:v}):x?e.
|
|
223
|
+
${y===`in-progress`?z({file:n,fileSize:a,disabled:i,transferProgress:f,transferShowProgress:m,loadingText:g,truncateTail:_,onCancel:v}):y===`error`?B({file:n,fileSize:a,disabled:i,transferShowProgress:m,transferLastProgress:h,transferErrorMessage:p,truncateTail:_,onCancel:v}):x?e.p`
|
|
224
224
|
<pkt-icon
|
|
225
225
|
name="document-text"
|
|
226
226
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -234,12 +234,12 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
234
234
|
${y===`idle`?H({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
235
235
|
${y===`idle`?U({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
236
236
|
</li>
|
|
237
|
-
`},J=({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,loadingText:y,truncateTail:b,onCancel:x,onOpenPreview:S,onThumbnailImageError:C})=>{let w=I(h),T=l.find(e=>e.id===u),E=T?.renderInlineUI?T.renderInlineUI(R({operationId:T.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})):null;return e.
|
|
237
|
+
`},J=({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,loadingText:y,truncateTail:b,onCancel:x,onOpenPreview:S,onThumbnailImageError:C})=>{let w=I(h),T=l.find(e=>e.id===u),E=T?.renderInlineUI?T.renderInlineUI(R({operationId:T.id,file:n,inputName:r,disabled:i,isActive:!0,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})):null;return e.p`
|
|
238
238
|
<li
|
|
239
239
|
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
240
|
>
|
|
241
241
|
${W({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})}
|
|
242
|
-
${w===`in-progress`?z({file:n,fileSize:a,disabled:i,transferProgress:h,transferShowProgress:_,loadingText:y,truncateTail:b,onCancel:x,iconName:`picture`}):w===`error`?B({file:n,fileSize:a,disabled:i,transferShowProgress:_,transferLastProgress:v,transferErrorMessage:g,truncateTail:b,onCancel:x}):E?e.
|
|
242
|
+
${w===`in-progress`?z({file:n,fileSize:a,disabled:i,transferProgress:h,transferShowProgress:_,loadingText:y,truncateTail:b,onCancel:x,iconName:`picture`}):w===`error`?B({file:n,fileSize:a,disabled:i,transferShowProgress:_,transferLastProgress:v,transferErrorMessage:g,truncateTail:b,onCancel:x}):E?e.p`
|
|
243
243
|
<pkt-icon
|
|
244
244
|
name="picture"
|
|
245
245
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
@@ -253,7 +253,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
253
253
|
${w===`idle`?H({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
254
254
|
${w===`idle`?U({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
255
255
|
</li>
|
|
256
|
-
`},Y=class extends E{constructor(...e){super(...e),this.activeOperationByFileId={},this.isPreviewModalOpen=!1,this.previewCurrentIndex=0,this.failedImageFileIds={},this.closePreview=()=>{this.isPreviewModalOpen=!1},this.onPreviewKeyDown=(e,t)=>{if(this.isPreviewModalOpen){if(e.key===`Tab`){x(e,e.currentTarget);return}switch(e.key){case`ArrowLeft`:e.preventDefault(),this.navigatePreview(`prev`,t);break;case`ArrowRight`:e.preventDefault(),this.navigatePreview(`next`,t);break;case`Escape`:e.preventDefault(),this.closePreview();break;default:break}}}}render(){let n=this.renderContent();return this.label?e.
|
|
256
|
+
`},Y=class extends E{constructor(...e){super(...e),this.activeOperationByFileId={},this.isPreviewModalOpen=!1,this.previewCurrentIndex=0,this.failedImageFileIds={},this.closePreview=()=>{this.isPreviewModalOpen=!1},this.onPreviewKeyDown=(e,t)=>{if(this.isPreviewModalOpen){if(e.key===`Tab`){x(e,e.currentTarget);return}switch(e.key){case`ArrowLeft`:e.preventDefault(),this.navigatePreview(`prev`,t);break;case`ArrowRight`:e.preventDefault(),this.navigatePreview(`next`,t);break;case`Escape`:e.preventDefault(),this.closePreview();break;default:break}}}}render(){let n=this.renderContent();return this.label?e.p`
|
|
257
257
|
<pkt-input-wrapper
|
|
258
258
|
.forId=${`${this.id}-input`}
|
|
259
259
|
.label=${this.label}
|
|
@@ -266,7 +266,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
266
266
|
>
|
|
267
267
|
${n}
|
|
268
268
|
</pkt-input-wrapper>
|
|
269
|
-
`:n}renderContent(){let r=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(r),o=this.getSupportedFormatsText(),s=[!this.label&&this.helptext?`${this.id}-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.
|
|
269
|
+
`:n}renderContent(){let r=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(r),o=this.getSupportedFormatsText(),s=[!this.label&&this.helptext?`${this.id}-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.p`
|
|
270
270
|
<div
|
|
271
271
|
class=${t.t({"pkt-fileupload":!0,"pkt-fileupload--full-width":this.fullwidth,"pkt-fileupload--error":this.hasEffectiveError,"pkt-fileupload--disabled":this.disabled})}
|
|
272
272
|
aria-disabled=${String(this.disabled)}
|
|
@@ -299,7 +299,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
299
299
|
aria-describedby=${n.t(s)}
|
|
300
300
|
@change=${this.onNativeFileChange}
|
|
301
301
|
/>
|
|
302
|
-
${this.uploadStrategy===`custom`?r.map(t=>e.
|
|
302
|
+
${this.uploadStrategy===`custom`?r.map(t=>e.p`<input type="hidden" name=${this.name} value=${t.fileId} />`):null}
|
|
303
303
|
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
304
304
|
<pkt-icon
|
|
305
305
|
name="attachment"
|
|
@@ -307,7 +307,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
307
307
|
aria-hidden="true"
|
|
308
308
|
></pkt-icon>
|
|
309
309
|
<p class="pkt-fileupload__drop-zone__placeholder__title">
|
|
310
|
-
${this.isDragActive?`${c.dragActive} ...`:e.
|
|
310
|
+
${this.isDragActive?`${c.dragActive} ...`:e.p`${c.dragInactive}
|
|
311
311
|
<button
|
|
312
312
|
type="button"
|
|
313
313
|
class="pkt-fileupload__drop-zone__placeholder__title__open-file-dialog"
|
|
@@ -316,12 +316,12 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
316
316
|
${c.openFileDialog}
|
|
317
317
|
</button>`}
|
|
318
318
|
</p>
|
|
319
|
-
${o?e.
|
|
319
|
+
${o?e.p`<p class="pkt-fileupload__drop-zone__placeholder__formats">
|
|
320
320
|
${a.supportedFormatsPrefix} ${o}
|
|
321
321
|
</p>`:null}
|
|
322
322
|
</div>
|
|
323
323
|
</div>
|
|
324
|
-
${this.hasEffectiveError?e.
|
|
324
|
+
${this.hasEffectiveError?e.p`
|
|
325
325
|
<pkt-alert
|
|
326
326
|
skin="error"
|
|
327
327
|
role="alert"
|
|
@@ -333,12 +333,12 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
333
333
|
${this.effectiveErrorMessage}
|
|
334
334
|
</pkt-alert>
|
|
335
335
|
`:null}
|
|
336
|
-
${r.length>0?e.
|
|
336
|
+
${r.length>0?e.p`<ul class="pkt-fileupload__queue-display">
|
|
337
337
|
${r.map(e=>this.renderQueueItem(e,i))}
|
|
338
338
|
</ul>`:null}
|
|
339
339
|
${this.renderPreviewModal(i)}
|
|
340
340
|
</div>
|
|
341
|
-
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations();if(this.itemRenderer===`thumbnail`){let i=this.canOpenPreview(e),a=this.failedImageFileIds[e.fileId]?.thumbnail?void 0:this.getThumbnailUrl(e);return J({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:a,previewEnabled:this.enableImagePreview,canOpenPreview:i,transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e),onOpenPreview:e=>this.openPreview(e,t),onThumbnailImageError:e=>this.markImageFailed(e,`thumbnail`)})}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),transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,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=C(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let n=t[this.previewCurrentIndex];if(!n)return null;let r=t.length>1,i=this.getThumbnailUrl(n),a=!!i&&!this.failedImageFileIds[n.fileId]?.preview,o=n.attributes?.targetFilename||n.file?.name||`Forhåndsvisning`;return e.
|
|
341
|
+
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations();if(this.itemRenderer===`thumbnail`){let i=this.canOpenPreview(e),a=this.failedImageFileIds[e.fileId]?.thumbnail?void 0:this.getThumbnailUrl(e);return J({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:a,previewEnabled:this.enableImagePreview,canOpenPreview:i,transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e),onOpenPreview:e=>this.openPreview(e,t),onThumbnailImageError:e=>this.markImageFailed(e,`thumbnail`)})}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),transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,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=C(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let n=t[this.previewCurrentIndex];if(!n)return null;let r=t.length>1,i=this.getThumbnailUrl(n),a=!!i&&!this.failedImageFileIds[n.fileId]?.preview,o=n.attributes?.targetFilename||n.file?.name||`Forhåndsvisning`;return e.p`
|
|
342
342
|
<pkt-modal
|
|
343
343
|
.open=${this.isPreviewModalOpen}
|
|
344
344
|
.headingText=${o}
|
|
@@ -348,7 +348,7 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
348
348
|
@keydown=${e=>this.onPreviewKeyDown(e,t)}
|
|
349
349
|
>
|
|
350
350
|
<div class="pkt-fileupload__image-preview">
|
|
351
|
-
${r?e.
|
|
351
|
+
${r?e.p`<button
|
|
352
352
|
type="button"
|
|
353
353
|
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--prev pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
354
354
|
aria-label=${`Forrige bilde ${this.previewCurrentIndex} / ${t.length}`}
|
|
@@ -363,22 +363,22 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
363
363
|
</button>`:null}
|
|
364
364
|
|
|
365
365
|
<div class="pkt-fileupload__image-preview__content">
|
|
366
|
-
${a?e.
|
|
366
|
+
${a?e.p`<img
|
|
367
367
|
src=${i}
|
|
368
368
|
alt=${`${o} - ${this.previewCurrentIndex+1} av ${t.length}`}
|
|
369
369
|
class="pkt-fileupload__image-preview__image"
|
|
370
370
|
@error=${()=>this.markImageFailed(n.fileId,`preview`)}
|
|
371
|
-
/>`:e.
|
|
371
|
+
/>`:e.p`<pkt-icon
|
|
372
372
|
name="picture"
|
|
373
373
|
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
374
374
|
aria-hidden="true"
|
|
375
375
|
></pkt-icon>`}
|
|
376
376
|
</div>
|
|
377
377
|
|
|
378
|
-
${r?e.
|
|
378
|
+
${r?e.p`<span class="pkt-fileupload__image-preview__counter">
|
|
379
379
|
${this.previewCurrentIndex+1} / ${t.length}
|
|
380
380
|
</span>`:null}
|
|
381
|
-
${r?e.
|
|
381
|
+
${r?e.p`<button
|
|
382
382
|
type="button"
|
|
383
383
|
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--next pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
384
384
|
aria-label=${`Neste bilde ${this.previewCurrentIndex+2} / ${t.length}`}
|
|
@@ -393,4 +393,4 @@ const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);
|
|
|
393
393
|
</button>`:null}
|
|
394
394
|
</div>
|
|
395
395
|
</pkt-modal>
|
|
396
|
-
`}getQueueItemOperations(){let e=[];return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(M()),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(N()),e.push(...this.extraOperations),e.push(j(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.
|
|
396
|
+
`}getQueueItemOperations(){let e=[];return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(M()),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(N()),e.push(...this.extraOperations),e.push(j(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.a()],Y.prototype,`activeOperationByFileId`,void 0),e.n([e.a()],Y.prototype,`isPreviewModalOpen`,void 0),e.n([e.a()],Y.prototype,`previewCurrentIndex`,void 0),e.n([e.a()],Y.prototype,`failedImageFileIds`,void 0),Y=e.n([e.s(`pkt-fileupload`)],Y);var X=Y;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return X}});
|