@oslokommune/punkt-react 16.15.0 → 16.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/punkt-react.es.js
CHANGED
|
@@ -8950,7 +8950,7 @@ try {
|
|
|
8950
8950
|
console.warn("Forsøker å definere <pkt-progressbar>, men den er allerede definert");
|
|
8951
8951
|
}
|
|
8952
8952
|
//#endregion
|
|
8953
|
-
//#region ../elements/dist/fileupload-
|
|
8953
|
+
//#region ../elements/dist/fileupload-DbmqRkz3.js
|
|
8954
8954
|
var mo = {
|
|
8955
8955
|
dropZoneDragMultiple: "Dra filer hit for å laste dem opp eller",
|
|
8956
8956
|
dropZoneDragSingle: "Dra en fil hit for å laste den opp eller",
|
|
@@ -9133,7 +9133,7 @@ function Po(e, t = mo.unknownFilename) {
|
|
|
9133
9133
|
}
|
|
9134
9134
|
var Fo = class extends lt {
|
|
9135
9135
|
constructor(...e) {
|
|
9136
|
-
super(...e), this.id = `pkt-fileupload-${
|
|
9136
|
+
super(...e), this.id = `pkt-fileupload-${Ii()}`, 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 = /* @__PURE__ */ new Map(), this.connectedForm = null, this.addedAnnouncementTimer = null, this.requiredSelectionMessage = mo.requiredMissing, this.onNativeFileChange = (e) => {
|
|
9137
9137
|
let t = e.target;
|
|
9138
9138
|
this.addFiles(t.files ? Array.from(t.files) : []), this.uploadStrategy === "custom" && (t.value = "");
|
|
9139
9139
|
}, this.openFileDialog = (e) => {
|
|
@@ -9207,7 +9207,7 @@ var Fo = class extends lt {
|
|
|
9207
9207
|
}
|
|
9208
9208
|
this.validationErrorMessage = null;
|
|
9209
9209
|
let n = t.map((e) => ({
|
|
9210
|
-
fileId:
|
|
9210
|
+
fileId: Ii(),
|
|
9211
9211
|
file: e,
|
|
9212
9212
|
attributes: { targetFilename: e.name }
|
|
9213
9213
|
}));
|
package/dist/punkt-react.umd.js
CHANGED
|
@@ -1396,7 +1396,7 @@
|
|
|
1396
1396
|
${this.statusType===`percentage`?`${r}%`:i}
|
|
1397
1397
|
</span>
|
|
1398
1398
|
</div>`:N}
|
|
1399
|
-
</div>`}setComputedValues(){this.progressbarId=this.id||bi(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`,this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``}syncAttributes(){this._handleAttribute(`aria-live`,this.ariaLive),this._handleAttribute(`aria-valuenow`,this.valueCurrent),this._handleAttribute(`aria-valuemin`,this.valueMin),this._handleAttribute(`aria-valuemax`,this.valueMax),this._handleAttribute(`aria-valuetext`,this.computedAriaValueText),this._handleAttribute(`aria-label`,this.ariaLabel),this._handleAttribute(`role`,this.role),this._handleAttribute(`aria-atomic`,`true`),this._handleAttribute(`id`,this.progressbarId),this.ariaLabel||this._handleAttribute(`aria-labelledby`,this.computedAriaLabelledby)}_handleAttribute(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}};K([W({type:String})],vo.prototype,`ariaLabel`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`ariaLabelledby`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`ariaValueText`,void 0),K([W({type:String})],vo.prototype,`ariaLive`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`id`,void 0),K([W({type:String})],vo.prototype,`role`,void 0),K([W({type:String})],vo.prototype,`skin`,void 0),K([W({type:String})],vo.prototype,`statusPlacement`,void 0),K([W({type:String})],vo.prototype,`statusType`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`title`,void 0),K([W({type:String})],vo.prototype,`titlePosition`,void 0),K([W({type:Number,reflect:!0})],vo.prototype,`valueCurrent`,void 0),K([W({type:Number})],vo.prototype,`valueMax`,void 0),K([W({type:Number})],vo.prototype,`valueMin`,void 0),K([G()],vo.prototype,`labelWidth`,void 0),K([G()],vo.prototype,`progressbarId`,void 0),K([G()],vo.prototype,`computedAriaLabelledby`,void 0),K([G()],vo.prototype,`computedAriaValueText`,void 0);try{U(`pkt-progressbar`)(vo)}catch{console.warn(`Forsøker å definere <pkt-progressbar>, men den er allerede definert`)}var yo={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 bo(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 xo(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 So(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function Co(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function wo(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 To(e,t){let n=So(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>wo(e,r,i))}function Eo(e,t){let n=(e??``).trim();if(n)return n;let r=So(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function Do(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function Oo(e,t){let n=So(e);if(n.length>0)return n.map(Do).join(`, `);let r=Co(t);return r.length>0?r.map(Do).join(`, `):``}function ko(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function Ao(e,t){let n=So(t.allowedFormats);if(n.length>0&&!To(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return ko(t.formatErrorMessage,r,{formats:e})}let r=bo(t.maxFileSize);if(r!==void 0&&e.size>r){let e=xo(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return ko(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function jo(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 Mo(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function No(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[Mo(e.progress)]-r[Mo(t.progress)])}function Po(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 Fo(e,t){if(e.key!==`Tab`)return!1;let n=Po(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 Io(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function Lo(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function Ro(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 zo(e,t=yo.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var Bo=class extends Ye{constructor(...e){super(...e),this.id=`pkt-fileupload-${crypto.randomUUID()}`,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=yo.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:crypto.randomUUID(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?yo.srFileAdded(n[0].attributes.targetFilename):yo.srFilesAdded(n.length));let r=this.getCurrentFiles(),i=this.multiple?[...r,...n]:[n[0]];this.commitFiles(i,`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 jo(e)}formatFileSize(e){return xo(e)}getResolvedAcceptValue(){return Eo(this.accept,this.allowedFormats)}getSupportedFormatsText(){return Oo(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return No(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=Ao(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?yo.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}=Ro(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:yo.srFilesUploadedOfTotal(t,e,yo.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=Ro(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:yo.srFilesFailedOfTotal(t,e,yo.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)}};K([W({type:String})],Bo.prototype,`id`,void 0),K([W({type:String})],Bo.prototype,`name`,void 0),K([W({type:String})],Bo.prototype,`label`,void 0),K([W({type:String})],Bo.prototype,`helptext`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`required`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`multiple`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`disabled`,void 0),K([W({type:Boolean,reflect:!0,attribute:`fullwidth`})],Bo.prototype,`fullwidth`,void 0),K([W({type:String,reflect:!0,attribute:`upload-strategy`})],Bo.prototype,`uploadStrategy`,void 0),K([W({type:String,reflect:!0,attribute:`item-renderer`})],Bo.prototype,`itemRenderer`,void 0),K([W({type:String})],Bo.prototype,`accept`,void 0),K([W({converter:Br.csvToArray,attribute:`allowed-formats`})],Bo.prototype,`allowedFormats`,void 0),K([W({type:String,attribute:`format-error-message`})],Bo.prototype,`formatErrorMessage`,void 0),K([W({attribute:`max-file-size`})],Bo.prototype,`maxFileSize`,void 0),K([W({type:String,attribute:`size-error-message`})],Bo.prototype,`sizeErrorMessage`,void 0),K([W({attribute:!1})],Bo.prototype,`onFileValidation`,void 0),K([W({attribute:!1})],Bo.prototype,`transfers`,void 0),K([W({type:Boolean,attribute:`add-comments-enabled`})],Bo.prototype,`addCommentsEnabled`,void 0),K([W({type:Boolean,attribute:`rename-files-enabled`})],Bo.prototype,`renameFilesEnabled`,void 0),K([W({attribute:!1})],Bo.prototype,`extraOperations`,void 0),K([W({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],Bo.prototype,`enableImagePreview`,void 0),K([W({type:Boolean,attribute:`has-error`})],Bo.prototype,`hasError`,void 0),K([W({type:String,attribute:`error-message`})],Bo.prototype,`errorMessage`,void 0),K([W({type:Boolean,attribute:`optional-tag`})],Bo.prototype,`optionalTag`,void 0),K([W({type:Boolean,attribute:`required-tag`})],Bo.prototype,`requiredTag`,void 0),K([W({type:Number,attribute:`truncate-tail`})],Bo.prototype,`truncateTail`,void 0),K([W({attribute:!1})],Bo.prototype,`value`,void 0),K([W({attribute:!1})],Bo.prototype,`defaultValue`,void 0),K([G()],Bo.prototype,`files`,void 0),K([G()],Bo.prototype,`isDragActive`,void 0),K([G()],Bo.prototype,`validationErrorMessage`,void 0),K([G()],Bo.prototype,`addedAnnouncement`,void 0),K([G()],Bo.prototype,`thumbnailUrls`,void 0);var Vo=`comments`,Ho=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`)}`},Uo=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},Wo=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},Go=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),Ko=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:e=>{let t=e.getAttribute(`targetFilename`)||e.file.attributes?.targetFilename||e.file.file?.name||``,n=`pkt-fileupload-rename-${e.file.fileId}`,r=()=>{let t=document.getElementById(n)?.value?.trim();t&&e.setAttribute(`targetFilename`,t),e.close()};return j`
|
|
1399
|
+
</div>`}setComputedValues(){this.progressbarId=this.id||bi(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`,this.computedAriaValueText=this.statusType===`fraction`&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||``}syncAttributes(){this._handleAttribute(`aria-live`,this.ariaLive),this._handleAttribute(`aria-valuenow`,this.valueCurrent),this._handleAttribute(`aria-valuemin`,this.valueMin),this._handleAttribute(`aria-valuemax`,this.valueMax),this._handleAttribute(`aria-valuetext`,this.computedAriaValueText),this._handleAttribute(`aria-label`,this.ariaLabel),this._handleAttribute(`role`,this.role),this._handleAttribute(`aria-atomic`,`true`),this._handleAttribute(`id`,this.progressbarId),this.ariaLabel||this._handleAttribute(`aria-labelledby`,this.computedAriaLabelledby)}_handleAttribute(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}};K([W({type:String})],vo.prototype,`ariaLabel`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`ariaLabelledby`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`ariaValueText`,void 0),K([W({type:String})],vo.prototype,`ariaLive`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`id`,void 0),K([W({type:String})],vo.prototype,`role`,void 0),K([W({type:String})],vo.prototype,`skin`,void 0),K([W({type:String})],vo.prototype,`statusPlacement`,void 0),K([W({type:String})],vo.prototype,`statusType`,void 0),K([W({type:String,reflect:!0})],vo.prototype,`title`,void 0),K([W({type:String})],vo.prototype,`titlePosition`,void 0),K([W({type:Number,reflect:!0})],vo.prototype,`valueCurrent`,void 0),K([W({type:Number})],vo.prototype,`valueMax`,void 0),K([W({type:Number})],vo.prototype,`valueMin`,void 0),K([G()],vo.prototype,`labelWidth`,void 0),K([G()],vo.prototype,`progressbarId`,void 0),K([G()],vo.prototype,`computedAriaLabelledby`,void 0),K([G()],vo.prototype,`computedAriaValueText`,void 0);try{U(`pkt-progressbar`)(vo)}catch{console.warn(`Forsøker å definere <pkt-progressbar>, men den er allerede definert`)}var yo={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 bo(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 xo(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 So(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function Co(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function wo(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 To(e,t){let n=So(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>wo(e,r,i))}function Eo(e,t){let n=(e??``).trim();if(n)return n;let r=So(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function Do(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function Oo(e,t){let n=So(e);if(n.length>0)return n.map(Do).join(`, `);let r=Co(t);return r.length>0?r.map(Do).join(`, `):``}function ko(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function Ao(e,t){let n=So(t.allowedFormats);if(n.length>0&&!To(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return ko(t.formatErrorMessage,r,{formats:e})}let r=bo(t.maxFileSize);if(r!==void 0&&e.size>r){let e=xo(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return ko(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function jo(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 Mo(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function No(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[Mo(e.progress)]-r[Mo(t.progress)])}function Po(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 Fo(e,t){if(e.key!==`Tab`)return!1;let n=Po(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 Io(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function Lo(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function Ro(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 zo(e,t=yo.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var Bo=class extends Ye{constructor(...e){super(...e),this.id=`pkt-fileupload-${bi()}`,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=yo.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:bi(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?yo.srFileAdded(n[0].attributes.targetFilename):yo.srFilesAdded(n.length));let r=this.getCurrentFiles(),i=this.multiple?[...r,...n]:[n[0]];this.commitFiles(i,`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 jo(e)}formatFileSize(e){return xo(e)}getResolvedAcceptValue(){return Eo(this.accept,this.allowedFormats)}getSupportedFormatsText(){return Oo(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return No(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=Ao(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?yo.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}=Ro(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:yo.srFilesUploadedOfTotal(t,e,yo.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=Ro(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:yo.srFilesFailedOfTotal(t,e,yo.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)}};K([W({type:String})],Bo.prototype,`id`,void 0),K([W({type:String})],Bo.prototype,`name`,void 0),K([W({type:String})],Bo.prototype,`label`,void 0),K([W({type:String})],Bo.prototype,`helptext`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`required`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`multiple`,void 0),K([W({type:Boolean,reflect:!0})],Bo.prototype,`disabled`,void 0),K([W({type:Boolean,reflect:!0,attribute:`fullwidth`})],Bo.prototype,`fullwidth`,void 0),K([W({type:String,reflect:!0,attribute:`upload-strategy`})],Bo.prototype,`uploadStrategy`,void 0),K([W({type:String,reflect:!0,attribute:`item-renderer`})],Bo.prototype,`itemRenderer`,void 0),K([W({type:String})],Bo.prototype,`accept`,void 0),K([W({converter:Br.csvToArray,attribute:`allowed-formats`})],Bo.prototype,`allowedFormats`,void 0),K([W({type:String,attribute:`format-error-message`})],Bo.prototype,`formatErrorMessage`,void 0),K([W({attribute:`max-file-size`})],Bo.prototype,`maxFileSize`,void 0),K([W({type:String,attribute:`size-error-message`})],Bo.prototype,`sizeErrorMessage`,void 0),K([W({attribute:!1})],Bo.prototype,`onFileValidation`,void 0),K([W({attribute:!1})],Bo.prototype,`transfers`,void 0),K([W({type:Boolean,attribute:`add-comments-enabled`})],Bo.prototype,`addCommentsEnabled`,void 0),K([W({type:Boolean,attribute:`rename-files-enabled`})],Bo.prototype,`renameFilesEnabled`,void 0),K([W({attribute:!1})],Bo.prototype,`extraOperations`,void 0),K([W({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],Bo.prototype,`enableImagePreview`,void 0),K([W({type:Boolean,attribute:`has-error`})],Bo.prototype,`hasError`,void 0),K([W({type:String,attribute:`error-message`})],Bo.prototype,`errorMessage`,void 0),K([W({type:Boolean,attribute:`optional-tag`})],Bo.prototype,`optionalTag`,void 0),K([W({type:Boolean,attribute:`required-tag`})],Bo.prototype,`requiredTag`,void 0),K([W({type:Number,attribute:`truncate-tail`})],Bo.prototype,`truncateTail`,void 0),K([W({attribute:!1})],Bo.prototype,`value`,void 0),K([W({attribute:!1})],Bo.prototype,`defaultValue`,void 0),K([G()],Bo.prototype,`files`,void 0),K([G()],Bo.prototype,`isDragActive`,void 0),K([G()],Bo.prototype,`validationErrorMessage`,void 0),K([G()],Bo.prototype,`addedAnnouncement`,void 0),K([G()],Bo.prototype,`thumbnailUrls`,void 0);var Vo=`comments`,Ho=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`)}`},Uo=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},Wo=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},Go=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),Ko=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:e=>{let t=e.getAttribute(`targetFilename`)||e.file.attributes?.targetFilename||e.file.file?.name||``,n=`pkt-fileupload-rename-${e.file.fileId}`,r=()=>{let t=document.getElementById(n)?.value?.trim();t&&e.setAttribute(`targetFilename`,t),e.close()};return j`
|
|
1400
1400
|
<label for=${n} class="pkt-sr-only">Endre filnavn</label>
|
|
1401
1401
|
<input
|
|
1402
1402
|
id=${n}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "16.15.
|
|
3
|
+
"version": "16.15.1",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
41
41
|
"@lit/react": "^1.0.7",
|
|
42
|
-
"@oslokommune/punkt-elements": "^16.15.
|
|
42
|
+
"@oslokommune/punkt-elements": "^16.15.1",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"react-hook-form": "^7.53.0"
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
110
110
|
},
|
|
111
111
|
"license": "MIT",
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "6cc24a37a17370c3a20c0406c6742bd1b6273054"
|
|
113
113
|
}
|