@oslokommune/punkt-elements 17.1.3 → 18.1.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 +35 -0
- package/dist/{accordion-BeLvLPrB.js → accordion-CcUosZjL.js} +27 -27
- package/dist/{accordion-B3GBlvUC.cjs → accordion-k0pWTG1X.cjs} +5 -5
- package/dist/alert-BD8YVKia.cjs +35 -0
- package/dist/{alert-DKK_Tb9J.js → alert-Bmaly2Yo.js} +57 -52
- package/dist/{async-directive-BPf6K-V2.js → async-directive-COqx0IYj.js} +5 -5
- package/dist/{async-directive-Da7TJpnq.cjs → async-directive-DN2eg9gA.cjs} +1 -1
- package/dist/{backlink-D1y26pj3.js → backlink-C_ZO-ZbR.js} +9 -9
- package/dist/{backlink-CMmrKTe4.cjs → backlink-Ch64Pivx.cjs} +3 -3
- package/dist/base-elements/element.d.ts +13 -1
- package/dist/base-elements/input-element.d.ts +4 -2
- package/dist/{breadcrumbs-CcTQ3Grm.js → breadcrumbs-CF_gAbUk.js} +16 -16
- package/dist/{breadcrumbs-B6JGhJgC.cjs → breadcrumbs-CzzbardP.cjs} +7 -7
- package/dist/{button-2-OSPJkj.js → button-C1CQSASU.js} +28 -28
- package/dist/{button-CE97NQIk.cjs → button-CF3dNKeI.cjs} +7 -7
- package/dist/{calendar-kn4SrtJy.cjs → calendar-BxF81kB9.cjs} +28 -27
- package/dist/{calendar-pOW3R5Pw.js → calendar-DRmxORMc.js} +82 -68
- package/dist/{card-CETDFkxR.cjs → card-Cg1daj05.cjs} +26 -26
- package/dist/{card-zQ0eKRMV.js → card-W_Jb0Tlo.js} +44 -44
- package/dist/{checkbox-CQNr_sEg.cjs → checkbox-BHQv8lHq.cjs} +11 -11
- package/dist/{checkbox-CH7NpINF.js → checkbox-BQw2dMSX.js} +23 -23
- package/dist/{class-map-BeimMvPv.cjs → class-map-C33ixq7O.cjs} +1 -1
- package/dist/{class-map-CnWCnBSX.js → class-map-wh4Yi3oj.js} +3 -3
- package/dist/{combobox-Bvg0UO9w.cjs → combobox-BpZow9OU.cjs} +19 -18
- package/dist/{combobox-CRdYYlxu.js → combobox-C9wwnUfM.js} +55 -54
- package/dist/components/accordion/accordion.d.ts +2 -6
- package/dist/components/accordion/accordionitem.d.ts +2 -8
- package/dist/components/alert/alert.d.ts +2 -2
- package/dist/components/backlink/backlink.d.ts +4 -5
- package/dist/components/backlink/backlink.test.d.ts +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +6 -7
- package/dist/components/breadcrumbs/index.d.ts +1 -1
- package/dist/components/calendar/calendar.d.ts +21 -6
- package/dist/components/checkbox/checkbox.d.ts +4 -2
- package/dist/components/combobox/combobox-base.d.ts +2 -1
- package/dist/components/consent/strings.d.ts +1 -85
- package/dist/components/datepicker/datepicker-base.d.ts +0 -3
- package/dist/components/datepicker/datepicker-multiple.d.ts +0 -2
- package/dist/components/datepicker/datepicker-range.d.ts +0 -2
- package/dist/components/datepicker/datepicker-single.d.ts +0 -2
- package/dist/components/datepicker/datepicker-utils.d.ts +2 -1
- package/dist/components/fileupload/fileupload-base.d.ts +7 -4
- package/dist/components/fileupload/fileupload-types.d.ts +5 -43
- package/dist/components/header/header-service.d.ts +3 -1
- package/dist/components/header/header.d.ts +2 -1
- package/dist/components/helptext/helptext.d.ts +2 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/input-wrapper/input-wrapper.d.ts +4 -2
- package/dist/components/radiobutton/radiobutton.d.ts +4 -2
- package/dist/components/searchinput/searchinput.d.ts +2 -1
- package/dist/{consent-CyY3RyoC.cjs → consent-CPtr7cBw.cjs} +5 -5
- package/dist/{consent-DZEkhgJ1.js → consent-D8MrqGKk.js} +10 -10
- package/dist/controllers/strings-controller.d.ts +27 -0
- package/dist/{datepicker-ButIas85.js → datepicker-D4YnAtWG.js} +104 -104
- package/dist/{datepicker-VTqSDQk5.cjs → datepicker-DaoumZT9.cjs} +38 -37
- package/dist/define-component-spec-BYOSeplU.js +6 -0
- package/dist/define-component-spec-DBNd2FJY.cjs +1 -0
- package/dist/{directive-helpers-CI8YZqku.js → directive-helpers-BWSAVe00.js} +1 -1
- package/dist/{directive-helpers-BlAV5EQD.cjs → directive-helpers-C6J4AkFk.cjs} +1 -1
- package/dist/docs/components/alert.d.ts +2 -3
- package/dist/docs/components/fileupload.d.ts +1 -0
- package/dist/element-DiFhBcIl.cjs +2 -0
- package/dist/{element-ChsFgr_B.js → element-WEzISABa.js} +241 -100
- package/dist/{element-with-slot-BvG9ctC-.js → element-with-slot-BKYUx4gb.js} +4 -4
- package/dist/{element-with-slot-Bj7nm7fO.cjs → element-with-slot-CBK4zrdN.cjs} +1 -1
- package/dist/{fileupload-D5IQ9HDe.js → fileupload-DEHSETw0.js} +340 -652
- package/dist/fileupload-DWu6FIMv.cjs +402 -0
- package/dist/{footer-DrR64HiK.js → footer-BJLEw6Ab.js} +91 -91
- package/dist/{footer-DbYQUYNR.cjs → footer-D_yYWkQ6.cjs} +32 -32
- package/dist/format-B8meU8Tm.cjs +1 -0
- package/dist/format-BTeSVkED.js +18 -0
- package/dist/{header-ClgIac6n.cjs → header-B7_4Cwaq.cjs} +84 -84
- package/dist/{header-KvJ1mGwA.js → header-DLVq7-dM.js} +267 -264
- package/dist/{header-menu-hVPXsb8g.js → header-menu-BsrrTjpT.js} +75 -75
- package/dist/{header-menu-BAsUNKSx.cjs → header-menu-m7nOOC1g.cjs} +24 -24
- package/dist/{heading-g-_IUB5T.js → heading-DSArgrDK.js} +16 -16
- package/dist/{heading-CFmiSuCQ.cjs → heading-_RPw2UW9.cjs} +1 -1
- package/dist/helptext-QMVsW5g6.cjs +27 -0
- package/dist/{helptext-DZng1D5i.js → helptext-dtVVufNH.js} +18 -19
- package/dist/{icon-D-LA22xD.js → icon-DEtOSWRK.js} +17 -17
- package/dist/{icon-9iwd2F2l.cjs → icon-DIavy2cB.cjs} +1 -1
- package/dist/{if-defined-CGzIlZ9-.js → if-defined-BmnvvxtR.js} +1 -1
- package/dist/if-defined-Dc3xFDaM.cjs +1 -0
- package/dist/input-element-DQY1Rpbp.cjs +1 -0
- package/dist/{input-element-DBMNBplu.js → input-element-IBypGOaV.js} +121 -120
- package/dist/input-wrapper-CQgAL1Br.js +308 -0
- package/dist/input-wrapper-mJZLVXy_.cjs +58 -0
- package/dist/link-DwLeY37f.js +131 -0
- package/dist/link-yk4IXDWm.cjs +7 -0
- package/dist/linkcard-BinKnxQF.cjs +13 -0
- package/dist/{linkcard-zqbg7Oqm.js → linkcard-D5DXpmXI.js} +16 -16
- package/dist/{listbox-Dc4rGdPi.cjs → listbox-C5zTRNAO.cjs} +15 -15
- package/dist/{listbox-va_E8afs.js → listbox-C8ooO8qZ.js} +100 -99
- package/dist/{loader-D_RDICnw.js → loader-C3HyayzL.js} +14 -14
- package/dist/{loader-CMUkVJmE.cjs → loader-DHF7M5Vn.cjs} +5 -5
- package/dist/{messagebox-Cv8LaSxv.cjs → messagebox-DqYf6VmQ.cjs} +5 -5
- package/dist/{messagebox-Cw-OWDya.js → messagebox-u8i3R5QA.js} +15 -15
- package/dist/{modal-BtInv031.cjs → modal-CnJ9y2TQ.cjs} +8 -8
- package/dist/{modal-D0t_X2dX.js → modal-V-jEe0aY.js} +20 -20
- 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 -34
- 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-C5EBX2T0.cjs → pkt-options-controller-BhMNCWcc.cjs} +1 -1
- package/dist/{pkt-options-controller-B77vH3PE.js → pkt-options-controller-CuQ6SClv.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-CbcfLerF.js → progressbar-DS4i8IWq.js} +21 -21
- package/dist/{progressbar-D5MmnQId.cjs → progressbar-DY5hxImR.cjs} +5 -5
- package/dist/{radiobutton-BUnf3EPi.js → radiobutton-BhvZztMZ.js} +24 -24
- package/dist/{radiobutton-DpsO1F-8.cjs → radiobutton-BswqwRnA.cjs} +8 -8
- package/dist/{ref-CQoEIIp0.cjs → ref-DZmN5Qgj.cjs} +1 -1
- package/dist/{ref-CWD6PjVd.js → ref-OU8ryfP6.js} +2 -2
- package/dist/{repeat-sY6B7fAT.cjs → repeat-DIa_g6WL.cjs} +1 -1
- package/dist/{repeat-C02g7d5S.js → repeat-Dx2H127b.js} +4 -4
- package/dist/{searchinput-DwnjsvJ1.js → searchinput-CJo1PpM7.js} +43 -43
- package/dist/searchinput-Cl46nW0r.cjs +60 -0
- package/dist/{select-DMre80qs.js → select-CBrjauXT.js} +21 -20
- package/dist/{select-BOJi6H6T.cjs → select-Dman8Skr.cjs} +4 -3
- package/dist/shared-strings/consent.d.ts +71 -0
- package/dist/shared-strings/format.d.ts +21 -0
- package/dist/shared-strings/index.d.ts +14 -0
- package/dist/shared-strings/nb.d.ts +121 -0
- package/dist/shared-strings/resolve.d.ts +12 -0
- package/dist/shared-strings/store.d.ts +27 -0
- package/dist/shared-strings/types.d.ts +40 -0
- package/dist/shared-types/accordion.d.ts +58 -0
- package/dist/shared-types/alert.d.ts +20 -0
- package/dist/shared-types/aria.d.ts +2 -1
- package/dist/shared-types/backlink.d.ts +23 -0
- package/dist/shared-types/breadcrumbs.d.ts +33 -0
- package/dist/shared-types/fileupload.d.ts +55 -28
- package/dist/shared-types/footer.d.ts +10 -0
- package/dist/shared-types/form-field.d.ts +45 -0
- package/dist/shared-types/header-footer.d.ts +2 -0
- package/dist/shared-types/index.d.ts +15 -6
- package/dist/shared-types/render-link.d.ts +22 -0
- package/dist/shared-types/skin.d.ts +2 -9
- package/dist/shared-utils/combobox/index.d.ts +1 -0
- package/dist/shared-utils/combobox/input-utils.d.ts +2 -1
- package/dist/shared-utils/combobox/messages.d.ts +7 -0
- package/dist/shared-utils/combobox/option-utils.d.ts +2 -1
- package/dist/shared-utils/combobox/selection-manager.d.ts +3 -2
- package/dist/{tabs-Cf9ai0FD.cjs → tabs-C1m5rSrR.cjs} +7 -7
- package/dist/{tabs-TvxgbrCF.js → tabs-Xu3mIedh.js} +32 -32
- package/dist/{tag-Ds6n1LIs.js → tag-Azkjhkeu.js} +33 -32
- package/dist/tag-BS6dDPxY.cjs +27 -0
- package/dist/tests/strings-override.test.d.ts +0 -0
- package/dist/{textarea-vfzIcXhX.js → textarea-D4qXcVGD.js} +30 -29
- package/dist/{textarea-BydiLM9Z.cjs → textarea-DftUkR6w.cjs} +3 -2
- package/dist/{textinput-DGdicNSx.cjs → textinput-Ar-1Sbqy.cjs} +13 -12
- package/dist/{textinput-CMP2jPP_.js → textinput-iCgwwNPU.js} +28 -27
- package/dist/{timepicker-ClwgYywH.js → timepicker-W6HVWtmA.js} +67 -64
- package/dist/timepicker-dpAF7h49.cjs +196 -0
- package/package.json +3 -3
- package/src/components/accordion/accordion.ts +2 -10
- package/src/components/accordion/accordionitem.ts +2 -9
- package/src/components/alert/alert.ts +19 -10
- package/src/components/backlink/backlink.test.ts +3 -3
- package/src/components/backlink/backlink.ts +5 -7
- package/src/components/breadcrumbs/breadcrumbs.ts +9 -10
- package/src/components/breadcrumbs/index.ts +1 -1
- package/src/components/calendar/calendar.ts +56 -26
- package/src/components/checkbox/checkbox.test.ts +0 -2
- package/src/components/checkbox/checkbox.ts +8 -4
- package/src/components/combobox/combobox-base.ts +2 -1
- package/src/components/combobox/combobox-value.ts +10 -9
- package/src/components/combobox/combobox.selection.test.ts +5 -1
- package/src/components/combobox/combobox.ts +4 -1
- package/src/components/consent/strings.ts +1 -125
- package/src/components/datepicker/date-tags.ts +4 -1
- package/src/components/datepicker/datepicker-base.ts +2 -6
- package/src/components/datepicker/datepicker-multiple.ts +0 -3
- package/src/components/datepicker/datepicker-range.ts +4 -7
- package/src/components/datepicker/datepicker-single.ts +0 -3
- package/src/components/datepicker/datepicker-utils.test.ts +5 -5
- package/src/components/datepicker/datepicker-utils.ts +6 -11
- package/src/components/datepicker/datepicker.ts +8 -1
- package/src/components/fileupload/fileupload-base.ts +29 -19
- package/src/components/fileupload/fileupload-renderers.ts +2 -1
- package/src/components/fileupload/fileupload-types.ts +5 -42
- package/src/components/fileupload/fileupload.test.ts +16 -0
- package/src/components/fileupload/fileupload.ts +19 -15
- package/src/components/header/header-global.ts +3 -3
- package/src/components/header/header-service.ts +13 -8
- package/src/components/header/header.ts +2 -1
- package/src/components/helptext/helptext.test.ts +1 -1
- package/src/components/helptext/helptext.ts +3 -3
- package/src/components/index.ts +10 -1
- package/src/components/input-wrapper/input-wrapper.ts +18 -10
- package/src/components/link/link.ts +8 -3
- package/src/components/listbox/listbox.ts +3 -3
- package/src/components/radiobutton/radiobutton.ts +8 -4
- package/src/components/searchinput/searchinput.ts +5 -3
- package/src/components/select/select.ts +1 -0
- package/src/components/tag/tag.ts +2 -1
- package/src/components/textarea/textarea.ts +1 -0
- package/src/components/textinput/textinput.ts +1 -0
- package/src/components/timepicker/timepicker.ts +23 -21
- package/dist/alert-Cs4Rmq_J.cjs +0 -33
- package/dist/element-BA8v6S7z.cjs +0 -2
- package/dist/fileupload-BeWiTAoW.cjs +0 -401
- package/dist/helptext-CTtKJcML.cjs +0 -27
- package/dist/if-defined-B89_ZeCj.cjs +0 -1
- package/dist/input-element-DYmQw-fH.cjs +0 -1
- package/dist/input-wrapper-BmxNvznr.js +0 -128
- package/dist/input-wrapper-D-fPaTbY.js +0 -176
- package/dist/input-wrapper-D5PR0rJn.cjs +0 -1
- package/dist/input-wrapper-Q-B-aBeb.cjs +0 -54
- package/dist/link-D-Eqm5KH.js +0 -98
- package/dist/link-DK7gvmnj.cjs +0 -7
- package/dist/linkcard-B29cmZqh.cjs +0 -13
- package/dist/searchinput-Bh975rjX.cjs +0 -60
- package/dist/tag-CzojNU7z.cjs +0 -27
- package/dist/timepicker-DYrnLHqN.cjs +0 -195
- package/dist/translations/no.json.d.ts +0 -94
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
const e=require("./element-DiFhBcIl.cjs"),t=require("./class-map-C33ixq7O.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-BD8YVKia.cjs"),require("./icon-DIavy2cB.cjs");const r=require("./if-defined-Dc3xFDaM.cjs"),i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-mJZLVXy_.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-CnJ9y2TQ.cjs"),require("./progressbar-DY5hxImR.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`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}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.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})],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=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
|
+
<input
|
|
4
|
+
id=${r}
|
|
5
|
+
type="text"
|
|
6
|
+
class="pkt-fileupload__queue-display__item__rename-input"
|
|
7
|
+
?disabled=${t.disabled}
|
|
8
|
+
.value=${n}
|
|
9
|
+
@keydown=${e=>O(e,i,t.close)}
|
|
10
|
+
/>
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
14
|
+
?disabled=${t.disabled}
|
|
15
|
+
@click=${i}
|
|
16
|
+
>
|
|
17
|
+
Lagre
|
|
18
|
+
</button>
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
22
|
+
?disabled=${t.disabled}
|
|
23
|
+
@click=${t.close}
|
|
24
|
+
>
|
|
25
|
+
Avbryt
|
|
26
|
+
</button>
|
|
27
|
+
`},renderHidden:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``;return e._`<input
|
|
28
|
+
type="hidden"
|
|
29
|
+
name=${`${t.inputName}-targetFilename`}
|
|
30
|
+
value=${n}
|
|
31
|
+
/>`}}),M=()=>({id:`comment`,title:e=>(e.attributes?.[E]??[]).length>0?``:`Legg til kommentar`,ariaLabel:`Legg til kommentar`,renderExtendedUI:t=>{let n=(t.getAttribute(E)??[])[0],r=`pkt-fileupload-comment-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(E,[{text:e,timestamp:new Date().toISOString()}]),t.close()};return e._`
|
|
32
|
+
<label for=${r} class="pkt-fileupload__queue-display__item__comment-label">
|
|
33
|
+
${n?`Rediger kommentar`:`Legg til kommentar`}
|
|
34
|
+
</label>
|
|
35
|
+
<textarea
|
|
36
|
+
id=${r}
|
|
37
|
+
class="pkt-fileupload__queue-display__item__comment-input"
|
|
38
|
+
?disabled=${t.disabled}
|
|
39
|
+
.value=${n?.text??``}
|
|
40
|
+
rows="2"
|
|
41
|
+
placeholder="Skriv inn kommentar"
|
|
42
|
+
@keydown=${e=>k(e,i,t.close)}
|
|
43
|
+
></textarea>
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
47
|
+
?disabled=${t.disabled}
|
|
48
|
+
@click=${i}
|
|
49
|
+
>
|
|
50
|
+
${n?`Lagre kommentar`:`Legg til kommentar`}
|
|
51
|
+
</button>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
55
|
+
?disabled=${t.disabled}
|
|
56
|
+
@click=${t.close}
|
|
57
|
+
>
|
|
58
|
+
Avbryt
|
|
59
|
+
</button>
|
|
60
|
+
`},renderContent:t=>{if(t.isActive)return null;let n=t.getAttribute(E)??[];if(n.length===0)return null;let r=n[0];return e._`
|
|
61
|
+
<div class="pkt-fileupload__queue-display__item__comments">
|
|
62
|
+
<div class="pkt-fileupload__queue-display__item__comment">
|
|
63
|
+
<div class="pkt-fileupload__queue-display__item__comment__content">
|
|
64
|
+
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label="Kommentar tekst">
|
|
65
|
+
${r.text}
|
|
66
|
+
</span>
|
|
67
|
+
<time class="pkt-fileupload__queue-display__item__comment__time">
|
|
68
|
+
${D(r.timestamp)}
|
|
69
|
+
</time>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="pkt-fileupload__queue-display__item__comment__actions">
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
class="pkt-fileupload__queue-display__item__comment__action"
|
|
75
|
+
aria-label="Rediger kommentar"
|
|
76
|
+
?disabled=${t.disabled}
|
|
77
|
+
@click=${t.activate}
|
|
78
|
+
>
|
|
79
|
+
<pkt-icon name="edit"></pkt-icon>
|
|
80
|
+
</button>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="pkt-fileupload__queue-display__item__comment__action"
|
|
84
|
+
aria-label="Slett kommentar"
|
|
85
|
+
?disabled=${t.disabled}
|
|
86
|
+
@click=${()=>t.setAttribute(E,void 0)}
|
|
87
|
+
>
|
|
88
|
+
<pkt-icon name="trash-can"></pkt-icon>
|
|
89
|
+
</button>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
`},renderHidden:t=>{let n=t.getAttribute(E);return e._`<input
|
|
94
|
+
type="hidden"
|
|
95
|
+
name=${`${t.inputName}-comments`}
|
|
96
|
+
value=${n?JSON.stringify(n):``}
|
|
97
|
+
/>`}}),N=(t,n)=>{let r=x(t,n);return r?e._`<span
|
|
98
|
+
class="pkt-fileupload__queue-display__item__title__head"
|
|
99
|
+
data-pkt-truncate-part="first"
|
|
100
|
+
>${r.head}</span
|
|
101
|
+
><span
|
|
102
|
+
class="pkt-fileupload__queue-display__item__title__tail"
|
|
103
|
+
data-pkt-truncate-part="tail"
|
|
104
|
+
>${r.tail}</span
|
|
105
|
+
>`:e._`<span data-pkt-truncate-part="first">${t}</span>`},P=(t,n,r)=>e._`
|
|
106
|
+
<p class="pkt-fileupload__queue-display__item__title">
|
|
107
|
+
${N(t,r)}${n?e._`<span class="pkt-fileupload__queue-display__item__filesize"> (${n})</span>`:null}
|
|
108
|
+
</p>
|
|
109
|
+
`,F=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,I=t=>e._`<span class="pkt-fileupload__queue-display__item__loading-text" aria-label="Laster opp fil"
|
|
110
|
+
>${t??`Laster opp...`}</span
|
|
111
|
+
>`,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,loadingText:o,truncateTail:s,onCancel:c,iconName:l=`document-text`})=>{let u=w(t),d=a??i!==0;return e._`
|
|
112
|
+
<pkt-icon
|
|
113
|
+
name=${l}
|
|
114
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
115
|
+
aria-hidden="true"
|
|
116
|
+
></pkt-icon>
|
|
117
|
+
${P(u,n,s)}
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
121
|
+
aria-label="Avbryt opplasting"
|
|
122
|
+
?disabled=${r}
|
|
123
|
+
@click=${()=>c(t.fileId)}
|
|
124
|
+
>
|
|
125
|
+
Avbryt
|
|
126
|
+
</button>
|
|
127
|
+
${d?e._`
|
|
128
|
+
<pkt-progressbar
|
|
129
|
+
class="pkt-fileupload__queue-display__item__progress"
|
|
130
|
+
valueCurrent=${Math.round(i*100)}
|
|
131
|
+
valueMax=${100}
|
|
132
|
+
statusType="none"
|
|
133
|
+
statusPlacement="following"
|
|
134
|
+
></pkt-progressbar>
|
|
135
|
+
<span class="pkt-fileupload__queue-display__item__percentage" aria-hidden="true"
|
|
136
|
+
>${Math.round(i*100)}%</span
|
|
137
|
+
>
|
|
138
|
+
`:I(o)}
|
|
139
|
+
`},z=({file:t,fileSize:n,disabled:r,transferShowProgress:i,transferLastProgress:a,transferErrorMessage:o,truncateTail:s,onCancel:c})=>{let l=w(t),u=!!i,d=Math.round((a??1)*100);return e._`
|
|
140
|
+
<pkt-icon
|
|
141
|
+
name="alert-error"
|
|
142
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
></pkt-icon>
|
|
145
|
+
${P(l,n,s)}
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
149
|
+
aria-label="Fjern fil som feilet under opplasting"
|
|
150
|
+
?disabled=${r}
|
|
151
|
+
@click=${()=>c(t.fileId)}
|
|
152
|
+
>
|
|
153
|
+
Fjern
|
|
154
|
+
</button>
|
|
155
|
+
${u?e._`
|
|
156
|
+
<pkt-progressbar
|
|
157
|
+
class="pkt-fileupload__queue-display__item__progress pkt-fileupload__queue-display__item__progress--error"
|
|
158
|
+
valueCurrent=${d}
|
|
159
|
+
valueMax=${100}
|
|
160
|
+
statusType="none"
|
|
161
|
+
statusPlacement="following"
|
|
162
|
+
></pkt-progressbar>
|
|
163
|
+
`:null}
|
|
164
|
+
${o?e._`<span class="pkt-fileupload__queue-display__item__error-message"
|
|
165
|
+
>${o}</span
|
|
166
|
+
>`:null}
|
|
167
|
+
`},B=({file:t,disabled:n,inputName:i,operations:a,activeOperationId:o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u})=>{let d=a.find(e=>e.id===o);if(d?.renderInlineUI||d?.renderExtendedUI)return null;let f=a.map(a=>{let d=L({operationId:a.id,file:t,inputName:i,disabled:n,isActive:a.id===o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u}),f=typeof a.title==`function`?a.title(t):a.title;if(!f)return null;let p=typeof a.ariaLabel==`function`?a.ariaLabel(t):a.ariaLabel;return e._`<button
|
|
168
|
+
type="button"
|
|
169
|
+
class="pkt-fileupload__queue-display__item__operation"
|
|
170
|
+
aria-label=${r.t(p)}
|
|
171
|
+
?disabled=${n}
|
|
172
|
+
@click=${()=>{(a.renderInlineUI||a.renderExtendedUI)&&d.activate(),a.onClick?.(d)}}
|
|
173
|
+
>
|
|
174
|
+
${f}
|
|
175
|
+
</button>`}).filter(Boolean);return f.length===0?null:e._`<div class="pkt-fileupload__queue-display__item__actions">${f}</div>`},V=({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=L({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._`<div class="pkt-fileupload__queue-display__item__operation-content">
|
|
176
|
+
${d}
|
|
177
|
+
</div>`}),H=({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=L({operationId:u.id,file:t,inputName:r,disabled:n,isActive:!0,onActivateOperation:o,onCloseOperation:s,getFileAttribute:c,setFileAttribute:l});return e._`<div class="pkt-fileupload__queue-display__item__expanded-operation-ui">
|
|
178
|
+
${u.renderExtendedUI(d)}
|
|
179
|
+
</div>`},U=({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=L({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)}),W=(t,n,r)=>{let i=w(t);return e._`
|
|
180
|
+
<pkt-icon
|
|
181
|
+
name="document-text"
|
|
182
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
183
|
+
aria-hidden="true"
|
|
184
|
+
></pkt-icon>
|
|
185
|
+
${P(i,n,r)}
|
|
186
|
+
`},G=({file:i,thumbnailUrl:a,previewEnabled:o,canOpenPreview:s,truncateTail:c,onOpenPreview:l,onThumbnailImageError:u})=>{let d=w(i),f=!!a,p=!!o&&!!s,m=p&&!!l;return e._`
|
|
187
|
+
<div
|
|
188
|
+
class=${t.t({"pkt-fileupload__queue-display__item__thumbnail":!0,"pkt-fileupload__queue-display__item__thumbnail--fallback":!f})}
|
|
189
|
+
>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
193
|
+
aria-label=${n.t(e.s.fileupload.previewImage,{filename:d})}
|
|
194
|
+
?disabled=${!m}
|
|
195
|
+
@click=${()=>{!m||!l||l(i.fileId)}}
|
|
196
|
+
>
|
|
197
|
+
<span class="pkt-btn__text">
|
|
198
|
+
${p?e._`<pkt-icon
|
|
199
|
+
name="expand"
|
|
200
|
+
class="pkt-fileupload__queue-display__item__thumbnail__expand-icon"
|
|
201
|
+
aria-hidden="true"
|
|
202
|
+
></pkt-icon>`:null}
|
|
203
|
+
${f?e._`<img
|
|
204
|
+
src=${r.t(a)}
|
|
205
|
+
alt=${d}
|
|
206
|
+
@error=${()=>u?.(i.fileId)}
|
|
207
|
+
/>`:e._`<pkt-icon
|
|
208
|
+
name="document-text"
|
|
209
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
210
|
+
aria-hidden="true"
|
|
211
|
+
></pkt-icon>`}
|
|
212
|
+
</span>
|
|
213
|
+
</button>
|
|
214
|
+
<span class="pkt-fileupload__queue-display__item__thumbnail__title"
|
|
215
|
+
>${N(d,c)}</span
|
|
216
|
+
>
|
|
217
|
+
</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,loadingText: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
|
+
<li
|
|
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
|
+
>
|
|
222
|
+
${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,loadingText:g,truncateTail:_,onCancel:v}):y===`error`?z({file:n,fileSize:a,disabled:i,transferShowProgress:m,transferLastProgress:h,transferErrorMessage:p,truncateTail:_,onCancel:v}):x?e._`
|
|
224
|
+
<pkt-icon
|
|
225
|
+
name="document-text"
|
|
226
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
227
|
+
aria-hidden="true"
|
|
228
|
+
></pkt-icon>
|
|
229
|
+
<div class="pkt-fileupload__queue-display__item__inline-ui">
|
|
230
|
+
${x}
|
|
231
|
+
</div>
|
|
232
|
+
`:W(n,a,_)}
|
|
233
|
+
${y===`idle`?B({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
234
|
+
${y===`idle`?V({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
235
|
+
${y===`idle`?H({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
236
|
+
</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,loadingText: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
|
+
<li
|
|
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
|
+
>
|
|
241
|
+
${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:_,loadingText:y,truncateTail:b,onCancel:x,iconName:`picture`}):w===`error`?z({file:n,fileSize:a,disabled:i,transferShowProgress:_,transferLastProgress:v,transferErrorMessage:g,truncateTail:b,onCancel:x}):E?e._`
|
|
243
|
+
<pkt-icon
|
|
244
|
+
name="picture"
|
|
245
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
246
|
+
aria-hidden="true"
|
|
247
|
+
></pkt-icon>
|
|
248
|
+
<div class="pkt-fileupload__queue-display__item__inline-ui">
|
|
249
|
+
${E}
|
|
250
|
+
</div>
|
|
251
|
+
`:G({file:n,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,truncateTail:b,onOpenPreview:S,onThumbnailImageError:C})}
|
|
252
|
+
${w===`idle`?B({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
253
|
+
${w===`idle`?V({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
254
|
+
${w===`idle`?H({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
255
|
+
</li>
|
|
256
|
+
`},J=class extends T{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`){o.r(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()}}}}updated(e){super.updated(e),this.classList.add(`pkt-fileupload-component`)}render(){let n=this.renderContent();return this.label?e._`
|
|
257
|
+
<pkt-input-wrapper
|
|
258
|
+
.strings=${this.strings}
|
|
259
|
+
.forId=${`${this.id}-input`}
|
|
260
|
+
.label=${this.label}
|
|
261
|
+
.helptext=${this.helptext}
|
|
262
|
+
.helptextDropdown=${this.helptextDropdown}
|
|
263
|
+
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
264
|
+
?disabled=${this.disabled}
|
|
265
|
+
?hasError=${this.hasEffectiveError}
|
|
266
|
+
?optionalTag=${this.optionalTag}
|
|
267
|
+
.optionalText=${this.optionalText}
|
|
268
|
+
?requiredTag=${this.requiredTag}
|
|
269
|
+
.requiredText=${this.requiredText}
|
|
270
|
+
.tagText=${this.tagText}
|
|
271
|
+
class=${t.t({"pkt-fileupload-wrapper":!0,"pkt-fileupload-wrapper--full-width":this.fullwidth})}
|
|
272
|
+
>
|
|
273
|
+
${n}
|
|
274
|
+
</pkt-input-wrapper>
|
|
275
|
+
`:n}renderContent(){let n=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(n),a=this.pktStrings.get(`fileupload`),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._`
|
|
276
|
+
<div
|
|
277
|
+
class=${t.t({"pkt-fileupload":!0,"pkt-fileupload--full-width":this.fullwidth,"pkt-fileupload--error":this.hasEffectiveError,"pkt-fileupload--disabled":this.disabled})}
|
|
278
|
+
aria-disabled=${String(this.disabled)}
|
|
279
|
+
?inert=${this.disabled}
|
|
280
|
+
>
|
|
281
|
+
<div class="pkt-sr-only" aria-live="polite" aria-atomic="true">
|
|
282
|
+
${this.getSrUploadedMessage()}
|
|
283
|
+
</div>
|
|
284
|
+
<div class="pkt-sr-only" aria-live="assertive" aria-atomic="true">
|
|
285
|
+
${this.getSrErrorsMessage()}
|
|
286
|
+
</div>
|
|
287
|
+
<div
|
|
288
|
+
class=${t.t({"pkt-fileupload__drop-zone":!0,"pkt-fileupload__drop-zone--drag-active":this.isDragActive,"pkt-fileupload__drop-zone--disabled":this.disabled})}
|
|
289
|
+
@dragover=${this.onDragOver}
|
|
290
|
+
@dragleave=${this.onDragLeave}
|
|
291
|
+
@drop=${this.onDrop}
|
|
292
|
+
@click=${this.onDropZoneClick}
|
|
293
|
+
>
|
|
294
|
+
<input
|
|
295
|
+
id=${`${this.id}-input`}
|
|
296
|
+
type="file"
|
|
297
|
+
name=${r.t(this.uploadStrategy===`form`?this.name:void 0)}
|
|
298
|
+
?multiple=${this.multiple}
|
|
299
|
+
?disabled=${this.disabled}
|
|
300
|
+
?required=${this.required&&this.uploadStrategy===`form`}
|
|
301
|
+
accept=${this.getResolvedAcceptValue()}
|
|
302
|
+
aria-label=${r.t(this.label?void 0:this.multiple?`Velg filer`:`Velg fil`)}
|
|
303
|
+
aria-required=${r.t(this.required?`true`:void 0)}
|
|
304
|
+
aria-invalid=${r.t(this.hasEffectiveError?`true`:void 0)}
|
|
305
|
+
aria-describedby=${r.t(s)}
|
|
306
|
+
@change=${this.onNativeFileChange}
|
|
307
|
+
/>
|
|
308
|
+
${this.uploadStrategy===`custom`?n.map(t=>e._`<input type="hidden" name=${this.name} value=${t.fileId} />`):null}
|
|
309
|
+
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
310
|
+
<pkt-icon
|
|
311
|
+
name="attachment"
|
|
312
|
+
class="pkt-fileupload__drop-zone__placeholder__icon"
|
|
313
|
+
aria-hidden="true"
|
|
314
|
+
></pkt-icon>
|
|
315
|
+
<p class="pkt-fileupload__drop-zone__placeholder__title">
|
|
316
|
+
${this.isDragActive?`${c.dragActive} ...`:e._`${c.dragInactive}
|
|
317
|
+
<button
|
|
318
|
+
type="button"
|
|
319
|
+
class="pkt-fileupload__drop-zone__placeholder__title__open-file-dialog"
|
|
320
|
+
@click=${this.openFileDialog}
|
|
321
|
+
>
|
|
322
|
+
${c.openFileDialog}
|
|
323
|
+
</button>`}
|
|
324
|
+
</p>
|
|
325
|
+
${o?e._`<p class="pkt-fileupload__drop-zone__placeholder__formats">
|
|
326
|
+
${a.supportedFormatsPrefix} ${o}
|
|
327
|
+
</p>`:null}
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
${this.hasEffectiveError?e._`
|
|
331
|
+
<pkt-alert
|
|
332
|
+
skin="error"
|
|
333
|
+
role="alert"
|
|
334
|
+
aria-live="assertive"
|
|
335
|
+
compact
|
|
336
|
+
id=${`${this.id}-error`}
|
|
337
|
+
class="pkt-alert--error pkt-fileupload__error-alert"
|
|
338
|
+
>
|
|
339
|
+
${this.effectiveErrorMessage}
|
|
340
|
+
</pkt-alert>
|
|
341
|
+
`:null}
|
|
342
|
+
${n.length>0?e._`<ul class="pkt-fileupload__queue-display">
|
|
343
|
+
${n.map(e=>this.renderQueueItem(e,i))}
|
|
344
|
+
</ul>`:null}
|
|
345
|
+
${this.renderPreviewModal(i)}
|
|
346
|
+
</div>
|
|
347
|
+
`}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 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: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 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,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=S(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let n=this.pktStrings.get(`fileupload`),r=t[this.previewCurrentIndex];if(!r)return null;let i=t.length>1,a=this.getThumbnailUrl(r),o=!!a&&!this.failedImageFileIds[r.fileId]?.preview,s=r.attributes?.targetFilename||r.file?.name||n.previewFallbackName;return e._`
|
|
348
|
+
<pkt-modal
|
|
349
|
+
.open=${this.isPreviewModalOpen}
|
|
350
|
+
.headingText=${s}
|
|
351
|
+
closeOnBackdropClick
|
|
352
|
+
class="pkt-fileupload__image-preview-modal"
|
|
353
|
+
@close=${this.closePreview}
|
|
354
|
+
@keydown=${e=>this.onPreviewKeyDown(e,t)}
|
|
355
|
+
>
|
|
356
|
+
<div class="pkt-fileupload__image-preview">
|
|
357
|
+
${i?e._`<button
|
|
358
|
+
type="button"
|
|
359
|
+
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--prev pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
360
|
+
aria-label=${`Forrige bilde ${this.previewCurrentIndex} / ${t.length}`}
|
|
361
|
+
@click=${()=>this.navigatePreview(`prev`,t)}
|
|
362
|
+
>
|
|
363
|
+
<pkt-icon
|
|
364
|
+
class="pkt-btn__icon pkt-icon"
|
|
365
|
+
name="chevron-thin-left"
|
|
366
|
+
aria-hidden="true"
|
|
367
|
+
></pkt-icon>
|
|
368
|
+
<span class="pkt-btn__text"></span>
|
|
369
|
+
</button>`:null}
|
|
370
|
+
|
|
371
|
+
<div class="pkt-fileupload__image-preview__content">
|
|
372
|
+
${o?e._`<img
|
|
373
|
+
src=${a}
|
|
374
|
+
alt=${`${s} - ${this.previewCurrentIndex+1} av ${t.length}`}
|
|
375
|
+
class="pkt-fileupload__image-preview__image"
|
|
376
|
+
@error=${()=>this.markImageFailed(r.fileId,`preview`)}
|
|
377
|
+
/>`:e._`<pkt-icon
|
|
378
|
+
name="picture"
|
|
379
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
380
|
+
aria-hidden="true"
|
|
381
|
+
></pkt-icon>`}
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
${i?e._`<span class="pkt-fileupload__image-preview__counter">
|
|
385
|
+
${this.previewCurrentIndex+1} / ${t.length}
|
|
386
|
+
</span>`:null}
|
|
387
|
+
${i?e._`<button
|
|
388
|
+
type="button"
|
|
389
|
+
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--next pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
390
|
+
aria-label=${`Neste bilde ${this.previewCurrentIndex+2} / ${t.length}`}
|
|
391
|
+
@click=${()=>this.navigatePreview(`next`,t)}
|
|
392
|
+
>
|
|
393
|
+
<pkt-icon
|
|
394
|
+
class="pkt-btn__icon pkt-icon"
|
|
395
|
+
name="chevron-thin-right"
|
|
396
|
+
aria-hidden="true"
|
|
397
|
+
></pkt-icon>
|
|
398
|
+
<span class="pkt-btn__text"></span>
|
|
399
|
+
</button>`:null}
|
|
400
|
+
</div>
|
|
401
|
+
</pkt-modal>
|
|
402
|
+
`}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}});
|