scb-wc 0.1.237 → 0.1.239
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 +19 -16
- package/all.d.ts +14 -0
- package/all.js +14 -0
- package/index.js +99 -85
- package/mvc/components/all.js +9 -0
- 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/{vendor → components/scb-chevron}/scb-chevron.js +1 -1
- package/mvc/components/scb-cookies-consent/scb-cookies-consent.js +1 -1
- package/mvc/components/scb-datepicker/scb-datepicker.js +143 -0
- 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 +3 -3
- package/mvc/components/scb-menu/scb-menu.js +5 -5
- 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-table-next/read-table.js +1 -0
- package/mvc/components/scb-table-next/scb-table-next.js +6 -0
- package/mvc/components/scb-textfield/scb-textfield.js +34 -176
- package/mvc/components/scb-toc/scb-toc-item.js +1 -1
- package/mvc/components/scb-tooltip/scb-tooltip.js +1 -1
- package/mvc/{vendor → components/shared}/component-size-token.js +1 -1
- package/mvc/components/shared/lazy-focus-ring.js +2 -0
- package/mvc/components/shared/lazy-ripple.js +2 -0
- package/mvc/{vendor → components/shared}/manual-popover.js +1 -1
- package/mvc/components/shared/scb-icon-svg.js +11 -0
- package/package.json +12 -2
- package/scb-components/index.d.ts +108 -0
- package/scb-components/scb-table-next/read-table.d.ts +29 -0
- package/scb-components/scb-table-next/scb-table-next.d.ts +22 -0
- package/scb-components/scb-viz/scb-viz-actions-runtime.d.ts +26 -0
- package/scb-components/scb-viz/scb-viz-print-runtime.d.ts +30 -0
- package/scb-components/scb-viz/scb-viz-series-differentiation-registry.d.ts +21 -0
- package/scb-components/scb-viz/scb-viz-series-differentiation-runtime.d.ts +42 -0
- package/scb-components/scb-viz/scb-viz-table-runtime.d.ts +28 -0
- package/scb-components/shared/component-size-token.d.ts +1 -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/manual-popover.d.ts +7 -0
- package/scb-components/shared/scb-icon-svg.d.ts +3 -0
- package/scb-menu/scb-menu-item.js +7 -1
- package/scb-menu/scb-menu.js +3 -0
- package/scb-table-next/read-table.js +87 -0
- package/scb-table-next/scb-table-next.js +226 -0
- package/scb-viz/scb-viz-series-differentiation-registry.js +10 -7
- package/scb-viz/scb-viz.js +43 -43
- package/scb-wc.bundle.js +417 -287
- package/scb-wc.d.ts +28 -0
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as d,h as m,m as v,p as i,v as s,y as h}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{
|
|
1
|
+
import{_ as d,h as m,m as v,p as i,v as s,y as h}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{ensureFocusRingOnFocusVisible as p}from"../shared/lazy-focus-ring.js";import{t}from"../../vendor/decorate.js";(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(a,g,b){try{customElements.get(a)||r(a,g,b)}catch(l){var c=String(l||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var n,e=(n=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",p)}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",p),super.disconnectedCallback()}render(){return s`
|
|
2
2
|
<div class="item ${this.checked?"checked":""}">
|
|
3
3
|
<md-ripple></md-ripple>
|
|
4
4
|
${this.showCheckbox?s`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as b,f as S,h as I,m as $,p as n,v as u,y as T}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{n as q}from"../../vendor/lazy-focus-ring.js";import{t as F}from"../../vendor/component-size-token.js";import{t as M}from"../../vendor/component-defaults.js";import{t as r}from"../../vendor/decorate.js";import"../../vendor/scb-chevron.js";import"../scb-icon-button/scb-icon-button.js";import{a as P,i as k,n as R,t as _}from"../../vendor/manual-popover.js";import"../scb-tooltip/scb-tooltip.js";import"./scb-select-option.js";(function(){try{var x=typeof globalThis<"u"?globalThis:window;if(!x.__scb_ce_guard_installed__){x.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,t,i){try{customElements.get(s)||e(s,t,i)}catch(c){var l=String(c||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var y,a=(y=class extends I{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=M["scb-select"].size,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=>{if(!this.open)return;const s=e.composedPath();if(!s.includes(this)){const t=s.find(i=>i instanceof HTMLElement?i.tagName.toLowerCase()==="scb-select":!1);if(t&&t!==this){this._setOpen(!1);return}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 s=this._getOptions(),t=e.composedPath(),i=s.find(l=>t.includes(l));i&&(this._selectOption(i),e.stopPropagation())},this._onKeyDown=e=>{if(e.key==="Tab"&&this.open){this._setOpen(!1),this._syncOptionsPopover();return}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 s=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(s);return}if((e.key==="Home"||e.key==="End")&&this.open){e.preventDefault(),e.stopPropagation();const s=this._getOptions();let t=s.findIndex(i=>!i.disabled);if(e.key==="End"){for(let i=s.length-1;i>=0;i-=1)if(!s[i]?.disabled){t=i;break}}this._setFocusedIndex(t);return}if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),this.open){const s=this._getFocusedOption();s&&this._selectOption(s);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 s=this._getOptions(),t=e.composedPath(),i=s.find(l=>t.includes(l));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,_(this.shadowRoot?.querySelector(".options")),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 s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),l=this._mapSpacingToken(this.spacingRight);s?this.style.setProperty("--scb-select-spacing-block-start",s):this.style.removeProperty("--scb-select-spacing-block-start"),t?this.style.setProperty("--scb-select-spacing-block-end",t):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"),l?this.style.setProperty("--scb-select-spacing-inline-end",l):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){if(this.open!==e)if(e){const s=this._getInitialFocusedIndex();this._updateOptionsPlacement(),this._prepareOptionsScroll(s),this.focusedIndex=s,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({preventScroll:!0})}_getOptions(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option"):[]}_ensureOptionIds(e=this._getOptions()){e.forEach((s,t)=>{s.id||(s.id=`${this._selectId}-option-${t}`)})}_getInitialFocusedIndex(){const e=this._getOptions(),s=this.variant==="multi-select"?this._getMultiValues():[this.value],t=e.findIndex(i=>!i.disabled&&s.includes(i.value));return t>=0?t:e.findIndex(i=>!i.disabled)}_setFocusedIndex(e,s={}){const t=this._getOptions();if(this._ensureOptionIds(t),t.forEach(c=>c.removeAttribute("data-focused")),e<0||t.length===0){this.focusedIndex=-1,this._activeDescendant="";return}let i=Math.max(0,Math.min(e,t.length-1));if(t[i]?.disabled){const c=t.findIndex((o,g)=>g>=i&&!o.disabled);let d=-1;for(let o=t.length-1;o>=0;o-=1)if(!t[o]?.disabled){d=o;break}i=c>=0?c:d}const l=t[i];if(!l||l.disabled){this.focusedIndex=-1,this._activeDescendant="";return}l.setAttribute("data-focused",""),this.focusedIndex=i,this._activeDescendant=l.id,s.scroll!==!1&&this._prepareOptionsScroll(i)}_prepareOptionsScroll(e){const s=this.shadowRoot?.querySelector(".options"),t=this._getOptions()[e];if(!s||!t)return;const i=getComputedStyle(s),l=getComputedStyle(this),c=Number.parseFloat(i.paddingTop)||0,d=Number.parseFloat(i.paddingBottom)||0,o=l.getPropertyValue("--scb-select-options-current-max-height").trim()||l.getPropertyValue("--scb-select-options-max-height").trim()||i.maxHeight,g=Number.parseFloat(o);if(!Number.isFinite(g)||g<=0){s.scrollTop=0;return}const v=s.getBoundingClientRect(),m=t.getBoundingClientRect(),p=m.top-v.top+s.scrollTop,f=p+m.height,h=g,w=Math.max(0,s.scrollHeight-h),O=s.scrollTop+c,V=s.scrollTop+h-d;let z=s.scrollTop;p<O?z=p-c:f>V&&(z=f-h+d),s.scrollTop=Math.max(0,Math.min(w,z))}_moveFocusedIndex(e){const s=this._getOptions();if(s.length===0)return;let t=this.focusedIndex>=0?this.focusedIndex:this._getInitialFocusedIndex();for(let i=0;i<s.length;i+=1)if(t=(t+e+s.length)%s.length,!s[t]?.disabled){this._setFocusedIndex(t);return}}_getFocusedOption(){return this._getOptions()[this.focusedIndex]}_updateOptionsPlacement(){const e=this.shadowRoot?.querySelector(".selected-value-container"),s=this.shadowRoot?.querySelector(".options");if(!e||!s)return;const t=e.getBoundingClientRect(),i=8,l=3,c=Number.parseFloat(getComputedStyle(this).getPropertyValue("--scb-select-options-max-height")),d=Number.isFinite(c)&&c>0?c:240,o=s.scrollHeight,g=Math.min(d,o),v=window.innerHeight-t.bottom-l-i,m=t.top-l-i,p=v<g&&m>v,f=Math.max(0,Math.min(g,p?m:v));if(this._optionsPlacement=p?"above":"below",this.style.setProperty("--scb-select-options-current-max-height",`${f}px`),s.style.overflowY=o>f+.5?"auto":"",k(s)){const h=Math.min(t.width,window.innerWidth-i*2),w=Math.min(Math.max(t.left,i),window.innerWidth-i-h);s.style.position="fixed",s.style.left=`${Math.round(w)}px`,s.style.right="auto",s.style.width=`${Math.round(h)}px`,p?(s.style.top="auto",s.style.bottom=`${Math.round(window.innerHeight-t.top+l)}px`):(s.style.top=`${Math.round(t.bottom+l)}px`,s.style.bottom="auto")}}_syncOptionsPopover(){const e=this.shadowRoot?.querySelector(".options")??null;if(e){if(this.open){P(e)&&this._scheduleOptionsPlacement();return}k(e)?R(e,()=>this._resetOptionsPlacement()):(_(e),this._resetOptionsPlacement())}}_resetOptionsPlacement(){this._optionsPlacement="below",this.style.removeProperty("--scb-select-options-current-max-height");const e=this.shadowRoot?.querySelector(".options");e?.style.removeProperty("position"),e?.style.removeProperty("left"),e?.style.removeProperty("right"),e?.style.removeProperty("top"),e?.style.removeProperty("bottom"),e?.style.removeProperty("width"),e?.style.removeProperty("overflow-y")}_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 s=this._getMultiValues();s.indexOf(e.value)>-1?this.values=s.filter(t=>t!==e.value):this.values=[...s,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 s=this._getMultiValues(),t=e.filter(i=>s.includes(i.value));return t&&t.length>0?t.map(i=>this._getOptionLabel(i)).join(", "):""}else{const s=e.find(t=>t.value===this.value);return s?this._getOptionLabel(s):""}}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._syncOptionsPopover(),this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this._scheduleOptionsPlacement()})):(this._syncOptionsPopover(),this._setFocusedIndex(-1)))}_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 s=new FormData;e.forEach(t=>s.append(this.name,t)),this._internals.setFormValue(s);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(),s=this.shadowRoot?.querySelector(".selected-value"),t=this.error,i=this._validationMessage;if(this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||t:t&&!this._hasValidationBeenReported&&!i,!e)this.removeAttribute("aria-invalid"),s&&s.setCustomValidity(""),this._internals&&this._internals.setValidity({});else if(s&&s.setCustomValidity(e),this._internals){const l=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(l,e,s??void 0)}this.toggleAttribute("aria-invalid",this.error),(t!==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(s=>{if(this.noHighlightSelected?s.setAttribute("no-highlight-selected",""):s.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const t=this._getMultiValues();s.showCheckbox=!0,s.checked=t.includes(s.value),s.showRadio=!1}else s.showCheckbox=!1,s.checked=this.value===s.value,this.withRadiobuttons&&(s.showRadio=!0)})}_renderLabel(){if(!this.label)return null;const e=!!this._getVisibleSupportingText(),s=`${this._selectId}-label`,t=u`
|
|
1
|
+
import{a as b,f as S,h as I,m as $,p as n,v as u,y as T}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{ensureFocusRingOnFocusVisible as q}from"../shared/lazy-focus-ring.js";import{componentSizeToken as F}from"../shared/component-size-token.js";import{t as M}from"../../vendor/component-defaults.js";import{t as r}from"../../vendor/decorate.js";import"../scb-chevron/scb-chevron.js";import"../scb-icon-button/scb-icon-button.js";import{closeManualPopover as k,closeManualPopoverAfterAnimations as P,isManualPopoverOpen as _,openManualPopover as R}from"../shared/manual-popover.js";import"../scb-tooltip/scb-tooltip.js";import"./scb-select-option.js";(function(){try{var x=typeof globalThis<"u"?globalThis:window;if(!x.__scb_ce_guard_installed__){x.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,t,i){try{customElements.get(s)||e(s,t,i)}catch(c){var l=String(c||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var y,a=(y=class extends I{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=M["scb-select"].size,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=>{if(!this.open)return;const s=e.composedPath();if(!s.includes(this)){const t=s.find(i=>i instanceof HTMLElement?i.tagName.toLowerCase()==="scb-select":!1);if(t&&t!==this){this._setOpen(!1);return}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 s=this._getOptions(),t=e.composedPath(),i=s.find(l=>t.includes(l));i&&(this._selectOption(i),e.stopPropagation())},this._onKeyDown=e=>{if(e.key==="Tab"&&this.open){this._setOpen(!1),this._syncOptionsPopover();return}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 s=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(s);return}if((e.key==="Home"||e.key==="End")&&this.open){e.preventDefault(),e.stopPropagation();const s=this._getOptions();let t=s.findIndex(i=>!i.disabled);if(e.key==="End"){for(let i=s.length-1;i>=0;i-=1)if(!s[i]?.disabled){t=i;break}}this._setFocusedIndex(t);return}if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),this.open){const s=this._getFocusedOption();s&&this._selectOption(s);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 s=this._getOptions(),t=e.composedPath(),i=s.find(l=>t.includes(l));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,k(this.shadowRoot?.querySelector(".options")),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 s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),l=this._mapSpacingToken(this.spacingRight);s?this.style.setProperty("--scb-select-spacing-block-start",s):this.style.removeProperty("--scb-select-spacing-block-start"),t?this.style.setProperty("--scb-select-spacing-block-end",t):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"),l?this.style.setProperty("--scb-select-spacing-inline-end",l):this.style.removeProperty("--scb-select-spacing-inline-end")}_setOpen(e){if(this.open!==e)if(e){const s=this._getInitialFocusedIndex();this._updateOptionsPlacement(),this._prepareOptionsScroll(s),this.focusedIndex=s,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({preventScroll:!0})}_getOptions(){const e=this.shadowRoot?.querySelector("slot");return e?e.assignedElements({flatten:!0}).filter(s=>s.tagName.toLowerCase()==="scb-select-option"):[]}_ensureOptionIds(e=this._getOptions()){e.forEach((s,t)=>{s.id||(s.id=`${this._selectId}-option-${t}`)})}_getInitialFocusedIndex(){const e=this._getOptions(),s=this.variant==="multi-select"?this._getMultiValues():[this.value],t=e.findIndex(i=>!i.disabled&&s.includes(i.value));return t>=0?t:e.findIndex(i=>!i.disabled)}_setFocusedIndex(e,s={}){const t=this._getOptions();if(this._ensureOptionIds(t),t.forEach(c=>c.removeAttribute("data-focused")),e<0||t.length===0){this.focusedIndex=-1,this._activeDescendant="";return}let i=Math.max(0,Math.min(e,t.length-1));if(t[i]?.disabled){const c=t.findIndex((o,g)=>g>=i&&!o.disabled);let d=-1;for(let o=t.length-1;o>=0;o-=1)if(!t[o]?.disabled){d=o;break}i=c>=0?c:d}const l=t[i];if(!l||l.disabled){this.focusedIndex=-1,this._activeDescendant="";return}l.setAttribute("data-focused",""),this.focusedIndex=i,this._activeDescendant=l.id,s.scroll!==!1&&this._prepareOptionsScroll(i)}_prepareOptionsScroll(e){const s=this.shadowRoot?.querySelector(".options"),t=this._getOptions()[e];if(!s||!t)return;const i=getComputedStyle(s),l=getComputedStyle(this),c=Number.parseFloat(i.paddingTop)||0,d=Number.parseFloat(i.paddingBottom)||0,o=l.getPropertyValue("--scb-select-options-current-max-height").trim()||l.getPropertyValue("--scb-select-options-max-height").trim()||i.maxHeight,g=Number.parseFloat(o);if(!Number.isFinite(g)||g<=0){s.scrollTop=0;return}const v=s.getBoundingClientRect(),m=t.getBoundingClientRect(),p=m.top-v.top+s.scrollTop,f=p+m.height,h=g,w=Math.max(0,s.scrollHeight-h),O=s.scrollTop+c,V=s.scrollTop+h-d;let z=s.scrollTop;p<O?z=p-c:f>V&&(z=f-h+d),s.scrollTop=Math.max(0,Math.min(w,z))}_moveFocusedIndex(e){const s=this._getOptions();if(s.length===0)return;let t=this.focusedIndex>=0?this.focusedIndex:this._getInitialFocusedIndex();for(let i=0;i<s.length;i+=1)if(t=(t+e+s.length)%s.length,!s[t]?.disabled){this._setFocusedIndex(t);return}}_getFocusedOption(){return this._getOptions()[this.focusedIndex]}_updateOptionsPlacement(){const e=this.shadowRoot?.querySelector(".selected-value-container"),s=this.shadowRoot?.querySelector(".options");if(!e||!s)return;const t=e.getBoundingClientRect(),i=8,l=3,c=Number.parseFloat(getComputedStyle(this).getPropertyValue("--scb-select-options-max-height")),d=Number.isFinite(c)&&c>0?c:240,o=s.scrollHeight,g=Math.min(d,o),v=window.innerHeight-t.bottom-l-i,m=t.top-l-i,p=v<g&&m>v,f=Math.max(0,Math.min(g,p?m:v));if(this._optionsPlacement=p?"above":"below",this.style.setProperty("--scb-select-options-current-max-height",`${f}px`),s.style.overflowY=o>f+.5?"auto":"",_(s)){const h=Math.min(t.width,window.innerWidth-i*2),w=Math.min(Math.max(t.left,i),window.innerWidth-i-h);s.style.position="fixed",s.style.left=`${Math.round(w)}px`,s.style.right="auto",s.style.width=`${Math.round(h)}px`,p?(s.style.top="auto",s.style.bottom=`${Math.round(window.innerHeight-t.top+l)}px`):(s.style.top=`${Math.round(t.bottom+l)}px`,s.style.bottom="auto")}}_syncOptionsPopover(){const e=this.shadowRoot?.querySelector(".options")??null;if(e){if(this.open){R(e)&&this._scheduleOptionsPlacement();return}_(e)?P(e,()=>this._resetOptionsPlacement()):(k(e),this._resetOptionsPlacement())}}_resetOptionsPlacement(){this._optionsPlacement="below",this.style.removeProperty("--scb-select-options-current-max-height");const e=this.shadowRoot?.querySelector(".options");e?.style.removeProperty("position"),e?.style.removeProperty("left"),e?.style.removeProperty("right"),e?.style.removeProperty("top"),e?.style.removeProperty("bottom"),e?.style.removeProperty("width"),e?.style.removeProperty("overflow-y")}_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 s=this._getMultiValues();s.indexOf(e.value)>-1?this.values=s.filter(t=>t!==e.value):this.values=[...s,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 s=this._getMultiValues(),t=e.filter(i=>s.includes(i.value));return t&&t.length>0?t.map(i=>this._getOptionLabel(i)).join(", "):""}else{const s=e.find(t=>t.value===this.value);return s?this._getOptionLabel(s):""}}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._syncOptionsPopover(),this.updateComplete.then(()=>{this._setFocusedIndex(this._getInitialFocusedIndex(),{scroll:!1}),this._scheduleOptionsPlacement()})):(this._syncOptionsPopover(),this._setFocusedIndex(-1)))}_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 s=new FormData;e.forEach(t=>s.append(this.name,t)),this._internals.setFormValue(s);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(),s=this.shadowRoot?.querySelector(".selected-value"),t=this.error,i=this._validationMessage;if(this._validationMessage=e,this.error=this.disabled?!1:e?this._hasValidationBeenReported||t:t&&!this._hasValidationBeenReported&&!i,!e)this.removeAttribute("aria-invalid"),s&&s.setCustomValidity(""),this._internals&&this._internals.setValidity({});else if(s&&s.setCustomValidity(e),this._internals){const l=this._customValidationMessage?{customError:!0}:{valueMissing:!0};this._internals.setValidity(l,e,s??void 0)}this.toggleAttribute("aria-invalid",this.error),(t!==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(s=>{if(this.noHighlightSelected?s.setAttribute("no-highlight-selected",""):s.removeAttribute("no-highlight-selected"),this.variant==="multi-select"){const t=this._getMultiValues();s.showCheckbox=!0,s.checked=t.includes(s.value),s.showRadio=!1}else s.showCheckbox=!1,s.checked=this.value===s.value,this.withRadiobuttons&&(s.showRadio=!0)})}_renderLabel(){if(!this.label)return null;const e=!!this._getVisibleSupportingText(),s=`${this._selectId}-label`,t=u`
|
|
2
2
|
<label
|
|
3
3
|
class="select-label ${!e&&!this.helpText?"select-label--without-supporting":""}"
|
|
4
4
|
id=${s}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as u,m as v,p as i,v as o,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{
|
|
1
|
+
import{h as u,m as v,p as i,v as o,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{componentSizeToken as b}from"../shared/component-size-token.js";import{t}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import{closeManualPopover as p,closeManualPopoverAfterAnimations as h,isManualPopoverOpen as k,openManualPopover as f}from"../shared/manual-popover.js";(function(){try{var d=typeof globalThis<"u"?globalThis:window;if(!d.__scb_ce_guard_installed__){d.__scb_ce_guard_installed__=!0;var s=customElements.define.bind(customElements);customElements.define=function(a,n,r){try{customElements.get(a)||s(a,n,r)}catch(m){var c=String(m||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw m}}}}catch{}})();var l,e=(l=class extends u{constructor(...s){super(...s),this.message="",this.open=!1,this.actionText="",this.showClose=!1,this.closeLabel="Stäng meddelande",this.fixed=!1,this.fadeout=!1,this.withLongerAction=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0}mapSpacingToken(s){if(!s)return;const a=String(s).trim();if(a)return/^\d+$/.test(a)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(a,10)))})`:a}applySpacing(){const s=this.mapSpacingToken(this.spacing),a=this.mapSpacingToken(this.spacingTop)??s,n=this.mapSpacingToken(this.spacingBottom)??s,r=this.mapSpacingToken(this.spacingLeft),c=this.mapSpacingToken(this.spacingRight);a?this.style.setProperty("--scb-snackbar-spacing-block-start",a):this.style.removeProperty("--scb-snackbar-spacing-block-start"),n?this.style.setProperty("--scb-snackbar-spacing-block-end",n):this.style.removeProperty("--scb-snackbar-spacing-block-end"),r?this.style.setProperty("--scb-snackbar-spacing-inline-start",r):this.style.removeProperty("--scb-snackbar-spacing-inline-start"),c?this.style.setProperty("--scb-snackbar-spacing-inline-end",c):this.style.removeProperty("--scb-snackbar-spacing-inline-end")}connectedCallback(){super.connectedCallback(),this.applySpacing()}disconnectedCallback(){window.clearTimeout(this._fadeoutTimer),p(this.renderRoot.querySelector(".snackbar")),super.disconnectedCallback()}handleAction(){this.dispatchEvent(new CustomEvent("snackbar-action",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("snackbaraction",{bubbles:!0,composed:!0})),this.open=!1}handleClose(){this.open=!1}updated(s){if(super.updated(s),s.has("open")||s.has("fixed")){const a=this.renderRoot.querySelector(".snackbar");this.open&&this.fixed?f(a):!this.open&&k(a)?h(a):p(a)}s.has("open")&&(this.open?(this.dispatchEvent(new CustomEvent("snackbar-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("snackbaropen",{bubbles:!0,composed:!0}))):(this.dispatchEvent(new CustomEvent("snackbar-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("snackbarclose",{bubbles:!0,composed:!0})))),(s.has("open")||s.has("fadeout"))&&(this.open&&this.fadeout?(window.clearTimeout(this._fadeoutTimer),this._fadeoutTimer=window.setTimeout(()=>{this.open=!1},5e3)):window.clearTimeout(this._fadeoutTimer)),(s.has("spacing")||s.has("spacingTop")||s.has("spacingBottom")||s.has("spacingLeft")||s.has("spacingRight"))&&this.applySpacing()}render(){const s=!!this.actionText,a=!!this.showClose;let n="snackbar";return!s&&!a&&(n+=" no-actions"),this.withLongerAction&&(n+=" longer-action"),o`
|
|
2
2
|
<div class="${n}" ?hidden=${!this.open}>
|
|
3
3
|
${this.withLongerAction?o`
|
|
4
4
|
<div
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as m,m as d,p as r,v as i,y as g}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 r,v as i,y as g}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import"../../vendor/ripple.js";import{ensureFocusRingReady as v}from"../shared/lazy-focus-ring.js";import{t as a}from"../../vendor/decorate.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,l,p){try{customElements.get(t)||e(t,l,p)}catch(o){var n=String(o||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var c,s=(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=t=>{const l=t.composedPath()[0];l instanceof HTMLElement&&l.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(),t=this.renderRoot.querySelector(".symbol-target"),l=this.renderRoot.querySelector("md-focus-ring"),p=this.renderRoot.querySelector("md-ripple");l&&e&&(l.control=e,l.visible=e.matches(":focus-visible")),p&&t&&(p.control=t)}__ensureNativeFocusRing(){this.__nativeFocusRingReady||this.__nativeFocusRingPending||(this.__nativeFocusRingPending=!0,v(),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,t=this.label?`${this.label}${this.subLabel?": "+this.subLabel:""}`:`Steg ${this.number||""}`.trim();switch(this.symbolVariant){case"icon":return i`
|
|
2
2
|
<div
|
|
3
3
|
class="scb-step-content"
|
|
4
4
|
tabindex="0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as _,m as x,p as f,v as w,y as C}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{
|
|
1
|
+
import{h as _,m as x,p as f,v as w,y as C}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{componentSizeToken as y}from"../shared/component-size-token.js";import{t as g}from"../../vendor/decorate.js";import"../scb-icon-button/scb-icon-button.js";(function(){try{var m=typeof globalThis<"u"?globalThis:window;if(!m.__scb_ce_guard_installed__){m.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,r,t){try{customElements.get(s)||e(s,r,t)}catch(o){var l=String(o||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var p,S=96,A=32,h=(p=class extends _{constructor(...e){super(...e),this.dataSorting=!1,this.columnWidthMode="auto",this._sortedColumn=null,this._sortDirection="asc",this._columnWidthFrame=null,this._onSlotChange=()=>{this._attachThListeners()}}render(){return w`
|
|
2
2
|
<div class="scb-table-scroll-wrapper">
|
|
3
3
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
4
4
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as y,m as _,p as g,v as m,y as w}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{
|
|
1
|
+
import{h as y,m as _,p as g,v as m,y as w}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{componentSizeToken as v}from"../shared/component-size-token.js";import{t as u}from"../../vendor/decorate.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-search/scb-search.js";import"../scb-pagination/scb-pagination.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(a,s,r){try{customElements.get(a)||e(a,s,r)}catch(n){var l=String(n||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw n}}}}catch{}})();var f,h=(f=class extends y{constructor(...e){super(...e),this.searchTerm="",this.pagination=!1,this.filteringSearch=!1,this.noScroll=!1,this.pageSize=10,this.disableSorting=[],this.currentPage=1,this.totalRows=0,this._sortedColumn=null,this._sortDirection="asc",this._filteredRows=null,this._tbodyObserver=null,this._observedTbody=null,this._pendingTableRefresh=!1,this._suppressTbodyObserver=!1,this._initialTableRefreshFrame=0,this._onSlotChange=()=>{this._attachTbodyObserver(),this._refreshFromTableContent()},this._onPaginationChange=a=>{const s=a.detail;s&&typeof s.page=="number"&&this._changePage(s.page)}}disconnectedCallback(){super.disconnectedCallback(),cancelAnimationFrame(this._initialTableRefreshFrame),this._disconnectTbodyObserver()}attributeChangedCallback(e,a,s){if(super.attributeChangedCallback(e,a,s),a!==s){if(e==="searchterm"){queueMicrotask(()=>{this.isConnected&&this._filterTable()});return}if(e==="currentpage"){queueMicrotask(()=>{this.isConnected&&this._paginateTable()});return}(e==="page-size"||e==="with-filtering-search"||e==="with-pagination")&&this._scheduleTableRefresh()}}render(){const e=Math.ceil(this.totalRows/this.pageSize);return m`
|
|
2
2
|
${this.filteringSearch?m`
|
|
3
3
|
<div class="filtering-search">
|
|
4
4
|
<scb-search
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){try{var r=typeof globalThis<"u"?globalThis:window;if(!r.__scb_ce_guard_installed__){r.__scb_ce_guard_installed__=!0;var l=customElements.define.bind(customElements);customElements.define=function(n,c,s){try{customElements.get(n)||l(n,c,s)}catch(d){var a=String(d||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();function p(r){if(!r.querySelector("a, sup"))return r.textContent?.trim()??"";const l=n=>{if(n.nodeType===Node.TEXT_NODE)return[n.textContent??""];if(!(n instanceof Element))return[];const c=Array.from(n.childNodes).flatMap(l);return n.localName==="sup"?[{tag:"sup",children:c}]:n.localName==="a"?[{tag:"a",children:c,href:n.getAttribute("href"),title:n.getAttribute("title")||void 0,ariaLabel:n.getAttribute("aria-label")||void 0}]:c};return Array.from(r.childNodes).flatMap(l)}var _=r=>r.scope==="row"||r.classList.contains("forspalt")||r.tagName==="TH"&&!r.scope;function C(r,l=1/0){let n=r.tHead?Array.from(r.tHead.rows):[];if(!r.tHead)for(const t of Array.from(r.rows)){if(!t.cells.length||!Array.from(t.cells).every(e=>e.tagName==="TH"))break;n.push(t)}if(!n.length)return;const c=new Set(n),s=Array.from(r.rows).filter(t=>!c.has(t));if(!s.length||s.length>l)return;const a=s.reduce((t,e)=>{const o=Array.from(e.cells).findIndex(i=>!_(i));return Math.max(t,o<0?e.cells.length:o)},1),d=s[0].cells.length-a;if((s.length+n.length+1)*d>l)return;const v=new Set(Array.from(r.querySelectorAll("[id]"),t=>t.id));if(r.querySelector("table, button, input, select, textarea, [tabindex], [contenteditable], [role]")||Array.from(r.querySelectorAll("*")).some(t=>t.localName.includes("-"))||Array.from(r.querySelectorAll("a")).some(t=>{const e=t.getAttribute("href")||"";let o;try{o=decodeURIComponent(e.slice(1))}catch{return!0}return!t.closest("th, td")||v.has(o)||!e.startsWith("#")||t.getAttribute("href")==="#"||t.hasAttribute("target")||t.hasAttribute("download")||t.getAttributeNames().some(i=>i.startsWith("on"))||t.hasAttribute("aria-labelledby")||t.hasAttribute("aria-describedby")})||r.getAttribute("role")&&r.getAttribute("role")!=="table")return;const u=n.map(()=>[]),N=n.map((t,e)=>{let o=0;return Array.from(t.cells).map(i=>{for(;u[e][o];)o++;const S=i.cloneNode(!0);S.querySelectorAll("[hidden], .visually-hidden, .sr-only").forEach(m=>m.remove());const y=i.textContent?.trim()??"",w=!!y&&!S.textContent?.trim(),h={text:y,content:p(i),visuallyHidden:w,ariaLabel:i.getAttribute("aria-label")||(w?y:void 0),column:o,colSpan:i.colSpan,rowSpan:i.rowSpan||n.length-e},A=o+h.colSpan,x=e+h.rowSpan;if(A>256||x>u.length)throw new RangeError("header-grid");for(let m=e;m<x;m++)for(let g=o;g<A;g++){if(u[m][g])throw new RangeError("header-grid");u[m][g]=h}return o=A,h})}),f=u[0].length;if(f<2||u.some(t=>t.length!==f||Array.from({length:f},(e,o)=>!t[o]).some(Boolean))||a>=f||s.some(t=>t.cells.length!==f||Array.from(t.cells).some(e=>e.colSpan!==1||e.rowSpan!==1)||!Array.from(t.cells).slice(0,a).some(e=>e.textContent?.trim())||Array.from(t.cells).slice(a).some(e=>e.tagName==="TH"||_(e))))return;if(s.some(t=>Array.from(t.cells).slice(a).every(e=>!e.textContent?.trim()))){const t=s.map(e=>JSON.stringify(Array.from(e.cells).slice(0,a).map(o=>o.textContent?.trim())));if(new Set(t).size!==t.length)return}const b=Array.from({length:f-a},(t,e)=>[...new Set(u.map(o=>o[e+a]))].filter(o=>o.text));if(!b.some(t=>!t.length))return{label:r.getAttribute("aria-label")||r.caption?.textContent?.trim()||"",headings:N,columns:b,stubCount:a,rows:s.map(t=>({stubs:Array.from(t.cells).slice(0,a).map(p),values:Array.from(t.cells).slice(a).map(p)}))}}export{C as readTable};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as b,f as $,g as _,h as R,m as E,v as s,y as k}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as y}from"../../vendor/decorate.js";import{readTable as S}from"./read-table.js";(function(){try{var v=typeof globalThis<"u"?globalThis:window;if(!v.__scb_ce_guard_installed__){v.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,a,n){try{customElements.get(e)||t(e,a,n)}catch(d){var c=String(d||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var x,C=200,w=new WeakSet,L=k`scb-table-next>table{box-sizing:border-box;inline-size:100%;border-collapse:separate;border-spacing:0;border:0;outline:1px solid var(--scb-tables-strong-outline-color);outline-offset:-1px;border-radius:var(--md-sys-shape-corner-small);overflow:hidden;background:var(--scb-tables-surface-color);color:inherit;font:inherit}scb-table-next>table>:is(thead,tbody,tfoot)>tr>:is(th,td){box-sizing:border-box;padding:var(--spacing-3) var(--spacing-4);min-inline-size:2.5rem;border-block-end:1px solid var(--scb-tables-strong-outline-color);border-inline-end:1px solid var(--scb-tables-strong-outline-color);font-variant-numeric:tabular-nums;font-weight:inherit}scb-table-next>table>:is(thead,tbody,tfoot)>tr>th,scb-table-next>table>tbody>tr>.forspalt{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table>thead>tr>*{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table>thead>tr>th{font-weight:var(--weight-bold);text-align:center}scb-table-next>table>thead>tr:last-child>th{text-align:end}scb-table-next>table>:is(tbody,tfoot)>tr>:is(th,td){text-align:end}scb-table-next>table>:is(tbody,tfoot)>tr>.forspalt,scb-table-next>table>:is(tbody,tfoot)>tr>:first-child,scb-table-next>table>:is(tbody,tfoot)>tr>th:is([scope=row],[scope=rowgroup]){text-align:start}scb-table-next>table>tbody>tr>.forspalt{min-inline-size:0}scb-table-next>table>tbody>tr>:first-child:not(:has(~th,~.forspalt)){min-inline-size:0}scb-table-next>table>tbody>tr:hover>*{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table a{color:inherit;text-decoration:underline}scb-table-next>table a:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}`,m=(x=class extends R{constructor(...t){super(...t),this._mobile=!1,this._widthReady=!1}connectedCallback(){super.connectedCallback();const t=this.getRootNode();if(!w.has(t)){const e=this.ownerDocument.createElement("style");e.textContent=L.cssText,(t instanceof Document?t.head:t).appendChild(e),w.add(t)}this._observer=new MutationObserver(()=>this._queueRead()),this._observer.observe(this,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["colspan","rowspan","aria-label","role","tabindex","contenteditable","scope","class","hidden","href","title","id","target","download","aria-labelledby","aria-describedby"]}),this._resize=new ResizeObserver(([e])=>{const a=e.contentRect.width;if(a<=0){this._widthReady=!1;return}const n=a<=575,c=n!==this._mobile;this._mobile=n,(!this._widthReady||c)&&(this._widthReady=!0,this._read())}),this._resize.observe(this)}disconnectedCallback(){this._observer?.disconnect(),this._resize?.disconnect(),this._frame!==void 0&&cancelAnimationFrame(this._frame),this._frame=void 0,this._widthReady=!1,super.disconnectedCallback()}_queueRead(){!this._mobile||!this._widthReady||this._frame!==void 0||(this._frame=requestAnimationFrame(()=>{this._frame=void 0,this._read()}))}_read(){if(!this._widthReady)return;if(!this._mobile){this._model=void 0;return}const t=this.querySelectorAll("table");try{this._model=t.length===1?S(t[0],C):void 0}catch(e){if(!(e instanceof RangeError))throw e;this._model=void 0}}_content(t){return typeof t=="string"?t:t.map(e=>typeof e=="string"?e:e.tag==="sup"?s`<sup>${this._content(e.children)}</sup>`:s`<a href=${e.href} title=${b(e.title)} aria-label=${b(e.ariaLabel)}>${this._content(e.children)}</a>`)}_mobileRows(t){const e=[],a=t.headings.flat().filter(r=>(r.text||r.ariaLabel)&&r.column+r.colSpan<=t.stubCount),n=a.map(r=>r.ariaLabel||r.text).join(" "),c=a.filter(r=>!r.visuallyHidden&&r.text);let d=[];const f=[];return t.columns.forEach((r,p)=>{let i=0;for(;i<r.length&&r[i]===d[i];)i++;f.length=i,r.forEach((l,o)=>{if(o<i)return;const h=`group-${p}-${o}`;f.push(h);const u=o===0?"outer":`group${i===0?" first":""}`;e.push(s`<tr class=${u}><th id=${h} aria-label=${b(l.ariaLabel)} scope="col" colspan="2">${this._content(l.content)}</th></tr>`)});const g=a.length?`stub-heading-${p}`:void 0;g&&(f.push(g),e.push(s`<tr class="stub-headings"><th id=${g} scope="col" colspan="2" aria-label=${b(n)}>${c.map((l,o)=>s`${o?" ":_}<span>${this._content(l.content)}</span>`)}</th></tr>`)),t.rows.forEach((l,o)=>{const h=`mobile-row-${p}-${o}`;e.push(s`<tr class=${o===t.rows.length-1?"last":""}>
|
|
2
|
+
<th class="stub" scope="row" id=${h} headers=${b(g)}>${l.stubs.filter(u=>u!=="").map((u,z)=>s`${z?" ":_}${this._content(u)}`)}</th>
|
|
3
|
+
<td headers=${[...f,h].join(" ")}>${this._content(l.values[p])}</td></tr>`)}),d=r}),e}render(){const t=this._model;return s`<div class="scroll" tabindex="0" ?hidden=${!!t}><slot @slotchange=${this._queueRead}></slot></div>
|
|
4
|
+
${t?s`<table class="mobile" aria-label=${b(t.label||void 0)}>
|
|
5
|
+
<tbody>${this._mobileRows(t)}</tbody>
|
|
6
|
+
</table>`:_}`}},x.styles=k`:host{display:block;min-inline-size:0;color:var(--scb-tables-content-color, var(--md-sys-color-on-surface));font-family:var(--scb-tables-cell-font, var(--brand-font, Inter, Arial, sans-serif));font-size:var(--scb-tables-cell-size);line-height:var(--scb-tables-cell-line-height);font-weight:var(--weight-regular)}*{box-sizing:border-box}:host([hidden]),[hidden]{display:none!important}.scroll{max-inline-size:100%;overflow-x:auto;padding-bottom:var(--spacing-8, 24px)}.scroll::-webkit-scrollbar{border-radius:var(--md-sys-shape-corner-large);height:8px;width:10px}.scroll::-webkit-scrollbar-thumb{background:var(--scb-tables-scrollbar-thumb-color, var(--md-sys-color-on-surface));border-radius:var(--md-sys-shape-corner-large);cursor:pointer}.scroll::-webkit-scrollbar-track{background:var(--scb-tables-scrollbar-track-color, var(--md-sys-color-secondary-container));border-radius:var(--md-sys-shape-corner-large)}a{color:inherit;text-decoration:underline}.scroll:focus-visible,a:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}table{inline-size:100%;border-collapse:separate;border-spacing:0;border:1px solid var(--scb-tables-strong-outline-color);border-radius:var(--md-sys-shape-corner-small);overflow:hidden;background:var(--scb-tables-surface-color);color:inherit;font:inherit}td,th{min-inline-size:2.5rem;font-variant-numeric:tabular-nums;font-weight:inherit}.stub{text-align:start}td{text-align:end}tbody tr:hover>*{background:var(--scb-tables-alternate-surface-color)}.mobile td,.mobile th{padding-block:var(--spacing-2);padding-inline:var(--spacing-5);border:0;background:0 0;vertical-align:top}.mobile .stub{min-inline-size:0;padding-inline-end:calc(var(--spacing-1)/2)}.mobile td{inline-size:1%;white-space:nowrap}.mobile .stub-headings>th{text-align:start;font-weight:var(--weight-bold)}.mobile .stub-headings>th:empty{padding:0}.mobile .outer>th{padding-block:var(--spacing-5);background:var(--scb-tables-alternate-surface-color);font-weight:var(--weight-bold);text-align:start;border-block-start:1px solid var(--scb-tables-strong-outline-color)}.mobile tbody:first-child>.outer:first-child>th{border-block-start:0}.mobile .group>th{padding-block-start:0;font-weight:var(--weight-bold);text-align:start}.mobile .group.first>th{padding-block-start:calc(var(--spacing-8) + var(--spacing-2))}.mobile .last>*{padding-block-end:calc(var(--spacing-8) + var(--spacing-2))}`,x);y([$()],m.prototype,"_model",void 0);y([$()],m.prototype,"_mobile",void 0);m=y([E("scb-table-next")],m);
|