@oslokommune/punkt-elements 16.14.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/CHANGELOG.md +34 -1
- package/dist/calendar-Ch1dgnBo.js +656 -0
- package/dist/calendar-DkjXla0I.cjs +90 -0
- package/dist/{card-CQYxrtL0.cjs → card-C3POnP3O.cjs} +1 -1
- package/dist/{card-Bir3-pl2.js → card-CEDbo1t7.js} +2 -2
- package/dist/{checkbox-Cspxcvt_.js → checkbox-Bjp43NxA.js} +1 -1
- package/dist/{checkbox-BARDb9iV.cjs → checkbox-nTbihMxW.cjs} +1 -1
- package/dist/{combobox-CstFVsy1.cjs → combobox-C4Q6kQEs.cjs} +1 -1
- package/dist/{combobox-DtYloYZq.js → combobox-CL9BLuxt.js} +6 -6
- package/dist/components/fileupload/fileupload-base.d.ts +116 -0
- package/dist/components/fileupload/fileupload-operations.d.ts +4 -0
- package/dist/components/fileupload/fileupload-renderers.d.ts +28 -0
- package/dist/components/fileupload/fileupload-types.d.ts +70 -0
- package/dist/components/fileupload/fileupload.d.ts +25 -0
- package/dist/components/fileupload/fileupload.test.d.ts +0 -0
- package/dist/components/fileupload/index.d.ts +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/converters-Bffq_YDm.cjs +1 -0
- package/dist/converters-jauYkvNh.js +1378 -0
- package/dist/{datepicker-gO2EuaBX.js → datepicker-BUK1Qanw.js} +22 -21
- package/dist/{datepicker-DfSdjIjl.cjs → datepicker-DYd3JCs_.cjs} +10 -10
- package/dist/docs/components/fileupload.d.ts +27 -0
- package/dist/fileupload-DbmqRkz3.js +1373 -0
- package/dist/fileupload-DjUAvBcP.cjs +396 -0
- package/dist/fileupload.d.ts +1 -0
- package/dist/{header-DpU4HYdj.cjs → header-Dps8o-ZY.cjs} +1 -1
- package/dist/{header-BHrgTCxj.js → header-T5O6sfCN.js} +3 -3
- package/dist/{helptext-CCBKKLus.js → helptext-C5rG4VkA.js} +2 -2
- package/dist/{helptext-D-3QfZv5.cjs → helptext-DQgStO4D.cjs} +1 -1
- package/dist/{input-element-Bw1s6NlF.js → input-element-CjebcQd1.js} +3 -3
- package/dist/{input-element-B1yxcfz4.cjs → input-element-FGcr5hGd.cjs} +1 -1
- package/dist/{input-wrapper-CzS4rUrK.cjs → input-wrapper-B_XFi211.cjs} +1 -1
- package/dist/{input-wrapper-XuUnGN_U.js → input-wrapper-DBpMVSxt.js} +4 -4
- package/dist/{listbox-DuBgTFvH.js → listbox-0NHJvNjz.js} +2 -2
- package/dist/{listbox-DCA2JoPV.cjs → listbox-CcThiNBY.cjs} +1 -1
- package/dist/{modal-CBEWrAi2.cjs → modal-B6591sWa.cjs} +1 -1
- package/dist/{modal-pPp8nia6.js → modal-DyIC3uhs.js} +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -0
- package/dist/pkt-fileupload.js +2 -0
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +25 -24
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-CdXtmOBb.cjs → progressbar-CrwpnIkv.cjs} +1 -1
- package/dist/{progressbar-Dy9AiYQz.js → progressbar-uC-0W6o4.js} +1 -1
- package/dist/{radiobutton-V_KPbup_.js → radiobutton-B-8-wWFf.js} +1 -1
- package/dist/{radiobutton-GOnpUbCW.cjs → radiobutton-DvXr7tDk.cjs} +1 -1
- package/dist/{select-Cwzq_O8S.cjs → select-B75wzvyz.cjs} +1 -1
- package/dist/{select-Bo-w84pI.js → select-D9B8Ighz.js} +3 -3
- package/dist/shared-types/fileupload.d.ts +73 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/shared-utils/fileupload/announcements.d.ts +11 -0
- package/dist/shared-utils/fileupload/filename.d.ts +13 -0
- package/dist/shared-utils/fileupload/focus-trap.d.ts +12 -0
- package/dist/shared-utils/fileupload/formats.d.ts +30 -0
- package/dist/shared-utils/fileupload/index.d.ts +15 -0
- package/dist/shared-utils/fileupload/navigation.d.ts +5 -0
- package/dist/shared-utils/fileupload/size.d.ts +12 -0
- package/dist/shared-utils/fileupload/transfers.d.ts +17 -0
- package/dist/shared-utils/fileupload/truncate.d.ts +13 -0
- package/dist/shared-utils/fileupload/validation.d.ts +24 -0
- package/dist/tests/component-registry.d.ts +2 -0
- package/dist/{textarea-DYInBFHP.js → textarea-CIWXMaAD.js} +2 -2
- package/dist/{textarea-CbqiuSE8.cjs → textarea-CjqprL6Y.cjs} +1 -1
- package/dist/{textinput-Bp-UeGOq.cjs → textinput-B0VWmVIF.cjs} +1 -1
- package/dist/{textinput-DO9RldRk.js → textinput-CxzAxM8E.js} +2 -2
- package/dist/{timepicker-BpBcPB-r.cjs → timepicker-Cv9juQeB.cjs} +1 -1
- package/dist/{timepicker-D_XpQJXa.js → timepicker-DXrpg5C7.js} +2 -2
- package/package.json +2 -2
- package/src/components/fileupload/fileupload-base.ts +558 -0
- package/src/components/fileupload/fileupload-operations.ts +213 -0
- package/src/components/fileupload/fileupload-renderers.ts +769 -0
- package/src/components/fileupload/fileupload-types.ts +88 -0
- package/src/components/fileupload/fileupload.test.ts +949 -0
- package/src/components/fileupload/fileupload.ts +469 -0
- package/src/components/fileupload/index.ts +34 -0
- package/src/components/index.ts +16 -0
- package/dist/calendar-BzEtOJla.js +0 -2031
- package/dist/calendar-E5jJLt8D.cjs +0 -90
- /package/dist/{booleanish-jJLlnr6-.cjs → booleanish-B5EFqFpJ.cjs} +0 -0
- /package/dist/{booleanish-BmcOU-43.js → booleanish-CRaKZ75t.js} +0 -0
- /package/dist/{consent-DeB_5sWH.js → consent-f_IGyHss.js} +0 -0
- /package/dist/{consent-hwu7pp3S.cjs → consent-zh2npq2K.cjs} +0 -0
- /package/dist/{dialog-polyfill.esm-1hPr0gl9.js → dialog-polyfill.esm-BmVHGRTX.js} +0 -0
- /package/dist/{dialog-polyfill.esm-D3Oinvk0.cjs → dialog-polyfill.esm-CXDsb3l-.cjs} +0 -0
- /package/dist/{heading-DiQLPxdf.js → heading-BxvE80bb.js} +0 -0
- /package/dist/{heading-BgSWIRii.cjs → heading-DRJTS27k.cjs} +0 -0
- /package/dist/{input-wrapper-Dwd-_sKm.cjs → input-wrapper-CYCCx8MP.cjs} +0 -0
- /package/dist/{input-wrapper-CDyHTR1V.js → input-wrapper-kw2y6Jp_.js} +0 -0
- /package/dist/{link-CyTCpI0k.cjs → link-B8zYc5WK.cjs} +0 -0
- /package/dist/{link-CKAFMz9j.js → link-CjJcwcxR.js} +0 -0
- /package/dist/{linkcard-BE4-FewK.cjs → linkcard-C4x-NJMi.cjs} +0 -0
- /package/dist/{linkcard-B0KOGaGj.js → linkcard-Ddh5R_L-.js} +0 -0
- /package/dist/{loader-CX2rsC01.cjs → loader-CGQXAuyM.cjs} +0 -0
- /package/dist/{loader-6kFZUErT.js → loader-DeizpX45.js} +0 -0
- /package/dist/{messagebox-Din9X53b.cjs → messagebox-Ccu29rDv.cjs} +0 -0
- /package/dist/{messagebox-Cwlg5sOr.js → messagebox-DqoPqo4K.js} +0 -0
- /package/dist/{pkt-options-controller-CXUGx134.cjs → pkt-options-controller-BPBb_O2K.cjs} +0 -0
- /package/dist/{pkt-options-controller-CRrI6WMk.js → pkt-options-controller-DbLrdRwH.js} +0 -0
- /package/dist/{repeat-Cepr3469.js → repeat-DV1O43YU.js} +0 -0
- /package/dist/{repeat-CqcDYBxr.cjs → repeat-DaDFvx86.cjs} +0 -0
- /package/dist/{tabs-Rc9N9HWa.js → tabs-4eWA7CsK.js} +0 -0
- /package/dist/{tabs-BfurI6C3.cjs → tabs-RnDtIFv3.cjs} +0 -0
- /package/dist/{tag-DLthw5b4.cjs → tag-DWtajZk6.cjs} +0 -0
- /package/dist/{tag-VwykmuQR.js → tag-hl59gziI.js} +0 -0
- /package/dist/{utils-CUqCKGvp.js → utils-BOOZ0ppt.js} +0 -0
- /package/dist/{utils-CjAbIttF.cjs → utils-CM67Oudc.cjs} +0 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`);require(`./alert-BEEnTiCb.cjs`),require(`./icon-Dr8sfT2X.cjs`);const n=require(`./if-defined-XKOD_t_V.cjs`),r=require(`./converters-Bffq_YDm.cjs`),i=require(`./utils-CM67Oudc.cjs`);require(`./input-wrapper-B_XFi211.cjs`),require(`./modal-B6591sWa.cjs`),require(`./progressbar-CrwpnIkv.cjs`);var a={dropZoneDragMultiple:`Dra filer hit for å laste dem opp eller`,dropZoneDragSingle:`Dra en fil hit for å laste den opp eller`,dropZoneDragMultipleThumbnail:`Dra bilder hit for å laste dem opp eller`,dropZoneDragSingleThumbnail:`Dra et bilde hit for å laste det opp eller`,dropZoneDragActiveMultiple:`Slipp filene her`,dropZoneDragActiveSingle:`Slipp filen her`,dropZoneDragActiveMultipleThumbnail:`Slipp bildene her`,dropZoneDragActiveSingleThumbnail:`Slipp bildet her`,dropZoneOpenFileDialogMultiple:`velg filer`,dropZoneOpenFileDialogSingle:`velg en fil`,dropZoneOpenFileDialogMultipleThumbnail:`velg fra kamerarull`,dropZoneOpenFileDialogSingleThumbnail:`velg fra kamerarull`,supportedFormatsPrefix:`Format:`,invalidFormatDefault:e=>`Ugyldig filtype. Tillatte formater: ${e}`,sizeTooLargeDefault:e=>`Filen er for stor. Maks størrelse er ${e}.`,requiredMissing:`Du må laste opp minst én fil.`,genericValidationRejection:`Filen ble avvist av validering.`,unknownFilename:`Ukjent fil`,fileLabel:e=>e===1?`fil`:`filer`,srFileAdded:e=>`Filen «${e}» er lagt til`,srFilesAdded:e=>`${e} filer er lagt til`,srFilesUploadedOfTotal:(e,t,n)=>`${e} av ${t} ${n} lastet opp`,srFilesFailedOfTotal:(e,t,n)=>`Feil ved opplasting: ${e} av ${t} ${n} feilet`};function o(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function s(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:e<1024*1024*1024?`${Math.round(e/(1024*1024))} MB`:`${Math.round(e/(1024*1024*1024))} GB`}function c(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function l(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function u(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function d(e,t){let n=c(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>u(e,r,i))}function f(e,t){let n=(e??``).trim();if(n)return n;let r=c(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function p(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function m(e,t){let n=c(e);if(n.length>0)return n.map(p).join(`, `);let r=l(t);return r.length>0?r.map(p).join(`, `):``}function h(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function g(e,t){let n=c(t.allowedFormats);if(n.length>0&&!d(e,n)){let e=n.join(`, `),r=`Ugyldig filtype. Tillatte formater: ${e}`;return h(t.formatErrorMessage,r,{formats:e})}let r=o(t.maxFileSize);if(r!==void 0&&e.size>r){let e=s(r),n=`Filen er for stor. Maks størrelse er ${e}.`;return h(t.sizeErrorMessage,n,{maxSize:e})}if(t.onFileValidation){let n=t.onFileValidation(e);if(n)return n}return null}function _(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function v(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function y(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[v(e.progress)]-r[v(t.progress)])}function b(e){if(!e)return[];let t=[`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([type="hidden"]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);return Array.from(e.querySelectorAll(t)).filter(e=>!e.hasAttribute(`inert`))}function x(e,t){if(e.key!==`Tab`)return!1;let n=b(t);if(n.length===0)return e.preventDefault(),!0;let r=n[0],i=n[n.length-1],a=(t?.ownerDocument??document).activeElement,o=!!a&&n.includes(a);return e.shiftKey?!o||a===r?(e.preventDefault(),i.focus(),!0):!1:!o||a===i?(e.preventDefault(),r.focus(),!0):!1}function S(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function C(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function w(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function T(e,t=a.unknownFilename){return e.attributes?.targetFilename||e.file?.name||t}var E=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${i.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.requiredSelectionMessage=a.requiredMissing,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:i.n(),file:e,attributes:{targetFilename:e.name}}));this.setAddedAnnouncement(n.length===1?a.srFileAdded(n[0].attributes.targetFilename):a.srFilesAdded(n.length));let r=this.getCurrentFiles(),o=this.multiple?[...r,...n]:[n[0]];this.commitFiles(o,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return _(e)}formatFileSize(e){return s(e)}getResolvedAcceptValue(){return f(this.accept,this.allowedFormats)}getSupportedFormatsText(){return m(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return y(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=g(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?a.genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesUploadedOfTotal(t,e,a.fileLabel(e))}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=w(this.getCurrentFiles(),this.transfers);return e===0||t===0?``:a.srFilesFailedOfTotal(t,e,a.fileLabel(e))}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.r([e.s({type:String})],E.prototype,`id`,void 0),e.r([e.s({type:String})],E.prototype,`name`,void 0),e.r([e.s({type:String})],E.prototype,`label`,void 0),e.r([e.s({type:String})],E.prototype,`helptext`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`required`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`multiple`,void 0),e.r([e.s({type:Boolean,reflect:!0})],E.prototype,`disabled`,void 0),e.r([e.s({type:Boolean,reflect:!0,attribute:`fullwidth`})],E.prototype,`fullwidth`,void 0),e.r([e.s({type:String,reflect:!0,attribute:`upload-strategy`})],E.prototype,`uploadStrategy`,void 0),e.r([e.s({type:String,reflect:!0,attribute:`item-renderer`})],E.prototype,`itemRenderer`,void 0),e.r([e.s({type:String})],E.prototype,`accept`,void 0),e.r([e.s({converter:r.t.csvToArray,attribute:`allowed-formats`})],E.prototype,`allowedFormats`,void 0),e.r([e.s({type:String,attribute:`format-error-message`})],E.prototype,`formatErrorMessage`,void 0),e.r([e.s({attribute:`max-file-size`})],E.prototype,`maxFileSize`,void 0),e.r([e.s({type:String,attribute:`size-error-message`})],E.prototype,`sizeErrorMessage`,void 0),e.r([e.s({attribute:!1})],E.prototype,`onFileValidation`,void 0),e.r([e.s({attribute:!1})],E.prototype,`transfers`,void 0),e.r([e.s({type:Boolean,attribute:`add-comments-enabled`})],E.prototype,`addCommentsEnabled`,void 0),e.r([e.s({type:Boolean,attribute:`rename-files-enabled`})],E.prototype,`renameFilesEnabled`,void 0),e.r([e.s({attribute:!1})],E.prototype,`extraOperations`,void 0),e.r([e.s({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],E.prototype,`enableImagePreview`,void 0),e.r([e.s({type:Boolean,attribute:`has-error`})],E.prototype,`hasError`,void 0),e.r([e.s({type:String,attribute:`error-message`})],E.prototype,`errorMessage`,void 0),e.r([e.s({type:Boolean,attribute:`optional-tag`})],E.prototype,`optionalTag`,void 0),e.r([e.s({type:Boolean,attribute:`required-tag`})],E.prototype,`requiredTag`,void 0),e.r([e.s({type:Number,attribute:`truncate-tail`})],E.prototype,`truncateTail`,void 0),e.r([e.s({attribute:!1})],E.prototype,`value`,void 0),e.r([e.s({attribute:!1})],E.prototype,`defaultValue`,void 0),e.r([e.o()],E.prototype,`files`,void 0),e.r([e.o()],E.prototype,`isDragActive`,void 0),e.r([e.o()],E.prototype,`validationErrorMessage`,void 0),e.r([e.o()],E.prototype,`addedAnnouncement`,void 0),e.r([e.o()],E.prototype,`thumbnailUrls`,void 0);var D=`comments`,O=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},k=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},A=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},j=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),M=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e.d`
|
|
2
|
+
<label for=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
|
+
<input
|
|
4
|
+
id=${r}
|
|
5
|
+
type="text"
|
|
6
|
+
class="pkt-fileupload__queue-display__item__rename-input"
|
|
7
|
+
?disabled=${t.disabled}
|
|
8
|
+
.value=${n}
|
|
9
|
+
@keydown=${e=>k(e,i,t.close)}
|
|
10
|
+
/>
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
14
|
+
?disabled=${t.disabled}
|
|
15
|
+
@click=${i}
|
|
16
|
+
>
|
|
17
|
+
Lagre
|
|
18
|
+
</button>
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
22
|
+
?disabled=${t.disabled}
|
|
23
|
+
@click=${t.close}
|
|
24
|
+
>
|
|
25
|
+
Avbryt
|
|
26
|
+
</button>
|
|
27
|
+
`},renderHidden:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``;return e.d`<input
|
|
28
|
+
type="hidden"
|
|
29
|
+
name=${`${t.inputName}-targetFilename`}
|
|
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.d`
|
|
32
|
+
<label for=${r} class="pkt-fileupload__queue-display__item__comment-label">
|
|
33
|
+
${n?`Rediger kommentar`:`Legg til kommentar`}
|
|
34
|
+
</label>
|
|
35
|
+
<textarea
|
|
36
|
+
id=${r}
|
|
37
|
+
class="pkt-fileupload__queue-display__item__comment-input"
|
|
38
|
+
?disabled=${t.disabled}
|
|
39
|
+
.value=${n?.text??``}
|
|
40
|
+
rows="2"
|
|
41
|
+
placeholder="Skriv inn kommentar"
|
|
42
|
+
@keydown=${e=>A(e,i,t.close)}
|
|
43
|
+
></textarea>
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
class="pkt-btn pkt-btn--secondary pkt-btn--small"
|
|
47
|
+
?disabled=${t.disabled}
|
|
48
|
+
@click=${i}
|
|
49
|
+
>
|
|
50
|
+
${n?`Lagre kommentar`:`Legg til kommentar`}
|
|
51
|
+
</button>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small"
|
|
55
|
+
?disabled=${t.disabled}
|
|
56
|
+
@click=${t.close}
|
|
57
|
+
>
|
|
58
|
+
Avbryt
|
|
59
|
+
</button>
|
|
60
|
+
`},renderContent:t=>{if(t.isActive)return null;let n=t.getAttribute(D)??[];if(n.length===0)return null;let r=n[0];return e.d`
|
|
61
|
+
<div class="pkt-fileupload__queue-display__item__comments">
|
|
62
|
+
<div class="pkt-fileupload__queue-display__item__comment">
|
|
63
|
+
<div class="pkt-fileupload__queue-display__item__comment__content">
|
|
64
|
+
<span class="pkt-fileupload__queue-display__item__comment__text" aria-label="Kommentar tekst">
|
|
65
|
+
${r.text}
|
|
66
|
+
</span>
|
|
67
|
+
<time class="pkt-fileupload__queue-display__item__comment__time">
|
|
68
|
+
${O(r.timestamp)}
|
|
69
|
+
</time>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="pkt-fileupload__queue-display__item__comment__actions">
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
class="pkt-fileupload__queue-display__item__comment__action"
|
|
75
|
+
aria-label="Rediger kommentar"
|
|
76
|
+
?disabled=${t.disabled}
|
|
77
|
+
@click=${t.activate}
|
|
78
|
+
>
|
|
79
|
+
<pkt-icon name="edit"></pkt-icon>
|
|
80
|
+
</button>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="pkt-fileupload__queue-display__item__comment__action"
|
|
84
|
+
aria-label="Slett kommentar"
|
|
85
|
+
?disabled=${t.disabled}
|
|
86
|
+
@click=${()=>t.setAttribute(D,void 0)}
|
|
87
|
+
>
|
|
88
|
+
<pkt-icon name="trash-can"></pkt-icon>
|
|
89
|
+
</button>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
`},renderHidden:t=>{let n=t.getAttribute(D);return e.d`<input
|
|
94
|
+
type="hidden"
|
|
95
|
+
name=${`${t.inputName}-comments`}
|
|
96
|
+
value=${n?JSON.stringify(n):``}
|
|
97
|
+
/>`}}),P=(t,n)=>{let r=S(t,n);return r?e.d`<span
|
|
98
|
+
class="pkt-fileupload__queue-display__item__title__head"
|
|
99
|
+
data-pkt-truncate-part="first"
|
|
100
|
+
>${r.head}</span
|
|
101
|
+
><span
|
|
102
|
+
class="pkt-fileupload__queue-display__item__title__tail"
|
|
103
|
+
data-pkt-truncate-part="tail"
|
|
104
|
+
>${r.tail}</span
|
|
105
|
+
>`:e.d`<span data-pkt-truncate-part="first">${t}</span>`},F=(t,n,r)=>e.d`
|
|
106
|
+
<p class="pkt-fileupload__queue-display__item__title">
|
|
107
|
+
${P(t,r)}${n?e.d`<span class="pkt-fileupload__queue-display__item__filesize"> (${n})</span>`:null}
|
|
108
|
+
</p>
|
|
109
|
+
`,I=e=>typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`,L=t=>e.d`<span class="pkt-fileupload__queue-display__item__loading-text" aria-label="Laster opp fil"
|
|
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.d`
|
|
112
|
+
<pkt-icon
|
|
113
|
+
name=${l}
|
|
114
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
115
|
+
aria-hidden="true"
|
|
116
|
+
></pkt-icon>
|
|
117
|
+
${F(u,n,s)}
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
121
|
+
aria-label="Avbryt opplasting"
|
|
122
|
+
?disabled=${r}
|
|
123
|
+
@click=${()=>c(t.fileId)}
|
|
124
|
+
>
|
|
125
|
+
Avbryt
|
|
126
|
+
</button>
|
|
127
|
+
${d?e.d`
|
|
128
|
+
<pkt-progressbar
|
|
129
|
+
class="pkt-fileupload__queue-display__item__progress"
|
|
130
|
+
valueCurrent=${Math.round(i*100)}
|
|
131
|
+
valueMax=${100}
|
|
132
|
+
statusType="none"
|
|
133
|
+
statusPlacement="following"
|
|
134
|
+
></pkt-progressbar>
|
|
135
|
+
<span class="pkt-fileupload__queue-display__item__percentage" aria-hidden="true"
|
|
136
|
+
>${Math.round(i*100)}%</span
|
|
137
|
+
>
|
|
138
|
+
`: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.d`
|
|
140
|
+
<pkt-icon
|
|
141
|
+
name="alert-error"
|
|
142
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
></pkt-icon>
|
|
145
|
+
${F(l,n,s)}
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
class="pkt-fileupload__queue-display__item__cancel-button"
|
|
149
|
+
aria-label="Fjern fil som feilet under opplasting"
|
|
150
|
+
?disabled=${r}
|
|
151
|
+
@click=${()=>c(t.fileId)}
|
|
152
|
+
>
|
|
153
|
+
Fjern
|
|
154
|
+
</button>
|
|
155
|
+
${u?e.d`
|
|
156
|
+
<pkt-progressbar
|
|
157
|
+
class="pkt-fileupload__queue-display__item__progress pkt-fileupload__queue-display__item__progress--error"
|
|
158
|
+
valueCurrent=${d}
|
|
159
|
+
valueMax=${100}
|
|
160
|
+
statusType="none"
|
|
161
|
+
statusPlacement="following"
|
|
162
|
+
></pkt-progressbar>
|
|
163
|
+
`:null}
|
|
164
|
+
${o?e.d`<span class="pkt-fileupload__queue-display__item__error-message"
|
|
165
|
+
>${o}</span
|
|
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.d`<button
|
|
168
|
+
type="button"
|
|
169
|
+
class="pkt-fileupload__queue-display__item__operation"
|
|
170
|
+
aria-label=${n.t(typeof a.ariaLabel==`function`?a.ariaLabel(t):a.ariaLabel)}
|
|
171
|
+
?disabled=${r}
|
|
172
|
+
@click=${()=>{(a.renderInlineUI||a.renderExtendedUI)&&d.activate(),a.onClick?.(d)}}
|
|
173
|
+
>
|
|
174
|
+
${f}
|
|
175
|
+
</button>`:null}).filter(Boolean);return f.length===0?null:e.d`<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.d`<div class="pkt-fileupload__queue-display__item__operation-content">
|
|
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.d`<div class="pkt-fileupload__queue-display__item__expanded-operation-ui">
|
|
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.d`
|
|
180
|
+
<pkt-icon
|
|
181
|
+
name="document-text"
|
|
182
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
183
|
+
aria-hidden="true"
|
|
184
|
+
></pkt-icon>
|
|
185
|
+
${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.d`
|
|
187
|
+
<div
|
|
188
|
+
class=${t.t({"pkt-fileupload__queue-display__item__thumbnail":!0,"pkt-fileupload__queue-display__item__thumbnail--fallback":!d})}
|
|
189
|
+
>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
193
|
+
aria-label=${`Forhåndsvis bilde ${u}`}
|
|
194
|
+
?disabled=${!p}
|
|
195
|
+
@click=${()=>{!p||!c||c(r.fileId)}}
|
|
196
|
+
>
|
|
197
|
+
<span class="pkt-btn__text">
|
|
198
|
+
${f?e.d`<pkt-icon
|
|
199
|
+
name="expand"
|
|
200
|
+
class="pkt-fileupload__queue-display__item__thumbnail__expand-icon"
|
|
201
|
+
aria-hidden="true"
|
|
202
|
+
></pkt-icon>`:null}
|
|
203
|
+
${d?e.d`<img
|
|
204
|
+
src=${n.t(i)}
|
|
205
|
+
alt=${u}
|
|
206
|
+
@error=${()=>l?.(r.fileId)}
|
|
207
|
+
/>`:e.d`<pkt-icon
|
|
208
|
+
name="document-text"
|
|
209
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
210
|
+
aria-hidden="true"
|
|
211
|
+
></pkt-icon>`}
|
|
212
|
+
</span>
|
|
213
|
+
</button>
|
|
214
|
+
<span class="pkt-fileupload__queue-display__item__thumbnail__title"
|
|
215
|
+
>${P(u,s)}</span
|
|
216
|
+
>
|
|
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.d`
|
|
219
|
+
<li
|
|
220
|
+
class=${t.t({"pkt-fileupload__queue-display__item":!0,"pkt-fileupload__queue-display__item--in-progress":y===`in-progress`,"pkt-fileupload__queue-display__item--error":y===`error`,[`pkt-fileupload__queue-display__item--${f}`]:typeof f==`string`})}
|
|
221
|
+
>
|
|
222
|
+
${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.d`
|
|
224
|
+
<pkt-icon
|
|
225
|
+
name="document-text"
|
|
226
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
227
|
+
aria-hidden="true"
|
|
228
|
+
></pkt-icon>
|
|
229
|
+
<div class="pkt-fileupload__queue-display__item__inline-ui">
|
|
230
|
+
${x}
|
|
231
|
+
</div>
|
|
232
|
+
`: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}
|
|
234
|
+
${y===`idle`?H({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
235
|
+
${y===`idle`?U({file:n,disabled:i,inputName:r,operations:o,activeOperationId:s,onActivateOperation:c,onCloseOperation:l,getFileAttribute:u,setFileAttribute:d}):null}
|
|
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.d`
|
|
238
|
+
<li
|
|
239
|
+
class=${t.t({"pkt-fileupload__queue-display__item":!0,"pkt-fileupload__queue-display__item--in-progress":w===`in-progress`,"pkt-fileupload__queue-display__item--error":w===`error`,[`pkt-fileupload__queue-display__item--${h}`]:typeof h==`string`})}
|
|
240
|
+
>
|
|
241
|
+
${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.d`
|
|
243
|
+
<pkt-icon
|
|
244
|
+
name="picture"
|
|
245
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
246
|
+
aria-hidden="true"
|
|
247
|
+
></pkt-icon>
|
|
248
|
+
<div class="pkt-fileupload__queue-display__item__inline-ui">
|
|
249
|
+
${E}
|
|
250
|
+
</div>
|
|
251
|
+
`: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}
|
|
253
|
+
${w===`idle`?H({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
254
|
+
${w===`idle`?U({file:n,disabled:i,inputName:r,operations:l,activeOperationId:u,onActivateOperation:d,onCloseOperation:f,getFileAttribute:p,setFileAttribute:m}):null}
|
|
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.d`
|
|
257
|
+
<pkt-input-wrapper
|
|
258
|
+
.forId=${`${this.id}-input`}
|
|
259
|
+
.label=${this.label}
|
|
260
|
+
.helptext=${this.helptext}
|
|
261
|
+
?disabled=${this.disabled}
|
|
262
|
+
?hasError=${this.hasEffectiveError}
|
|
263
|
+
?optionalTag=${this.optionalTag}
|
|
264
|
+
?requiredTag=${this.requiredTag}
|
|
265
|
+
class=${t.t({"pkt-fileupload-wrapper":!0,"pkt-fileupload-wrapper--full-width":this.fullwidth})}
|
|
266
|
+
>
|
|
267
|
+
${n}
|
|
268
|
+
</pkt-input-wrapper>
|
|
269
|
+
`:n}renderContent(){let r=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(r),o=this.getSupportedFormatsText(),s=[!this.label&&this.helptext?`${this.id}-helptext`:void 0,this.hasEffectiveError?`${this.id}-error`:void 0].filter(Boolean).join(` `)||void 0,c=this.itemRenderer===`thumbnail`?this.multiple?{dragInactive:a.dropZoneDragMultipleThumbnail,dragActive:a.dropZoneDragActiveMultipleThumbnail,openFileDialog:a.dropZoneOpenFileDialogMultipleThumbnail}:{dragInactive:a.dropZoneDragSingleThumbnail,dragActive:a.dropZoneDragActiveSingleThumbnail,openFileDialog:a.dropZoneOpenFileDialogSingleThumbnail}:this.multiple?{dragInactive:a.dropZoneDragMultiple,dragActive:a.dropZoneDragActiveMultiple,openFileDialog:a.dropZoneOpenFileDialogMultiple}:{dragInactive:a.dropZoneDragSingle,dragActive:a.dropZoneDragActiveSingle,openFileDialog:a.dropZoneOpenFileDialogSingle};return e.d`
|
|
270
|
+
<div
|
|
271
|
+
class=${t.t({"pkt-fileupload":!0,"pkt-fileupload--full-width":this.fullwidth,"pkt-fileupload--error":this.hasEffectiveError,"pkt-fileupload--disabled":this.disabled})}
|
|
272
|
+
aria-disabled=${String(this.disabled)}
|
|
273
|
+
?inert=${this.disabled}
|
|
274
|
+
>
|
|
275
|
+
<div class="pkt-sr-only" aria-live="polite" aria-atomic="true">
|
|
276
|
+
${this.getSrUploadedMessage()}
|
|
277
|
+
</div>
|
|
278
|
+
<div class="pkt-sr-only" aria-live="assertive" aria-atomic="true">
|
|
279
|
+
${this.getSrErrorsMessage()}
|
|
280
|
+
</div>
|
|
281
|
+
<div
|
|
282
|
+
class=${t.t({"pkt-fileupload__drop-zone":!0,"pkt-fileupload__drop-zone--drag-active":this.isDragActive,"pkt-fileupload__drop-zone--disabled":this.disabled})}
|
|
283
|
+
@dragover=${this.onDragOver}
|
|
284
|
+
@dragleave=${this.onDragLeave}
|
|
285
|
+
@drop=${this.onDrop}
|
|
286
|
+
@click=${this.onDropZoneClick}
|
|
287
|
+
>
|
|
288
|
+
<input
|
|
289
|
+
id=${`${this.id}-input`}
|
|
290
|
+
type="file"
|
|
291
|
+
name=${n.t(this.uploadStrategy===`form`?this.name:void 0)}
|
|
292
|
+
?multiple=${this.multiple}
|
|
293
|
+
?disabled=${this.disabled}
|
|
294
|
+
?required=${this.required&&this.uploadStrategy===`form`}
|
|
295
|
+
accept=${this.getResolvedAcceptValue()}
|
|
296
|
+
aria-label=${n.t(this.label?void 0:this.multiple?`Velg filer`:`Velg fil`)}
|
|
297
|
+
aria-required=${n.t(this.required?`true`:void 0)}
|
|
298
|
+
aria-invalid=${n.t(this.hasEffectiveError?`true`:void 0)}
|
|
299
|
+
aria-describedby=${n.t(s)}
|
|
300
|
+
@change=${this.onNativeFileChange}
|
|
301
|
+
/>
|
|
302
|
+
${this.uploadStrategy===`custom`?r.map(t=>e.d`<input type="hidden" name=${this.name} value=${t.fileId} />`):null}
|
|
303
|
+
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
304
|
+
<pkt-icon
|
|
305
|
+
name="attachment"
|
|
306
|
+
class="pkt-fileupload__drop-zone__placeholder__icon"
|
|
307
|
+
aria-hidden="true"
|
|
308
|
+
></pkt-icon>
|
|
309
|
+
<p class="pkt-fileupload__drop-zone__placeholder__title">
|
|
310
|
+
${this.isDragActive?`${c.dragActive} ...`:e.d`${c.dragInactive}
|
|
311
|
+
<button
|
|
312
|
+
type="button"
|
|
313
|
+
class="pkt-fileupload__drop-zone__placeholder__title__open-file-dialog"
|
|
314
|
+
@click=${this.openFileDialog}
|
|
315
|
+
>
|
|
316
|
+
${c.openFileDialog}
|
|
317
|
+
</button>`}
|
|
318
|
+
</p>
|
|
319
|
+
${o?e.d`<p class="pkt-fileupload__drop-zone__placeholder__formats">
|
|
320
|
+
${a.supportedFormatsPrefix} ${o}
|
|
321
|
+
</p>`:null}
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
${this.hasEffectiveError?e.d`
|
|
325
|
+
<pkt-alert
|
|
326
|
+
skin="error"
|
|
327
|
+
role="alert"
|
|
328
|
+
aria-live="assertive"
|
|
329
|
+
compact
|
|
330
|
+
id=${`${this.id}-error`}
|
|
331
|
+
class="pkt-alert--error pkt-fileupload__error-alert"
|
|
332
|
+
>
|
|
333
|
+
${this.effectiveErrorMessage}
|
|
334
|
+
</pkt-alert>
|
|
335
|
+
`:null}
|
|
336
|
+
${r.length>0?e.d`<ul class="pkt-fileupload__queue-display">
|
|
337
|
+
${r.map(e=>this.renderQueueItem(e,i))}
|
|
338
|
+
</ul>`:null}
|
|
339
|
+
${this.renderPreviewModal(i)}
|
|
340
|
+
</div>
|
|
341
|
+
`}renderQueueItem(e,t){let n=typeof e.file?.size==`number`?this.formatFileSize(e.file.size):``,r=this.getQueueItemOperations();if(this.itemRenderer===`thumbnail`){let i=this.canOpenPreview(e),a=this.failedImageFileIds[e.fileId]?.thumbnail?void 0:this.getThumbnailUrl(e);return J({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),thumbnailUrl:a,previewEnabled:this.enableImagePreview,canOpenPreview:i,transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e),onOpenPreview:e=>this.openPreview(e,t),onThumbnailImageError:e=>this.markImageFailed(e,`thumbnail`)})}return q({file:e,inputName:this.name,disabled:this.disabled,fileSize:n,operations:r,activeOperationId:this.activeOperationByFileId[e.fileId],onActivateOperation:(e,t)=>this.activateOperation(e,t),onCloseOperation:e=>this.closeOperation(e),getFileAttribute:(e,t)=>this.getFileAttribute(e,t),setFileAttribute:(e,t,n)=>this.setFileAttribute(e,t,n),transferProgress:e.progress,transferErrorMessage:e.errorMessage,transferShowProgress:e.showProgress,transferLastProgress:e.lastProgress,loadingText:`Laster opp`,truncateTail:this.truncateTail,onCancel:e=>this.cancelTransfer(e)})}markImageFailed(e,t){this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],[t]:!0}}}getPreviewableImages(e){return this.enableImagePreview?e.filter(e=>e.progress===`done`&&this.isImageFile(e)):[]}canOpenPreview(e){return this.enableImagePreview&&e.progress===`done`&&this.isImageFile(e)}openPreview(e,t){let n=t.findIndex(t=>t.fileId===e);n<0||(this.previewCurrentIndex=n,this.isPreviewModalOpen=!0,this.failedImageFileIds={...this.failedImageFileIds,[e]:{...this.failedImageFileIds[e],preview:!1}})}navigatePreview(e,t){t.length!==0&&(this.previewCurrentIndex=C(this.previewCurrentIndex,e,t.length))}renderPreviewModal(t){if(!this.enableImagePreview||t.length===0)return null;let n=t[this.previewCurrentIndex];if(!n)return null;let r=t.length>1,i=this.getThumbnailUrl(n),a=!!i&&!this.failedImageFileIds[n.fileId]?.preview,o=n.attributes?.targetFilename||n.file?.name||`Forhåndsvisning`;return e.d`
|
|
342
|
+
<pkt-modal
|
|
343
|
+
.open=${this.isPreviewModalOpen}
|
|
344
|
+
.headingText=${o}
|
|
345
|
+
closeOnBackdropClick
|
|
346
|
+
class="pkt-fileupload__image-preview-modal"
|
|
347
|
+
@close=${this.closePreview}
|
|
348
|
+
@keydown=${e=>this.onPreviewKeyDown(e,t)}
|
|
349
|
+
>
|
|
350
|
+
<div class="pkt-fileupload__image-preview">
|
|
351
|
+
${r?e.d`<button
|
|
352
|
+
type="button"
|
|
353
|
+
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--prev pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
354
|
+
aria-label=${`Forrige bilde ${this.previewCurrentIndex} / ${t.length}`}
|
|
355
|
+
@click=${()=>this.navigatePreview(`prev`,t)}
|
|
356
|
+
>
|
|
357
|
+
<pkt-icon
|
|
358
|
+
class="pkt-btn__icon pkt-icon"
|
|
359
|
+
name="chevron-thin-left"
|
|
360
|
+
aria-hidden="true"
|
|
361
|
+
></pkt-icon>
|
|
362
|
+
<span class="pkt-btn__text"></span>
|
|
363
|
+
</button>`:null}
|
|
364
|
+
|
|
365
|
+
<div class="pkt-fileupload__image-preview__content">
|
|
366
|
+
${a?e.d`<img
|
|
367
|
+
src=${i}
|
|
368
|
+
alt=${`${o} - ${this.previewCurrentIndex+1} av ${t.length}`}
|
|
369
|
+
class="pkt-fileupload__image-preview__image"
|
|
370
|
+
@error=${()=>this.markImageFailed(n.fileId,`preview`)}
|
|
371
|
+
/>`:e.d`<pkt-icon
|
|
372
|
+
name="picture"
|
|
373
|
+
class="pkt-fileupload__queue-display__item__icon pkt-icon--medium"
|
|
374
|
+
aria-hidden="true"
|
|
375
|
+
></pkt-icon>`}
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
${r?e.d`<span class="pkt-fileupload__image-preview__counter">
|
|
379
|
+
${this.previewCurrentIndex+1} / ${t.length}
|
|
380
|
+
</span>`:null}
|
|
381
|
+
${r?e.d`<button
|
|
382
|
+
type="button"
|
|
383
|
+
class="pkt-fileupload__image-preview__nav pkt-fileupload__image-preview__nav--next pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--icon-only"
|
|
384
|
+
aria-label=${`Neste bilde ${this.previewCurrentIndex+2} / ${t.length}`}
|
|
385
|
+
@click=${()=>this.navigatePreview(`next`,t)}
|
|
386
|
+
>
|
|
387
|
+
<pkt-icon
|
|
388
|
+
class="pkt-btn__icon pkt-icon"
|
|
389
|
+
name="chevron-thin-right"
|
|
390
|
+
aria-hidden="true"
|
|
391
|
+
></pkt-icon>
|
|
392
|
+
<span class="pkt-btn__text"></span>
|
|
393
|
+
</button>`:null}
|
|
394
|
+
</div>
|
|
395
|
+
</pkt-modal>
|
|
396
|
+
`}getQueueItemOperations(){let e=[];return this.renameFilesEnabled&&this.itemRenderer!==`thumbnail`&&e.push(M()),this.addCommentsEnabled&&this.itemRenderer!==`thumbnail`&&e.push(N()),e.push(...this.extraOperations),e.push(j(e=>this.removeFileItem(e))),e}activateOperation(e,t){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:t}}closeOperation(e){this.activeOperationByFileId={...this.activeOperationByFileId,[e]:void 0}}getFileAttribute(e,t){let n=this.getCurrentFiles().find(t=>t.fileId===e);if(n)return n.attributes?.[t]??void 0}setFileAttribute(e,t,n){let r=this.getCurrentFiles().find(t=>t.fileId===e);if(!r)return;let i={...r.attributes,[t]:n};n===void 0&&delete i[t],this.updateFileItem(e,{attributes:i})}};e.r([e.o()],Y.prototype,`activeOperationByFileId`,void 0),e.r([e.o()],Y.prototype,`isPreviewModalOpen`,void 0),e.r([e.o()],Y.prototype,`previewCurrentIndex`,void 0),e.r([e.o()],Y.prototype,`failedImageFileIds`,void 0),Y=e.r([e.c(`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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`);require(`./button-D-TOBaJB.cjs`);const i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./booleanish-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`);require(`./icon-Dr8sfT2X.cjs`);const r=require(`./if-defined-XKOD_t_V.cjs`);require(`./button-D-TOBaJB.cjs`);const i=require(`./ref-BaJ0mBT_.cjs`),a=require(`./booleanish-B5EFqFpJ.cjs`);require(`./link-B8zYc5WK.cjs`),require(`./textinput-B0VWmVIF.cjs`);var o=e=>typeof e.target==`string`?{title:e.title,iconName:e.iconName,href:e.target}:{title:e.title,iconName:e.iconName,onClick:e.target},s=e=>o(e),c=e=>{if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!isNaN(t.getTime()))return t.toLocaleDateString(`nb-NO`,{day:`numeric`,month:`long`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})},l=class extends e.t{constructor(...e){super(...e),this.canChangeRepresentation=!1,this.logoutOnClick=!1}handleChangeRepresentation(){this.dispatchEvent(new CustomEvent(`change-representation`,{bubbles:!0,composed:!0}))}handleLogout(){this.dispatchEvent(new CustomEvent(`log-out`,{bubbles:!0,composed:!0}))}handleMenuItemClick(e){`onClick`in e&&typeof e.onClick==`function`&&e.onClick()}renderLinkOrButton(n,r){let i=`href`in n,a=t.t({"pkt-user-menu__link":!0,"pkt-link-button":!i,"pkt-link":!i,"pkt-link--icon-left":!i,[r||``]:!!r});return i?e.d`
|
|
2
2
|
<pkt-link
|
|
3
3
|
icon-name=${n.iconName||e.l}
|
|
4
4
|
href=${n.href}
|
|
@@ -5,9 +5,9 @@ import "./icon-Co72KtgF.js";
|
|
|
5
5
|
import { t as u } from "./if-defined-Cjj8qN-Z.js";
|
|
6
6
|
import "./button-BIpd1xJh.js";
|
|
7
7
|
import { n as d, t as f } from "./ref-RS8Uv6uC.js";
|
|
8
|
-
import { t as p } from "./booleanish-
|
|
9
|
-
import "./link-
|
|
10
|
-
import "./textinput-
|
|
8
|
+
import { t as p } from "./booleanish-CRaKZ75t.js";
|
|
9
|
+
import "./link-CjJcwcxR.js";
|
|
10
|
+
import "./textinput-CxzAxM8E.js";
|
|
11
11
|
//#region ../../shared-types/header.ts
|
|
12
12
|
var m = (e) => typeof e.target == "string" ? {
|
|
13
13
|
title: e.title,
|
|
@@ -2,8 +2,8 @@ import { c as e, d as t, l as n, o as r, r as i, s as a } from "./element-cZ85T_
|
|
|
2
2
|
import { t as o } from "./class-map-C8HuhNzZ.js";
|
|
3
3
|
import { n as s, t as c } from "./element-with-slot-4J2o3SeU.js";
|
|
4
4
|
import { r as l } from "./icon-Co72KtgF.js";
|
|
5
|
-
import { n as u } from "./utils-
|
|
6
|
-
import { t as d } from "./input-wrapper-
|
|
5
|
+
import { n as u } from "./utils-BOOZ0ppt.js";
|
|
6
|
+
import { t as d } from "./input-wrapper-kw2y6Jp_.js";
|
|
7
7
|
//#region src/components/helptext/helptext.ts
|
|
8
8
|
var f = class extends c {
|
|
9
9
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`),r=require(`./icon-Dr8sfT2X.cjs`),i=require(`./utils-
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`),r=require(`./icon-Dr8sfT2X.cjs`),i=require(`./utils-CM67Oudc.cjs`),a=require(`./input-wrapper-CYCCx8MP.cjs`);var o=class extends n.t{constructor(...e){super(...e),this.forId=i.n(),this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=a.t.props.helptextDropdownButton.default,this.isHelpTextOpen=!1}render(){let i=()=>{let e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!0,detail:{isOpen:e}}))},a=t.t({"pkt-inputwrapper__helptext-container":!0,"pkt-inputwrapper__has-helptext":this.helptext||this.helptextDropdown||this.hasSlotContent()});return e.d`${e.d`<div class="${a}">
|
|
2
2
|
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
|
|
3
3
|
<div class="pkt-contents" name="helptext">${n.n(this)}</div>
|
|
4
4
|
${this.helptext&&r.r(this.helptext)}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as e, r as t, s as n } from "./element-cZ85T_aa.js";
|
|
2
2
|
import { t as r } from "./element-with-slot-4J2o3SeU.js";
|
|
3
|
-
import { n as i } from "./utils-
|
|
4
|
-
import { t as a } from "./booleanish-
|
|
5
|
-
import { t as o } from "./input-wrapper-
|
|
3
|
+
import { n as i } from "./utils-BOOZ0ppt.js";
|
|
4
|
+
import { t as a } from "./booleanish-CRaKZ75t.js";
|
|
5
|
+
import { t as o } from "./input-wrapper-kw2y6Jp_.js";
|
|
6
6
|
//#region ../../node_modules/element-internals-polyfill/dist/index.js
|
|
7
7
|
(function(e) {
|
|
8
8
|
let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), g = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./element-with-slot-CWoTGA1B.cjs`),n=require(`./utils-CjAbIttF.cjs`),r=require(`./booleanish-jJLlnr6-.cjs`),i=require(`./input-wrapper-Dwd-_sKm.cjs`);(function(e){"use strict";let t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap,g={ariaAtomic:`aria-atomic`,ariaAutoComplete:`aria-autocomplete`,ariaBusy:`aria-busy`,ariaChecked:`aria-checked`,ariaColCount:`aria-colcount`,ariaColIndex:`aria-colindex`,ariaColIndexText:`aria-colindextext`,ariaColSpan:`aria-colspan`,ariaCurrent:`aria-current`,ariaDescription:`aria-description`,ariaDisabled:`aria-disabled`,ariaExpanded:`aria-expanded`,ariaHasPopup:`aria-haspopup`,ariaHidden:`aria-hidden`,ariaInvalid:`aria-invalid`,ariaKeyShortcuts:`aria-keyshortcuts`,ariaLabel:`aria-label`,ariaLevel:`aria-level`,ariaLive:`aria-live`,ariaModal:`aria-modal`,ariaMultiLine:`aria-multiline`,ariaMultiSelectable:`aria-multiselectable`,ariaOrientation:`aria-orientation`,ariaPlaceholder:`aria-placeholder`,ariaPosInSet:`aria-posinset`,ariaPressed:`aria-pressed`,ariaReadOnly:`aria-readonly`,ariaRelevant:`aria-relevant`,ariaRequired:`aria-required`,ariaRoleDescription:`aria-roledescription`,ariaRowCount:`aria-rowcount`,ariaRowIndex:`aria-rowindex`,ariaRowIndexText:`aria-rowindextext`,ariaRowSpan:`aria-rowspan`,ariaSelected:`aria-selected`,ariaSetSize:`aria-setsize`,ariaSort:`aria-sort`,ariaValueMax:`aria-valuemax`,ariaValueMin:`aria-valuemin`,ariaValueNow:`aria-valuenow`,ariaValueText:`aria-valuetext`,role:`role`},_=(e,t)=>{for(let n in g){t[n]=null;let r=null,i=g[n];Object.defineProperty(t,n,{get(){return r},set(n){r=n,e.isConnected?T(e,i,n):u.set(e,t)}})}};function v(e){let t=i.get(e),{form:n}=t;P(e,n,t),A(e,t.labels)}let y=(e,t=!1)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return i.has(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode(),a=!t||e.disabled;for(;r;)r.formDisabledCallback&&a&&E(r,e.disabled),r=n.nextNode()},b={attributes:!0,attributeFilter:[`disabled`,`name`]},x=z()?new MutationObserver(e=>{for(let t of e){let e=t.target;if(t.attributeName===`disabled`&&(e.constructor.formAssociated?E(e,e.hasAttribute(`disabled`)):e.localName===`fieldset`&&y(e)),t.attributeName===`name`&&e.constructor.formAssociated){let t=i.get(e),n=l.get(e);t.setFormValue(n)}}}):{};function S(e){e.forEach(e=>{let{addedNodes:t,removedNodes:n}=e,a=Array.from(t),o=Array.from(n);a.forEach(e=>{var t;if(i.has(e)&&e.constructor.formAssociated&&v(e),u.has(e)){let t=u.get(e);Object.keys(g).filter(e=>t[e]!==null).forEach(n=>{T(e,g[n],t[n])}),u.delete(e)}if(h.has(e)){let t=h.get(e);T(e,`internals-valid`,t.validity.valid.toString()),T(e,`internals-invalid`,(!t.validity.valid).toString()),T(e,`aria-invalid`,(!t.validity.valid).toString()),h.delete(e)}if(e.localName===`form`){let t=c.get(e),n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return i.has(e)&&e.constructor.formAssociated&&!(t&&t.has(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode();for(;r;)v(r),r=n.nextNode()}e.localName===`fieldset`&&((t=x.observe)==null||t.call(x,e,b),y(e,!0))}),o.forEach(e=>{let t=i.get(e);t&&r.get(t)&&D(t),s.has(e)&&s.get(e).disconnect()})})}function C(e){e.forEach(e=>{let{removedNodes:t}=e;t.forEach(t=>{let n=p.get(e.target);i.has(t)&&R(t),n.disconnect()})})}let ee=e=>{var t;let n=new MutationObserver(C);(window==null?void 0:window.ShadyDOM)?.inUse&&e.mode&&e.host&&(e=e.host),(t=n.observe)==null||t.call(n,e,{childList:!0}),p.set(e,n)};z()&&new MutationObserver(S);let w={childList:!0,subtree:!0},T=(e,t,n)=>{e.getAttribute(t)!==n&&e.setAttribute(t,n)},E=(e,t)=>{e.toggleAttribute(`internals-disabled`,t),t?T(e,`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.formDisabledCallback&&e.formDisabledCallback.apply(e,[t])},D=e=>{r.get(e).forEach(e=>{e.remove()}),r.set(e,[])},O=(e,t)=>{let n=document.createElement(`input`);return n.type=`hidden`,n.name=e.getAttribute(`name`),e.after(n),r.get(t).push(n),n},k=(e,t)=>{var n;r.set(t,[]),(n=x.observe)==null||n.call(x,e,b)},A=(e,t)=>{if(t.length){Array.from(t).forEach(t=>t.addEventListener(`click`,e.click.bind(e)));let n=t[0].id;t[0].id||(n=`${t[0].htmlFor}_Label`,t[0].id=n),T(e,`aria-labelledby`,n)}},j=e=>{let t=Array.from(e.elements).filter(e=>!e.tagName.includes(`-`)&&e.validity).map(e=>e.validity.valid),n=c.get(e)||[],r=Array.from(n).filter(e=>e.isConnected).map(e=>i.get(e).validity.valid),a=[...t,...r].includes(!1);e.toggleAttribute(`internals-invalid`,a),e.toggleAttribute(`internals-valid`,!a)},M=e=>{j(F(e.target))},N=e=>{j(F(e.target))},te=e=>{let t=[`button[type=submit]`,`input[type=submit]`,`button:not([type])`].map(e=>`${e}:not([disabled])`).map(t=>`${t}:not([form])${e.id?`,${t}[form='${e.id}']`:``}`).join(`,`);e.addEventListener(`click`,n=>{if(n.target.closest(t)){let t=c.get(e);if(e.noValidate)return;t.size&&Array.from(t).reverse().map(e=>i.get(e).reportValidity()).includes(!1)&&n.preventDefault()}})},ne=e=>{let t=c.get(e.target);t&&t.size&&t.forEach(e=>{e.constructor.formAssociated&&e.formResetCallback&&e.formResetCallback.apply(e)})},P=(e,t,n)=>{if(t){let r=c.get(t);if(r)r.add(e);else{let n=new Set;n.add(e),c.set(t,n),te(t),t.addEventListener(`reset`,ne),t.addEventListener(`input`,M),t.addEventListener(`change`,N)}o.set(t,{ref:e,internals:n}),e.constructor.formAssociated&&e.formAssociatedCallback&&setTimeout(()=>{e.formAssociatedCallback.apply(e,[t])},0),j(t)}},F=e=>{let t=e.parentNode;return t&&t.tagName!==`FORM`&&(t=F(t)),t},I=(e,t,n=DOMException)=>{if(!e.constructor.formAssociated)throw new n(t)},L=(e,t,n)=>{let r=c.get(e);return r&&r.size&&r.forEach(e=>{i.get(e)[n]()||(t=!1)}),t},R=e=>{if(e.constructor.formAssociated){let t=i.get(e),{labels:n,form:r}=t;A(e,n),P(e,r,t)}};function z(){return typeof MutationObserver<`u`}class B{constructor(){this.badInput=!1,this.customError=!1,this.patternMismatch=!1,this.rangeOverflow=!1,this.rangeUnderflow=!1,this.stepMismatch=!1,this.tooLong=!1,this.tooShort=!1,this.typeMismatch=!1,this.valid=!0,this.valueMissing=!1,Object.seal(this)}}let re=e=>(e.badInput=!1,e.customError=!1,e.patternMismatch=!1,e.rangeOverflow=!1,e.rangeUnderflow=!1,e.stepMismatch=!1,e.tooLong=!1,e.tooShort=!1,e.typeMismatch=!1,e.valid=!0,e.valueMissing=!1,e),ie=(e,t,n)=>(e.valid=V(t),Object.keys(t).forEach(n=>e[n]=t[n]),n&&j(n),e),V=e=>{let t=!0;for(let n in e)n!==`valid`&&e[n]!==!1&&(t=!1);return t},H=new WeakMap;function U(e,t){e.toggleAttribute(t,!0),e.part&&e.part.add(t)}class W extends Set{static get isPolyfilled(){return!0}constructor(e){if(super(),!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);H.set(this,e)}add(e){if(!/^--/.test(e)||typeof e!=`string`)throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);let t=super.add(e),n=H.get(this),r=`state${e}`;return n.isConnected?U(n,r):setTimeout(()=>{U(n,r)}),t}clear(){for(let[e]of this.entries())this.delete(e);super.clear()}delete(e){let t=super.delete(e),n=H.get(this);return n.isConnected?(n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)):setTimeout(()=>{n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)}),t}}function G(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function K(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var q;class J{constructor(e){q.set(this,void 0),K(this,q,e,`f`);for(let t=0;t<e.length;t++){let n=e[t];this[t]=n,n.hasAttribute(`name`)&&(this[n.getAttribute(`name`)]=n)}Object.freeze(this)}get length(){return G(this,q,`f`).length}[(q=new WeakMap,Symbol.iterator)](){return G(this,q,`f`)[Symbol.iterator]()}item(e){return this[e]==null?null:this[e]}namedItem(e){return this[e]==null?null:this[e]}}function ae(){let e=HTMLFormElement.prototype.checkValidity;HTMLFormElement.prototype.checkValidity=n;let t=HTMLFormElement.prototype.reportValidity;HTMLFormElement.prototype.reportValidity=r;function n(...t){let n=e.apply(this,t);return L(this,n,`checkValidity`)}function r(...e){let n=t.apply(this,e);return L(this,n,`reportValidity`)}let{get:i}=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,`elements`,{get(...e){let t=i.call(this,...e),n=Array.from(c.get(this)||[]);return n.length===0?t:new J(Array.from(t).concat(n).sort((e,t)=>e.compareDocumentPosition?e.compareDocumentPosition(t)&2?1:-1:0))}})}class Y{static get isPolyfilled(){return!0}constructor(e){if(!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);let r=e.getRootNode(),a=new B;this.states=new W(e),t.set(this,e),n.set(this,a),i.set(e,this),_(e,this),k(e,this),Object.seal(this),r instanceof DocumentFragment&&ee(r)}checkValidity(){let e=t.get(this);if(I(e,`Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let r=n.get(this);if(!r.valid){let t=new Event(`invalid`,{bubbles:!1,cancelable:!0,composed:!1});e.dispatchEvent(t)}return r.valid}get form(){let e=t.get(this);I(e,`Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);let n;return e.constructor.formAssociated===!0&&(n=F(e)),n}get labels(){let e=t.get(this);I(e,`Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);let n=e.getAttribute(`id`),r=e.getRootNode();return r&&n?r.querySelectorAll(`[for="${n}"]`):[]}reportValidity(){let e=t.get(this);if(I(e,`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let n=this.checkValidity(),r=f.get(this);if(r&&!e.constructor.formAssociated)throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);return!n&&r&&(e.focus(),r.focus()),n}setFormValue(e){let n=t.get(this);if(I(n,`Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`),D(this),e!=null&&!(e instanceof FormData)){if(n.getAttribute(`name`)){let t=O(n,this);t.value=e}}else e!=null&&e instanceof FormData&&Array.from(e).reverse().forEach(([e,t])=>{if(typeof t==`string`){let r=O(n,this);r.name=e,r.value=t}});l.set(n,e)}setValidity(e,r,i){let o=t.get(this);if(I(o,`Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!e)throw TypeError(`Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.`);f.set(this,i);let s=n.get(this),c={};for(let t in e)c[t]=e[t];Object.keys(c).length===0&&re(s);let l=Object.assign(Object.assign({},s),c);delete l.valid;let{valid:u}=ie(s,l,this.form);if(!u&&!r)throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);a.set(this,u?``:r),o.isConnected?(o.toggleAttribute(`internals-invalid`,!u),o.toggleAttribute(`internals-valid`,u),T(o,`aria-invalid`,`${!u}`)):h.set(o,this)}get shadowRoot(){let e=t.get(this);return d.get(e)||null}get validationMessage(){return I(t.get(this),`Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`),a.get(this)}get validity(){return I(t.get(this),`Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`),n.get(this)}get willValidate(){let e=t.get(this);return I(e,`Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`),!(e.disabled||e.hasAttribute(`disabled`)||e.hasAttribute(`readonly`))}}function oe(){if(typeof window>`u`||!window.ElementInternals||!HTMLElement.prototype.attachInternals)return!1;class e extends HTMLElement{constructor(){super(),this.internals=this.attachInternals()}}let t=`element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g,``)}`;customElements.define(t,e);let n=new e;return[`shadowRoot`,`form`,`willValidate`,`validity`,`validationMessage`,`labels`,`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`].every(e=>e in n.internals)}let X=!1,Z=!1;function Q(e){Z||(Z=!0,window.CustomStateSet=W,e&&(HTMLElement.prototype.attachInternals=function(...t){let n=e.call(this,t);return n.states=new W(this),n}))}function $(e=!0){if(!X){if(X=!0,typeof window<`u`&&(window.ElementInternals=Y),typeof CustomElementRegistry<`u`){let e=CustomElementRegistry.prototype.define;CustomElementRegistry.prototype.define=function(t,n,r){if(n.formAssociated){let e=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){m.has(this)||(m.set(this,!0),this.hasAttribute(`disabled`)&&E(this,!0)),e?.apply(this),R(this)}}e.call(this,t,n,r)}}if(typeof HTMLElement<`u`&&(HTMLElement.prototype.attachInternals=function(){if(!this.tagName)return{};if(this.tagName.indexOf(`-`)===-1)throw Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);if(i.has(this))throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);return new Y(this)}),typeof Element<`u`){function e(...e){let n=t.apply(this,e);if(d.set(this,n),z()){let e=new MutationObserver(S);window.ShadyDOM?e.observe(this,w):e.observe(n,w),s.set(this,e)}return n}let t=Element.prototype.attachShadow;Element.prototype.attachShadow=e}z()&&typeof document<`u`&&new MutationObserver(S).observe(document.documentElement,w),typeof HTMLFormElement<`u`&&ae(),(e||typeof window<`u`&&!window.CustomStateSet)&&Q()}}return customElements.polyfillWrapFlushCallback||(oe()?typeof window<`u`&&!window.CustomStateSet&&Q(HTMLElement.prototype.attachInternals):$(!1)),e.forceCustomStateSetPolyfill=Q,e.forceElementInternalsPolyfill=$,Object.defineProperty(e,`__esModule`,{value:!0}),e})({});var a=`on`,o=`--checked`,s=`,`,c=class extends t.t{static get formAssociated(){return!0}constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.step=null,this.ariaDescribedBy=null,this.ariaLabelledby=null,this.name=``,this.pattern=null,this.placeholder=null,this.id=n.n(),this.counter=!1,this.hasError=!1,this.inline=!1,this.hasFieldset=!1,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=i.t.props.helptextDropdownButton.default,this.label=null,this.optionalText=e.i.forms.labels.optional,this.requiredText=e.i.forms.labels.required,this.tagText=null,this.dataTestid=``,this.touched=!1,this.internals=this.attachInternals()}manageValidity(t){if(!t){console.warn(`manageValidity called without valid input element`);return}this.required&&!this.value?this.internals.setValidity({valueMissing:!0},e.i.forms.messages.required,t):t.validity?.typeMismatch||t.validity?.badInput?this.internals.setValidity({typeMismatch:!0},e.i.forms.messages.invalid,t):t.validity?.patternMismatch?this.internals.setValidity({patternMismatch:!0},e.i.forms.messages.invalidPattern,t):t.validity?.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},e.i.forms.messages.tooShort,t):t.validity?.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},e.i.forms.messages.tooLong,t):t.validity?.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},this.min?e.i.forms.messages.rangeUnderflowMin.replace(`{min}`,this.min?.toString()):e.i.forms.messages.rangeUnderflow,t):t.validity?.stepMismatch?this.internals.setValidity({stepMismatch:!0},e.i.forms.messages.invalid,t):t.validity?.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},this.max?e.i.forms.messages.rangeOverflowMax.replace(`{max}`,this.max?.toString()):e.i.forms.messages.rangeOverflow,t):t.validity?.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({})}setFormValue(e){if(this.internals)if(Array.isArray(e)){let t=new FormData;e.forEach(e=>{t.append(this.name,e)}),this.internals.setFormValue(t)}else this.internals.setFormValue(e)}coordinateRadioGroup(){if(!this.form||!this.name||this.type!==`radio`)return;let e=`pkt-radiobutton[name="${this.name}"], input[type=radio][name="${this.name}"]`;this.form.querySelectorAll(e).forEach(e=>{if(e!==this&&e.getAttribute(`name`)===this.name&&e.getAttribute(`value`)!==this.value){let t=e;t.checked&&(t.checked=!1,t.internals&&(t.internals.setFormValue(null),t.internals.states?.delete(o)))}})}valueChecked(e){if(!this.touched)return;let t=this.internals.form||this.closest(`form`),n=t?new FormData(t):null;if(this.type===`radio`&&this.coordinateRadioGroup(),typeof e==`string`?(this.checked=e===`true`,this.internals.ariaChecked=String(e===`true`)):typeof e==`boolean`&&(this.checked=e,this.internals.ariaChecked=String(e)),this.checked){let e=(typeof this.value==`string`?this.value:``)||a;this.internals.setFormValue(e),n&&n.append(this.name,e),this.internals.states.add(o)}else this.internals.setFormValue(null),n&&n.delete(this.name),this.internals.states.delete(o);this.dispatchChangeEvents(this.checked),this.internals.reportValidity()}valueChanged(e,t){(t!==this.value||t!==this._value)&&(typeof e==`string`?((this.multiple||this.range)&&e.includes(s)&&(e=e.split(s)),this.value=e,this._value=Array.isArray(e)?e:[e]):Array.isArray(e)?(this.value=this.multiple||this.range?e:e[0],this._value=e):(this.value=``,this._value=[]),(!this.value||this.value.length===0)&&t&&t.length!==0?this.clearInputValue():this.value&&this.value.toString()!==t?.toString()&&this.onChange(this.value))}dispatchChangeEvents(e){this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e,bubbles:!0,composed:!0}))}clearInputValue(){let e=this.multiple||this.range?[]:``;this.value=e,this.setFormValue(e),this.dispatchChangeEvents(e)}onFocus(){this.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,composed:!0}))}onBlur(){this.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,composed:!0}))}onInput(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}normalizeValue(e){return(this.range||this.multiple)&&typeof e==`string`&&e.includes(s)?e.split(s):!this.multiple&&!this.range&&Array.isArray(e)?e[0]||``:e}validate(){this.inputRef?.value&&this.manageValidity(this.inputRef.value),this.inputRefTo?.value&&this.manageValidity(this.inputRefTo.value)}onChange(e){if(!this.touched){this.touched=!0,e&&this.setFormValue(e),this.validate();return}if(typeof e!=`string`&&!Array.isArray(e))return;let t=this.normalizeValue(e);this.setFormValue(t),this.validate(),this.dispatchChangeEvents(t)}formResetCallback(){if(this.touched=!1,this._options&&this._options.length&&this._options.forEach(e=>{`selected`in e&&(e.selected=!1)}),this.checked!==void 0)this.checked=!1,this.internals.ariaChecked=`false`,this.internals.setFormValue(``),this.inputRef?.value&&`checked`in this.inputRef.value&&(this.inputRef.value.checked=!1),this.valueChecked(this.checked);else{this.internals.setFormValue(``);let e=this.defaultValue||(this.multiple||this.range?[]:``);this.value=e,this._value=Array.isArray(e)?e:[e],this.valueChanged(this.value,null)}this.internals.ariaInvalid=`false`}updated(e){super.updated(e),e.has(`dataTestid`)&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute(`data-testid`)||this.setAttribute(`data-testid`,this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute(`data-testid`)))}firstUpdated(e){if(super.firstUpdated(e),this.form||=this.internals.form||this.closest(`form`),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.defaultChecked&&(this.internals.ariaChecked=`true`,this.checked=!0),this.required&&(this.internals.ariaRequired=`true`),this.disabled&&(this.internals.ariaDisabled=`true`),this.id&&!this.name&&(this.name=this.id),this.checked!==void 0){let e=this.checked===``||this.checked===`true`||this.checked===!0;this.internals.ariaChecked=String(e);let t=e?(typeof this.value==`string`?this.value:``)||a:null;this.internals.setFormValue(t)}else this.setFormValue(this.value);this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute(`form`,``),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute(`form`,``),this.manageValidity(this.inputRefTo.value))}};e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`checked`,void 0),e.r([e.s({type:Boolean})],c.prototype,`defaultChecked`,void 0),e.r([e.s({type:Boolean})],c.prototype,`multiple`,void 0),e.r([e.s({type:Boolean})],c.prototype,`range`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`type`,void 0),e.r([e.s()],c.prototype,`defaultValue`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`disabled`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`readonly`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`required`,void 0),e.r([e.s({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],c.prototype,`max`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`maxlength`,void 0),e.r([e.s({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],c.prototype,`min`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`minlength`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`step`,void 0),e.r([e.s({type:String})],c.prototype,`ariaDescribedBy`,void 0),e.r([e.s({type:String})],c.prototype,`ariaLabelledby`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`name`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`pattern`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`placeholder`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`id`,void 0),e.r([e.s({type:Boolean})],c.prototype,`counter`,void 0),e.r([e.s({type:Boolean})],c.prototype,`hasError`,void 0),e.r([e.s({type:Boolean})],c.prototype,`inline`,void 0),e.r([e.s({type:Boolean})],c.prototype,`hasFieldset`,void 0),e.r([e.s({type:Boolean})],c.prototype,`optionalTag`,void 0),e.r([e.s({type:Boolean})],c.prototype,`requiredTag`,void 0),e.r([e.s({type:Boolean})],c.prototype,`skipForwardTestid`,void 0),e.r([e.s({type:Boolean,reflect:!0,converter:r.t})],c.prototype,`useWrapper`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`fullwidth`,void 0),e.r([e.s({type:Number})],c.prototype,`counterMaxLength`,void 0),e.r([e.s({type:String})],c.prototype,`errorMessage`,void 0),e.r([e.s({type:String})],c.prototype,`helptext`,void 0),e.r([e.s({type:String})],c.prototype,`helptextDropdown`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`helptextDropdownButton`,void 0),e.r([e.s({type:String})],c.prototype,`label`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`optionalText`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`requiredText`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`tagText`,void 0),e.r([e.s({type:String,attribute:`data-testid`})],c.prototype,`dataTestid`,void 0),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
1
|
+
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./element-with-slot-CWoTGA1B.cjs`),n=require(`./utils-CM67Oudc.cjs`),r=require(`./booleanish-B5EFqFpJ.cjs`),i=require(`./input-wrapper-CYCCx8MP.cjs`);(function(e){"use strict";let t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=new WeakMap,g={ariaAtomic:`aria-atomic`,ariaAutoComplete:`aria-autocomplete`,ariaBusy:`aria-busy`,ariaChecked:`aria-checked`,ariaColCount:`aria-colcount`,ariaColIndex:`aria-colindex`,ariaColIndexText:`aria-colindextext`,ariaColSpan:`aria-colspan`,ariaCurrent:`aria-current`,ariaDescription:`aria-description`,ariaDisabled:`aria-disabled`,ariaExpanded:`aria-expanded`,ariaHasPopup:`aria-haspopup`,ariaHidden:`aria-hidden`,ariaInvalid:`aria-invalid`,ariaKeyShortcuts:`aria-keyshortcuts`,ariaLabel:`aria-label`,ariaLevel:`aria-level`,ariaLive:`aria-live`,ariaModal:`aria-modal`,ariaMultiLine:`aria-multiline`,ariaMultiSelectable:`aria-multiselectable`,ariaOrientation:`aria-orientation`,ariaPlaceholder:`aria-placeholder`,ariaPosInSet:`aria-posinset`,ariaPressed:`aria-pressed`,ariaReadOnly:`aria-readonly`,ariaRelevant:`aria-relevant`,ariaRequired:`aria-required`,ariaRoleDescription:`aria-roledescription`,ariaRowCount:`aria-rowcount`,ariaRowIndex:`aria-rowindex`,ariaRowIndexText:`aria-rowindextext`,ariaRowSpan:`aria-rowspan`,ariaSelected:`aria-selected`,ariaSetSize:`aria-setsize`,ariaSort:`aria-sort`,ariaValueMax:`aria-valuemax`,ariaValueMin:`aria-valuemin`,ariaValueNow:`aria-valuenow`,ariaValueText:`aria-valuetext`,role:`role`},_=(e,t)=>{for(let n in g){t[n]=null;let r=null,i=g[n];Object.defineProperty(t,n,{get(){return r},set(n){r=n,e.isConnected?T(e,i,n):u.set(e,t)}})}};function v(e){let t=i.get(e),{form:n}=t;P(e,n,t),A(e,t.labels)}let y=(e,t=!1)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return i.has(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode(),a=!t||e.disabled;for(;r;)r.formDisabledCallback&&a&&E(r,e.disabled),r=n.nextNode()},b={attributes:!0,attributeFilter:[`disabled`,`name`]},x=z()?new MutationObserver(e=>{for(let t of e){let e=t.target;if(t.attributeName===`disabled`&&(e.constructor.formAssociated?E(e,e.hasAttribute(`disabled`)):e.localName===`fieldset`&&y(e)),t.attributeName===`name`&&e.constructor.formAssociated){let t=i.get(e),n=l.get(e);t.setFormValue(n)}}}):{};function S(e){e.forEach(e=>{let{addedNodes:t,removedNodes:n}=e,a=Array.from(t),o=Array.from(n);a.forEach(e=>{var t;if(i.has(e)&&e.constructor.formAssociated&&v(e),u.has(e)){let t=u.get(e);Object.keys(g).filter(e=>t[e]!==null).forEach(n=>{T(e,g[n],t[n])}),u.delete(e)}if(h.has(e)){let t=h.get(e);T(e,`internals-valid`,t.validity.valid.toString()),T(e,`internals-invalid`,(!t.validity.valid).toString()),T(e,`aria-invalid`,(!t.validity.valid).toString()),h.delete(e)}if(e.localName===`form`){let t=c.get(e),n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return i.has(e)&&e.constructor.formAssociated&&!(t&&t.has(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=n.nextNode();for(;r;)v(r),r=n.nextNode()}e.localName===`fieldset`&&((t=x.observe)==null||t.call(x,e,b),y(e,!0))}),o.forEach(e=>{let t=i.get(e);t&&r.get(t)&&D(t),s.has(e)&&s.get(e).disconnect()})})}function C(e){e.forEach(e=>{let{removedNodes:t}=e;t.forEach(t=>{let n=p.get(e.target);i.has(t)&&R(t),n.disconnect()})})}let ee=e=>{var t;let n=new MutationObserver(C);(window==null?void 0:window.ShadyDOM)?.inUse&&e.mode&&e.host&&(e=e.host),(t=n.observe)==null||t.call(n,e,{childList:!0}),p.set(e,n)};z()&&new MutationObserver(S);let w={childList:!0,subtree:!0},T=(e,t,n)=>{e.getAttribute(t)!==n&&e.setAttribute(t,n)},E=(e,t)=>{e.toggleAttribute(`internals-disabled`,t),t?T(e,`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.formDisabledCallback&&e.formDisabledCallback.apply(e,[t])},D=e=>{r.get(e).forEach(e=>{e.remove()}),r.set(e,[])},O=(e,t)=>{let n=document.createElement(`input`);return n.type=`hidden`,n.name=e.getAttribute(`name`),e.after(n),r.get(t).push(n),n},k=(e,t)=>{var n;r.set(t,[]),(n=x.observe)==null||n.call(x,e,b)},A=(e,t)=>{if(t.length){Array.from(t).forEach(t=>t.addEventListener(`click`,e.click.bind(e)));let n=t[0].id;t[0].id||(n=`${t[0].htmlFor}_Label`,t[0].id=n),T(e,`aria-labelledby`,n)}},j=e=>{let t=Array.from(e.elements).filter(e=>!e.tagName.includes(`-`)&&e.validity).map(e=>e.validity.valid),n=c.get(e)||[],r=Array.from(n).filter(e=>e.isConnected).map(e=>i.get(e).validity.valid),a=[...t,...r].includes(!1);e.toggleAttribute(`internals-invalid`,a),e.toggleAttribute(`internals-valid`,!a)},M=e=>{j(F(e.target))},N=e=>{j(F(e.target))},te=e=>{let t=[`button[type=submit]`,`input[type=submit]`,`button:not([type])`].map(e=>`${e}:not([disabled])`).map(t=>`${t}:not([form])${e.id?`,${t}[form='${e.id}']`:``}`).join(`,`);e.addEventListener(`click`,n=>{if(n.target.closest(t)){let t=c.get(e);if(e.noValidate)return;t.size&&Array.from(t).reverse().map(e=>i.get(e).reportValidity()).includes(!1)&&n.preventDefault()}})},ne=e=>{let t=c.get(e.target);t&&t.size&&t.forEach(e=>{e.constructor.formAssociated&&e.formResetCallback&&e.formResetCallback.apply(e)})},P=(e,t,n)=>{if(t){let r=c.get(t);if(r)r.add(e);else{let n=new Set;n.add(e),c.set(t,n),te(t),t.addEventListener(`reset`,ne),t.addEventListener(`input`,M),t.addEventListener(`change`,N)}o.set(t,{ref:e,internals:n}),e.constructor.formAssociated&&e.formAssociatedCallback&&setTimeout(()=>{e.formAssociatedCallback.apply(e,[t])},0),j(t)}},F=e=>{let t=e.parentNode;return t&&t.tagName!==`FORM`&&(t=F(t)),t},I=(e,t,n=DOMException)=>{if(!e.constructor.formAssociated)throw new n(t)},L=(e,t,n)=>{let r=c.get(e);return r&&r.size&&r.forEach(e=>{i.get(e)[n]()||(t=!1)}),t},R=e=>{if(e.constructor.formAssociated){let t=i.get(e),{labels:n,form:r}=t;A(e,n),P(e,r,t)}};function z(){return typeof MutationObserver<`u`}class B{constructor(){this.badInput=!1,this.customError=!1,this.patternMismatch=!1,this.rangeOverflow=!1,this.rangeUnderflow=!1,this.stepMismatch=!1,this.tooLong=!1,this.tooShort=!1,this.typeMismatch=!1,this.valid=!0,this.valueMissing=!1,Object.seal(this)}}let re=e=>(e.badInput=!1,e.customError=!1,e.patternMismatch=!1,e.rangeOverflow=!1,e.rangeUnderflow=!1,e.stepMismatch=!1,e.tooLong=!1,e.tooShort=!1,e.typeMismatch=!1,e.valid=!0,e.valueMissing=!1,e),ie=(e,t,n)=>(e.valid=V(t),Object.keys(t).forEach(n=>e[n]=t[n]),n&&j(n),e),V=e=>{let t=!0;for(let n in e)n!==`valid`&&e[n]!==!1&&(t=!1);return t},H=new WeakMap;function U(e,t){e.toggleAttribute(t,!0),e.part&&e.part.add(t)}class W extends Set{static get isPolyfilled(){return!0}constructor(e){if(super(),!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);H.set(this,e)}add(e){if(!/^--/.test(e)||typeof e!=`string`)throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);let t=super.add(e),n=H.get(this),r=`state${e}`;return n.isConnected?U(n,r):setTimeout(()=>{U(n,r)}),t}clear(){for(let[e]of this.entries())this.delete(e);super.clear()}delete(e){let t=super.delete(e),n=H.get(this);return n.isConnected?(n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)):setTimeout(()=>{n.toggleAttribute(`state${e}`,!1),n.part&&n.part.remove(`state${e}`)}),t}}function G(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function K(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var q;class J{constructor(e){q.set(this,void 0),K(this,q,e,`f`);for(let t=0;t<e.length;t++){let n=e[t];this[t]=n,n.hasAttribute(`name`)&&(this[n.getAttribute(`name`)]=n)}Object.freeze(this)}get length(){return G(this,q,`f`).length}[(q=new WeakMap,Symbol.iterator)](){return G(this,q,`f`)[Symbol.iterator]()}item(e){return this[e]==null?null:this[e]}namedItem(e){return this[e]==null?null:this[e]}}function ae(){let e=HTMLFormElement.prototype.checkValidity;HTMLFormElement.prototype.checkValidity=n;let t=HTMLFormElement.prototype.reportValidity;HTMLFormElement.prototype.reportValidity=r;function n(...t){let n=e.apply(this,t);return L(this,n,`checkValidity`)}function r(...e){let n=t.apply(this,e);return L(this,n,`reportValidity`)}let{get:i}=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`);Object.defineProperty(HTMLFormElement.prototype,`elements`,{get(...e){let t=i.call(this,...e),n=Array.from(c.get(this)||[]);return n.length===0?t:new J(Array.from(t).concat(n).sort((e,t)=>e.compareDocumentPosition?e.compareDocumentPosition(t)&2?1:-1:0))}})}class Y{static get isPolyfilled(){return!0}constructor(e){if(!e||!e.tagName||e.tagName.indexOf(`-`)===-1)throw TypeError(`Illegal constructor`);let r=e.getRootNode(),a=new B;this.states=new W(e),t.set(this,e),n.set(this,a),i.set(e,this),_(e,this),k(e,this),Object.seal(this),r instanceof DocumentFragment&&ee(r)}checkValidity(){let e=t.get(this);if(I(e,`Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let r=n.get(this);if(!r.valid){let t=new Event(`invalid`,{bubbles:!1,cancelable:!0,composed:!1});e.dispatchEvent(t)}return r.valid}get form(){let e=t.get(this);I(e,`Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`);let n;return e.constructor.formAssociated===!0&&(n=F(e)),n}get labels(){let e=t.get(this);I(e,`Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`);let n=e.getAttribute(`id`),r=e.getRootNode();return r&&n?r.querySelectorAll(`[for="${n}"]`):[]}reportValidity(){let e=t.get(this);if(I(e,`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!this.willValidate)return!0;let n=this.checkValidity(),r=f.get(this);if(r&&!e.constructor.formAssociated)throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`);return!n&&r&&(e.focus(),r.focus()),n}setFormValue(e){let n=t.get(this);if(I(n,`Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`),D(this),e!=null&&!(e instanceof FormData)){if(n.getAttribute(`name`)){let t=O(n,this);t.value=e}}else e!=null&&e instanceof FormData&&Array.from(e).reverse().forEach(([e,t])=>{if(typeof t==`string`){let r=O(n,this);r.name=e,r.value=t}});l.set(n,e)}setValidity(e,r,i){let o=t.get(this);if(I(o,`Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`),!e)throw TypeError(`Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.`);f.set(this,i);let s=n.get(this),c={};for(let t in e)c[t]=e[t];Object.keys(c).length===0&&re(s);let l=Object.assign(Object.assign({},s),c);delete l.valid;let{valid:u}=ie(s,l,this.form);if(!u&&!r)throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`);a.set(this,u?``:r),o.isConnected?(o.toggleAttribute(`internals-invalid`,!u),o.toggleAttribute(`internals-valid`,u),T(o,`aria-invalid`,`${!u}`)):h.set(o,this)}get shadowRoot(){let e=t.get(this);return d.get(e)||null}get validationMessage(){return I(t.get(this),`Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`),a.get(this)}get validity(){return I(t.get(this),`Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`),n.get(this)}get willValidate(){let e=t.get(this);return I(e,`Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`),!(e.disabled||e.hasAttribute(`disabled`)||e.hasAttribute(`readonly`))}}function oe(){if(typeof window>`u`||!window.ElementInternals||!HTMLElement.prototype.attachInternals)return!1;class e extends HTMLElement{constructor(){super(),this.internals=this.attachInternals()}}let t=`element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g,``)}`;customElements.define(t,e);let n=new e;return[`shadowRoot`,`form`,`willValidate`,`validity`,`validationMessage`,`labels`,`setFormValue`,`setValidity`,`checkValidity`,`reportValidity`].every(e=>e in n.internals)}let X=!1,Z=!1;function Q(e){Z||(Z=!0,window.CustomStateSet=W,e&&(HTMLElement.prototype.attachInternals=function(...t){let n=e.call(this,t);return n.states=new W(this),n}))}function $(e=!0){if(!X){if(X=!0,typeof window<`u`&&(window.ElementInternals=Y),typeof CustomElementRegistry<`u`){let e=CustomElementRegistry.prototype.define;CustomElementRegistry.prototype.define=function(t,n,r){if(n.formAssociated){let e=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){m.has(this)||(m.set(this,!0),this.hasAttribute(`disabled`)&&E(this,!0)),e?.apply(this),R(this)}}e.call(this,t,n,r)}}if(typeof HTMLElement<`u`&&(HTMLElement.prototype.attachInternals=function(){if(!this.tagName)return{};if(this.tagName.indexOf(`-`)===-1)throw Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);if(i.has(this))throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);return new Y(this)}),typeof Element<`u`){function e(...e){let n=t.apply(this,e);if(d.set(this,n),z()){let e=new MutationObserver(S);window.ShadyDOM?e.observe(this,w):e.observe(n,w),s.set(this,e)}return n}let t=Element.prototype.attachShadow;Element.prototype.attachShadow=e}z()&&typeof document<`u`&&new MutationObserver(S).observe(document.documentElement,w),typeof HTMLFormElement<`u`&&ae(),(e||typeof window<`u`&&!window.CustomStateSet)&&Q()}}return customElements.polyfillWrapFlushCallback||(oe()?typeof window<`u`&&!window.CustomStateSet&&Q(HTMLElement.prototype.attachInternals):$(!1)),e.forceCustomStateSetPolyfill=Q,e.forceElementInternalsPolyfill=$,Object.defineProperty(e,`__esModule`,{value:!0}),e})({});var a=`on`,o=`--checked`,s=`,`,c=class extends t.t{static get formAssociated(){return!0}constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.step=null,this.ariaDescribedBy=null,this.ariaLabelledby=null,this.name=``,this.pattern=null,this.placeholder=null,this.id=n.n(),this.counter=!1,this.hasError=!1,this.inline=!1,this.hasFieldset=!1,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage=``,this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=i.t.props.helptextDropdownButton.default,this.label=null,this.optionalText=e.i.forms.labels.optional,this.requiredText=e.i.forms.labels.required,this.tagText=null,this.dataTestid=``,this.touched=!1,this.internals=this.attachInternals()}manageValidity(t){if(!t){console.warn(`manageValidity called without valid input element`);return}this.required&&!this.value?this.internals.setValidity({valueMissing:!0},e.i.forms.messages.required,t):t.validity?.typeMismatch||t.validity?.badInput?this.internals.setValidity({typeMismatch:!0},e.i.forms.messages.invalid,t):t.validity?.patternMismatch?this.internals.setValidity({patternMismatch:!0},e.i.forms.messages.invalidPattern,t):t.validity?.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},e.i.forms.messages.tooShort,t):t.validity?.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},e.i.forms.messages.tooLong,t):t.validity?.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},this.min?e.i.forms.messages.rangeUnderflowMin.replace(`{min}`,this.min?.toString()):e.i.forms.messages.rangeUnderflow,t):t.validity?.stepMismatch?this.internals.setValidity({stepMismatch:!0},e.i.forms.messages.invalid,t):t.validity?.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},this.max?e.i.forms.messages.rangeOverflowMax.replace(`{max}`,this.max?.toString()):e.i.forms.messages.rangeOverflow,t):t.validity?.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({})}setFormValue(e){if(this.internals)if(Array.isArray(e)){let t=new FormData;e.forEach(e=>{t.append(this.name,e)}),this.internals.setFormValue(t)}else this.internals.setFormValue(e)}coordinateRadioGroup(){if(!this.form||!this.name||this.type!==`radio`)return;let e=`pkt-radiobutton[name="${this.name}"], input[type=radio][name="${this.name}"]`;this.form.querySelectorAll(e).forEach(e=>{if(e!==this&&e.getAttribute(`name`)===this.name&&e.getAttribute(`value`)!==this.value){let t=e;t.checked&&(t.checked=!1,t.internals&&(t.internals.setFormValue(null),t.internals.states?.delete(o)))}})}valueChecked(e){if(!this.touched)return;let t=this.internals.form||this.closest(`form`),n=t?new FormData(t):null;if(this.type===`radio`&&this.coordinateRadioGroup(),typeof e==`string`?(this.checked=e===`true`,this.internals.ariaChecked=String(e===`true`)):typeof e==`boolean`&&(this.checked=e,this.internals.ariaChecked=String(e)),this.checked){let e=(typeof this.value==`string`?this.value:``)||a;this.internals.setFormValue(e),n&&n.append(this.name,e),this.internals.states.add(o)}else this.internals.setFormValue(null),n&&n.delete(this.name),this.internals.states.delete(o);this.dispatchChangeEvents(this.checked),this.internals.reportValidity()}valueChanged(e,t){(t!==this.value||t!==this._value)&&(typeof e==`string`?((this.multiple||this.range)&&e.includes(s)&&(e=e.split(s)),this.value=e,this._value=Array.isArray(e)?e:[e]):Array.isArray(e)?(this.value=this.multiple||this.range?e:e[0],this._value=e):(this.value=``,this._value=[]),(!this.value||this.value.length===0)&&t&&t.length!==0?this.clearInputValue():this.value&&this.value.toString()!==t?.toString()&&this.onChange(this.value))}dispatchChangeEvents(e){this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`value-change`,{detail:e,bubbles:!0,composed:!0}))}clearInputValue(){let e=this.multiple||this.range?[]:``;this.value=e,this.setFormValue(e),this.dispatchChangeEvents(e)}onFocus(){this.dispatchEvent(new FocusEvent(`focus`,{bubbles:!0,composed:!0}))}onBlur(){this.dispatchEvent(new FocusEvent(`blur`,{bubbles:!0,composed:!0}))}onInput(){this.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0}))}normalizeValue(e){return(this.range||this.multiple)&&typeof e==`string`&&e.includes(s)?e.split(s):!this.multiple&&!this.range&&Array.isArray(e)?e[0]||``:e}validate(){this.inputRef?.value&&this.manageValidity(this.inputRef.value),this.inputRefTo?.value&&this.manageValidity(this.inputRefTo.value)}onChange(e){if(!this.touched){this.touched=!0,e&&this.setFormValue(e),this.validate();return}if(typeof e!=`string`&&!Array.isArray(e))return;let t=this.normalizeValue(e);this.setFormValue(t),this.validate(),this.dispatchChangeEvents(t)}formResetCallback(){if(this.touched=!1,this._options&&this._options.length&&this._options.forEach(e=>{`selected`in e&&(e.selected=!1)}),this.checked!==void 0)this.checked=!1,this.internals.ariaChecked=`false`,this.internals.setFormValue(``),this.inputRef?.value&&`checked`in this.inputRef.value&&(this.inputRef.value.checked=!1),this.valueChecked(this.checked);else{this.internals.setFormValue(``);let e=this.defaultValue||(this.multiple||this.range?[]:``);this.value=e,this._value=Array.isArray(e)?e:[e],this.valueChanged(this.value,null)}this.internals.ariaInvalid=`false`}updated(e){super.updated(e),e.has(`dataTestid`)&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute(`data-testid`)||this.setAttribute(`data-testid`,this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute(`data-testid`)))}firstUpdated(e){if(super.firstUpdated(e),this.form||=this.internals.form||this.closest(`form`),this.value&&this.defaultValue===null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.defaultChecked&&(this.internals.ariaChecked=`true`,this.checked=!0),this.required&&(this.internals.ariaRequired=`true`),this.disabled&&(this.internals.ariaDisabled=`true`),this.id&&!this.name&&(this.name=this.id),this.checked!==void 0){let e=this.checked===``||this.checked===`true`||this.checked===!0;this.internals.ariaChecked=String(e);let t=e?(typeof this.value==`string`?this.value:``)||a:null;this.internals.setFormValue(t)}else this.setFormValue(this.value);this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute(`form`,``),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute(`form`,``),this.manageValidity(this.inputRefTo.value))}};e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`checked`,void 0),e.r([e.s({type:Boolean})],c.prototype,`defaultChecked`,void 0),e.r([e.s({type:Boolean})],c.prototype,`multiple`,void 0),e.r([e.s({type:Boolean})],c.prototype,`range`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`type`,void 0),e.r([e.s()],c.prototype,`defaultValue`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`disabled`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`readonly`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`required`,void 0),e.r([e.s({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],c.prototype,`max`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`maxlength`,void 0),e.r([e.s({reflect:!0,converter:{fromAttribute:e=>e,toAttribute:e=>e?.toString()??null}})],c.prototype,`min`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`minlength`,void 0),e.r([e.s({type:Number,reflect:!0})],c.prototype,`step`,void 0),e.r([e.s({type:String})],c.prototype,`ariaDescribedBy`,void 0),e.r([e.s({type:String})],c.prototype,`ariaLabelledby`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`name`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`pattern`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`placeholder`,void 0),e.r([e.s({type:String,reflect:!0})],c.prototype,`id`,void 0),e.r([e.s({type:Boolean})],c.prototype,`counter`,void 0),e.r([e.s({type:Boolean})],c.prototype,`hasError`,void 0),e.r([e.s({type:Boolean})],c.prototype,`inline`,void 0),e.r([e.s({type:Boolean})],c.prototype,`hasFieldset`,void 0),e.r([e.s({type:Boolean})],c.prototype,`optionalTag`,void 0),e.r([e.s({type:Boolean})],c.prototype,`requiredTag`,void 0),e.r([e.s({type:Boolean})],c.prototype,`skipForwardTestid`,void 0),e.r([e.s({type:Boolean,reflect:!0,converter:r.t})],c.prototype,`useWrapper`,void 0),e.r([e.s({type:Boolean,reflect:!0})],c.prototype,`fullwidth`,void 0),e.r([e.s({type:Number})],c.prototype,`counterMaxLength`,void 0),e.r([e.s({type:String})],c.prototype,`errorMessage`,void 0),e.r([e.s({type:String})],c.prototype,`helptext`,void 0),e.r([e.s({type:String})],c.prototype,`helptextDropdown`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`helptextDropdownButton`,void 0),e.r([e.s({type:String})],c.prototype,`label`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`optionalText`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`requiredText`,void 0),e.r([e.s({type:String,reflect:!1})],c.prototype,`tagText`,void 0),e.r([e.s({type:String,attribute:`data-testid`})],c.prototype,`dataTestid`,void 0),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|