scb-wc 0.1.78 → 0.1.80
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 +41 -22
- package/all.js +0 -2
- package/index.js +88 -90
- package/mvc/components/all.js +0 -2
- package/mvc/components/scb-accordion/scb-accordion-item.js +3 -173
- package/mvc/components/scb-accordion/scb-accordion.js +4 -33
- package/mvc/components/scb-app-bar/scb-app-bar.js +2 -110
- package/mvc/components/scb-avatar/scb-avatar.js +2 -94
- package/mvc/components/scb-badge/scb-badge.js +2 -72
- package/mvc/components/scb-breadcrumb/scb-breadcrumb-item.js +2 -12
- package/mvc/components/scb-breadcrumb/scb-breadcrumb.js +4 -91
- package/mvc/components/scb-button/scb-button.js +47 -309
- package/mvc/components/scb-calendar/scb-calendar-event.js +2 -6
- package/mvc/components/scb-calendar/scb-calendar.js +6 -120
- package/mvc/components/scb-calendar-card/scb-calendar-card.js +21 -350
- package/mvc/components/scb-card/scb-card.js +54 -819
- package/mvc/components/scb-checkbox/scb-checkbox-group.js +3 -31
- package/mvc/components/scb-checkbox/scb-checkbox.js +5 -127
- package/mvc/components/scb-chip/scb-chip.js +2 -76
- package/mvc/components/scb-collapse/scb-collapse.js +2 -44
- package/mvc/components/scb-cookies-consent/scb-cookies-consent.js +7 -73
- package/mvc/components/scb-dialog/scb-dialog.js +2 -213
- package/mvc/components/scb-divider/scb-divider.js +1 -69
- package/mvc/components/scb-drawer/scb-drawer.js +6 -102
- package/mvc/components/scb-drop-zone/scb-drop-zone.js +2 -410
- package/mvc/components/scb-dropdown/scb-dropdown.js +17 -222
- package/mvc/components/scb-fab/scb-fab.js +7 -95
- package/mvc/components/scb-fact-card/scb-fact-card-content.js +2 -69
- package/mvc/components/scb-fact-card/scb-fact-card.js +2 -214
- package/mvc/components/scb-footer/scb-footer-section.js +1 -3
- package/mvc/components/scb-footer/scb-footer.js +3 -172
- package/mvc/components/scb-gallery-grid/scb-gallery-grid.js +2 -112
- package/mvc/components/scb-grid/scb-grid-item.js +1 -32
- package/mvc/components/scb-grid/scb-grid.js +1 -99
- package/mvc/components/scb-grid/scb-stack.js +1 -33
- package/mvc/components/scb-header/scb-header-menu-item.js +1 -5
- package/mvc/components/scb-header/scb-header-tab.js +1 -5
- package/mvc/components/scb-header/scb-header.js +75 -888
- package/mvc/components/scb-horizontal-scroller/scb-horizontal-scroller.js +43 -168
- package/mvc/components/scb-icon-button/scb-icon-button.js +59 -171
- package/mvc/components/scb-keyfigure-card/scb-keyfigure-card.js +17 -218
- package/mvc/components/scb-link/scb-link.js +4 -55
- package/mvc/components/scb-list/scb-list-item.js +23 -126
- package/mvc/components/scb-list/scb-list.js +5 -26
- package/mvc/components/scb-menu/scb-menu-item.js +16 -190
- package/mvc/components/scb-menu/scb-menu-section.js +4 -36
- package/mvc/components/scb-menu/scb-menu.js +5 -69
- package/mvc/components/scb-menu/scb-sub-menu.js +2 -7
- package/mvc/components/scb-nav/scb-nav-item.js +1 -28
- package/mvc/components/scb-nav/scb-nav.js +5 -98
- package/mvc/components/scb-notification-card/scb-notification-card.js +7 -364
- package/mvc/components/scb-options-menu/scb-options-menu-item.js +3 -50
- package/mvc/components/scb-options-menu/scb-options-menu.js +2 -82
- package/mvc/components/scb-options-menu/scb-options-sub-menu.js +2 -31
- package/mvc/components/scb-overlay/scb-overlay.js +3 -43
- package/mvc/components/scb-pagination/scb-pagination.js +19 -221
- package/mvc/components/scb-progress-indicator/scb-progress-indicator.js +2 -67
- package/mvc/components/scb-progress-stepper/scb-progress-step.js +4 -121
- package/mvc/components/scb-progress-stepper/scb-progress-stepper.js +2 -56
- package/mvc/components/scb-radio-button/scb-radio-button.js +5 -116
- package/mvc/components/scb-radio-button/scb-radio-group.js +2 -32
- package/mvc/components/scb-scrollspy/scb-scrollspy.js +2 -61
- package/mvc/components/scb-search/scb-search.js +5 -249
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +1 -32
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +2 -70
- package/mvc/components/scb-select/scb-select-option.js +2 -54
- package/mvc/components/scb-select/scb-select.js +4 -244
- package/mvc/components/scb-skeleton/scb-skeleton.js +2 -35
- package/mvc/components/scb-slider/scb-slider.js +5 -9
- package/mvc/components/scb-snackbar/scb-snackbar.js +9 -84
- package/mvc/components/scb-status-pill/scb-status-pill.js +2 -43
- package/mvc/components/scb-stepper/scb-step.js +8 -186
- package/mvc/components/scb-stepper/scb-stepper.js +2 -130
- package/mvc/components/scb-switch/scb-switch.js +4 -49
- package/mvc/components/scb-table/scb-table.js +2 -48
- package/mvc/components/scb-table-advanced/scb-table-advanced.js +2 -53
- package/mvc/components/scb-tabs/scb-primary-tab.js +2 -7
- package/mvc/components/scb-tabs/scb-secondary-tab.js +2 -7
- package/mvc/components/scb-tabs/scb-tabs.js +4 -31
- package/mvc/components/scb-textfield/scb-textfield.js +142 -388
- package/mvc/components/scb-toc/scb-toc-item.js +3 -251
- package/mvc/components/scb-toc/scb-toc.js +2 -16
- package/mvc/components/scb-tooltip/scb-tooltip.js +8 -155
- package/mvc/components/scb-viz/scb-viz.js +4 -619
- package/mvc/scb-wc-core.css +1 -1
- package/mvc/scb-wc-selfhost.css +1 -1
- package/mvc/scb-wc.css +1 -1
- package/mvc/vendor/assist-chip.js +3 -3
- package/mvc/vendor/chip-set.js +1 -1
- package/mvc/vendor/chip.js +2 -2
- package/mvc/vendor/elevation.js +2 -2
- package/mvc/vendor/filter-chip.js +1 -1
- package/mvc/vendor/focusable.js +1 -1
- package/mvc/vendor/form-associated.js +1 -1
- package/mvc/vendor/icon.js +2 -2
- package/mvc/vendor/lazy-focus-ring.js +2 -0
- package/mvc/vendor/lazy-ripple.js +2 -0
- package/mvc/vendor/md-focus-ring.js +2 -2
- package/mvc/vendor/ripple.js +2 -2
- package/mvc/vendor/scb-card-variants.internal.js +284 -0
- package/mvc/vendor/scb-chevron.js +10 -0
- package/mvc/vendor/scb-header-drawer.internal.js +71 -0
- package/mvc/vendor/shared-styles.js +1 -1
- package/mvc/vendor/tab-styles.js +3 -3
- package/mvc/vendor/validator.js +1 -1
- package/mvc/vendor/vendor.js +3 -4
- package/package.json +2 -2
- package/scb-accordion/scb-accordion-item.js +33 -32
- package/scb-app-bar/scb-app-bar.js +1 -1
- package/scb-button/scb-button.js +287 -259
- package/scb-calendar/scb-calendar.js +49 -49
- package/scb-calendar-card/scb-calendar-card.js +105 -59
- package/scb-card/scb-card-variants.internal.js +230 -0
- package/scb-card/scb-card.js +387 -528
- package/scb-checkbox/scb-checkbox.js +0 -1
- package/scb-chevron/scb-chevron.js +0 -1
- package/scb-components/scb-button/scb-button.d.ts +14 -2
- package/scb-components/scb-calendar/scb-calendar.d.ts +1 -0
- package/scb-components/scb-calendar-card/scb-calendar-card.d.ts +16 -4
- package/scb-components/scb-card/scb-card-variants.internal.d.ts +15 -0
- package/scb-components/scb-card/scb-card.d.ts +26 -9
- package/scb-components/scb-cookies-consent/scb-cookies-consent.d.ts +3 -0
- package/scb-components/scb-header/scb-header-drawer.internal.d.ts +31 -0
- package/scb-components/scb-header/scb-header.d.ts +1 -2
- package/scb-components/scb-horizontal-scroller/scb-horizontal-scroller.d.ts +6 -1
- package/scb-components/scb-icon-button/scb-icon-button.d.ts +28 -29
- package/scb-components/scb-keyfigure-card/scb-keyfigure-card.d.ts +13 -4
- package/scb-components/scb-list/scb-list-item.d.ts +20 -2
- package/scb-components/scb-list/scb-list.d.ts +1 -2
- package/scb-components/scb-nav/scb-nav.d.ts +2 -0
- package/scb-components/scb-segmented-button/scb-segmented-item.d.ts +1 -0
- package/scb-components/scb-select/scb-select-option.d.ts +2 -0
- package/scb-components/scb-toc/scb-toc-item.d.ts +1 -0
- package/scb-components/scb-tooltip/scb-tooltip.d.ts +2 -0
- package/scb-cookies-consent/scb-cookies-consent.js +43 -31
- package/scb-datepicker/scb-datepicker.js +27 -25
- package/scb-dialog/scb-dialog.js +1 -1
- package/scb-dropdown/scb-dropdown.js +29 -28
- package/scb-header/scb-header-drawer.internal.js +78 -0
- package/scb-header/scb-header.js +41 -89
- package/scb-horizontal-scroller/scb-horizontal-scroller.js +181 -88
- package/scb-icon-button/scb-icon-button.js +293 -205
- package/scb-keyfigure-card/scb-keyfigure-card.js +96 -43
- package/scb-list/scb-list-item.js +117 -52
- package/scb-list/scb-list.js +9 -9
- package/scb-nav/scb-nav.js +26 -23
- package/scb-notification-card/scb-notification-card.js +0 -2
- package/scb-options-menu/scb-options-menu-item.js +20 -20
- package/scb-pagination/scb-pagination.js +0 -1
- package/scb-progress-stepper/scb-progress-step.js +19 -17
- package/scb-radio-button/scb-radio-button.js +0 -1
- package/scb-search/scb-search.js +29 -28
- package/scb-segmented-button/scb-segmented-item.js +22 -19
- package/scb-select/scb-select-option.js +20 -14
- package/scb-select/scb-select.js +26 -26
- package/scb-stepper/scb-step.js +34 -31
- package/scb-textfield/scb-textfield.js +39 -39
- package/scb-toc/scb-toc-item.js +26 -26
- package/scb-tooltip/scb-tooltip.js +5 -4
- package/scb-viz/scb-viz.js +1 -1
- package/scb-wc-core.css +1 -1
- package/scb-wc-public-entry/index.d.ts +97 -0
- package/scb-wc-selfhost.css +1 -1
- package/scb-wc.bundle.js +1873 -1476
- package/scb-wc.css +1 -1
- package/scb-wc.d.ts +194 -198
- package/mvc/components/scb-chevron/scb-chevron.js +0 -41
- package/mvc/components/scb-datepicker/scb-datepicker.js +0 -296
- package/mvc/vendor/element-internals.js +0 -1
- package/mvc/vendor/filled-icon-button.js +0 -2
- package/mvc/vendor/filled-tonal-icon-button.js +0 -2
- package/mvc/vendor/form-label-activation.js +0 -1
- package/mvc/vendor/form-submitter.js +0 -1
- package/mvc/vendor/icon-button.js +0 -2
- package/mvc/vendor/list.js +0 -8
- package/mvc/vendor/outlined-icon-button.js +0 -2
- package/mvc/vendor/shared-styles2.js +0 -30
- package/scb-components/index.d.ts +0 -99
- package/scb-components/scb-chevron/scb-chevron.d.ts +0 -11
- package/scb-components/scb-datepicker/scb-datepicker.d.ts +0 -39
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as C,g as b,h as _,m as S,o as w,p as r,s as u,v as c,y as V}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/ripple.js";import{t as a}from"../../vendor/decorate.js";import{n as T,t as p}from"../../vendor/assertClassBrand.js";import"../../vendor/md-focus-ring.js";import{t as I}from"../../vendor/delegate.js";import{a as B,n as M,o as R,r as z,s as L,t as q}from"../../vendor/form-associated.js";import{t as O}from"../../vendor/redispatch-event.js";import{i as H,n as P,r as A}from"../../vendor/validator.js";import{t as F}from"../../vendor/checkbox-validator.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,o,l){try{customElements.get(s)||e(s,o,l)}catch(m){var h=String(m||"");if(h.indexOf("already been used")===-1&&h.indexOf("NotSupportedError")===-1)throw m}}}}catch{}})();var E=Symbol("dispatchHooks");function D(t,e){const s=t[E];if(!s)throw new Error(`'${t.type}' event needs setupDispatchHooks().`);s.addEventListener("after",e)}var k=new WeakMap;function j(t,...e){let s=k.get(t);s||(s=new Set,k.set(t,s));for(const o of e){if(s.has(o))continue;let l=!1;t.addEventListener(o,h=>{if(l)return;h.stopImmediatePropagation();const m=Reflect.construct(h.constructor,[h.type,h]),g=new EventTarget;m[E]=g,l=!0;const $=t.dispatchEvent(m);l=!1,$||h.preventDefault(),g.dispatchEvent(new Event("after"))},{capture:!0}),s.add(o)}}var G=H(z(B(_))),d=class extends G{constructor(){super(),this.selected=!1,this.icons=!1,this.showOnlySelectedIcon=!1,this.required=!1,this.value="on",this.addEventListener("click",t=>{!L(t)||!this.input||(this.focus(),R(this.input))}),j(this,"keydown"),this.addEventListener("keydown",t=>{D(t,()=>{t.defaultPrevented||t.key!=="Enter"||this.disabled||!this.input||this.input.click()})})}render(){return c`
|
|
2
2
|
<div class="switch ${w(this.getRenderClasses())}">
|
|
3
3
|
<input
|
|
4
4
|
id="switch"
|
|
@@ -42,8 +42,8 @@ import{_,b as S,c as w,g as V,h as r,l as u,p as C,v as b,y as c}from"../../vend
|
|
|
42
42
|
d="M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z" />
|
|
43
43
|
</svg>
|
|
44
44
|
</slot>
|
|
45
|
-
`}renderTouchTarget(){return c`<span class="touch"></span>`}shouldShowIcons(){return this.icons||this.showOnlySelectedIcon}handleInput(t){const e=t.target;this.selected=e.checked}handleChange(t){R(this,t)}[H](){return this.selected?this.value:null}[A](){return String(this.selected)}formResetCallback(){this.selected=this.hasAttribute("selected")}formStateRestoreCallback(t){this.selected=t==="true"}[q](){return new F(()=>({checked:this.selected,required:this.required}))}[O](){return this.input}};T(d);d.shadowRootOptions={mode:"open",delegatesFocus:!0};u([r({type:Boolean})],d.prototype,"selected",void 0);u([r({type:Boolean})],d.prototype,"icons",void 0);u([r({type:Boolean,attribute:"show-only-selected-icon"})],d.prototype,"showOnlySelectedIcon",void 0);u([r({type:Boolean})],d.prototype,"required",void 0);u([r()],d.prototype,"value",void 0);u([C("input")],d.prototype,"input",void 0);var W=S`@layer styles, hcm;@layer styles{:host{display:inline-flex;outline:none;vertical-align:top;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer}:host([disabled]){cursor:default}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--md-switch-track-height, 32px))/2) 0px}md-focus-ring{--md-focus-ring-shape-start-start: var(--md-switch-track-shape-start-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-start-end: var(--md-switch-track-shape-start-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-end-end: var(--md-switch-track-shape-end-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-end-start: var(--md-switch-track-shape-end-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)))}.switch{align-items:center;display:inline-flex;flex-shrink:0;position:relative;width:var(--md-switch-track-width, 52px);height:var(--md-switch-track-height, 32px);border-start-start-radius:var(--md-switch-track-shape-start-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-start-end-radius:var(--md-switch-track-shape-start-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-end-radius:var(--md-switch-track-shape-end-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-start-radius:var(--md-switch-track-shape-end-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)))}input{appearance:none;height:48px;outline:none;margin:0;position:absolute;width:100%;z-index:1;cursor:inherit}:host([touch-target=none]) input{display:none}}@layer styles{.track{position:absolute;width:100%;height:100%;box-sizing:border-box;border-radius:inherit;display:flex;justify-content:center;align-items:center}.track::before{content:"";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;transition-property:opacity,background-color;transition-timing-function:linear;transition-duration:67ms}.disabled .track{background-color:rgba(0,0,0,0);border-color:rgba(0,0,0,0)}.disabled .track::before,.disabled .track::after{transition:none;opacity:var(--md-switch-disabled-track-opacity, 0.12)}.disabled .track::before{background-clip:content-box}.selected .track::before{background-color:var(--md-switch-selected-track-color, var(--md-sys-color-primary, #6750a4))}.selected:hover .track::before{background-color:var(--md-switch-selected-hover-track-color, var(--md-sys-color-primary, #6750a4))}.selected:focus-within .track::before{background-color:var(--md-switch-selected-focus-track-color, var(--md-sys-color-primary, #6750a4))}.selected:active .track::before{background-color:var(--md-switch-selected-pressed-track-color, var(--md-sys-color-primary, #6750a4))}.selected.disabled .track{background-clip:border-box}.selected.disabled .track::before{background-color:var(--md-switch-disabled-selected-track-color, var(--md-sys-color-on-surface, #1d1b20))}.unselected .track::before{background-color:var(--md-switch-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-track-outline-color, var(--md-sys-color-outline, #79747e));border-style:solid;border-width:var(--md-switch-track-outline-width, 2px)}.unselected:hover .track::before{background-color:var(--md-switch-hover-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-hover-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected:focus-visible .track::before{background-color:var(--md-switch-focus-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-focus-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected:active .track::before{background-color:var(--md-switch-pressed-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-pressed-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected.disabled .track::before{background-color:var(--md-switch-disabled-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-disabled-track-outline-color, var(--md-sys-color-on-surface, #1d1b20))}}@layer hcm{@media(forced-colors: active){.selected .track::before{background:ButtonText;border-color:ButtonText}.disabled .track::before{border-color:GrayText;opacity:1}.disabled.selected .track::before{background:GrayText}}}@layer styles{.handle-container{display:flex;place-content:center;place-items:center;position:relative;transition:margin 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275)}.selected .handle-container{margin-inline-start:calc(var(--md-switch-track-width, 52px) - var(--md-switch-track-height, 32px))}.unselected .handle-container{margin-inline-end:calc(var(--md-switch-track-width, 52px) - var(--md-switch-track-height, 32px))}.disabled .handle-container{transition:none}.handle{border-start-start-radius:var(--md-switch-handle-shape-start-start, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-start-end-radius:var(--md-switch-handle-shape-start-end, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-end-radius:var(--md-switch-handle-shape-end-end, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-start-radius:var(--md-switch-handle-shape-end-start, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));height:var(--md-switch-handle-height, 16px);width:var(--md-switch-handle-width, 16px);transform-origin:center;transition-property:height,width;transition-duration:250ms,250ms;transition-timing-function:cubic-bezier(0.2, 0, 0, 1),cubic-bezier(0.2, 0, 0, 1);z-index:0}.handle::before{content:"";display:flex;inset:0;position:absolute;border-radius:inherit;box-sizing:border-box;transition:background-color 67ms linear}.disabled .handle,.disabled .handle::before{transition:none}.selected .handle{height:var(--md-switch-selected-handle-height, 24px);width:var(--md-switch-selected-handle-width, 24px)}.handle.with-icon{height:var(--md-switch-with-icon-handle-height, 24px);width:var(--md-switch-with-icon-handle-width, 24px)}.selected:not(.disabled):active .handle,.unselected:not(.disabled):active .handle{height:var(--md-switch-pressed-handle-height, 28px);width:var(--md-switch-pressed-handle-width, 28px);transition-timing-function:linear;transition-duration:100ms}.selected .handle::before{background-color:var(--md-switch-selected-handle-color, var(--md-sys-color-on-primary, #fff))}.selected:hover .handle::before{background-color:var(--md-switch-selected-hover-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected:focus-within .handle::before{background-color:var(--md-switch-selected-focus-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected:active .handle::before{background-color:var(--md-switch-selected-pressed-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected.disabled .handle::before{background-color:var(--md-switch-disabled-selected-handle-color, var(--md-sys-color-surface, #fef7ff));opacity:var(--md-switch-disabled-selected-handle-opacity, 1)}.unselected .handle::before{background-color:var(--md-switch-handle-color, var(--md-sys-color-outline, #79747e))}.unselected:hover .handle::before{background-color:var(--md-switch-hover-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected:focus-within .handle::before{background-color:var(--md-switch-focus-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected:active .handle::before{background-color:var(--md-switch-pressed-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected.disabled .handle::before{background-color:var(--md-switch-disabled-handle-color, var(--md-sys-color-on-surface, #1d1b20));opacity:var(--md-switch-disabled-handle-opacity, 0.38)}md-ripple{border-radius:var(--md-switch-state-layer-shape, var(--md-sys-shape-corner-full, 9999px));height:var(--md-switch-state-layer-size, 40px);inset:unset;width:var(--md-switch-state-layer-size, 40px)}.selected md-ripple{--md-ripple-hover-color: var(--md-switch-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-pressed-color: var(--md-switch-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-hover-opacity: var(--md-switch-selected-hover-state-layer-opacity, 0.08);--md-ripple-pressed-opacity: var(--md-switch-selected-pressed-state-layer-opacity, 0.12)}.unselected md-ripple{--md-ripple-hover-color: var(--md-switch-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-color: var(--md-switch-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-switch-hover-state-layer-opacity, 0.08);--md-ripple-pressed-opacity: var(--md-switch-pressed-state-layer-opacity, 0.12)}}@layer hcm{@media(forced-colors: active){.unselected .handle::before{background:ButtonText}.disabled .handle::before{opacity:1}.disabled.unselected .handle::before{background:GrayText}}}@layer styles{.icons{position:relative;height:100%;width:100%}.icon{position:absolute;inset:0;margin:auto;display:flex;align-items:center;justify-content:center;fill:currentColor;transition:fill 67ms linear,opacity 33ms linear,transform 167ms cubic-bezier(0.2, 0, 0, 1);opacity:0}.disabled .icon{transition:none}.selected .icon--on,.unselected .icon--off{opacity:1}.unselected .handle:not(.with-icon) .icon--on{transform:rotate(-45deg)}.icon--off{width:var(--md-switch-icon-size, 16px);height:var(--md-switch-icon-size, 16px);color:var(--md-switch-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:hover .icon--off{color:var(--md-switch-hover-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:focus-within .icon--off{color:var(--md-switch-focus-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:active .icon--off{color:var(--md-switch-pressed-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected.disabled .icon--off{color:var(--md-switch-disabled-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));opacity:var(--md-switch-disabled-icon-opacity, 0.38)}.icon--on{width:var(--md-switch-selected-icon-size, 16px);height:var(--md-switch-selected-icon-size, 16px);color:var(--md-switch-selected-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:hover .icon--on{color:var(--md-switch-selected-hover-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:focus-within .icon--on{color:var(--md-switch-selected-focus-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:active .icon--on{color:var(--md-switch-selected-pressed-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected.disabled .icon--on{color:var(--md-switch-disabled-selected-icon-color, var(--md-sys-color-on-surface, #1d1b20));opacity:var(--md-switch-disabled-selected-icon-opacity, 0.38)}}@layer hcm{@media(forced-colors: active){.icon--off{fill:Canvas}.icon--on{fill:ButtonText}.disabled.unselected .icon--off,.disabled.selected .icon--on{opacity:1}.disabled .icon--on{fill:GrayText}}}
|
|
46
|
-
`,y=class extends d{};y.styles=[W];y=u([
|
|
45
|
+
`}renderTouchTarget(){return c`<span class="touch"></span>`}shouldShowIcons(){return this.icons||this.showOnlySelectedIcon}handleInput(t){const e=t.target;this.selected=e.checked}handleChange(t){O(this,t)}[M](){return this.selected?this.value:null}[q](){return String(this.selected)}formResetCallback(){this.selected=this.hasAttribute("selected")}formStateRestoreCallback(t){this.selected=t==="true"}[P](){return new F(()=>({checked:this.selected,required:this.required}))}[A](){return this.input}};I(d);d.shadowRootOptions={mode:"open",delegatesFocus:!0};u([r({type:Boolean})],d.prototype,"selected",void 0);u([r({type:Boolean})],d.prototype,"icons",void 0);u([r({type:Boolean,attribute:"show-only-selected-icon"})],d.prototype,"showOnlySelectedIcon",void 0);u([r({type:Boolean})],d.prototype,"required",void 0);u([r()],d.prototype,"value",void 0);u([C("input")],d.prototype,"input",void 0);var W=V`@layer styles, hcm;@layer styles{:host{display:inline-flex;outline:none;vertical-align:top;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer}:host([disabled]){cursor:default}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--md-switch-track-height, 32px))/2) 0px}md-focus-ring{--md-focus-ring-shape-start-start: var(--md-switch-track-shape-start-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-start-end: var(--md-switch-track-shape-start-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-end-end: var(--md-switch-track-shape-end-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));--md-focus-ring-shape-end-start: var(--md-switch-track-shape-end-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)))}.switch{align-items:center;display:inline-flex;flex-shrink:0;position:relative;width:var(--md-switch-track-width, 52px);height:var(--md-switch-track-height, 32px);border-start-start-radius:var(--md-switch-track-shape-start-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-start-end-radius:var(--md-switch-track-shape-start-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-end-radius:var(--md-switch-track-shape-end-end, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-start-radius:var(--md-switch-track-shape-end-start, var(--md-switch-track-shape, var(--md-sys-shape-corner-full, 9999px)))}input{appearance:none;height:48px;outline:none;margin:0;position:absolute;width:100%;z-index:1;cursor:inherit}:host([touch-target=none]) input{display:none}}@layer styles{.track{position:absolute;width:100%;height:100%;box-sizing:border-box;border-radius:inherit;display:flex;justify-content:center;align-items:center}.track::before{content:"";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;transition-property:opacity,background-color;transition-timing-function:linear;transition-duration:67ms}.disabled .track{background-color:rgba(0,0,0,0);border-color:rgba(0,0,0,0)}.disabled .track::before,.disabled .track::after{transition:none;opacity:var(--md-switch-disabled-track-opacity, 0.12)}.disabled .track::before{background-clip:content-box}.selected .track::before{background-color:var(--md-switch-selected-track-color, var(--md-sys-color-primary, #6750a4))}.selected:hover .track::before{background-color:var(--md-switch-selected-hover-track-color, var(--md-sys-color-primary, #6750a4))}.selected:focus-within .track::before{background-color:var(--md-switch-selected-focus-track-color, var(--md-sys-color-primary, #6750a4))}.selected:active .track::before{background-color:var(--md-switch-selected-pressed-track-color, var(--md-sys-color-primary, #6750a4))}.selected.disabled .track{background-clip:border-box}.selected.disabled .track::before{background-color:var(--md-switch-disabled-selected-track-color, var(--md-sys-color-on-surface, #1d1b20))}.unselected .track::before{background-color:var(--md-switch-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-track-outline-color, var(--md-sys-color-outline, #79747e));border-style:solid;border-width:var(--md-switch-track-outline-width, 2px)}.unselected:hover .track::before{background-color:var(--md-switch-hover-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-hover-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected:focus-visible .track::before{background-color:var(--md-switch-focus-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-focus-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected:active .track::before{background-color:var(--md-switch-pressed-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-pressed-track-outline-color, var(--md-sys-color-outline, #79747e))}.unselected.disabled .track::before{background-color:var(--md-switch-disabled-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));border-color:var(--md-switch-disabled-track-outline-color, var(--md-sys-color-on-surface, #1d1b20))}}@layer hcm{@media(forced-colors: active){.selected .track::before{background:ButtonText;border-color:ButtonText}.disabled .track::before{border-color:GrayText;opacity:1}.disabled.selected .track::before{background:GrayText}}}@layer styles{.handle-container{display:flex;place-content:center;place-items:center;position:relative;transition:margin 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275)}.selected .handle-container{margin-inline-start:calc(var(--md-switch-track-width, 52px) - var(--md-switch-track-height, 32px))}.unselected .handle-container{margin-inline-end:calc(var(--md-switch-track-width, 52px) - var(--md-switch-track-height, 32px))}.disabled .handle-container{transition:none}.handle{border-start-start-radius:var(--md-switch-handle-shape-start-start, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-start-end-radius:var(--md-switch-handle-shape-start-end, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-end-radius:var(--md-switch-handle-shape-end-end, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));border-end-start-radius:var(--md-switch-handle-shape-end-start, var(--md-switch-handle-shape, var(--md-sys-shape-corner-full, 9999px)));height:var(--md-switch-handle-height, 16px);width:var(--md-switch-handle-width, 16px);transform-origin:center;transition-property:height,width;transition-duration:250ms,250ms;transition-timing-function:cubic-bezier(0.2, 0, 0, 1),cubic-bezier(0.2, 0, 0, 1);z-index:0}.handle::before{content:"";display:flex;inset:0;position:absolute;border-radius:inherit;box-sizing:border-box;transition:background-color 67ms linear}.disabled .handle,.disabled .handle::before{transition:none}.selected .handle{height:var(--md-switch-selected-handle-height, 24px);width:var(--md-switch-selected-handle-width, 24px)}.handle.with-icon{height:var(--md-switch-with-icon-handle-height, 24px);width:var(--md-switch-with-icon-handle-width, 24px)}.selected:not(.disabled):active .handle,.unselected:not(.disabled):active .handle{height:var(--md-switch-pressed-handle-height, 28px);width:var(--md-switch-pressed-handle-width, 28px);transition-timing-function:linear;transition-duration:100ms}.selected .handle::before{background-color:var(--md-switch-selected-handle-color, var(--md-sys-color-on-primary, #fff))}.selected:hover .handle::before{background-color:var(--md-switch-selected-hover-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected:focus-within .handle::before{background-color:var(--md-switch-selected-focus-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected:active .handle::before{background-color:var(--md-switch-selected-pressed-handle-color, var(--md-sys-color-primary-container, #eaddff))}.selected.disabled .handle::before{background-color:var(--md-switch-disabled-selected-handle-color, var(--md-sys-color-surface, #fef7ff));opacity:var(--md-switch-disabled-selected-handle-opacity, 1)}.unselected .handle::before{background-color:var(--md-switch-handle-color, var(--md-sys-color-outline, #79747e))}.unselected:hover .handle::before{background-color:var(--md-switch-hover-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected:focus-within .handle::before{background-color:var(--md-switch-focus-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected:active .handle::before{background-color:var(--md-switch-pressed-handle-color, var(--md-sys-color-on-surface-variant, #49454f))}.unselected.disabled .handle::before{background-color:var(--md-switch-disabled-handle-color, var(--md-sys-color-on-surface, #1d1b20));opacity:var(--md-switch-disabled-handle-opacity, 0.38)}md-ripple{border-radius:var(--md-switch-state-layer-shape, var(--md-sys-shape-corner-full, 9999px));height:var(--md-switch-state-layer-size, 40px);inset:unset;width:var(--md-switch-state-layer-size, 40px)}.selected md-ripple{--md-ripple-hover-color: var(--md-switch-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-pressed-color: var(--md-switch-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-hover-opacity: var(--md-switch-selected-hover-state-layer-opacity, 0.08);--md-ripple-pressed-opacity: var(--md-switch-selected-pressed-state-layer-opacity, 0.12)}.unselected md-ripple{--md-ripple-hover-color: var(--md-switch-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-color: var(--md-switch-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-switch-hover-state-layer-opacity, 0.08);--md-ripple-pressed-opacity: var(--md-switch-pressed-state-layer-opacity, 0.12)}}@layer hcm{@media(forced-colors: active){.unselected .handle::before{background:ButtonText}.disabled .handle::before{opacity:1}.disabled.unselected .handle::before{background:GrayText}}}@layer styles{.icons{position:relative;height:100%;width:100%}.icon{position:absolute;inset:0;margin:auto;display:flex;align-items:center;justify-content:center;fill:currentColor;transition:fill 67ms linear,opacity 33ms linear,transform 167ms cubic-bezier(0.2, 0, 0, 1);opacity:0}.disabled .icon{transition:none}.selected .icon--on,.unselected .icon--off{opacity:1}.unselected .handle:not(.with-icon) .icon--on{transform:rotate(-45deg)}.icon--off{width:var(--md-switch-icon-size, 16px);height:var(--md-switch-icon-size, 16px);color:var(--md-switch-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:hover .icon--off{color:var(--md-switch-hover-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:focus-within .icon--off{color:var(--md-switch-focus-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected:active .icon--off{color:var(--md-switch-pressed-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9))}.unselected.disabled .icon--off{color:var(--md-switch-disabled-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));opacity:var(--md-switch-disabled-icon-opacity, 0.38)}.icon--on{width:var(--md-switch-selected-icon-size, 16px);height:var(--md-switch-selected-icon-size, 16px);color:var(--md-switch-selected-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:hover .icon--on{color:var(--md-switch-selected-hover-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:focus-within .icon--on{color:var(--md-switch-selected-focus-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected:active .icon--on{color:var(--md-switch-selected-pressed-icon-color, var(--md-sys-color-on-primary-container, #21005d))}.selected.disabled .icon--on{color:var(--md-switch-disabled-selected-icon-color, var(--md-sys-color-on-surface, #1d1b20));opacity:var(--md-switch-disabled-selected-icon-opacity, 0.38)}}@layer hcm{@media(forced-colors: active){.icon--off{fill:Canvas}.icon--on{fill:ButtonText}.disabled.unselected .icon--off,.disabled.selected .icon--on{opacity:1}.disabled .icon--on{fill:GrayText}}}
|
|
46
|
+
`,y=class extends d{};y.styles=[W];y=u([S("md-switch")],y);var n,f,i=(n=new WeakSet,f=class extends _{constructor(){super(),T(this,n),this._internals=null,this.label="",this.ariaLabel="",this.icons=!1,this.selected=!1,this.required=!1,this.disabled=!1,this.fullWidth=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.name="",this.value="on",this._form=null,this._formResetHandler=null,this._initialSelected=!1,this._customValidationMessage="","attachInternals"in this&&(this._internals=this.attachInternals())}connectedCallback(){super.connectedCallback(),this._initialSelected=this.selected,this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.selected=this._initialSelected,this.__syncFormValue()},this._form.addEventListener("reset",this._formResetHandler,!0)),this.__syncFormValue()}disconnectedCallback(){this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),super.disconnectedCallback()}firstUpdated(){this.shadowRoot?.querySelector("md-switch")?.addEventListener("change",e=>{this.selected=e.target.selected,this.dispatchEvent(new CustomEvent("change",{detail:{selected:this.selected},bubbles:!0,composed:!0}))}),p(n,this,x).call(this)}updated(e){super.updated(e),e.has("disabled")&&this.toggleAttribute("aria-disabled",this.disabled),(e.has("selected")||e.has("disabled")||e.has("value"))&&this.__syncFormValue(),(e.has("selected")||e.has("disabled")||e.has("required"))&&this.__syncValidity(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&p(n,this,x).call(this)}formDisabledCallback(e){this.disabled=e}__getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!this.selected?"Aktivera det här valet.":""}__syncValidity(){const e=this.shadowRoot?.querySelector("md-switch"),s=this.disabled?"":this.__getValidationMessage();this._internals&&(s?this._internals.setValidity({valueMissing:!0},s,e??void 0):this._internals.setValidity({})),this.toggleAttribute("aria-invalid",!!s)}checkValidity(){return!this.__getValidationMessage()}reportValidity(){return this.__syncValidity(),this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(e){this._customValidationMessage=e,this.__syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this.__getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}__syncFormValue(){if(!this._internals)return;const e=this.disabled||!this.selected?null:this.value;this._internals.setFormValue(e)}render(){const e=this.label.trim().length>0,s=e?b:this.ariaLabel||b,o=c`
|
|
47
47
|
<md-switch
|
|
48
48
|
?icons=${this.icons}
|
|
49
49
|
?selected=${this.selected}
|
|
@@ -56,49 +56,4 @@ import{_,b as S,c as w,g as V,h as r,l as u,p as C,v as b,y as c}from"../../vend
|
|
|
56
56
|
<span class="switch-label">${this.label}</span>
|
|
57
57
|
${o}
|
|
58
58
|
</label>
|
|
59
|
-
`:o}},f.formAssociated=!0,f.styles=S
|
|
60
|
-
:host {
|
|
61
|
-
display: block;
|
|
62
|
-
/* Vertikalt avstånd styrs av spacing-attributen via CSS-variabler */
|
|
63
|
-
margin-block-start: var(--scb-switch-spacing-block-start, 0);
|
|
64
|
-
margin-block-end: var(--scb-switch-spacing-block-end, 0);
|
|
65
|
-
margin-inline-start: var(--scb-switch-spacing-inline-start, 0);
|
|
66
|
-
margin-inline-end: var(--scb-switch-spacing-inline-end, 0);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.switch-container {
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
justify-content: flex-start;
|
|
73
|
-
width: auto;
|
|
74
|
-
|
|
75
|
-
/* Gap hämtas från spacing-tokens och följer density-lägen */
|
|
76
|
-
gap: var(--scb-switch-gap, var(--spacing-3, 8px));
|
|
77
|
-
|
|
78
|
-
cursor: pointer;
|
|
79
|
-
|
|
80
|
-
/* Basfärg för innehållet. Labeln ärver om inget annat anges. */
|
|
81
|
-
color: var(--md-sys-color-on-surface);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* När full-width är true, kör space-between + 100% bredd */
|
|
85
|
-
:host([full-width]) .switch-container {
|
|
86
|
-
justify-content: space-between;
|
|
87
|
-
width: 100%;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.switch-label {
|
|
91
|
-
/* liten vertikal justering kopplad till spacing-tokens */
|
|
92
|
-
transform: translateY(var(--scb-switch-label-offset-y, var(--spacing-1, 2px)));
|
|
93
|
-
|
|
94
|
-
/* Typografiska tokens*/
|
|
95
|
-
font-family: var(--brand-font, 'Inter', sans-serif);
|
|
96
|
-
font-size: var(--md-sys-typescale-title-medium-size, 18px);
|
|
97
|
-
line-height: var(--md-sys-typescale-title-medium-line-height, 26px);
|
|
98
|
-
font-weight: var(--md-sys-typescale-title-large-weight, 600);
|
|
99
|
-
letter-spacing: var(--md-sys-typescale-title-medium-tracking, -0.3px);
|
|
100
|
-
|
|
101
|
-
/* Ärver färg från container */
|
|
102
|
-
color: var(--scb-switch-label-color, inherit);
|
|
103
|
-
}
|
|
104
|
-
`,f);function x(){const t=p(n,this,v).call(this,this.spacing),e=p(n,this,v).call(this,this.spacingTop)??t,s=p(n,this,v).call(this,this.spacingBottom)??t,o=p(n,this,v).call(this,this.spacingLeft),l=p(n,this,v).call(this,this.spacingRight);e?this.style.setProperty("--scb-switch-spacing-block-start",e):this.style.removeProperty("--scb-switch-spacing-block-start"),s?this.style.setProperty("--scb-switch-spacing-block-end",s):this.style.removeProperty("--scb-switch-spacing-block-end"),o?this.style.setProperty("--scb-switch-spacing-inline-start",o):this.style.removeProperty("--scb-switch-spacing-inline-start"),l?this.style.setProperty("--scb-switch-spacing-inline-end",l):this.style.removeProperty("--scb-switch-spacing-inline-end")}function v(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}a([r({type:String})],i.prototype,"label",void 0);a([r({type:String,reflect:!0,attribute:"aria-label"})],i.prototype,"ariaLabel",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"icons",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"selected",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"required",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"disabled",void 0);a([r({type:Boolean,reflect:!0,attribute:"full-width"})],i.prototype,"fullWidth",void 0);a([r({type:String,reflect:!0})],i.prototype,"spacing",void 0);a([r({type:String,attribute:"spacing-top",reflect:!0})],i.prototype,"spacingTop",void 0);a([r({type:String,attribute:"spacing-bottom",reflect:!0})],i.prototype,"spacingBottom",void 0);a([r({type:String,attribute:"spacing-left",reflect:!0})],i.prototype,"spacingLeft",void 0);a([r({type:String,attribute:"spacing-right",reflect:!0})],i.prototype,"spacingRight",void 0);a([r({type:String})],i.prototype,"name",void 0);a([r({type:String})],i.prototype,"value",void 0);i=a([V("scb-switch")],i);export{i as ScbSwitch};
|
|
59
|
+
`:o}},f.formAssociated=!0,f.styles=V`:host{display:block;margin-block-start:var(--scb-switch-spacing-block-start, 0);margin-block-end:var(--scb-switch-spacing-block-end, 0);margin-inline-start:var(--scb-switch-spacing-inline-start, 0);margin-inline-end:var(--scb-switch-spacing-inline-end, 0)}.switch-container{display:flex;align-items:center;justify-content:flex-start;width:auto;gap:var(--scb-switch-gap, var(--spacing-3, 8px));cursor:pointer;color:var(--md-sys-color-on-surface)}:host([full-width]) .switch-container{justify-content:space-between;width:100%}.switch-label{transform:translateY(var(--scb-switch-label-offset-y, var(--spacing-1, 2px)));font-family:var(--brand-font, 'Inter', sans-serif);font-size:var(--md-sys-typescale-title-medium-size, 18px);line-height:var(--md-sys-typescale-title-medium-line-height, 26px);font-weight:var(--md-sys-typescale-title-large-weight, 600);letter-spacing:var(--md-sys-typescale-title-medium-tracking, -0.3px);color:var(--scb-switch-label-color, inherit)}`,f);function x(){const t=p(n,this,v).call(this,this.spacing),e=p(n,this,v).call(this,this.spacingTop)??t,s=p(n,this,v).call(this,this.spacingBottom)??t,o=p(n,this,v).call(this,this.spacingLeft),l=p(n,this,v).call(this,this.spacingRight);e?this.style.setProperty("--scb-switch-spacing-block-start",e):this.style.removeProperty("--scb-switch-spacing-block-start"),s?this.style.setProperty("--scb-switch-spacing-block-end",s):this.style.removeProperty("--scb-switch-spacing-block-end"),o?this.style.setProperty("--scb-switch-spacing-inline-start",o):this.style.removeProperty("--scb-switch-spacing-inline-start"),l?this.style.setProperty("--scb-switch-spacing-inline-end",l):this.style.removeProperty("--scb-switch-spacing-inline-end")}function v(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}a([r({type:String})],i.prototype,"label",void 0);a([r({type:String,reflect:!0,attribute:"aria-label"})],i.prototype,"ariaLabel",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"icons",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"selected",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"required",void 0);a([r({type:Boolean,reflect:!0})],i.prototype,"disabled",void 0);a([r({type:Boolean,reflect:!0,attribute:"full-width"})],i.prototype,"fullWidth",void 0);a([r({type:String,reflect:!0})],i.prototype,"spacing",void 0);a([r({type:String,attribute:"spacing-top",reflect:!0})],i.prototype,"spacingTop",void 0);a([r({type:String,attribute:"spacing-bottom",reflect:!0})],i.prototype,"spacingBottom",void 0);a([r({type:String,attribute:"spacing-left",reflect:!0})],i.prototype,"spacingLeft",void 0);a([r({type:String,attribute:"spacing-right",reflect:!0})],i.prototype,"spacingRight",void 0);a([r({type:String})],i.prototype,"name",void 0);a([r({type:String})],i.prototype,"value",void 0);i=a([S("scb-switch")],i);export{i as ScbSwitch};
|
|
@@ -1,51 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as g,m as _,p as b,v,y as C}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as f}from"../../vendor/decorate.js";import"../scb-icon-button/scb-icon-button.js";(function(){try{var y=typeof globalThis<"u"?globalThis:window;if(!y.__scb_ce_guard_installed__){y.__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(a){var l=String(a||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var p,w=96,S=32,m=(p=class extends g{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 v`
|
|
2
2
|
<div class="scb-table-scroll-wrapper">
|
|
3
3
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
4
4
|
</div>
|
|
5
|
-
`}firstUpdated(){const e=this.shadowRoot?.querySelector("slot");e&&(e.addEventListener("slotchange",()=>this._attachThListeners()),this._attachThListeners())}updated(e){e.has("dataSorting")&&(this.dataSorting||(this._sortedColumn=null,this._sortDirection="asc"),this._attachThListeners()),e.has("columnWidthMode")&&this._queueColumnWidthUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._columnWidthFrame!==null&&(cancelAnimationFrame(this._columnWidthFrame),this._columnWidthFrame=null)}_getTbody(){const e=this.shadowRoot?.querySelector("slot");if(!e)return null;const s=e.assignedNodes({flatten:!0});for(const r of s)if(r.nodeType===Node.ELEMENT_NODE){const t=r,l=t.tagName.toLowerCase()==="tbody"?t:t.querySelector("tbody");if(l)return l}return null}_getTables(){const e=this.shadowRoot?.querySelector("slot");if(!e)return[];const s=e.assignedNodes({flatten:!0}),r=[];return s.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const l=t;l.tagName.toLowerCase()==="table"&&r.push(l),r.push(...Array.from(l.querySelectorAll("table")))}}),r}_attachThListeners(){const e=this.shadowRoot?.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0}),r=[],t=[],l=[],a=[];s.forEach(o=>{o.nodeType===Node.ELEMENT_NODE&&(r.push(...o.querySelectorAll("thead")),t.push(...o.querySelectorAll("th")),l.push(...o.querySelectorAll("td")),a.push(...o.querySelectorAll("tr")))}),r.forEach(o=>{o.style.borderTop="1px solid var(--md-sys-color-on-surface)"}),t.forEach((o,i)=>{o.style.textAlign="left",o.style.padding="12px",o.style.position="relative",o.style.backgroundColor="var(--md-sys-color-surface)",o.style.fontFamily="var(--md-sys-typescale-label-medium-font)",o.style.fontSize="var(--md-sys-typescale-label-medium-size)",o.style.lineHeight="var(--md-sys-typescale-label-medium-line-height)",o.style.fontWeight=" var(--weight-bold)",o.style.letterSpacing="var(--md-sys-typescale-label-medium-tracking)",o.style.verticalAlign="bottom",o.style.borderRight="1px solid var(--md-sys-color-on-surface)",o.style.borderBottom="1px solid var(--md-sys-color-on-surface)",o.style.overflowWrap="normal",o.style.wordBreak="normal",o.style.hyphens="manual";const c=(o.textContent??"").replace(/\s+/g," ").trim();for(;o.firstChild;)o.removeChild(o.firstChild);const u=document.createElement("p");if(u.textContent=c,u.style.margin="0",this.dataSorting){const d=document.createElement("scb-icon-button");d.className="scb-sort-icon",d.onclick=()=>this._onThClick(i),d.setAttribute("variant","standard"),d.setAttribute("size","small"),d.style.alignSelf="end",this._sortedColumn===i?(d.setAttribute("variant","filled-tonal"),d.setAttribute("icon",this._sortDirection==="asc"?"arrow_downward":"arrow_upward")):(d.setAttribute("icon","swap_horiz"),d.style.transform+=" rotate(90deg)");const h=document.createElement("div");h.style.display="flex",h.style.gap="8px",h.style.flexWrap="nowrap",h.style.alignItems="center",h.appendChild(u),h.appendChild(d),o.appendChild(h)}else o.appendChild(u)}),l.forEach(o=>{o.style.padding="12px",o.style.textAlign="left",o.style.borderTop="1px solid var(--md-sys-color-outline-variant)",o.style.verticalAlign="text-top",o.style.backgroundColor="var(--md-sys-color-surface)",o.style.fontFamily="var(--md-sys-typescale-body-medium-font)",o.style.fontSize="var(--md-sys-typescale-body-medium-size)",o.style.lineHeight="var(--md-sys-typescale-body-medium-line-height)",o.style.fontWeight="var(--md-sys-typescale-body-medium-weight)",o.style.letterSpacing="var(--md-sys-typescale-body-medium-tracking)",o.style.borderRight="1px solid var(--md-sys-color-on-surface)",o.style.borderBottom="1px solid var(--md-sys-color-on-surface)",o.style.overflowWrap="normal",o.style.wordBreak="normal",o.style.hyphens="manual"}),a.forEach(o=>{const i=Array.from(o.cells);i.forEach((c,u)=>{c.style.borderRight=u===i.length-1?"none":"1px solid var(--md-sys-color-on-surface)"})});const n=this._getTbody();n&&Array.from(n.querySelectorAll("tr")).forEach((o,i)=>{const c=i%2===0?"var(--md-sys-color-surface-container)":"var(--md-sys-color-surface)";Array.from(o.cells).forEach(u=>{u.style.backgroundColor=c})}),this._queueColumnWidthUpdate()}_queueColumnWidthUpdate(){this._columnWidthFrame!==null&&cancelAnimationFrame(this._columnWidthFrame),this._columnWidthFrame=requestAnimationFrame(()=>{this._columnWidthFrame=null,this._applyColumnWidthMode()})}_applyColumnWidthMode(){this._getTables().forEach(e=>{if(this._removeGeneratedColGroup(e),e.style.tableLayout="",e.style.width="",e.style.minWidth="",e.style.maxWidth="",this.columnWidthMode!=="header")return;const s=Array.from(e.querySelectorAll("thead tr")),r=s[s.length-1];if(!r)return;const t=Array.from(r.cells).map((a,n)=>{const o=this._measureCellContentWidth(a),i=this._measureColumnReadableBodyWidth(e,n),c=Math.max(o,i);return`${Math.ceil(c>0?Math.max(c,w):0)}px`}),l=t.reduce((a,n)=>a+parseFloat(n),0);this._applyGeneratedColGroup(e,t),e.style.tableLayout="fixed",e.style.width=`${Math.ceil(l)}px`,e.style.minWidth=`${Math.ceil(l)}px`,e.style.maxWidth="none"})}_applyGeneratedColGroup(e,s){const r=document.createElement("colgroup");r.setAttribute("data-scb-generated-column-widths","true"),s.forEach(t=>{const l=document.createElement("col");l.style.width=t,l.style.minWidth=t,r.appendChild(l)}),e.insertBefore(r,e.firstChild)}_removeGeneratedColGroup(e){e.querySelector('colgroup[data-scb-generated-column-widths="true"]')?.remove()}_measureCellContentWidth(e){const s=e.firstElementChild?.cloneNode(!0)??document.createElement("span");e.firstElementChild||(s.textContent=e.textContent??"");const r=window.getComputedStyle(e),t=document.createElement("div");t.style.position="absolute",t.style.left="-99999px",t.style.top="0",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width="max-content",t.style.maxWidth="none",t.style.whiteSpace="nowrap",t.style.fontFamily=r.fontFamily,t.style.fontSize=r.fontSize,t.style.fontWeight=r.fontWeight,t.style.lineHeight=r.lineHeight,t.style.letterSpacing=r.letterSpacing,s instanceof HTMLElement&&(s.style.width="max-content",s.style.maxWidth="none",s.style.whiteSpace="nowrap"),t.appendChild(s),document.body.appendChild(t);const l=parseFloat(r.paddingLeft||"0"),a=parseFloat(r.paddingRight||"0"),n=parseFloat(r.borderLeftWidth||"0"),o=parseFloat(r.borderRightWidth||"0"),i=t.getBoundingClientRect().width+l+a+n+o;return document.body.removeChild(t),i}_measureColumnReadableBodyWidth(e,s){return Array.from(e.querySelectorAll("tbody tr")).reduce((r,t)=>{const l=t.cells[s];if(!l)return r;const a=(l.textContent??"").replace(/\s+/g," ").trim().split(" ").filter(Boolean).reduce((o,i)=>Math.max(o,this._measureCellTextWidth(l,i)),0),n=a>0?a+S:0;return Math.max(r,n)},0)}_measureCellTextWidth(e,s){const r=window.getComputedStyle(e),t=document.createElement("span");t.textContent=s,t.style.position="absolute",t.style.left="-99999px",t.style.top="0",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.fontFamily=r.fontFamily,t.style.fontSize=r.fontSize,t.style.fontWeight=r.fontWeight,t.style.lineHeight=r.lineHeight,t.style.letterSpacing=r.letterSpacing,document.body.appendChild(t);const l=parseFloat(r.paddingLeft||"0"),a=parseFloat(r.paddingRight||"0"),n=parseFloat(r.borderLeftWidth||"0"),o=parseFloat(r.borderRightWidth||"0"),i=t.getBoundingClientRect().width+l+a+n+o;return document.body.removeChild(t),i}_onThClick(e){this.dataSorting&&(this._sortedColumn===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortedColumn=e,this._sortDirection="asc"),this._sortTable(e,this._sortDirection),this._attachThListeners(),this.dispatchEvent(new CustomEvent("tablesortchange",{detail:{sortedColumn:this._sortedColumn,sortDirection:this._sortDirection},bubbles:!0,composed:!0})))}_sortTable(e,s){const r=this._getTbody();if(!r)return;const t=Array.from(r.querySelectorAll("tr"));t.sort((l,a)=>{const n=this._getCellSortableValue(l.children[e]),o=this._getCellSortableValue(a.children[e]);return this._compareCellValues(n,o,s)}),t.forEach(l=>r.appendChild(l))}_getCellSortableValue(e){if(!e)return"";const s=e,r=this._getSortableAttributeValue(s);if(r)return r;const t=[],l=s.textContent?.replace(/\s+/g," ").trim();return l&&t.push(l),s.querySelectorAll("[data-sort-value], [data-sort], [aria-label], [label], [value], [title]").forEach(a=>{const n=this._getSortableAttributeValue(a);n&&!t.includes(n)&&t.push(n)}),t.join(" ").trim()}_getSortableAttributeValue(e){return(e.getAttribute("data-sort-value")??e.getAttribute("data-sort")??e.getAttribute("aria-label")??e.getAttribute("label")??e.getAttribute("value")??e.getAttribute("title")??"").replace(/\s+/g," ").trim()}_compareCellValues(e,s,r){const t=this._parseSortableNumber(e),l=this._parseSortableNumber(s);if(t!==null&&l!==null)return r==="asc"?t-l:l-t;const a=Date.parse(e.replace(/\s+/g," ")),n=Date.parse(s.replace(/\s+/g," "));if(!isNaN(a)&&!isNaN(n))return r==="asc"?a-n:n-a;const o=e.localeCompare(s,"sv");return r==="asc"?o:-o}_parseSortableNumber(e){const s=e.trim();if(!/^[+-]?(?:\d+|\d{1,3}(?:[\s\u00a0\u202f]\d{3})+)(?:[,.]\d+)?$/.test(s))return null;const r=Number(s.replace(/[\s\u00a0\u202f]/g,"").replace(",","."));return Number.isNaN(r)?null:r}},p.styles=_`
|
|
6
|
-
:host {
|
|
7
|
-
display: block;
|
|
8
|
-
color: var(--md-sys-color-on-surface);
|
|
9
|
-
font-family: var(--brand-font, Inter, Arial, sans-serif);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.scb-table-scroll-wrapper {
|
|
13
|
-
width: 100%;
|
|
14
|
-
overflow-x: auto;
|
|
15
|
-
overflow-y: auto;
|
|
16
|
-
max-width: 100%;
|
|
17
|
-
padding-bottom: 24px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar {
|
|
21
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
22
|
-
height: 8px;
|
|
23
|
-
width: 10px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar-thumb {
|
|
27
|
-
background: var(--md-sys-color-on-surface);
|
|
28
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar-track {
|
|
33
|
-
background: var(--md-sys-color-secondary-container);
|
|
34
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
::slotted(table) {
|
|
38
|
-
border-collapse: collapse;
|
|
39
|
-
border-spacing: 0;
|
|
40
|
-
min-width: 100%;
|
|
41
|
-
overflow: hidden;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
::slotted(th) .scb-sort-icon {
|
|
45
|
-
pointer-events: none;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
::slotted(th:hover) .scb-sort-icon {
|
|
49
|
-
pointer-events: auto;
|
|
50
|
-
}
|
|
51
|
-
`,p);b([f({type:Boolean,attribute:"data-sorting"})],m.prototype,"dataSorting",void 0);b([f({type:String,attribute:"column-width-mode"})],m.prototype,"columnWidthMode",void 0);m=b([v("scb-table")],m);
|
|
5
|
+
`}firstUpdated(){const e=this.shadowRoot?.querySelector("slot");e&&(e.addEventListener("slotchange",()=>this._attachThListeners()),this._attachThListeners())}updated(e){e.has("dataSorting")&&(this.dataSorting||(this._sortedColumn=null,this._sortDirection="asc"),this._attachThListeners()),e.has("columnWidthMode")&&this._queueColumnWidthUpdate()}disconnectedCallback(){super.disconnectedCallback(),this._columnWidthFrame!==null&&(cancelAnimationFrame(this._columnWidthFrame),this._columnWidthFrame=null)}_getTbody(){const e=this.shadowRoot?.querySelector("slot");if(!e)return null;const s=e.assignedNodes({flatten:!0});for(const r of s)if(r.nodeType===Node.ELEMENT_NODE){const t=r,l=t.tagName.toLowerCase()==="tbody"?t:t.querySelector("tbody");if(l)return l}return null}_getTables(){const e=this.shadowRoot?.querySelector("slot");if(!e)return[];const s=e.assignedNodes({flatten:!0}),r=[];return s.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const l=t;l.tagName.toLowerCase()==="table"&&r.push(l),r.push(...Array.from(l.querySelectorAll("table")))}}),r}_attachThListeners(){const e=this.shadowRoot?.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0}),r=[],t=[],l=[],a=[];s.forEach(o=>{o.nodeType===Node.ELEMENT_NODE&&(r.push(...o.querySelectorAll("thead")),t.push(...o.querySelectorAll("th")),l.push(...o.querySelectorAll("td")),a.push(...o.querySelectorAll("tr")))}),r.forEach(o=>{o.style.borderTop="1px solid var(--md-sys-color-on-surface)"}),t.forEach((o,i)=>{o.style.textAlign="left",o.style.padding="12px",o.style.position="relative",o.style.backgroundColor="var(--md-sys-color-surface)",o.style.fontFamily="var(--md-sys-typescale-label-medium-font)",o.style.fontSize="var(--md-sys-typescale-label-medium-size)",o.style.lineHeight="var(--md-sys-typescale-label-medium-line-height)",o.style.fontWeight=" var(--weight-bold)",o.style.letterSpacing="var(--md-sys-typescale-label-medium-tracking)",o.style.verticalAlign="bottom",o.style.borderRight="1px solid var(--md-sys-color-on-surface)",o.style.borderBottom="1px solid var(--md-sys-color-on-surface)",o.style.overflowWrap="normal",o.style.wordBreak="normal",o.style.hyphens="manual";const c=(o.textContent??"").replace(/\s+/g," ").trim();for(;o.firstChild;)o.removeChild(o.firstChild);const u=document.createElement("p");if(u.textContent=c,u.style.margin="0",this.dataSorting){const d=document.createElement("scb-icon-button");d.className="scb-sort-icon",d.onclick=()=>this._onThClick(i),d.setAttribute("variant","standard"),d.setAttribute("size","small"),d.style.alignSelf="end",this._sortedColumn===i?(d.setAttribute("variant","filled-tonal"),d.setAttribute("icon",this._sortDirection==="asc"?"arrow_downward":"arrow_upward")):(d.setAttribute("icon","swap_horiz"),d.style.transform+=" rotate(90deg)");const h=document.createElement("div");h.style.display="flex",h.style.gap="8px",h.style.flexWrap="nowrap",h.style.alignItems="center",h.appendChild(u),h.appendChild(d),o.appendChild(h)}else o.appendChild(u)}),l.forEach(o=>{o.style.padding="12px",o.style.textAlign="left",o.style.borderTop="1px solid var(--md-sys-color-outline-variant)",o.style.verticalAlign="text-top",o.style.backgroundColor="var(--md-sys-color-surface)",o.style.fontFamily="var(--md-sys-typescale-body-medium-font)",o.style.fontSize="var(--md-sys-typescale-body-medium-size)",o.style.lineHeight="var(--md-sys-typescale-body-medium-line-height)",o.style.fontWeight="var(--md-sys-typescale-body-medium-weight)",o.style.letterSpacing="var(--md-sys-typescale-body-medium-tracking)",o.style.borderRight="1px solid var(--md-sys-color-on-surface)",o.style.borderBottom="1px solid var(--md-sys-color-on-surface)",o.style.overflowWrap="normal",o.style.wordBreak="normal",o.style.hyphens="manual"}),a.forEach(o=>{const i=Array.from(o.cells);i.forEach((c,u)=>{c.style.borderRight=u===i.length-1?"none":"1px solid var(--md-sys-color-on-surface)"})});const n=this._getTbody();n&&Array.from(n.querySelectorAll("tr")).forEach((o,i)=>{const c=i%2===0?"var(--md-sys-color-surface-container)":"var(--md-sys-color-surface)";Array.from(o.cells).forEach(u=>{u.style.backgroundColor=c})}),this._queueColumnWidthUpdate()}_queueColumnWidthUpdate(){this._columnWidthFrame!==null&&cancelAnimationFrame(this._columnWidthFrame),this._columnWidthFrame=requestAnimationFrame(()=>{this._columnWidthFrame=null,this._applyColumnWidthMode()})}_applyColumnWidthMode(){this._getTables().forEach(e=>{if(this._removeGeneratedColGroup(e),e.style.tableLayout="",e.style.width="",e.style.minWidth="",e.style.maxWidth="",this.columnWidthMode!=="header")return;const s=Array.from(e.querySelectorAll("thead tr")),r=s[s.length-1];if(!r)return;const t=Array.from(r.cells).map((a,n)=>{const o=this._measureCellContentWidth(a),i=this._measureColumnReadableBodyWidth(e,n),c=Math.max(o,i);return`${Math.ceil(c>0?Math.max(c,w):0)}px`}),l=t.reduce((a,n)=>a+parseFloat(n),0);this._applyGeneratedColGroup(e,t),e.style.tableLayout="fixed",e.style.width=`${Math.ceil(l)}px`,e.style.minWidth=`${Math.ceil(l)}px`,e.style.maxWidth="none"})}_applyGeneratedColGroup(e,s){const r=document.createElement("colgroup");r.setAttribute("data-scb-generated-column-widths","true"),s.forEach(t=>{const l=document.createElement("col");l.style.width=t,l.style.minWidth=t,r.appendChild(l)}),e.insertBefore(r,e.firstChild)}_removeGeneratedColGroup(e){e.querySelector('colgroup[data-scb-generated-column-widths="true"]')?.remove()}_measureCellContentWidth(e){const s=e.firstElementChild?.cloneNode(!0)??document.createElement("span");e.firstElementChild||(s.textContent=e.textContent??"");const r=window.getComputedStyle(e),t=document.createElement("div");t.style.position="absolute",t.style.left="-99999px",t.style.top="0",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.width="max-content",t.style.maxWidth="none",t.style.whiteSpace="nowrap",t.style.fontFamily=r.fontFamily,t.style.fontSize=r.fontSize,t.style.fontWeight=r.fontWeight,t.style.lineHeight=r.lineHeight,t.style.letterSpacing=r.letterSpacing,s instanceof HTMLElement&&(s.style.width="max-content",s.style.maxWidth="none",s.style.whiteSpace="nowrap"),t.appendChild(s),document.body.appendChild(t);const l=parseFloat(r.paddingLeft||"0"),a=parseFloat(r.paddingRight||"0"),n=parseFloat(r.borderLeftWidth||"0"),o=parseFloat(r.borderRightWidth||"0"),i=t.getBoundingClientRect().width+l+a+n+o;return document.body.removeChild(t),i}_measureColumnReadableBodyWidth(e,s){return Array.from(e.querySelectorAll("tbody tr")).reduce((r,t)=>{const l=t.cells[s];if(!l)return r;const a=(l.textContent??"").replace(/\s+/g," ").trim().split(" ").filter(Boolean).reduce((o,i)=>Math.max(o,this._measureCellTextWidth(l,i)),0),n=a>0?a+S:0;return Math.max(r,n)},0)}_measureCellTextWidth(e,s){const r=window.getComputedStyle(e),t=document.createElement("span");t.textContent=s,t.style.position="absolute",t.style.left="-99999px",t.style.top="0",t.style.visibility="hidden",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.fontFamily=r.fontFamily,t.style.fontSize=r.fontSize,t.style.fontWeight=r.fontWeight,t.style.lineHeight=r.lineHeight,t.style.letterSpacing=r.letterSpacing,document.body.appendChild(t);const l=parseFloat(r.paddingLeft||"0"),a=parseFloat(r.paddingRight||"0"),n=parseFloat(r.borderLeftWidth||"0"),o=parseFloat(r.borderRightWidth||"0"),i=t.getBoundingClientRect().width+l+a+n+o;return document.body.removeChild(t),i}_onThClick(e){this.dataSorting&&(this._sortedColumn===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortedColumn=e,this._sortDirection="asc"),this._sortTable(e,this._sortDirection),this._attachThListeners(),this.dispatchEvent(new CustomEvent("tablesortchange",{detail:{sortedColumn:this._sortedColumn,sortDirection:this._sortDirection},bubbles:!0,composed:!0})))}_sortTable(e,s){const r=this._getTbody();if(!r)return;const t=Array.from(r.querySelectorAll("tr"));t.sort((l,a)=>{const n=this._getCellSortableValue(l.children[e]),o=this._getCellSortableValue(a.children[e]);return this._compareCellValues(n,o,s)}),t.forEach(l=>r.appendChild(l))}_getCellSortableValue(e){if(!e)return"";const s=e,r=this._getSortableAttributeValue(s);if(r)return r;const t=[],l=s.textContent?.replace(/\s+/g," ").trim();return l&&t.push(l),s.querySelectorAll("[data-sort-value], [data-sort], [aria-label], [label], [value], [title]").forEach(a=>{const n=this._getSortableAttributeValue(a);n&&!t.includes(n)&&t.push(n)}),t.join(" ").trim()}_getSortableAttributeValue(e){return(e.getAttribute("data-sort-value")??e.getAttribute("data-sort")??e.getAttribute("aria-label")??e.getAttribute("label")??e.getAttribute("value")??e.getAttribute("title")??"").replace(/\s+/g," ").trim()}_compareCellValues(e,s,r){const t=this._parseSortableNumber(e),l=this._parseSortableNumber(s);if(t!==null&&l!==null)return r==="asc"?t-l:l-t;const a=Date.parse(e.replace(/\s+/g," ")),n=Date.parse(s.replace(/\s+/g," "));if(!isNaN(a)&&!isNaN(n))return r==="asc"?a-n:n-a;const o=e.localeCompare(s,"sv");return r==="asc"?o:-o}_parseSortableNumber(e){const s=e.trim();if(!/^[+-]?(?:\d+|\d{1,3}(?:[\s\u00a0\u202f]\d{3})+)(?:[,.]\d+)?$/.test(s))return null;const r=Number(s.replace(/[\s\u00a0\u202f]/g,"").replace(",","."));return Number.isNaN(r)?null:r}},p.styles=C`:host{display:block;color:var(--md-sys-color-on-surface);font-family:var(--brand-font, Inter, Arial, sans-serif)}.scb-table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:auto;max-width:100%;padding-bottom:24px}.scb-table-scroll-wrapper::-webkit-scrollbar{border-radius:var(--md-sys-shape-corner-large);height:8px;width:10px}.scb-table-scroll-wrapper::-webkit-scrollbar-thumb{background:var(--md-sys-color-on-surface);border-radius:var(--md-sys-shape-corner-large);cursor:pointer}.scb-table-scroll-wrapper::-webkit-scrollbar-track{background:var(--md-sys-color-secondary-container);border-radius:var(--md-sys-shape-corner-large)}::slotted(table){border-collapse:collapse;border-spacing:0;min-width:100%;overflow:hidden}::slotted(th) .scb-sort-icon{pointer-events:none}::slotted(th:hover) .scb-sort-icon{pointer-events:auto}`,p);f([b({type:Boolean,attribute:"data-sorting"})],m.prototype,"dataSorting",void 0);f([b({type:String,attribute:"column-width-mode"})],m.prototype,"columnWidthMode",void 0);m=f([_("scb-table")],m);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as _,m,p as b,v as p,y as v}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.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 f=typeof globalThis<"u"?globalThis:window;if(!f.__scb_ce_guard_installed__){f.__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(t){var a=String(t||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw t}}}}catch{}})();var y,d=(y=class extends _{constructor(...e){super(...e),this.searchTerm="",this.pagination=!1,this.filteringSearch=!1,this.noScroll=!1,this.pageSize=10,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._onSlotChange=()=>{this._attachTbodyObserver(),this._refreshFromTableContent()},this._onPaginationChange=s=>{const r=s.detail;r&&typeof r.page=="number"&&this._changePage(r.page)}}disconnectedCallback(){super.disconnectedCallback(),this._disconnectTbodyObserver()}attributeChangedCallback(e,s,r){if(super.attributeChangedCallback(e,s,r),s!==r){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 p`
|
|
2
2
|
${this.filteringSearch?p`
|
|
3
3
|
<div style="margin-bottom: 12px;">
|
|
4
4
|
<scb-search
|
|
@@ -22,55 +22,4 @@ import{_,b as m,g as v,h as b,y as p}from"../../vendor/vendor.js";import"../../v
|
|
|
22
22
|
></scb-pagination>
|
|
23
23
|
`:""}
|
|
24
24
|
</div>
|
|
25
|
-
`}_onSearchInput(e){const s=e.target.value;this.searchTerm=s,this._filterTable(),this.dispatchEvent(new CustomEvent("tableadvancedchange",{detail:{searchTerm:this.searchTerm,currentPage:this.currentPage},bubbles:!0,composed:!0}))}_filterTable(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;if(s.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const o=i.querySelector("tbody");o&&(r=o)}}),!r)return;const a=Array.from(r.querySelectorAll("tr")),t=this.searchTerm.trim().toLowerCase();if(!t)this._filteredRows=null,a.forEach(i=>i.style.display=""),this._updateTotalRows(),this._ensureCurrentPageWithinBounds(),this.pagination&&this._paginateTable(),this._sortedColumn!==null&&this._sortTable(this._sortedColumn,this._sortDirection);else{this._filteredRows=a.filter(o=>this._getRowSearchText(o).toLowerCase().includes(t)),a.forEach(o=>o.style.display="none");let i=this._filteredRows;this._sortedColumn!==null&&(i=[...i],i.sort((o,c)=>{const h=this._getCellSortableValue(o.children[this._sortedColumn]),n=this._getCellSortableValue(c.children[this._sortedColumn]);return this._compareCellValues(h,n,this._sortDirection)}),this._filteredRows=i),this.totalRows=this._filteredRows.length,this._ensureCurrentPageWithinBounds(),this.pagination?this._paginateTable():this._filteredRows.forEach(o=>o.style.display="")}}firstUpdated(){const e=this.shadowRoot.querySelector("slot");e&&(e.addEventListener("slotchange",()=>this._attachThListeners()),this._attachThListeners(),this._attachTbodyObserver(),this._refreshFromTableContent())}updated(e){super.updated(e),(e.has("searchTerm")||e.has("currentPage")||e.has("pageSize")||e.has("filteringSearch")||e.has("pagination"))&&this.updateComplete.then(()=>{this.isConnected&&this._refreshFromTableContent()})}_disconnectTbodyObserver(){this._tbodyObserver&&(this._tbodyObserver.disconnect(),this._tbodyObserver=null),this._observedTbody=null}_attachTbodyObserver(){const e=this._getTbody();if(!e){this._disconnectTbodyObserver();return}this._observedTbody!==e&&(this._disconnectTbodyObserver(),this._observedTbody=e,this._tbodyObserver=new MutationObserver(()=>{this._suppressTbodyObserver||this._scheduleTableRefresh()}),this._tbodyObserver.observe(e,{childList:!0,subtree:!0,characterData:!0}))}_scheduleTableRefresh(){this._pendingTableRefresh||(this._pendingTableRefresh=!0,queueMicrotask(()=>{this._pendingTableRefresh=!1,this._refreshFromTableContent()}))}_refreshFromTableContent(){if(this._attachTbodyObserver(),this.filteringSearch){this._filterTable();return}if(this._updateTotalRows(),this._ensureCurrentPageWithinBounds(),this._sortedColumn!==null){this._sortTable(this._sortedColumn,this._sortDirection);return}this.pagination&&this._paginateTable()}_ensureCurrentPageWithinBounds(){const e=Math.max(1,Math.ceil(this.totalRows/this.pageSize)),s=Math.min(Math.max(1,this.currentPage),e);s!==this.currentPage&&(this.currentPage=s)}_getTbody(){const e=this.shadowRoot.querySelector("slot");if(!e)return null;const s=e.assignedNodes({flatten:!0});for(const r of s)if(r.nodeType===Node.ELEMENT_NODE){const l=r.querySelector("tbody");if(l)return l}return null}_attachThListeners(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0}),r=[],l=[],a=[];s.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&(r.push(...t.querySelectorAll("th")),l.push(...t.querySelectorAll("td")),a.push(...t.querySelectorAll("tr")))}),r.forEach((t,i)=>{t.style.textAlign="left",t.style.padding="16px 0px 16px 32px",t.style.position="relative",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-label-medium-font)",t.style.fontSize="var(--md-sys-typescale-label-medium-size)",t.style.lineHeight="var(--md-sys-typescale-label-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-label-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-label-medium-tracking)",t.style.verticalAlign="bottom";const o=t.firstChild;if(o&&o.nodeType===Node.TEXT_NODE&&o.textContent?.trim()||o&&o.nodeType===Node.ELEMENT_NODE&&o.tagName.toLowerCase()!=="p"){const h=document.createElement("p");h.textContent=o.textContent?o.textContent.trim():"",h.style.margin="0",t.replaceChild(h,o),t.querySelectorAll("scb-icon-button.scb-sort-icon").forEach(g=>g.remove());const n=document.createElement("scb-icon-button");n.className="scb-sort-icon",n.onclick=()=>this._onThClick(i),n.setAttribute("variant","standard"),n.setAttribute("size","small"),this._sortedColumn===i?(n.setAttribute("variant","filled-tonal"),n.setAttribute("icon",this._sortDirection==="asc"?"arrow_downward":"arrow_upward")):(n.setAttribute("icon","swap_horiz"),n.style.transform+=" rotate(90deg)",n.style.alignSelf="end");var c=document.createElement("div");c.style.display="flex",c.style.gap="8px",c.style.flexWrap="nowrap",c.style.alignItems="center",c.appendChild(h),c.appendChild(n),t.appendChild(c)}}),l.forEach(t=>{t.style.padding="16px 0px 16px 32px",t.style.textAlign="left",t.style.borderTop="1px solid var(--md-sys-color-outline-variant)",t.style.verticalAlign="text-top",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-body-medium-font)",t.style.fontSize="var(--md-sys-typescale-body-medium-size)",t.style.lineHeight="var(--md-sys-typescale-body-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-body-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-body-medium-tracking)"}),a.forEach((t,i)=>{i%2===1&&t.querySelectorAll("td").forEach(h=>{h.style.backgroundColor="var(--scb-background-row)"});const o=t.querySelectorAll("th");o.length>0&&o.forEach((h,n)=>{n===0&&(h.style.paddingLeft="24px"),n===o.length-1?h.style.paddingRight="24px":h.style.paddingRight=""});const c=t.querySelectorAll("td");c.length>0&&c.forEach((h,n)=>{n===0&&(h.style.paddingLeft="24px"),n===c.length-1?h.style.paddingRight="24px":h.style.paddingRight=""})}),this.pagination&&this._paginateTable()}_onThClick(e){this._sortedColumn===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortedColumn=e,this._sortDirection="asc"),this._sortTable(e,this._sortDirection),this._attachThListeners()}_sortTable(e,s){const r=this.shadowRoot.querySelector("slot");if(!r)return;const l=r.assignedNodes({flatten:!0});let a=null;if(l.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE){const c=o.querySelector("tbody");c&&(a=c)}}),!a)return;let t;this._filteredRows?t=[...this._filteredRows]:t=Array.from(a.querySelectorAll("tr")),t.sort((o,c)=>{const h=this._getCellSortableValue(o.children[e]),n=this._getCellSortableValue(c.children[e]);return this._compareCellValues(h,n,s)});const i=this._tbodyObserver!==null;i&&this._disconnectTbodyObserver();try{t.forEach(o=>a.appendChild(o))}finally{i&&this._attachTbodyObserver()}this._filteredRows&&(this._filteredRows=t,this.totalRows=this._filteredRows.length),this.pagination&&this._paginateTable()}_getRowSearchText(e){return Array.from(e.cells).map(s=>this._getCellSortableValue(s)).join(" ")}_getCellSortableValue(e){if(!e)return"";const s=e,r=this._getSortableAttributeValue(s);if(r)return r;const l=[],a=s.textContent?.replace(/\s+/g," ").trim();return a&&l.push(a),s.querySelectorAll("[data-sort-value], [data-sort], [aria-label], [label], [value], [title]").forEach(t=>{const i=this._getSortableAttributeValue(t);i&&!l.includes(i)&&l.push(i)}),l.join(" ").trim()}_getSortableAttributeValue(e){return(e.getAttribute("data-sort-value")??e.getAttribute("data-sort")??e.getAttribute("aria-label")??e.getAttribute("label")??e.getAttribute("value")??e.getAttribute("title")??"").replace(/\s+/g," ").trim()}_compareCellValues(e,s,r){const l=this._parseSortableNumber(e),a=this._parseSortableNumber(s);if(l!==null&&a!==null)return r==="asc"?l-a:a-l;const t=Date.parse(e.replace(/\s+/g," ")),i=Date.parse(s.replace(/\s+/g," "));if(!isNaN(t)&&!isNaN(i))return r==="asc"?t-i:i-t;const o=e.localeCompare(s,"sv");return r==="asc"?o:-o}_parseSortableNumber(e){const s=e.trim();if(!/^[+-]?(?:\d+|\d{1,3}(?:[\s\u00a0\u202f]\d{3})+)(?:[,.]\d+)?$/.test(s))return null;const r=Number(s.replace(/[\s\u00a0\u202f]/g,"").replace(",","."));return Number.isNaN(r)?null:r}_updateTotalRows(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;s.forEach(l=>{if(l.nodeType===Node.ELEMENT_NODE){const a=l.querySelector("tbody");a&&(r=a)}}),r&&(this.totalRows=r.querySelectorAll("tr").length,this._ensureCurrentPageWithinBounds())}_paginateTable(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;if(s.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const o=i.querySelector("tbody");o&&(r=o)}}),!r)return;let l;this._filteredRows?l=this._filteredRows:l=Array.from(r.querySelectorAll("tr")),Array.from(r.querySelectorAll("tr")).forEach(i=>i.style.display="none");const a=(this.currentPage-1)*this.pageSize,t=a+this.pageSize;l.slice(a,t).forEach(i=>i.style.display="")}_changePage(e){const s=Math.ceil(this.totalRows/this.pageSize);e<1||e>s||(this.currentPage=e,this._paginateTable(),this.dispatchEvent(new CustomEvent("tableadvancedchange",{detail:{searchTerm:this.searchTerm,currentPage:this.currentPage},bubbles:!0,composed:!0})),this.requestUpdate())}},y.styles=m`
|
|
26
|
-
:host {
|
|
27
|
-
display: block;
|
|
28
|
-
color: var(--md-sys-color-on-surface);
|
|
29
|
-
font-family: var(--brand-font, Inter, Arial, sans-serif);
|
|
30
|
-
--scb-background-row: var(--md-sys-color-surface);
|
|
31
|
-
}
|
|
32
|
-
scb-search{
|
|
33
|
-
max-width: 400px;
|
|
34
|
-
}
|
|
35
|
-
.scb-table-scroll-wrapper {
|
|
36
|
-
width: 100%;
|
|
37
|
-
overflow-x: auto;
|
|
38
|
-
overflow-y: auto;
|
|
39
|
-
max-width: 100%;
|
|
40
|
-
padding-bottom: 24px;
|
|
41
|
-
/* Optional: set max-height if you want vertical scroll */
|
|
42
|
-
}
|
|
43
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar {
|
|
44
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
45
|
-
height: 8px;
|
|
46
|
-
width: 10px;
|
|
47
|
-
}
|
|
48
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar-thumb {
|
|
49
|
-
background: var(--md-sys-color-on-surface);
|
|
50
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
}
|
|
53
|
-
.scb-table-scroll-wrapper::-webkit-scrollbar-track {
|
|
54
|
-
background: var(--md-sys-color-secondary-container);
|
|
55
|
-
border-radius: var(--md-sys-shape-corner-large);
|
|
56
|
-
}
|
|
57
|
-
::slotted(table) {
|
|
58
|
-
border-collapse: collapse;
|
|
59
|
-
border-spacing: 0;
|
|
60
|
-
border-radius: 24px;
|
|
61
|
-
min-width: 100%;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
/* Remove overflow: hidden to allow scroll */
|
|
64
|
-
}
|
|
65
|
-
.pagination {
|
|
66
|
-
margin-top: 16px;
|
|
67
|
-
display: flex;
|
|
68
|
-
justify-self: center;
|
|
69
|
-
}
|
|
70
|
-
::slotted(th) .scb-sort-icon {
|
|
71
|
-
pointer-events: none;
|
|
72
|
-
}
|
|
73
|
-
::slotted(th:hover) .scb-sort-icon {
|
|
74
|
-
pointer-events: auto;
|
|
75
|
-
}
|
|
76
|
-
`,y);u([b({type:String})],d.prototype,"searchTerm",void 0);u([b({type:Boolean,attribute:"with-pagination"})],d.prototype,"pagination",void 0);u([b({type:Boolean,attribute:"with-filtering-search"})],d.prototype,"filteringSearch",void 0);u([b({type:Boolean,attribute:"no-scroll"})],d.prototype,"noScroll",void 0);u([b({type:Number,attribute:"page-size"})],d.prototype,"pageSize",void 0);u([b({type:Number})],d.prototype,"currentPage",void 0);u([b({type:Number})],d.prototype,"totalRows",void 0);d=u([v("scb-table-advanced")],d);
|
|
25
|
+
`}_onSearchInput(e){const s=e.target.value;this.searchTerm=s,this._filterTable(),this.dispatchEvent(new CustomEvent("tableadvancedchange",{detail:{searchTerm:this.searchTerm,currentPage:this.currentPage},bubbles:!0,composed:!0}))}_filterTable(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;if(s.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const o=i.querySelector("tbody");o&&(r=o)}}),!r)return;const a=Array.from(r.querySelectorAll("tr")),t=this.searchTerm.trim().toLowerCase();if(!t)this._filteredRows=null,a.forEach(i=>i.style.display=""),this._updateTotalRows(),this._ensureCurrentPageWithinBounds(),this.pagination&&this._paginateTable(),this._sortedColumn!==null&&this._sortTable(this._sortedColumn,this._sortDirection);else{this._filteredRows=a.filter(o=>this._getRowSearchText(o).toLowerCase().includes(t)),a.forEach(o=>o.style.display="none");let i=this._filteredRows;this._sortedColumn!==null&&(i=[...i],i.sort((o,c)=>{const h=this._getCellSortableValue(o.children[this._sortedColumn]),n=this._getCellSortableValue(c.children[this._sortedColumn]);return this._compareCellValues(h,n,this._sortDirection)}),this._filteredRows=i),this.totalRows=this._filteredRows.length,this._ensureCurrentPageWithinBounds(),this.pagination?this._paginateTable():this._filteredRows.forEach(o=>o.style.display="")}}firstUpdated(){const e=this.shadowRoot.querySelector("slot");e&&(e.addEventListener("slotchange",()=>this._attachThListeners()),this._attachThListeners(),this._attachTbodyObserver(),this._refreshFromTableContent())}updated(e){super.updated(e),(e.has("searchTerm")||e.has("currentPage")||e.has("pageSize")||e.has("filteringSearch")||e.has("pagination"))&&this.updateComplete.then(()=>{this.isConnected&&this._refreshFromTableContent()})}_disconnectTbodyObserver(){this._tbodyObserver&&(this._tbodyObserver.disconnect(),this._tbodyObserver=null),this._observedTbody=null}_attachTbodyObserver(){const e=this._getTbody();if(!e){this._disconnectTbodyObserver();return}this._observedTbody!==e&&(this._disconnectTbodyObserver(),this._observedTbody=e,this._tbodyObserver=new MutationObserver(()=>{this._suppressTbodyObserver||this._scheduleTableRefresh()}),this._tbodyObserver.observe(e,{childList:!0,subtree:!0,characterData:!0}))}_scheduleTableRefresh(){this._pendingTableRefresh||(this._pendingTableRefresh=!0,queueMicrotask(()=>{this._pendingTableRefresh=!1,this._refreshFromTableContent()}))}_refreshFromTableContent(){if(this._attachTbodyObserver(),this.filteringSearch){this._filterTable();return}if(this._updateTotalRows(),this._ensureCurrentPageWithinBounds(),this._sortedColumn!==null){this._sortTable(this._sortedColumn,this._sortDirection);return}this.pagination&&this._paginateTable()}_ensureCurrentPageWithinBounds(){const e=Math.max(1,Math.ceil(this.totalRows/this.pageSize)),s=Math.min(Math.max(1,this.currentPage),e);s!==this.currentPage&&(this.currentPage=s)}_getTbody(){const e=this.shadowRoot.querySelector("slot");if(!e)return null;const s=e.assignedNodes({flatten:!0});for(const r of s)if(r.nodeType===Node.ELEMENT_NODE){const l=r.querySelector("tbody");if(l)return l}return null}_attachThListeners(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0}),r=[],l=[],a=[];s.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&(r.push(...t.querySelectorAll("th")),l.push(...t.querySelectorAll("td")),a.push(...t.querySelectorAll("tr")))}),r.forEach((t,i)=>{t.style.textAlign="left",t.style.padding="16px 0px 16px 32px",t.style.position="relative",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-label-medium-font)",t.style.fontSize="var(--md-sys-typescale-label-medium-size)",t.style.lineHeight="var(--md-sys-typescale-label-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-label-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-label-medium-tracking)",t.style.verticalAlign="bottom";const o=t.firstChild;if(o&&o.nodeType===Node.TEXT_NODE&&o.textContent?.trim()||o&&o.nodeType===Node.ELEMENT_NODE&&o.tagName.toLowerCase()!=="p"){const h=document.createElement("p");h.textContent=o.textContent?o.textContent.trim():"",h.style.margin="0",t.replaceChild(h,o),t.querySelectorAll("scb-icon-button.scb-sort-icon").forEach(g=>g.remove());const n=document.createElement("scb-icon-button");n.className="scb-sort-icon",n.onclick=()=>this._onThClick(i),n.setAttribute("variant","standard"),n.setAttribute("size","small"),this._sortedColumn===i?(n.setAttribute("variant","filled-tonal"),n.setAttribute("icon",this._sortDirection==="asc"?"arrow_downward":"arrow_upward")):(n.setAttribute("icon","swap_horiz"),n.style.transform+=" rotate(90deg)",n.style.alignSelf="end");var c=document.createElement("div");c.style.display="flex",c.style.gap="8px",c.style.flexWrap="nowrap",c.style.alignItems="center",c.appendChild(h),c.appendChild(n),t.appendChild(c)}}),l.forEach(t=>{t.style.padding="16px 0px 16px 32px",t.style.textAlign="left",t.style.borderTop="1px solid var(--md-sys-color-outline-variant)",t.style.verticalAlign="text-top",t.style.backgroundColor="var(--md-sys-color-surface)",t.style.fontFamily="var(--md-sys-typescale-body-medium-font)",t.style.fontSize="var(--md-sys-typescale-body-medium-size)",t.style.lineHeight="var(--md-sys-typescale-body-medium-line-height)",t.style.fontWeight="var(--md-sys-typescale-body-medium-weight)",t.style.letterSpacing="var(--md-sys-typescale-body-medium-tracking)"}),a.forEach((t,i)=>{i%2===1&&t.querySelectorAll("td").forEach(h=>{h.style.backgroundColor="var(--scb-background-row)"});const o=t.querySelectorAll("th");o.length>0&&o.forEach((h,n)=>{n===0&&(h.style.paddingLeft="24px"),n===o.length-1?h.style.paddingRight="24px":h.style.paddingRight=""});const c=t.querySelectorAll("td");c.length>0&&c.forEach((h,n)=>{n===0&&(h.style.paddingLeft="24px"),n===c.length-1?h.style.paddingRight="24px":h.style.paddingRight=""})}),this.pagination&&this._paginateTable()}_onThClick(e){this._sortedColumn===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortedColumn=e,this._sortDirection="asc"),this._sortTable(e,this._sortDirection),this._attachThListeners()}_sortTable(e,s){const r=this.shadowRoot.querySelector("slot");if(!r)return;const l=r.assignedNodes({flatten:!0});let a=null;if(l.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE){const c=o.querySelector("tbody");c&&(a=c)}}),!a)return;let t;this._filteredRows?t=[...this._filteredRows]:t=Array.from(a.querySelectorAll("tr")),t.sort((o,c)=>{const h=this._getCellSortableValue(o.children[e]),n=this._getCellSortableValue(c.children[e]);return this._compareCellValues(h,n,s)});const i=this._tbodyObserver!==null;i&&this._disconnectTbodyObserver();try{t.forEach(o=>a.appendChild(o))}finally{i&&this._attachTbodyObserver()}this._filteredRows&&(this._filteredRows=t,this.totalRows=this._filteredRows.length),this.pagination&&this._paginateTable()}_getRowSearchText(e){return Array.from(e.cells).map(s=>this._getCellSortableValue(s)).join(" ")}_getCellSortableValue(e){if(!e)return"";const s=e,r=this._getSortableAttributeValue(s);if(r)return r;const l=[],a=s.textContent?.replace(/\s+/g," ").trim();return a&&l.push(a),s.querySelectorAll("[data-sort-value], [data-sort], [aria-label], [label], [value], [title]").forEach(t=>{const i=this._getSortableAttributeValue(t);i&&!l.includes(i)&&l.push(i)}),l.join(" ").trim()}_getSortableAttributeValue(e){return(e.getAttribute("data-sort-value")??e.getAttribute("data-sort")??e.getAttribute("aria-label")??e.getAttribute("label")??e.getAttribute("value")??e.getAttribute("title")??"").replace(/\s+/g," ").trim()}_compareCellValues(e,s,r){const l=this._parseSortableNumber(e),a=this._parseSortableNumber(s);if(l!==null&&a!==null)return r==="asc"?l-a:a-l;const t=Date.parse(e.replace(/\s+/g," ")),i=Date.parse(s.replace(/\s+/g," "));if(!isNaN(t)&&!isNaN(i))return r==="asc"?t-i:i-t;const o=e.localeCompare(s,"sv");return r==="asc"?o:-o}_parseSortableNumber(e){const s=e.trim();if(!/^[+-]?(?:\d+|\d{1,3}(?:[\s\u00a0\u202f]\d{3})+)(?:[,.]\d+)?$/.test(s))return null;const r=Number(s.replace(/[\s\u00a0\u202f]/g,"").replace(",","."));return Number.isNaN(r)?null:r}_updateTotalRows(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;s.forEach(l=>{if(l.nodeType===Node.ELEMENT_NODE){const a=l.querySelector("tbody");a&&(r=a)}}),r&&(this.totalRows=r.querySelectorAll("tr").length,this._ensureCurrentPageWithinBounds())}_paginateTable(){const e=this.shadowRoot.querySelector("slot");if(!e)return;const s=e.assignedNodes({flatten:!0});let r=null;if(s.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const o=i.querySelector("tbody");o&&(r=o)}}),!r)return;let l;this._filteredRows?l=this._filteredRows:l=Array.from(r.querySelectorAll("tr")),Array.from(r.querySelectorAll("tr")).forEach(i=>i.style.display="none");const a=(this.currentPage-1)*this.pageSize,t=a+this.pageSize;l.slice(a,t).forEach(i=>i.style.display="")}_changePage(e){const s=Math.ceil(this.totalRows/this.pageSize);e<1||e>s||(this.currentPage=e,this._paginateTable(),this.dispatchEvent(new CustomEvent("tableadvancedchange",{detail:{searchTerm:this.searchTerm,currentPage:this.currentPage},bubbles:!0,composed:!0})),this.requestUpdate())}},y.styles=v`:host{display:block;color:var(--md-sys-color-on-surface);font-family:var(--brand-font, Inter, Arial, sans-serif);--scb-background-row:var(--md-sys-color-surface)}scb-search{max-width:400px}.scb-table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:auto;max-width:100%;padding-bottom:24px}.scb-table-scroll-wrapper::-webkit-scrollbar{border-radius:var(--md-sys-shape-corner-large);height:8px;width:10px}.scb-table-scroll-wrapper::-webkit-scrollbar-thumb{background:var(--md-sys-color-on-surface);border-radius:var(--md-sys-shape-corner-large);cursor:pointer}.scb-table-scroll-wrapper::-webkit-scrollbar-track{background:var(--md-sys-color-secondary-container);border-radius:var(--md-sys-shape-corner-large)}::slotted(table){border-collapse:collapse;border-spacing:0;border-radius:24px;min-width:100%;overflow:hidden}.pagination{margin-top:16px;display:flex;justify-self:center}::slotted(th) .scb-sort-icon{pointer-events:none}::slotted(th:hover) .scb-sort-icon{pointer-events:auto}`,y);u([b({type:String})],d.prototype,"searchTerm",void 0);u([b({type:Boolean,attribute:"with-pagination"})],d.prototype,"pagination",void 0);u([b({type:Boolean,attribute:"with-filtering-search"})],d.prototype,"filteringSearch",void 0);u([b({type:Boolean,attribute:"no-scroll"})],d.prototype,"noScroll",void 0);u([b({type:Number,attribute:"page-size"})],d.prototype,"pageSize",void 0);u([b({type:Number})],d.prototype,"currentPage",void 0);u([b({type:Number})],d.prototype,"totalRows",void 0);d=u([m("scb-table-advanced")],d);
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,
|
|
3
|
-
/* Icon-only: dölj textslot */
|
|
4
|
-
:host([icon-only]) slot:not([name='icon']) {
|
|
5
|
-
display: none;
|
|
6
|
-
}
|
|
7
|
-
`],c);s([i({type:String})],e.prototype,"icon",null);s([i({type:Boolean,reflect:!0,attribute:"icon-only"})],e.prototype,"iconOnly",void 0);s([i({type:Boolean,reflect:!0,attribute:"inline-icon"})],e.prototype,"inlineIcon",void 0);e=s([m("scb-primary-tab")],e);
|
|
1
|
+
import{m,p as i,s as d,y as p}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as s}from"../../vendor/decorate.js";import{r as h,t as _}from"../../vendor/tab-styles.js";(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var a=customElements.define.bind(customElements);customElements.define=function(r,v,b){try{customElements.get(r)||a(r,v,b)}catch(l){var n=String(l||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var y=class extends h{constructor(){super(...arguments),this.inlineIcon=!1}getContentClasses(){return{...super.getContentClasses(),stacked:!this.inlineIcon}}};d([i({type:Boolean,attribute:"inline-icon"})],y.prototype,"inlineIcon",void 0);var u=p`:host{--_active-indicator-color: var(--md-primary-tab-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_active-indicator-height: var(--md-primary-tab-active-indicator-height, 3px);--_active-indicator-shape: var(--md-primary-tab-active-indicator-shape, 3px 3px 0px 0px);--_active-hover-state-layer-color: var(--md-primary-tab-active-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_active-hover-state-layer-opacity: var(--md-primary-tab-active-hover-state-layer-opacity, 0.08);--_active-pressed-state-layer-color: var(--md-primary-tab-active-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_active-pressed-state-layer-opacity: var(--md-primary-tab-active-pressed-state-layer-opacity, 0.12);--_container-color: var(--md-primary-tab-container-color, var(--md-sys-color-surface, #fef7ff));--_container-elevation: var(--md-primary-tab-container-elevation, 0);--_container-height: var(--md-primary-tab-container-height, 48px);--_with-icon-and-label-text-container-height: var(--md-primary-tab-with-icon-and-label-text-container-height, 64px);--_hover-state-layer-color: var(--md-primary-tab-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-primary-tab-hover-state-layer-opacity, 0.08);--_pressed-state-layer-color: var(--md-primary-tab-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_pressed-state-layer-opacity: var(--md-primary-tab-pressed-state-layer-opacity, 0.12);--_active-focus-icon-color: var(--md-primary-tab-active-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_active-hover-icon-color: var(--md-primary-tab-active-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_active-icon-color: var(--md-primary-tab-active-icon-color, var(--md-sys-color-primary, #6750a4));--_active-pressed-icon-color: var(--md-primary-tab-active-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-primary-tab-icon-size, 24px);--_focus-icon-color: var(--md-primary-tab-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-icon-color: var(--md-primary-tab-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_icon-color: var(--md-primary-tab-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-icon-color: var(--md-primary-tab-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-primary-tab-label-text-font, var(--md-sys-typescale-title-small-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-primary-tab-label-text-line-height, var(--md-sys-typescale-title-small-line-height, 1.25rem));--_label-text-size: var(--md-primary-tab-label-text-size, var(--md-sys-typescale-title-small-size, 0.875rem));--_label-text-weight: var(--md-primary-tab-label-text-weight, var(--md-sys-typescale-title-small-weight, var(--md-ref-typeface-weight-medium, 500)));--_active-focus-label-text-color: var(--md-primary-tab-active-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_active-hover-label-text-color: var(--md-primary-tab-active-hover-label-text-color, var(--md-sys-color-primary, #6750a4));--_active-label-text-color: var(--md-primary-tab-active-label-text-color, var(--md-sys-color-primary, #6750a4));--_active-pressed-label-text-color: var(--md-primary-tab-active-pressed-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-label-text-color: var(--md-primary-tab-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-primary-tab-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-color: var(--md-primary-tab-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-label-text-color: var(--md-primary-tab-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_container-shape-start-start: var(--md-primary-tab-container-shape-start-start, var(--md-primary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-start-end: var(--md-primary-tab-container-shape-start-end, var(--md-primary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-end: var(--md-primary-tab-container-shape-end-end, var(--md-primary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-start: var(--md-primary-tab-container-shape-end-start, var(--md-primary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)))}.content.stacked{flex-direction:column;gap:2px}.content.stacked.has-icon.has-label{height:var(--_with-icon-and-label-text-container-height)}
|
|
2
|
+
`,t=class extends y{};t.styles=[_,u];t=d([m("md-primary-tab")],t);var c,e=(c=class extends t{constructor(...a){super(...a),this.iconOnly=!1,this.inlineIcon=!1,this._onActivate=()=>{const r=this.textContent?.trim()??"";this.dispatchEvent(new CustomEvent("activate",{detail:{label:r},bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab")}get icon(){return this._icon}set icon(a){const r=this._icon;r!==a&&(this._icon=a,this.requestUpdate("icon",r),this.updateIconSlot())}firstUpdated(a){super.firstUpdated(a),this.addEventListener("click",this._onActivate),this._icon&&this.updateIconSlot()}updated(){if(super.updated(),this.setAttribute("aria-selected",this.active?"true":"false"),this.iconOnly&&!this.hasAttribute("aria-label")){const a=this.textContent?.trim()??"";a&&this.setAttribute("aria-label",a)}}updateIconSlot(){const a=this.querySelector('md-icon[slot="icon"]');if(!this._icon){a?.remove();return}if(a)a.textContent=this._icon;else{const r=document.createElement("md-icon");r.setAttribute("slot","icon"),r.textContent=this._icon,this.appendChild(r)}}},c.styles=[...t.styles,p`:host([icon-only]) slot:not([name=icon]){display:none}`],c);s([i({type:String})],e.prototype,"icon",null);s([i({type:Boolean,reflect:!0,attribute:"icon-only"})],e.prototype,"iconOnly",void 0);s([i({type:Boolean,reflect:!0,attribute:"inline-icon"})],e.prototype,"inlineIcon",void 0);e=s([m("scb-primary-tab")],e);
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,
|
|
3
|
-
/* Icon-only: göm all text utom slot="icon" */
|
|
4
|
-
:host([icon-only]) slot:not([name='icon']) {
|
|
5
|
-
display: none;
|
|
6
|
-
}
|
|
7
|
-
`],s);c([v({type:String})],r.prototype,"icon",null);c([v({type:Boolean,reflect:!0,attribute:"icon-only"})],r.prototype,"iconOnly",void 0);r=c([l("scb-secondary-tab")],r);
|
|
1
|
+
import{m as d,p as l,s as m,y as v}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as c}from"../../vendor/decorate.js";import{r as h,t as p}from"../../vendor/tab-styles.js";(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(a,y,b){try{customElements.get(a)||e(a,y,b)}catch(i){var n=String(i||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var u=class extends h{constructor(){super(...arguments),this.fullWidthIndicator=!0}},_=v`:host{--_active-indicator-color: var(--md-secondary-tab-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_active-indicator-height: var(--md-secondary-tab-active-indicator-height, 2px);--_active-label-text-color: var(--md-secondary-tab-active-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_container-color: var(--md-secondary-tab-container-color, var(--md-sys-color-surface, #fef7ff));--_container-elevation: var(--md-secondary-tab-container-elevation, 0);--_container-height: var(--md-secondary-tab-container-height, 48px);--_focus-label-text-color: var(--md-secondary-tab-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-secondary-tab-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-color: var(--md-secondary-tab-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-secondary-tab-hover-state-layer-opacity, 0.08);--_label-text-font: var(--md-secondary-tab-label-text-font, var(--md-sys-typescale-title-small-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-secondary-tab-label-text-line-height, var(--md-sys-typescale-title-small-line-height, 1.25rem));--_label-text-size: var(--md-secondary-tab-label-text-size, var(--md-sys-typescale-title-small-size, 0.875rem));--_label-text-weight: var(--md-secondary-tab-label-text-weight, var(--md-sys-typescale-title-small-weight, var(--md-ref-typeface-weight-medium, 500)));--_pressed-label-text-color: var(--md-secondary-tab-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-color: var(--md-secondary-tab-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-secondary-tab-pressed-state-layer-opacity, 0.12);--_active-focus-icon-color: var(--md-secondary-tab-active-focus-icon-color, );--_active-focus-label-text-color: var(--md-secondary-tab-active-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-icon-color: var(--md-secondary-tab-active-hover-icon-color, );--_active-hover-label-text-color: var(--md-secondary-tab-active-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-state-layer-color: var(--md-secondary-tab-active-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-state-layer-opacity: var(--md-secondary-tab-active-hover-state-layer-opacity, 0.08);--_active-icon-color: var(--md-secondary-tab-active-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_active-indicator-shape: var(--md-secondary-tab-active-indicator-shape, 0);--_active-pressed-icon-color: var(--md-secondary-tab-active-pressed-icon-color, );--_active-pressed-label-text-color: var(--md-secondary-tab-active-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-pressed-state-layer-color: var(--md-secondary-tab-active-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-pressed-state-layer-opacity: var(--md-secondary-tab-active-pressed-state-layer-opacity, 0.12);--_label-text-color: var(--md-secondary-tab-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-icon-color: var(--md-secondary-tab-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-icon-color: var(--md-secondary-tab-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_icon-size: var(--md-secondary-tab-icon-size, 24px);--_icon-color: var(--md-secondary-tab-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-icon-color: var(--md-secondary-tab-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_container-shape-start-start: var(--md-secondary-tab-container-shape-start-start, var(--md-secondary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-start-end: var(--md-secondary-tab-container-shape-start-end, var(--md-secondary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-end: var(--md-secondary-tab-container-shape-end-end, var(--md-secondary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-start: var(--md-secondary-tab-container-shape-end-start, var(--md-secondary-tab-container-shape, var(--md-sys-shape-corner-none, 0px)))}
|
|
2
|
+
`,t=class extends u{};t.styles=[p,_];t=m([d("md-secondary-tab")],t);var s,r=(s=class extends t{constructor(...e){super(...e),this.iconOnly=!1,this._onActivate=()=>{const a=this.textContent?.trim()??"";this.dispatchEvent(new CustomEvent("activate",{detail:{label:a},bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab")}get icon(){return this._icon}set icon(e){const a=this._icon;a!==e&&(this._icon=e,this.requestUpdate("icon",a),this.updateIconSlot())}firstUpdated(e){if(super.firstUpdated(e),this.iconOnly&&!this.hasAttribute("aria-label")){const a=this.textContent?.trim()??"";a&&this.setAttribute("aria-label",a)}this.addEventListener("click",this._onActivate),this._icon&&this.updateIconSlot()}updated(){if(super.updated(),this.iconOnly&&!this.hasAttribute("aria-label")){const e=this.textContent?.trim()??"";e&&this.setAttribute("aria-label",e)}}updateIconSlot(){const e=this.querySelector('md-icon[slot="icon"]');if(!this._icon){e?.remove();return}if(e)e.textContent=this._icon;else{const a=document.createElement("md-icon");a.setAttribute("slot","icon"),a.textContent=this._icon,this.appendChild(a)}}},s.styles=[...t.styles,v`:host([icon-only]) slot:not([name=icon]){display:none}`],s);c([l({type:String})],r.prototype,"icon",null);c([l({type:Boolean,reflect:!0,attribute:"icon-only"})],r.prototype,"iconOnly",void 0);r=c([d("scb-secondary-tab")],r);
|
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,_=class extends T{};_.styles=[B];_=n([w("md-divider")],_);var p=class extends
|
|
1
|
+
import{d as S,h as C,l as L,m as w,p as r,s as n,v as M,y as E}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as b}from"../../vendor/decorate.js";import{n as P,t as h}from"../../vendor/assertClassBrand.js";import{n as A}from"../../vendor/tab-styles.js";import"./scb-primary-tab.js";import"./scb-secondary-tab.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(s,i,c){try{customElements.get(s)||e(s,i,c)}catch(a){var o=String(a||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var T=class extends C{constructor(){super(...arguments),this.inset=!1,this.insetStart=!1,this.insetEnd=!1}};n([r({type:Boolean,reflect:!0})],T.prototype,"inset",void 0);n([r({type:Boolean,reflect:!0,attribute:"inset-start"})],T.prototype,"insetStart",void 0);n([r({type:Boolean,reflect:!0,attribute:"inset-end"})],T.prototype,"insetEnd",void 0);var B=E`:host{box-sizing:border-box;color:var(--md-divider-color, var(--md-sys-color-outline-variant, #cac4d0));display:flex;height:var(--md-divider-thickness, 1px);width:100%}:host([inset]),:host([inset-start]){padding-inline-start:16px}:host([inset]),:host([inset-end]){padding-inline-end:16px}:host::before{background:currentColor;content:"";height:100%;width:100%}@media(forced-colors: active){:host::before{background:CanvasText}}
|
|
2
|
+
`,_=class extends T{};_.styles=[B];_=n([w("md-divider")],_);var p=class extends C{get activeTab(){return this.tabs.find(t=>t.active)??null}set activeTab(t){t&&this.activateTab(t)}get activeTabIndex(){return this.tabs.findIndex(t=>t.active)}set activeTabIndex(t){const e=()=>{const s=this.tabs[t];s&&this.activateTab(s)};if(!this.slotElement){this.updateComplete.then(e);return}e()}get focusedTab(){return this.tabs.find(t=>t.matches(":focus-within"))}constructor(){super(),this.autoActivate=!1,this.internals=this.attachInternals(),this.internals.role="tablist",this.addEventListener("keydown",this.handleKeydown.bind(this)),this.addEventListener("keyup",this.handleKeyup.bind(this)),this.addEventListener("focusout",this.handleFocusout.bind(this))}async scrollToTab(t){await this.updateComplete;const{tabs:e}=this;if(t??(t=this.activeTab),!t||!e.includes(t)||!this.tabsScrollerElement)return;for(const I of this.tabs)await I.updateComplete;const s=t.offsetLeft,i=t.offsetWidth,c=this.scrollLeft,o=this.offsetWidth,a=48,u=s-a,m=s+i-o+a,y=Math.min(u,Math.max(m,c)),g=this.focusedTab?"auto":"instant";this.tabsScrollerElement.scrollTo({behavior:g,top:0,left:y})}render(){return M`
|
|
3
3
|
<div class="tabs">
|
|
4
4
|
<slot
|
|
5
5
|
@slotchange=${this.handleSlotChange}
|
|
6
6
|
@click=${this.handleTabClick}></slot>
|
|
7
7
|
</div>
|
|
8
8
|
<md-divider part="divider"></md-divider>
|
|
9
|
-
`}async handleTabClick(t){const e=t.target;await 0,!(t.defaultPrevented||!D(e)||e.active)&&this.activateTab(e)}activateTab(t){const{tabs:e}=this,s=this.activeTab;if(!(!e.includes(t)||s===t)){for(const i of e)i.active=i===t;if(s){if(!this.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))){for(const i of e)i.active=i===s;return}t[A](s)}this.updateFocusableTab(t),this.scrollToTab(t)}}updateFocusableTab(t){for(const e of this.tabs)e.tabIndex=e===t?0:-1}async handleKeydown(t){await 0;const e=t.key==="ArrowLeft",s=t.key==="ArrowRight",i=t.key==="Home",c=t.key==="End";if(t.defaultPrevented||!e&&!s&&!i&&!c)return;const{tabs:o}=this;if(o.length<2)return;t.preventDefault();let a;if(i||c)a=i?0:o.length-1;else{const m=getComputedStyle(this).direction==="rtl"?e:s,{focusedTab:y}=this;if(!y)a=m?0:o.length-1;else{const g=this.tabs.indexOf(y);a=m?g+1:g-1,a>=o.length?a=0:a<0&&(a=o.length-1)}}const u=o[a];u.focus(),this.autoActivate?this.activateTab(u):this.updateFocusableTab(u)}handleKeyup(){this.scrollToTab(this.focusedTab??this.activeTab)}handleFocusout(){if(this.matches(":focus-within"))return;const{activeTab:t}=this;t&&this.updateFocusableTab(t)}handleSlotChange(){const t=this.tabs[0];!this.activeTab&&t&&this.activateTab(t),this.scrollToTab(this.activeTab)}};n([L({flatten:!0,selector:"[md-tab]"})],p.prototype,"tabs",void 0);n([r({type:Number,attribute:"active-tab-index"})],p.prototype,"activeTabIndex",null);n([r({type:Boolean,attribute:"auto-activate"})],p.prototype,"autoActivate",void 0);n([
|
|
10
|
-
`,v=class extends p{};v.styles=[F];v=n([w("md-tabs")],v);var l,x,d=(l=new WeakSet,x=class extends v{constructor(...e){super(...e),P(this,l),this.ariaLabel="",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._isDispatching=!1,this._onChange=s=>{if(!s.composed&&!this._isDispatching){s.stopPropagation(),this._isDispatching=!0;const i=s.target.activeTabIndex;this.dispatchEvent(new CustomEvent("change",{detail:{activeTabIndex:i},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("tabschange",{detail:{activeTabIndex:i},bubbles:!0,composed:!0})),this._isDispatching=!1}}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tablist")}firstUpdated(e){super.firstUpdated(e),this.addEventListener("change",this._onChange),h(l,this,
|
|
11
|
-
:host {
|
|
12
|
-
/*Containerfärg */
|
|
13
|
-
--md-primary-tab-container-color: var(--md-sys-color-surface);
|
|
14
|
-
--md-secondary-tab-container-color: var(--md-sys-color-surface);
|
|
15
|
-
|
|
16
|
-
/* Text- och ikonfärger */
|
|
17
|
-
--md-primary-tab-label-text-color: var(--md-sys-color-on-surface-variant);
|
|
18
|
-
--md-secondary-tab-label-text-color: var(--md-sys-color-on-surface-variant);
|
|
19
|
-
--md-primary-tab-active-label-text-color: var(--md-sys-color-on-surface);
|
|
20
|
-
--md-secondary-tab-active-label-text-color: var(--md-sys-color-on-surface);
|
|
21
|
-
|
|
22
|
-
/* Indikator och divider */
|
|
23
|
-
--md-primary-tab-active-indicator-color: var(--md-sys-color-primary);
|
|
24
|
-
--md-primary-tab-divider-color: var(--md-sys-color-outline-variant);
|
|
25
|
-
--md-secondary-tab-divider-color: var(--md-sys-color-outline-variant);
|
|
26
|
-
|
|
27
|
-
/* State layers (hover/press) */
|
|
28
|
-
--md-primary-tab-hover-state-layer-color: var(--md-sys-color-on-surface);
|
|
29
|
-
--md-secondary-tab-hover-state-layer-color: var(--md-sys-color-on-surface);
|
|
30
|
-
|
|
31
|
-
/* Vertikalt avstånd styrs av spacing-attributen via CSS-variabler */
|
|
32
|
-
margin-block-start: var(--scb-tabs-spacing-block-start, 0);
|
|
33
|
-
margin-block-end: var(--scb-tabs-spacing-block-end, 0);
|
|
34
|
-
margin-inline-start: var(--scb-tabs-spacing-inline-start, 0);
|
|
35
|
-
margin-inline-end: var(--scb-tabs-spacing-inline-end, 0);
|
|
36
|
-
}
|
|
37
|
-
`],x);function E(){const t=h(l,this,f).call(this,this.spacing),e=h(l,this,f).call(this,this.spacingTop)??t,s=h(l,this,f).call(this,this.spacingBottom)??t,i=h(l,this,f).call(this,this.spacingLeft),c=h(l,this,f).call(this,this.spacingRight);e?this.style.setProperty("--scb-tabs-spacing-block-start",e):this.style.removeProperty("--scb-tabs-spacing-block-start"),s?this.style.setProperty("--scb-tabs-spacing-block-end",s):this.style.removeProperty("--scb-tabs-spacing-block-end"),i?this.style.setProperty("--scb-tabs-spacing-inline-start",i):this.style.removeProperty("--scb-tabs-spacing-inline-start"),c?this.style.setProperty("--scb-tabs-spacing-inline-end",c):this.style.removeProperty("--scb-tabs-spacing-inline-end")}function f(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}b([r({type:String,reflect:!0,attribute:"aria-label"})],d.prototype,"ariaLabel",void 0);b([r({type:String,reflect:!0})],d.prototype,"spacing",void 0);b([r({type:String,attribute:"spacing-top",reflect:!0})],d.prototype,"spacingTop",void 0);b([r({type:String,attribute:"spacing-bottom",reflect:!0})],d.prototype,"spacingBottom",void 0);b([r({type:String,attribute:"spacing-left",reflect:!0})],d.prototype,"spacingLeft",void 0);b([r({type:String,attribute:"spacing-right",reflect:!0})],d.prototype,"spacingRight",void 0);d=b([w("scb-tabs")],d);
|
|
9
|
+
`}async handleTabClick(t){const e=t.target;await 0,!(t.defaultPrevented||!D(e)||e.active)&&this.activateTab(e)}activateTab(t){const{tabs:e}=this,s=this.activeTab;if(!(!e.includes(t)||s===t)){for(const i of e)i.active=i===t;if(s){if(!this.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))){for(const i of e)i.active=i===s;return}t[A](s)}this.updateFocusableTab(t),this.scrollToTab(t)}}updateFocusableTab(t){for(const e of this.tabs)e.tabIndex=e===t?0:-1}async handleKeydown(t){await 0;const e=t.key==="ArrowLeft",s=t.key==="ArrowRight",i=t.key==="Home",c=t.key==="End";if(t.defaultPrevented||!e&&!s&&!i&&!c)return;const{tabs:o}=this;if(o.length<2)return;t.preventDefault();let a;if(i||c)a=i?0:o.length-1;else{const m=getComputedStyle(this).direction==="rtl"?e:s,{focusedTab:y}=this;if(!y)a=m?0:o.length-1;else{const g=this.tabs.indexOf(y);a=m?g+1:g-1,a>=o.length?a=0:a<0&&(a=o.length-1)}}const u=o[a];u.focus(),this.autoActivate?this.activateTab(u):this.updateFocusableTab(u)}handleKeyup(){this.scrollToTab(this.focusedTab??this.activeTab)}handleFocusout(){if(this.matches(":focus-within"))return;const{activeTab:t}=this;t&&this.updateFocusableTab(t)}handleSlotChange(){const t=this.tabs[0];!this.activeTab&&t&&this.activateTab(t),this.scrollToTab(this.activeTab)}};n([L({flatten:!0,selector:"[md-tab]"})],p.prototype,"tabs",void 0);n([r({type:Number,attribute:"active-tab-index"})],p.prototype,"activeTabIndex",null);n([r({type:Boolean,attribute:"auto-activate"})],p.prototype,"autoActivate",void 0);n([S(".tabs")],p.prototype,"tabsScrollerElement",void 0);n([S("slot")],p.prototype,"slotElement",void 0);function D(t){return t instanceof HTMLElement&&t.hasAttribute("md-tab")}var F=E`:host{box-sizing:border-box;display:flex;flex-direction:column;overflow:auto;scroll-behavior:smooth;scrollbar-width:none;position:relative}:host([hidden]){display:none}:host::-webkit-scrollbar{display:none}.tabs{align-items:end;display:flex;height:100%;overflow:inherit;scroll-behavior:inherit;scrollbar-width:inherit;justify-content:space-between;width:100%}::slotted(*){flex:1}::slotted([active]){z-index:1}
|
|
10
|
+
`,v=class extends p{};v.styles=[F];v=n([w("md-tabs")],v);var l,x,d=(l=new WeakSet,x=class extends v{constructor(...e){super(...e),P(this,l),this.ariaLabel="",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._isDispatching=!1,this._onChange=s=>{if(!s.composed&&!this._isDispatching){s.stopPropagation(),this._isDispatching=!0;const i=s.target.activeTabIndex;this.dispatchEvent(new CustomEvent("change",{detail:{activeTabIndex:i},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("tabschange",{detail:{activeTabIndex:i},bubbles:!0,composed:!0})),this._isDispatching=!1}}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tablist")}firstUpdated(e){super.firstUpdated(e),this.addEventListener("change",this._onChange),h(l,this,k).call(this)}updated(e){super.updated(e),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&h(l,this,k).call(this)}},x.styles=[...v.styles,E`:host{--md-primary-tab-container-color:var(--md-sys-color-surface);--md-secondary-tab-container-color:var(--md-sys-color-surface);--md-primary-tab-label-text-color:var(--md-sys-color-on-surface-variant);--md-secondary-tab-label-text-color:var(--md-sys-color-on-surface-variant);--md-primary-tab-active-label-text-color:var(--md-sys-color-on-surface);--md-secondary-tab-active-label-text-color:var(--md-sys-color-on-surface);--md-primary-tab-active-indicator-color:var(--md-sys-color-primary);--md-primary-tab-divider-color:var(--md-sys-color-outline-variant);--md-secondary-tab-divider-color:var(--md-sys-color-outline-variant);--md-primary-tab-hover-state-layer-color:var(--md-sys-color-on-surface);--md-secondary-tab-hover-state-layer-color:var(--md-sys-color-on-surface);margin-block-start:var(--scb-tabs-spacing-block-start, 0);margin-block-end:var(--scb-tabs-spacing-block-end, 0);margin-inline-start:var(--scb-tabs-spacing-inline-start, 0);margin-inline-end:var(--scb-tabs-spacing-inline-end, 0)}`],x);function k(){const t=h(l,this,f).call(this,this.spacing),e=h(l,this,f).call(this,this.spacingTop)??t,s=h(l,this,f).call(this,this.spacingBottom)??t,i=h(l,this,f).call(this,this.spacingLeft),c=h(l,this,f).call(this,this.spacingRight);e?this.style.setProperty("--scb-tabs-spacing-block-start",e):this.style.removeProperty("--scb-tabs-spacing-block-start"),s?this.style.setProperty("--scb-tabs-spacing-block-end",s):this.style.removeProperty("--scb-tabs-spacing-block-end"),i?this.style.setProperty("--scb-tabs-spacing-inline-start",i):this.style.removeProperty("--scb-tabs-spacing-inline-start"),c?this.style.setProperty("--scb-tabs-spacing-inline-end",c):this.style.removeProperty("--scb-tabs-spacing-inline-end")}function f(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}b([r({type:String,reflect:!0,attribute:"aria-label"})],d.prototype,"ariaLabel",void 0);b([r({type:String,reflect:!0})],d.prototype,"spacing",void 0);b([r({type:String,attribute:"spacing-top",reflect:!0})],d.prototype,"spacingTop",void 0);b([r({type:String,attribute:"spacing-bottom",reflect:!0})],d.prototype,"spacingBottom",void 0);b([r({type:String,attribute:"spacing-left",reflect:!0})],d.prototype,"spacingLeft",void 0);b([r({type:String,attribute:"spacing-right",reflect:!0})],d.prototype,"spacingRight",void 0);d=b([w("scb-tabs")],d);
|