scb-wc 0.1.150 → 0.1.151
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 +22 -41
- package/all.js +5 -0
- package/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/icons.json +3 -1
- package/index.js +95 -90
- package/mvc/components/all.js +5 -0
- package/mvc/components/scb-accordion/scb-accordion-item.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/{vendor → components/scb-chevron}/scb-chevron.js +1 -1
- package/mvc/components/scb-datepicker/scb-datepicker.js +132 -0
- package/mvc/components/scb-dropdown/scb-dropdown.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-list/scb-list-item.js +2 -2
- 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-options-menu/scb-options-menu-item.js +1 -1
- package/mvc/components/scb-progress-stepper/scb-progress-step.js +1 -1
- package/mvc/components/scb-search/scb-search.js +1 -1
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +1 -1
- package/mvc/components/scb-select/scb-select-option.js +2 -2
- package/mvc/components/scb-select/scb-select.js +1 -1
- package/mvc/components/scb-stepper/scb-step.js +1 -1
- package/mvc/components/scb-textfield/scb-textfield.js +28 -159
- package/mvc/components/scb-toc/scb-toc-item.js +1 -1
- package/mvc/components/shared/lazy-focus-ring.js +2 -0
- package/mvc/components/shared/lazy-ripple.js +2 -0
- package/mvc/components/shared/scb-icon-svg.js +11 -0
- package/mvc/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/package.json +2 -2
- package/scb-chevron/scb-chevron.js +1 -0
- package/scb-components/index.d.ts +104 -0
- package/scb-components/scb-chevron/scb-chevron.d.ts +11 -0
- package/scb-components/scb-datepicker/scb-datepicker.d.ts +45 -0
- package/scb-components/shared/lazy-focus-ring.d.ts +4 -0
- package/scb-components/shared/lazy-ripple.d.ts +9 -0
- package/scb-components/shared/scb-icon-svg.d.ts +3 -0
- package/scb-datepicker/scb-datepicker.js +1 -0
- package/scb-wc.bundle.js +906 -906
- package/scb-wc.d.ts +208 -198
- package/shared/scb-icon-svg.js +5 -2
- package/mvc/vendor/lazy-focus-ring.js +0 -2
- package/mvc/vendor/lazy-ripple.js +0 -2
- package/mvc/vendor/scb-icon-svg.js +0 -11
- package/scb-wc-public-entry/index.d.ts +0 -99
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as g,h as y,m as k,p as n,v as h,y as S}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{f as g,h as y,m as k,p as n,v as h,y as S}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{addLazyFocusRingListeners as x}from"../shared/lazy-focus-ring.js";import{t as a}from"../../vendor/decorate.js";import{renderScbIcon as f}from"../shared/scb-icon-svg.js";import"./scb-nav-item.js";(function(){try{var d=typeof globalThis<"u"?globalThis:window;if(!d.__scb_ce_guard_installed__){d.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,i,s){try{customElements.get(e)||t(e,i,s)}catch(l){var o=String(l||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var p,m={fromAttribute(d){return d===null?!1:d.toLowerCase()!=="false"}},r=(p=class extends y{constructor(...t){super(...t),this.__itemsEl=null,this.__resizeObserver=null,this.__resizeRaf=null,this.__canScrollLeft=!1,this.__canScrollRight=!1,this.label="",this.activeHref="",this.activateOnClick=!0,this.scrollShadow=!1,this.leftScrollButtonLabel="Scrolla vänster",this.rightScrollButtonLabel="Scrolla höger",this.sticky=!1,this.stickyTop="0px",this.stickyZIndex=5,this.stickyBackground="",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.__autoAriaLabel=!1,this.__itemIdPrefix=`scb-nav-${Math.random().toString(36).slice(2)}`,this.__itemIdCounter=0,this.__onSlotChange=async()=>{await this.__decorateItems(),this.__applyActiveHref(),this.__scheduleScrollControlUpdate()},this.__scrollLeft=()=>{this.__scrollBy(-this.__getScrollStep())},this.__scrollRight=()=>{this.__scrollBy(this.__getScrollStep())},this.__onWheel=e=>{if(e.ctrlKey)return;const i=this.__itemsEl;if(!i)return;const s=i.scrollWidth-i.clientWidth;if(s<=1)return;const o=this.__normalizeWheelDelta(e);if(o===0)return;const l=Math.max(0,Math.min(s,i.scrollLeft+o));l!==i.scrollLeft&&(e.preventDefault(),i.scrollLeft=l,this.__updateScrollControls())},this.__onItemsScroll=()=>{this.__updateScrollControls()},this.__onClick=e=>{const i=e.composedPath().find(o=>o instanceof HTMLElement&&(o.tagName==="A"||o.tagName==="BUTTON"||o.tagName==="SCB-NAV-ITEM"));if(!i)return;const s=this.__getItemHref(i);this.dispatchEvent(new CustomEvent("scb-nav-select",{bubbles:!0,composed:!0,detail:{item:i,href:s}})),this.dispatchEvent(new CustomEvent("scbnavselect",{bubbles:!0,composed:!0,detail:{item:i,href:s}})),this.activateOnClick&&s&&(this.activeHref=s)}}mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}__applySpacing(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,i=this.mapSpacingToken(this.spacingBottom)??t,s=this.mapSpacingToken(this.spacingLeft),o=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-nav-spacing-block-start",e):this.style.removeProperty("--scb-nav-spacing-block-start"),i?this.style.setProperty("--scb-nav-spacing-block-end",i):this.style.removeProperty("--scb-nav-spacing-block-end"),s?this.style.setProperty("--scb-nav-spacing-inline-start",s):this.style.removeProperty("--scb-nav-spacing-inline-start"),o?this.style.setProperty("--scb-nav-spacing-inline-end",o):this.style.removeProperty("--scb-nav-spacing-inline-end")}__syncStickyStyles(){if(!this.sticky){this.style.removeProperty("--_scb-nav-sticky-top"),this.style.removeProperty("--_scb-nav-sticky-z-index"),this.style.removeProperty("--_scb-nav-sticky-background");return}const t=(this.stickyTop||"").trim()||"0px";this.style.setProperty("--_scb-nav-sticky-top",t);const e=Number.isFinite(this.stickyZIndex)?this.stickyZIndex:5;this.style.setProperty("--_scb-nav-sticky-z-index",String(e));const i=(this.stickyBackground||"").trim();if(!i){this.style.removeProperty("--_scb-nav-sticky-background");return}const s=i.startsWith("--")?`var(${i})`:i;this.style.setProperty("--_scb-nav-sticky-background",s)}connectedCallback(){super.connectedCallback(),this.__removeLazyFocusRingListeners=x(this,this.renderRoot),this.hasAttribute("role")||this.setAttribute("role","navigation"),this.__syncStickyStyles(),this.__syncAriaLabel()}disconnectedCallback(){this.__removeLazyFocusRingListeners?.(),this.__removeLazyFocusRingListeners=void 0,this.__itemsEl?.removeEventListener("scroll",this.__onItemsScroll),this.__itemsEl=null,this.__resizeObserver?.disconnect(),this.__resizeObserver=null,this.__resizeRaf!==null&&(cancelAnimationFrame(this.__resizeRaf),this.__resizeRaf=null),super.disconnectedCallback()}async firstUpdated(){this.__itemsEl=this.renderRoot.querySelector(".scb-nav__items"),this.__itemsEl&&this.__itemsEl.addEventListener("scroll",this.__onItemsScroll,{passive:!0}),this.__resizeObserver=new ResizeObserver(()=>{this.__scheduleScrollControlUpdate()}),this.__resizeObserver.observe(this),this.__itemsEl&&this.__resizeObserver.observe(this.__itemsEl),await this.__decorateItems(),this.__applyActiveHref(),this.__applySpacing(),this.__scheduleScrollControlUpdate(),document.fonts?.ready?.then(()=>{this.isConnected&&this.__scheduleScrollControlUpdate()})}updated(t){t.has("label")&&this.__syncAriaLabel(),(t.has("sticky")||t.has("stickyTop")||t.has("stickyZIndex")||t.has("stickyBackground"))&&this.__syncStickyStyles(),t.has("activeHref")&&this.__applyActiveHref(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this.__applySpacing()}__syncAriaLabel(){if(this.hasAttribute("aria-label")){this.__autoAriaLabel=!1;return}const t=(this.label||"").trim();if(!t){this.__autoAriaLabel&&(this.removeAttribute("aria-label"),this.__autoAriaLabel=!1);return}this.setAttribute("aria-label",t),this.__autoAriaLabel=!0}async __decorateItems(){const t=this.__getSlottedItems();if(t.some(e=>e.tagName==="A"||e.tagName==="BUTTON"||e.tagName==="SCB-NAV-ITEM"))for(const e of t){const i=e instanceof HTMLAnchorElement,s=e instanceof HTMLButtonElement,o=e.tagName==="SCB-NAV-ITEM";if(!i&&!s&&!o||(s&&!e.hasAttribute("type")&&e.setAttribute("type","button"),e.getAttribute("data-scb-nav-decorated")==="true"))continue;e.id||(this.__itemIdCounter+=1,e.id=`${this.__itemIdPrefix}-${this.__itemIdCounter}`);const l=_=>{const v=e.querySelector(_);if(v instanceof HTMLElement)return v;const u=document.createElement(_);return e.appendChild(u),u},b=l("md-ripple");b&&b.style.setProperty("--md-ripple-focus-opacity","0");const c=l("md-focus-ring");c&&(c.setAttribute("inward",""),c.setAttribute("for",e.id),c.style.position="absolute",c.style.inset="0",c.style.pointerEvents="none",c.style.borderRadius="24px"),e.setAttribute("data-scb-nav-decorated","true")}}__getSlottedItems(){const t=this.renderRoot.querySelector("slot");return t?t.assignedElements({flatten:!0}).filter(e=>e instanceof HTMLElement):[]}__getItemHref(t){return t instanceof HTMLAnchorElement?(t.getAttribute("href")||"").trim():t.tagName==="SCB-NAV-ITEM"?(t.getAttribute("href")||t.getAttribute("data-href")||t.href||t.dataHref||"").trim():(t.getAttribute("data-href")||"").trim()}__applyActiveHref(){const t=(this.activeHref||"").trim(),e=this.__getSlottedItems();for(const i of e){const s=i instanceof HTMLAnchorElement,o=i instanceof HTMLButtonElement,l=i.tagName==="SCB-NAV-ITEM";if(!s&&!o&&!l)continue;o&&!i.hasAttribute("type")&&i.setAttribute("type","button");const b=this.__getItemHref(i);t&&b===t?(i.setAttribute("aria-current","location"),i.setAttribute("data-scb-nav-managed","true"),i.setAttribute("data-active","true")):(i.getAttribute("data-scb-nav-managed")==="true"&&(i.removeAttribute("aria-current"),i.removeAttribute("data-scb-nav-managed")),i.removeAttribute("data-active"))}}__getScrollStep(){const t=this.__itemsEl;return t?Math.max(Math.round(t.clientWidth*.8),120):200}__scrollBy(t){this.__itemsEl?.scrollBy({left:t,behavior:"smooth"})}__normalizeWheelDelta(t){const e=this.__itemsEl,i=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY;return e?t.deltaMode===WheelEvent.DOM_DELTA_LINE?i*16:t.deltaMode===WheelEvent.DOM_DELTA_PAGE?i*e.clientWidth:i:i}__scheduleScrollControlUpdate(){this.__resizeRaf===null&&(this.__resizeRaf=requestAnimationFrame(()=>{this.__resizeRaf=null,this.__updateScrollControls()}))}__updateScrollControls(){const t=this.__itemsEl;if(!t){this.__canScrollLeft=!1,this.__canScrollRight=!1,this.toggleAttribute("data-scroll-left",!1),this.toggleAttribute("data-scroll-right",!1);return}const e=t.scrollLeft>0,i=t.scrollLeft+t.clientWidth<t.scrollWidth-1;this.__canScrollLeft=e,this.__canScrollRight=i,this.toggleAttribute("data-scroll-left",e),this.toggleAttribute("data-scroll-right",i)}render(){return h`
|
|
2
2
|
<div class="scb-nav">
|
|
3
3
|
${this.__canScrollLeft?h`
|
|
4
4
|
<button
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as d,m as p,p as a,v as u,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{h as d,m as p,p as a,v as u,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{ensureFocusRingOnFocusVisible as v}from"../shared/lazy-focus-ring.js";import{t as r}from"../../vendor/decorate.js";import"../scb-divider/scb-divider.js";(function(){try{var c=typeof globalThis<"u"?globalThis:window;if(!c.__scb_ce_guard_installed__){c.__scb_ce_guard_installed__=!0;var i=customElements.define.bind(customElements);customElements.define=function(t,e,s){try{customElements.get(t)||i(t,e,s)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var b,o=(b=class extends d{constructor(...i){super(...i),this.label="",this.hasSubMenu=!1,this.openLeft=!1,this.divider=!1,this.leadingIcon="",this.trailingIcon="",this.itemHref="",this.href="",this._observedSubMenu=null,this._syncSubMenuFlags=()=>{const t=this.nextElementSibling,e=!!(t&&t.tagName==="SCB-OPTIONS-SUB-MENU"),s=!!(e&&t.hasAttribute("open-left"));e!==this.hasSubMenu&&(this.hasSubMenu=e),s!==this.openLeft&&(this.openLeft=s);const n=e?t:null;n!==this._observedSubMenu&&(this._subMenuAttrObserver?.disconnect(),this._subMenuAttrObserver=void 0,this._observedSubMenu=n,n&&(this._subMenuAttrObserver=new MutationObserver(()=>this._syncSubMenuFlags()),this._subMenuAttrObserver.observe(n,{attributes:!0,attributeFilter:["open-left"]})))},this.handleClick=t=>{this._effectiveHref?this._navigateToHref(t):this._toggleSubMenu()},this._onBlur=t=>{const e=this.closest("scb-options-sub-menu");if(e&&e.open){const s=t.relatedTarget;(!s||!e.contains(s))&&(e.dispatchEvent(new CustomEvent("hide-submenu",{bubbles:!0,composed:!0})),e.dispatchEvent(new CustomEvent("hidesubmenu",{bubbles:!0,composed:!0})))}},this._onFocus=()=>{const t=this.nextElementSibling;this.classList.contains("open-submenu")&&(t&&t.tagName==="SCB-OPTIONS-SUB-MENU"&&t.hasAttribute("open")||this.classList.remove("open-submenu"))},this._onKeyDown=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.handleClick(t);return}if(t.key==="ArrowDown"){t.preventDefault();let e=this.nextElementSibling;for(;e&&e.tagName!=="SCB-OPTIONS-MENU-ITEM";)e=e.nextElementSibling;e&&e.shadowRoot?.querySelector("li")?.focus();return}if(t.key==="ArrowUp"){t.preventDefault();let e=this.previousElementSibling;for(;e&&e.tagName!=="SCB-OPTIONS-MENU-ITEM";)e=e.previousElementSibling;e&&e.shadowRoot?.querySelector("li")?.focus();return}if(t.key==="ArrowRight"){t.preventDefault();const e=this.nextElementSibling;e&&e.tagName==="SCB-OPTIONS-SUB-MENU"&&(e.hasAttribute("open")||(this._toggleSubMenu(),e.dispatchEvent(new CustomEvent("show-submenu",{bubbles:!0,composed:!0})),e.dispatchEvent(new CustomEvent("showsubmenu",{bubbles:!0,composed:!0}))),setTimeout(()=>{const s=e.querySelector("scb-options-menu-item");s&&s.shadowRoot?.querySelector("li")?.focus()},0));return}if(t.key==="ArrowLeft"){t.preventDefault();const e=this.nextElementSibling;if(e&&e.tagName==="SCB-OPTIONS-SUB-MENU"&&e.hasAttribute("open")){this._toggleSubMenu(),e.dispatchEvent(new CustomEvent("hide-submenu",{bubbles:!0,composed:!0})),e.dispatchEvent(new CustomEvent("hidesubmenu",{bubbles:!0,composed:!0}));return}const s=this.closest("scb-options-sub-menu");if(s){const n=s.previousElementSibling;n&&n.tagName==="SCB-OPTIONS-MENU-ITEM"&&n.shadowRoot?.querySelector("li")?.focus()}return}}}get _effectiveHref(){return this.itemHref||this.href}connectedCallback(){super.connectedCallback(),this._syncSubMenuFlags(),this._subMenuChildObserver??(this._subMenuChildObserver=new MutationObserver(()=>this._syncSubMenuFlags())),this._subMenuChildObserver.disconnect();const i=this.parentElement;i&&this._subMenuChildObserver.observe(i,{childList:!0})}disconnectedCallback(){this._subMenuChildObserver?.disconnect(),this._subMenuAttrObserver?.disconnect(),this._subMenuChildObserver=void 0,this._subMenuAttrObserver=void 0,this._observedSubMenu=null,super.disconnectedCallback()}render(){return u`
|
|
2
2
|
${this.divider?u`<scb-divider></scb-divider>`:""}
|
|
3
3
|
<li @click=${this.handleClick} @keydown=${this._onKeyDown} @blur=${this._onBlur} @focus=${this._onFocus} @focusin=${v} role="menuitem" tabindex="0">
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as u,g as c,h as f,m as y,p as i,v as a,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{f as u,g as c,h as f,m as y,p as i,v as a,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{ensureFocusRingOnFocusVisible as h}from"../shared/lazy-focus-ring.js";import{t as o}from"../../vendor/decorate.js";(function(){try{var l=typeof globalThis<"u"?globalThis:window;if(!l.__scb_ce_guard_installed__){l.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(s,r,b){try{customElements.get(s)||t(s,r,b)}catch(d){var p=String(d||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var n,e=(n=class extends f{constructor(...t){super(...t),this.width="100%",this.active=!1,this.current=!1,this.disabled=!1,this.href="",this.label="",this.position="top",this._stepId=`scb-step-${Math.random().toString(36).slice(2)}`}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","listitem")}updated(t){super.updated?.(t),this.style.setProperty("--progress-step-width",this.width)}_onClick(){if(this.disabled)return;const t={width:this.width,label:this.label,active:this.active,disabled:this.disabled,href:this.href||void 0};this.dispatchEvent(new CustomEvent("step-click",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("stepclick",{detail:t,bubbles:!0,composed:!0}))}_onKeydown(t){this.disabled||this.href||t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this._onClick())}firstUpdated(t){super.firstUpdated?.(t),this._setupTooltipPositioning()}_setupTooltipPositioning(){new MutationObserver(()=>this._adjustTooltipPosition()).observe(this,{attributes:!0,childList:!0,subtree:!0}),window.addEventListener("resize",()=>this._adjustTooltipPosition())}_adjustTooltipPosition(){const t=this.renderRoot.querySelector(".tooltip");if(!t)return;t.style.left="50%",t.style.right="",t.style.transform="translateX(-50%)",t.classList.remove("tooltip-left","tooltip-right");const s=t.getBoundingClientRect(),r=8;s.right>window.innerWidth-r&&(t.style.left="auto",t.style.right=`${r}px`,t.style.transform="none",t.classList.add("tooltip-right")),s.left<r&&(t.style.left=`${r}px`,t.style.right="auto",t.style.transform="none",t.classList.add("tooltip-left"))}render(){const t=!!this.href&&!this.disabled,s=this.label?.trim()||"Steg";return a`
|
|
2
2
|
${t?a`
|
|
3
3
|
<a
|
|
4
4
|
id=${this._stepId}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../scb-list/scb-list.js","../../vendor/decorate.js","../../vendor/vendor.js","../../vendor/vendor-lit.js","../scb-list/scb-list-item.js","../../vendor/preload-helper.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as x,g as h,h as w,m as S,p as o,v as c,y as z}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{t as k}from"../../vendor/preload-helper.js";import{
|
|
2
|
+
import{f as x,g as h,h as w,m as S,p as o,v as c,y as z}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{t as k}from"../../vendor/preload-helper.js";import{ensureFocusRingReady as A}from"../shared/lazy-focus-ring.js";import{t as n}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 t=customElements.define.bind(customElements);customElements.define=function(e,s,r){try{customElements.get(e)||t(e,s,r)}catch(l){var i=String(l||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var p,V=0,a=(p=class extends w{async _ensureListDepsLoaded(){this._listDepsLoaded||(this._listDepsPromise??(this._listDepsPromise=k(()=>import("../scb-list/scb-list.js").then(()=>{this._listDepsLoaded=!0}),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)),await this._listDepsPromise)}_ensureListDepsWhenNeeded(){const t=(this.value??"").trim().length>0;!this._inputFocused||!t||!this._hasSuggestions||this._ensureListDepsLoaded().then(()=>this.requestUpdate())}constructor(){super(),this._internals=null,this.supportingText="",this.inputLabel="",this.clearLabel="Rensa sökfält",this.suggestionsLabel="Sökförslag",this.errorText="",this.value="",this.name="",this.disabled=!1,this.required=!1,this.error=!1,this.autocomplete=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.size="medium",this.fullScreen=!1,this._inputFocused=!1,this._visibleSuggestions=0,this._listDepsLoaded=!1,this._activeIndex=-1,this._listboxId=`scb-search-listbox-${++V}`,this._kbMode=!1,this._valueOnFocus="",this._lastChangeValue="",this._kbShouldShowRing=!1,this._onGlobalKeydown=t=>{t.key==="Tab"&&(A(),this._kbShouldShowRing=!0,this._inputFocused&&this._updateInputRingVisibility())},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&this._updateInputRingVisibility()},this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._listScrollHandler=()=>{const t=this._getActiveItem();this._kbMode&&t&&this._positionOptionRing(t)},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),this._syncDensityForSize(),this._onWindowResize=this._onWindowResize.bind(this),window.addEventListener("resize",this._onWindowResize,{passive:!0}),window.addEventListener("keydown",this._onGlobalKeydown,!0),window.addEventListener("pointerdown",this._onGlobalPointerDown,!0),this._initialValue=this.value??"",this._lastChangeValue=this.value??"",this._form=this.closest("form"),this._form&&(this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const t=this._inputEl();t&&(t.value=this._initialValue),this._lastChangeValue=this._initialValue,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this.error=!1,this._hasValidationBeenReported=!1,this._updateComboboxA11y(),this._syncValidity()},this._form.addEventListener("reset",this._formResetHandler,!0)),this._syncFormValue(),this._syncValidity()}disconnectedCallback(){const t=this._inputEl();t&&this._boundNativeKeydown&&t.removeEventListener("keydown",this._boundNativeKeydown,!0),this._detachListScrollListener(),window.removeEventListener("resize",this._onWindowResize),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),super.disconnectedCallback()}firstUpdated(){this._ensureListboxA11y(),this._updateComboboxA11y();const t=this._inputEl();t&&(this._boundNativeKeydown=e=>this._handleKey(e),t.addEventListener("keydown",this._boundNativeKeydown,!0),t.disabled=this.disabled),this.applySpacing()}updated(t){if(super.updated(t),t.has("size")&&this._syncDensityForSize(),this._ensureListboxA11y(),this._updateComboboxA11y(),this._attachListScrollListener(),(t.has("value")||t.has("disabled"))&&this._syncFormValue(),(t.has("value")||t.has("disabled")||t.has("required")||t.has("errorText"))&&this._syncValidity(),t.has("disabled")){this.toggleAttribute("aria-disabled",this.disabled);const e=this._inputEl();e&&(e.disabled=this.disabled)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this.applySpacing()}render(){const t=(this.value??"").trim().length>0,e=this._inputFocused&&t&&this._hasSuggestions&&this._listDepsLoaded,s=this.error?this._validationMessage||this.errorText||"Ogiltig sökning.":"",r=s?"search-supporting-text":void 0,i=this.inputLabel||this.supportingText||"Sök";return c`
|
|
3
3
|
<div class="ripple-wrapper">
|
|
4
4
|
<md-icon class="leading">${t?"arrow_back":"search"}</md-icon>
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as m,m as p,p as a,v as s,y as b}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{h as m,m as p,p as a,v as s,y as b}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{ensureFocusRingOnFocusVisible as h}from"../shared/lazy-focus-ring.js";import{t as o}from"../../vendor/decorate.js";(function(){try{var l=typeof globalThis<"u"?globalThis:window;if(!l.__scb_ce_guard_installed__){l.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,c){try{customElements.get(t)||e(t,i,c)}catch(d){var n=String(d||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var u,r=(u=class extends m{constructor(...e){super(...e),this.label="",this.value="",this.selected=!1,this.icon="",this.href="",this.disabled=!1,this.onHostKeydown=t=>{if(!this.href||this.isEffectivelyDisabled||t.code!=="Space"&&t.code!=="Enter"&&t.code!=="NumpadEnter")return;const i=this.shadowRoot?.querySelector("a[href]");i&&(t.preventDefault(),t.stopPropagation(),i.click())}}get isEffectivelyDisabled(){const e=this.parentElement?.hasAttribute?.("disabled");return this.disabled||!!e}get hasDefaultSlotContent(){return Array.from(this.childNodes).some(e=>e.nodeType===1?!0:e.nodeType===3?(e.textContent??"").trim()!=="":!1)}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",h)}render(){const e=this.isEffectivelyDisabled,t=!!this.icon,i=!!this.label||this.hasDefaultSlotContent,c=this.label?s`${this.label}`:s`<slot></slot>`,n=`segmented-item${t||this.selected?" has-icon":""}${i?"":" no-label"}`,d=s`
|
|
2
2
|
<md-ripple ?disabled="${e}"></md-ripple>
|
|
3
3
|
${this.selected?t&&i?s`<md-icon>check</md-icon>`:t?s`<md-icon>check</md-icon><md-icon>${this.icon}</md-icon>`:s`<md-icon>check</md-icon>`:t?s`<md-icon>${this.icon}</md-icon>`:""}
|
|
4
4
|
${i?s`<span>${c}</span>`:""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as m,m as b,p as i,v as o,y as u}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{h as m,m as b,p as i,v as o,y as u}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{ensureFocusRingOnFocusVisible as d}from"../shared/lazy-focus-ring.js";import{t}from"../../vendor/decorate.js";(function(){try{var s=typeof globalThis<"u"?globalThis:window;if(!s.__scb_ce_guard_installed__){s.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(a,h,p){try{customElements.get(a)||r(a,h,p)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var c,e=(c=class extends m{constructor(...r){super(...r),this.value="",this.disabled=!1,this.showCheckbox=!1,this.checked=!1,this.showRadio=!1,this.label="",this.noHighlightSelected=!1}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",d)}updated(){this.setAttribute("role","option"),this.setAttribute("aria-selected",this.checked?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}disconnectedCallback(){this.removeEventListener("focusin",d),super.disconnectedCallback()}render(){return o`
|
|
2
2
|
<div class="item ${this.checked?"checked":""}">
|
|
3
3
|
<md-ripple></md-ripple>
|
|
4
4
|
${this.showCheckbox?o`<md-icon class="${this.checked?"checkbox-checked":""}" aria-hidden="true">${this.checked?"check_box":"check_box_outline_blank"}</md-icon>`:null}
|
|
@@ -6,4 +6,4 @@ import{h as m,m as b,p as i,v as o,y as u}from"../../vendor/vendor.js";import"..
|
|
|
6
6
|
<div class="label">${this.label?this.label:o`<slot></slot>`}</div>
|
|
7
7
|
<md-focus-ring inward></md-focus-ring>
|
|
8
8
|
</div>
|
|
9
|
-
`}},
|
|
9
|
+
`}},c.styles=u`:host{display:block;outline:0}:host([hidden]){display:none}:host([disabled]){pointer-events:none;opacity:.38}:host(:focus-visible) .item{outline:2px solid var(--md-sys-color-primary);outline-offset:-2px}:host([data-focused]) .item{background-color:var(--md-sys-color-surface-container)}.item{display:flex;align-items:center;padding:var(--scb-select-option-padding-y, var(--spacing-3)) var(--scb-select-option-padding-x, var(--spacing-5));gap:var(--scb-select-option-gap, var(--spacing-4));min-height:var(--scb-select-option-min-height, var(--scb-control-size-medium, 40px));position:relative;color:var(--md-sys-color-on-surface);font-family:var(--scb-select-option-font-family, var(--scb-form-control-option-font, var(--brand-font, Inter, Arial, sans-serif)));font-size:var(--scb-select-option-font-size, var(--scb-form-control-option-size, var(--scb-typography-body-medium-size, var(--md-sys-typescale-body-medium-size))));line-height:var(--scb-select-option-line-height, var(--scb-form-control-option-line-height, var(--scb-typography-body-medium-line-height, var(--md-sys-typescale-body-medium-line-height))));font-weight:var(--scb-select-option-font-weight, var(--scb-form-control-option-font-weight, var(--scb-typography-body-medium-weight, var(--md-sys-typescale-body-medium-weight))));letter-spacing:var(--scb-select-option-letter-spacing, var(--scb-form-control-option-letter-spacing, var(--scb-typography-body-medium-tracking, var(--md-sys-typescale-body-medium-tracking))))}.label{min-width:0;flex:1 1 auto}.label ::slotted(*){color:inherit!important;font-family:inherit!important;font-size:inherit!important;line-height:inherit!important;font-weight:inherit!important;letter-spacing:inherit!important;margin-block:0!important;margin-inline:0!important}md-icon{font-size:var(--scb-select-option-icon-size, var(--icon-size-medium, 24px));line-height:1;flex:0 0 auto}md-focus-ring{border-radius:var(--md-sys-shape-corner-small)}.item.checked{background-color:var(--md-sys-color-secondary-container)}:host([no-highlight-selected]) .item.checked{background-color:transparent}md-icon.radio-checked{color:var(--md-sys-color-primary)}`,c);t([i({type:String})],e.prototype,"value",void 0);t([i({type:Boolean,reflect:!0})],e.prototype,"disabled",void 0);t([i({type:Boolean})],e.prototype,"showCheckbox",void 0);t([i({type:Boolean})],e.prototype,"checked",void 0);t([i({type:Boolean})],e.prototype,"showRadio",void 0);t([i({type:String})],e.prototype,"label",void 0);t([i({type:Boolean,attribute:"no-highlight-selected",reflect:!0})],e.prototype,"noHighlightSelected",void 0);e=t([b("scb-select-option")],e);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as d,f as x,h as V,m as O,p as a,v as u,y as I}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 r}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-tooltip/scb-tooltip.js";(function(){try{var b=typeof globalThis<"u"?globalThis:window;if(!b.__scb_ce_guard_installed__){b.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,i){try{customElements.get(t)||e(t,s,i)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var g,o=(g=class extends V{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.required=!1,this.error=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.errorText="",this.helpText="",this.helpLabel="Visa hjälptext",this.withRadiobuttons=!1,this.noHighlightSelected=!1,this.size="medium",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._initialValues=[],this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._selectId=`scb-select-${Math.random().toString(36).slice(2,11)}`,this._placementFrame=0,this._optionsPlacement="below",this._activeDescendant="",this._onDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||(this._setOpen(!1),requestAnimationFrame(()=>{this.open||this._focusTrigger()})))},this._scheduleOptionsPlacement=()=>{!this.open||!this.isConnected||(this._placementFrame&&cancelAnimationFrame(this._placementFrame),this._placementFrame=requestAnimationFrame(()=>{this._placementFrame=0,this._updateOptionsPlacement()}))},this._onSlotClick=e=>{const t=this._getOptions(),s=e.composedPath(),i=t.find(n=>s.includes(n));i&&(this._selectOption(i),e.stopPropagation())},this._onKeyDown=e=>{if(e.key==="Escape"&&this.open){e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._focusTrigger();return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation();const t=e.key==="ArrowDown"?1:-1;if(!this.open){this._setOpen(!0),this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this.focusedIndex>=0&&e.key==="ArrowUp"&&this._moveFocusedIndex(-1)});return}this._moveFocusedIndex(t);return}if((e.key==="Home"||e.key==="End")&&this.open){e.preventDefault(),e.stopPropagation();const t=this._getOptions();let s=t.findIndex(i=>!i.disabled);if(e.key==="End"){for(let i=t.length-1;i>=0;i-=1)if(!t[i]?.disabled){s=i;break}}this._setFocusedIndex(s);return}if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),this.open){const t=this._getFocusedOption();t&&this._selectOption(t);return}this._setOpen(!0)}},this._onOptionKeyDown=e=>{if(e.key==="Escape"&&this.open){e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._focusTrigger();return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=this._getOptions(),s=e.composedPath(),i=t.find(n=>s.includes(n));i&&this._selectOption(i)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),document.addEventListener("scroll",this._scheduleOptionsPlacement,!0),window.addEventListener("resize",this._scheduleOptionsPlacement),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize(),this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this.error=!1,this._hasValidationBeenReported=!1,this._syncFormValue(),this._syncValidity(),this.requestUpdate()},this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0))}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),document.removeEventListener("scroll",this._scheduleOptionsPlacement,!0),window.removeEventListener("resize",this._scheduleOptionsPlacement),this._placementFrame&&(cancelAnimationFrame(this._placementFrame),this._placementFrame=0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_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,s=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),n=this._mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-select-spacing-block-start",t):this.style.removeProperty("--scb-select-spacing-block-start"),s?this.style.setProperty("--scb-select-spacing-block-end",s):this.style.removeProperty("--scb-select-spacing-block-end"),i?this.style.setProperty("--scb-select-spacing-inline-start",i):this.style.removeProperty("--scb-select-spacing-inline-start"),n?this.style.setProperty("--scb-select-spacing-inline-end",n):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){if(this.open!==e)if(e){const t=this._getInitialFocusedIndex();this._updateOptionsPlacement(),this._prepareOptionsScroll(t),this.focusedIndex=t,this.open=e,this.requestUpdate()}else this.open=e,this.focusedIndex=-1}_toggleOpen(){this.disabled||this._setOpen(!this.open)}_focusTrigger(){this.shadowRoot?.querySelector(".selected-value-container")?.focus()}_getOptions(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option"):[]}_ensureOptionIds(e=this._getOptions()){e.forEach((t,s)=>{t.id||(t.id=`${this._selectId}-option-${s}`)})}_getInitialFocusedIndex(){const e=this._getOptions(),t=this.variant==="multi-select"?this._getMultiValues():[this.value],s=e.findIndex(i=>!i.disabled&&t.includes(i.value));return s>=0?s:e.findIndex(i=>!i.disabled)}_setFocusedIndex(e,t={}){const s=this._getOptions();if(this._ensureOptionIds(s),s.forEach(l=>l.removeAttribute("data-focused")),e<0||s.length===0){this.focusedIndex=-1,this._activeDescendant="";return}let i=Math.max(0,Math.min(e,s.length-1));if(s[i]?.disabled){const l=s.findIndex((c,p)=>p>=i&&!c.disabled);let h=-1;for(let c=s.length-1;c>=0;c-=1)if(!s[c]?.disabled){h=c;break}i=l>=0?l:h}const n=s[i];if(!n||n.disabled){this.focusedIndex=-1,this._activeDescendant="";return}n.setAttribute("data-focused",""),this.focusedIndex=i,this._activeDescendant=n.id,t.scroll!==!1&&n.scrollIntoView({block:"nearest"})}_prepareOptionsScroll(e){const t=this.shadowRoot?.querySelector(".options"),s=this._getOptions()[e];if(!t||!s)return;const i=getComputedStyle(t),n=getComputedStyle(this),l=Number.parseFloat(i.paddingTop)||0,h=Number.parseFloat(i.paddingBottom)||0,c=n.getPropertyValue("--scb-select-options-max-height").trim()||i.maxHeight,p=Number.parseFloat(c);if(!Number.isFinite(p)||p<=0){t.scrollTop=0;return}const w=t.getBoundingClientRect(),f=s.getBoundingClientRect(),m=f.top-w.top+t.scrollTop,_=m+f.height,v=p+l+h,k=Math.max(0,t.scrollHeight-v),z=t.scrollTop+l,S=t.scrollTop+v-h;let y=t.scrollTop;m<z?y=m-l:_>S&&(y=_-v+h),t.scrollTop=Math.max(0,Math.min(k,y))}_moveFocusedIndex(e){const t=this._getOptions();if(t.length===0)return;let s=this.focusedIndex>=0?this.focusedIndex:this._getInitialFocusedIndex();for(let i=0;i<t.length;i+=1)if(s=(s+e+t.length)%t.length,!t[s]?.disabled){this._setFocusedIndex(s);return}}_getFocusedOption(){return this._getOptions()[this.focusedIndex]}_updateOptionsPlacement(){const e=this.shadowRoot?.querySelector(".selected-value-container");if(!e)return;const t=e.getBoundingClientRect(),s=8,i=3,n=240,l=window.innerHeight-t.bottom-i-s,h=t.top-i-s,c=l<160&&h>l,p=Math.max(96,Math.min(n,c?h:l));this._optionsPlacement=c?"above":"below",this.style.setProperty("--scb-select-options-max-height",`${p}px`)}_resetOptionsPlacement(){this._optionsPlacement="below",this.style.removeProperty("--scb-select-options-max-height")}_hasMoreThanFourOptions(){const e=this._getOptions();return["extra-small","small","medium"].includes(this.size)?e.length>5:e.length>4}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const t=this._getMultiValues();t.indexOf(e.value)>-1?this.values=t.filter(s=>s!==e.value):this.values=[...t,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this._setOpen(!1),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})),this.updateComplete.then(()=>this._focusTrigger()));this._updateOptionsChecked(),this.requestUpdate()}}_getOptionLabel(e){return e.label||e.textContent?.trim()||""}_getSelectedLabel(){const e=this._getOptions();if(this.variant==="multi-select"){const t=this._getMultiValues(),s=e.filter(i=>t.includes(i.value));return s&&s.length>0?s.map(i=>this._getOptionLabel(i)).join(", "):""}else{const t=e.find(s=>s.value===this.value);return t?this._getOptionLabel(t):""}}firstUpdated(){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),e.has("size")&&this._syncDensityForSize(),e.has("errorText")&&this.error&&this._syncValidity(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing(),e.has("open")&&(this.open?this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this._scheduleOptionsPlacement()}):(this._setFocusedIndex(-1),this._resetOptionsPlacement()))}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){const e=this._getMultiValues();if(e.length===0){this._internals.setFormValue(null);return}const t=new FormData;e.forEach(s=>t.append(this.name,s)),this._internals.setFormValue(t);return}this._internals.setFormValue(this.value||null)}}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.variant==="multi-select"?this._getMultiValues().length>0:this.value)?this.errorText||"Välj ett alternativ.":""}_syncValidity(){const e=this.disabled?"":this._getValidationMessage(),t=this.shadowRoot?.querySelector(".selected-value"),s=this.error,i=this._validationMessage;if(this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||s:s&&!this._hasValidationBeenReported&&!i,!e)this.removeAttribute("aria-invalid"),t&&t.setCustomValidity(""),this._internals&&this._internals.setValidity({});else if(t&&t.setCustomValidity(e),this._internals){const n=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(n,e,t??void 0)}this.toggleAttribute("aria-invalid",this.error),(s!==this.error||i!==this._validationMessage)&&this.requestUpdate()}checkValidity(){return this._syncValidity(),this._internals?this._internals.checkValidity():!this.error}reportValidity(){return this._hasValidationBeenReported=!0,this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=String(e??""),this._syncValidity()}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}get labels(){return this._internals?.labels}_updateOptionsChecked(){const e=this._getOptions();this._ensureOptionIds(e),e.forEach(t=>{if(this.noHighlightSelected?t.setAttribute("no-highlight-selected",""):t.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const s=this._getMultiValues();t.showCheckbox=!0,t.checked=s.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}_renderLabel(){if(!this.label)return null;const e=!!this._getVisibleSupportingText(),t=`${this._selectId}-label`,s=u`
|
|
1
|
+
import{a as d,f as x,h as V,m as O,p as a,v as u,y as I}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 r}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-tooltip/scb-tooltip.js";(function(){try{var b=typeof globalThis<"u"?globalThis:window;if(!b.__scb_ce_guard_installed__){b.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,i){try{customElements.get(t)||e(t,s,i)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var g,o=(g=class extends V{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.required=!1,this.error=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.errorText="",this.helpText="",this.helpLabel="Visa hjälptext",this.withRadiobuttons=!1,this.noHighlightSelected=!1,this.size="medium",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._initialValues=[],this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._selectId=`scb-select-${Math.random().toString(36).slice(2,11)}`,this._placementFrame=0,this._optionsPlacement="below",this._activeDescendant="",this._onDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||(this._setOpen(!1),requestAnimationFrame(()=>{this.open||this._focusTrigger()})))},this._scheduleOptionsPlacement=()=>{!this.open||!this.isConnected||(this._placementFrame&&cancelAnimationFrame(this._placementFrame),this._placementFrame=requestAnimationFrame(()=>{this._placementFrame=0,this._updateOptionsPlacement()}))},this._onSlotClick=e=>{const t=this._getOptions(),s=e.composedPath(),i=t.find(n=>s.includes(n));i&&(this._selectOption(i),e.stopPropagation())},this._onKeyDown=e=>{if(e.key==="Escape"&&this.open){e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._focusTrigger();return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation();const t=e.key==="ArrowDown"?1:-1;if(!this.open){this._setOpen(!0),this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this.focusedIndex>=0&&e.key==="ArrowUp"&&this._moveFocusedIndex(-1)});return}this._moveFocusedIndex(t);return}if((e.key==="Home"||e.key==="End")&&this.open){e.preventDefault(),e.stopPropagation();const t=this._getOptions();let s=t.findIndex(i=>!i.disabled);if(e.key==="End"){for(let i=t.length-1;i>=0;i-=1)if(!t[i]?.disabled){s=i;break}}this._setFocusedIndex(s);return}if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),this.open){const t=this._getFocusedOption();t&&this._selectOption(t);return}this._setOpen(!0)}},this._onOptionKeyDown=e=>{if(e.key==="Escape"&&this.open){e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._focusTrigger();return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const t=this._getOptions(),s=e.composedPath(),i=t.find(n=>s.includes(n));i&&this._selectOption(i)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),document.addEventListener("scroll",this._scheduleOptionsPlacement,!0),window.addEventListener("resize",this._scheduleOptionsPlacement),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize(),this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this.error=!1,this._hasValidationBeenReported=!1,this._syncFormValue(),this._syncValidity(),this.requestUpdate()},this._formSubmitHandler=e=>{this.reportValidity()||(e.preventDefault(),e.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0))}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),document.removeEventListener("scroll",this._scheduleOptionsPlacement,!0),window.removeEventListener("resize",this._scheduleOptionsPlacement),this._placementFrame&&(cancelAnimationFrame(this._placementFrame),this._placementFrame=0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_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,s=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),n=this._mapSpacingToken(this.spacingRight);t?this.style.setProperty("--scb-select-spacing-block-start",t):this.style.removeProperty("--scb-select-spacing-block-start"),s?this.style.setProperty("--scb-select-spacing-block-end",s):this.style.removeProperty("--scb-select-spacing-block-end"),i?this.style.setProperty("--scb-select-spacing-inline-start",i):this.style.removeProperty("--scb-select-spacing-inline-start"),n?this.style.setProperty("--scb-select-spacing-inline-end",n):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){if(this.open!==e)if(e){const t=this._getInitialFocusedIndex();this._updateOptionsPlacement(),this._prepareOptionsScroll(t),this.focusedIndex=t,this.open=e,this.requestUpdate()}else this.open=e,this.focusedIndex=-1}_toggleOpen(){this.disabled||this._setOpen(!this.open)}_focusTrigger(){this.shadowRoot?.querySelector(".selected-value-container")?.focus()}_getOptions(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option"):[]}_ensureOptionIds(e=this._getOptions()){e.forEach((t,s)=>{t.id||(t.id=`${this._selectId}-option-${s}`)})}_getInitialFocusedIndex(){const e=this._getOptions(),t=this.variant==="multi-select"?this._getMultiValues():[this.value],s=e.findIndex(i=>!i.disabled&&t.includes(i.value));return s>=0?s:e.findIndex(i=>!i.disabled)}_setFocusedIndex(e,t={}){const s=this._getOptions();if(this._ensureOptionIds(s),s.forEach(l=>l.removeAttribute("data-focused")),e<0||s.length===0){this.focusedIndex=-1,this._activeDescendant="";return}let i=Math.max(0,Math.min(e,s.length-1));if(s[i]?.disabled){const l=s.findIndex((c,p)=>p>=i&&!c.disabled);let h=-1;for(let c=s.length-1;c>=0;c-=1)if(!s[c]?.disabled){h=c;break}i=l>=0?l:h}const n=s[i];if(!n||n.disabled){this.focusedIndex=-1,this._activeDescendant="";return}n.setAttribute("data-focused",""),this.focusedIndex=i,this._activeDescendant=n.id,t.scroll!==!1&&n.scrollIntoView({block:"nearest"})}_prepareOptionsScroll(e){const t=this.shadowRoot?.querySelector(".options"),s=this._getOptions()[e];if(!t||!s)return;const i=getComputedStyle(t),n=getComputedStyle(this),l=Number.parseFloat(i.paddingTop)||0,h=Number.parseFloat(i.paddingBottom)||0,c=n.getPropertyValue("--scb-select-options-max-height").trim()||i.maxHeight,p=Number.parseFloat(c);if(!Number.isFinite(p)||p<=0){t.scrollTop=0;return}const w=t.getBoundingClientRect(),f=s.getBoundingClientRect(),m=f.top-w.top+t.scrollTop,_=m+f.height,v=p+l+h,k=Math.max(0,t.scrollHeight-v),z=t.scrollTop+l,S=t.scrollTop+v-h;let y=t.scrollTop;m<z?y=m-l:_>S&&(y=_-v+h),t.scrollTop=Math.max(0,Math.min(k,y))}_moveFocusedIndex(e){const t=this._getOptions();if(t.length===0)return;let s=this.focusedIndex>=0?this.focusedIndex:this._getInitialFocusedIndex();for(let i=0;i<t.length;i+=1)if(s=(s+e+t.length)%t.length,!t[s]?.disabled){this._setFocusedIndex(s);return}}_getFocusedOption(){return this._getOptions()[this.focusedIndex]}_updateOptionsPlacement(){const e=this.shadowRoot?.querySelector(".selected-value-container");if(!e)return;const t=e.getBoundingClientRect(),s=8,i=3,n=240,l=window.innerHeight-t.bottom-i-s,h=t.top-i-s,c=l<160&&h>l,p=Math.max(96,Math.min(n,c?h:l));this._optionsPlacement=c?"above":"below",this.style.setProperty("--scb-select-options-max-height",`${p}px`)}_resetOptionsPlacement(){this._optionsPlacement="below",this.style.removeProperty("--scb-select-options-max-height")}_hasMoreThanFourOptions(){const e=this._getOptions();return["extra-small","small","medium"].includes(this.size)?e.length>5:e.length>4}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const t=this._getMultiValues();t.indexOf(e.value)>-1?this.values=t.filter(s=>s!==e.value):this.values=[...t,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this._setOpen(!1),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})),this.updateComplete.then(()=>this._focusTrigger()));this._updateOptionsChecked(),this.requestUpdate()}}_getOptionLabel(e){return e.label||e.textContent?.trim()||""}_getSelectedLabel(){const e=this._getOptions();if(this.variant==="multi-select"){const t=this._getMultiValues(),s=e.filter(i=>t.includes(i.value));return s&&s.length>0?s.map(i=>this._getOptionLabel(i)).join(", "):""}else{const t=e.find(s=>s.value===this.value);return t?this._getOptionLabel(t):""}}firstUpdated(){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._syncFormValue(),this._syncValidity(),e.has("size")&&this._syncDensityForSize(),e.has("errorText")&&this.error&&this._syncValidity(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing(),e.has("open")&&(this.open?this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this._scheduleOptionsPlacement()}):(this._setFocusedIndex(-1),this._resetOptionsPlacement()))}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){const e=this._getMultiValues();if(e.length===0){this._internals.setFormValue(null);return}const t=new FormData;e.forEach(s=>t.append(this.name,s)),this._internals.setFormValue(t);return}this._internals.setFormValue(this.value||null)}}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.variant==="multi-select"?this._getMultiValues().length>0:this.value)?this.errorText||"Välj ett alternativ.":""}_syncValidity(){const e=this.disabled?"":this._getValidationMessage(),t=this.shadowRoot?.querySelector(".selected-value"),s=this.error,i=this._validationMessage;if(this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||s:s&&!this._hasValidationBeenReported&&!i,!e)this.removeAttribute("aria-invalid"),t&&t.setCustomValidity(""),this._internals&&this._internals.setValidity({});else if(t&&t.setCustomValidity(e),this._internals){const n=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(n,e,t??void 0)}this.toggleAttribute("aria-invalid",this.error),(s!==this.error||i!==this._validationMessage)&&this.requestUpdate()}checkValidity(){return this._syncValidity(),this._internals?this._internals.checkValidity():!this.error}reportValidity(){return this._hasValidationBeenReported=!0,this._syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=String(e??""),this._syncValidity()}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}get labels(){return this._internals?.labels}_updateOptionsChecked(){const e=this._getOptions();this._ensureOptionIds(e),e.forEach(t=>{if(this.noHighlightSelected?t.setAttribute("no-highlight-selected",""):t.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const s=this._getMultiValues();t.showCheckbox=!0,t.checked=s.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}_renderLabel(){if(!this.label)return null;const e=!!this._getVisibleSupportingText(),t=`${this._selectId}-label`,s=u`
|
|
2
2
|
<label
|
|
3
3
|
class="select-label ${!e&&!this.helpText?"select-label--without-supporting":""}"
|
|
4
4
|
id=${t}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as m,m as d,p as a,v as o,y as u}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{h as m,m as d,p as a,v as o,y as u}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{ensureFocusRingReady as h}from"../shared/lazy-focus-ring.js";import{t as i}from"../../vendor/decorate.js";(function(){try{var n=typeof globalThis<"u"?globalThis:window;if(!n.__scb_ce_guard_installed__){n.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,r,l){try{customElements.get(s)||e(s,r,l)}catch(p){var b=String(p||"");if(b.indexOf("already been used")===-1&&b.indexOf("NotSupportedError")===-1)throw p}}}}catch{}})();var c,t=(c=class extends m{constructor(...e){super(...e),this.label="",this.subLabel="",this.symbolVariant="number",this.number=0,this.active=!1,this.completed=!1,this.changeOnCompleted=!1,this.islast=!1,this.variant="horizontal",this.widthWeight=1,this.icon="",this.__nativeFocusRingReady=!1,this.__nativeFocusRingPending=!1,this.__onFocusIn=s=>{const r=s.composedPath()[0];r instanceof HTMLElement&&r.matches(":focus-visible")&&this.__ensureNativeFocusRing()},this.__onFocusOut=()=>{this.__syncInteractiveParts()}}updated(){!this.subLabel||this.subLabel.trim()===""?this.setAttribute("no-content",""):this.removeAttribute("no-content"),this.widthWeight>0?this.style.setProperty("--scb-step-width-weight",String(this.widthWeight)):this.style.removeProperty("--scb-step-width-weight"),this.__syncInteractiveParts()}__getControl(){return this.renderRoot.querySelector(".scb-step-content")}__syncInteractiveParts(){const e=this.__getControl(),s=this.renderRoot.querySelector(".symbol-target"),r=this.renderRoot.querySelector("md-focus-ring"),l=this.renderRoot.querySelector("md-ripple");r&&e&&(r.control=e,r.visible=e.matches(":focus-visible")),l&&s&&(l.control=s)}__ensureNativeFocusRing(){this.__nativeFocusRingReady||this.__nativeFocusRingPending||(this.__nativeFocusRingPending=!0,h(),customElements.whenDefined("md-focus-ring").then(()=>{this.__nativeFocusRingPending=!1,this.__nativeFocusRingReady=!0,this.toggleAttribute("data-native-focus-ring-ready",!0),this.requestUpdate(),this.updateComplete.then(()=>this.__syncInteractiveParts())}))}handleKeyDown(e){e.key==="Enter"||e.key===" "?(e.preventDefault(),this.dispatchEvent(new MouseEvent("click",{bubbles:!0,composed:!0}))):["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(this.dispatchEvent(new CustomEvent("scb-stepper-keynav",{detail:{key:e.key},bubbles:!0,composed:!0})),e.preventDefault())}render(){const e=this.active?"step":void 0,s=this.label?`${this.label}${this.subLabel?": "+this.subLabel:""}`:`Steg ${this.number||""}`.trim();switch(this.symbolVariant){case"icon":return o`
|
|
2
2
|
<div
|
|
3
3
|
class="scb-step-content"
|
|
4
4
|
tabindex="0"
|