@oslokommune/punkt-elements 16.26.4 → 16.26.6

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{combobox-B9YSsRZB.js → combobox-1xG07Oce.js} +2 -2
  3. package/dist/{combobox-BhIqExJZ.cjs → combobox-BjBNyEly.cjs} +1 -1
  4. package/dist/components/fileupload/fileupload-base.d.ts +10 -0
  5. package/dist/components/fileupload/fileupload-types.d.ts +10 -0
  6. package/dist/docs/components/select.d.ts +3 -0
  7. package/dist/{fileupload-DpvQ3e_T.js → fileupload-2hf8YNhO.js} +414 -92
  8. package/dist/{fileupload-BMHJaAKR.cjs → fileupload-BLVrslUX.cjs} +42 -37
  9. package/dist/pkt-combobox.cjs +1 -1
  10. package/dist/pkt-combobox.js +1 -1
  11. package/dist/pkt-fileupload.cjs +1 -1
  12. package/dist/pkt-fileupload.js +1 -1
  13. package/dist/pkt-index.cjs +1 -1
  14. package/dist/pkt-index.js +3 -3
  15. package/dist/pkt-options-controller-CPrfqepu.cjs +1 -0
  16. package/dist/{pkt-options-controller-Cis62vGe.js → pkt-options-controller-DMxYwnnj.js} +32 -9
  17. package/dist/pkt-select.cjs +1 -1
  18. package/dist/pkt-select.js +1 -1
  19. package/dist/{select-BVPcJEIz.cjs → select-C3Q_bGZb.cjs} +1 -1
  20. package/dist/{select-C1--vTZ2.js → select-YyR17Ml6.js} +1 -1
  21. package/package.json +2 -2
  22. package/src/components/combobox/combobox.selection.test.ts +51 -0
  23. package/src/components/combobox/combobox.ts +3 -0
  24. package/src/components/fileupload/fileupload-base.ts +14 -0
  25. package/src/components/fileupload/fileupload-types.ts +10 -0
  26. package/src/components/fileupload/fileupload.test.ts +35 -0
  27. package/src/components/fileupload/fileupload.ts +5 -0
  28. package/src/components/select/select.test.ts +73 -3
  29. package/dist/pkt-options-controller-DHKHMyXM.cjs +0 -1
@@ -1,4 +1,4 @@
1
- const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");require("./alert-B8dLsiTz.cjs"),require("./icon-B8PVq2O6.cjs");const n=require("./if-defined-DrwbxQOj.cjs"),r=require("./converters-9jHlXDyy.cjs"),i=require("./utils-63cRpWut.cjs");require("./input-wrapper-BRjQB4zM.cjs"),require("./modal-DKU7PnjJ.cjs"),require("./progressbar-BN5y20CC.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`
1
+ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");require("./alert-B8dLsiTz.cjs"),require("./icon-B8PVq2O6.cjs");const n=require("./if-defined-DrwbxQOj.cjs"),r=require("./converters-9jHlXDyy.cjs"),i=require("./utils-63cRpWut.cjs");require("./input-wrapper-BRjQB4zM.cjs"),require("./modal-DKU7PnjJ.cjs"),require("./progressbar-BN5y20CC.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={name:`pkt-fileupload`,react:`PktFileUpload`,"css-class":`pkt-fileupload`,isElement:!1,isPureReact:!0,"dark-mode":!0,props:{name:{type:`string`,name:`Navn for innsending`,category:`tech`,required:!0},label:{type:`string`,name:`Etikett`,description:`Etikett/tittel over komponenten`,category:`form`},helptext:{type:`string | ReactNode`,name:`Hjelpetekst`,description:`Hjelpetekst under etiketten`,category:`form`},helptextDropdown:{type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{type:`string`,name:`Knappetekst for utvidet hjelpetekst`,default:`Les mer`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:"Gjør feltet obligatorisk. I `uploadStrategy='form'` brukes native validering på file input. I `uploadStrategy='custom'` valideres kravet ved submit og komponenten viser feilmelding hvis ingen filer er valgt.",default:!1,category:`form`},value:{type:`FileItemList`,name:`Fil-liste (controlled)`,description:`Liste over filer i komponenten. Bruk denne for controlled-modus.`,category:`form`},defaultValue:{type:`FileItem[]`,name:`Default-verdi (uncontrolled)`,description:"Default-verdi når komponenten brukes 'uncontrolled'. Ingen grunn til at denne ikke skal være tom array `[]`",category:`form`},onFilesChanged:{type:`(files: FileItem[]) => void`,name:`Callback ved fil-endring`,description:`Kalles når fil(er) legges til, fjernes eller oppdateres`,category:`tech`},uploadStrategy:{name:`Opplastingstype`,type:[`form`,`custom`],values:{form:`form (når filer lastes opp ved submit)`,custom:`custom (når filer lastes opp via webappens egen logikk)`},description:"Velg mellom skjemaopplasting (filene sendes når skjemaet sendes inn) og bakgrunnsopplasting (webappen håndterer opplasting via `onFileUploadRequested` og oppdaterer `transfers`).",default:`form`,category:`functionality`},multiple:{type:`boolean`,name:`Tillat opplasting av flere filer`,default:!1,category:`functionality`},itemRenderer:{type:[`filename`,`thumbnail`],name:`Visningtype av filer`,description:`Hvordan filer skal vises i opplastings-køen. Enten filnavn eller som thumbnails. Du kan også (eksperimentelt) lage din egen komponent.`,default:`filename`,category:`functionality`},optionalTag:{type:`boolean`,name:`Vis 'Valgfritt'-tag`,description:`Vis 'Valgfritt'-tag ved etiketten`,category:`form`},optionalText:{type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,default:`Valgfritt`,category:`contents`},requiredTag:{type:`boolean`,name:`Vis 'Må fylles ut'-tag`,description:`Vis 'Må fylles ut'-tag ved etiketten`,category:`form`},requiredText:{type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,default:`Må fylles ut`,category:`contents`},tagText:{type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Deaktiverer hele komponenten - ingen interaksjon mulig`,default:!1,category:`form`},errorMessage:{type:`string`,name:`Feilmelding`,description:`Feilmelding for å vise under komponenten (ekstern/programmatisk feil)`,default:`Det oppstod en feil ved opplastingen av fil(ene).`,category:`form`},hasError:{type:`boolean`,name:`Har feil`,description:`Om komponenten har en feiltilstand`,default:!1,category:`form`},allowedFormats:{type:`string[]`,name:`Tillatte filformater`,description:`Liste over tillatte filformater. F.eks. ['pdf', 'jpg', 'png'] eller ['image/*', 'application/pdf']`,category:`validation`},formatErrorMessage:{type:`string`,name:`Feilmelding for ugyldig format`,description:`Tilpasset feilmelding ved ugyldig filtype.`,category:`validation`},maxFileSize:{type:`string | number`,name:`Maks filstørrelse`,description:`Maksimal filstørrelse. F.eks. '5MB', '500KB', '1GB' eller antall bytes`,category:`validation`},onFileValidation:{type:`(file: File) => string | null`,name:`Egendefinert validering`,description:`Kjører etter innebygd format/størrelse-validering. Returner feilmeldingsstreng hvis ugyldig, null hvis gyldig.`,category:`validation`},sizeErrorMessage:{type:`string`,name:`Feilmelding for stor fil`,description:`Tilpasset feilmelding ved for stor fil.`,category:`validation`},addCommentsEnabled:{type:`boolean`,name:`Tillat kommentarer`,description:"La brukeren skrive en kommentar pr fil. Kommentarene postes i felter med navn `{fileupload-navn}-comment`",default:!1,showIf:{itemRenderer:`filename`},category:`functionality`},enableImagePreview:{type:`boolean`,name:`Forhåndsvisning av bilder`,description:`Aktiver forhåndsvisning av bilder i modal (kun for thumbnail-visning)`,default:!1,showIf:{itemRenderer:`thumbnail`},category:`functionality`},extraOperations:{type:`Array<QueueItemOperation>`,name:`Ekstra operasjoner`,description:"Ekstra operasjoner pr fil (eksperimentelt). Hver operasjon er et objekt med stabil `id`, `title` og valgfrie `onClick`/`renderInlineUI`/`renderExtendedUI`/`renderContent`/`renderHidden`. Callbacks får et `context`-objekt med file, disabled, isActive, activate, close, getAttribute og setAttribute.",category:`functionality`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Om komponenten skal ta full bredde av foreldreelementet`,default:!1,category:`styling`},onFileUploadRequested:{type:`(fileItem: FileItem) => void`,name:`Callback for opplastingsforespørsel`,description:`Ved <code>uploadStrategy='custom'</code> blir denne funksjonen kalt når brukeren velger en eller flere filer. Dette lar webappen sette i gang opplasting i bakgrunnen.`,relatedTypes:[`FileItem`],category:`functionality`},onTransferCancelled:{type:`(fileItemId: string) => void`,name:`Callback for avbrutt opplasting`,description:`Kalles når brukeren klikker 'Slett' eller 'Avbryt'. Webappen må dermed avbryte opplastingen av denne fila.`,category:`functionality`},renameFilesEnabled:{type:`boolean`,name:`Tillat å gi nytt navn`,description:"La brukeren angi et navn pr fil. Filnavnene postes i felter med navn `{fileupload-navn}-targetFilename`",default:!1,showIf:{itemRenderer:`filename`},category:`functionality`},transfers:{type:`Array<FileTransfer>`,name:`Pågående filoverføringer`,description:`Ved <code>uploadStrategy='custom'</code> vil du fortelle komponenten om pågående overføringer her. Hver fil har en progress-verdi.`,items:{type:`object`,elementType:`FileTransfer`,ref:`FileTransfer`},category:`functionality`},truncateTail:{type:`number`,name:`Forkort filnavn`,description:"Hvordan lange filnavn skal forkortes med ellipse i køen. Med `4` vil filnavnet vises som `langt-filnavn-med ... .pdf`. Med verdi `0` kommer ellipsen til slutt.",category:`functionality`},previewUploadIntervalMs:{type:`number`,name:`Demo: opplastingshastighet (ms/5%)`,description:"Kun for dokumentasjons-forhåndsvisning. Senker simulert opplasting for å demonstrere statusvisning. Gjelder kun i `uploadStrategy='custom'`.",default:100,showIf:{uploadStrategy:`custom`},category:`demo`},previewSimulateUploadError:{type:`boolean`,name:`Demo: simuler feil ved 90% opplasting`,description:`Kun for dokumentasjons-forhåndsvisning. Hvis aktivert feiler simulert opplasting rundt 90%.`,default:!1,showIf:{uploadStrategy:`custom`},category:`demo`},previewUploadStatus:{type:[`progressbar`,`text`],name:`Visning av opplastingstatus`,description:"Kun for dokumentasjons-forhåndsvisning. Vises kun når `uploadStrategy='custom'`. Status vises først etter at brukeren faktisk har valgt fil(er).",default:`progressbar`,showIf:{uploadStrategy:`custom`},category:`demo`}},types:{FileItem:{description:`En valgt fil i køen. <code>FileItemList</code> er en array av <code>FileItem</code>. Brukes som parameter i callbacks som <code>onFileUploadRequested</code> og i <code>FileItemList</code> (<code>value</code> / <code>defaultValue</code>).`,properties:{fileId:{type:`string`,description:`Unik id for filen i komponenten.`},file:{type:`File`,description:`Fil-objektet fra nettleseren.`},attributes:{type:`Record<string, unknown>`,description:`Metadata per fil (f.eks. <code>targetFilename</code> for visningsnavn).`}}},FileTransfer:{description:`Status for én pågående opplasting når <code>uploadStrategy="custom"</code>.`,properties:{fileId:{type:`string`,description:`Kobler til <code>FileItem.fileId</code>.`},progress:{type:`number | 'done' | 'error' | 'canceled' | 'queued'`,description:`Fremdrift (<code>0..1</code>) eller tilstand.`},errorMessage:{type:`string`,description:`Feilmelding ved <code>error</code>.`,required:!1},showProgress:{type:`boolean`,description:`Vis determinate progress vs. «Laster opp…».`,required:!1}}}}},D=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=E.props.helptextDropdownButton.default,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.optionalText=E.props.optionalText.default,this.requiredTag=!1,this.requiredText=E.props.requiredText.default,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.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})],D.prototype,`id`,void 0),e.n([e.o({type:String})],D.prototype,`name`,void 0),e.n([e.o({type:String})],D.prototype,`label`,void 0),e.n([e.o({type:String})],D.prototype,`helptext`,void 0),e.n([e.o({type:String,attribute:`helptext-dropdown`})],D.prototype,`helptextDropdown`,void 0),e.n([e.o({type:String,attribute:`helptext-dropdown-button`})],D.prototype,`helptextDropdownButton`,void 0),e.n([e.o({type:Boolean,reflect:!0})],D.prototype,`required`,void 0),e.n([e.o({type:Boolean,reflect:!0})],D.prototype,`multiple`,void 0),e.n([e.o({type:Boolean,reflect:!0})],D.prototype,`disabled`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`fullwidth`})],D.prototype,`fullwidth`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`upload-strategy`})],D.prototype,`uploadStrategy`,void 0),e.n([e.o({type:String,reflect:!0,attribute:`item-renderer`})],D.prototype,`itemRenderer`,void 0),e.n([e.o({type:String})],D.prototype,`accept`,void 0),e.n([e.o({converter:r.t.csvToArray,attribute:`allowed-formats`})],D.prototype,`allowedFormats`,void 0),e.n([e.o({type:String,attribute:`format-error-message`})],D.prototype,`formatErrorMessage`,void 0),e.n([e.o({attribute:`max-file-size`})],D.prototype,`maxFileSize`,void 0),e.n([e.o({type:String,attribute:`size-error-message`})],D.prototype,`sizeErrorMessage`,void 0),e.n([e.o({attribute:!1})],D.prototype,`onFileValidation`,void 0),e.n([e.o({attribute:!1})],D.prototype,`transfers`,void 0),e.n([e.o({type:Boolean,attribute:`add-comments-enabled`})],D.prototype,`addCommentsEnabled`,void 0),e.n([e.o({type:Boolean,attribute:`rename-files-enabled`})],D.prototype,`renameFilesEnabled`,void 0),e.n([e.o({attribute:!1})],D.prototype,`extraOperations`,void 0),e.n([e.o({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],D.prototype,`enableImagePreview`,void 0),e.n([e.o({type:Boolean,attribute:`has-error`})],D.prototype,`hasError`,void 0),e.n([e.o({type:String,attribute:`error-message`})],D.prototype,`errorMessage`,void 0),e.n([e.o({type:Boolean,attribute:`optional-tag`})],D.prototype,`optionalTag`,void 0),e.n([e.o({type:String,attribute:`optional-text`})],D.prototype,`optionalText`,void 0),e.n([e.o({type:Boolean,attribute:`required-tag`})],D.prototype,`requiredTag`,void 0),e.n([e.o({type:String,attribute:`required-text`})],D.prototype,`requiredText`,void 0),e.n([e.o({type:String,attribute:`tag-text`})],D.prototype,`tagText`,void 0),e.n([e.o({type:Number,attribute:`truncate-tail`})],D.prototype,`truncateTail`,void 0),e.n([e.o({attribute:!1})],D.prototype,`value`,void 0),e.n([e.o({attribute:!1})],D.prototype,`defaultValue`,void 0),e.n([e.a()],D.prototype,`files`,void 0),e.n([e.a()],D.prototype,`isDragActive`,void 0),e.n([e.a()],D.prototype,`validationErrorMessage`,void 0),e.n([e.a()],D.prototype,`addedAnnouncement`,void 0),e.n([e.a()],D.prototype,`thumbnailUrls`,void 0);var O=`comments`,k=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`)}`},A=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},j=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},M=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),N=()=>({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}
@@ -6,7 +6,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
6
6
  class="pkt-fileupload__queue-display__item__rename-input"
7
7
  ?disabled=${t.disabled}
8
8
  .value=${n}
9
- @keydown=${e=>k(e,i,t.close)}
9
+ @keydown=${e=>A(e,i,t.close)}
10
10
  />
11
11
  <button
12
12
  type="button"
@@ -28,7 +28,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
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.p`
31
+ />`}}),P=()=>({id:`comment`,title:e=>(e.attributes?.[O]??[]).length>0?``:`Legg til kommentar`,ariaLabel:`Legg til kommentar`,renderExtendedUI:t=>{let n=(t.getAttribute(O)??[])[0],r=`pkt-fileupload-comment-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(O,[{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>
@@ -39,7 +39,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
39
39
  .value=${n?.text??``}
40
40
  rows="2"
41
41
  placeholder="Skriv inn kommentar"
42
- @keydown=${e=>A(e,i,t.close)}
42
+ @keydown=${e=>j(e,i,t.close)}
43
43
  ></textarea>
44
44
  <button
45
45
  type="button"
@@ -57,7 +57,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.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.p`
60
+ `},renderContent:t=>{if(t.isActive)return null;let n=t.getAttribute(O)??[];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">
@@ -65,7 +65,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
65
65
  ${r.text}
66
66
  </span>
67
67
  <time class="pkt-fileupload__queue-display__item__comment__time">
68
- ${O(r.timestamp)}
68
+ ${k(r.timestamp)}
69
69
  </time>
70
70
  </div>
71
71
  <div class="pkt-fileupload__queue-display__item__comment__actions">
@@ -83,18 +83,18 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
83
83
  class="pkt-fileupload__queue-display__item__comment__action"
84
84
  aria-label="Slett kommentar"
85
85
  ?disabled=${t.disabled}
86
- @click=${()=>t.setAttribute(D,void 0)}
86
+ @click=${()=>t.setAttribute(O,void 0)}
87
87
  >
88
88
  <pkt-icon name="trash-can"></pkt-icon>
89
89
  </button>
90
90
  </div>
91
91
  </div>
92
92
  </div>
93
- `},renderHidden:t=>{let n=t.getAttribute(D);return e.p`<input
93
+ `},renderHidden:t=>{let n=t.getAttribute(O);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.p`<span
97
+ />`}}),F=(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,19 +102,19 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.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.p`<span data-pkt-truncate-part="first">${t}</span>`},F=(t,n,r)=>e.p`
105
+ >`:e.p`<span data-pkt-truncate-part="first">${t}</span>`},I=(t,n,r)=>e.p`
106
106
  <p class="pkt-fileupload__queue-display__item__title">
107
- ${P(t,r)}${n?e.p`<span class="pkt-fileupload__queue-display__item__filesize"> (${n})</span>`:null}
107
+ ${F(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.p`<span class="pkt-fileupload__queue-display__item__loading-text" aria-label="Laster opp fil"
109
+ `,L=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,R=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.p`
111
+ >`,z=({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)}),B=({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"
115
115
  aria-hidden="true"
116
116
  ></pkt-icon>
117
- ${F(u,n,s)}
117
+ ${I(u,n,s)}
118
118
  <button
119
119
  type="button"
120
120
  class="pkt-fileupload__queue-display__item__cancel-button"
@@ -135,14 +135,14 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
135
135
  <span class="pkt-fileupload__queue-display__item__percentage" aria-hidden="true"
136
136
  >${Math.round(i*100)}%</span
137
137
  >
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.p`
138
+ `:R(o)}
139
+ `},V=({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"
143
143
  aria-hidden="true"
144
144
  ></pkt-icon>
145
- ${F(l,n,s)}
145
+ ${I(l,n,s)}
146
146
  <button
147
147
  type="button"
148
148
  class="pkt-fileupload__queue-display__item__cancel-button"
@@ -164,7 +164,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
164
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.p`<button
167
+ `},H=({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=z({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-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.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.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">
175
+ </button>`:null}).filter(Boolean);return f.length===0?null:e.p`<div class="pkt-fileupload__queue-display__item__actions">${f}</div>`},U=({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=z({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.p`<div class="pkt-fileupload__queue-display__item__expanded-operation-ui">
177
+ </div>`}),W=({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=z({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.p`
179
+ </div>`},G=({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=z({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)}),K=(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
- ${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.p`
185
+ ${I(T(t),n,r)}
186
+ `,q=({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
  >
@@ -212,15 +212,15 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
212
212
  </span>
213
213
  </button>
214
214
  <span class="pkt-fileupload__queue-display__item__thumbnail__title"
215
- >${P(u,s)}</span
215
+ >${F(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.p`
218
+ `},J=({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=L(f),b=o.find(e=>e.id===s),x=b?.renderInlineUI?b.renderInlineUI(z({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
- ${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.p`
222
+ ${G({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d})}
223
+ ${y===`in-progress`?B({file:n,fileSize:a,disabled:i,transferProgress:f,transferShowProgress:m,loadingText:g,truncateTail:_,onCancel:v}):y===`error`?V({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"
@@ -229,17 +229,17 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
229
229
  <div class="pkt-fileupload__queue-display__item__inline-ui">
230
230
  ${x}
231
231
  </div>
232
- `:G(n,a,_)}
233
- ${y===`idle`?V({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
232
+ `:K(n,a,_)}
234
233
  ${y===`idle`?H({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
235
234
  ${y===`idle`?U({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
235
+ ${y===`idle`?W({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.p`
237
+ `},Y=({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=L(h),T=l.find(e=>e.id===u),E=T?.renderInlineUI?T.renderInlineUI(z({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
- ${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.p`
241
+ ${G({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m})}
242
+ ${w===`in-progress`?B({file:n,fileSize:a,disabled:i,transferProgress:h,transferShowProgress:_,loadingText:y,truncateTail:b,onCancel:x,iconName:`picture`}):w===`error`?V({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"
@@ -248,20 +248,25 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
248
248
  <div class="pkt-fileupload__queue-display__item__inline-ui">
249
249
  ${E}
250
250
  </div>
251
- `:K({file:n,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,truncateTail:b,onOpenPreview:S,onThumbnailImageError:C})}
252
- ${w===`idle`?V({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
251
+ `:q({file:n,thumbnailUrl:o,previewEnabled:s,canOpenPreview:c,truncateTail:b,onOpenPreview:S,onThumbnailImageError:C})}
253
252
  ${w===`idle`?H({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
254
253
  ${w===`idle`?U({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
254
+ ${w===`idle`?W({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.p`
256
+ `},X=class extends D{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}
260
260
  .helptext=${this.helptext}
261
+ .helptextDropdown=${this.helptextDropdown}
262
+ .helptextDropdownButton=${this.helptextDropdownButton}
261
263
  ?disabled=${this.disabled}
262
264
  ?hasError=${this.hasEffectiveError}
263
265
  ?optionalTag=${this.optionalTag}
266
+ .optionalText=${this.optionalText}
264
267
  ?requiredTag=${this.requiredTag}
268
+ .requiredText=${this.requiredText}
269
+ .tagText=${this.tagText}
265
270
  class=${t.t({"pkt-fileupload-wrapper":!0,"pkt-fileupload-wrapper--full-width":this.fullwidth})}
266
271
  >
267
272
  ${n}
@@ -338,7 +343,7 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
338
343
  </ul>`:null}
339
344
  ${this.renderPreviewModal(i)}
340
345
  </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.p`
346
+ `}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 Y({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 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),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
347
  <pkt-modal
343
348
  .open=${this.isPreviewModalOpen}
344
349
  .headingText=${o}
@@ -393,4 +398,4 @@ const e=require("./element-DJzurxgt.cjs"),t=require("./class-map-CCZN5uS3.cjs");
393
398
  </button>`:null}
394
399
  </div>
395
400
  </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.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}});
401
+ `}getQueueItemOperations(){let e=[];return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(N()),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(P()),e.push(...this.extraOperations),e.push(M(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()],X.prototype,`activeOperationByFileId`,void 0),e.n([e.a()],X.prototype,`isPreviewModalOpen`,void 0),e.n([e.a()],X.prototype,`previewCurrentIndex`,void 0),e.n([e.a()],X.prototype,`failedImageFileIds`,void 0),X=e.n([e.s(`pkt-fileupload`)],X);var Z=X;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Z}});
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./combobox-BhIqExJZ.cjs");exports.PktCombobox=e.n,exports.default=e.t;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./combobox-BjBNyEly.cjs");exports.PktCombobox=e.n,exports.default=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./combobox-B9YSsRZB.js";
1
+ import { n as e, t } from "./combobox-1xG07Oce.js";
2
2
  export { e as PktCombobox, t as default };
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fileupload-BMHJaAKR.cjs");Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return e.n}}),exports.default=e.t;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./fileupload-BLVrslUX.cjs");Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return e.n}}),exports.default=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./fileupload-DpvQ3e_T.js";
1
+ import { n as e, t } from "./fileupload-2hf8YNhO.js";
2
2
  export { e as PktFileUpload, t as default };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./alert-B8dLsiTz.cjs"),t=require("./icon-B8PVq2O6.cjs"),n=require("./button-B5tQpKeG.cjs"),r=require("./accordion-FISAiAbX.cjs"),i=require("./backlink-DDGlLzk9.cjs"),a=require("./breadcrumbs-D3tfWqvC.cjs"),o=require("./calendar-DIzGBdbh.cjs"),s=require("./card-BSZs5lRF.cjs"),c=require("./tag-C4fEuT-r.cjs"),l=require("./heading-DyJpBFT2.cjs"),u=require("./combobox-BhIqExJZ.cjs"),d=require("./header-DaFGbtLu.cjs"),f=require("./header-menu-DMdP_c6X.cjs"),p=require("./datepicker-DXxTiHJd.cjs"),m=require("./fileupload-BMHJaAKR.cjs"),h=require("./helptext-eckq4JEX.cjs"),g=require("./input-wrapper-BRjQB4zM.cjs"),_=require("./consent-X3wvhteO.cjs"),v=require("./checkbox-DfIvuwAj.cjs"),y=require("./modal-DKU7PnjJ.cjs"),b=require("./progressbar-BN5y20CC.cjs"),x=require("./link-Geze7498.cjs"),S=require("./textinput-CaIDCB2J.cjs"),C=require("./linkcard-6LCXRTR-.cjs"),w=require("./loader-CgW4Vst3.cjs"),T=require("./messagebox-VD5oEZ19.cjs"),E=require("./radiobutton-BH6rl98w.cjs"),D=require("./tabs-CGo0ODPa.cjs"),O=require("./textarea-Cb0pj6ki.cjs"),k=require("./select-BVPcJEIz.cjs"),A=require("./searchinput-DG6YetL1.cjs"),j=require("./timepicker-BcHEEtpX.cjs");exports.PktAccordion=r.r,exports.PktAccordionItem=r.n,exports.PktAlert=e.n,exports.PktBackLink=i.n,exports.PktBreadcrumbs=a.t,exports.PktButton=n.n,exports.PktCalendar=o.n,exports.PktCard=s.n,exports.PktCheckbox=v.n,exports.PktCombobox=u.n,exports.PktConsent=_.n,exports.PktDateTags=p.a,exports.PktDatepicker=p.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return m.n}}),exports.PktHeader=d.t,exports.PktHeaderMenu=f.n,exports.PktHeaderService=d.n,exports.PktHeaderUserMenu=d.r,exports.PktHeading=l.n,exports.PktHelptext=h.n,exports.PktIcon=t.n,exports.PktInputWrapper=g.n,exports.PktLink=x.n,exports.PktLinkCard=C.n,exports.PktLoader=w.n,exports.PktMessagebox=T.n,exports.PktModal=y.n,exports.PktProgressbar=b.n,exports.PktRadioButton=E.n,exports.PktRadiobutton=E.n,exports.PktSearchInput=A.n,exports.PktSelect=k.n,exports.PktTabItem=D.n,exports.PktTabs=D.r,exports.PktTag=c.n,exports.PktTextarea=O.n,exports.PktTextinput=S.n,exports.PktTimepicker=j.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./alert-B8dLsiTz.cjs"),t=require("./icon-B8PVq2O6.cjs"),n=require("./button-B5tQpKeG.cjs"),r=require("./accordion-FISAiAbX.cjs"),i=require("./backlink-DDGlLzk9.cjs"),a=require("./breadcrumbs-D3tfWqvC.cjs"),o=require("./calendar-DIzGBdbh.cjs"),s=require("./card-BSZs5lRF.cjs"),c=require("./tag-C4fEuT-r.cjs"),l=require("./heading-DyJpBFT2.cjs"),u=require("./combobox-BjBNyEly.cjs"),d=require("./header-DaFGbtLu.cjs"),f=require("./header-menu-DMdP_c6X.cjs"),p=require("./datepicker-DXxTiHJd.cjs"),m=require("./fileupload-BLVrslUX.cjs"),h=require("./helptext-eckq4JEX.cjs"),g=require("./input-wrapper-BRjQB4zM.cjs"),_=require("./consent-X3wvhteO.cjs"),v=require("./checkbox-DfIvuwAj.cjs"),y=require("./modal-DKU7PnjJ.cjs"),b=require("./progressbar-BN5y20CC.cjs"),x=require("./link-Geze7498.cjs"),S=require("./textinput-CaIDCB2J.cjs"),C=require("./linkcard-6LCXRTR-.cjs"),w=require("./loader-CgW4Vst3.cjs"),T=require("./messagebox-VD5oEZ19.cjs"),E=require("./radiobutton-BH6rl98w.cjs"),D=require("./tabs-CGo0ODPa.cjs"),O=require("./textarea-Cb0pj6ki.cjs"),k=require("./select-C3Q_bGZb.cjs"),A=require("./searchinput-DG6YetL1.cjs"),j=require("./timepicker-BcHEEtpX.cjs");exports.PktAccordion=r.r,exports.PktAccordionItem=r.n,exports.PktAlert=e.n,exports.PktBackLink=i.n,exports.PktBreadcrumbs=a.t,exports.PktButton=n.n,exports.PktCalendar=o.n,exports.PktCard=s.n,exports.PktCheckbox=v.n,exports.PktCombobox=u.n,exports.PktConsent=_.n,exports.PktDateTags=p.a,exports.PktDatepicker=p.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return m.n}}),exports.PktHeader=d.t,exports.PktHeaderMenu=f.n,exports.PktHeaderService=d.n,exports.PktHeaderUserMenu=d.r,exports.PktHeading=l.n,exports.PktHelptext=h.n,exports.PktIcon=t.n,exports.PktInputWrapper=g.n,exports.PktLink=x.n,exports.PktLinkCard=C.n,exports.PktLoader=w.n,exports.PktMessagebox=T.n,exports.PktModal=y.n,exports.PktProgressbar=b.n,exports.PktRadioButton=E.n,exports.PktRadiobutton=E.n,exports.PktSearchInput=A.n,exports.PktSelect=k.n,exports.PktTabItem=D.n,exports.PktTabs=D.r,exports.PktTag=c.n,exports.PktTextarea=O.n,exports.PktTextinput=S.n,exports.PktTimepicker=j.t;
package/dist/pkt-index.js CHANGED
@@ -8,11 +8,11 @@ import { n as s } from "./calendar-CjlUA-Lb.js";
8
8
  import { n as c } from "./card-D3jVkwxJ.js";
9
9
  import { n as l } from "./tag-DBNga0hg.js";
10
10
  import { n as u } from "./heading-CD0PhL8g.js";
11
- import { n as d } from "./combobox-B9YSsRZB.js";
11
+ import { n as d } from "./combobox-1xG07Oce.js";
12
12
  import { n as f, r as p, t as m } from "./header-CFzvRT3j.js";
13
13
  import { n as h } from "./header-menu-C8b5vd3n.js";
14
14
  import { a as g, t as _ } from "./datepicker-B_J5APcK.js";
15
- import { n as v } from "./fileupload-DpvQ3e_T.js";
15
+ import { n as v } from "./fileupload-2hf8YNhO.js";
16
16
  import { n as y } from "./helptext-OfqH5npD.js";
17
17
  import { n as b } from "./input-wrapper-DaA98B5l.js";
18
18
  import { n as x } from "./consent-D5sY6JK3.js";
@@ -27,7 +27,7 @@ import { n as k } from "./messagebox-fiaAyHLG.js";
27
27
  import { n as A } from "./radiobutton-DFCA9V07.js";
28
28
  import { n as j, r as M } from "./tabs-ChdR0D1C.js";
29
29
  import { n as N } from "./textarea-DNitIoWX.js";
30
- import { n as P } from "./select-C1--vTZ2.js";
30
+ import { n as P } from "./select-YyR17Ml6.js";
31
31
  import { n as F } from "./searchinput-CyO5k4Q4.js";
32
32
  import { t as I } from "./timepicker-Ch-ums4R.js";
33
33
  export { i as PktAccordion, r as PktAccordionItem, e as PktAlert, a as PktBackLink, o as PktBreadcrumbs, n as PktButton, s as PktCalendar, c as PktCard, S as PktCheckbox, d as PktCombobox, x as PktConsent, g as PktDateTags, _ as PktDatepicker, v as PktFileUpload, m as PktHeader, h as PktHeaderMenu, f as PktHeaderService, p as PktHeaderUserMenu, u as PktHeading, y as PktHelptext, t as PktIcon, b as PktInputWrapper, T as PktLink, D as PktLinkCard, O as PktLoader, k as PktMessagebox, C as PktModal, w as PktProgressbar, A as PktRadioButton, A as PktRadiobutton, F as PktSearchInput, P as PktSelect, j as PktTabItem, M as PktTabs, l as PktTag, N as PktTextarea, E as PktTextinput, I as PktTimepicker };
@@ -0,0 +1 @@
1
+ const e=require("./element-with-slot-BY7Jc-q8.cjs");var t=class{constructor(e){this.nodes=[],this.options=[],this.generation=0,this.host=e,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){this.nodes=[],Array.from(this.host.childNodes).forEach(e=>{(e.nodeName===`OPTION`||e.nodeName===`DATA`)&&this.addNode(e)}),this.createOptions(),this.observer.observe(this.host,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`disabled`,`selected`,`value`],attributeOldValue:!0,characterData:!0})}hostDisconnected(){this.observer.disconnect()}addNode(e){(e.nodeName===`OPTION`||e.nodeName===`DATA`)&&(e.hasAttribute(`hidden`)&&!e.hasAttribute(`data-skip`)&&e.setAttribute(`data-hidden`,`true`),!e.hasAttribute(`hidden`)&&e.hasAttribute(`data-skip`)&&e.hasAttribute(`data-hidden`)&&e.removeAttribute(`data-hidden`),e.setAttribute(`class`,`pkt-hide`),e.setAttribute(`data-skip`,`true`),e.setAttribute(`hidden`,`true`),this.nodes.includes(e)||this.nodes.push(e))}createOptions(){this.options=this.nodes.map(e=>({value:e.hasAttribute(`value`)?e.getAttribute(`value`)??``:e.textContent??``,label:e.textContent||e.getAttribute(`value`)||``,selected:e.hasAttribute(`selected`),disabled:e.hasAttribute(`disabled`),hidden:e.hasAttribute(`data-hidden`)})),this.generation++,this.host.requestUpdate()}handleMutations(t){let n=!1;t.forEach(t=>{if(t.type===`childList`){if(t.target!==this.host){let r=t.target;e.r(r)&&r.parentNode===this.host&&(n=!0);return}t.addedNodes.forEach(t=>{e.r(t)&&(this.addNode(t),n=!0)}),t.removedNodes.forEach(t=>{e.r(t)&&(this.nodes=this.nodes.filter(e=>e!==t),n=!0)})}if(t.type===`attributes`){let r=t.target;if(!e.r(r)||r.parentNode!==this.host||t.attributeName&&r.getAttribute(t.attributeName)===t.oldValue)return;this.addNode(r),n=!0}if(t.type===`characterData`){let r=t.target.parentElement;r&&e.r(r)&&r.parentNode===this.host&&(n=!0)}}),n&&this.createOptions()}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
@@ -5,19 +5,26 @@ var t = class {
5
5
  this.nodes = [], this.options = [], this.generation = 0, this.host = e, this.host.addController(this), this.nodes = [], this.options = [], this.observer = new MutationObserver((e) => this.handleMutations(e));
6
6
  }
7
7
  hostConnected() {
8
- Array.from(this.host.childNodes).forEach((e) => {
8
+ this.nodes = [], Array.from(this.host.childNodes).forEach((e) => {
9
9
  (e.nodeName === "OPTION" || e.nodeName === "DATA") && this.addNode(e);
10
10
  }), this.createOptions(), this.observer.observe(this.host, {
11
11
  childList: !0,
12
- subtree: !1,
13
- attributes: !0
12
+ subtree: !0,
13
+ attributes: !0,
14
+ attributeFilter: [
15
+ "disabled",
16
+ "selected",
17
+ "value"
18
+ ],
19
+ attributeOldValue: !0,
20
+ characterData: !0
14
21
  });
15
22
  }
16
23
  hostDisconnected() {
17
24
  this.observer.disconnect();
18
25
  }
19
26
  addNode(e) {
20
- (e.nodeName === "OPTION" || e.nodeName === "DATA") && (e.hasAttribute("hidden") && !e.hasAttribute("data-skip") && e.setAttribute("data-hidden", "true"), !e.hasAttribute("hidden") && e.hasAttribute("data-skip") && e.hasAttribute("data-hidden") && e.removeAttribute("data-hidden"), e.setAttribute("class", "pkt-hide"), e.setAttribute("data-skip", "true"), e.setAttribute("hidden", "true"), this.nodes.push(e));
27
+ (e.nodeName === "OPTION" || e.nodeName === "DATA") && (e.hasAttribute("hidden") && !e.hasAttribute("data-skip") && e.setAttribute("data-hidden", "true"), !e.hasAttribute("hidden") && e.hasAttribute("data-skip") && e.hasAttribute("data-hidden") && e.removeAttribute("data-hidden"), e.setAttribute("class", "pkt-hide"), e.setAttribute("data-skip", "true"), e.setAttribute("hidden", "true"), this.nodes.includes(e) || this.nodes.push(e));
21
28
  }
22
29
  createOptions() {
23
30
  this.options = this.nodes.map((e) => ({
@@ -31,11 +38,27 @@ var t = class {
31
38
  handleMutations(t) {
32
39
  let n = !1;
33
40
  t.forEach((t) => {
34
- t.type === "childList" && (t.addedNodes.forEach((t) => {
35
- e(t) && (this.addNode(t), n = !0);
36
- }), t.removedNodes.forEach((t) => {
37
- e(t) && (this.nodes = this.nodes.filter((e) => e !== t), n = !0);
38
- })), t.type === "attributes" && e(t.target) && (this.addNode(t.target), n = !0);
41
+ if (t.type === "childList") {
42
+ if (t.target !== this.host) {
43
+ let r = t.target;
44
+ e(r) && r.parentNode === this.host && (n = !0);
45
+ return;
46
+ }
47
+ t.addedNodes.forEach((t) => {
48
+ e(t) && (this.addNode(t), n = !0);
49
+ }), t.removedNodes.forEach((t) => {
50
+ e(t) && (this.nodes = this.nodes.filter((e) => e !== t), n = !0);
51
+ });
52
+ }
53
+ if (t.type === "attributes") {
54
+ let r = t.target;
55
+ if (!e(r) || r.parentNode !== this.host || t.attributeName && r.getAttribute(t.attributeName) === t.oldValue) return;
56
+ this.addNode(r), n = !0;
57
+ }
58
+ if (t.type === "characterData") {
59
+ let r = t.target.parentElement;
60
+ r && e(r) && r.parentNode === this.host && (n = !0);
61
+ }
39
62
  }), n && this.createOptions();
40
63
  }
41
64
  };
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./select-BVPcJEIz.cjs");exports.PktSelect=e.n,exports.default=e.t;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./select-C3Q_bGZb.cjs");exports.PktSelect=e.n,exports.default=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./select-C1--vTZ2.js";
1
+ import { n as e, t } from "./select-YyR17Ml6.js";
2
2
  export { e as PktSelect, t as default };
@@ -1,4 +1,4 @@
1
- const e=require("./element-DJzurxgt.cjs"),t=require("./element-with-slot-BY7Jc-q8.cjs"),n=require("./if-defined-DrwbxQOj.cjs"),r=require("./ref-DO7TzO4O.cjs"),i=require("./input-element-DZLXF2rI.cjs"),a=require("./pkt-options-controller-DHKHMyXM.cjs");require("./input-wrapper-BRjQB4zM.cjs");var o=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.o({type:Array,attribute:`options`})],o.prototype,`_optionsProp`,void 0),e.n([e.a()],o.prototype,`_options`,void 0);var s=class extends o{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e.p`
1
+ const e=require("./element-DJzurxgt.cjs"),t=require("./element-with-slot-BY7Jc-q8.cjs"),n=require("./if-defined-DrwbxQOj.cjs"),r=require("./ref-DO7TzO4O.cjs"),i=require("./input-element-DZLXF2rI.cjs"),a=require("./pkt-options-controller-CPrfqepu.cjs");require("./input-wrapper-BRjQB4zM.cjs");var o=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.o({type:Array,attribute:`options`})],o.prototype,`_optionsProp`,void 0),e.n([e.a()],o.prototype,`_options`,void 0);var s=class extends o{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e.p`
2
2
  <pkt-input-wrapper
3
3
  ?counter=${this.counter}
4
4
  ?disabled=${this.disabled}
@@ -3,7 +3,7 @@ import { n as a } from "./element-with-slot-mXLg8gg8.js";
3
3
  import { t as o } from "./if-defined-D0bnetLJ.js";
4
4
  import { n as s, t as c } from "./ref-WGS0u7i2.js";
5
5
  import { t as l } from "./input-element-DgylI1GK.js";
6
- import { t as u } from "./pkt-options-controller-Cis62vGe.js";
6
+ import { t as u } from "./pkt-options-controller-DMxYwnnj.js";
7
7
  import "./input-wrapper-DaA98B5l.js";
8
8
  //#region src/base-elements/options-input-element.ts
9
9
  var d = class extends l {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "16.26.4",
3
+ "version": "16.26.6",
4
4
  "description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -80,5 +80,5 @@
80
80
  "url": "https://github.com/oslokommune/punkt/issues"
81
81
  },
82
82
  "license": "MIT",
83
- "gitHead": "c4b1158f9296ddd9d20c80bf5e02df1d589a6cc5"
83
+ "gitHead": "d47c547935b6e47994ee8d5b921176fde1e75118"
84
84
  }