scb-wc 0.1.239 → 0.1.240
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/README.md +16 -19
- package/all.d.ts +0 -14
- package/all.js +0 -14
- package/index.js +85 -99
- package/mvc/components/all.js +0 -9
- package/mvc/components/scb-accordion/scb-accordion-item.js +1 -1
- package/mvc/components/scb-accordion/scb-accordion.js +1 -1
- package/mvc/components/scb-app-bar/scb-app-bar.js +1 -1
- package/mvc/components/scb-button/scb-button.js +3 -3
- package/mvc/components/scb-calendar/scb-calendar.js +1 -1
- package/mvc/components/scb-calendar-card/scb-calendar-card.js +4 -4
- package/mvc/components/scb-card/scb-card.js +2 -2
- package/mvc/components/scb-cookies-consent/scb-cookies-consent.js +1 -1
- package/mvc/components/scb-dialog/scb-dialog.js +1 -1
- package/mvc/components/scb-drawer/scb-drawer.js +3 -3
- package/mvc/components/scb-drop-zone/scb-drop-zone.js +1 -1
- package/mvc/components/scb-dropdown/scb-dropdown.js +1 -1
- package/mvc/components/scb-fact-card/scb-fact-card.js +1 -1
- package/mvc/components/scb-header/scb-header.js +2 -2
- package/mvc/components/scb-horizontal-scroller/scb-horizontal-scroller.js +6 -6
- package/mvc/components/scb-icon-button/scb-icon-button.js +5 -5
- package/mvc/components/scb-keyfigure-card/scb-keyfigure-card.js +6 -6
- package/mvc/components/scb-link/scb-link.js +1 -1
- package/mvc/components/scb-link-button/scb-link-button.js +1 -1
- package/mvc/components/scb-list/scb-list-item.js +6 -6
- package/mvc/components/scb-menu/scb-menu-item.js +1 -1
- package/mvc/components/scb-nav/scb-nav.js +1 -1
- package/mvc/components/scb-notification-card/scb-notification-card.js +1 -1
- package/mvc/components/scb-options-menu/scb-options-menu-item.js +1 -1
- package/mvc/components/scb-options-menu/scb-options-menu.js +2 -2
- package/mvc/components/scb-options-menu/scb-options-sub-menu.js +1 -1
- package/mvc/components/scb-overlay/scb-overlay.js +3 -3
- package/mvc/components/scb-pagination/scb-pagination.js +1 -1
- package/mvc/components/scb-progress-stepper/scb-progress-step.js +1 -1
- package/mvc/components/scb-search/scb-search.js +3 -3
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +1 -1
- package/mvc/components/scb-select/scb-select-option.js +1 -1
- package/mvc/components/scb-select/scb-select.js +1 -1
- package/mvc/components/scb-snackbar/scb-snackbar.js +1 -1
- package/mvc/components/scb-stepper/scb-step.js +1 -1
- package/mvc/components/scb-table/scb-table.js +1 -1
- package/mvc/components/scb-table-advanced/scb-table-advanced.js +1 -1
- package/mvc/components/scb-textfield/scb-textfield.js +176 -34
- package/mvc/components/scb-toc/scb-toc-item.js +1 -1
- package/mvc/components/scb-tooltip/scb-tooltip.js +1 -1
- package/mvc/{components/shared → vendor}/component-size-token.js +1 -1
- package/mvc/vendor/lazy-focus-ring.js +2 -0
- package/mvc/vendor/lazy-ripple.js +2 -0
- package/mvc/{components/shared → vendor}/manual-popover.js +1 -1
- package/mvc/{components/scb-chevron → vendor}/scb-chevron.js +1 -1
- package/mvc/vendor/scb-icon-svg.js +11 -0
- package/package.json +2 -12
- package/scb-viz/scb-viz-series-differentiation-registry.js +7 -10
- package/scb-viz/scb-viz.js +43 -43
- package/scb-wc.bundle.js +286 -407
- package/scb-wc.d.ts +0 -28
- package/shared/scb-icon-svg.js +2 -5
- package/mvc/components/scb-datepicker/scb-datepicker.js +0 -143
- package/mvc/components/scb-table-next/read-table.js +0 -1
- package/mvc/components/scb-table-next/scb-table-next.js +0 -6
- package/mvc/components/shared/lazy-focus-ring.js +0 -2
- package/mvc/components/shared/lazy-ripple.js +0 -2
- package/mvc/components/shared/scb-icon-svg.js +0 -11
- package/scb-components/index.d.ts +0 -108
- package/scb-components/scb-table-next/read-table.d.ts +0 -29
- package/scb-components/scb-table-next/scb-table-next.d.ts +0 -22
- package/scb-components/scb-viz/scb-viz-actions-runtime.d.ts +0 -26
- package/scb-components/scb-viz/scb-viz-print-runtime.d.ts +0 -30
- package/scb-components/scb-viz/scb-viz-series-differentiation-registry.d.ts +0 -21
- package/scb-components/scb-viz/scb-viz-series-differentiation-runtime.d.ts +0 -42
- package/scb-components/scb-viz/scb-viz-table-runtime.d.ts +0 -28
- package/scb-components/shared/component-size-token.d.ts +0 -1
- package/scb-components/shared/lazy-focus-ring.d.ts +0 -4
- package/scb-components/shared/lazy-ripple.d.ts +0 -9
- package/scb-components/shared/manual-popover.d.ts +0 -7
- package/scb-components/shared/scb-icon-svg.d.ts +0 -3
- package/scb-table-next/read-table.js +0 -87
- package/scb-table-next/scb-table-next.js +0 -226
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g,h as x,m as w,p as c,v as d,y as E}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{componentSizeToken as _}from"../shared/component-size-token.js";import{t as l}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import{closeManualPopover as v,closeManualPopoverAfterAnimations as T,closeNestedPopupSurfaces as z,isManualPopoverOpen as C,openManualPopover as F}from"../shared/manual-popover.js";import"../scb-textfield/scb-textfield.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,s){try{customElements.get(t)||e(t,i,s)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var m,a,k={fromAttribute(h){if(h===null)return!1;const e=h.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="no"}},b=new Set,y="",S="",r=(m=class extends x{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant="basic",this.label="",this.icon="",this.supportingText="",this.okButton="OK",this.cancelButton="Avbryt",this.deleteButton="Delete",this.confirmButton="Ta bort",this.denyButton="Avbryt",this.resetButton="Återställ",this.submitButton="Spara",this.closeLabel="Stäng dialog",this.formId="",this.formAction="",this.formMethod="",this.formEnctype="",this.__lastTriggerEl=null,this.__focusBeforeOpen=null,this.__stackInactive=!1,this.__submitting=!1,this.__redirectingFocus=!1,this.__scrollLocked=!1,this.__initialControlStates=new Map,this.__onDocumentClick=t=>{this.__getActionFromEvent(t)==="toggle"&&(this.__setOpen(!this.open),t.stopPropagation())},this.__onDocumentKeydown=t=>{if(!this.open||t.key!=="Escape")return;const i=a.__getTopmostOpenDialog();i&&i!==this||this.__hasOpenNestedOverlay(t)||(t.preventDefault(),t.stopPropagation(),this.__fireCancelable("esc")&&this.__setOpen(!1))},this.__onDocumentFocusIn=t=>{this.__redirectingFocus||a.__getTopmostOpenDialog()!==this||t.composedPath().includes(this)||(this.__redirectingFocus=!0,queueMicrotask(()=>{this.__focusInitial(),this.__redirectingFocus=!1}))},this.__rememberInitialControlStates=()=>{for(const t of this.__getSlottedElements()){if(!(t instanceof HTMLElement)||this.__initialControlStates.has(t))continue;const i={},s=t;"value"in s&&(i.value=s.value),"checked"in s&&(i.checked=s.checked),"selected"in s&&(i.selected=s.selected),Object.keys(i).length>0&&this.__initialControlStates.set(t,i)}},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire("scrim"),this.__setOpen(!1))},this.__onOk=()=>{this.__fire("ok"),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire("cancel"),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire("confirm"),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire("deny"),this.__setOpen(!1)},this.__onReset=()=>{const t=this.shadowRoot?.querySelector("form");t instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(t),t.reset()),this.__rememberInitialControlStates();for(const[i,s]of this.__initialControlStates){if(!i.isConnected)continue;if(i instanceof HTMLInputElement){i.type==="file"?i.value="":i.value=i.defaultValue,i.checked=i.defaultChecked;continue}if(i instanceof HTMLTextAreaElement){i.value=i.defaultValue;continue}if(i instanceof HTMLSelectElement){for(const o of Array.from(i.options))o.selected=o.defaultSelected;continue}const n=i;n.formResetCallback?.(),"value"in s&&(n.value=s.value),"checked"in s&&(n.checked=s.checked),"selected"in s&&(n.selected=s.selected),n.requestUpdate?.()}this.__fire("reset")},this.__onSubmit=()=>{if(this.__submitting)return;const t=this.shadowRoot?.querySelector("form");if(t instanceof HTMLFormElement){if(!this.__validateFormAndSlottedFields(t))return;t.requestSubmit()}},this.__onFormSubmit=async t=>{const i=t.currentTarget;if(!(i instanceof HTMLFormElement)||(t.preventDefault(),t.stopPropagation(),this.__submitting)||!this.__validateFormAndSlottedFields(i))return;const s=this.__createFormData(i),n=this.__getFormMethod(),o=i.action;if(this.__fireCancelable("submit",{form:i,formData:s,method:n,action:o})){if(this.formAction.trim()&&(n==="PUT"||n==="DELETE")){const p=new AbortController;this.__submitAbortController=p,this.__submitting=!0,this.setAttribute("aria-busy","true");try{const u=await fetch(o,{method:n,body:s,credentials:"same-origin",signal:p.signal}),f={form:i,formData:s,method:n,action:o,response:u,status:u.status};if(!u.ok){this.__fire("submit-error",f);return}this.__fire("submit-success",f),this.open&&this.__setOpen(!1)}catch(u){u instanceof DOMException&&u.name==="AbortError"&&!this.isConnected||this.__fire("submit-error",{form:i,formData:s,method:n,action:o,error:u})}finally{this.__submitAbortController===p&&(this.__submitAbortController=void 0,this.__submitting=!1,this.removeAttribute("aria-busy"))}return}if(this.formAction.trim()){const p=f=>{this.__appendSlottedFiles(i,f.formData)},u=i.getAttribute("enctype");Array.from(s.values()).some(f=>f instanceof File)&&!this.formEnctype.trim()&&(i.enctype="multipart/form-data"),i.addEventListener("formdata",p,{once:!0});try{this.__setOpen(!1),HTMLFormElement.prototype.submit.call(i)}finally{i.removeEventListener("formdata",p),u===null?i.removeAttribute("enctype"):i.setAttribute("enctype",u)}return}this.__setOpen(!1)}},this.__onKeydownTrap=t=>{if(!this.open||t.key!=="Tab"||a.__getTopmostOpenDialog()&&a.__getTopmostOpenDialog()!==this)return;const i=this.__collectFocusableElements();if(!i.length)return;const s=i[0],n=i[i.length-1],o=this.__currentFocusableFromEvent(t,i);!o||!i.includes(o)?((t.shiftKey?n:s).focus(),t.preventDefault()):t.shiftKey&&o===s?(n.focus(),t.preventDefault()):!t.shiftKey&&o===n&&(s.focus(),t.preventDefault())}}__getActionFromEvent(e){if(!this.id)return null;for(const t of e.composedPath())if(t instanceof Element){if(t.getAttribute("data-dialog-toggle")===this.id)return this.__lastTriggerEl=t,"toggle";if(t.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=t,"toggle"}return null}__hasOpenNestedOverlay(e){const t="scb-options-menu, scb-dropdown, scb-select",i=s=>s instanceof Element&&s!==this&&s.matches(t)&&!!s.open;return e.composedPath().some(i)?!0:Array.from(this.querySelectorAll(t)).some(s=>!!s.open)}__isModalOverlay(){return!this.inSb&&!this.__usesInPlaceLayout()}static __getTopmostOpenDialog(){return[...a.__openDialogs].reverse().find(e=>e.open&&e.isConnected&&e.__isModalOverlay())}static __restoreBackgroundInert(){for(const[e,t]of a.__backgroundInertSnapshot)e.inert=t;a.__backgroundInertSnapshot.clear()}static __setBackgroundInert(e){if(a.__restoreBackgroundInert(),!e)return;let t=e;for(;;){const i=t.parentNode;if(i instanceof Element||i instanceof ShadowRoot)for(const s of Array.from(i.children))s===t||!(s instanceof HTMLElement)||(a.__backgroundInertSnapshot.set(s,s.inert),s.inert=!0);if(i instanceof ShadowRoot){t=i.host;continue}if(i instanceof Element){t=i;continue}break}}__getRequestedZIndex(){if(typeof this.zIndex=="number"&&Number.isFinite(this.zIndex))return Math.trunc(this.zIndex);const e=Number.parseInt(getComputedStyle(this).getPropertyValue("--scb-layer-dialog-scrim"),10);return Number.isFinite(e)?e:1e3}__setStackLayer(e){this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__setStackInactive(e){this.__stackInactive!==e&&(this.__stackInactive=e,this.requestUpdate())}static __syncModalStack(){a.__openDialogs=a.__openDialogs.filter(s=>s.open&&s.isConnected&&s.__isModalOverlay());const e=a.__getTopmostOpenDialog(),t=a.__openDialogs.map(s=>s.__getRequestedZIndex()),i=t.length?Math.max(...t):1e3;a.__openDialogs.forEach((s,n)=>{s.__setStackInactive(s!==e),s.__setStackLayer(i+n*2)}),a.__setBackgroundInert(e)}__registerOpenDialog(){this.__isModalOverlay()&&(a.__openDialogs=a.__openDialogs.filter(e=>e!==this),a.__openDialogs.push(this),a.__syncModalStack())}__unregisterOpenDialog(){const e=[...a.__openDialogs].reverse().find(t=>t===this||t.open&&t.isConnected)===this;return a.__openDialogs=a.__openDialogs.filter(t=>t!==this),this.__setStackInactive(!1),a.__syncModalStack(),this.__applyZIndex(),e}__getDeepActiveElement(){let e=this.ownerDocument.activeElement;for(;e instanceof HTMLElement&&e.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e instanceof HTMLElement?e:null}__isInsideDialog(e){let t=e;for(;t;){if(t===this)return!0;t instanceof ShadowRoot?t=t.host:t=t.parentNode}return!1}__focusInitial(){if(!this.open||this.__stackInactive||a.__getTopmostOpenDialog()!==this)return;const e=this.__collectFocusableElements()[0];if(e){e.focus();return}this.shadowRoot?.querySelector(".container")?.focus()}__clearSavedFocus(){this.__lastTriggerEl=null,this.__focusBeforeOpen=null}async __restoreFocusAfterClose(){const e=this.__lastTriggerEl?.isConnected?this.__lastTriggerEl:this.__focusBeforeOpen?.isConnected?this.__focusBeforeOpen:null;this.__clearSavedFocus(),await Promise.resolve();const t=a.__getTopmostOpenDialog();if(t){await t.updateComplete,e&&t.__isInsideDialog(e)&&e.focus();const i=t.__getDeepActiveElement();(!i||!t.__isInsideDialog(i))&&t.__focusInitial();return}e?.focus()}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),document.addEventListener("focusin",this.__onDocumentFocusIn,!0),this.addEventListener("keydown",this.__onKeydownTrap),this.open&&this.hasUpdated&&(this.__focusBeforeOpen=this.__getDeepActiveElement(),this.__registerOpenDialog(),this.__toggleScrollLock(!0),this.__isModalOverlay()&&this.updateComplete.then(()=>this.__focusInitial()))}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),document.removeEventListener("focusin",this.__onDocumentFocusIn,!0),this.removeEventListener("keydown",this.__onKeydownTrap),this.__submitAbortController?.abort(),v(this.shadowRoot?.querySelector(".layer"));const e=this.__unregisterOpenDialog();this.__toggleScrollLock(!1),e?this.__restoreFocusAfterClose():this.__clearSavedFocus(),super.disconnectedCallback()}__applyZIndex(){const e=typeof this.zIndex=="number"&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty("--z-dialog-scrim"),this.style.removeProperty("--z-dialog");return}this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__applyMaxSize(){const e=(this.maxW??"").trim(),t=(this.maxH??"").trim();e?(this.style.setProperty("--scb-dialog-max-w",e),this.style.setProperty("--scb-dialog-width",`min(${e}, 90vw)`)):(this.style.removeProperty("--scb-dialog-max-w"),this.style.removeProperty("--scb-dialog-width")),t?this.style.setProperty("--scb-dialog-max-h",t):this.style.removeProperty("--scb-dialog-max-h")}updated(e){if(e.has("zIndex")&&(this.open&&this.__isModalOverlay()?a.__syncModalStack():this.__applyZIndex()),(e.has("maxW")||e.has("maxH"))&&this.__applyMaxSize(),e.has("open")){const t=e.get("open");this.__updateTriggersExpanded(),this.open&&!t?(this.__focusBeforeOpen=this.__getDeepActiveElement(),this.__registerOpenDialog(),this.__isModalOverlay()&&this.updateComplete.then(()=>this.__focusInitial())):!this.open&&t&&(this.__unregisterOpenDialog()?this.__restoreFocusAfterClose():this.__clearSavedFocus()),this.__toggleScrollLock(this.open)}if(e.has("inSb")&&this.open&&(this.__unregisterOpenDialog(),this.__registerOpenDialog(),this.__toggleScrollLock(!1),this.__toggleScrollLock(!0)),e.has("open")||e.has("inSb")){const t=this.shadowRoot?.querySelector(".layer");if(this.open&&this.__isModalOverlay())F(t);else if(this.open||z(this),!this.open&&C(t)){const i=this.shadowRoot?.querySelector(".container");T(t,void 0,i??t??void 0)}else v(t)}(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute("aria-controls")&&e.setAttribute("aria-expanded",String(this.open))})}__usesInPlaceLayout(){const e=getComputedStyle(this);return e.getPropertyValue("--scb-dialog-scrim-position").trim()==="relative"||e.getPropertyValue("--scb-dialog-container-position").trim()==="absolute"}__toggleScrollLock(e){const t=document.documentElement,i=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;if(b.size===0){y=t.style.overflow,S=i.style.paddingRight;const s=window.innerWidth-t.clientWidth;if(t.style.overflow="hidden",s>0){const n=Number.parseFloat(getComputedStyle(i).paddingRight)||0;i.style.paddingRight=`${n+s}px`}}b.add(this),this.__scrollLocked=!0;return}this.__scrollLocked&&(b.delete(this),b.size===0&&(t.style.overflow=y,i.style.paddingRight=S),this.__scrollLocked=!1)}mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){const e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,i=this.mapSpacingToken(this.spacingBottom)??e,s=this.mapSpacingToken(this.spacingLeft),n=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dialog-spacing-block-start",t):this.style.removeProperty("--scb-dialog-spacing-block-start"),i?this.style.setProperty("--scb-dialog-spacing-block-end",i):this.style.removeProperty("--scb-dialog-spacing-block-end"),s?this.style.setProperty("--scb-dialog-spacing-inline-start",s):this.style.removeProperty("--scb-dialog-spacing-inline-start"),n?this.style.setProperty("--scb-dialog-spacing-inline-end",n):this.style.removeProperty("--scb-dialog-spacing-inline-end")}__setOpen(e){this.open=e,this.__fire(e?"open":"close")}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__fireCancelable(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}__getFormMethod(){const e=String(this.formMethod||"GET").trim().toUpperCase();return e==="POST"||e==="PUT"||e==="DELETE"?e:"GET"}__getSlottedElements(){const e=this.shadowRoot?.querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const t=e.assignedElements({flatten:!0}),i=[];for(const s of t)i.push(s,...Array.from(s.querySelectorAll("*")));return i}__appendHiddenFormValue(e,t,i){const s=document.createElement("input");s.type="hidden",s.name=t,s.value=i,s.setAttribute("data-scb-dialog-generated","true"),e.append(s)}__clearGeneratedFormValues(e){e.querySelectorAll('input[data-scb-dialog-generated="true"]').forEach(t=>t.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;const i=(t.getAttribute("name")??"").trim();if(i&&!(t.disabled===!0||t.hasAttribute("disabled"))){if(t instanceof HTMLInputElement){if(t.form===e)return;const s=(t.type||"").toLowerCase();if(s==="file")return;if(s==="checkbox"||s==="radio"){t.checked&&this.__appendHiddenFormValue(e,i,t.value||"on");return}this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(s=>{this.__appendHiddenFormValue(e,i,s.value)});return}this.__appendHiddenFormValue(e,i,t.value??"");return}switch(t.tagName){case"SCB-TEXTFIELD":if(String(t.type??"").toLowerCase()==="file")return;this.__appendHiddenFormValue(e,i,String(t.value??""));return;case"SCB-CHECKBOX":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-RADIO-BUTTON":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-SWITCH":(t.selected||t.checked)&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-CHIP":t.selected&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;default:"value"in t&&this.__appendHiddenFormValue(e,i,String(t.value??""))}}})}__appendSlottedFiles(e,t){for(const i of this.__getSlottedElements()){if(!(i instanceof HTMLElement))continue;const s=(i.getAttribute("name")??"").trim();if(!(!s||i.disabled===!0||i.hasAttribute("disabled"))){if(i instanceof HTMLInputElement&&i.type==="file"){if(i.form===e)continue;for(const n of Array.from(i.files??[]))t.append(s,n);continue}if(i.tagName==="SCB-TEXTFIELD"&&String(i.type??"").toLowerCase()==="file"){const n=i.files;for(const o of Array.from(n??[]))t.append(s,o)}}}}__createFormData(e){this.__syncSlottedFormValues(e);const t=new FormData(e);return this.__appendSlottedFiles(e,t),t}__validateFormAndSlottedFields(e){const t=o=>o.disabled===!0||o.hasAttribute("disabled");let i=e.reportValidity(),s=null;const n=new Set;return this.__getSlottedElements().forEach(o=>{if(!(o instanceof HTMLElement)||n.has(o)||t(o))return;n.add(o);const p=o;if(o.tagName==="SCB-TEXTFIELD"&&p.error===!0){s||(s=o),i=!1;return}if(typeof p.reportValidity=="function"){const u=!!p.reportValidity();!u&&!s&&(s=o),i=i&&u}}),!i&&s&&s.focus(),i}__isFocusableElement(e){if(!(e instanceof HTMLElement)||!e.matches(a.__focusableSelector)||e.disabled||e.getAttribute("aria-hidden")==="true")return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}__collectAssignedFocusableElements(e){const t=[];return this.__isFocusableElement(e)&&t.push(e),t.push(...Array.from(e.querySelectorAll(a.__focusableSelector)).filter(i=>this.__isFocusableElement(i))),t}__collectFocusableElements(){const e=this.shadowRoot;if(!e)return[];const t=[],i=new Set,s=o=>{i.has(o)||(i.add(o),t.push(o))},n=o=>{if(o instanceof HTMLSlotElement){o.assignedElements({flatten:!0}).flatMap(p=>this.__collectAssignedFocusableElements(p)).forEach(s);return}o instanceof HTMLElement&&this.__isFocusableElement(o)&&s(o),o.childNodes.forEach(n)};return e.childNodes.forEach(n),t}__currentFocusableFromEvent(e,t){const i=e.composedPath();return t.find(s=>i.includes(s))??(this.shadowRoot?.activeElement instanceof HTMLElement?this.shadowRoot.activeElement:null)??(document.activeElement instanceof HTMLElement?document.activeElement:null)}__slotIsEmpty(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){const t=this.variant==="form"||this.variant==="floating"||this.variant==="iframe";return d`
|
|
1
|
+
import{g,h as x,m as w,p as c,v as d,y as E}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as _}from"../../vendor/component-size-token.js";import{t as l}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import{a as T,i as z,n as C,r as F,t as v}from"../../vendor/manual-popover.js";import"../scb-textfield/scb-textfield.js";import"../scb-checkbox/scb-checkbox.js";import"../scb-radio-button/scb-radio-button.js";import"../scb-switch/scb-switch.js";import"../scb-chip/scb-chip.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,s){try{customElements.get(t)||e(t,i,s)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var m,a,k={fromAttribute(h){if(h===null)return!1;const e=h.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="no"}},b=new Set,y="",S="",r=(m=class extends x{constructor(...e){super(...e),this.open=!1,this.inSb=!1,this.scrimClose=!0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.variant="basic",this.label="",this.icon="",this.supportingText="",this.okButton="OK",this.cancelButton="Avbryt",this.deleteButton="Delete",this.confirmButton="Ta bort",this.denyButton="Avbryt",this.resetButton="Återställ",this.submitButton="Spara",this.closeLabel="Stäng dialog",this.formId="",this.formAction="",this.formMethod="",this.formEnctype="",this.__lastTriggerEl=null,this.__focusBeforeOpen=null,this.__stackInactive=!1,this.__submitting=!1,this.__redirectingFocus=!1,this.__scrollLocked=!1,this.__initialControlStates=new Map,this.__onDocumentClick=t=>{this.__getActionFromEvent(t)==="toggle"&&(this.__setOpen(!this.open),t.stopPropagation())},this.__onDocumentKeydown=t=>{if(!this.open||t.key!=="Escape")return;const i=a.__getTopmostOpenDialog();i&&i!==this||this.__hasOpenNestedOverlay(t)||(t.preventDefault(),t.stopPropagation(),this.__fireCancelable("esc")&&this.__setOpen(!1))},this.__onDocumentFocusIn=t=>{this.__redirectingFocus||a.__getTopmostOpenDialog()!==this||t.composedPath().includes(this)||(this.__redirectingFocus=!0,queueMicrotask(()=>{this.__focusInitial(),this.__redirectingFocus=!1}))},this.__rememberInitialControlStates=()=>{for(const t of this.__getSlottedElements()){if(!(t instanceof HTMLElement)||this.__initialControlStates.has(t))continue;const i={},s=t;"value"in s&&(i.value=s.value),"checked"in s&&(i.checked=s.checked),"selected"in s&&(i.selected=s.selected),Object.keys(i).length>0&&this.__initialControlStates.set(t,i)}},this.__onScrimClick=()=>{this.scrimClose&&(this.__fire("scrim"),this.__setOpen(!1))},this.__onOk=()=>{this.__fire("ok"),this.__setOpen(!1)},this.__onCancel=()=>{this.__fire("cancel"),this.__setOpen(!1)},this.__onConfirm=()=>{this.__fire("confirm"),this.__setOpen(!1)},this.__onDeny=()=>{this.__fire("deny"),this.__setOpen(!1)},this.__onReset=()=>{const t=this.shadowRoot?.querySelector("form");t instanceof HTMLFormElement&&(this.__clearGeneratedFormValues(t),t.reset()),this.__rememberInitialControlStates();for(const[i,s]of this.__initialControlStates){if(!i.isConnected)continue;if(i instanceof HTMLInputElement){i.type==="file"?i.value="":i.value=i.defaultValue,i.checked=i.defaultChecked;continue}if(i instanceof HTMLTextAreaElement){i.value=i.defaultValue;continue}if(i instanceof HTMLSelectElement){for(const o of Array.from(i.options))o.selected=o.defaultSelected;continue}const n=i;n.formResetCallback?.(),"value"in s&&(n.value=s.value),"checked"in s&&(n.checked=s.checked),"selected"in s&&(n.selected=s.selected),n.requestUpdate?.()}this.__fire("reset")},this.__onSubmit=()=>{if(this.__submitting)return;const t=this.shadowRoot?.querySelector("form");if(t instanceof HTMLFormElement){if(!this.__validateFormAndSlottedFields(t))return;t.requestSubmit()}},this.__onFormSubmit=async t=>{const i=t.currentTarget;if(!(i instanceof HTMLFormElement)||(t.preventDefault(),t.stopPropagation(),this.__submitting)||!this.__validateFormAndSlottedFields(i))return;const s=this.__createFormData(i),n=this.__getFormMethod(),o=i.action;if(this.__fireCancelable("submit",{form:i,formData:s,method:n,action:o})){if(this.formAction.trim()&&(n==="PUT"||n==="DELETE")){const p=new AbortController;this.__submitAbortController=p,this.__submitting=!0,this.setAttribute("aria-busy","true");try{const u=await fetch(o,{method:n,body:s,credentials:"same-origin",signal:p.signal}),f={form:i,formData:s,method:n,action:o,response:u,status:u.status};if(!u.ok){this.__fire("submit-error",f);return}this.__fire("submit-success",f),this.open&&this.__setOpen(!1)}catch(u){u instanceof DOMException&&u.name==="AbortError"&&!this.isConnected||this.__fire("submit-error",{form:i,formData:s,method:n,action:o,error:u})}finally{this.__submitAbortController===p&&(this.__submitAbortController=void 0,this.__submitting=!1,this.removeAttribute("aria-busy"))}return}if(this.formAction.trim()){const p=f=>{this.__appendSlottedFiles(i,f.formData)},u=i.getAttribute("enctype");Array.from(s.values()).some(f=>f instanceof File)&&!this.formEnctype.trim()&&(i.enctype="multipart/form-data"),i.addEventListener("formdata",p,{once:!0});try{this.__setOpen(!1),HTMLFormElement.prototype.submit.call(i)}finally{i.removeEventListener("formdata",p),u===null?i.removeAttribute("enctype"):i.setAttribute("enctype",u)}return}this.__setOpen(!1)}},this.__onKeydownTrap=t=>{if(!this.open||t.key!=="Tab"||a.__getTopmostOpenDialog()&&a.__getTopmostOpenDialog()!==this)return;const i=this.__collectFocusableElements();if(!i.length)return;const s=i[0],n=i[i.length-1],o=this.__currentFocusableFromEvent(t,i);!o||!i.includes(o)?((t.shiftKey?n:s).focus(),t.preventDefault()):t.shiftKey&&o===s?(n.focus(),t.preventDefault()):!t.shiftKey&&o===n&&(s.focus(),t.preventDefault())}}__getActionFromEvent(e){if(!this.id)return null;for(const t of e.composedPath())if(t instanceof Element){if(t.getAttribute("data-dialog-toggle")===this.id)return this.__lastTriggerEl=t,"toggle";if(t.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=t,"toggle"}return null}__hasOpenNestedOverlay(e){const t="scb-options-menu, scb-dropdown, scb-select",i=s=>s instanceof Element&&s!==this&&s.matches(t)&&!!s.open;return e.composedPath().some(i)?!0:Array.from(this.querySelectorAll(t)).some(s=>!!s.open)}__isModalOverlay(){return!this.inSb&&!this.__usesInPlaceLayout()}static __getTopmostOpenDialog(){return[...a.__openDialogs].reverse().find(e=>e.open&&e.isConnected&&e.__isModalOverlay())}static __restoreBackgroundInert(){for(const[e,t]of a.__backgroundInertSnapshot)e.inert=t;a.__backgroundInertSnapshot.clear()}static __setBackgroundInert(e){if(a.__restoreBackgroundInert(),!e)return;let t=e;for(;;){const i=t.parentNode;if(i instanceof Element||i instanceof ShadowRoot)for(const s of Array.from(i.children))s===t||!(s instanceof HTMLElement)||(a.__backgroundInertSnapshot.set(s,s.inert),s.inert=!0);if(i instanceof ShadowRoot){t=i.host;continue}if(i instanceof Element){t=i;continue}break}}__getRequestedZIndex(){if(typeof this.zIndex=="number"&&Number.isFinite(this.zIndex))return Math.trunc(this.zIndex);const e=Number.parseInt(getComputedStyle(this).getPropertyValue("--scb-layer-dialog-scrim"),10);return Number.isFinite(e)?e:1e3}__setStackLayer(e){this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__setStackInactive(e){this.__stackInactive!==e&&(this.__stackInactive=e,this.requestUpdate())}static __syncModalStack(){a.__openDialogs=a.__openDialogs.filter(s=>s.open&&s.isConnected&&s.__isModalOverlay());const e=a.__getTopmostOpenDialog(),t=a.__openDialogs.map(s=>s.__getRequestedZIndex()),i=t.length?Math.max(...t):1e3;a.__openDialogs.forEach((s,n)=>{s.__setStackInactive(s!==e),s.__setStackLayer(i+n*2)}),a.__setBackgroundInert(e)}__registerOpenDialog(){this.__isModalOverlay()&&(a.__openDialogs=a.__openDialogs.filter(e=>e!==this),a.__openDialogs.push(this),a.__syncModalStack())}__unregisterOpenDialog(){const e=[...a.__openDialogs].reverse().find(t=>t===this||t.open&&t.isConnected)===this;return a.__openDialogs=a.__openDialogs.filter(t=>t!==this),this.__setStackInactive(!1),a.__syncModalStack(),this.__applyZIndex(),e}__getDeepActiveElement(){let e=this.ownerDocument.activeElement;for(;e instanceof HTMLElement&&e.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e instanceof HTMLElement?e:null}__isInsideDialog(e){let t=e;for(;t;){if(t===this)return!0;t instanceof ShadowRoot?t=t.host:t=t.parentNode}return!1}__focusInitial(){if(!this.open||this.__stackInactive||a.__getTopmostOpenDialog()!==this)return;const e=this.__collectFocusableElements()[0];if(e){e.focus();return}this.shadowRoot?.querySelector(".container")?.focus()}__clearSavedFocus(){this.__lastTriggerEl=null,this.__focusBeforeOpen=null}async __restoreFocusAfterClose(){const e=this.__lastTriggerEl?.isConnected?this.__lastTriggerEl:this.__focusBeforeOpen?.isConnected?this.__focusBeforeOpen:null;this.__clearSavedFocus(),await Promise.resolve();const t=a.__getTopmostOpenDialog();if(t){await t.updateComplete,e&&t.__isInsideDialog(e)&&e.focus();const i=t.__getDeepActiveElement();(!i||!t.__isInsideDialog(i))&&t.__focusInitial();return}e?.focus()}connectedCallback(){super.connectedCallback(),this.__applyZIndex(),this.__applyMaxSize(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),document.addEventListener("focusin",this.__onDocumentFocusIn,!0),this.addEventListener("keydown",this.__onKeydownTrap),this.open&&this.hasUpdated&&(this.__focusBeforeOpen=this.__getDeepActiveElement(),this.__registerOpenDialog(),this.__toggleScrollLock(!0),this.__isModalOverlay()&&this.updateComplete.then(()=>this.__focusInitial()))}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),document.removeEventListener("focusin",this.__onDocumentFocusIn,!0),this.removeEventListener("keydown",this.__onKeydownTrap),this.__submitAbortController?.abort(),v(this.shadowRoot?.querySelector(".layer"));const e=this.__unregisterOpenDialog();this.__toggleScrollLock(!1),e?this.__restoreFocusAfterClose():this.__clearSavedFocus(),super.disconnectedCallback()}__applyZIndex(){const e=typeof this.zIndex=="number"&&Number.isFinite(this.zIndex)?this.zIndex:void 0;if(e===void 0){this.style.removeProperty("--z-dialog-scrim"),this.style.removeProperty("--z-dialog");return}this.style.setProperty("--z-dialog-scrim",String(e)),this.style.setProperty("--z-dialog",String(e+1))}__applyMaxSize(){const e=(this.maxW??"").trim(),t=(this.maxH??"").trim();e?(this.style.setProperty("--scb-dialog-max-w",e),this.style.setProperty("--scb-dialog-width",`min(${e}, 90vw)`)):(this.style.removeProperty("--scb-dialog-max-w"),this.style.removeProperty("--scb-dialog-width")),t?this.style.setProperty("--scb-dialog-max-h",t):this.style.removeProperty("--scb-dialog-max-h")}updated(e){if(e.has("zIndex")&&(this.open&&this.__isModalOverlay()?a.__syncModalStack():this.__applyZIndex()),(e.has("maxW")||e.has("maxH"))&&this.__applyMaxSize(),e.has("open")){const t=e.get("open");this.__updateTriggersExpanded(),this.open&&!t?(this.__focusBeforeOpen=this.__getDeepActiveElement(),this.__registerOpenDialog(),this.__isModalOverlay()&&this.updateComplete.then(()=>this.__focusInitial())):!this.open&&t&&(this.__unregisterOpenDialog()?this.__restoreFocusAfterClose():this.__clearSavedFocus()),this.__toggleScrollLock(this.open)}if(e.has("inSb")&&this.open&&(this.__unregisterOpenDialog(),this.__registerOpenDialog(),this.__toggleScrollLock(!1),this.__toggleScrollLock(!0)),e.has("open")||e.has("inSb")){const t=this.shadowRoot?.querySelector(".layer");if(this.open&&this.__isModalOverlay())T(t);else if(this.open||F(this),!this.open&&z(t)){const i=this.shadowRoot?.querySelector(".container");C(t,void 0,i??t??void 0)}else v(t)}(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this.__applySpacing()}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-dialog-toggle="${this.id}"]`).forEach(e=>{e.hasAttribute("aria-controls")&&e.setAttribute("aria-expanded",String(this.open))})}__usesInPlaceLayout(){const e=getComputedStyle(this);return e.getPropertyValue("--scb-dialog-scrim-position").trim()==="relative"||e.getPropertyValue("--scb-dialog-container-position").trim()==="absolute"}__toggleScrollLock(e){const t=document.documentElement,i=document.body;if(e){if(this.__scrollLocked||this.inSb||this.__usesInPlaceLayout())return;if(b.size===0){y=t.style.overflow,S=i.style.paddingRight;const s=window.innerWidth-t.clientWidth;if(t.style.overflow="hidden",s>0){const n=Number.parseFloat(getComputedStyle(i).paddingRight)||0;i.style.paddingRight=`${n+s}px`}}b.add(this),this.__scrollLocked=!0;return}this.__scrollLocked&&(b.delete(this),b.size===0&&(t.style.overflow=y,i.style.paddingRight=S),this.__scrollLocked=!1)}mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}__applySpacing(){const e=this.mapSpacingToken(this.spacing),t=this.mapSpacingToken(this.spacingTop)??e,i=this.mapSpacingToken(this.spacingBottom)??e,s=this.mapSpacingToken(this.spacingLeft),n=this.mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dialog-spacing-block-start",t):this.style.removeProperty("--scb-dialog-spacing-block-start"),i?this.style.setProperty("--scb-dialog-spacing-block-end",i):this.style.removeProperty("--scb-dialog-spacing-block-end"),s?this.style.setProperty("--scb-dialog-spacing-inline-start",s):this.style.removeProperty("--scb-dialog-spacing-inline-start"),n?this.style.setProperty("--scb-dialog-spacing-inline-end",n):this.style.removeProperty("--scb-dialog-spacing-inline-end")}__setOpen(e){this.open=e,this.__fire(e?"open":"close")}__fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}__fireCancelable(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}__getFormMethod(){const e=String(this.formMethod||"GET").trim().toUpperCase();return e==="POST"||e==="PUT"||e==="DELETE"?e:"GET"}__getSlottedElements(){const e=this.shadowRoot?.querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const t=e.assignedElements({flatten:!0}),i=[];for(const s of t)i.push(s,...Array.from(s.querySelectorAll("*")));return i}__appendHiddenFormValue(e,t,i){const s=document.createElement("input");s.type="hidden",s.name=t,s.value=i,s.setAttribute("data-scb-dialog-generated","true"),e.append(s)}__clearGeneratedFormValues(e){e.querySelectorAll('input[data-scb-dialog-generated="true"]').forEach(t=>t.remove())}__syncSlottedFormValues(e){this.__clearGeneratedFormValues(e),this.__getSlottedElements().forEach(t=>{if(!(t instanceof HTMLElement))return;const i=(t.getAttribute("name")??"").trim();if(i&&!(t.disabled===!0||t.hasAttribute("disabled"))){if(t instanceof HTMLInputElement){if(t.form===e)return;const s=(t.type||"").toLowerCase();if(s==="file")return;if(s==="checkbox"||s==="radio"){t.checked&&this.__appendHiddenFormValue(e,i,t.value||"on");return}this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLTextAreaElement){if(t.form===e)return;this.__appendHiddenFormValue(e,i,t.value??"");return}if(t instanceof HTMLSelectElement){if(t.form===e)return;if(t.multiple){Array.from(t.selectedOptions).forEach(s=>{this.__appendHiddenFormValue(e,i,s.value)});return}this.__appendHiddenFormValue(e,i,t.value??"");return}switch(t.tagName){case"SCB-TEXTFIELD":if(String(t.type??"").toLowerCase()==="file")return;this.__appendHiddenFormValue(e,i,String(t.value??""));return;case"SCB-CHECKBOX":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-RADIO-BUTTON":t.checked&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-SWITCH":(t.selected||t.checked)&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;case"SCB-CHIP":t.selected&&this.__appendHiddenFormValue(e,i,String(t.value??t.getAttribute("value")??"on"));return;default:"value"in t&&this.__appendHiddenFormValue(e,i,String(t.value??""))}}})}__appendSlottedFiles(e,t){for(const i of this.__getSlottedElements()){if(!(i instanceof HTMLElement))continue;const s=(i.getAttribute("name")??"").trim();if(!(!s||i.disabled===!0||i.hasAttribute("disabled"))){if(i instanceof HTMLInputElement&&i.type==="file"){if(i.form===e)continue;for(const n of Array.from(i.files??[]))t.append(s,n);continue}if(i.tagName==="SCB-TEXTFIELD"&&String(i.type??"").toLowerCase()==="file"){const n=i.files;for(const o of Array.from(n??[]))t.append(s,o)}}}}__createFormData(e){this.__syncSlottedFormValues(e);const t=new FormData(e);return this.__appendSlottedFiles(e,t),t}__validateFormAndSlottedFields(e){const t=o=>o.disabled===!0||o.hasAttribute("disabled");let i=e.reportValidity(),s=null;const n=new Set;return this.__getSlottedElements().forEach(o=>{if(!(o instanceof HTMLElement)||n.has(o)||t(o))return;n.add(o);const p=o;if(o.tagName==="SCB-TEXTFIELD"&&p.error===!0){s||(s=o),i=!1;return}if(typeof p.reportValidity=="function"){const u=!!p.reportValidity();!u&&!s&&(s=o),i=i&&u}}),!i&&s&&s.focus(),i}__isFocusableElement(e){if(!(e instanceof HTMLElement)||!e.matches(a.__focusableSelector)||e.disabled||e.getAttribute("aria-hidden")==="true")return!1;const t=getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}__collectAssignedFocusableElements(e){const t=[];return this.__isFocusableElement(e)&&t.push(e),t.push(...Array.from(e.querySelectorAll(a.__focusableSelector)).filter(i=>this.__isFocusableElement(i))),t}__collectFocusableElements(){const e=this.shadowRoot;if(!e)return[];const t=[],i=new Set,s=o=>{i.has(o)||(i.add(o),t.push(o))},n=o=>{if(o instanceof HTMLSlotElement){o.assignedElements({flatten:!0}).flatMap(p=>this.__collectAssignedFocusableElements(p)).forEach(s);return}o instanceof HTMLElement&&this.__isFocusableElement(o)&&s(o),o.childNodes.forEach(n)};return e.childNodes.forEach(n),t}__currentFocusableFromEvent(e,t){const i=e.composedPath();return t.find(s=>i.includes(s))??(this.shadowRoot?.activeElement instanceof HTMLElement?this.shadowRoot.activeElement:null)??(document.activeElement instanceof HTMLElement?document.activeElement:null)}__slotIsEmpty(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).length===0:!0}renderHeader(e){const t=this.variant==="form"||this.variant==="floating"||this.variant==="iframe";return d`
|
|
2
2
|
<div class="header">
|
|
3
3
|
<div class="title">
|
|
4
4
|
${this.icon?d`<md-icon class="dialog-icon">${this.icon}</md-icon>`:g}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as f,h as y,m as b,p as c,v as m,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import{
|
|
1
|
+
import{g as f,h as y,m as b,p as c,v as m,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import{a as h,i as w,n as v,r as E,t as p}from"../../vendor/manual-popover.js";import"../scb-divider/scb-divider.js";(function(){try{var _=typeof globalThis<"u"?globalThis:window;if(!_.__scb_ce_guard_installed__){_.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,r,s){try{customElements.get(t)||e(t,r,s)}catch(a){var u=String(a||"");if(u.indexOf("already been used")===-1&&u.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var n,o,d={fromAttribute(_){if(_===null)return!1;const e=_.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="no"}},i=(n=class extends y{constructor(...e){super(...e),this.floating=!0,this.left=!0,this.right=!1,this.open=!1,this.overlay=!1,this.lockScroll=!1,this.closeOnOverlay=!0,this.modal=!1,this.ariaLabel="Sidopanel",this.__effectiveSide="left",this.__lastTriggerEl=null,this.__scrollLockHeld=!1,this.__lastTriggerWasAriaControls=!1,this.__onDocumentClick=t=>{const r=this.__getActionFromEvent(t);if(r){r==="open"&&this.__setOpen(!0),r==="close"&&this.__setOpen(!1),r==="toggle"&&this.__setOpen(!this.open),t.stopPropagation();return}this.floating&&this.open&&!this.overlay&&(t.composedPath().includes(this)||this.__setOpen(!1))},this.__onDocumentKeydown=t=>{if(this.open){if(t.key==="Escape"){if(this.__hasOpenNestedOverlay(t))return;t.preventDefault(),t.stopPropagation(),this.__setOpen(!1);return}if(this.overlay&&t.key==="Tab"){const r=this.__getFocusable();if(r.length===0)return;const s=r[0],u=r[r.length-1],a=this.__currentFocusableFromEvent(t,r);t.shiftKey?(a===s||!a)&&(t.preventDefault(),u.focus()):(a===u||!a)&&(t.preventDefault(),s.focus())}}}}static __ensureOverlayStyles(){if(typeof document>"u"||document.getElementById("scb-drawer-overlay-styles"))return;const e=document.createElement("style");e.id="scb-drawer-overlay-styles",e.textContent=`
|
|
2
2
|
.scb-drawer-global-overlay {
|
|
3
3
|
position: fixed;
|
|
4
4
|
inset: 0;
|
|
@@ -27,7 +27,7 @@ import{g as f,h as y,m as b,p as c,v as m,y as g}from"../../vendor/vendor.js";im
|
|
|
27
27
|
@media (prefers-reduced-motion: reduce) {
|
|
28
28
|
.scb-drawer-global-overlay { transition: none; }
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(e)}static __ensureOverlay(){if(typeof document>"u"||o.__overlayEl)return;o.__ensureOverlayStyles();const e=document.createElement("div");e.className="scb-drawer-global-overlay",e.addEventListener("pointerdown",()=>{const t=o.__overlayStack[o.__overlayStack.length-1];t&&t.closeOnOverlay&&t.__setOpen(!1)},{passive:!0}),document.body.appendChild(e),o.__overlayEl=e}static __showOverlay(e){o.__ensureOverlay(),o.__overlayEl&&(o.__overlayStack.includes(e)||o.__overlayStack.push(e),o.__syncOverlayColors(e),
|
|
30
|
+
`,document.head.appendChild(e)}static __ensureOverlay(){if(typeof document>"u"||o.__overlayEl)return;o.__ensureOverlayStyles();const e=document.createElement("div");e.className="scb-drawer-global-overlay",e.addEventListener("pointerdown",()=>{const t=o.__overlayStack[o.__overlayStack.length-1];t&&t.closeOnOverlay&&t.__setOpen(!1)},{passive:!0}),document.body.appendChild(e),o.__overlayEl=e}static __showOverlay(e){o.__ensureOverlay(),o.__overlayEl&&(o.__overlayStack.includes(e)||o.__overlayStack.push(e),o.__syncOverlayColors(e),h(o.__overlayEl),o.__overlayEl.classList.add("is-visible"))}static __hideOverlay(e){const t=o.__overlayStack.indexOf(e);t>=0&&o.__overlayStack.splice(t,1);const r=o.__overlayStack[o.__overlayStack.length-1];r&&o.__syncOverlayColors(r),o.__overlayStack.length===0&&o.__overlayEl&&(o.__overlayEl.classList.remove("is-visible"),v(o.__overlayEl),o.__overlayEl.style.removeProperty("--scb-drawer-overlay-color"),o.__overlayEl.style.removeProperty("--scb-drawer-scrim-color"))}static __syncOverlayColors(e){if(!o.__overlayEl||typeof getComputedStyle!="function")return;const t=getComputedStyle(e);for(const r of["--scb-drawer-overlay-color","--scb-drawer-scrim-color"]){const s=t.getPropertyValue(r).trim();s?o.__overlayEl.style.setProperty(r,s):o.__overlayEl.style.removeProperty(r)}}static __lockScrollEnable(){if(!(typeof document>"u")){if(o.__lockedCount===0){o.__prevDocOverflow=document.documentElement.style.overflow||"",o.__prevBodyOverflow=document.body.style.overflow||"",o.__prevBodyPaddingRight=document.body.style.paddingRight||"";const e=Math.max(0,window.innerWidth-document.documentElement.clientWidth);if(e>0){const t=Number.parseFloat(getComputedStyle(document.body).paddingRight||"0");document.body.style.paddingRight=`${t+e}px`}document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden"}o.__lockedCount++}}static __lockScrollDisable(){typeof document>"u"||(o.__lockedCount=Math.max(0,o.__lockedCount-1),o.__lockedCount===0&&(document.documentElement.style.overflow=o.__prevDocOverflow??"",document.body.style.overflow=o.__prevBodyOverflow??"",document.body.style.paddingRight=o.__prevBodyPaddingRight??""))}render(){const e=this.modal&&this.overlay&&this.floating;return m`
|
|
31
31
|
<div
|
|
32
32
|
class="root"
|
|
33
33
|
role=${e?"dialog":f}
|
|
@@ -36,6 +36,6 @@ import{g as f,h as y,m as b,p as c,v as m,y as g}from"../../vendor/vendor.js";im
|
|
|
36
36
|
>
|
|
37
37
|
<div class="panel"><slot></slot></div>
|
|
38
38
|
</div>
|
|
39
|
-
`}connectedCallback(){super.connectedCallback(),this.__syncEffectiveSide(new Map),document.addEventListener("click",this.__onDocumentClick,!1)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),this.overlay&&(o.__hideOverlay(this),this.__releaseScrollLock()),
|
|
39
|
+
`}connectedCallback(){super.connectedCallback(),this.__syncEffectiveSide(new Map),document.addEventListener("click",this.__onDocumentClick,!1)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),this.overlay&&(o.__hideOverlay(this),this.__releaseScrollLock()),p(this),super.disconnectedCallback()}__getActionFromEvent(e){if(!this.id)return null;const t=e.composedPath();for(const r of t)if(r instanceof Element){if(r.getAttribute("data-drawer-open")===this.id)return this.__lastTriggerEl=r,this.__lastTriggerWasAriaControls=!1,"open";if(r.getAttribute("data-drawer-close")===this.id)return this.contains(r)||(this.__lastTriggerEl=r,this.__lastTriggerWasAriaControls=!1),"close";if(r.getAttribute("data-drawer-toggle")===this.id)return this.__lastTriggerEl=r,this.__lastTriggerWasAriaControls=!1,"toggle";if(r.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=r,this.__lastTriggerWasAriaControls=!0,"toggle"}return null}__hasOpenNestedOverlay(e){const t="scb-options-menu, scb-dropdown, scb-select",r=s=>s instanceof Element&&s!==this&&s.matches(t)&&!!s.open;return e.composedPath().some(r)?!0:Array.from(this.querySelectorAll(t)).some(s=>!!s.open)}__getFocusable(){const e=["button","[href]","input","select","textarea",'[tabindex]:not([tabindex="-1"])',"scb-button","scb-icon-button","scb-textfield","scb-checkbox","scb-radio-button","scb-switch","scb-chip","scb-menu-item"].join(", "),t=new Set,r=s=>{s.querySelectorAll(e).forEach(u=>{const a=this.__resolveFocusable(u);a&&t.add(a)})};return r(this),r(this.renderRoot),Array.from(t).filter(s=>!this.__isDisabledOrHidden(s))}__resolveFocusable(e){return this.__isDisabledOrHidden(e)?null:e.tagName==="SCB-BUTTON"||e.tagName==="SCB-ICON-BUTTON"?e.shadowRoot?.querySelector(".native-button, button, a")??e:e.tagName==="SCB-MENU-ITEM"?e.shadowRoot?.querySelector(".scb-menu-label-text")??e:e}__isDisabledOrHidden(e){if(e.disabled||e.getAttribute("aria-hidden")==="true")return!0;const t=getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"}__currentFocusableFromEvent(e,t){const r=e.composedPath();return t.find(s=>r.includes(s))??(this.shadowRoot?.activeElement instanceof HTMLElement?this.shadowRoot.activeElement:null)??(document.activeElement instanceof HTMLElement?document.activeElement:null)}__setOpen(e){this.open=e}async __focusFirstControl(){await this.updateComplete;for(let e=0;e<4;e+=1){await new Promise(r=>requestAnimationFrame(()=>r()));const t=this.__getFocusable()[0];if(t?.focus?.({preventScroll:!0}),t&&this.__isFocused(t))return}}__isFocused(e){if(document.activeElement===e)return!0;const t=e.getRootNode();return t instanceof ShadowRoot&&t.activeElement===e}__syncLastTriggerExpanded(e){this.__lastTriggerEl&&this.__lastTriggerWasAriaControls&&this.__lastTriggerEl.getAttribute("aria-controls")===this.id&&this.__lastTriggerEl.setAttribute("aria-expanded",String(e))}__syncEffectiveSide(e){const t=this.left&&this.right;let r;t?e.has("left")&&this.left&&!e.has("right")?r="left":r="right":this.right?r="right":r="left",this.__effectiveSide!==r&&(this.__effectiveSide=r),this.getAttribute("data-side")!==r&&this.setAttribute("data-side",r)}willUpdate(e){this.__syncEffectiveSide(e)}updated(e){if(this.open&&this.floating&&this.overlay&&o.__syncOverlayColors(this),e.has("open")){const t=!!e.get("open");this.__applyOpenSideEffects(t,this.open)}(e.has("open")||e.has("floating"))&&(this.open&&this.floating?h(this):(this.open||E(this),!this.open&&(w(this)||this.__scrollLockHeld)?v(this,this.__scrollLockHeld?()=>this.__releaseScrollLock():void 0):p(this)))}__applyOpenSideEffects(e,t){if(t&&!e)this.__syncLastTriggerExpanded(!0),this.floating&&this.overlay&&(o.__showOverlay(this),this.lockScroll&&this.__acquireScrollLock()),document.addEventListener("keydown",this.__onDocumentKeydown,!0),this.__focusFirstControl(),this.dispatchEvent(new CustomEvent("scb-drawer-opened",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbdraweropened",{bubbles:!0,composed:!0}));else if(!t&&e){this.__syncLastTriggerExpanded(!1),this.floating&&this.overlay&&o.__hideOverlay(this),document.removeEventListener("keydown",this.__onDocumentKeydown,!0);const r=this.__lastTriggerEl;requestAnimationFrame(()=>{this.open||r?.focus?.({preventScroll:!0})}),this.dispatchEvent(new CustomEvent("scb-drawer-closed",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbdrawerclosed",{bubbles:!0,composed:!0}))}}__acquireScrollLock(){this.__scrollLockHeld||(o.__lockScrollEnable(),this.__scrollLockHeld=!0)}__releaseScrollLock(){this.__scrollLockHeld&&(this.__scrollLockHeld=!1,o.__lockScrollDisable())}},o=n,n.__overlayEl=null,n.__overlayStack=[],n.__lockedCount=0,n.__prevDocOverflow=null,n.__prevBodyOverflow=null,n.__prevBodyPaddingRight=null,n.styles=g`:host{display:block;color:var(--scb-drawer-content-color, var(--md-sys-color-on-surface));padding:var(--scb-drawer-design-surface-padding-medium);background:var(--scb-drawer-background,
|
|
40
40
|
var(--md-sys-color-surface-container)
|
|
41
41
|
);font-family:var(--brand-font)}:host([popover]){inset:auto;margin:0;border:0}:host([floating]){box-sizing:border-box;position:fixed;top:0;height:100vh;height:100dvh;width:clamp(var(--scb-drawer-min-width, 280px),var(--scb-drawer-fluid-width, 70vw),var(--scb-drawer-max-width, 360px));--scb-drawer-background:var(--scb-drawer-surface-color, var(--md-sys-color-surface-container-lowest));box-shadow:var(--scb-drawer-elevation, var(--scb-shadow-drawer-start));border-radius:var(--scb-drawer-design-surface-radius-medium);z-index:var(--scb-drawer-z, var(--scb-layer-drawer, 1000));transition:transform .3s ease,opacity .3s ease,visibility .3s;opacity:0;visibility:hidden;pointer-events:none;will-change:transform;font-family:var(--brand-font);overflow:hidden}@media (prefers-reduced-motion:reduce){:host([floating]){transition:none}}:host([floating][data-side="left"]){left:0;transform:translateX(-100%)}:host([floating][data-side="left"][open]){transform:translateX(0);opacity:1;visibility:visible;pointer-events:auto}:host([floating][data-side="right"]){right:0;transform:translateX(100%);box-shadow:var(--scb-drawer-elevation, var(--scb-shadow-drawer-end))}:host([floating][data-side="right"][open]){transform:translateX(0);opacity:1;visibility:visible;pointer-events:auto}::slotted(scb-menu){background:var(--scb-drawer-surface-color, var(--md-sys-color-surface-container-lowest));--scb-menu-background:var(--scb-drawer-surface-color, var(--md-sys-color-surface-container-lowest))}.root{height:100%;display:flex;flex-direction:column;min-height:0}.panel{contain:layout paint style;flex:1 1 auto;min-height:0;overflow:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch}:host([floating]:not([open])) .panel{content-visibility:auto;contain-intrinsic-size:0 600px}@supports not (scrollbar-gutter:stable){.panel{overflow-y:scroll}}:host{--scb-drawer-design-surface-padding-medium:var(--scb-drawer-padding, var(--spacing-4, 12px));--scb-drawer-design-surface-radius-medium:var(--scb-drawer-surface-radius, var(--radius-none, 0px))}`,n);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"floating",void 0);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"left",void 0);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"right",void 0);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"open",void 0);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"overlay",void 0);l([c({type:Boolean,reflect:!0,attribute:"lock-scroll",converter:d})],i.prototype,"lockScroll",void 0);l([c({type:Boolean,reflect:!0,attribute:"close-on-overlay",converter:d})],i.prototype,"closeOnOverlay",void 0);l([c({type:Boolean,reflect:!0,converter:d})],i.prototype,"modal",void 0);l([c({type:String,reflect:!0,attribute:"aria-label"})],i.prototype,"ariaLabel",void 0);i=o=l([b("scb-drawer")],i);export{i as ScbDrawer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as p,g as b,h as y,m as _,p as o,v as d,y as z}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{componentSizeToken as m}from"../shared/component-size-token.js";import{t as s}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(i,r,a){try{customElements.get(i)||e(i,r,a)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var g,t=(g=class extends y{constructor(){super(),this._internals=null,this.type="default",this.name="",this.multiple=!1,this.label="",this.supportingText="",this.metaText="",this.buttonLabel="",this.replaceButtonLabel="",this.removeButtonLabel="",this.removeSelectedFileLabel="",this.selectedImagesLabel="",this.selectedFilesLabel="",this.imagePreviewLabel="",this.filePreviewLabel="",this.selectedImagesPreviewText="",this.existingFileLabel="",this.selectedFileLabel="",this.previewEyebrow="",this.emptyPreviewTitle="",this.emptyPreviewMeta="",this.accept="",this.hidePreview=!1,this.showExistingPreview=!1,this.disabled=!1,this.required=!1,this.error=!1,this.errorText="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this.existingValue="",this.existingValueName="",this.removeValueName="",this._isDragOver=!1,this._selectedPreviewKind="empty",this._selectedPreviewSrc="",this._selectedPreviewAlt="",this._selectedPreviewTitle="",this._selectedPreviewMeta="",this._selectedPreviewItems=[],this._markedForRemoval=!1,this._dragDepth=0,this._previewSource="external",this._form=null,this._formDataHandler=null,this._formSubmitHandler=null,this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._supportingTextId=`scb-drop-zone-supporting-${Math.random().toString(36).slice(2)}`,this._metaTextId=`scb-drop-zone-meta-${Math.random().toString(36).slice(2)}`,this._errorTextId=`scb-drop-zone-error-${Math.random().toString(36).slice(2)}`,"attachInternals"in this&&(this._internals=this.attachInternals())}get _resolvedAccept(){return this.accept.trim()||(this.type==="image"?"image/*,.png,.jpg,.jpeg,.webp,.svg,.gif,.bmp,.avif":"")}get _hasExistingPreview(){return this.multiple||this._markedForRemoval||!(this.existingValue.trim()||this.previewSrc.trim()||this.previewTitle.trim()||this.previewMeta.trim())?!1:this.showExistingPreview||!!this.previewSrc.trim()}get _resolvedPreviewKind(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewSrc.trim()?"image":"file":this._selectedPreviewKind}get _hasPreview(){return this._resolvedPreviewKind!=="empty"}get _hasFormFileValue(){return this._selectedPreviewItems.length?!0:!this.multiple&&!!this.existingValue.trim()&&!this._markedForRemoval}get _resolvedValidationMessage(){return this._customValidationMessage?this._customValidationMessage:!this.disabled&&this.required&&!this._hasFormFileValue?this.errorText||"Välj en fil.":""}get _visibleErrorText(){return this.error?this._validationMessage||this.errorText||"Välj en fil.":""}get _resolvedLabel(){return this.label||(this.type==="image"?"Ladda upp bild":"Ladda upp fil")}get _resolvedSupportingText(){return this.multiple?this.supportingText||(this.type==="image"?"Dra och släpp en eller flera bilder här, eller välj bilder från din dator.":"Dra och släpp en eller flera filer här, eller välj filer från din dator."):this.supportingText||(this.type==="image"?"Dra och släpp en bild här, eller välj en bild från din dator.":"Dra och släpp en fil här, eller välj en fil från din dator.")}get _resolvedMetaText(){return this.metaText?this.metaText:this.type==="image"?"PNG, JPG, SVG, GIF, BMP, AVIF och WebP stöds.":"Alla filtyper stöds."}get _resolvedButtonLabel(){return this.buttonLabel||(this.type==="image"?"Välj bild":"Välj fil")}get _resolvedReplaceButtonLabel(){return this.replaceButtonLabel?this.replaceButtonLabel:this.multiple||this._resolvedPreviewKind==="multi"?"Lägg till fler filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Ersätt bild":"Ersätt fil":this._resolvedPreviewKind==="image"?"Byt bild":"Byt fil"}get _resolvedRemoveButtonLabel(){return this.removeButtonLabel?this.removeButtonLabel:this._resolvedPreviewKind==="multi"?"Ta bort filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Ta bort befintlig bild":"Ta bort befintlig fil":this._resolvedPreviewKind==="image"?"Ta bort bild":"Ta bort fil"}get _resolvedRemoveSelectedFileLabel(){return this.removeSelectedFileLabel||"Ta bort"}get _resolvedSelectedImagesLabel(){return this.selectedImagesLabel||"Valda bilder"}get _resolvedSelectedFilesLabel(){return this.selectedFilesLabel||"Valda filer"}get _resolvedImagePreviewLabel(){return this.imagePreviewLabel||"Bild"}get _resolvedFilePreviewLabel(){return this.filePreviewLabel||"Fil"}get _resolvedSelectedImagesPreviewText(){return this.selectedImagesPreviewText||"Valda bilder visas under uppladdningsytan."}get _resolvedExistingFileLabel(){return this.existingFileLabel||"Befintlig fil"}get _resolvedSelectedFileLabel(){return this.selectedFileLabel||"Vald fil"}get _resolvedPreviewEyebrow(){return this.previewEyebrow?this.previewEyebrow:this._hasPreview?this._resolvedPreviewKind==="multi"?"Uppladdade filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Befintlig bild":"Befintlig fil":this._resolvedPreviewKind==="image"?"Uppladdad bild":"Uppladdad fil":"Förhandsvisning"}get _resolvedEmptyPreviewTitle(){return this.emptyPreviewTitle?this.emptyPreviewTitle:this.multiple?this.type==="image"?"Inga bilder uppladdade":"Inga filer uppladdade":this.type==="image"?"Ingen bild uppladdad":"Ingen fil uppladdad"}get _resolvedEmptyPreviewMeta(){return this.emptyPreviewMeta?this.emptyPreviewMeta:this.multiple?this.type==="image"?"Förhandsvisningen visas här när du har laddat upp bilder.":"Förhandsvisningen visas här när du har laddat upp filer.":this.type==="image"?"Förhandsvisningen visas här när du har laddat upp en bild.":"Förhandsvisningen visas här när du har laddat upp en fil."}get _resolvedPreviewSrc(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewSrc.trim():this._selectedPreviewSrc}get _resolvedPreviewAlt(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewAlt:this._selectedPreviewAlt}get _resolvedPreviewTitle(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewTitle||(this._resolvedPreviewKind==="image"?"Befintlig bild":"Befintlig fil"):this._selectedPreviewTitle}get _resolvedPreviewMeta(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewMeta:this._selectedPreviewMeta}connectedCallback(){super.connectedCallback(),this._syncFormValue(),this._form=this.closest("form"),this._form&&(this._formDataHandler=e=>{const i=e.formData;i&&this._appendToFormData(i)},this._form.addEventListener("formdata",this._formDataHandler),this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("submit",this._formSubmitHandler))}disconnectedCallback(){this._form&&this._formDataHandler&&this._form.removeEventListener("formdata",this._formDataHandler),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler),this._formDataHandler=null,this._formSubmitHandler=null,this._form=null,this._revokeObjectUrl(),super.disconnectedCallback()}updated(e){e.has("type")&&this.type==="image"&&this._selectedPreviewKind==="file"&&this._clearSelectedFileState(),(e.has("disabled")||e.has("name")||e.has("multiple")||e.has("existingValueName")||e.has("removeValueName")||e.has("existingValue"))&&this._syncFormValue(),(e.has("required")||e.has("errorText"))&&this._syncValidity()}formDisabledCallback(e){this.disabled=e,e&&(this._hasValidationBeenReported=!1),this._syncFormValue()}formResetCallback(){this._clearSelectedFileState(),this._markedForRemoval=!1,this._previewSource="external",this._hasValidationBeenReported=!1,this.error=!1,this._clearNativeInputValue(),this._syncFormValue()}_syncFormValue(){if(!this._internals){this._syncValidity();return}const e=this.name.trim(),i=this.existingValueName.trim(),r=this.removeValueName.trim(),a=new FormData;if(!this.disabled&&e&&this._selectedPreviewItems.length&&this._selectedPreviewItems.forEach(n=>{a.append(e,n.file,n.file.name)}),!this.disabled&&!this.multiple&&i&&this.existingValue.trim()&&a.append(i,this.existingValue),!this.disabled&&!this.multiple&&r&&a.append(r,this._markedForRemoval?"true":"false"),[...a.keys()].length===0){this._internals.setFormValue(null),this._syncValidity();return}this._internals.setFormValue(a),this._syncValidity()}_syncValidity(){const e=this._resolvedValidationMessage,i=this.error,r=this._validationMessage,a=this.renderRoot?.querySelector('[data-role="zone"]')??void 0;if(this._internals)if(e){const n=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(n,e,a)}else this._internals.setValidity({});this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||i:i&&!this._hasValidationBeenReported&&!r,this._internals&&!e&&this._internals.setValidity({}),(i!==this.error||r!==this._validationMessage)&&this.requestUpdate()}checkValidity(){return this._syncValidity(),this._internals?this._internals.checkValidity():!this._resolvedValidationMessage}reportValidity(){return this._hasValidationBeenReported=!0,this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,e||(this._hasValidationBeenReported=!1,this.error=!1),this._syncValidity()}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity??{valid:this.checkValidity()}}get validationMessage(){return this._internals?.validationMessage??this._resolvedValidationMessage}get willValidate(){return this._internals?.willValidate??!this.disabled}get labels(){return this._internals?.labels??document.createDocumentFragment().childNodes}_appendToFormData(e){if(this.disabled)return;const i=this.name.trim();if(i&&this._selectedPreviewItems.length&&(e.getAll(i).some(r=>r instanceof File&&this._selectedPreviewItems.some(a=>a.file===r))||this._selectedPreviewItems.forEach(r=>{e.append(i,r.file,r.file.name)})),!this.multiple){const r=this.existingValueName.trim();r&&this.existingValue.trim()&&!e.has(r)&&e.append(r,this.existingValue);const a=this.removeValueName.trim();a&&!e.has(a)&&e.append(a,this._markedForRemoval?"true":"false")}}openPicker(){if(this.disabled)return;const e=this.renderRoot.querySelector('[data-role="native-input"]');if(e){try{e.value=""}catch{}e.click()}}setPreviewState(e){this.previewSrc=e?.src??"",this.previewAlt=e?.alt??"",this.previewTitle=e?.title??"",this.previewMeta=e?.meta??"",this._markedForRemoval=!1,this._previewSource=this._selectedPreviewItems.length?"internal":"external",this._syncFormValue()}setExistingFileState(e){if(this.multiple){this.existingValue="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._syncFormValue();return}this.existingValue=e?.value??"",this.previewSrc=e?.src??"",this.previewAlt=e?.alt??"",this.previewTitle=e?.title??"",this.previewMeta=e?.meta??"",this._markedForRemoval=!1,this._previewSource=this._selectedPreviewItems.length?"internal":"external",this._syncFormValue()}clearPreviewState(){this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._previewSource="external",this._clearSelectedFileState(),this._clearNativeInputValue(),this._syncFormValue()}clearExistingFileState(){this.existingValue="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._selectedPreviewItems.length||(this._previewSource="external"),this._syncFormValue()}_dispatch(e,i={},r=!1){const a=new CustomEvent(e,{detail:i,bubbles:!0,composed:!0,cancelable:r});return this.dispatchEvent(a),a}_handleFiles(e){const i=Array.from(e??[]).filter(n=>this._isAcceptedFile(n));if(!i.length)return;const r=this.multiple?i:[i[0]];this._setSelectedFilesState(r,this.multiple);const a=this._selectedPreviewItems.map(n=>n.file);this._dispatch("file-selected",{file:a[0],files:a,addedFiles:r,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval}),this._dispatch("change",{file:a[0],files:a,addedFiles:r,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval})}_onZoneClick(e){this.disabled||e.composedPath().some(i=>i instanceof HTMLElement&&i.getAttribute("data-role")==="choose-button")||this.openPicker()}_onZoneKeydown(e){this.disabled||(e.key==="Enter"||e.key===" "||e.key==="Spacebar")&&(e.preventDefault(),this.openPicker())}_preventDefaultDrag(e){e.preventDefault(),e.stopPropagation()}_onDragEnter(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth+=1,this._isDragOver=!0)}_onDragOver(e){this.disabled||(this._preventDefaultDrag(e),this._isDragOver=!0)}_onDragLeave(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth=Math.max(0,this._dragDepth-1),this._dragDepth||(this._isDragOver=!1))}_onDrop(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth=0,this._isDragOver=!1,this._handleFiles(e.dataTransfer?.files??null))}_onNativeInputChange(e){const i=e.currentTarget;this._handleFiles(i?.files??null)}_onChooseButtonClick(e){e.preventDefault(),e.stopPropagation(),this.openPicker()}_onReplaceButtonClick(e){e.preventDefault(),e.stopPropagation(),this.openPicker()}_onRemoveButtonClick(e){if(e.preventDefault(),e.stopPropagation(),!this._dispatch("clear-request",{file:this._selectedPreviewItems[0]?.file??null,files:this._selectedPreviewItems.map(i=>i.file),existingValue:this.existingValue,markedForRemoval:this._markedForRemoval},!0).defaultPrevented){if(this._selectedPreviewItems.length){this._clearSelectedFileState(),this._clearNativeInputValue(),this._previewSource=this._hasExistingPreview?"external":"internal",this._dispatch("change",{file:null,files:[],existingValue:this.existingValue,markedForRemoval:this._markedForRemoval});return}if(this._hasExistingPreview){this._markedForRemoval=!0,this._previewSource="external",this._syncFormValue(),this.requestUpdate(),this._dispatch("change",{file:null,files:[],existingValue:this.existingValue,markedForRemoval:!0});return}this.clearPreviewState()}}_onRemoveSelectedItemClick(e){if(e.preventDefault(),e.stopPropagation(),this.disabled)return;const i=e.currentTarget?.getAttribute("data-index")||"",r=Number.parseInt(i,10);Number.isInteger(r)&&this._removeSelectedItemAt(r)}_isAcceptedFile(e){const i=this._resolvedAccept.trim();if(!i)return!0;const r=e.name.toLowerCase(),a=(e.type||"").toLowerCase(),n=i.split(",").map(l=>l.trim().toLowerCase()).filter(Boolean);return n.length?n.some(l=>l==="*/*"?!0:l.endsWith("/*")?a.startsWith(l.slice(0,-1)):l.startsWith(".")?r.endsWith(l):a===l):!0}_setSelectedFilesState(e,i){const r=e.filter(Boolean);if(!r.length)return;const a=i?this._selectedPreviewItems:[],n=r.map(c=>{const v=this._getPreviewKindForFile(c),u=this._getFileTypeLabel(c),w=this._formatFileSize(c.size);return{file:c,kind:v,src:v==="image"?URL.createObjectURL(c):"",alt:v==="image"?c.name||"Uppladdad bild":"",title:c.name||(v==="image"?"Uppladdad bild":"Uppladdad fil"),meta:[u,w].filter(Boolean).join(" • ")}});i||this._revokeObjectUrl();const l=this.multiple?[...a,...n]:[n[0]];!this.multiple&&a.length&&this._revokeObjectUrlsForItems(a),this._markedForRemoval=!1,this._applySelectedPreviewItems(l)}_clearSelectedFileState(){this._revokeObjectUrl(),this._applySelectedPreviewItems([])}_applySelectedPreviewItems(e){this._selectedPreviewItems=e;const i=e[0];if(!i){this._selectedPreviewKind="empty",this._selectedPreviewTitle="",this._selectedPreviewMeta="",this._selectedPreviewAlt="",this._selectedPreviewSrc="",this._previewSource="internal",this._syncFormValue();return}if(e.length>1){const r=e.reduce((a,n)=>a+(Number.isFinite(n.file.size)?n.file.size:0),0);this._selectedPreviewKind="multi",this._selectedPreviewTitle=`${e.length} filer valda`,this._selectedPreviewMeta=`Totalt ${this._formatFileSize(r)}`,this._selectedPreviewAlt="",this._selectedPreviewSrc=""}else this._selectedPreviewKind=i.kind,this._selectedPreviewTitle=i.title,this._selectedPreviewMeta=i.meta,this._selectedPreviewAlt=i.alt,this._selectedPreviewSrc=i.src;this._previewSource="internal",this._syncFormValue()}_removeSelectedItemAt(e){if(e<0||e>=this._selectedPreviewItems.length)return;const i=this._selectedPreviewItems[e];i.src&&URL.revokeObjectURL(i.src);const r=this._selectedPreviewItems.filter((a,n)=>n!==e);this._applySelectedPreviewItems(r),this._dispatch("file-removed",{file:i.file,files:r.map(a=>a.file),index:e,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval}),this._dispatch("change",{file:r[0]?.file??null,files:r.map(a=>a.file),removedFile:i.file,removedIndex:e,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval})}_renderSelectedImageCards(){return!this.multiple||this.type!=="image"||this.hidePreview||!this._selectedPreviewItems.some(e=>e.kind==="image"&&e.src)?null:d`
|
|
1
|
+
import{f as p,g as b,h as y,m as _,p as o,v as d,y as z}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as m}from"../../vendor/component-size-token.js";import{t as s}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(i,r,a){try{customElements.get(i)||e(i,r,a)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var g,t=(g=class extends y{constructor(){super(),this._internals=null,this.type="default",this.name="",this.multiple=!1,this.label="",this.supportingText="",this.metaText="",this.buttonLabel="",this.replaceButtonLabel="",this.removeButtonLabel="",this.removeSelectedFileLabel="",this.selectedImagesLabel="",this.selectedFilesLabel="",this.imagePreviewLabel="",this.filePreviewLabel="",this.selectedImagesPreviewText="",this.existingFileLabel="",this.selectedFileLabel="",this.previewEyebrow="",this.emptyPreviewTitle="",this.emptyPreviewMeta="",this.accept="",this.hidePreview=!1,this.showExistingPreview=!1,this.disabled=!1,this.required=!1,this.error=!1,this.errorText="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this.existingValue="",this.existingValueName="",this.removeValueName="",this._isDragOver=!1,this._selectedPreviewKind="empty",this._selectedPreviewSrc="",this._selectedPreviewAlt="",this._selectedPreviewTitle="",this._selectedPreviewMeta="",this._selectedPreviewItems=[],this._markedForRemoval=!1,this._dragDepth=0,this._previewSource="external",this._form=null,this._formDataHandler=null,this._formSubmitHandler=null,this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._supportingTextId=`scb-drop-zone-supporting-${Math.random().toString(36).slice(2)}`,this._metaTextId=`scb-drop-zone-meta-${Math.random().toString(36).slice(2)}`,this._errorTextId=`scb-drop-zone-error-${Math.random().toString(36).slice(2)}`,"attachInternals"in this&&(this._internals=this.attachInternals())}get _resolvedAccept(){return this.accept.trim()||(this.type==="image"?"image/*,.png,.jpg,.jpeg,.webp,.svg,.gif,.bmp,.avif":"")}get _hasExistingPreview(){return this.multiple||this._markedForRemoval||!(this.existingValue.trim()||this.previewSrc.trim()||this.previewTitle.trim()||this.previewMeta.trim())?!1:this.showExistingPreview||!!this.previewSrc.trim()}get _resolvedPreviewKind(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewSrc.trim()?"image":"file":this._selectedPreviewKind}get _hasPreview(){return this._resolvedPreviewKind!=="empty"}get _hasFormFileValue(){return this._selectedPreviewItems.length?!0:!this.multiple&&!!this.existingValue.trim()&&!this._markedForRemoval}get _resolvedValidationMessage(){return this._customValidationMessage?this._customValidationMessage:!this.disabled&&this.required&&!this._hasFormFileValue?this.errorText||"Välj en fil.":""}get _visibleErrorText(){return this.error?this._validationMessage||this.errorText||"Välj en fil.":""}get _resolvedLabel(){return this.label||(this.type==="image"?"Ladda upp bild":"Ladda upp fil")}get _resolvedSupportingText(){return this.multiple?this.supportingText||(this.type==="image"?"Dra och släpp en eller flera bilder här, eller välj bilder från din dator.":"Dra och släpp en eller flera filer här, eller välj filer från din dator."):this.supportingText||(this.type==="image"?"Dra och släpp en bild här, eller välj en bild från din dator.":"Dra och släpp en fil här, eller välj en fil från din dator.")}get _resolvedMetaText(){return this.metaText?this.metaText:this.type==="image"?"PNG, JPG, SVG, GIF, BMP, AVIF och WebP stöds.":"Alla filtyper stöds."}get _resolvedButtonLabel(){return this.buttonLabel||(this.type==="image"?"Välj bild":"Välj fil")}get _resolvedReplaceButtonLabel(){return this.replaceButtonLabel?this.replaceButtonLabel:this.multiple||this._resolvedPreviewKind==="multi"?"Lägg till fler filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Ersätt bild":"Ersätt fil":this._resolvedPreviewKind==="image"?"Byt bild":"Byt fil"}get _resolvedRemoveButtonLabel(){return this.removeButtonLabel?this.removeButtonLabel:this._resolvedPreviewKind==="multi"?"Ta bort filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Ta bort befintlig bild":"Ta bort befintlig fil":this._resolvedPreviewKind==="image"?"Ta bort bild":"Ta bort fil"}get _resolvedRemoveSelectedFileLabel(){return this.removeSelectedFileLabel||"Ta bort"}get _resolvedSelectedImagesLabel(){return this.selectedImagesLabel||"Valda bilder"}get _resolvedSelectedFilesLabel(){return this.selectedFilesLabel||"Valda filer"}get _resolvedImagePreviewLabel(){return this.imagePreviewLabel||"Bild"}get _resolvedFilePreviewLabel(){return this.filePreviewLabel||"Fil"}get _resolvedSelectedImagesPreviewText(){return this.selectedImagesPreviewText||"Valda bilder visas under uppladdningsytan."}get _resolvedExistingFileLabel(){return this.existingFileLabel||"Befintlig fil"}get _resolvedSelectedFileLabel(){return this.selectedFileLabel||"Vald fil"}get _resolvedPreviewEyebrow(){return this.previewEyebrow?this.previewEyebrow:this._hasPreview?this._resolvedPreviewKind==="multi"?"Uppladdade filer":this._previewSource==="external"&&this._hasExistingPreview?this._resolvedPreviewKind==="image"?"Befintlig bild":"Befintlig fil":this._resolvedPreviewKind==="image"?"Uppladdad bild":"Uppladdad fil":"Förhandsvisning"}get _resolvedEmptyPreviewTitle(){return this.emptyPreviewTitle?this.emptyPreviewTitle:this.multiple?this.type==="image"?"Inga bilder uppladdade":"Inga filer uppladdade":this.type==="image"?"Ingen bild uppladdad":"Ingen fil uppladdad"}get _resolvedEmptyPreviewMeta(){return this.emptyPreviewMeta?this.emptyPreviewMeta:this.multiple?this.type==="image"?"Förhandsvisningen visas här när du har laddat upp bilder.":"Förhandsvisningen visas här när du har laddat upp filer.":this.type==="image"?"Förhandsvisningen visas här när du har laddat upp en bild.":"Förhandsvisningen visas här när du har laddat upp en fil."}get _resolvedPreviewSrc(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewSrc.trim():this._selectedPreviewSrc}get _resolvedPreviewAlt(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewAlt:this._selectedPreviewAlt}get _resolvedPreviewTitle(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewTitle||(this._resolvedPreviewKind==="image"?"Befintlig bild":"Befintlig fil"):this._selectedPreviewTitle}get _resolvedPreviewMeta(){return this._previewSource==="external"&&this._hasExistingPreview?this.previewMeta:this._selectedPreviewMeta}connectedCallback(){super.connectedCallback(),this._syncFormValue(),this._form=this.closest("form"),this._form&&(this._formDataHandler=e=>{const i=e.formData;i&&this._appendToFormData(i)},this._form.addEventListener("formdata",this._formDataHandler),this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("submit",this._formSubmitHandler))}disconnectedCallback(){this._form&&this._formDataHandler&&this._form.removeEventListener("formdata",this._formDataHandler),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler),this._formDataHandler=null,this._formSubmitHandler=null,this._form=null,this._revokeObjectUrl(),super.disconnectedCallback()}updated(e){e.has("type")&&this.type==="image"&&this._selectedPreviewKind==="file"&&this._clearSelectedFileState(),(e.has("disabled")||e.has("name")||e.has("multiple")||e.has("existingValueName")||e.has("removeValueName")||e.has("existingValue"))&&this._syncFormValue(),(e.has("required")||e.has("errorText"))&&this._syncValidity()}formDisabledCallback(e){this.disabled=e,e&&(this._hasValidationBeenReported=!1),this._syncFormValue()}formResetCallback(){this._clearSelectedFileState(),this._markedForRemoval=!1,this._previewSource="external",this._hasValidationBeenReported=!1,this.error=!1,this._clearNativeInputValue(),this._syncFormValue()}_syncFormValue(){if(!this._internals){this._syncValidity();return}const e=this.name.trim(),i=this.existingValueName.trim(),r=this.removeValueName.trim(),a=new FormData;if(!this.disabled&&e&&this._selectedPreviewItems.length&&this._selectedPreviewItems.forEach(n=>{a.append(e,n.file,n.file.name)}),!this.disabled&&!this.multiple&&i&&this.existingValue.trim()&&a.append(i,this.existingValue),!this.disabled&&!this.multiple&&r&&a.append(r,this._markedForRemoval?"true":"false"),[...a.keys()].length===0){this._internals.setFormValue(null),this._syncValidity();return}this._internals.setFormValue(a),this._syncValidity()}_syncValidity(){const e=this._resolvedValidationMessage,i=this.error,r=this._validationMessage,a=this.renderRoot?.querySelector('[data-role="zone"]')??void 0;if(this._internals)if(e){const n=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(n,e,a)}else this._internals.setValidity({});this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||i:i&&!this._hasValidationBeenReported&&!r,this._internals&&!e&&this._internals.setValidity({}),(i!==this.error||r!==this._validationMessage)&&this.requestUpdate()}checkValidity(){return this._syncValidity(),this._internals?this._internals.checkValidity():!this._resolvedValidationMessage}reportValidity(){return this._hasValidationBeenReported=!0,this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,e||(this._hasValidationBeenReported=!1,this.error=!1),this._syncValidity()}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity??{valid:this.checkValidity()}}get validationMessage(){return this._internals?.validationMessage??this._resolvedValidationMessage}get willValidate(){return this._internals?.willValidate??!this.disabled}get labels(){return this._internals?.labels??document.createDocumentFragment().childNodes}_appendToFormData(e){if(this.disabled)return;const i=this.name.trim();if(i&&this._selectedPreviewItems.length&&(e.getAll(i).some(r=>r instanceof File&&this._selectedPreviewItems.some(a=>a.file===r))||this._selectedPreviewItems.forEach(r=>{e.append(i,r.file,r.file.name)})),!this.multiple){const r=this.existingValueName.trim();r&&this.existingValue.trim()&&!e.has(r)&&e.append(r,this.existingValue);const a=this.removeValueName.trim();a&&!e.has(a)&&e.append(a,this._markedForRemoval?"true":"false")}}openPicker(){if(this.disabled)return;const e=this.renderRoot.querySelector('[data-role="native-input"]');if(e){try{e.value=""}catch{}e.click()}}setPreviewState(e){this.previewSrc=e?.src??"",this.previewAlt=e?.alt??"",this.previewTitle=e?.title??"",this.previewMeta=e?.meta??"",this._markedForRemoval=!1,this._previewSource=this._selectedPreviewItems.length?"internal":"external",this._syncFormValue()}setExistingFileState(e){if(this.multiple){this.existingValue="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._syncFormValue();return}this.existingValue=e?.value??"",this.previewSrc=e?.src??"",this.previewAlt=e?.alt??"",this.previewTitle=e?.title??"",this.previewMeta=e?.meta??"",this._markedForRemoval=!1,this._previewSource=this._selectedPreviewItems.length?"internal":"external",this._syncFormValue()}clearPreviewState(){this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._previewSource="external",this._clearSelectedFileState(),this._clearNativeInputValue(),this._syncFormValue()}clearExistingFileState(){this.existingValue="",this.previewSrc="",this.previewAlt="",this.previewTitle="",this.previewMeta="",this._markedForRemoval=!1,this._selectedPreviewItems.length||(this._previewSource="external"),this._syncFormValue()}_dispatch(e,i={},r=!1){const a=new CustomEvent(e,{detail:i,bubbles:!0,composed:!0,cancelable:r});return this.dispatchEvent(a),a}_handleFiles(e){const i=Array.from(e??[]).filter(n=>this._isAcceptedFile(n));if(!i.length)return;const r=this.multiple?i:[i[0]];this._setSelectedFilesState(r,this.multiple);const a=this._selectedPreviewItems.map(n=>n.file);this._dispatch("file-selected",{file:a[0],files:a,addedFiles:r,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval}),this._dispatch("change",{file:a[0],files:a,addedFiles:r,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval})}_onZoneClick(e){this.disabled||e.composedPath().some(i=>i instanceof HTMLElement&&i.getAttribute("data-role")==="choose-button")||this.openPicker()}_onZoneKeydown(e){this.disabled||(e.key==="Enter"||e.key===" "||e.key==="Spacebar")&&(e.preventDefault(),this.openPicker())}_preventDefaultDrag(e){e.preventDefault(),e.stopPropagation()}_onDragEnter(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth+=1,this._isDragOver=!0)}_onDragOver(e){this.disabled||(this._preventDefaultDrag(e),this._isDragOver=!0)}_onDragLeave(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth=Math.max(0,this._dragDepth-1),this._dragDepth||(this._isDragOver=!1))}_onDrop(e){this.disabled||(this._preventDefaultDrag(e),this._dragDepth=0,this._isDragOver=!1,this._handleFiles(e.dataTransfer?.files??null))}_onNativeInputChange(e){const i=e.currentTarget;this._handleFiles(i?.files??null)}_onChooseButtonClick(e){e.preventDefault(),e.stopPropagation(),this.openPicker()}_onReplaceButtonClick(e){e.preventDefault(),e.stopPropagation(),this.openPicker()}_onRemoveButtonClick(e){if(e.preventDefault(),e.stopPropagation(),!this._dispatch("clear-request",{file:this._selectedPreviewItems[0]?.file??null,files:this._selectedPreviewItems.map(i=>i.file),existingValue:this.existingValue,markedForRemoval:this._markedForRemoval},!0).defaultPrevented){if(this._selectedPreviewItems.length){this._clearSelectedFileState(),this._clearNativeInputValue(),this._previewSource=this._hasExistingPreview?"external":"internal",this._dispatch("change",{file:null,files:[],existingValue:this.existingValue,markedForRemoval:this._markedForRemoval});return}if(this._hasExistingPreview){this._markedForRemoval=!0,this._previewSource="external",this._syncFormValue(),this.requestUpdate(),this._dispatch("change",{file:null,files:[],existingValue:this.existingValue,markedForRemoval:!0});return}this.clearPreviewState()}}_onRemoveSelectedItemClick(e){if(e.preventDefault(),e.stopPropagation(),this.disabled)return;const i=e.currentTarget?.getAttribute("data-index")||"",r=Number.parseInt(i,10);Number.isInteger(r)&&this._removeSelectedItemAt(r)}_isAcceptedFile(e){const i=this._resolvedAccept.trim();if(!i)return!0;const r=e.name.toLowerCase(),a=(e.type||"").toLowerCase(),n=i.split(",").map(l=>l.trim().toLowerCase()).filter(Boolean);return n.length?n.some(l=>l==="*/*"?!0:l.endsWith("/*")?a.startsWith(l.slice(0,-1)):l.startsWith(".")?r.endsWith(l):a===l):!0}_setSelectedFilesState(e,i){const r=e.filter(Boolean);if(!r.length)return;const a=i?this._selectedPreviewItems:[],n=r.map(c=>{const v=this._getPreviewKindForFile(c),u=this._getFileTypeLabel(c),w=this._formatFileSize(c.size);return{file:c,kind:v,src:v==="image"?URL.createObjectURL(c):"",alt:v==="image"?c.name||"Uppladdad bild":"",title:c.name||(v==="image"?"Uppladdad bild":"Uppladdad fil"),meta:[u,w].filter(Boolean).join(" • ")}});i||this._revokeObjectUrl();const l=this.multiple?[...a,...n]:[n[0]];!this.multiple&&a.length&&this._revokeObjectUrlsForItems(a),this._markedForRemoval=!1,this._applySelectedPreviewItems(l)}_clearSelectedFileState(){this._revokeObjectUrl(),this._applySelectedPreviewItems([])}_applySelectedPreviewItems(e){this._selectedPreviewItems=e;const i=e[0];if(!i){this._selectedPreviewKind="empty",this._selectedPreviewTitle="",this._selectedPreviewMeta="",this._selectedPreviewAlt="",this._selectedPreviewSrc="",this._previewSource="internal",this._syncFormValue();return}if(e.length>1){const r=e.reduce((a,n)=>a+(Number.isFinite(n.file.size)?n.file.size:0),0);this._selectedPreviewKind="multi",this._selectedPreviewTitle=`${e.length} filer valda`,this._selectedPreviewMeta=`Totalt ${this._formatFileSize(r)}`,this._selectedPreviewAlt="",this._selectedPreviewSrc=""}else this._selectedPreviewKind=i.kind,this._selectedPreviewTitle=i.title,this._selectedPreviewMeta=i.meta,this._selectedPreviewAlt=i.alt,this._selectedPreviewSrc=i.src;this._previewSource="internal",this._syncFormValue()}_removeSelectedItemAt(e){if(e<0||e>=this._selectedPreviewItems.length)return;const i=this._selectedPreviewItems[e];i.src&&URL.revokeObjectURL(i.src);const r=this._selectedPreviewItems.filter((a,n)=>n!==e);this._applySelectedPreviewItems(r),this._dispatch("file-removed",{file:i.file,files:r.map(a=>a.file),index:e,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval}),this._dispatch("change",{file:r[0]?.file??null,files:r.map(a=>a.file),removedFile:i.file,removedIndex:e,existingValue:this.existingValue,markedForRemoval:this._markedForRemoval})}_renderSelectedImageCards(){return!this.multiple||this.type!=="image"||this.hidePreview||!this._selectedPreviewItems.some(e=>e.kind==="image"&&e.src)?null:d`
|
|
2
2
|
<div class="scb-drop-zone__selected-images" aria-label=${this._resolvedSelectedImagesLabel}>
|
|
3
3
|
${this._selectedPreviewItems.map((e,i)=>e.kind!=="image"||!e.src?null:d`
|
|
4
4
|
<article class="scb-drop-zone__selected-image-card" aria-label=${`${e.title}, ${e.meta}`}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as g,g as S,h as I,m as A,p as d,v,y as W}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{ensureFocusRingOnFocusVisible as $}from"../shared/lazy-focus-ring.js";import{t as B}from"../../vendor/component-defaults.js";import{t as r}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"../scb-button/scb-button.js";import{closeManualPopover as z,closeManualPopoverAfterAnimations as H,isManualPopoverOpen as M,openManualPopover as L}from"../shared/manual-popover.js";import"../scb-options-menu/scb-options-menu.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,n){try{customElements.get(t)||e(t,i,n)}catch(l){var s=String(l||"");if(s.indexOf("already been used")===-1&&s.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var w,a=(w=class extends I{constructor(...e){super(...e),this.label="Dropdown",this.variant="filled",this.size=B["scb-dropdown"].size,this.open=!1,this.disabled=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.menuGap="3",this.width=null,this.minWidth=null,this.maxWidth=null,this.dataIndex=null,this.ariaCurrent=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._panelPlacementRaf=null,this._onViewportChange=()=>{this.open&&this._schedulePanelPlacement()},this._onDocumentClickBound=t=>{if(!this.open)return;const i=t.composedPath(),n=i.find(s=>s instanceof HTMLElement&&s.tagName.toLowerCase()==="scb-dropdown");if(n&&n!==this){this.open=!1;return}i.includes(this)||(this.open=!1)},this._onDocumentKeydownBound=t=>{this.open&&t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.open=!1,this.updateComplete.then(()=>this.focus({preventScroll:!0})))},this._onSlottedMenuOpen=()=>{this.open||(this.open=!0)},this._onSlottedMenuClose=()=>{this.open&&(this.open=!1)},this._onSlotChange=()=>{this._syncSlottedMenu(),this._applyPanelSizing(),this._applyInertByOpen(),this.requestUpdate()},this._onTriggerClick=t=>{this.hasAttribute("as-tab")||t.stopPropagation(),!this.disabled&&(this.open=!this.open)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._onDocumentClickBound,!0),document.addEventListener("keydown",this._onDocumentKeydownBound),window.addEventListener("resize",this._onViewportChange,{passive:!0}),window.addEventListener("scroll",this._onViewportChange,{passive:!0,capture:!0})}disconnectedCallback(){document.removeEventListener("click",this._onDocumentClickBound,!0),document.removeEventListener("keydown",this._onDocumentKeydownBound),window.removeEventListener("resize",this._onViewportChange),window.removeEventListener("scroll",this._onViewportChange,!0),this._detachSlottedMenuListeners(),z(this.renderRoot.querySelector(".panel")),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._panelHeightSyncRaf!==null&&(window.cancelAnimationFrame(this._panelHeightSyncRaf),this._panelHeightSyncRaf=null),this._panelPlacementRaf!==null&&(window.cancelAnimationFrame(this._panelPlacementRaf),this._panelPlacementRaf=null),this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),this._syncSlottedMenu(),this._applyPanelVars(),this._applyPanelSizing(),this._applyChevronState(),this._applyInertByOpen(),this._setupPanelResizeObserver(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen(),this._syncPanelPopover()}updated(e){super.updated(e),e.has("menuGap")&&this._applyPanelVars(),(e.has("width")||e.has("minWidth")||e.has("maxWidth"))&&this._applyPanelSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing(),e.has("open")&&(this.open||this._closeAllSubMenus(),this._syncSlottedMenuOpen(),this._applyChevronState(),this._applyInertByOpen(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen(),this._syncPanelPopover(),this.dispatchEvent(new CustomEvent("openchange",{bubbles:!0,composed:!0,detail:{open:this.open}})))}_applyPanelVars(){if(this.menuGap==null||String(this.menuGap).trim()===""){this.style.removeProperty("--scb-dropdown-panel-gap");return}this.style.setProperty("--scb-dropdown-panel-gap",this._mapSpacingToken(this.menuGap))}_applyPanelSizing(){const e=this.renderRoot.querySelector(".panel-surface");e&&(this.width&&String(this.width).trim()!==""?e.style.inlineSize=this.width:e.style.removeProperty("inline-size"),this.minWidth&&String(this.minWidth).trim()!==""?e.style.minInlineSize=this.minWidth:e.style.removeProperty("min-inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?e.style.maxInlineSize=this.maxWidth:e.style.removeProperty("max-inline-size")),this._slottedMenuEl&&(this.width&&String(this.width).trim()!==""?this._slottedMenuEl.style.inlineSize=this.width:this._slottedMenuEl.style.removeProperty("inline-size"),this.minWidth&&String(this.minWidth).trim()!==""?this._slottedMenuEl.style.minInlineSize=this.minWidth:this._slottedMenuEl.style.removeProperty("min-inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?this._slottedMenuEl.style.maxInlineSize=this.maxWidth:this._slottedMenuEl.style.removeProperty("max-inline-size")),this._schedulePanelHeightSync()}_setupPanelResizeObserver(){if(this._panelResizeObserver||typeof ResizeObserver>"u")return;const e=this._panelInnerEl;e&&(this._panelResizeObserver=new ResizeObserver(()=>{this._schedulePanelHeightSync()}),this._panelResizeObserver.observe(e))}_schedulePanelHeightSync(){this._panelHeightSyncRaf===null&&(this._panelHeightSyncRaf=window.requestAnimationFrame(()=>{this._panelHeightSyncRaf=null,this._syncPanelMaxHeightByOpen()}))}_schedulePanelPlacement(){this._panelPlacementRaf===null&&(this._panelPlacementRaf=window.requestAnimationFrame(()=>{this._panelPlacementRaf=null,this._positionPanelInViewport()}))}_syncPanelPopover(){const e=this.renderRoot.querySelector(".panel");if(!e)return;if(this.open){L(e)&&this._schedulePanelPlacement();return}const t=()=>{this._panelSurfaceEl?.style.removeProperty("--scb-dropdown-panel-viewport-max-height"),e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("right"),e.style.removeProperty("top"),e.style.removeProperty("bottom"),e.style.removeProperty("width")};M(e)?H(e,t,this._panelSurfaceEl??e):(z(e),t())}_positionPanelInViewport(){const e=this.renderRoot.querySelector(".panel"),t=this._triggerEl;if(!e||!t||!M(e))return;const i=this._panelSurfaceEl,n=t.getBoundingClientRect(),s=i?.getBoundingClientRect(),l=8,c=Number.parseFloat(getComputedStyle(this).getPropertyValue("--scb-dropdown-panel-gap")),o=Number.isFinite(c)?c:8,p=Math.max(0,window.innerWidth-l*2),b=i?getComputedStyle(i):null,E=b?[b.paddingInlineStart,b.paddingInlineEnd].map(u=>Number.parseFloat(u)).filter(Number.isFinite).reduce((u,O)=>u+O,0):0,x=(this._panelInnerEl?.scrollWidth||0)+E,y=Number.parseFloat(b?.maxWidth??""),P=this.width?0:Math.min(x,Number.isFinite(y)?y:x),T=Math.max(s?.width||0,i?.scrollWidth||0,P,n.width),f=Math.min(Math.max(n.width,T),p),C=Math.min(Math.max(n.left,l),window.innerWidth-l-f);e.style.position="fixed",e.style.left=`${Math.round(C)}px`,e.style.right="auto",e.style.width=`${Math.round(f)}px`;const m=window.innerHeight-n.bottom-o-l,_=n.top-o-l,k=(i?.scrollHeight||s?.height||0)>m&&_>m,R=Math.max(0,k?_:m);i?.style.setProperty("--scb-dropdown-panel-viewport-max-height",`${Math.floor(R)}px`),k?(e.style.top="auto",e.style.bottom=`${Math.round(window.innerHeight-n.top+o)}px`):(e.style.top=`${Math.round(n.bottom+o)}px`,e.style.bottom="auto")}_syncPanelMaxHeightByOpen(){const e=this._panelSurfaceEl;if(!e)return;if(this._slottedMenuEl){e.style.removeProperty("--scb-dropdown-panel-current-max-height");return}if(!this.open){e.style.setProperty("--scb-dropdown-panel-current-max-height","0px");return}const t=this._panelInnerEl;if(!t)return;const i=getComputedStyle(e),n=(Number.parseFloat(i.paddingTop)||0)+(Number.parseFloat(i.paddingBottom)||0),s=`${Math.ceil(t.scrollHeight+n)}px`;e.style.getPropertyValue("--scb-dropdown-panel-current-max-height").trim()!==s&&(e.style.setProperty("--scb-dropdown-panel-current-max-height",s),this._schedulePanelPlacement())}_mapSpacingToken(e){const t=String(e).trim();return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_mapHostSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapHostSpacingToken(this.spacing),t=this._mapHostSpacingToken(this.spacingTop)??e,i=this._mapHostSpacingToken(this.spacingBottom)??e,n=this._mapHostSpacingToken(this.spacingLeft),s=this._mapHostSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dropdown-spacing-block-start",t):this.style.removeProperty("--scb-dropdown-spacing-block-start"),i?this.style.setProperty("--scb-dropdown-spacing-block-end",i):this.style.removeProperty("--scb-dropdown-spacing-block-end"),n?this.style.setProperty("--scb-dropdown-spacing-inline-start",n):this.style.removeProperty("--scb-dropdown-spacing-inline-start"),s?this.style.setProperty("--scb-dropdown-spacing-inline-end",s):this.style.removeProperty("--scb-dropdown-spacing-inline-end")}_syncSlottedMenu(){const e=(this._slotEl?.assignedElements({flatten:!0})??[]).find(t=>t.tagName.toLowerCase()==="scb-options-menu");if(e===this._slottedMenuEl){this._syncSlottedMenuOpen();return}this._detachSlottedMenuListeners(),this._slottedMenuEl=e??null,this._slottedMenuEl&&(this._slottedMenuEl.addEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.addEventListener("close",this._onSlottedMenuClose),this._syncSlottedMenuOpen())}_detachSlottedMenuListeners(){this._slottedMenuEl&&(this._slottedMenuEl.removeEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.removeEventListener("close",this._onSlottedMenuClose))}_syncSlottedMenuOpen(){if(!this._slottedMenuEl)return;if(this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),this.open){this._slottedMenuEl.open=!0;return}const e=this._getPanelTransitionMs();if(e<=0){this._slottedMenuEl.open=!1;return}this._menuCloseTimer=window.setTimeout(()=>{this._menuCloseTimer=null,!this.open&&this._slottedMenuEl&&(this._slottedMenuEl.open=!1)},e)}_syncOverflowVisibilityByOpen(){if(this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this.removeAttribute("data-open-settled"),!this.open)return;const e=this.renderRoot.querySelector(".panel-surface");if(!e){this.setAttribute("data-open-settled","");return}const t=this._getTransitionMs(e);if(t<=0){this.setAttribute("data-open-settled","");return}this._openSettledTimer=window.setTimeout(()=>{this._openSettledTimer=null,this.open&&this.setAttribute("data-open-settled","")},t)}_getPanelTransitionMs(){const e=this.renderRoot.querySelector(".panel-surface");return e?this._getTransitionMs(e):0}_getTransitionMs(e){const t=getComputedStyle(e),i=t.transitionDuration.split(",").map(o=>o.trim()),n=t.transitionDelay.split(",").map(o=>o.trim()),s=o=>{const p=parseFloat(o);return Number.isFinite(p)?o.endsWith("ms")?p:o.endsWith("s")?p*1e3:p:0},l=Math.max(i.length,n.length);let c=0;for(let o=0;o<l;o+=1){const p=s(i[o]??i[i.length-1]??"0s"),b=s(n[o]??n[n.length-1]??"0s");c=Math.max(c,p+b)}return Math.ceil(c)}_applyInertByOpen(){const e=this.renderRoot.querySelector(".panel");e&&(this.open?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false"),this._restoreTabIndexesIfNeeded()):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true"),this._removeTabIndexesIfNeeded()))}_supportsInert(){return"inert"in HTMLElement.prototype}_collectFocusableFromSlot(){const e=this._slotEl;if(!e)return[];const t=e.assignedElements({flatten:!0}),i=[],n=s=>{s instanceof HTMLElement&&s.matches("a,button,input,select,textarea,[tabindex]")&&i.push(s)};return t.forEach(s=>{n(s),s.querySelectorAll?.("a,button,input,select,textarea,[tabindex]").forEach(l=>n(l))}),i}_removeTabIndexesIfNeeded(){this._supportsInert()||this._collectFocusableFromSlot().forEach(e=>{const t=e.getAttribute("tabindex");t!==null&&e.setAttribute("data-scb-prev-tabindex",t),e.setAttribute("tabindex","-1")})}_restoreTabIndexesIfNeeded(){this._supportsInert()||this._collectFocusableFromSlot().forEach(e=>{const t=e.getAttribute("data-scb-prev-tabindex");t!==null?(e.setAttribute("tabindex",t),e.removeAttribute("data-scb-prev-tabindex")):e.removeAttribute("tabindex")})}_closeAllSubMenus(){const e=this.querySelectorAll("scb-options-sub-menu");for(const t of e)t.removeAttribute("open")}focus(e){const t=this._triggerEl;if(t?.focus){t.focus(e);return}super.focus(e)}_applyChevronState(){if(this.hasAttribute("as-tab"))return;const e=this._ensureTriggerChevronEl();e&&(e.open=this.open)}_ensureTriggerChevronEl(){const e=this._triggerEl;if(e?.tagName?.toLowerCase?.()!=="scb-button")return null;const t=e?.shadowRoot;if(!t)return null;const i=t.querySelector('scb-chevron[slot="icon"]');if(i)return i;const n=t.querySelector('md-icon[slot="icon"]')??t.querySelector("md-icon");if(!n)return null;const s=document.createElement("scb-chevron");s.setAttribute("slot","icon"),s.setAttribute("aria-hidden","true"),s.classList.add("chevron");const l=getComputedStyle(n).fontSize;return l&&s.style.setProperty("--scb-chevron-size",l),n.replaceWith(s),s}render(){const e=!!this._slottedMenuEl,t=this.hasAttribute("as-tab"),i=this.dataIndex,n=this.ariaCurrent==="page"?"page":S;return v`
|
|
1
|
+
import{d as g,g as S,h as I,m as A,p as d,v,y as W}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{n as $}from"../../vendor/lazy-focus-ring.js";import{t as B}from"../../vendor/component-defaults.js";import{t as r}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import"../scb-button/scb-button.js";import{a as H,i as z,n as L,t as M}from"../../vendor/manual-popover.js";import"../scb-options-menu/scb-options-menu.js";(function(){try{var h=typeof globalThis<"u"?globalThis:window;if(!h.__scb_ce_guard_installed__){h.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,n){try{customElements.get(t)||e(t,i,n)}catch(l){var s=String(l||"");if(s.indexOf("already been used")===-1&&s.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var w,a=(w=class extends I{constructor(...e){super(...e),this.label="Dropdown",this.variant="filled",this.size=B["scb-dropdown"].size,this.open=!1,this.disabled=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.menuGap="3",this.width=null,this.minWidth=null,this.maxWidth=null,this.dataIndex=null,this.ariaCurrent=null,this._slottedMenuEl=null,this._openSettledTimer=null,this._menuCloseTimer=null,this._panelResizeObserver=null,this._panelHeightSyncRaf=null,this._panelPlacementRaf=null,this._onViewportChange=()=>{this.open&&this._schedulePanelPlacement()},this._onDocumentClickBound=t=>{if(!this.open)return;const i=t.composedPath(),n=i.find(s=>s instanceof HTMLElement&&s.tagName.toLowerCase()==="scb-dropdown");if(n&&n!==this){this.open=!1;return}i.includes(this)||(this.open=!1)},this._onDocumentKeydownBound=t=>{this.open&&t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.open=!1,this.updateComplete.then(()=>this.focus({preventScroll:!0})))},this._onSlottedMenuOpen=()=>{this.open||(this.open=!0)},this._onSlottedMenuClose=()=>{this.open&&(this.open=!1)},this._onSlotChange=()=>{this._syncSlottedMenu(),this._applyPanelSizing(),this._applyInertByOpen(),this.requestUpdate()},this._onTriggerClick=t=>{this.hasAttribute("as-tab")||t.stopPropagation(),!this.disabled&&(this.open=!this.open)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._onDocumentClickBound,!0),document.addEventListener("keydown",this._onDocumentKeydownBound),window.addEventListener("resize",this._onViewportChange,{passive:!0}),window.addEventListener("scroll",this._onViewportChange,{passive:!0,capture:!0})}disconnectedCallback(){document.removeEventListener("click",this._onDocumentClickBound,!0),document.removeEventListener("keydown",this._onDocumentKeydownBound),window.removeEventListener("resize",this._onViewportChange),window.removeEventListener("scroll",this._onViewportChange,!0),this._detachSlottedMenuListeners(),M(this.renderRoot.querySelector(".panel")),this._panelResizeObserver&&(this._panelResizeObserver.disconnect(),this._panelResizeObserver=null),this._panelHeightSyncRaf!==null&&(window.cancelAnimationFrame(this._panelHeightSyncRaf),this._panelHeightSyncRaf=null),this._panelPlacementRaf!==null&&(window.cancelAnimationFrame(this._panelPlacementRaf),this._panelPlacementRaf=null),this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),this._syncSlottedMenu(),this._applyPanelVars(),this._applyPanelSizing(),this._applyChevronState(),this._applyInertByOpen(),this._setupPanelResizeObserver(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen(),this._syncPanelPopover()}updated(e){super.updated(e),e.has("menuGap")&&this._applyPanelVars(),(e.has("width")||e.has("minWidth")||e.has("maxWidth"))&&this._applyPanelSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing(),e.has("open")&&(this.open||this._closeAllSubMenus(),this._syncSlottedMenuOpen(),this._applyChevronState(),this._applyInertByOpen(),this._syncPanelMaxHeightByOpen(),this._syncOverflowVisibilityByOpen(),this._syncPanelPopover(),this.dispatchEvent(new CustomEvent("openchange",{bubbles:!0,composed:!0,detail:{open:this.open}})))}_applyPanelVars(){if(this.menuGap==null||String(this.menuGap).trim()===""){this.style.removeProperty("--scb-dropdown-panel-gap");return}this.style.setProperty("--scb-dropdown-panel-gap",this._mapSpacingToken(this.menuGap))}_applyPanelSizing(){const e=this.renderRoot.querySelector(".panel-surface");e&&(this.width&&String(this.width).trim()!==""?e.style.inlineSize=this.width:e.style.removeProperty("inline-size"),this.minWidth&&String(this.minWidth).trim()!==""?e.style.minInlineSize=this.minWidth:e.style.removeProperty("min-inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?e.style.maxInlineSize=this.maxWidth:e.style.removeProperty("max-inline-size")),this._slottedMenuEl&&(this.width&&String(this.width).trim()!==""?this._slottedMenuEl.style.inlineSize=this.width:this._slottedMenuEl.style.removeProperty("inline-size"),this.minWidth&&String(this.minWidth).trim()!==""?this._slottedMenuEl.style.minInlineSize=this.minWidth:this._slottedMenuEl.style.removeProperty("min-inline-size"),this.maxWidth&&String(this.maxWidth).trim()!==""?this._slottedMenuEl.style.maxInlineSize=this.maxWidth:this._slottedMenuEl.style.removeProperty("max-inline-size")),this._schedulePanelHeightSync()}_setupPanelResizeObserver(){if(this._panelResizeObserver||typeof ResizeObserver>"u")return;const e=this._panelInnerEl;e&&(this._panelResizeObserver=new ResizeObserver(()=>{this._schedulePanelHeightSync()}),this._panelResizeObserver.observe(e))}_schedulePanelHeightSync(){this._panelHeightSyncRaf===null&&(this._panelHeightSyncRaf=window.requestAnimationFrame(()=>{this._panelHeightSyncRaf=null,this._syncPanelMaxHeightByOpen()}))}_schedulePanelPlacement(){this._panelPlacementRaf===null&&(this._panelPlacementRaf=window.requestAnimationFrame(()=>{this._panelPlacementRaf=null,this._positionPanelInViewport()}))}_syncPanelPopover(){const e=this.renderRoot.querySelector(".panel");if(!e)return;if(this.open){H(e)&&this._schedulePanelPlacement();return}const t=()=>{this._panelSurfaceEl?.style.removeProperty("--scb-dropdown-panel-viewport-max-height"),e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("right"),e.style.removeProperty("top"),e.style.removeProperty("bottom"),e.style.removeProperty("width")};z(e)?L(e,t,this._panelSurfaceEl??e):(M(e),t())}_positionPanelInViewport(){const e=this.renderRoot.querySelector(".panel"),t=this._triggerEl;if(!e||!t||!z(e))return;const i=this._panelSurfaceEl,n=t.getBoundingClientRect(),s=i?.getBoundingClientRect(),l=8,c=Number.parseFloat(getComputedStyle(this).getPropertyValue("--scb-dropdown-panel-gap")),o=Number.isFinite(c)?c:8,p=Math.max(0,window.innerWidth-l*2),b=i?getComputedStyle(i):null,E=b?[b.paddingInlineStart,b.paddingInlineEnd].map(u=>Number.parseFloat(u)).filter(Number.isFinite).reduce((u,O)=>u+O,0):0,x=(this._panelInnerEl?.scrollWidth||0)+E,y=Number.parseFloat(b?.maxWidth??""),P=this.width?0:Math.min(x,Number.isFinite(y)?y:x),T=Math.max(s?.width||0,i?.scrollWidth||0,P,n.width),f=Math.min(Math.max(n.width,T),p),C=Math.min(Math.max(n.left,l),window.innerWidth-l-f);e.style.position="fixed",e.style.left=`${Math.round(C)}px`,e.style.right="auto",e.style.width=`${Math.round(f)}px`;const m=window.innerHeight-n.bottom-o-l,_=n.top-o-l,k=(i?.scrollHeight||s?.height||0)>m&&_>m,R=Math.max(0,k?_:m);i?.style.setProperty("--scb-dropdown-panel-viewport-max-height",`${Math.floor(R)}px`),k?(e.style.top="auto",e.style.bottom=`${Math.round(window.innerHeight-n.top+o)}px`):(e.style.top=`${Math.round(n.bottom+o)}px`,e.style.bottom="auto")}_syncPanelMaxHeightByOpen(){const e=this._panelSurfaceEl;if(!e)return;if(this._slottedMenuEl){e.style.removeProperty("--scb-dropdown-panel-current-max-height");return}if(!this.open){e.style.setProperty("--scb-dropdown-panel-current-max-height","0px");return}const t=this._panelInnerEl;if(!t)return;const i=getComputedStyle(e),n=(Number.parseFloat(i.paddingTop)||0)+(Number.parseFloat(i.paddingBottom)||0),s=`${Math.ceil(t.scrollHeight+n)}px`;e.style.getPropertyValue("--scb-dropdown-panel-current-max-height").trim()!==s&&(e.style.setProperty("--scb-dropdown-panel-current-max-height",s),this._schedulePanelPlacement())}_mapSpacingToken(e){const t=String(e).trim();return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_mapHostSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapHostSpacingToken(this.spacing),t=this._mapHostSpacingToken(this.spacingTop)??e,i=this._mapHostSpacingToken(this.spacingBottom)??e,n=this._mapHostSpacingToken(this.spacingLeft),s=this._mapHostSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-dropdown-spacing-block-start",t):this.style.removeProperty("--scb-dropdown-spacing-block-start"),i?this.style.setProperty("--scb-dropdown-spacing-block-end",i):this.style.removeProperty("--scb-dropdown-spacing-block-end"),n?this.style.setProperty("--scb-dropdown-spacing-inline-start",n):this.style.removeProperty("--scb-dropdown-spacing-inline-start"),s?this.style.setProperty("--scb-dropdown-spacing-inline-end",s):this.style.removeProperty("--scb-dropdown-spacing-inline-end")}_syncSlottedMenu(){const e=(this._slotEl?.assignedElements({flatten:!0})??[]).find(t=>t.tagName.toLowerCase()==="scb-options-menu");if(e===this._slottedMenuEl){this._syncSlottedMenuOpen();return}this._detachSlottedMenuListeners(),this._slottedMenuEl=e??null,this._slottedMenuEl&&(this._slottedMenuEl.addEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.addEventListener("close",this._onSlottedMenuClose),this._syncSlottedMenuOpen())}_detachSlottedMenuListeners(){this._slottedMenuEl&&(this._slottedMenuEl.removeEventListener("open",this._onSlottedMenuOpen),this._slottedMenuEl.removeEventListener("close",this._onSlottedMenuClose))}_syncSlottedMenuOpen(){if(!this._slottedMenuEl)return;if(this._menuCloseTimer!==null&&(window.clearTimeout(this._menuCloseTimer),this._menuCloseTimer=null),this.open){this._slottedMenuEl.open=!0;return}const e=this._getPanelTransitionMs();if(e<=0){this._slottedMenuEl.open=!1;return}this._menuCloseTimer=window.setTimeout(()=>{this._menuCloseTimer=null,!this.open&&this._slottedMenuEl&&(this._slottedMenuEl.open=!1)},e)}_syncOverflowVisibilityByOpen(){if(this._openSettledTimer!==null&&(window.clearTimeout(this._openSettledTimer),this._openSettledTimer=null),this.removeAttribute("data-open-settled"),!this.open)return;const e=this.renderRoot.querySelector(".panel-surface");if(!e){this.setAttribute("data-open-settled","");return}const t=this._getTransitionMs(e);if(t<=0){this.setAttribute("data-open-settled","");return}this._openSettledTimer=window.setTimeout(()=>{this._openSettledTimer=null,this.open&&this.setAttribute("data-open-settled","")},t)}_getPanelTransitionMs(){const e=this.renderRoot.querySelector(".panel-surface");return e?this._getTransitionMs(e):0}_getTransitionMs(e){const t=getComputedStyle(e),i=t.transitionDuration.split(",").map(o=>o.trim()),n=t.transitionDelay.split(",").map(o=>o.trim()),s=o=>{const p=parseFloat(o);return Number.isFinite(p)?o.endsWith("ms")?p:o.endsWith("s")?p*1e3:p:0},l=Math.max(i.length,n.length);let c=0;for(let o=0;o<l;o+=1){const p=s(i[o]??i[i.length-1]??"0s"),b=s(n[o]??n[n.length-1]??"0s");c=Math.max(c,p+b)}return Math.ceil(c)}_applyInertByOpen(){const e=this.renderRoot.querySelector(".panel");e&&(this.open?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false"),this._restoreTabIndexesIfNeeded()):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true"),this._removeTabIndexesIfNeeded()))}_supportsInert(){return"inert"in HTMLElement.prototype}_collectFocusableFromSlot(){const e=this._slotEl;if(!e)return[];const t=e.assignedElements({flatten:!0}),i=[],n=s=>{s instanceof HTMLElement&&s.matches("a,button,input,select,textarea,[tabindex]")&&i.push(s)};return t.forEach(s=>{n(s),s.querySelectorAll?.("a,button,input,select,textarea,[tabindex]").forEach(l=>n(l))}),i}_removeTabIndexesIfNeeded(){this._supportsInert()||this._collectFocusableFromSlot().forEach(e=>{const t=e.getAttribute("tabindex");t!==null&&e.setAttribute("data-scb-prev-tabindex",t),e.setAttribute("tabindex","-1")})}_restoreTabIndexesIfNeeded(){this._supportsInert()||this._collectFocusableFromSlot().forEach(e=>{const t=e.getAttribute("data-scb-prev-tabindex");t!==null?(e.setAttribute("tabindex",t),e.removeAttribute("data-scb-prev-tabindex")):e.removeAttribute("tabindex")})}_closeAllSubMenus(){const e=this.querySelectorAll("scb-options-sub-menu");for(const t of e)t.removeAttribute("open")}focus(e){const t=this._triggerEl;if(t?.focus){t.focus(e);return}super.focus(e)}_applyChevronState(){if(this.hasAttribute("as-tab"))return;const e=this._ensureTriggerChevronEl();e&&(e.open=this.open)}_ensureTriggerChevronEl(){const e=this._triggerEl;if(e?.tagName?.toLowerCase?.()!=="scb-button")return null;const t=e?.shadowRoot;if(!t)return null;const i=t.querySelector('scb-chevron[slot="icon"]');if(i)return i;const n=t.querySelector('md-icon[slot="icon"]')??t.querySelector("md-icon");if(!n)return null;const s=document.createElement("scb-chevron");s.setAttribute("slot","icon"),s.setAttribute("aria-hidden","true"),s.classList.add("chevron");const l=getComputedStyle(n).fontSize;return l&&s.style.setProperty("--scb-chevron-size",l),n.replaceWith(s),s}render(){const e=!!this._slottedMenuEl,t=this.hasAttribute("as-tab"),i=this.dataIndex,n=this.ariaCurrent==="page"?"page":S;return v`
|
|
2
2
|
${t?v`
|
|
3
3
|
<div class="tab-wrap">
|
|
4
4
|
<button
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/icon.js","../../vendor/rolldown-runtime.js","../../vendor/vendor.js","../../vendor/vendor-lit.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f,h as v,m,p as s,v as p,y}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as _}from"../../vendor/preload-helper.js";import{
|
|
2
|
+
import{f,h as v,m,p as s,v as p,y}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as _}from"../../vendor/preload-helper.js";import{t as k}from"../../vendor/component-size-token.js";import{t as r}from"../../vendor/decorate.js";import{t as h}from"../../vendor/assertClassBrand.js";import{t as w}from"../../vendor/classPrivateMethodInitSpec.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-link/scb-link.js";import"./scb-fact-card-content.js";(function(){try{var c=typeof globalThis<"u"?globalThis:window;if(!c.__scb_ce_guard_installed__){c.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,n,d){try{customElements.get(e)||t(e,n,d)}catch(g){var o=String(g||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw g}}}}catch{}})();var b,l,i,x={fromAttribute:c=>c??"",toAttribute:c=>typeof c!="string"||c.trim()===""?null:c},a=(b=new WeakSet,l=class extends v{constructor(...t){super(...t),w(this,b),this.__onCloseClick=e=>{e.stopPropagation(),this.__setOpen(!1)},this.variant="filled",this.title="",this.subtitle="",this.supportingText="",this.icon="",this.showCloseButton=!1,this.closeLabel="Stäng faktakort",this.__hasIconSlot=!1,this.open=!0,this.__lastTriggerEl=null,this.sizing="",this.width="",this.maxWidth="",this.height="",this.maxHeight="",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.__onIconSlotChange=()=>{const e=this.renderRoot.querySelector('slot[name="icon"]');this.__hasIconSlot=!!e?.assignedNodes({flatten:!0}).some(n=>n.nodeType===Node.TEXT_NODE?!!n.textContent?.trim():!0)}}static __handleDocClick(t){const e=t.composedPath();for(const n of e){if(!(n instanceof Element))continue;const d=n.getAttribute("data-fact-card-toggle")||n.getAttribute("aria-controls");if(!d)continue;const o=i.__instances.get(d);if(!o){i.__instances.delete(d);continue}o.__lastTriggerEl=n,o.__setOpen(!o.open);break}}static __ensureDocListener(){i.__docListenerAttached||(document.addEventListener("click",i.__handleDocClick,!0),i.__docListenerAttached=!0)}static __maybeRemoveDocListener(){i.__docListenerAttached&&i.__instances.size===0&&(document.removeEventListener("click",i.__handleDocClick,!0),i.__docListenerAttached=!1)}connectedCallback(){super.connectedCallback(),this.id&&i.__instances.set(this.id,this),i.__ensureDocListener()}disconnectedCallback(){this.id&&i.__instances.delete(this.id),i.__maybeRemoveDocListener(),super.disconnectedCallback()}updated(t){t.has("open")&&this.__updateTriggersExpanded(),t.has("width")&&(this.width?this.style.inlineSize=this.width:this.style.removeProperty("inline-size")),t.has("maxWidth")&&(this.maxWidth?this.style.maxInlineSize=this.maxWidth:this.style.removeProperty("max-inline-size")),t.has("height")&&(this.height?this.style.blockSize=this.height:this.style.removeProperty("block-size")),t.has("maxHeight")&&(this.maxHeight?this.style.maxBlockSize=this.maxHeight:this.style.removeProperty("max-block-size")),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&h(b,this,u).call(this)}__updateTriggersExpanded(){this.id&&document.querySelectorAll(`[aria-controls="${this.id}"], [data-fact-card-toggle="${this.id}"]`).forEach(t=>{t.hasAttribute("aria-controls")&&t.setAttribute("aria-expanded",String(this.open))})}__setOpen(t){const e=this.open;e!==t&&(this.open=t,this.dispatchEvent(new CustomEvent("openchange",{bubbles:!0,composed:!0,detail:{open:this.open}})),t&&!e?this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})):!t&&e&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))}render(){if(!this.open)return p``;const t=this.variant==="outlined"?"outlined":"filled",e=!!this.icon||this.__hasIconSlot||this.__hasLightDomSlot("icon");return p`
|
|
3
3
|
<div class="outer ${e?"has-icon":""}">
|
|
4
4
|
<div class="icon-wrapper ${t}" ?hidden=${!e}>
|
|
5
5
|
<slot name="icon" @slotchange=${this.__onIconSlotChange}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/lazy-focus-ring.js","../../vendor/rolldown-runtime.js","../../vendor/preload-helper.js","../scb-drawer/scb-drawer.js","../../vendor/vendor.js","../../vendor/vendor-lit.js","../../vendor/decorate.js","../../vendor/manual-popover.js","../scb-divider/scb-divider.js","../../vendor/assertClassBrand.js","../../vendor/classPrivateMethodInitSpec.js","../scb-menu/scb-menu.js","../scb-menu/scb-menu-item.js","../../vendor/scb-chevron.js","../scb-menu/scb-menu-section.js","../scb-menu/scb-sub-menu.js","../scb-search/scb-search.js","../../vendor/icon.js","../../vendor/ripple.js","../../vendor/attachable-controller.js","../../vendor/component-size-token.js","../../vendor/component-defaults.js","../../vendor/scb-header-drawer.internal.js","../scb-button/scb-button.js","../scb-icon-button/scb-icon-button.js","../scb-skeleton/scb-skeleton.js","../scb-grid/scb-grid.js","../scb-grid/scb-grid-item.js","../scb-grid/scb-stack.js","../scb-dropdown/scb-dropdown.js","../scb-options-menu/scb-options-menu.js","../scb-options-menu/scb-options-menu-item.js","../scb-options-menu/scb-options-sub-menu.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{f as _,g as w,h as R,m as N,p as l,v,y as O}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as S}from"../../vendor/preload-helper.js";import{t as B}from"../../vendor/component-defaults.js";import{t as c}from"../../vendor/decorate.js";(function(){try{var u=typeof globalThis<"u"?globalThis:window;if(!u.__scb_ce_guard_installed__){u.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,a,r){try{customElements.get(t)||e(t,a,r)}catch(o){var s=String(o||"");if(s.indexOf("already been used")===-1&&s.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var C,T,H=0,I=[0,2,4,8,12,16,20,24,32,40,48,64,80,96,120],W=()=>{if(typeof window>"u"||typeof document>"u"||!("customElements"in window)||document.head.querySelector("style[data-scb-header-pre-upgrade]"))return;const u=document.createElement("style");u.setAttribute("data-scb-header-pre-upgrade",""),u.textContent=`
|
|
3
3
|
scb-header:not(:defined),
|
|
4
4
|
scb-header[data-upgrading] {
|
|
@@ -52,7 +52,7 @@ import{f as _,g as w,h as R,m as N,p as l,v,y as O}from"../../vendor/vendor.js";
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
`,document.head.appendChild(u);const e=n=>{const g=String(n??"").trim();if(g){if(/^\d+$/.test(g)){const b=Math.max(0,Math.min(14,parseInt(g,10)));return`var(--spacing-${b}, ${I[b]}px)`}return g}},t=n=>{const g=String(n??"").trim();if(!g)return!1;try{const b=JSON.parse(g);return Array.isArray(b)&&b.length>0}catch{return!1}},a=n=>n!=null&&!/^(false|0|off|no)$/i.test(n.trim()),r=n=>{for(const g of Array.from(n.children)){const b=g.tagName.toLowerCase();if(b==="scb-header-tab"||b==="scb-dropdown")return!0}return!1},s=n=>{r(n)||t(n.getAttribute("tabs"))||a(n.getAttribute("reserve-tabs"))||a(n.getAttribute("layout-pending"))?n.setAttribute("data-pre-has-tabs",""):n.removeAttribute("data-pre-has-tabs");const g=e(n.getAttribute("spacing")),b=e(n.getAttribute("spacing-top"))??g,y=e(n.getAttribute("spacing-bottom"))??g,x=e(n.getAttribute("padding-inline")),k=e(n.getAttribute("padding-inline-expanded"))??x;b?n.style.setProperty("--scb-header-spacing-block-start",b):n.style.removeProperty("--scb-header-spacing-block-start"),y?n.style.setProperty("--scb-header-spacing-block-end",y):n.style.removeProperty("--scb-header-spacing-block-end"),x?n.style.setProperty("--scb-header-padding-inline",x):n.style.removeProperty("--scb-header-padding-inline"),k?n.style.setProperty("--scb-header-padding-inline-expanded",k):n.style.removeProperty("--scb-header-padding-inline-expanded");const d=(n.getAttribute("logo-width")??"").trim();d?n.style.setProperty("--scb-header-pre-logo-w",d):n.style.removeProperty("--scb-header-pre-logo-w");const f=(n.getAttribute("logo-height")??"").trim();f?n.style.setProperty("--scb-header-pre-logo-img-h",f):n.style.removeProperty("--scb-header-pre-logo-img-h");const m=(n.getAttribute("search-height")??"").trim();m?n.style.setProperty("--scb-header-pre-control-size",m):n.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(s);const h=new MutationObserver(n=>{for(const g of n){if(g.type==="attributes"){const b=g.target;b instanceof HTMLElement&&b.tagName.toLowerCase()==="scb-header"&&s(b);continue}if(g.type==="childList"){const b=[...Array.from(g.addedNodes),...Array.from(g.removedNodes)];for(const y of b){if(!(y instanceof HTMLElement))continue;if(y.tagName.toLowerCase()==="scb-header"){s(y);continue}const x=y.closest?.("scb-header");x&&s(x)}}}});h.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","padding-inline","padding-inline-expanded","logo-width","logo-height","logo-aspect-ratio","logo-alt","logotype-text","search-height","reserve-tabs","layout-pending"]}),customElements.whenDefined("scb-header").then(()=>{h.disconnect()})};W();var P={fromAttribute:u=>u==null?!0:!/^(false|0|off|no)$/i.test(u),toAttribute:u=>String(!!u)},L={fromAttribute:u=>u==null?!1:!/^(false|0|off|no)$/i.test(u),toAttribute:u=>u?"":null},F={fromAttribute:u=>u==="small"||u==="medium"||u==="large"?u:"medium",toAttribute:u=>{const e=String(u??"");return e==="small"||e==="medium"||e==="large"?e:null}},i=(C=class extends R{constructor(){super(),this.maxWidth="1440px",this.size=B["scb-header"].size,this.logoText="",this.logotypeText="",this.logoAlt="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.layoutPending=!1,this.utilityItems=[],this.searchButtonLabel="Sök",this.searchClearLabel="Rensa sökfält",this.searchCloseLabel="Stäng sök",this.menuButtonLabel="Meny",this.menuOpenLabel="Öppna meny",this.utilityNavigationLabel="Funktionslänkar",this.mainNavigationLabel="Huvudnavigering",this.deferDrawer=!1,this.showDrawer=!0,this.alwaysShowMenuButton=!1,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._drawerReady=!1,this._mobileSearchOpen=!1,this._initialUpgradeComplete=!1,this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._observedLayout=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this.layoutPending||this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{window.innerWidth>=this.BP_SM&&this._mobileSearchOpen&&this._setMobileSearchOpen(!1),this._scheduleMeasure()},this._onMenuSelect=t=>{t.stopPropagation();const a=t.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:a,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:a,bubbles:!0,composed:!0}));const r=a?.item,s=typeof a?.href=="string"?a.href:typeof a?.itemHref=="string"?a.itemHref:typeof a?.item_href=="string"?a.item_href:"",o=r?r.getAttribute("item-href")??r.getAttribute("href")??"":"";String(s||o||"").trim()&&this._closeDrawerNow()},this._onMenuSelectAlias=t=>{t.stopPropagation()},this._collapsed=!1,this._unlockAtWidth=0,this._tabsCollapsed=!1,this._desktop=typeof window<"u"&&window.innerWidth>=T.BP_MD_DEFAULT,this._hideLogoText=!1,this._slotWatchers=[],this._harvestPending=!1,this._harvest=(t={})=>{const a=Array.from(this.children),r=[],s=[],o=[];let h=-1,n=!1;const g=d=>({label:d.getAttribute("label")??"",href:d.getAttribute("href")??void 0,icon:d.getAttribute("icon")??void 0}),b=d=>{d.hasAttribute("role")&&d.removeAttribute("role"),d.hasAttribute("hidden")||d.setAttribute("hidden",""),d.getAttribute("aria-hidden")!=="true"&&d.setAttribute("aria-hidden","true")};for(const d of a){const f=d.tagName.toLowerCase();if(this._isDrawerCloseNode(d)){this._syncDrawerCloseNode(d);continue}if(f==="scb-header-tab"){b(d);const m=d.getAttribute("label")??"",p=d.getAttribute("href"),A=p&&p.trim()!==""?p:void 0;(d.hasAttribute("selected")||d.getAttribute("selected")==="true"||d.getAttribute("active")==="true"||d.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length),r.push({kind:"tab",label:m,href:A});continue}if(f==="scb-badge"){const m=d.querySelector("scb-dropdown");if(m){n=!0;const p=m.getAttribute("label")??"";(m.hasAttribute("selected")||m.getAttribute("selected")==="true"||m.getAttribute("active")==="true"||m.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length);const A=`scb-header-tab-${r.length}`;d.getAttribute("slot")!==A&&d.setAttribute("slot",A),m.hasAttribute("slot")&&m.removeAttribute("slot"),m.hasAttribute("as-tab")||m.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:A,label:p});continue}}if(f==="scb-dropdown"){n=!0;const m=d.getAttribute("label")??"";(d.hasAttribute("selected")||d.getAttribute("selected")==="true"||d.getAttribute("active")==="true"||d.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length);const p=`scb-header-tab-${r.length}`;d.getAttribute("slot")!==p&&d.setAttribute("slot",p),d.hasAttribute("as-tab")||d.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:p,label:m});continue}if(f==="scb-header-utility"){b(d),s.push({label:d.getAttribute("label")??"",href:d.getAttribute("href")??"#",target:d.getAttribute("target")??void 0});continue}if(f==="scb-header-menu-group"){b(d);const m={label:d.getAttribute("label")??"",icon:d.getAttribute("icon")??void 0,children:[]};d.querySelectorAll("scb-header-menu-item").forEach(p=>m.children.push(g(p))),o.push(m);continue}if(f==="scb-header-menu-item"){b(d),o.push(g(d));continue}d.hasAttribute("slot")||b(d)}const y=!this._sameNavItems(this._slotNavItems,r),x=!this._sameUtilityItems(this._slotUtils,s),k=!this._sameMenuNodes(this._slotMenu,o);y&&(this._slotNavItems=r),x&&(this._slotUtils=s),k&&(this._slotMenu=o),n&&this._ensureDropdownReady(),!this.hasAttribute("active-tab")&&h>=0&&this.activeTab!==h&&(this.activeTab=h),(t.scheduleMeasure??!0)&&queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{if(this.layoutPending)return;const t=this._top,a=this._logoGroup;if(!t||!a)return;const r=window.innerWidth;this._desktop=r>=this.BP_MD;const s=t.clientWidth,o=this._overflows(this._util),h=!this._desktop||o;this._collapsed?!h&&s>=this._unlockAtWidth&&this._setCollapsed(!1):h&&(this._unlockAtWidth=s+this._HYST,this._setCollapsed(!0)),this._setTabsCollapsed(this._tabsOverflows());let n=!1;if(this.showSearch&&r>=this.BP_SM&&r<this.BP_MD&&this._searchWrap){const x=getComputedStyle(this._searchWrap),k=Math.max(this._num(x.minWidth,this._tokenPx("--scb-header-search-min",250)),this._tokenPx("--scb-header-search-min",250)),d=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),f=this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;n=a.getBoundingClientRect().width+d+k+d+f+8>s+.5}this._setHideSearch(n);let g=!1;const b=this.renderRoot.querySelector(".actions"),y=Array.from(b?.querySelectorAll(".header-icon-button")??[]).filter(x=>this._visible(x));if(y.length>0&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const x=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),k=b?this._num(getComputedStyle(b).columnGap,0):0,d=y.reduce((m,p)=>m+p.getBoundingClientRect().width,0)+k*Math.max(0,y.length-1);this._hideLogoText&&this.removeAttribute("data-hide-logo-text");const f=a.getBoundingClientRect().width;this._hideLogoText&&this.setAttribute("data-hide-logo-text",""),g=f+x+d+(this._hideLogoText?this._HYST:0)>s+.5}this._setHideLogoText(g)},this._onGlobalFocusRingKeydown=t=>{t.key==="Tab"&&(this.toggleAttribute("data-keyboard-focus",!0),this._ensureFocusRingReady())},this._onGlobalFocusRingPointerDown=()=>{this.removeAttribute("data-keyboard-focus")},this._onLocalFocusIn=t=>{const a=t.composedPath()[0];a instanceof HTMLElement&&a.matches(":focus-visible")&&this._ensureFocusRingReady()},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=async t=>{this.showDrawer&&(this._setMobileSearchOpen(!1),this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})),!this._drawerReady&&(t.stopPropagation(),await this._ensureDrawerReady(),await this.updateComplete,this._openDrawerNow()))},this._onMobileSearchToggle=()=>{const t=!this._mobileSearchOpen;this._setMobileSearchOpen(t),t&&this.updateComplete.then(()=>{this.renderRoot.querySelector(".mobile-search-panel .header-search-input")?.focus?.()})},this._onTabClick=t=>{const a=t.currentTarget;if(!a)return;const r=a.tagName.toLowerCase()==="a";if(r&&(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey))return;const s=a.getAttribute("data-index"),o=s!=null?Number(s):0,h=this._getNavItems()[o];if(h?.kind==="dropdown")return;this.activeTab=o;const n=h?.kind==="tab"?h.href??"":"",g=new CustomEvent("tab-change",{detail:{index:o,href:n},bubbles:!0,composed:!0,cancelable:!0}),b=new CustomEvent("tabchange",{detail:{index:o,href:n},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(g)&&this.dispatchEvent(b))&&r&&t.preventDefault()},this._onDropdownTabActivate=t=>{const a=t.detail?.dataIndex,r=typeof a=="number"?a:typeof a=="string"?Number(a):this._readTabIndexFromEvent(t);if(r==null||!Number.isFinite(r))return;const s=this._getNavItems();r<0||r>=s.length||s[r]?.kind==="dropdown"&&(this.activeTab=r,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=t=>{const a=t.key;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="Home"&&a!=="End")return;const r=this._getNavItems();if(!r.length)return;const s=this._readTabIndexFromEvent(t);if(s==null)return;let o=Math.max(0,Math.min(r.length-1,s));a==="ArrowRight"?o=(o+1)%r.length:a==="ArrowLeft"?o=(o-1+r.length)%r.length:a==="Home"?o=0:a==="End"&&(o=r.length-1),t.preventDefault(),this._focusTabAtIndex(o)},this._onNativeSearchInput=t=>{const a=t.currentTarget;this._emitSearchInput(a?.value??"")},this._onNativeSearchSubmit=t=>{t.preventDefault();const a=t.currentTarget?.querySelector(".header-search-input");this._emitSearchChange(a?.value??"")},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))},this._onNativeSearchClear=t=>{t.preventDefault(),this._onSearchClear(),this.updateComplete.then(()=>{const a=t.currentTarget?.closest("form")?.querySelector(".header-search-input");a&&(a.value=""),a?.focus()})};const e=++H;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}requestLayout(){this.layoutPending||(this.setAttribute("data-layout-settling",""),this.updateComplete.then(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-layout-settling"))}))}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",T.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",T.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(s=>s.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active","role"],t=s=>{const o=new MutationObserver(h=>{this._scheduleHarvest()});this._slotWatchers.push(o),o.observe(s,{attributes:!0,attributeFilter:e})},a=()=>{this._slotWatchers.forEach(o=>o.disconnect()),this._slotWatchers=[];const s=Array.from(this.children);for(const o of s){const h=o.tagName.toLowerCase();if((h==="scb-header-tab"||h==="scb-dropdown"||h==="scb-header-utility"||h==="scb-header-menu-item"||h==="scb-header-menu-group"||h==="scb-badge")&&t(o),h==="scb-badge"){const n=o,g=new MutationObserver(y=>{a(),this._scheduleHarvest()});this._slotWatchers.push(g),g.observe(n,{childList:!0});const b=n.querySelector("scb-dropdown");b&&t(b);continue}if(h==="scb-header-menu-group"){const n=o,g=new MutationObserver(b=>{a(),this._scheduleHarvest()});this._slotWatchers.push(g),g.observe(n,{childList:!0,subtree:!0}),n.querySelectorAll("scb-header-menu-item").forEach(b=>t(b))}}},r=new MutationObserver(s=>{let o=!1;for(const h of s)if(h.type==="childList"){o=!0;break}o&&a(),this._scheduleHarvest()});this._slotMo=r,r.observe(this,{childList:!0}),a()}_sameNavItems(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.kind!==s.kind||r.label!==s.label)return!1;if(r.kind==="tab"&&s.kind==="tab"){if((r.href??"")!==(s.href??""))return!1}else if(r.kind==="dropdown"&&s.kind==="dropdown"&&r.slotName!==s.slotName)return!1}return!0}_sameUtilityItems(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.label!==s.label||r.href!==s.href||(r.target??"")!==(s.target??""))return!1}return!0}_sameMenuNodes(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.label!==s.label||(r.href??"")!==(s.href??"")||(r.icon??"")!==(s.icon??"")||!this._sameMenuNodes(r.children??[],s.children??[]))return!1}return!0}_isDrawerCloseNode(e){const t=e.tagName.toLowerCase(),a=e.getAttribute("slot");if(a==="drawer-close")return!0;if(a||t!=="scb-icon-button")return!1;const r=(e.getAttribute("icon")??"").trim().toLowerCase(),s=(e.getAttribute("aria-label")??"").trim().toLowerCase();return r==="close"||s.includes("stäng")||s.includes("close")}_syncDrawerCloseNode(e){e.getAttribute("slot")!=="drawer-close"&&e.setAttribute("slot","drawer-close"),e.setAttribute("data-drawer-close",this._drawerId),e.setAttribute("aria-controls",this._drawerId),this._drawerReady?(e.removeAttribute("hidden"),e.removeAttribute("aria-hidden")):(e.hasAttribute("hidden")||e.setAttribute("hidden",""),e.getAttribute("aria-hidden")!=="true"&&e.setAttribute("aria-hidden","true"))}_syncDrawerCloseNodes(){for(const e of Array.from(this.children))this._isDrawerCloseNode(e)&&this._syncDrawerCloseNode(e)}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_setMobileSearchOpen(e){this._mobileSearchOpen!==e&&(this._mobileSearchOpen=e,this.toggleAttribute("data-mobile-search-open",e))}_num(e,t){const a=Number.parseFloat(String(e??"").trim());return Number.isFinite(a)?a:t}_tokenPx(e,t){const a=getComputedStyle(this);return this._num(a.getPropertyValue(e),t)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav,t=e?.closest(".tabs-row");if(!e||!t||!this._desktop||!this.showDrawer)return!1;const a=t.querySelector(".menu-trigger--tabs-right"),r=a&&(this.alwaysShowMenuButton||this._collapsed),s=r?a.getBoundingClientRect().width:0,o=r?this._num(getComputedStyle(t).columnGap,0):0,h=t.getBoundingClientRect().width-s-o;return e.getBoundingClientRect().width>h+.5}_setTabsCollapsed(e){if(this._tabsCollapsed===e)return;const t=this._tabsNav;let a=e&&!!t?.contains(this.shadowRoot?.activeElement??null);if(e)for(const r of this._getNavItems()){if(r.kind!=="dropdown")continue;const s=this._getDropdownForSlot(r.slotName);a||(a=s===document.activeElement),s?.removeAttribute("open")}this._tabsCollapsed=e,this.toggleAttribute("data-tabs-collapsed",e),a&&this.updateComplete.then(()=>this._menuBtn?.focus())}_observeLayout(){const e=[this._top,this._tabsNav,this._tabsNav?.closest(".tabs-row"),this._menuBtn].filter(t=>!!t);if(!(e.length===this._observedLayout.length&&e.every((t,a)=>t===this._observedLayout[a]))){this._ro?.disconnect(),this._observedLayout=e;for(const t of e)this._ro?.observe(t,{box:"border-box"})}}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this._onGlobalFocusRingKeydown,!0),window.addEventListener("pointerdown",this._onGlobalFocusRingPointerDown,!0),this._initialUpgradeComplete||this.setAttribute("data-upgrading",""),this._harvest({scheduleMeasure:!1}),this._attachSlotObservers()}_finishInitialUpgrade(){this._initialUpgradeComplete||(this._initialUpgradeComplete=!0,requestAnimationFrame(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-upgrading"))}))}firstUpdated(){this._syncLandmarkAttributes(),this.renderRoot.addEventListener("focusin",this._onLocalFocusIn),this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),this.updateComplete.then(()=>{this._harvest({scheduleMeasure:!1}),this._attachSlotObservers(),this._syncDropdownTabs(),this._finishInitialUpgrade()}),this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._observeLayout(),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"380px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"250px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("paddingInline")||e.has("paddingInlineExpanded"))&&this._applyPaddingInline(),(e.has("banner")||e.has("bannerLabel"))&&this._syncLandmarkAttributes(),(e.has("utilityItems")||e.has("_collapsed")||e.has("_tabsCollapsed")||e.has("_desktop")||e.has("_mobileSearchOpen")||e.has("tabs")||e.has("logoText")||e.has("logotypeText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("alwaysShowMenuButton")||e.has("showSearch")||e.has("layoutPending")||e.has("searchMax")||e.has("searchMin")||e.has("paddingInline")||e.has("paddingInlineExpanded")||e.has("size"))&&this.updateComplete.then(()=>{this._observeLayout(),this._scheduleMeasure()}),(e.has("showDrawer")||e.has("deferDrawer"))&&this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),e.has("showSearch")&&!this.showSearch&&this._setMobileSearchOpen(!1),e.has("layoutPending")&&!this.layoutPending&&this.requestLayout(),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._observedLayout=[],this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],this.renderRoot.removeEventListener("focusin",this._onLocalFocusIn),window.removeEventListener("keydown",this._onGlobalFocusRingKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalFocusRingPointerDown,!0),window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t){if(/^\d+$/.test(t)){const a=Math.max(0,Math.min(14,parseInt(t,10)));return`var(--spacing-${a}, ${I[a]}px)`}return t}}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,a=this._mapSpacingToken(this.spacingBottom)??e;t?this.style.setProperty("--scb-header-spacing-block-start",t):this.style.removeProperty("--scb-header-spacing-block-start"),a?this.style.setProperty("--scb-header-spacing-block-end",a):this.style.removeProperty("--scb-header-spacing-block-end")}_applyPaddingInline(){const e=this._mapSpacingToken(this.paddingInline),t=this._mapSpacingToken(this.paddingInlineExpanded)??e;e?this.style.setProperty("--scb-header-padding-inline",e):this.style.removeProperty("--scb-header-padding-inline"),t?this.style.setProperty("--scb-header-padding-inline-expanded",t):this.style.removeProperty("--scb-header-padding-inline-expanded")}_syncLandmarkAttributes(){const e=this.renderRoot.querySelector(".header-landmark");if(!e)return;if(!this.banner){e.removeAttribute("role"),e.removeAttribute("aria-label");return}e.setAttribute("role","banner");const t=(this.bannerLabel??"").trim();t?e.setAttribute("aria-label",t):e.removeAttribute("aria-label")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),t=(this.logoHeight??"").trim(),a=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),t?this.style.setProperty("--scb-header-logo-img-h",t):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),a?this.style.setProperty("--scb-header-logo-img-aspect-ratio",a):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0)}_ensureFocusRingReady(){customElements.get("md-focus-ring")||(this._focusRingImportPromise??(this._focusRingImportPromise=S(()=>import("../shared/lazy-focus-ring.js"),__vite__mapDeps([0,1]),import.meta.url)),this._focusRingImportPromise.then(({ensureFocusRingReady:e})=>{e()}))}async _ensureDrawerReady(){this._drawerReady||(this._drawerImportPromise??(this._drawerImportPromise=Promise.all([S(()=>import("../scb-drawer/scb-drawer.js"),__vite__mapDeps([2,3,4,5,6,7,8,9]),import.meta.url),S(()=>import("../scb-menu/scb-menu.js"),__vite__mapDeps([10,3,4,5,8,9,7,11,1,12,13,14]),import.meta.url),S(()=>import("../scb-search/scb-search.js"),__vite__mapDeps([15,3,4,16,17,18,19,1,0,20,21,5,6]),import.meta.url),S(()=>import("../../vendor/scb-header-drawer.internal.js").then(e=>{this._drawerRenderer=e}),__vite__mapDeps([22,3,4]),import.meta.url),this._ensureDrawerSlotComponentsReady()]).then(()=>{})),await this._drawerImportPromise,this._drawerReady=!0,this._syncDrawerCloseNodes())}_drawerSlotContains(e){return[...this.querySelectorAll('[slot="drawer-menu"], [slot="drawer-close"]')].some(t=>t.matches(e)||!!t.querySelector(e))}async _ensureDrawerSlotComponentsReady(){this.querySelector('[slot="drawer-menu"], [slot="drawer-close"]')&&await Promise.all([this._drawerSlotContains("scb-button")?S(()=>import("../scb-button/scb-button.js"),__vite__mapDeps([23,3,4,1,21,5,8,9]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-icon-button")?S(()=>import("../scb-icon-button/scb-icon-button.js"),__vite__mapDeps([24,3,4,1,21,5,8,9]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-skeleton")?S(()=>import("../scb-skeleton/scb-skeleton.js"),__vite__mapDeps([25,3,4,5]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-grid")?S(()=>import("../scb-grid/scb-grid.js"),__vite__mapDeps([26,3,4,5,8,9,27,28]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-grid-item")?S(()=>import("../scb-grid/scb-grid-item.js"),__vite__mapDeps([27,3,4,5,8,9]),import.meta.url):Promise.resolve()])}async _ensureDropdownReady(){customElements.get("scb-dropdown")||(this._dropdownImportPromise??(this._dropdownImportPromise=S(()=>import("../scb-dropdown/scb-dropdown.js").then(()=>{}),__vite__mapDeps([29,3,4,16,17,0,1,21,5,12,23,8,9,6,30,31,18,19,7,32]),import.meta.url)),await this._dropdownImportPromise)}_syncMenuBtnAria(){this.renderRoot.querySelectorAll(".menu-trigger").forEach(e=>{e.setAttribute("aria-expanded",String(this._menuExpanded))})}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const t=this.querySelector(`[slot="${e}"]`);return t?t.tagName.toLowerCase()==="scb-dropdown"?t:t.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,t)=>{if(e.kind!=="dropdown")return;const a=this._getDropdownForSlot(e.slotName);if(!a)return;const r=String(t);a.getAttribute("data-index")!==r&&a.setAttribute("data-index",r),a.hasAttribute("as-tab")||a.setAttribute("as-tab","");const s=this.size,o=a;o?.size!==s&&(o.size=s),t===this.activeTab?a.getAttribute("aria-current")!=="page"&&a.setAttribute("aria-current","page"):a.hasAttribute("aria-current")&&a.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const t=e.composedPath?e.composedPath():[];for(const a of t){if(!(a instanceof HTMLElement))continue;const r=a.getAttribute("data-index");if(r==null)continue;const s=Number(r);if(Number.isFinite(s))return s}return null}_focusTabAtIndex(e){const t=this._getNavItems()[e];if(t){if(t.kind==="dropdown"){this._getDropdownForSlot(t.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_syncFlags(e,t){this.toggleAttribute("data-no-utility",e),this.toggleAttribute("data-no-search",t)}_emitSearchInput(e){this.searchText=e,this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))}_emitSearchChange(e,t){this.searchText=e,this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:t},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:t},bubbles:!0,composed:!0}))}_renderMenuButton(e="",t=!1){const a=e?`menu-trigger ${e}`:"menu-trigger",r=(this.menuButtonLabel??"").trim(),s=(this.menuOpenLabel??"").trim()||r,o=this._menuExpanded?"true":"false";return t?v`
|
|
55
|
+
`,document.head.appendChild(u);const e=n=>{const g=String(n??"").trim();if(g){if(/^\d+$/.test(g)){const b=Math.max(0,Math.min(14,parseInt(g,10)));return`var(--spacing-${b}, ${I[b]}px)`}return g}},t=n=>{const g=String(n??"").trim();if(!g)return!1;try{const b=JSON.parse(g);return Array.isArray(b)&&b.length>0}catch{return!1}},a=n=>n!=null&&!/^(false|0|off|no)$/i.test(n.trim()),r=n=>{for(const g of Array.from(n.children)){const b=g.tagName.toLowerCase();if(b==="scb-header-tab"||b==="scb-dropdown")return!0}return!1},s=n=>{r(n)||t(n.getAttribute("tabs"))||a(n.getAttribute("reserve-tabs"))||a(n.getAttribute("layout-pending"))?n.setAttribute("data-pre-has-tabs",""):n.removeAttribute("data-pre-has-tabs");const g=e(n.getAttribute("spacing")),b=e(n.getAttribute("spacing-top"))??g,y=e(n.getAttribute("spacing-bottom"))??g,x=e(n.getAttribute("padding-inline")),k=e(n.getAttribute("padding-inline-expanded"))??x;b?n.style.setProperty("--scb-header-spacing-block-start",b):n.style.removeProperty("--scb-header-spacing-block-start"),y?n.style.setProperty("--scb-header-spacing-block-end",y):n.style.removeProperty("--scb-header-spacing-block-end"),x?n.style.setProperty("--scb-header-padding-inline",x):n.style.removeProperty("--scb-header-padding-inline"),k?n.style.setProperty("--scb-header-padding-inline-expanded",k):n.style.removeProperty("--scb-header-padding-inline-expanded");const d=(n.getAttribute("logo-width")??"").trim();d?n.style.setProperty("--scb-header-pre-logo-w",d):n.style.removeProperty("--scb-header-pre-logo-w");const f=(n.getAttribute("logo-height")??"").trim();f?n.style.setProperty("--scb-header-pre-logo-img-h",f):n.style.removeProperty("--scb-header-pre-logo-img-h");const m=(n.getAttribute("search-height")??"").trim();m?n.style.setProperty("--scb-header-pre-control-size",m):n.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(s);const h=new MutationObserver(n=>{for(const g of n){if(g.type==="attributes"){const b=g.target;b instanceof HTMLElement&&b.tagName.toLowerCase()==="scb-header"&&s(b);continue}if(g.type==="childList"){const b=[...Array.from(g.addedNodes),...Array.from(g.removedNodes)];for(const y of b){if(!(y instanceof HTMLElement))continue;if(y.tagName.toLowerCase()==="scb-header"){s(y);continue}const x=y.closest?.("scb-header");x&&s(x)}}}});h.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","padding-inline","padding-inline-expanded","logo-width","logo-height","logo-aspect-ratio","logo-alt","logotype-text","search-height","reserve-tabs","layout-pending"]}),customElements.whenDefined("scb-header").then(()=>{h.disconnect()})};W();var P={fromAttribute:u=>u==null?!0:!/^(false|0|off|no)$/i.test(u),toAttribute:u=>String(!!u)},L={fromAttribute:u=>u==null?!1:!/^(false|0|off|no)$/i.test(u),toAttribute:u=>u?"":null},F={fromAttribute:u=>u==="small"||u==="medium"||u==="large"?u:"medium",toAttribute:u=>{const e=String(u??"");return e==="small"||e==="medium"||e==="large"?e:null}},i=(C=class extends R{constructor(){super(),this.maxWidth="1440px",this.size=B["scb-header"].size,this.logoText="",this.logotypeText="",this.logoAlt="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.layoutPending=!1,this.utilityItems=[],this.searchButtonLabel="Sök",this.searchClearLabel="Rensa sökfält",this.searchCloseLabel="Stäng sök",this.menuButtonLabel="Meny",this.menuOpenLabel="Öppna meny",this.utilityNavigationLabel="Funktionslänkar",this.mainNavigationLabel="Huvudnavigering",this.deferDrawer=!1,this.showDrawer=!0,this.alwaysShowMenuButton=!1,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._drawerReady=!1,this._mobileSearchOpen=!1,this._initialUpgradeComplete=!1,this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._observedLayout=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this.layoutPending||this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{window.innerWidth>=this.BP_SM&&this._mobileSearchOpen&&this._setMobileSearchOpen(!1),this._scheduleMeasure()},this._onMenuSelect=t=>{t.stopPropagation();const a=t.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:a,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:a,bubbles:!0,composed:!0}));const r=a?.item,s=typeof a?.href=="string"?a.href:typeof a?.itemHref=="string"?a.itemHref:typeof a?.item_href=="string"?a.item_href:"",o=r?r.getAttribute("item-href")??r.getAttribute("href")??"":"";String(s||o||"").trim()&&this._closeDrawerNow()},this._onMenuSelectAlias=t=>{t.stopPropagation()},this._collapsed=!1,this._unlockAtWidth=0,this._tabsCollapsed=!1,this._desktop=typeof window<"u"&&window.innerWidth>=T.BP_MD_DEFAULT,this._hideLogoText=!1,this._slotWatchers=[],this._harvestPending=!1,this._harvest=(t={})=>{const a=Array.from(this.children),r=[],s=[],o=[];let h=-1,n=!1;const g=d=>({label:d.getAttribute("label")??"",href:d.getAttribute("href")??void 0,icon:d.getAttribute("icon")??void 0}),b=d=>{d.hasAttribute("role")&&d.removeAttribute("role"),d.hasAttribute("hidden")||d.setAttribute("hidden",""),d.getAttribute("aria-hidden")!=="true"&&d.setAttribute("aria-hidden","true")};for(const d of a){const f=d.tagName.toLowerCase();if(this._isDrawerCloseNode(d)){this._syncDrawerCloseNode(d);continue}if(f==="scb-header-tab"){b(d);const m=d.getAttribute("label")??"",p=d.getAttribute("href"),A=p&&p.trim()!==""?p:void 0;(d.hasAttribute("selected")||d.getAttribute("selected")==="true"||d.getAttribute("active")==="true"||d.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length),r.push({kind:"tab",label:m,href:A});continue}if(f==="scb-badge"){const m=d.querySelector("scb-dropdown");if(m){n=!0;const p=m.getAttribute("label")??"";(m.hasAttribute("selected")||m.getAttribute("selected")==="true"||m.getAttribute("active")==="true"||m.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length);const A=`scb-header-tab-${r.length}`;d.getAttribute("slot")!==A&&d.setAttribute("slot",A),m.hasAttribute("slot")&&m.removeAttribute("slot"),m.hasAttribute("as-tab")||m.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:A,label:p});continue}}if(f==="scb-dropdown"){n=!0;const m=d.getAttribute("label")??"";(d.hasAttribute("selected")||d.getAttribute("selected")==="true"||d.getAttribute("active")==="true"||d.getAttribute("aria-current")==="page")&&h===-1&&(h=r.length);const p=`scb-header-tab-${r.length}`;d.getAttribute("slot")!==p&&d.setAttribute("slot",p),d.hasAttribute("as-tab")||d.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:p,label:m});continue}if(f==="scb-header-utility"){b(d),s.push({label:d.getAttribute("label")??"",href:d.getAttribute("href")??"#",target:d.getAttribute("target")??void 0});continue}if(f==="scb-header-menu-group"){b(d);const m={label:d.getAttribute("label")??"",icon:d.getAttribute("icon")??void 0,children:[]};d.querySelectorAll("scb-header-menu-item").forEach(p=>m.children.push(g(p))),o.push(m);continue}if(f==="scb-header-menu-item"){b(d),o.push(g(d));continue}d.hasAttribute("slot")||b(d)}const y=!this._sameNavItems(this._slotNavItems,r),x=!this._sameUtilityItems(this._slotUtils,s),k=!this._sameMenuNodes(this._slotMenu,o);y&&(this._slotNavItems=r),x&&(this._slotUtils=s),k&&(this._slotMenu=o),n&&this._ensureDropdownReady(),!this.hasAttribute("active-tab")&&h>=0&&this.activeTab!==h&&(this.activeTab=h),(t.scheduleMeasure??!0)&&queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{if(this.layoutPending)return;const t=this._top,a=this._logoGroup;if(!t||!a)return;const r=window.innerWidth;this._desktop=r>=this.BP_MD;const s=t.clientWidth,o=this._overflows(this._util),h=!this._desktop||o;this._collapsed?!h&&s>=this._unlockAtWidth&&this._setCollapsed(!1):h&&(this._unlockAtWidth=s+this._HYST,this._setCollapsed(!0)),this._setTabsCollapsed(this._tabsOverflows());let n=!1;if(this.showSearch&&r>=this.BP_SM&&r<this.BP_MD&&this._searchWrap){const x=getComputedStyle(this._searchWrap),k=Math.max(this._num(x.minWidth,this._tokenPx("--scb-header-search-min",250)),this._tokenPx("--scb-header-search-min",250)),d=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),f=this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;n=a.getBoundingClientRect().width+d+k+d+f+8>s+.5}this._setHideSearch(n);let g=!1;const b=this.renderRoot.querySelector(".actions"),y=Array.from(b?.querySelectorAll(".header-icon-button")??[]).filter(x=>this._visible(x));if(y.length>0&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const x=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),k=b?this._num(getComputedStyle(b).columnGap,0):0,d=y.reduce((m,p)=>m+p.getBoundingClientRect().width,0)+k*Math.max(0,y.length-1);this._hideLogoText&&this.removeAttribute("data-hide-logo-text");const f=a.getBoundingClientRect().width;this._hideLogoText&&this.setAttribute("data-hide-logo-text",""),g=f+x+d+(this._hideLogoText?this._HYST:0)>s+.5}this._setHideLogoText(g)},this._onGlobalFocusRingKeydown=t=>{t.key==="Tab"&&(this.toggleAttribute("data-keyboard-focus",!0),this._ensureFocusRingReady())},this._onGlobalFocusRingPointerDown=()=>{this.removeAttribute("data-keyboard-focus")},this._onLocalFocusIn=t=>{const a=t.composedPath()[0];a instanceof HTMLElement&&a.matches(":focus-visible")&&this._ensureFocusRingReady()},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=async t=>{this.showDrawer&&(this._setMobileSearchOpen(!1),this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})),!this._drawerReady&&(t.stopPropagation(),await this._ensureDrawerReady(),await this.updateComplete,this._openDrawerNow()))},this._onMobileSearchToggle=()=>{const t=!this._mobileSearchOpen;this._setMobileSearchOpen(t),t&&this.updateComplete.then(()=>{this.renderRoot.querySelector(".mobile-search-panel .header-search-input")?.focus?.()})},this._onTabClick=t=>{const a=t.currentTarget;if(!a)return;const r=a.tagName.toLowerCase()==="a";if(r&&(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey))return;const s=a.getAttribute("data-index"),o=s!=null?Number(s):0,h=this._getNavItems()[o];if(h?.kind==="dropdown")return;this.activeTab=o;const n=h?.kind==="tab"?h.href??"":"",g=new CustomEvent("tab-change",{detail:{index:o,href:n},bubbles:!0,composed:!0,cancelable:!0}),b=new CustomEvent("tabchange",{detail:{index:o,href:n},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(g)&&this.dispatchEvent(b))&&r&&t.preventDefault()},this._onDropdownTabActivate=t=>{const a=t.detail?.dataIndex,r=typeof a=="number"?a:typeof a=="string"?Number(a):this._readTabIndexFromEvent(t);if(r==null||!Number.isFinite(r))return;const s=this._getNavItems();r<0||r>=s.length||s[r]?.kind==="dropdown"&&(this.activeTab=r,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=t=>{const a=t.key;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="Home"&&a!=="End")return;const r=this._getNavItems();if(!r.length)return;const s=this._readTabIndexFromEvent(t);if(s==null)return;let o=Math.max(0,Math.min(r.length-1,s));a==="ArrowRight"?o=(o+1)%r.length:a==="ArrowLeft"?o=(o-1+r.length)%r.length:a==="Home"?o=0:a==="End"&&(o=r.length-1),t.preventDefault(),this._focusTabAtIndex(o)},this._onNativeSearchInput=t=>{const a=t.currentTarget;this._emitSearchInput(a?.value??"")},this._onNativeSearchSubmit=t=>{t.preventDefault();const a=t.currentTarget?.querySelector(".header-search-input");this._emitSearchChange(a?.value??"")},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))},this._onNativeSearchClear=t=>{t.preventDefault(),this._onSearchClear(),this.updateComplete.then(()=>{const a=t.currentTarget?.closest("form")?.querySelector(".header-search-input");a&&(a.value=""),a?.focus()})};const e=++H;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}requestLayout(){this.layoutPending||(this.setAttribute("data-layout-settling",""),this.updateComplete.then(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-layout-settling"))}))}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",T.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",T.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(s=>s.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active","role"],t=s=>{const o=new MutationObserver(h=>{this._scheduleHarvest()});this._slotWatchers.push(o),o.observe(s,{attributes:!0,attributeFilter:e})},a=()=>{this._slotWatchers.forEach(o=>o.disconnect()),this._slotWatchers=[];const s=Array.from(this.children);for(const o of s){const h=o.tagName.toLowerCase();if((h==="scb-header-tab"||h==="scb-dropdown"||h==="scb-header-utility"||h==="scb-header-menu-item"||h==="scb-header-menu-group"||h==="scb-badge")&&t(o),h==="scb-badge"){const n=o,g=new MutationObserver(y=>{a(),this._scheduleHarvest()});this._slotWatchers.push(g),g.observe(n,{childList:!0});const b=n.querySelector("scb-dropdown");b&&t(b);continue}if(h==="scb-header-menu-group"){const n=o,g=new MutationObserver(b=>{a(),this._scheduleHarvest()});this._slotWatchers.push(g),g.observe(n,{childList:!0,subtree:!0}),n.querySelectorAll("scb-header-menu-item").forEach(b=>t(b))}}},r=new MutationObserver(s=>{let o=!1;for(const h of s)if(h.type==="childList"){o=!0;break}o&&a(),this._scheduleHarvest()});this._slotMo=r,r.observe(this,{childList:!0}),a()}_sameNavItems(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.kind!==s.kind||r.label!==s.label)return!1;if(r.kind==="tab"&&s.kind==="tab"){if((r.href??"")!==(s.href??""))return!1}else if(r.kind==="dropdown"&&s.kind==="dropdown"&&r.slotName!==s.slotName)return!1}return!0}_sameUtilityItems(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.label!==s.label||r.href!==s.href||(r.target??"")!==(s.target??""))return!1}return!0}_sameMenuNodes(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a+=1){const r=e[a],s=t[a];if(!r||!s||r.label!==s.label||(r.href??"")!==(s.href??"")||(r.icon??"")!==(s.icon??"")||!this._sameMenuNodes(r.children??[],s.children??[]))return!1}return!0}_isDrawerCloseNode(e){const t=e.tagName.toLowerCase(),a=e.getAttribute("slot");if(a==="drawer-close")return!0;if(a||t!=="scb-icon-button")return!1;const r=(e.getAttribute("icon")??"").trim().toLowerCase(),s=(e.getAttribute("aria-label")??"").trim().toLowerCase();return r==="close"||s.includes("stäng")||s.includes("close")}_syncDrawerCloseNode(e){e.getAttribute("slot")!=="drawer-close"&&e.setAttribute("slot","drawer-close"),e.setAttribute("data-drawer-close",this._drawerId),e.setAttribute("aria-controls",this._drawerId),this._drawerReady?(e.removeAttribute("hidden"),e.removeAttribute("aria-hidden")):(e.hasAttribute("hidden")||e.setAttribute("hidden",""),e.getAttribute("aria-hidden")!=="true"&&e.setAttribute("aria-hidden","true"))}_syncDrawerCloseNodes(){for(const e of Array.from(this.children))this._isDrawerCloseNode(e)&&this._syncDrawerCloseNode(e)}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_setMobileSearchOpen(e){this._mobileSearchOpen!==e&&(this._mobileSearchOpen=e,this.toggleAttribute("data-mobile-search-open",e))}_num(e,t){const a=Number.parseFloat(String(e??"").trim());return Number.isFinite(a)?a:t}_tokenPx(e,t){const a=getComputedStyle(this);return this._num(a.getPropertyValue(e),t)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav,t=e?.closest(".tabs-row");if(!e||!t||!this._desktop||!this.showDrawer)return!1;const a=t.querySelector(".menu-trigger--tabs-right"),r=a&&(this.alwaysShowMenuButton||this._collapsed),s=r?a.getBoundingClientRect().width:0,o=r?this._num(getComputedStyle(t).columnGap,0):0,h=t.getBoundingClientRect().width-s-o;return e.getBoundingClientRect().width>h+.5}_setTabsCollapsed(e){if(this._tabsCollapsed===e)return;const t=this._tabsNav;let a=e&&!!t?.contains(this.shadowRoot?.activeElement??null);if(e)for(const r of this._getNavItems()){if(r.kind!=="dropdown")continue;const s=this._getDropdownForSlot(r.slotName);a||(a=s===document.activeElement),s?.removeAttribute("open")}this._tabsCollapsed=e,this.toggleAttribute("data-tabs-collapsed",e),a&&this.updateComplete.then(()=>this._menuBtn?.focus())}_observeLayout(){const e=[this._top,this._tabsNav,this._tabsNav?.closest(".tabs-row"),this._menuBtn].filter(t=>!!t);if(!(e.length===this._observedLayout.length&&e.every((t,a)=>t===this._observedLayout[a]))){this._ro?.disconnect(),this._observedLayout=e;for(const t of e)this._ro?.observe(t,{box:"border-box"})}}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this._onGlobalFocusRingKeydown,!0),window.addEventListener("pointerdown",this._onGlobalFocusRingPointerDown,!0),this._initialUpgradeComplete||this.setAttribute("data-upgrading",""),this._harvest({scheduleMeasure:!1}),this._attachSlotObservers()}_finishInitialUpgrade(){this._initialUpgradeComplete||(this._initialUpgradeComplete=!0,requestAnimationFrame(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-upgrading"))}))}firstUpdated(){this._syncLandmarkAttributes(),this.renderRoot.addEventListener("focusin",this._onLocalFocusIn),this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),this.updateComplete.then(()=>{this._harvest({scheduleMeasure:!1}),this._attachSlotObservers(),this._syncDropdownTabs(),this._finishInitialUpgrade()}),this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._observeLayout(),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"380px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"250px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("paddingInline")||e.has("paddingInlineExpanded"))&&this._applyPaddingInline(),(e.has("banner")||e.has("bannerLabel"))&&this._syncLandmarkAttributes(),(e.has("utilityItems")||e.has("_collapsed")||e.has("_tabsCollapsed")||e.has("_desktop")||e.has("_mobileSearchOpen")||e.has("tabs")||e.has("logoText")||e.has("logotypeText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("alwaysShowMenuButton")||e.has("showSearch")||e.has("layoutPending")||e.has("searchMax")||e.has("searchMin")||e.has("paddingInline")||e.has("paddingInlineExpanded")||e.has("size"))&&this.updateComplete.then(()=>{this._observeLayout(),this._scheduleMeasure()}),(e.has("showDrawer")||e.has("deferDrawer"))&&this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),e.has("showSearch")&&!this.showSearch&&this._setMobileSearchOpen(!1),e.has("layoutPending")&&!this.layoutPending&&this.requestLayout(),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._observedLayout=[],this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],this.renderRoot.removeEventListener("focusin",this._onLocalFocusIn),window.removeEventListener("keydown",this._onGlobalFocusRingKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalFocusRingPointerDown,!0),window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t){if(/^\d+$/.test(t)){const a=Math.max(0,Math.min(14,parseInt(t,10)));return`var(--spacing-${a}, ${I[a]}px)`}return t}}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,a=this._mapSpacingToken(this.spacingBottom)??e;t?this.style.setProperty("--scb-header-spacing-block-start",t):this.style.removeProperty("--scb-header-spacing-block-start"),a?this.style.setProperty("--scb-header-spacing-block-end",a):this.style.removeProperty("--scb-header-spacing-block-end")}_applyPaddingInline(){const e=this._mapSpacingToken(this.paddingInline),t=this._mapSpacingToken(this.paddingInlineExpanded)??e;e?this.style.setProperty("--scb-header-padding-inline",e):this.style.removeProperty("--scb-header-padding-inline"),t?this.style.setProperty("--scb-header-padding-inline-expanded",t):this.style.removeProperty("--scb-header-padding-inline-expanded")}_syncLandmarkAttributes(){const e=this.renderRoot.querySelector(".header-landmark");if(!e)return;if(!this.banner){e.removeAttribute("role"),e.removeAttribute("aria-label");return}e.setAttribute("role","banner");const t=(this.bannerLabel??"").trim();t?e.setAttribute("aria-label",t):e.removeAttribute("aria-label")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),t=(this.logoHeight??"").trim(),a=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),t?this.style.setProperty("--scb-header-logo-img-h",t):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),a?this.style.setProperty("--scb-header-logo-img-aspect-ratio",a):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0)}_ensureFocusRingReady(){customElements.get("md-focus-ring")||(this._focusRingImportPromise??(this._focusRingImportPromise=S(()=>import("../../vendor/lazy-focus-ring.js").then(e=>e.i),__vite__mapDeps([0,1,2]),import.meta.url)),this._focusRingImportPromise.then(({ensureFocusRingReady:e})=>{e()}))}async _ensureDrawerReady(){this._drawerReady||(this._drawerImportPromise??(this._drawerImportPromise=Promise.all([S(()=>import("../scb-drawer/scb-drawer.js"),__vite__mapDeps([3,4,5,6,7,8,9,10]),import.meta.url),S(()=>import("../scb-menu/scb-menu.js"),__vite__mapDeps([11,4,5,6,9,10,8,12,2,13,14,15]),import.meta.url),S(()=>import("../scb-search/scb-search.js"),__vite__mapDeps([16,4,5,17,1,18,19,2,0,20,21,6,7]),import.meta.url),S(()=>import("../../vendor/scb-header-drawer.internal.js").then(e=>{this._drawerRenderer=e}),__vite__mapDeps([22,4,5]),import.meta.url),this._ensureDrawerSlotComponentsReady()]).then(()=>{})),await this._drawerImportPromise,this._drawerReady=!0,this._syncDrawerCloseNodes())}_drawerSlotContains(e){return[...this.querySelectorAll('[slot="drawer-menu"], [slot="drawer-close"]')].some(t=>t.matches(e)||!!t.querySelector(e))}async _ensureDrawerSlotComponentsReady(){this.querySelector('[slot="drawer-menu"], [slot="drawer-close"]')&&await Promise.all([this._drawerSlotContains("scb-button")?S(()=>import("../scb-button/scb-button.js"),__vite__mapDeps([23,4,5,2,21,6,9,10]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-icon-button")?S(()=>import("../scb-icon-button/scb-icon-button.js"),__vite__mapDeps([24,4,5,2,21,6,9,10]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-skeleton")?S(()=>import("../scb-skeleton/scb-skeleton.js"),__vite__mapDeps([25,4,5,6]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-grid")?S(()=>import("../scb-grid/scb-grid.js"),__vite__mapDeps([26,4,5,6,9,10,27,28]),import.meta.url):Promise.resolve(),this._drawerSlotContains("scb-grid-item")?S(()=>import("../scb-grid/scb-grid-item.js"),__vite__mapDeps([27,4,5,6,9,10]),import.meta.url):Promise.resolve()])}async _ensureDropdownReady(){customElements.get("scb-dropdown")||(this._dropdownImportPromise??(this._dropdownImportPromise=S(()=>import("../scb-dropdown/scb-dropdown.js").then(()=>{}),__vite__mapDeps([29,4,5,17,1,0,2,21,6,13,23,9,10,7,30,31,18,19,8,32]),import.meta.url)),await this._dropdownImportPromise)}_syncMenuBtnAria(){this.renderRoot.querySelectorAll(".menu-trigger").forEach(e=>{e.setAttribute("aria-expanded",String(this._menuExpanded))})}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const t=this.querySelector(`[slot="${e}"]`);return t?t.tagName.toLowerCase()==="scb-dropdown"?t:t.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,t)=>{if(e.kind!=="dropdown")return;const a=this._getDropdownForSlot(e.slotName);if(!a)return;const r=String(t);a.getAttribute("data-index")!==r&&a.setAttribute("data-index",r),a.hasAttribute("as-tab")||a.setAttribute("as-tab","");const s=this.size,o=a;o?.size!==s&&(o.size=s),t===this.activeTab?a.getAttribute("aria-current")!=="page"&&a.setAttribute("aria-current","page"):a.hasAttribute("aria-current")&&a.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const t=e.composedPath?e.composedPath():[];for(const a of t){if(!(a instanceof HTMLElement))continue;const r=a.getAttribute("data-index");if(r==null)continue;const s=Number(r);if(Number.isFinite(s))return s}return null}_focusTabAtIndex(e){const t=this._getNavItems()[e];if(t){if(t.kind==="dropdown"){this._getDropdownForSlot(t.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_syncFlags(e,t){this.toggleAttribute("data-no-utility",e),this.toggleAttribute("data-no-search",t)}_emitSearchInput(e){this.searchText=e,this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))}_emitSearchChange(e,t){this.searchText=e,this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:t},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:t},bubbles:!0,composed:!0}))}_renderMenuButton(e="",t=!1){const a=e?`menu-trigger ${e}`:"menu-trigger",r=(this.menuButtonLabel??"").trim(),s=(this.menuOpenLabel??"").trim()||r,o=this._menuExpanded?"true":"false";return t?v`
|
|
56
56
|
<button
|
|
57
57
|
type="button"
|
|
58
58
|
class=${`${a} header-icon-button`}
|