@oslokommune/punkt-elements 20.0.3 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/{accordion-5N_ptxrN.cjs → accordion-CSSp30G1.cjs} +1 -1
- package/dist/{accordion-C5cu1xXT.js → accordion-DIjltHSH.js} +11 -14
- package/dist/{alert-DkyTTo7S.cjs → alert-0a5lX0pL.cjs} +12 -12
- package/dist/{alert-CA1fDbyc.js → alert-ZrB-P881.js} +36 -38
- package/dist/{async-directive-DCLIOGR8.cjs → async-directive-Bn7zgxUy.cjs} +1 -1
- package/dist/{async-directive-BcS8rfeC.js → async-directive-Ct3Mrb1M.js} +10 -11
- package/dist/{backlink-CXOxMeyt.cjs → backlink-BAvqdPlG.cjs} +1 -1
- package/dist/{backlink-CDBRcaAu.js → backlink-MBTAhQuD.js} +5 -7
- package/dist/{booleanish-OQJTYSrw.js → booleanish-CBa3Cr2h.js} +1 -2
- package/dist/{breadcrumbs-5oUaCef3.js → breadcrumbs-DtEt1-wn.js} +3 -4
- package/dist/{button-Bswo1C0M.js → button-CJzu0l5A.js} +45 -35
- package/dist/button-DHVRpzpS.cjs +32 -0
- package/dist/{calendar-BOd-9PDd.js → calendar-CkAAgviq.js} +66 -76
- package/dist/calendar-xYEsKilS.cjs +85 -0
- package/dist/{card-CKStAH0Q.js → card-CsEfBJcP.js} +10 -12
- package/dist/{card-BbV4OBqb.cjs → card-XznwedEG.cjs} +1 -1
- package/dist/{checkbox-iMOdzpJ_.cjs → checkbox-Cg7wnn8U.cjs} +1 -1
- package/dist/{checkbox-DIJbuqWm.js → checkbox-XvlUQmg5.js} +8 -10
- package/dist/{checkbox-group-Kua6HuRE.cjs → checkbox-group-BF29zyLd.cjs} +1 -1
- package/dist/{checkbox-group-DLLbWgQb.js → checkbox-group-CRIV5CX0.js} +8 -10
- package/dist/{class-map-BDwVSgLb.js → class-map-C9n5CNC8.js} +2 -3
- package/dist/{classutils-DcYnSgfc.js → classutils-C4jETHHk.js} +1 -2
- package/dist/{combobox-Pxa80TeZ.js → combobox-CDJcIkNJ.js} +63 -66
- package/dist/combobox-DuXavWEY.cjs +139 -0
- package/dist/{consent-UkinU27V.cjs → consent-BOSXNt4Y.cjs} +1 -1
- package/dist/{consent-p-0n2b9x.js → consent-DwppvYBR.js} +5 -7
- package/dist/{consume-Bp12si68.js → consume-C6aWEFx-.js} +4 -8
- package/dist/{converters-CW6SN0TT.cjs → converters-Dp64-kF1.cjs} +1 -1
- package/dist/{converters-CYgQrWVm.js → converters-v_GK06o3.js} +36 -72
- package/dist/{datepicker-Cpiu_Nrf.cjs → datepicker-Cnrbqm62.cjs} +53 -53
- package/dist/{datepicker-BpxUWiIC.js → datepicker-DHdFA8Dx.js} +82 -88
- package/dist/define-component-spec-wHP10r2x.js +5 -0
- package/dist/{dialog-polyfill.esm-D39dWbRt.js → dialog-polyfill.esm-BGBREnq_.js} +2 -3
- package/dist/dialog-polyfill.esm-BPk0-8XP.cjs +1 -0
- package/dist/{directive-helpers-BoDzpPID.js → directive-helpers-KMRvtO9j.js} +2 -3
- package/dist/{element-DLgZkx5L.js → element-Bwc-likm.js} +9 -18
- package/dist/{element-with-slot-mG-h7Sjw.js → element-with-slot-47quDZRt.js} +4 -6
- package/dist/{element-with-slot-CeKuRE3_.cjs → element-with-slot-D_8fAzCW.cjs} +1 -1
- package/dist/{fetch-header-footer-data-Pc32etrk.js → fetch-header-footer-data-CPVt_P8s.js} +3 -6
- package/dist/{fileupload-vPDmtXiM.js → fileupload-BQw5nlzQ.js} +25 -36
- package/dist/{fileupload-DXJtAagE.cjs → fileupload-Cjde62AR.cjs} +1 -1
- package/dist/{focus-modality-controller-Dc2S-KqR.js → focus-modality-controller-DVsT6GeR.js} +1 -2
- package/dist/focus-trap-C-PcFOw6.js +42 -0
- package/dist/focus-trap-C9tsr-xL.cjs +1 -0
- package/dist/{footer-CpE05IW2.cjs → footer-NQaQc2DH.cjs} +9 -9
- package/dist/{footer-D8t0PCPC.js → footer-SbOYv50e.js} +20 -24
- package/dist/{format-BTeSVkED.js → format-DwjTfa9h.js} +1 -2
- package/dist/{header-ChT1hHNA.js → header-CZnKVVt4.js} +22 -26
- package/dist/{header-CiwHNHKD.cjs → header-YbbGgmsD.cjs} +2 -2
- package/dist/{header-menu-Dq9lwNr1.cjs → header-menu-BJMMwrCR.cjs} +1 -1
- package/dist/{header-menu-BrjsNjBH.js → header-menu-k2ACrfOv.js} +9 -11
- package/dist/{heading-DAkjw2Am.cjs → heading-BNlor2MU.cjs} +1 -1
- package/dist/{heading-CMZmPEL9.js → heading-SYKHysr8.js} +19 -21
- package/dist/{helptext-Bse1LpRd.cjs → helptext-CQaNvbiv.cjs} +9 -9
- package/dist/{helptext-BFQzrOw4.js → helptext-kKmVQkwo.js} +20 -22
- package/dist/{icon-C1oCGwEe.js → icon-CZDw42U7.js} +5 -8
- package/dist/if-defined-B3pYog2C.js +4 -0
- package/dist/{input-element-2LHxo0em.cjs → input-element-CfZIyfon.cjs} +1 -1
- package/dist/{input-element-De40zUox.js → input-element-DE0FzjgP.js} +19 -25
- package/dist/{input-wrapper-C_Rzwxx7.cjs → input-wrapper-CbYMk21W.cjs} +1 -1
- package/dist/{input-wrapper-DkpJS1hR.js → input-wrapper-DYg1VHPv.js} +13 -15
- package/dist/{link-DLPpwjq4.js → link-Bc4zf-Dj.js} +19 -22
- package/dist/link-lPrxhYq0.cjs +7 -0
- package/dist/{linkcard-DIG6VYpl.cjs → linkcard-Bih7HS2t.cjs} +1 -1
- package/dist/{linkcard-Dr-r8jBO.js → linkcard-LCFAdVsG.js} +7 -9
- package/dist/{listbox-HrH4JonS.cjs → listbox-Du8llYth.cjs} +10 -10
- package/dist/{listbox-DAvIBH4P.js → listbox-df8gHweY.js} +17 -19
- package/dist/{loader-CFidlqSG.js → loader-C-2b3bGK.js} +9 -12
- package/dist/{loader-DTIrOtTo.cjs → loader-DiQSwWpb.cjs} +1 -1
- package/dist/{messagebox-BLYx3AL7.cjs → messagebox-BiG-fJX9.cjs} +1 -1
- package/dist/{messagebox-B_07P0QA.js → messagebox-CH3bKoJO.js} +9 -11
- package/dist/modal-B3rnE83a.cjs +37 -0
- package/dist/{modal-CA_M2Ix6.js → modal-SBJ8aGvM.js} +33 -35
- package/dist/{option-group-element-DzM8YznZ.js → option-group-element-DtSw52Dr.js} +7 -8
- package/dist/{option-group-element-CVNaBIlP.cjs → option-group-element-dN0ntPZk.cjs} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-breadcrumbs.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.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 +2 -3
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +37 -37
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-CzvBlEPD.js → pkt-options-controller-Dz7DP0wC.js} +2 -3
- package/dist/{pkt-options-controller-9zoH1OBW.cjs → pkt-options-controller-WsHVdPJA.cjs} +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{progressbar-CfCc2zhp.js → progressbar-DlbkKRgP.js} +9 -11
- package/dist/{progressbar-BdqIhC1Z.cjs → progressbar-Wyq_Q1Ur.cjs} +1 -1
- package/dist/{provide-_MnlMGnw.js → provide-DFu2tSv_.js} +3 -5
- package/dist/{radio-group-BRY_74od.js → radio-group-bRF8fnPW.js} +8 -10
- package/dist/{radio-group-CsUgnEv0.cjs → radio-group-u1IH7g-4.cjs} +1 -1
- package/dist/{radiobutton-CQhuG2lj.cjs → radiobutton-86ZvvDmJ.cjs} +1 -1
- package/dist/{radiobutton-lHnq8wX_.js → radiobutton-Bf6aFfYt.js} +8 -10
- package/dist/{ref-B6p6mQkO.cjs → ref-C6VUWwmF.cjs} +1 -1
- package/dist/{ref-BAegS9BR.js → ref-qE1RBrI7.js} +3 -4
- package/dist/{repeat-Cy1M16Di.js → repeat-c2P6osbb.js} +3 -4
- package/dist/{scroll-lock-CR-g54ai.js → scroll-lock-C9jzbJ4E.js} +1 -2
- package/dist/{searchinput-TAqMUJ0B.cjs → searchinput-D5l64Mkb.cjs} +7 -7
- package/dist/{searchinput-BLGaXkP6.js → searchinput-DN8kDZQ1.js} +18 -20
- package/dist/{select-Dle67Uwv.cjs → select-C7kAlSxs.cjs} +15 -15
- package/dist/{select-BvtUxW0Q.js → select-CXIEM2qY.js} +15 -18
- package/dist/shared-types/button.d.ts +13 -0
- package/dist/shared-types/index.d.ts +1 -1
- package/dist/shared-types-BvRk9kiK.js +0 -0
- package/dist/{tabs-BmmTUKuC.js → tabs-Cg16Sl3u.js} +57 -60
- package/dist/tabs-n7hQWwyI.cjs +40 -0
- package/dist/{tag-BZdC0voc.cjs → tag-BAikRN2Y.cjs} +1 -1
- package/dist/{tag-Cam7ISOF.js → tag-HXcXopyA.js} +9 -11
- package/dist/{textarea-Djp5L2Zd.js → textarea-12le8b4I.js} +12 -14
- package/dist/{textarea-DSX3jMlI.cjs → textarea-CRcSfWgX.cjs} +1 -1
- package/dist/{textinput-CBrOZcvL.js → textinput-CC0zxUBT.js} +11 -13
- package/dist/{textinput-CN2F3Q3H.cjs → textinput-Dooq2n8W.cjs} +1 -1
- package/dist/{timepicker-CkaJkIGn.cjs → timepicker-BM4I5w-i.cjs} +20 -20
- package/dist/{timepicker-CT4wfrgQ.js → timepicker-Cz81VQu3.js} +27 -28
- package/dist/{utils-BwF4QSrq.js → utils-Dn5ykFtS.js} +1 -2
- package/package.json +10 -10
- package/src/components/button/button.ts +14 -14
- package/dist/button-bVWAX98x.cjs +0 -32
- package/dist/calendar-CDTCgTJn.cjs +0 -85
- package/dist/combobox-CWL8T3UK.cjs +0 -139
- package/dist/define-component-spec-BYOSeplU.js +0 -6
- package/dist/dialog-polyfill.esm-CW51hN2p.cjs +0 -1
- package/dist/focus-trap-DG3pEuyJ.js +0 -60
- package/dist/focus-trap-DSv4Ifqm.cjs +0 -1
- package/dist/if-defined-DiYi2v_Q.js +0 -5
- package/dist/link-pkFJ11Zd.cjs +0 -7
- package/dist/modal-BvTfLfFq.cjs +0 -37
- package/dist/shared-types-A6iGIX-f.js +0 -1
- package/dist/tabs-B96Orh6O.cjs +0 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./async-directive-DCLIOGR8.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a,o=new WeakMap,s=new WeakMap,c=new WeakSet;function l(e){let t=o.get(e);return t||(t=new T(e),o.set(e,t)),t}var u=Symbol(`default`);function d(e){return e===void 0?u:e}function f(e){if(e.nodeType!==Node.ELEMENT_NODE)return u;let t=e.getAttribute(`slot`);return t===null?u:d(t)}function p(e){return Array.isArray(e)?e.map(e=>{let t=e===null?u:e;return[t,t]}):Object.entries(e).map(([e,t])=>[e,t===null?u:t])}function m(e,t){return e.length===t.length&&e.every(([e,n],r)=>t[r][0]===e&&t[r][1]===n)}function h(e){if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return!n(t)&&!r(t)}function g(e){return e.nodeType===Node.TEXT_NODE&&!!e.nodeValue&&!i(e)}function _(e,t){if(!h(e))return!1;if(e instanceof HTMLTemplateElement){let n=f(e);for(let r of Array.from(e.content.childNodes))v(t,n,r)}else v(t,f(e),e);return!0}function v(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}function y(e,t,n){Node.prototype.insertBefore.call(e,t,n)}function b(e){e.parentNode&&Node.prototype.removeChild.call(e.parentNode,e)}function x(e){return Object.getOwnPropertyDescriptor(Node.prototype,`nextSibling`).get.call(e)}function S(e,t){return e.node.compareDocumentPosition(t.node)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function C(e){if(e.nodeType!==Node.TEXT_NODE||Object.prototype.hasOwnProperty.call(e,`data`))return;let t=e,n={data:Object.getOwnPropertyDescriptor(CharacterData.prototype,`data`),nodeValue:Object.getOwnPropertyDescriptor(Node.prototype,`nodeValue`)};for(let[e,r]of Object.entries(n))r?.get&&r.set&&Object.defineProperty(t,e,{configurable:!0,get:()=>r.get.call(t),set:e=>{r.set.call(t,e),w(t)}})}function w(e){let t=s.get(e);if(t){i(e)||t.releaseText(e);return}let n=e.parentNode&&o.get(e.parentNode);n&&(i(e)?n.adoptText(e):n.blankTextChanged(e))}var T=class e{constructor(e){this.nodesBySlot=new Map,this.trackedNodes=new Set,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.mirrorOf=new Map,this.hasWhitespace=!1,this.contentBounds=null,this.changedWhitespace=new Set,this.directives=new Set,this.sources=new Map,this.subscribers=new Set,this.generation=0,this.initialCollectionDone=!1,this.inOwnChange=!1,this.rendering=!1,this.contentEnd=null,this.rootMarker=null,this.observer=null,this.observing=!1,this.wantsObserver=!1,this.followsHostRenders=!1,this.host=e,typeof e.addController==`function`&&(this.followsHostRenders=!0,e.addController({hostConnected:()=>{if(!this.wantsObserver)return;let e=!this.observing;this.startObserving(),e&&this.resync()},hostDisconnected:()=>this.stopObservingIfUnused(),hostUpdate:()=>{e.hasUpdated||this.collectLateChildren(),this.flushMutations(!1),e.hasUpdated||this.insertContentEnd(),this.rendering=!0,queueMicrotask(()=>{this.rendering=!1})},hostUpdated:()=>{this.rendering=!1,!this.rootMarker&&this.contentEnd?.parentNode===e&&(this.rootMarker=x(this.contentEnd)),this.flushMutations(!0)}}))}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)this.watchHostText(t),_(t,this.nodesBySlot)&&this.track(t);this.syncWhitespace()}collectLateChildren(){if(this.initialCollectionDone){for(let e of Array.from(this.host.childNodes))this.trackedNodes.has(e)||this.placeholderToNode.has(e)||(this.watchHostText(e),h(e)&&(this.addContent(e),this.generation++));this.syncWhitespace()}}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.stopObservingIfUnused()}addSource(e,t,n){let r=this.sources.get(e);r&&r.manager===t&&m(r.mapping,n)||(r&&r.manager!==t&&this.detachFrom(r.manager,e),this.sources.set(e,{manager:t,mapping:n}),t.subscribers.add(this),t.startObserving(),this.handleChange())}removeSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.detachFrom(t.manager,e),this.handleChange())}detachFrom(e,t){[...this.sources.entries()].some(([n,r])=>n!==t&&r.manager===e)||(e.subscribers.delete(this),e.stopObservingIfUnused())}reachableParts(e=new Set){if(e.has(this))return[];e.add(this);let t=[...this.directives];for(let n of this.subscribers)t.push(...n.reachableParts(e));return t}getNodes(e){return this.placementNodes(e).filter(e=>!c.has(e))}placementNodes(e){return this.nodesFor(d(e))}hasContent(e){return this.getNodes(e).length>0}nodesFor(e){let t=this.nodesBySlot.get(e)??[];if(this.sources.size===0)return t;let n=[];for(let{manager:t,mapping:r}of this.sources.values())for(let[i,a]of r)a===e&&n.push(...t.nodesFor(i));return n.length?[...t,...n]:t}ensurePlaceholder(e){if(this.nodeToPlaceholder.has(e))return;if(e.parentNode!==this.host){for(let{manager:t}of this.sources.values())t.ensurePlaceholder(e);return}let t=this.isInTemplate(e)?this.getContentEnd():e;y(this.host,this.createPlaceholder(e),t)}createPlaceholder(t){let n=document.createComment(e.PLACEHOLDER_PREFIX);if(t.nodeType===Node.TEXT_NODE){let e=t;Object.defineProperty(n,"data",{configurable:!0,get:()=>e.data,set:t=>{e.data=t}})}return this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n),n}forgetPlaceholder(e){let t=this.nodeToPlaceholder.get(e);return t&&(this.placeholderToNode.delete(t),this.nodeToPlaceholder.delete(e)),t}placeholderOf(e){return this.trackedNodes.has(e)?this.nodeToPlaceholder.get(e):void 0}handleNow(e){if(this.rendering)return e();this.flushMutations(!1);let t=e();return this.flushMutations(!1),t}positionInHost(e){if(!e||e.parentNode===this.host)return this.rendering||e&&!this.isInTemplate(e)?e:this.getContentEnd()??e;if(this.trackedNodes.has(e))return this.nodeToPlaceholder.get(e)??e;for(let t=e.previousSibling;t;t=t.previousSibling){let e=this.placeholderOf(t);if(e)return e.nextSibling}for(let t=e.nextSibling;t;t=t.nextSibling){let e=this.placeholderOf(t);if(e)return e}return this.reachableParts().some(t=>t.parentOfPart()===e.parentNode)?this.getContentEnd():e}owns(e){return this.trackedNodes.has(e)}moveDistributed(e,t){let n=this.nodeToPlaceholder.get(e);if(this.rendering||!n||!this.trackedNodes.has(e)||!e.parentNode||e.parentNode===this.host)return!1;this.flushMutations(!1);let r=this.positionInHost(t);if(r===n||r===e)return!0;if(r&&r.parentNode!==this.host)return!1;let i=f(e),a=this.nodesBySlot.get(i);if(!a||!a.includes(e))return!1;let o=null;for(let t=r;t&&!o;t=t.nextSibling){let n=this.placeholderToNode.get(t)??t;if(n!==e&&this.trackedNodes.has(n)){if(n instanceof HTMLTemplateElement)return!1;f(n)===i&&(o=n)}}let s=a[a.length-1]===e?a[a.length-2]:a[a.length-1],c=o??s;return c&&(!c.parentNode||c.parentNode===this.host)?!1:(this.asOwnChange(()=>{y(this.host,n,r),a.splice(a.indexOf(e),1),a.splice(o?a.indexOf(o):a.length,0,e),o?y(o.parentNode,e,o):s&&y(s.parentNode,e,s.nextSibling),this.handleChange()}),!0)}replaceContent(e){if(!this.initialCollectionDone)return!1;let t=e.flatMap(e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e]);if(t.some(e=>e.contains(this.host)))return!1;this.flushMutations(!1);let n=this.getContentEnd();return n?(this.asOwnChange(()=>{let e=new Set(this.trackedNodes);for(let t of this.nodesBySlot.values())t.forEach(t=>e.add(t));for(let t of e){let e=this.forgetPlaceholder(t);e&&b(e),b(t),this.untrack(t)}for(this.nodesBySlot.clear(),this.mirrorOf.clear(),this.contentBounds=null;n.previousSibling;)b(n.previousSibling);let r=document.createDocumentFragment();r.append(...t),y(this.host,r,n);for(let e of t)this.watchHostText(e),h(e)&&this.addContent(e);this.handleChange()}),!0):!1}adoptText(e){this.initialCollectionDone&&!this.trackedNodes.has(e)&&(e.parentNode!==this.host||this.isInTemplate(e)||(this.flushMutations(!1),this.asOwnChange(()=>{this.dropMirror(e),this.insertInSlotOrder(e),this.track(e),this.handleChange()})))}blankTextChanged(e){let t=this.mirrorOf.get(e);t&&(t.data=e.data,e.data)||this.initialCollectionDone&&(e.parentNode!==this.host||this.isInTemplate(e)||(this.watchHostText(e),this.changedWhitespace.add(e),this.flushMutations(!1),this.asOwnChange(()=>this.handleChange())))}releaseText(e){if(this.flushMutations(!1),!this.trackedNodes.has(e))return;let t=this.nodeToPlaceholder.get(e);(t?t.parentNode===this.host:e.parentNode===this.host)&&this.asOwnChange(()=>{t&&(this.forgetPlaceholder(e),Node.prototype.replaceChild.call(this.host,e,t)),this.removeContent(e),this.watchHostText(e),this.handleChange()})}watchHostText(e){C(e),g(e)&&(this.hasWhitespace=!0,this.changedWhitespace.add(e))}syncWhitespace(){if(!this.hasWhitespace)return;let e=this.findContentBounds(),t=this.contentBounds,n=this.changedWhitespace;if(this.contentBounds=e,this.changedWhitespace=new Set,!e)for(let e of[...this.mirrorOf.keys()])this.dropMirror(e);else{if(this.dropMirrorsOutside(),!t)this.collectBlankBetween(e.firstAt,e.lastAt,n);else{if(t.first!==e.first){let r=this.placeOf(t.first);r&&this.precedes(e.firstAt,r)?this.collectBlankBetween(e.firstAt,r,n):this.collectBlankBeside(e.firstAt,`nextSibling`,n)}if(t.last!==e.last){let r=this.placeOf(t.last);r&&this.precedes(r,e.lastAt)?this.collectBlankBetween(r,e.lastAt,n):this.collectBlankBeside(e.lastAt,`previousSibling`,n)}}for(let t of n)t.parentNode===this.host&&g(t)&&this.isBetween(t,e)?this.addMirror(t):this.dropMirror(t)}}dropMirrorsOutside(){let e=this.nodesBySlot.get(u)??[],t=[],n=e=>{if(c.has(e))t.push(this.nodeToPlaceholder.get(e));else if(this.placeOf(e))return!1;return!0};for(let t=0;t<e.length&&n(e[t]);t++);for(let t=e.length-1;t>=0&&n(e[t]);t--);t.forEach(e=>this.dropMirror(e))}precedes(e,t){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)}collectBlankBeside(e,t,n){for(let r=e[t];r;r=r[t]){if(g(r)){n.add(r);continue}let e=this.placeholderToNode.get(r)??r;if(!c.has(e)&&this.trackedNodes.has(e))return}}findContentBounds(){let e=this.nodesBySlot.get(u)??[],t=e=>c.has(e)?null:this.placeOf(e),n,r=null,i,a=null;for(let i=0;i<e.length&&!r;i++)[n,r]=[e[i],t(e[i])];for(let n=e.length-1;n>=0&&!a;n--)[i,a]=[e[n],t(e[n])];return n&&i&&r&&a?{first:n,last:i,firstAt:r,lastAt:a}:null}placeOf(e){if(!this.trackedNodes.has(e))return null;let t=this.nodeToPlaceholder.get(e)??e;return t.parentNode===this.host?t:null}isBetween(e,{firstAt:t,lastAt:n}){return this.precedes(t,e)&&this.precedes(e,n)}collectBlankBetween(e,t,n){if(e===t)return;let[r,i]=this.precedes(e,t)?[e,t]:[t,e];for(let e=r.nextSibling;e&&e!==i;e=e.nextSibling)g(e)&&n.add(e)}addMirror(e){if(this.mirrorOf.has(e))return;let t=document.createTextNode(e.data);c.add(t),this.mirrorOf.set(e,t),this.placeholderToNode.set(e,t),this.nodeToPlaceholder.set(t,e),this.insertInSlotOrder(t)}dropMirror(e){let t=this.mirrorOf.get(e);t&&(this.mirrorOf.delete(e),this.forgetPlaceholder(t),b(t),this.removeFromSlots(t))}insertContentEnd(){this.contentEnd||(this.contentEnd=document.createComment(``),Object.defineProperty(this.contentEnd,"nextSibling",{configurable:!0,get:()=>null})),this.contentEnd.parentNode!==this.host&&y(this.host,this.contentEnd,null)}getContentEnd(){let e=this.contentEnd;return e?(e.parentNode!==this.host&&this.rootMarker?.parentNode===this.host&&y(this.host,e,this.rootMarker),e.parentNode===this.host?e:null):null}isInTemplate(e){let t=this.getContentEnd();return!t||e.parentNode!==this.host?!1:e===t||!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}startObserving(){if(this.wantsObserver=!0,this.observing)return;this.observing=!0;let e=()=>{this.observing&&typeof MutationObserver<`u`&&(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0,subtree:!0}))};this.followsHostRenders?e():setTimeout(e,0)}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}stopObservingIfUnused(){let e=this.directives.size===0&&this.subscribers.size===0;(!this.host.isConnected||e&&!this.followsHostRenders)&&this.stopObserving()}flushMutations(e){if(this.inOwnChange)return;let t=this.observer?.takeRecords();t?.length&&this.handleMutations(t,e)}handleMutations(e,t=!1){this.inOwnChange||this.asOwnChange(()=>this.applyMutations(e,t))}applyMutations(e,t){let n=!1,r=[],i=new Map,a=[];for(let o of e){for(let e of o.removedNodes){let a=this.placeholderToNode.get(e);if(a&&e.parentNode===this.host)t||(this.removeFromSlots(a),this.insertInSlotOrder(a),b(a),c.has(a)&&this.changedWhitespace.add(e),n=!0);else if(a){if(this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(a),c.has(a)&&this.mirrorOf.delete(e),t)continue;b(a),this.removeContent(a),n=!0}else if(this.trackedNodes.has(e)&&!this.host.contains(e)&&!t){this.removeContent(e);let t=this.forgetPlaceholder(e);if(t&&(r.push(t),o.target!==this.host)){let e=i.get(o.target)??[];e.push(t),i.set(o.target,e)}n=!0}}if(o.target!==this.host)o.addedNodes.length&&a.push(o);else if(!t){for(let e of o.addedNodes)if(!this.placeholderToNode.has(e)){if(this.trackedNodes.has(e)&&e.parentNode===this.host){let t=this.forgetPlaceholder(e);t&&b(t),this.removeFromSlots(e),this.insertInSlotOrder(e),n=!0}else!this.trackedNodes.has(e)&&h(e)?(this.addContent(e),n=!0):(this.watchHostText(e),g(e)&&(n=!0))}}}i.size&&this.adoptNodesInParts(a,i)&&(n=!0);for(let e of r)b(e);this.getContentEnd(),n&&this.handleChange()}adoptNodesInParts(e,t){let n=new Set;for(let r of e)t.has(r.target)&&r.addedNodes.forEach(e=>n.add(e));if(n.size===0)return!1;let r=this.reachableParts(),i=[];for(let e of n){if(!e.parentNode||!t.has(e.parentNode)||s.has(e)||c.has(e)||this.placeholderToNode.has(e))continue;let n=r.find(t=>t.contains(e));if(!n)continue;let a=this.hostPositionFor(e,n,t);a&&i.push({node:e,before:a.before})}if(i.length===0)return!1;let a=!1;for(let{node:e,before:t}of i.sort(S))h(e)&&!(e instanceof HTMLTemplateElement)?(y(this.host,this.createPlaceholder(e),t),this.insertInSlotOrder(e),this.track(e),a=!0):y(this.host,e,t);return a}hostPositionFor(e,t,n){let{startNode:r,endNode:i}=t.bounds();for(let t=e.nextSibling;t&&t!==i;t=t.nextSibling){let e=this.placeholderOf(t);if(e)return{before:e}}for(let t=e.previousSibling;t&&t!==r;t=t.previousSibling){let e=this.placeholderOf(t);if(e)return{before:e.nextSibling}}let a=e.parentNode?n.get(e.parentNode):void 0;return a?{before:a[0]}:null}resync(){this.asOwnChange(()=>{let e=!1;for(let t of[...this.trackedNodes]){let n=this.nodeToPlaceholder.get(t),r=this.host.contains(t);(!r||n&&n.parentNode!==this.host)&&(n&&b(this.forgetPlaceholder(t)),r&&b(t),this.removeContent(t),e=!0)}let t=this.getContentEnd();for(let n=t?this.host.firstChild:null;n&&n!==t;n=n.nextSibling)this.trackedNodes.has(n)||this.placeholderToNode.has(n)||(this.watchHostText(n),h(n)&&(this.addContent(n),e=!0));this.syncWhitespace(),this.sortSlots()&&(e=!0),e&&this.handleChange()})}sortSlots(){let e=!1;for(let t of this.nodesBySlot.values()){if(!t.every(e=>this.nodeToPlaceholder.has(e)))continue;let n=t.map(e=>({node:this.nodeToPlaceholder.get(e),real:e})).sort(S).map(({real:e})=>e);n.every((e,n)=>e===t[n])||(t.splice(0,t.length,...n),n.forEach(b),e=!0)}return e}handleChange(){this.syncWhitespace(),this.generation++,this.notifyDirectives();for(let e of this.subscribers)e.handleChange();this.host.requestUpdate()}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}asOwnChange(e){let t=this.inOwnChange;this.inOwnChange=!0;try{e()}finally{t||(this.observer?.takeRecords(),this.inOwnChange=!1)}}addContent(e){e instanceof HTMLTemplateElement?_(e,this.nodesBySlot):this.insertInSlotOrder(e),this.track(e)}removeContent(e){this.untrack(e),this.removeFromSlots(e)}track(e){this.trackedNodes.add(e),s.set(e,this),C(e)}untrack(e){this.trackedNodes.delete(e),s.get(e)===this&&s.delete(e)}insertInSlotOrder(e){let t=f(e),n=this.nodesBySlot.get(t)??[];this.nodesBySlot.set(t,n);let r=this.nodeToPlaceholder.get(e)??e,i=e=>{let t=this.nodeToPlaceholder.get(e)??e;return!!(r.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)},a=n.length;for(;a>0&&i(n[a-1]);)a--;n.splice(a,0,e)}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}};a=T,a.PLACEHOLDER_PREFIX=`pkt-slot`;var E=class extends t.t{constructor(t){if(super(t),this.manager=null,this.host=null,this.part=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(t,[n,r]){return this.part=t,this.host=n,this.slotName=r,this.manager||(this.manager=l(n),this.manager.collectNodes(),this.manager.addDirective(this)),this.placeNodes(),e.g}handleNodesChanged(){this.isConnected&&this.manager&&this.placeNodes()}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){this.host&&(this.manager=l(this.host),this.manager.addDirective(this),this.placeNodes())}contains(e){let t=this.parentOfPart();return!this.isConnected||!t?!1:this.isInsidePart(e,t,this.coversContainer(t))}bounds(){return{startNode:this.part?.startNode??null,endNode:this.part?.endNode??null}}parentOfPart(){return this.part?this.part.startNode?this.part.startNode.parentNode:this.part.parentNode:null}placeNodes(){if(!this.manager||!this.part)return;let e=this.manager.generation;if(e===this.lastGeneration)return;this.lastGeneration=e;let t=this.parentOfPart();if(!t)return;let n=this.manager.placementNodes(this.slotName),r=this.coversContainer(t),i=this.part.endNode;for(let e=n.length-1;e>=0;e--){let a=n[e];this.isInsidePart(a,t,r)||(this.manager.ensurePlaceholder(a),y(t,a,i)),i=a}}coversContainer(e){let{startNode:t,endNode:n}=this.part;return!n&&(!t||t===e.firstChild)}isInsidePart(e,t,n){if(!this.part||e.parentNode!==t)return!1;if(n)return!0;let{startNode:r,endNode:i}=this.part,a=!r||!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING),o=!i||!!(e.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING);return a&&o}},D=e.f(E),O=class extends t.t{constructor(t){if(super(t),this.target=null,this.source=null,this.mapping=[],t.type!==e.m.ELEMENT)throw Error(`forwardSlots() can only be used as an element directive`)}render(t,n){return e.g}update(t,[n,r]){let i=t.element;return typeof i.addController==`function`?this.connect(i,n,r):customElements.whenDefined(i.localName).then(()=>{this.isConnected&&this.connect(i,n,r)}),e.g}connect(e,t,n){let r=l(e);this.target&&this.target!==r&&this.target.removeSource(this),this.target=r,this.source=l(t),this.source.collectNodes(),this.mapping=p(n),this.target.addSource(this,this.source,this.mapping)}disconnected(){this.target?.removeSource(this)}reconnected(){this.target&&this.source&&this.target.addSource(this,this.source,this.mapping)}},k=e.f(O),A=new Map;function j(e){if(A.has(e))return A.get(e);let t,n=HTMLElement.prototype;for(;!t&&n;)t=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n);return A.set(e,t),t}function M(e,t){return t.some(t=>typeof t!=`string`&&t.contains(e))}var N=class extends e.t{connectedCallback(){l(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return l(this).hasContent(e)}appendChild(e){let t=l(this);return t.moveDistributed(e,null)?e:t.handleNow(()=>super.insertBefore(e,t.positionInHost(null)))}append(...e){if(M(this,e)){super.append(...e);return}let t=l(this);t.handleNow(()=>{let n=document.createDocumentFragment();n.append(...e),super.insertBefore(n,t.positionInHost(null))})}prepend(...e){l(this).handleNow(()=>super.prepend(...e))}insertBefore(e,t){let n=l(this);return n.moveDistributed(e,t)?e:n.handleNow(()=>super.insertBefore(e,n.positionInHost(t)))}removeChild(e){let t=l(this);return e.parentNode===this||!t.owns(e)?super.removeChild(e):t.handleNow(()=>(e.parentNode?.removeChild(e),e))}replaceChild(e,t){let n=l(this);return t.parentNode===this||!n.owns(t)?super.replaceChild(e,t):n.handleNow(()=>(super.insertBefore(e,n.positionInHost(t)),t.parentNode?.removeChild(t),t))}replaceChildren(...e){let t=e.map(e=>typeof e==`string`?document.createTextNode(e):e);l(this).replaceContent(t)||super.replaceChildren(...e)}get textContent(){return j(`textContent`).get.call(this)}set textContent(e){let t=e==null?``:String(e);l(this).replaceContent(t?[document.createTextNode(t)]:[])||j(`textContent`).set.call(this,e)}get innerHTML(){return j(`innerHTML`).get.call(this)}set innerHTML(e){let t=document.createElement(`template`);t.innerHTML=e,l(this).replaceContent(Array.from(t.content.childNodes))||j(`innerHTML`).set.call(this,e)}get innerText(){let e=j(`innerText`);return e?.get?e.get.call(this):this.textContent}set innerText(e){let t=j(`innerText`);if(!t?.set){this.textContent=e;return}let n=document.createElement(`div`);t.set.call(n,e),l(this).replaceContent(Array.from(n.childNodes))||t.set.call(this,e)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return N}});
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./async-directive-Bn7zgxUy.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a,o=new WeakMap,s=new WeakMap,c=new WeakSet;function l(e){let t=o.get(e);return t||(t=new T(e),o.set(e,t)),t}var u=Symbol(`default`);function d(e){return e===void 0?u:e}function f(e){if(e.nodeType!==Node.ELEMENT_NODE)return u;let t=e.getAttribute(`slot`);return t===null?u:d(t)}function p(e){return Array.isArray(e)?e.map(e=>{let t=e===null?u:e;return[t,t]}):Object.entries(e).map(([e,t])=>[e,t===null?u:t])}function m(e,t){return e.length===t.length&&e.every(([e,n],r)=>t[r][0]===e&&t[r][1]===n)}function h(e){if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return!n(t)&&!r(t)}function g(e){return e.nodeType===Node.TEXT_NODE&&!!e.nodeValue&&!i(e)}function _(e,t){if(!h(e))return!1;if(e instanceof HTMLTemplateElement){let n=f(e);for(let r of Array.from(e.content.childNodes))v(t,n,r)}else v(t,f(e),e);return!0}function v(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}function y(e,t,n){Node.prototype.insertBefore.call(e,t,n)}function b(e){e.parentNode&&Node.prototype.removeChild.call(e.parentNode,e)}function x(e){return Object.getOwnPropertyDescriptor(Node.prototype,`nextSibling`).get.call(e)}function S(e,t){return e.node.compareDocumentPosition(t.node)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function C(e){if(e.nodeType!==Node.TEXT_NODE||Object.prototype.hasOwnProperty.call(e,`data`))return;let t=e,n={data:Object.getOwnPropertyDescriptor(CharacterData.prototype,`data`),nodeValue:Object.getOwnPropertyDescriptor(Node.prototype,`nodeValue`)};for(let[e,r]of Object.entries(n))r?.get&&r.set&&Object.defineProperty(t,e,{configurable:!0,get:()=>r.get.call(t),set:e=>{r.set.call(t,e),w(t)}})}function w(e){let t=s.get(e);if(t){i(e)||t.releaseText(e);return}let n=e.parentNode&&o.get(e.parentNode);n&&(i(e)?n.adoptText(e):n.blankTextChanged(e))}var T=class e{constructor(e){this.nodesBySlot=new Map,this.trackedNodes=new Set,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.mirrorOf=new Map,this.hasWhitespace=!1,this.contentBounds=null,this.changedWhitespace=new Set,this.directives=new Set,this.sources=new Map,this.subscribers=new Set,this.generation=0,this.initialCollectionDone=!1,this.inOwnChange=!1,this.rendering=!1,this.contentEnd=null,this.rootMarker=null,this.observer=null,this.observing=!1,this.wantsObserver=!1,this.followsHostRenders=!1,this.host=e,typeof e.addController==`function`&&(this.followsHostRenders=!0,e.addController({hostConnected:()=>{if(!this.wantsObserver)return;let e=!this.observing;this.startObserving(),e&&this.resync()},hostDisconnected:()=>this.stopObservingIfUnused(),hostUpdate:()=>{e.hasUpdated||this.collectLateChildren(),this.flushMutations(!1),e.hasUpdated||this.insertContentEnd(),this.rendering=!0,queueMicrotask(()=>{this.rendering=!1})},hostUpdated:()=>{this.rendering=!1,!this.rootMarker&&this.contentEnd?.parentNode===e&&(this.rootMarker=x(this.contentEnd)),this.flushMutations(!0)}}))}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)this.watchHostText(t),_(t,this.nodesBySlot)&&this.track(t);this.syncWhitespace()}collectLateChildren(){if(this.initialCollectionDone){for(let e of Array.from(this.host.childNodes))this.trackedNodes.has(e)||this.placeholderToNode.has(e)||(this.watchHostText(e),h(e)&&(this.addContent(e),this.generation++));this.syncWhitespace()}}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.stopObservingIfUnused()}addSource(e,t,n){let r=this.sources.get(e);r&&r.manager===t&&m(r.mapping,n)||(r&&r.manager!==t&&this.detachFrom(r.manager,e),this.sources.set(e,{manager:t,mapping:n}),t.subscribers.add(this),t.startObserving(),this.handleChange())}removeSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.detachFrom(t.manager,e),this.handleChange())}detachFrom(e,t){[...this.sources.entries()].some(([n,r])=>n!==t&&r.manager===e)||(e.subscribers.delete(this),e.stopObservingIfUnused())}reachableParts(e=new Set){if(e.has(this))return[];e.add(this);let t=[...this.directives];for(let n of this.subscribers)t.push(...n.reachableParts(e));return t}getNodes(e){return this.placementNodes(e).filter(e=>!c.has(e))}placementNodes(e){return this.nodesFor(d(e))}hasContent(e){return this.getNodes(e).length>0}nodesFor(e){let t=this.nodesBySlot.get(e)??[];if(this.sources.size===0)return t;let n=[];for(let{manager:t,mapping:r}of this.sources.values())for(let[i,a]of r)a===e&&n.push(...t.nodesFor(i));return n.length?[...t,...n]:t}ensurePlaceholder(e){if(this.nodeToPlaceholder.has(e))return;if(e.parentNode!==this.host){for(let{manager:t}of this.sources.values())t.ensurePlaceholder(e);return}let t=this.isInTemplate(e)?this.getContentEnd():e;y(this.host,this.createPlaceholder(e),t)}createPlaceholder(t){let n=document.createComment(e.PLACEHOLDER_PREFIX);if(t.nodeType===Node.TEXT_NODE){let e=t;Object.defineProperty(n,"data",{configurable:!0,get:()=>e.data,set:t=>{e.data=t}})}return this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n),n}forgetPlaceholder(e){let t=this.nodeToPlaceholder.get(e);return t&&(this.placeholderToNode.delete(t),this.nodeToPlaceholder.delete(e)),t}placeholderOf(e){return this.trackedNodes.has(e)?this.nodeToPlaceholder.get(e):void 0}handleNow(e){if(this.rendering)return e();this.flushMutations(!1);let t=e();return this.flushMutations(!1),t}positionInHost(e){if(!e||e.parentNode===this.host)return this.rendering||e&&!this.isInTemplate(e)?e:this.getContentEnd()??e;if(this.trackedNodes.has(e))return this.nodeToPlaceholder.get(e)??e;for(let t=e.previousSibling;t;t=t.previousSibling){let e=this.placeholderOf(t);if(e)return e.nextSibling}for(let t=e.nextSibling;t;t=t.nextSibling){let e=this.placeholderOf(t);if(e)return e}return this.reachableParts().some(t=>t.parentOfPart()===e.parentNode)?this.getContentEnd():e}owns(e){return this.trackedNodes.has(e)}moveDistributed(e,t){let n=this.nodeToPlaceholder.get(e);if(this.rendering||!n||!this.trackedNodes.has(e)||!e.parentNode||e.parentNode===this.host)return!1;this.flushMutations(!1);let r=this.positionInHost(t);if(r===n||r===e)return!0;if(r&&r.parentNode!==this.host)return!1;let i=f(e),a=this.nodesBySlot.get(i);if(!a||!a.includes(e))return!1;let o=null;for(let t=r;t&&!o;t=t.nextSibling){let n=this.placeholderToNode.get(t)??t;if(n!==e&&this.trackedNodes.has(n)){if(n instanceof HTMLTemplateElement)return!1;f(n)===i&&(o=n)}}let s=a[a.length-1]===e?a[a.length-2]:a[a.length-1],c=o??s;return c&&(!c.parentNode||c.parentNode===this.host)?!1:(this.asOwnChange(()=>{y(this.host,n,r),a.splice(a.indexOf(e),1),a.splice(o?a.indexOf(o):a.length,0,e),o?y(o.parentNode,e,o):s&&y(s.parentNode,e,s.nextSibling),this.handleChange()}),!0)}replaceContent(e){if(!this.initialCollectionDone)return!1;let t=e.flatMap(e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e]);if(t.some(e=>e.contains(this.host)))return!1;this.flushMutations(!1);let n=this.getContentEnd();return n?(this.asOwnChange(()=>{let e=new Set(this.trackedNodes);for(let t of this.nodesBySlot.values())t.forEach(t=>e.add(t));for(let t of e){let e=this.forgetPlaceholder(t);e&&b(e),b(t),this.untrack(t)}for(this.nodesBySlot.clear(),this.mirrorOf.clear(),this.contentBounds=null;n.previousSibling;)b(n.previousSibling);let r=document.createDocumentFragment();r.append(...t),y(this.host,r,n);for(let e of t)this.watchHostText(e),h(e)&&this.addContent(e);this.handleChange()}),!0):!1}adoptText(e){this.initialCollectionDone&&!this.trackedNodes.has(e)&&(e.parentNode!==this.host||this.isInTemplate(e)||(this.flushMutations(!1),this.asOwnChange(()=>{this.dropMirror(e),this.insertInSlotOrder(e),this.track(e),this.handleChange()})))}blankTextChanged(e){let t=this.mirrorOf.get(e);t&&(t.data=e.data,e.data)||this.initialCollectionDone&&(e.parentNode!==this.host||this.isInTemplate(e)||(this.watchHostText(e),this.changedWhitespace.add(e),this.flushMutations(!1),this.asOwnChange(()=>this.handleChange())))}releaseText(e){if(this.flushMutations(!1),!this.trackedNodes.has(e))return;let t=this.nodeToPlaceholder.get(e);(t?t.parentNode===this.host:e.parentNode===this.host)&&this.asOwnChange(()=>{t&&(this.forgetPlaceholder(e),Node.prototype.replaceChild.call(this.host,e,t)),this.removeContent(e),this.watchHostText(e),this.handleChange()})}watchHostText(e){C(e),g(e)&&(this.hasWhitespace=!0,this.changedWhitespace.add(e))}syncWhitespace(){if(!this.hasWhitespace)return;let e=this.findContentBounds(),t=this.contentBounds,n=this.changedWhitespace;if(this.contentBounds=e,this.changedWhitespace=new Set,!e)for(let e of[...this.mirrorOf.keys()])this.dropMirror(e);else{if(this.dropMirrorsOutside(),!t)this.collectBlankBetween(e.firstAt,e.lastAt,n);else{if(t.first!==e.first){let r=this.placeOf(t.first);r&&this.precedes(e.firstAt,r)?this.collectBlankBetween(e.firstAt,r,n):this.collectBlankBeside(e.firstAt,`nextSibling`,n)}if(t.last!==e.last){let r=this.placeOf(t.last);r&&this.precedes(r,e.lastAt)?this.collectBlankBetween(r,e.lastAt,n):this.collectBlankBeside(e.lastAt,`previousSibling`,n)}}for(let t of n)t.parentNode===this.host&&g(t)&&this.isBetween(t,e)?this.addMirror(t):this.dropMirror(t)}}dropMirrorsOutside(){let e=this.nodesBySlot.get(u)??[],t=[],n=e=>{if(c.has(e))t.push(this.nodeToPlaceholder.get(e));else if(this.placeOf(e))return!1;return!0};for(let t=0;t<e.length&&n(e[t]);t++);for(let t=e.length-1;t>=0&&n(e[t]);t--);t.forEach(e=>this.dropMirror(e))}precedes(e,t){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)}collectBlankBeside(e,t,n){for(let r=e[t];r;r=r[t]){if(g(r)){n.add(r);continue}let e=this.placeholderToNode.get(r)??r;if(!c.has(e)&&this.trackedNodes.has(e))return}}findContentBounds(){let e=this.nodesBySlot.get(u)??[],t=e=>c.has(e)?null:this.placeOf(e),n,r=null,i,a=null;for(let i=0;i<e.length&&!r;i++)[n,r]=[e[i],t(e[i])];for(let n=e.length-1;n>=0&&!a;n--)[i,a]=[e[n],t(e[n])];return n&&i&&r&&a?{first:n,last:i,firstAt:r,lastAt:a}:null}placeOf(e){if(!this.trackedNodes.has(e))return null;let t=this.nodeToPlaceholder.get(e)??e;return t.parentNode===this.host?t:null}isBetween(e,{firstAt:t,lastAt:n}){return this.precedes(t,e)&&this.precedes(e,n)}collectBlankBetween(e,t,n){if(e===t)return;let[r,i]=this.precedes(e,t)?[e,t]:[t,e];for(let e=r.nextSibling;e&&e!==i;e=e.nextSibling)g(e)&&n.add(e)}addMirror(e){if(this.mirrorOf.has(e))return;let t=document.createTextNode(e.data);c.add(t),this.mirrorOf.set(e,t),this.placeholderToNode.set(e,t),this.nodeToPlaceholder.set(t,e),this.insertInSlotOrder(t)}dropMirror(e){let t=this.mirrorOf.get(e);t&&(this.mirrorOf.delete(e),this.forgetPlaceholder(t),b(t),this.removeFromSlots(t))}insertContentEnd(){this.contentEnd||(this.contentEnd=document.createComment(``),Object.defineProperty(this.contentEnd,"nextSibling",{configurable:!0,get:()=>null})),this.contentEnd.parentNode!==this.host&&y(this.host,this.contentEnd,null)}getContentEnd(){let e=this.contentEnd;return e?(e.parentNode!==this.host&&this.rootMarker?.parentNode===this.host&&y(this.host,e,this.rootMarker),e.parentNode===this.host?e:null):null}isInTemplate(e){let t=this.getContentEnd();return!t||e.parentNode!==this.host?!1:e===t||!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)}startObserving(){if(this.wantsObserver=!0,this.observing)return;this.observing=!0;let e=()=>{this.observing&&typeof MutationObserver<`u`&&(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0,subtree:!0}))};this.followsHostRenders?e():setTimeout(e,0)}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}stopObservingIfUnused(){let e=this.directives.size===0&&this.subscribers.size===0;(!this.host.isConnected||e&&!this.followsHostRenders)&&this.stopObserving()}flushMutations(e){if(this.inOwnChange)return;let t=this.observer?.takeRecords();t?.length&&this.handleMutations(t,e)}handleMutations(e,t=!1){this.inOwnChange||this.asOwnChange(()=>this.applyMutations(e,t))}applyMutations(e,t){let n=!1,r=[],i=new Map,a=[];for(let o of e){for(let e of o.removedNodes){let a=this.placeholderToNode.get(e);if(a&&e.parentNode===this.host)t||(this.removeFromSlots(a),this.insertInSlotOrder(a),b(a),c.has(a)&&this.changedWhitespace.add(e),n=!0);else if(a){if(this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(a),c.has(a)&&this.mirrorOf.delete(e),t)continue;b(a),this.removeContent(a),n=!0}else if(this.trackedNodes.has(e)&&!this.host.contains(e)&&!t){this.removeContent(e);let t=this.forgetPlaceholder(e);if(t&&(r.push(t),o.target!==this.host)){let e=i.get(o.target)??[];e.push(t),i.set(o.target,e)}n=!0}}if(o.target!==this.host)o.addedNodes.length&&a.push(o);else if(!t){for(let e of o.addedNodes)if(!this.placeholderToNode.has(e)){if(this.trackedNodes.has(e)&&e.parentNode===this.host){let t=this.forgetPlaceholder(e);t&&b(t),this.removeFromSlots(e),this.insertInSlotOrder(e),n=!0}else!this.trackedNodes.has(e)&&h(e)?(this.addContent(e),n=!0):(this.watchHostText(e),g(e)&&(n=!0))}}}i.size&&this.adoptNodesInParts(a,i)&&(n=!0);for(let e of r)b(e);this.getContentEnd(),n&&this.handleChange()}adoptNodesInParts(e,t){let n=new Set;for(let r of e)t.has(r.target)&&r.addedNodes.forEach(e=>n.add(e));if(n.size===0)return!1;let r=this.reachableParts(),i=[];for(let e of n){if(!e.parentNode||!t.has(e.parentNode)||s.has(e)||c.has(e)||this.placeholderToNode.has(e))continue;let n=r.find(t=>t.contains(e));if(!n)continue;let a=this.hostPositionFor(e,n,t);a&&i.push({node:e,before:a.before})}if(i.length===0)return!1;let a=!1;for(let{node:e,before:t}of i.sort(S))h(e)&&!(e instanceof HTMLTemplateElement)?(y(this.host,this.createPlaceholder(e),t),this.insertInSlotOrder(e),this.track(e),a=!0):y(this.host,e,t);return a}hostPositionFor(e,t,n){let{startNode:r,endNode:i}=t.bounds();for(let t=e.nextSibling;t&&t!==i;t=t.nextSibling){let e=this.placeholderOf(t);if(e)return{before:e}}for(let t=e.previousSibling;t&&t!==r;t=t.previousSibling){let e=this.placeholderOf(t);if(e)return{before:e.nextSibling}}let a=e.parentNode?n.get(e.parentNode):void 0;return a?{before:a[0]}:null}resync(){this.asOwnChange(()=>{let e=!1;for(let t of[...this.trackedNodes]){let n=this.nodeToPlaceholder.get(t),r=this.host.contains(t);(!r||n&&n.parentNode!==this.host)&&(n&&b(this.forgetPlaceholder(t)),r&&b(t),this.removeContent(t),e=!0)}let t=this.getContentEnd();for(let n=t?this.host.firstChild:null;n&&n!==t;n=n.nextSibling)this.trackedNodes.has(n)||this.placeholderToNode.has(n)||(this.watchHostText(n),h(n)&&(this.addContent(n),e=!0));this.syncWhitespace(),this.sortSlots()&&(e=!0),e&&this.handleChange()})}sortSlots(){let e=!1;for(let t of this.nodesBySlot.values()){if(!t.every(e=>this.nodeToPlaceholder.has(e)))continue;let n=t.map(e=>({node:this.nodeToPlaceholder.get(e),real:e})).sort(S).map(({real:e})=>e);n.every((e,n)=>e===t[n])||(t.splice(0,t.length,...n),n.forEach(b),e=!0)}return e}handleChange(){this.syncWhitespace(),this.generation++,this.notifyDirectives();for(let e of this.subscribers)e.handleChange();this.host.requestUpdate()}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}asOwnChange(e){let t=this.inOwnChange;this.inOwnChange=!0;try{e()}finally{t||(this.observer?.takeRecords(),this.inOwnChange=!1)}}addContent(e){e instanceof HTMLTemplateElement?_(e,this.nodesBySlot):this.insertInSlotOrder(e),this.track(e)}removeContent(e){this.untrack(e),this.removeFromSlots(e)}track(e){this.trackedNodes.add(e),s.set(e,this),C(e)}untrack(e){this.trackedNodes.delete(e),s.get(e)===this&&s.delete(e)}insertInSlotOrder(e){let t=f(e),n=this.nodesBySlot.get(t)??[];this.nodesBySlot.set(t,n);let r=this.nodeToPlaceholder.get(e)??e,i=e=>{let t=this.nodeToPlaceholder.get(e)??e;return!!(r.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)},a=n.length;for(;a>0&&i(n[a-1]);)a--;n.splice(a,0,e)}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}};a=T,a.PLACEHOLDER_PREFIX=`pkt-slot`;var E=class extends t.t{constructor(t){if(super(t),this.manager=null,this.host=null,this.part=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(t,[n,r]){return this.part=t,this.host=n,this.slotName=r,this.manager||(this.manager=l(n),this.manager.collectNodes(),this.manager.addDirective(this)),this.placeNodes(),e.g}handleNodesChanged(){this.isConnected&&this.manager&&this.placeNodes()}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){this.host&&(this.manager=l(this.host),this.manager.addDirective(this),this.placeNodes())}contains(e){let t=this.parentOfPart();return!this.isConnected||!t?!1:this.isInsidePart(e,t,this.coversContainer(t))}bounds(){return{startNode:this.part?.startNode??null,endNode:this.part?.endNode??null}}parentOfPart(){return this.part?this.part.startNode?this.part.startNode.parentNode:this.part.parentNode:null}placeNodes(){if(!this.manager||!this.part)return;let e=this.manager.generation;if(e===this.lastGeneration)return;this.lastGeneration=e;let t=this.parentOfPart();if(!t)return;let n=this.manager.placementNodes(this.slotName),r=this.coversContainer(t),i=this.part.endNode;for(let e=n.length-1;e>=0;e--){let a=n[e];this.isInsidePart(a,t,r)||(this.manager.ensurePlaceholder(a),y(t,a,i)),i=a}}coversContainer(e){let{startNode:t,endNode:n}=this.part;return!n&&(!t||t===e.firstChild)}isInsidePart(e,t,n){if(!this.part||e.parentNode!==t)return!1;if(n)return!0;let{startNode:r,endNode:i}=this.part,a=!r||!!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING),o=!i||!!(e.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING);return a&&o}},D=e.f(E),O=class extends t.t{constructor(t){if(super(t),this.target=null,this.source=null,this.mapping=[],t.type!==e.m.ELEMENT)throw Error(`forwardSlots() can only be used as an element directive`)}render(t,n){return e.g}update(t,[n,r]){let i=t.element;return typeof i.addController==`function`?this.connect(i,n,r):customElements.whenDefined(i.localName).then(()=>{this.isConnected&&this.connect(i,n,r)}),e.g}connect(e,t,n){let r=l(e);this.target&&this.target!==r&&this.target.removeSource(this),this.target=r,this.source=l(t),this.source.collectNodes(),this.mapping=p(n),this.target.addSource(this,this.source,this.mapping)}disconnected(){this.target?.removeSource(this)}reconnected(){this.target&&this.source&&this.target.addSource(this,this.source,this.mapping)}},k=e.f(O),A=new Map;function j(e){if(A.has(e))return A.get(e);let t,n=HTMLElement.prototype;for(;!t&&n;)t=Object.getOwnPropertyDescriptor(n,e),n=Object.getPrototypeOf(n);return A.set(e,t),t}function M(e,t){return t.some(t=>typeof t!=`string`&&t.contains(e))}var N=class extends e.t{connectedCallback(){l(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return l(this).hasContent(e)}appendChild(e){let t=l(this);return t.moveDistributed(e,null)?e:t.handleNow(()=>super.insertBefore(e,t.positionInHost(null)))}append(...e){if(M(this,e)){super.append(...e);return}let t=l(this);t.handleNow(()=>{let n=document.createDocumentFragment();n.append(...e),super.insertBefore(n,t.positionInHost(null))})}prepend(...e){l(this).handleNow(()=>super.prepend(...e))}insertBefore(e,t){let n=l(this);return n.moveDistributed(e,t)?e:n.handleNow(()=>super.insertBefore(e,n.positionInHost(t)))}removeChild(e){let t=l(this);return e.parentNode===this||!t.owns(e)?super.removeChild(e):t.handleNow(()=>(e.parentNode?.removeChild(e),e))}replaceChild(e,t){let n=l(this);return t.parentNode===this||!n.owns(t)?super.replaceChild(e,t):n.handleNow(()=>(super.insertBefore(e,n.positionInHost(t)),t.parentNode?.removeChild(t),t))}replaceChildren(...e){let t=e.map(e=>typeof e==`string`?document.createTextNode(e):e);l(this).replaceContent(t)||super.replaceChildren(...e)}get textContent(){return j(`textContent`).get.call(this)}set textContent(e){let t=e==null?``:String(e);l(this).replaceContent(t?[document.createTextNode(t)]:[])||j(`textContent`).set.call(this,e)}get innerHTML(){return j(`innerHTML`).get.call(this)}set innerHTML(e){let t=document.createElement(`template`);t.innerHTML=e,l(this).replaceContent(Array.from(t.content.childNodes))||j(`innerHTML`).set.call(this,e)}get innerText(){let e=j(`innerText`);return e?.get?e.get.call(this):this.textContent}set innerText(e){let t=j(`innerText`);if(!t?.set){this.textContent=e;return}let n=document.createElement(`div`);t.set.call(n,e),l(this).replaceContent(Array.from(n.childNodes))||t.set.call(this,e)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return N}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../shared-types/header-footer.ts
|
|
2
2
|
var e = "https://cdn.web.oslo.kommune.no/header-footer/header-footer.json", t = "https://www.oslo.kommune.no", n = {
|
|
3
3
|
automat: "parking-meter",
|
|
4
4
|
bike: "bicycle",
|
|
@@ -51,14 +51,12 @@ function o(e, t) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
//#region ../../shared-utils/header-footer/select-megamenu.ts
|
|
54
|
+
// ../../shared-utils/header-footer/select-megamenu.ts
|
|
56
55
|
var s = "nb-NO";
|
|
57
56
|
function c(e, t = s) {
|
|
58
57
|
if (e) return e[t] ?? e[s];
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
//#region ../../shared-utils/header-footer/fetch-header-footer-data.ts
|
|
59
|
+
// ../../shared-utils/header-footer/fetch-header-footer-data.ts
|
|
62
60
|
var l = /* @__PURE__ */ new Map();
|
|
63
61
|
async function u(e) {
|
|
64
62
|
let t = await fetch(e);
|
|
@@ -84,5 +82,4 @@ async function p(t = e, n) {
|
|
|
84
82
|
let r = l.get(t);
|
|
85
83
|
return r || (r = u(t), r.catch(() => l.delete(t)), l.set(t, r)), d(r, n);
|
|
86
84
|
}
|
|
87
|
-
//#endregion
|
|
88
85
|
export { e as a, r as i, c as n, t as o, o as r, p as t };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { _ as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./element-
|
|
2
|
-
import { t as s } from "./class-map-
|
|
3
|
-
import { n as c, t as l } from "./format-
|
|
4
|
-
import "./alert-
|
|
5
|
-
import "./icon-
|
|
6
|
-
import "./input-wrapper-
|
|
7
|
-
import "./progressbar-
|
|
8
|
-
import { t as u } from "./if-defined-
|
|
9
|
-
import { t as d } from "./converters-
|
|
10
|
-
import { n as f } from "./utils-
|
|
11
|
-
import { r as p } from "./focus-trap-
|
|
12
|
-
import "./modal-
|
|
13
|
-
|
|
1
|
+
import { _ as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./element-Bwc-likm.js";
|
|
2
|
+
import { t as s } from "./class-map-C9n5CNC8.js";
|
|
3
|
+
import { n as c, t as l } from "./format-DwjTfa9h.js";
|
|
4
|
+
import "./alert-ZrB-P881.js";
|
|
5
|
+
import "./icon-CZDw42U7.js";
|
|
6
|
+
import "./input-wrapper-DYg1VHPv.js";
|
|
7
|
+
import "./progressbar-DlbkKRgP.js";
|
|
8
|
+
import { t as u } from "./if-defined-B3pYog2C.js";
|
|
9
|
+
import { t as d } from "./converters-v_GK06o3.js";
|
|
10
|
+
import { n as f } from "./utils-Dn5ykFtS.js";
|
|
11
|
+
import { r as p } from "./focus-trap-C-PcFOw6.js";
|
|
12
|
+
import "./modal-SBJ8aGvM.js";
|
|
13
|
+
// ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
15
15
|
if (e == null || e === "") return;
|
|
16
16
|
if (typeof e == "number") return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
@@ -33,8 +33,7 @@ function m(e) {
|
|
|
33
33
|
function h(e) {
|
|
34
34
|
return e < 1024 ? `${Math.round(e)} B` : e < 1048576 ? `${Math.round(e / 1024)} KB` : e < 1073741824 ? `${Math.round(e / 1048576)} MB` : `${Math.round(e / 1073741824)} GB`;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
//#region ../../shared-utils/fileupload/formats.ts
|
|
36
|
+
// ../../shared-utils/fileupload/formats.ts
|
|
38
37
|
function g(e) {
|
|
39
38
|
return Array.isArray(e) ? e.map((e) => String(e).trim().toLowerCase()).filter(Boolean) : [];
|
|
40
39
|
}
|
|
@@ -73,8 +72,7 @@ function S(e, t) {
|
|
|
73
72
|
let r = _(t);
|
|
74
73
|
return r.length > 0 ? r.map(x).join(", ") : "";
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
//#region ../../shared-utils/fileupload/validation.ts
|
|
75
|
+
// ../../shared-utils/fileupload/validation.ts
|
|
78
76
|
function C(e, t, n) {
|
|
79
77
|
return ((e ?? "").trim() || t).replace(/\{(\w+)\}/g, (e, t) => n[t] ?? `{${t}}`);
|
|
80
78
|
}
|
|
@@ -101,8 +99,7 @@ function T(e) {
|
|
|
101
99
|
let n = e.attributes?.targetFilename || t?.name || "";
|
|
102
100
|
return /\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n);
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
//#region ../../shared-utils/fileupload/transfers.ts
|
|
102
|
+
// ../../shared-utils/fileupload/transfers.ts
|
|
106
103
|
function E(e) {
|
|
107
104
|
return typeof e == "number" ? "in-progress" : e === "error" ? "error" : "idle";
|
|
108
105
|
}
|
|
@@ -123,21 +120,18 @@ function ee(e, t, n) {
|
|
|
123
120
|
};
|
|
124
121
|
}).sort((e, t) => r[E(e.progress)] - r[E(t.progress)]);
|
|
125
122
|
}
|
|
126
|
-
|
|
127
|
-
//#region ../../shared-utils/fileupload/truncate.ts
|
|
123
|
+
// ../../shared-utils/fileupload/truncate.ts
|
|
128
124
|
function D(e, t) {
|
|
129
125
|
return !t || t <= 0 || e.length <= t + 3 ? null : {
|
|
130
126
|
head: e.slice(0, e.length - t),
|
|
131
127
|
tail: e.slice(-t)
|
|
132
128
|
};
|
|
133
129
|
}
|
|
134
|
-
|
|
135
|
-
//#region ../../shared-utils/fileupload/navigation.ts
|
|
130
|
+
// ../../shared-utils/fileupload/navigation.ts
|
|
136
131
|
function O(e, t, n) {
|
|
137
132
|
return n <= 0 ? 0 : t === "prev" ? e <= 0 ? n - 1 : e - 1 : e >= n - 1 ? 0 : e + 1;
|
|
138
133
|
}
|
|
139
|
-
|
|
140
|
-
//#region ../../shared-utils/fileupload/announcements.ts
|
|
134
|
+
// ../../shared-utils/fileupload/announcements.ts
|
|
141
135
|
function k(e, t) {
|
|
142
136
|
let n = e.length;
|
|
143
137
|
if (n === 0 || !t || t.length === 0) return {
|
|
@@ -156,24 +150,22 @@ function k(e, t) {
|
|
|
156
150
|
failedCount: i
|
|
157
151
|
};
|
|
158
152
|
}
|
|
159
|
-
|
|
160
|
-
//#region ../../shared-utils/fileupload/filename.ts
|
|
153
|
+
// ../../shared-utils/fileupload/filename.ts
|
|
161
154
|
function A(e, t = i.fileupload.unknownFilename) {
|
|
162
155
|
return e.attributes?.targetFilename || e.file?.name || t;
|
|
163
156
|
}
|
|
164
|
-
|
|
165
|
-
//#region src/components/fileupload/fileupload-base.ts
|
|
157
|
+
// src/components/fileupload/fileupload-base.ts
|
|
166
158
|
var j = class extends a {
|
|
167
159
|
constructor(...e) {
|
|
168
160
|
super(...e), this.id = `pkt-fileupload-${f()}`, this.name = "files", this.label = "", this.helptext = "", this.helptextDropdown = "", this.required = !1, this.multiple = !1, this.disabled = !1, this.fullwidth = !1, this.uploadStrategy = "form", this.itemRenderer = "filename", this.accept = "", this.allowedFormats = [], this.formatErrorMessage = "", this.sizeErrorMessage = "", this.transfers = [], this.addCommentsEnabled = !1, this.renameFilesEnabled = !1, this.extraOperations = [], this.enableImagePreview = !1, this.hasError = !1, this.errorMessage = "", this.optionalTag = !1, this.requiredTag = !1, this.tagText = null, this.truncateTail = 4, this.files = [], this.isDragActive = !1, this.validationErrorMessage = null, this.addedAnnouncement = "", this.thumbnailUrls = {}, this.hasInitializedValue = !1, this.hasWarnedInvalidValueCombo = !1, this.thumbnailFileById = /* @__PURE__ */ new Map(), this.connectedForm = null, this.addedAnnouncementTimer = null, this.onNativeFileChange = (e) => {
|
|
169
161
|
let t = e.target;
|
|
170
162
|
this.addFiles(t.files ? Array.from(t.files) : []), this.uploadStrategy === "custom" && (t.value = "");
|
|
171
163
|
}, this.openFileDialog = (e) => {
|
|
172
|
-
e.preventDefault(), e.stopPropagation(),
|
|
164
|
+
e.preventDefault(), e.stopPropagation(), this.disabled || this.querySelector(`#${this.id}-input`)?.click();
|
|
173
165
|
}, this.onDropZoneClick = (e) => {
|
|
174
166
|
this.disabled || e.target.closest(".pkt-fileupload__drop-zone__placeholder__title__open-file-dialog") || this.querySelector(`#${this.id}-input`)?.click();
|
|
175
167
|
}, this.onDragOver = (e) => {
|
|
176
|
-
e.preventDefault(),
|
|
168
|
+
e.preventDefault(), this.disabled || (this.isDragActive = !0);
|
|
177
169
|
}, this.onDragLeave = () => {
|
|
178
170
|
this.isDragActive = !1;
|
|
179
171
|
}, this.onDrop = (e) => {
|
|
@@ -481,8 +473,7 @@ r([o({ type: String })], j.prototype, "id", void 0), r([o({ type: String })], j.
|
|
|
481
473
|
type: Number,
|
|
482
474
|
attribute: "truncate-tail"
|
|
483
475
|
})], j.prototype, "truncateTail", void 0), r([o({ attribute: !1 })], j.prototype, "value", void 0), r([o({ attribute: !1 })], j.prototype, "defaultValue", void 0), r([n()], j.prototype, "files", void 0), r([n()], j.prototype, "isDragActive", void 0), r([n()], j.prototype, "validationErrorMessage", void 0), r([n()], j.prototype, "addedAnnouncement", void 0), r([n()], j.prototype, "thumbnailUrls", void 0);
|
|
484
|
-
|
|
485
|
-
//#region src/components/fileupload/fileupload-operations.ts
|
|
476
|
+
// src/components/fileupload/fileupload-operations.ts
|
|
486
477
|
var M = "comments", N = (e, t) => {
|
|
487
478
|
let n = new Date(e);
|
|
488
479
|
if (Number.isNaN(n.getTime())) return e;
|
|
@@ -1391,8 +1382,6 @@ var M = "comments", N = (e, t) => {
|
|
|
1391
1382
|
}
|
|
1392
1383
|
};
|
|
1393
1384
|
r([n()], $.prototype, "activeOperationByFileId", void 0), r([n()], $.prototype, "isPreviewModalOpen", void 0), r([n()], $.prototype, "previewCurrentIndex", void 0), r([n()], $.prototype, "failedImageFileIds", void 0), $ = r([t("pkt-fileupload")], $);
|
|
1394
|
-
|
|
1395
|
-
//#region src/components/fileupload/index.ts
|
|
1385
|
+
// src/components/fileupload/index.ts
|
|
1396
1386
|
var ne = $;
|
|
1397
|
-
//#endregion
|
|
1398
1387
|
export { $ as n, ne as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-DkyTTo7S.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-C_Rzwxx7.cjs"),require("./progressbar-BdqIhC1Z.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-CW6SN0TT.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-BvTfLfFq.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.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)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./class-map-C82GtM1w.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-0a5lX0pL.cjs"),require("./icon-5A378_yh.cjs"),require("./input-wrapper-CbYMk21W.cjs"),require("./progressbar-Wyq_Q1Ur.cjs");const r=require("./if-defined-Ci4ZQsgL.cjs"),i=require("./converters-Dp64-kF1.cjs"),a=require("./utils-63cRpWut.cjs"),o=require("./focus-trap-C9tsr-xL.cjs");require("./modal-B3rnE83a.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),this.disabled||this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),this.disabled||(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{this.required&&this.uploadStrategy===`custom`&&(this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault()))}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.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)):(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),this.hasInitializedValue=!0)}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`)||e.has(`form`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(e&&typeof DataTransfer<`u`)try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(typeof URL>`u`||typeof URL.createObjectURL!=`function`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){typeof URL>`u`||typeof URL.revokeObjectURL!=`function`?(this.thumbnailUrls={},this.thumbnailFileById.clear()):(Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear())}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}get ownerForm(){if(this.form!==void 0){if(!this.form)return null;let e=this.ownerDocument?.getElementById(this.form);return e instanceof HTMLFormElement?e:null}return this.closest(`form`)}syncFormSubmitListener(){let e=this.ownerForm;this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String,reflect:!0})],T.prototype,`form`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=(e,t)=>{let r=new Date(e);if(Number.isNaN(r.getTime()))return e;let i=String(r.getDate()).padStart(2,`0`),a=String(r.getMonth()+1).padStart(2,`0`),o=r.getFullYear(),s=String(r.getHours()).padStart(2,`0`),c=String(r.getMinutes()).padStart(2,`0`);return n.t(t.commentTimestamp,{date:`${i}.${a}.${o}`,time:`${s}:${c}`})},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=(e,t)=>({id:`remove`,title:t.remove,ariaLabel:t.removeFile,onClick:({file:t})=>e(t.fileId)}),j=t=>({id:`rename`,title:t.rename,ariaLabel:t.renameFile,renderInlineUI:n=>{let r=n.getAttribute(`targetFilename`)||n.file.attributes?.targetFilename||n.file.file?.name||``,i=`pkt-fileupload-rename-${n.file.fileId}`,a=()=>{let e=document.getElementById(i)?.value?.trim();e&&n.setAttribute(`targetFilename`,e),n.close()};return e._`
|
|
2
2
|
<label for=${i} class="pkt-sr-only">${t.renameInputLabel}</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${i}
|
package/dist/{focus-modality-controller-Dc2S-KqR.js → focus-modality-controller-DVsT6GeR.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/controllers/focus-modality-controller.ts
|
|
2
2
|
var e = class {
|
|
3
3
|
constructor(e, t = null) {
|
|
4
4
|
this.pointerJustUsed = !1, this.handlePointerDown = () => {
|
|
@@ -25,5 +25,4 @@ var e = class {
|
|
|
25
25
|
t && (e === void 0 ? delete t.dataset.navtype : t.dataset.navtype = e);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { e as t };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// ../../shared-utils/focus-trap/index.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e ? Array.from(e.querySelectorAll("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\"])")).filter((e) => !e.hasAttribute("inert")) : [];
|
|
4
|
+
}
|
|
5
|
+
var t = (e) => {
|
|
6
|
+
if (e.hasAttribute("inert") || e.closest("[inert]") || e.hidden || e.closest("[hidden]")) return !0;
|
|
7
|
+
let t = e;
|
|
8
|
+
for (; t;) {
|
|
9
|
+
let n = t.closest("details");
|
|
10
|
+
if (!n) break;
|
|
11
|
+
if (!n.hasAttribute("open")) {
|
|
12
|
+
let t = n.querySelector(":scope > summary");
|
|
13
|
+
if (!t || !t.contains(e)) return !0;
|
|
14
|
+
}
|
|
15
|
+
t = n.parentElement;
|
|
16
|
+
}
|
|
17
|
+
return !1;
|
|
18
|
+
}, n = (e, r) => {
|
|
19
|
+
e.matches("a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex=\"-1\"])") && !t(e) && r.push(e);
|
|
20
|
+
let i = e.shadowRoot;
|
|
21
|
+
if (i) for (let e of Array.from(i.children)) n(e, r);
|
|
22
|
+
for (let t of Array.from(e.children)) n(t, r);
|
|
23
|
+
};
|
|
24
|
+
function r(e) {
|
|
25
|
+
if (!e) return [];
|
|
26
|
+
let t = [];
|
|
27
|
+
for (let r of Array.from(e.children)) n(r, t);
|
|
28
|
+
return t;
|
|
29
|
+
}
|
|
30
|
+
function i(e = document) {
|
|
31
|
+
let t = e.activeElement;
|
|
32
|
+
for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
function a(t, n) {
|
|
36
|
+
if (t.key !== "Tab") return !1;
|
|
37
|
+
let r = e(n);
|
|
38
|
+
if (r.length === 0) return t.preventDefault(), !0;
|
|
39
|
+
let i = r[0], a = r[r.length - 1], o = (n?.ownerDocument ?? document).activeElement, s = !!o && r.includes(o);
|
|
40
|
+
return t.shiftKey ? !s || o === i ? (t.preventDefault(), a.focus(), !0) : !1 : !s || o === a ? (t.preventDefault(), i.focus(), !0) : !1;
|
|
41
|
+
}
|
|
42
|
+
export { r as n, a as r, i as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e?Array.from(e.querySelectorAll(`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"])`)).filter(e=>!e.hasAttribute(`inert`)):[]}var t=e=>{if(e.hasAttribute(`inert`)||e.closest(`[inert]`)||e.hidden||e.closest(`[hidden]`))return!0;let t=e;for(;t;){let n=t.closest(`details`);if(!n)break;if(!n.hasAttribute(`open`)){let t=n.querySelector(`:scope > summary`);if(!t||!t.contains(e))return!0}t=n.parentElement}return!1},n=(e,r)=>{e.matches(`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])`)&&!t(e)&&r.push(e);let i=e.shadowRoot;if(i)for(let e of Array.from(i.children))n(e,r);for(let t of Array.from(e.children))n(t,r)};function r(e){if(!e)return[];let t=[];for(let r of Array.from(e.children))n(r,t);return t}function i(e=document){let t=e.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function a(t,n){if(t.key!==`Tab`)return!1;let r=e(n);if(r.length===0)return t.preventDefault(),!0;let i=r[0],a=r[r.length-1],o=(n?.ownerDocument??document).activeElement,s=!!o&&r.includes(o);return t.shiftKey?!s||o===i?(t.preventDefault(),a.focus(),!0):!1:!s||o===a?(t.preventDefault(),i.focus(),!0):!1}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const e=require("./element-CEarCnHH.cjs")
|
|
2
|
-
<a href=${
|
|
3
|
-
>${
|
|
1
|
+
const e=require("./element-CEarCnHH.cjs"),t=require("./if-defined-Ci4ZQsgL.cjs"),n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./shared-types-BvRk9kiK.cjs"),require("./consent-BOSXNt4Y.cjs"),require("./icon-5A378_yh.cjs");var i=`oslo.kommune.no`,a=/\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;function o(e){let t=e.toLowerCase().replace(/\.$/,``),n=t.split(`.`);return n.length<=2?t:n.slice(a.test(t)?-3:-2).join(`.`)}function s(e){if(!e)return;let t;try{t=new URL(e)}catch{return}if(t.protocol===`http:`||t.protocol===`https:`)return o(t.hostname.toLowerCase().replace(/\.$/,``))}function c(e,t=i){if(!e)return;let n;try{n=new URL(e)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=n.hostname.toLowerCase().replace(/\.$/,``),a=t.toLowerCase();if(!(r===a||r.endsWith(`.${a}`)))return o(r)}var l=`#cb-trigger`,u=class extends e.t{constructor(...e){super(...e),this.locale=`nb-NO`,this.skipGlobal=!1,this.openLinksInNewTab=!1,this.includeConsent=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.devMode=!1,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null}connectedCallback(){super.connectedCallback(),!this.data&&!this.skipGlobal&&this.loadData()}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort()}updated(e){super.updated(e),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData()}async loadData(){this.abortController?.abort(),this.abortController=new AbortController;try{this.fetchedData=await r.t(this.dataUrl,this.abortController.signal)}catch(e){if(e.name===`AbortError`)return;console.warn(`Failed to fetch header/footer data:`,e),this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get globalFooterData(){return r.n(this.data??this.fetchedData,this.locale)?.footer}linkTarget(e){return e.openInNewTab||this.openLinksInNewTab?{target:`_blank`,rel:`noopener noreferrer`}:{target:`_self`}}renderLinkDomain(t,n=`pkt-footer__link-domain`){if(!t.external)return e.h;let r=s(t.href);return r?e._` <span class=${n}>(${r})</span>`:e.h}renderCustomLink(n){let{target:r,rel:i}=this.linkTarget(n);return e._`
|
|
2
|
+
<a href=${n.href} target=${r} rel=${t.t(i)}
|
|
3
|
+
>${n.text}${this.renderLinkDomain(n)}</a
|
|
4
4
|
>
|
|
5
5
|
`}renderConsent(){return this.includeConsent?e._`
|
|
6
6
|
<pkt-consent
|
|
@@ -38,10 +38,10 @@ const e=require("./element-CEarCnHH.cjs");require("./consent-UkinU27V.cjs");cons
|
|
|
38
38
|
${t.links.map(e=>this.renderGlobalSectionLink(e))}
|
|
39
39
|
</ul>
|
|
40
40
|
</section>
|
|
41
|
-
`}renderSomeLink(t){let r
|
|
41
|
+
`}renderSomeLink(t){let n=r.r(t.url,t.text);return n?e._`
|
|
42
42
|
<li>
|
|
43
43
|
<a class="pkt-footer__some-link" href=${t.url} aria-label=${t.text}>
|
|
44
|
-
<pkt-icon class="pkt-footer__some-icon" name=${
|
|
44
|
+
<pkt-icon class="pkt-footer__some-icon" name=${n}></pkt-icon>
|
|
45
45
|
</a>
|
|
46
46
|
</li>
|
|
47
47
|
`:e._`<li><a href=${t.url}>${t.text}</a></li>`}renderGlobalBottom(t){let n=t.links?.length>0,r=t.some?.length>0;return!n&&!r?e.h:e._`
|
|
@@ -66,7 +66,7 @@ const e=require("./element-CEarCnHH.cjs");require("./consent-UkinU27V.cjs");cons
|
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
68
68
|
</div>
|
|
69
|
-
`:e.h}};e.n([e.u({type:String,attribute:`data-url`})],u.prototype,`dataUrl`,void 0),e.n([e.u({type:Object,attribute:!1})],u.prototype,`data`,void 0),e.n([e.u({type:String})],u.prototype,`locale`,void 0),e.n([e.u({type:Boolean,attribute:`skip-global`,converter:
|
|
69
|
+
`:e.h}};e.n([e.u({type:String,attribute:`data-url`})],u.prototype,`dataUrl`,void 0),e.n([e.u({type:Object,attribute:!1})],u.prototype,`data`,void 0),e.n([e.u({type:String})],u.prototype,`locale`,void 0),e.n([e.u({type:Boolean,attribute:`skip-global`,converter:n.t})],u.prototype,`skipGlobal`,void 0),e.n([e.u({type:Boolean,attribute:`open-links-in-new-tab`,converter:n.t})],u.prototype,`openLinksInNewTab`,void 0),e.n([e.u({type:Boolean,attribute:`include-consent`,converter:n.t})],u.prototype,`includeConsent`,void 0),e.n([e.u({type:String,attribute:`hotjar-id`})],u.prototype,`hotjarId`,void 0),e.n([e.u({type:String,attribute:`google-analytics-id`})],u.prototype,`googleAnalyticsId`,void 0),e.n([e.u({type:Boolean,attribute:`dev-mode`,converter:n.t})],u.prototype,`devMode`,void 0),e.n([e.u({type:String,attribute:`cookie-domain`})],u.prototype,`cookieDomain`,void 0),e.n([e.u({type:String,attribute:`cookie-secure`})],u.prototype,`cookieSecure`,void 0),e.n([e.u({type:String,attribute:`cookie-expiry-days`})],u.prototype,`cookieExpiryDays`,void 0),e.n([e.l()],u.prototype,`fetchedData`,void 0);var d=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-host`)}renderColumn(t){return e._`
|
|
70
70
|
<section>
|
|
71
71
|
<h2>${t.title}</h2>
|
|
72
72
|
${t.text?e._`<p>${t.text}</p>`:e.h}
|
|
@@ -92,10 +92,10 @@ const e=require("./element-CEarCnHH.cjs");require("./consent-UkinU27V.cjs");cons
|
|
|
92
92
|
${t||n?this.renderSecondary():e.h}
|
|
93
93
|
${this.renderGlobalFooter()}
|
|
94
94
|
</footer>
|
|
95
|
-
`}};e.n([e.u({type:Array})],d.prototype,`columns`,void 0);try{e.d(`pkt-footer`)(d)}catch{console.warn(`Forsøker å definere <pkt-footer>, men den er allerede definert`)}var f=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-simple-host`)}renderLink(
|
|
96
|
-
<a class="pkt-footer-simple__link" href=${
|
|
95
|
+
`}};e.n([e.u({type:Array})],d.prototype,`columns`,void 0);try{e.d(`pkt-footer`)(d)}catch{console.warn(`Forsøker å definere <pkt-footer>, men den er allerede definert`)}var f=class extends u{connectedCallback(){super.connectedCallback(),this.classList.add(`pkt-footer-simple-host`)}renderLink(n){let{target:r,rel:i}=this.linkTarget(n);return e._`
|
|
96
|
+
<a class="pkt-footer-simple__link" href=${n.href} target=${r} rel=${t.t(i)}>
|
|
97
97
|
<pkt-icon class="pkt-footer-simple__link-icon" name="arrow-link"></pkt-icon>
|
|
98
|
-
<span>${
|
|
98
|
+
<span>${n.text}${this.renderLinkDomain(n,`pkt-footer-simple__link-domain`)}</span>
|
|
99
99
|
</a>
|
|
100
100
|
`}render(){let t=!!this.links?.length,n=this.skipGlobal&&this.includeConsent;return e._`
|
|
101
101
|
<footer class="pkt-footer-simple">
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-
|
|
2
|
-
import "./
|
|
3
|
-
import { t as
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
6
|
-
import "./
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-Bwc-likm.js";
|
|
2
|
+
import { t as s } from "./if-defined-B3pYog2C.js";
|
|
3
|
+
import { t as c } from "./booleanish-CBa3Cr2h.js";
|
|
4
|
+
import { n as l, r as u, t as d } from "./fetch-header-footer-data-CPVt_P8s.js";
|
|
5
|
+
import "./shared-types-BvRk9kiK.js";
|
|
6
|
+
import "./consent-DwppvYBR.js";
|
|
7
|
+
import "./icon-CZDw42U7.js";
|
|
8
|
+
// ../../shared-utils/header-footer/external-domain.ts
|
|
9
9
|
var f = "oslo.kommune.no", p = /\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;
|
|
10
10
|
function m(e) {
|
|
11
11
|
let t = e.toLowerCase().replace(/\.$/, ""), n = t.split(".");
|
|
@@ -33,8 +33,7 @@ function g(e, t = f) {
|
|
|
33
33
|
let r = n.hostname.toLowerCase().replace(/\.$/, ""), i = t.toLowerCase();
|
|
34
34
|
if (!(r === i || r.endsWith(`.${i}`))) return m(r);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
//#region src/components/footer/footer-base.ts
|
|
36
|
+
// src/components/footer/footer-base.ts
|
|
38
37
|
var _ = "#cb-trigger", v = class extends a {
|
|
39
38
|
constructor(...e) {
|
|
40
39
|
super(...e), this.locale = "nb-NO", this.skipGlobal = !1, this.openLinksInNewTab = !1, this.includeConsent = !1, this.hotjarId = null, this.googleAnalyticsId = null, this.devMode = !1, this.cookieDomain = null, this.cookieSecure = null, this.cookieExpiryDays = null;
|
|
@@ -51,7 +50,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
51
50
|
async loadData() {
|
|
52
51
|
this.abortController?.abort(), this.abortController = new AbortController();
|
|
53
52
|
try {
|
|
54
|
-
this.fetchedData = await
|
|
53
|
+
this.fetchedData = await d(this.dataUrl, this.abortController.signal);
|
|
55
54
|
} catch (e) {
|
|
56
55
|
if (e.name === "AbortError") return;
|
|
57
56
|
console.warn("Failed to fetch header/footer data:", e), this.dispatchEvent(new CustomEvent("data-error", {
|
|
@@ -62,7 +61,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
get globalFooterData() {
|
|
65
|
-
return
|
|
64
|
+
return l(this.data ?? this.fetchedData, this.locale)?.footer;
|
|
66
65
|
}
|
|
67
66
|
linkTarget(e) {
|
|
68
67
|
return e.openInNewTab || this.openLinksInNewTab ? {
|
|
@@ -78,7 +77,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
78
77
|
renderCustomLink(t) {
|
|
79
78
|
let { target: n, rel: r } = this.linkTarget(t);
|
|
80
79
|
return e`
|
|
81
|
-
<a href=${t.href} target=${n} rel=${
|
|
80
|
+
<a href=${t.href} target=${n} rel=${s(r)}
|
|
82
81
|
>${t.text}${this.renderLinkDomain(t)}</a
|
|
83
82
|
>
|
|
84
83
|
`;
|
|
@@ -131,7 +130,7 @@ var _ = "#cb-trigger", v = class extends a {
|
|
|
131
130
|
`;
|
|
132
131
|
}
|
|
133
132
|
renderSomeLink(t) {
|
|
134
|
-
let n =
|
|
133
|
+
let n = u(t.url, t.text);
|
|
135
134
|
return n ? e`
|
|
136
135
|
<li>
|
|
137
136
|
<a class="pkt-footer__some-link" href=${t.url} aria-label=${t.text}>
|
|
@@ -181,15 +180,15 @@ i([o({
|
|
|
181
180
|
})], v.prototype, "data", void 0), i([o({ type: String })], v.prototype, "locale", void 0), i([o({
|
|
182
181
|
type: Boolean,
|
|
183
182
|
attribute: "skip-global",
|
|
184
|
-
converter:
|
|
183
|
+
converter: c
|
|
185
184
|
})], v.prototype, "skipGlobal", void 0), i([o({
|
|
186
185
|
type: Boolean,
|
|
187
186
|
attribute: "open-links-in-new-tab",
|
|
188
|
-
converter:
|
|
187
|
+
converter: c
|
|
189
188
|
})], v.prototype, "openLinksInNewTab", void 0), i([o({
|
|
190
189
|
type: Boolean,
|
|
191
190
|
attribute: "include-consent",
|
|
192
|
-
converter:
|
|
191
|
+
converter: c
|
|
193
192
|
})], v.prototype, "includeConsent", void 0), i([o({
|
|
194
193
|
type: String,
|
|
195
194
|
attribute: "hotjar-id"
|
|
@@ -199,7 +198,7 @@ i([o({
|
|
|
199
198
|
})], v.prototype, "googleAnalyticsId", void 0), i([o({
|
|
200
199
|
type: Boolean,
|
|
201
200
|
attribute: "dev-mode",
|
|
202
|
-
converter:
|
|
201
|
+
converter: c
|
|
203
202
|
})], v.prototype, "devMode", void 0), i([o({
|
|
204
203
|
type: String,
|
|
205
204
|
attribute: "cookie-domain"
|
|
@@ -210,8 +209,7 @@ i([o({
|
|
|
210
209
|
type: String,
|
|
211
210
|
attribute: "cookie-expiry-days"
|
|
212
211
|
})], v.prototype, "cookieExpiryDays", void 0), i([r()], v.prototype, "fetchedData", void 0);
|
|
213
|
-
|
|
214
|
-
//#region src/components/footer/footer.ts
|
|
212
|
+
// src/components/footer/footer.ts
|
|
215
213
|
var y = class extends v {
|
|
216
214
|
connectedCallback() {
|
|
217
215
|
super.connectedCallback(), this.classList.add("pkt-footer-host");
|
|
@@ -260,8 +258,7 @@ try {
|
|
|
260
258
|
} catch {
|
|
261
259
|
console.warn("Forsøker å definere <pkt-footer>, men den er allerede definert");
|
|
262
260
|
}
|
|
263
|
-
|
|
264
|
-
//#region src/components/footer/footer-simple.ts
|
|
261
|
+
// src/components/footer/footer-simple.ts
|
|
265
262
|
var b = class extends v {
|
|
266
263
|
connectedCallback() {
|
|
267
264
|
super.connectedCallback(), this.classList.add("pkt-footer-simple-host");
|
|
@@ -269,7 +266,7 @@ var b = class extends v {
|
|
|
269
266
|
renderLink(t) {
|
|
270
267
|
let { target: n, rel: r } = this.linkTarget(t);
|
|
271
268
|
return e`
|
|
272
|
-
<a class="pkt-footer-simple__link" href=${t.href} target=${n} rel=${
|
|
269
|
+
<a class="pkt-footer-simple__link" href=${t.href} target=${n} rel=${s(r)}>
|
|
273
270
|
<pkt-icon class="pkt-footer-simple__link-icon" name="arrow-link"></pkt-icon>
|
|
274
271
|
<span>${t.text}${this.renderLinkDomain(t, "pkt-footer-simple__link-domain")}</span>
|
|
275
272
|
</a>
|
|
@@ -300,5 +297,4 @@ try {
|
|
|
300
297
|
} catch {
|
|
301
298
|
console.warn("Forsøker å definere <pkt-footer-simple>, men den er allerede definert");
|
|
302
299
|
}
|
|
303
|
-
//#endregion
|
|
304
300
|
export { y as n, b as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../shared-strings/format.ts
|
|
2
2
|
var e = /\{(\w+)\}/g;
|
|
3
3
|
function t(t, n) {
|
|
4
4
|
return n ? t.replace(e, (e, r) => {
|
|
@@ -14,5 +14,4 @@ function i(e, t) {
|
|
|
14
14
|
let n = `${e}::${t}`;
|
|
15
15
|
r.has(n) || (r.add(n), console.warn(`[punkt] Mangler verdi for plassholderen {${e}} i teksten «${t}»`));
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { n, t };
|