scb-wc 0.1.238 → 0.1.239
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +2 -0
- package/all.js +2 -0
- package/index.js +15 -13
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-table-next/read-table.js +1 -0
- package/mvc/components/scb-table-next/scb-table-next.js +6 -0
- package/package.json +12 -2
- package/scb-components/index.d.ts +2 -0
- package/scb-components/scb-table-next/read-table.d.ts +29 -0
- package/scb-components/scb-table-next/scb-table-next.d.ts +22 -0
- package/scb-table-next/read-table.js +87 -0
- package/scb-table-next/scb-table-next.js +226 -0
- package/scb-wc.bundle.js +253 -132
- package/scb-wc.d.ts +4 -0
package/all.d.ts
CHANGED
|
@@ -85,6 +85,8 @@ import './scb-components/scb-stepper/scb-step.js';
|
|
|
85
85
|
import './scb-components/scb-stepper/scb-stepper.js';
|
|
86
86
|
import './scb-components/scb-switch/scb-switch.js';
|
|
87
87
|
import './scb-components/scb-table-advanced/scb-table-advanced.js';
|
|
88
|
+
import './scb-components/scb-table-next/read-table.js';
|
|
89
|
+
import './scb-components/scb-table-next/scb-table-next.js';
|
|
88
90
|
import './scb-components/scb-table/scb-table.js';
|
|
89
91
|
import './scb-components/scb-tabs/scb-primary-tab.js';
|
|
90
92
|
import './scb-components/scb-tabs/scb-secondary-tab.js';
|
package/all.js
CHANGED
|
@@ -85,6 +85,8 @@ import './scb-stepper/scb-step.js';
|
|
|
85
85
|
import './scb-stepper/scb-stepper.js';
|
|
86
86
|
import './scb-switch/scb-switch.js';
|
|
87
87
|
import './scb-table-advanced/scb-table-advanced.js';
|
|
88
|
+
import './scb-table-next/read-table.js';
|
|
89
|
+
import './scb-table-next/scb-table-next.js';
|
|
88
90
|
import './scb-table/scb-table.js';
|
|
89
91
|
import './scb-tabs/scb-primary-tab.js';
|
|
90
92
|
import './scb-tabs/scb-secondary-tab.js';
|
package/index.js
CHANGED
|
@@ -92,16 +92,18 @@ import { ScbStep as ze } from "./scb-stepper/scb-step.js";
|
|
|
92
92
|
import { ScbStepper as Be } from "./scb-stepper/scb-stepper.js";
|
|
93
93
|
import { ScbTable as Ve } from "./scb-table/scb-table.js";
|
|
94
94
|
import { ScbTableAdvanced as He } from "./scb-table-advanced/scb-table-advanced.js";
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import {
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
|
|
95
|
+
import { readTable as Ue } from "./scb-table-next/read-table.js";
|
|
96
|
+
import { ScbTableNext as We } from "./scb-table-next/scb-table-next.js";
|
|
97
|
+
import { ScbPrimaryTab as Ge } from "./scb-tabs/scb-primary-tab.js";
|
|
98
|
+
import { ScbSecondaryTab as Ke } from "./scb-tabs/scb-secondary-tab.js";
|
|
99
|
+
import { ScbTabs as qe } from "./scb-tabs/scb-tabs.js";
|
|
100
|
+
import { ScbTocItem as Je } from "./scb-toc/scb-toc-item.js";
|
|
101
|
+
import { ScbToc as Ye } from "./scb-toc/scb-toc.js";
|
|
102
|
+
import { buildScbVizExportFileName as Xe, createScbVizCsvBlob as Ze, createScbVizRasterBlobFromElement as Qe, createScbVizRasterDataUrlFromElement as $e, downloadScbVizBlob as et, getScbVizCurrentFullscreenElement as tt, getScbVizExportBaseFileName as nt, getScbVizFullscreenDocument as rt, isScbVizFullscreenSupported as it, openScbVizPrintFrame as at, runWithScbVizForcedPrintLightMode as ot, toggleScbVizFullscreen as st } from "./scb-viz/scb-viz-actions-runtime.js";
|
|
103
|
+
import { buildScbVizPrintDocumentHtml as ct, buildScbVizPrintableFooterHtml as lt, buildScbVizPrintableTableHtml as ut } from "./scb-viz/scb-viz-print-runtime.js";
|
|
104
|
+
import { appendScbVizSeriesDifferentiationPatternMarks as dt, getScbVizSeriesDifferentiationPatternDefinition as ft, getScbVizSeriesDifferentiationPatternKinds as pt, getScbVizSeriesDifferentiationRegistry as mt, getScbVizSeriesDifferentiationVariant as ht, scbVizSeriesDifferentiationRegistry as gt } from "./scb-viz/scb-viz-series-differentiation-registry.js";
|
|
105
|
+
import { clearScbVizSeriesDifferentiationColorClass as _t, clearScbVizSeriesDifferentiationMetadata as vt, ensureScbVizGroupedSeriesDifferentiationStore as yt, ensureScbVizStyledModeSeriesPattern as bt, getScbVizGroupedSeriesDifferentiationKey as xt, getScbVizGroupedSeriesDifferentiationVariant as St, getScbVizGroupedSeriesDifferentiationVariantIndex as Ct, getScbVizHighchartsColorClassName as wt, getScbVizHighchartsSvgElement as Tt, getScbVizHighchartsSvgRoot as Et, getScbVizLegendSeriesDifferentiationTargets as Dt, getScbVizSeriesDifferentiationColorIndex as Ot, getScbVizSeriesDifferentiationVariantByIndex as kt, isScbVizGroupedSeriesDifferentiationChart as At, isScbVizHighchartsStyledMode as jt, setScbVizSeriesDifferentiationColorClass as Mt, setScbVizSeriesDifferentiationMetadata as Nt, shouldShowScbVizSeriesDifferentiationAction as Pt, usesScbVizGroupedPointDifferentiation as Ft } from "./scb-viz/scb-viz-series-differentiation-runtime.js";
|
|
106
|
+
import { buildScbVizResolvedTableView as It, createScbVizCsvRows as Lt, inferScbVizTableAlignments as Rt, normalizeScbVizRenderableCell as zt, readScbVizTableDataFromSlot as Bt } from "./scb-viz/scb-viz-table-runtime.js";
|
|
107
|
+
import { ScbViz as Vt } from "./scb-viz/scb-viz.js";
|
|
108
|
+
import { ensureRippleReady as Ht, syncRippleToControl as Ut } from "./shared/lazy-ripple.js";
|
|
109
|
+
export { D as SCBBreadcrumb, E as SCBBreadcrumbItem, l as ScbAccordion, s as ScbAccordionItem, u as ScbActionCard, C as ScbAppBar, a as ScbAvatar, w as ScbBadge, c as ScbButton, H as ScbCalendar, U as ScbCalendarCard, O as ScbCalendarEvent, d as ScbCard, P as ScbCheckbox, N as ScbCheckboxGroup, o as ScbChevron, R as ScbChip, W as ScbCollapse, f as ScbContainerCard, G as ScbCookiesConsent, A as ScbDatepicker, z as ScbDialog, k as ScbDivider, K as ScbDrawer, q as ScbDropZone, Z as ScbDropdown, $ as ScbFactCard, Q as ScbFactCardContent, ie as ScbFooter, ee as ScbFooterSection, se as ScbFormErrorSummary, fe as ScbGalleryGrid, re as ScbGrid, te as ScbGridItem, _e as ScbHeader, pe as ScbHeaderMenuGroup, me as ScbHeaderMenuItem, he as ScbHeaderTab, ge as ScbHeaderUtility, ue as ScbHorizontalScroller, ae as ScbIcon, g as ScbIconButton, ve as ScbKeyFigureCard, T as ScbLink, ye as ScbLinkButton, p as ScbLinkCard, V as ScbList, m as ScbListCard, B as ScbListItem, Ce as ScbMenu, be as ScbMenuItem, Te as ScbNav, we as ScbNavItem, oe as ScbNotificationCard, X as ScbOptionsMenu, J as ScbOptionsMenuItem, Y as ScbOptionsSubMenu, de as ScbOverlay, Ee as ScbPagination, Ge as ScbPrimaryTab, De as ScbProgressIndicator, Oe as ScbProgressStep, ke as ScbProgressStepper, I as ScbRadioButton, F as ScbRadioGroup, Ae as ScbScrollspy, S as ScbSearch, Ke as ScbSecondaryTab, Me as ScbSegmentedButton, je as ScbSegmentedItem, Pe as ScbSelect, Ne as ScbSelectOption, Fe as ScbSkeleton, Ie as ScbSlider, Le as ScbSnackbar, h as ScbSocialCard, ne as ScbStack, Re as ScbStatusPill, ze as ScbStep, Be as ScbStepper, Se as ScbSubmenu, L as ScbSwitch, Ve as ScbTable, He as ScbTableAdvanced, We as ScbTableNext, qe as ScbTabs, M as ScbTextField, Ye as ScbToc, Je as ScbTocItem, j as ScbTooltip, Vt as ScbViz, xe as ScbmenuSection, e as addLazyFocusRingListeners, dt as appendScbVizSeriesDifferentiationPatternMarks, Xe as buildScbVizExportFileName, ct as buildScbVizPrintDocumentHtml, lt as buildScbVizPrintableFooterHtml, ut as buildScbVizPrintableTableHtml, It as buildScbVizResolvedTableView, _t as clearScbVizSeriesDifferentiationColorClass, vt as clearScbVizSeriesDifferentiationMetadata, _ as closeManualPopover, v as closeManualPopoverAfterAnimations, y as closeNestedPopupSurfaces, i as componentSizeToken, Ze as createScbVizCsvBlob, Lt as createScbVizCsvRows, Qe as createScbVizRasterBlobFromElement, $e as createScbVizRasterDataUrlFromElement, et as downloadScbVizBlob, t as ensureFocusRingOnFocusVisible, n as ensureFocusRingOnTab, r as ensureFocusRingReady, Ht as ensureRippleReady, yt as ensureScbVizGroupedSeriesDifferentiationStore, bt as ensureScbVizStyledModeSeriesPattern, tt as getScbVizCurrentFullscreenElement, nt as getScbVizExportBaseFileName, rt as getScbVizFullscreenDocument, xt as getScbVizGroupedSeriesDifferentiationKey, St as getScbVizGroupedSeriesDifferentiationVariant, Ct as getScbVizGroupedSeriesDifferentiationVariantIndex, wt as getScbVizHighchartsColorClassName, Tt as getScbVizHighchartsSvgElement, Et as getScbVizHighchartsSvgRoot, Dt as getScbVizLegendSeriesDifferentiationTargets, Ot as getScbVizSeriesDifferentiationColorIndex, ft as getScbVizSeriesDifferentiationPatternDefinition, pt as getScbVizSeriesDifferentiationPatternKinds, mt as getScbVizSeriesDifferentiationRegistry, ht as getScbVizSeriesDifferentiationVariant, kt as getScbVizSeriesDifferentiationVariantByIndex, ce as hasScbSvgIcon, Rt as inferScbVizTableAlignments, b as isManualPopoverOpen, it as isScbVizFullscreenSupported, At as isScbVizGroupedSeriesDifferentiationChart, jt as isScbVizHighchartsStyledMode, zt as normalizeScbVizRenderableCell, x as openManualPopover, at as openScbVizPrintFrame, Bt as readScbVizTableDataFromSlot, Ue as readTable, le as renderScbIcon, ot as runWithScbVizForcedPrintLightMode, gt as scbVizSeriesDifferentiationRegistry, Mt as setScbVizSeriesDifferentiationColorClass, Nt as setScbVizSeriesDifferentiationMetadata, Pt as shouldShowScbVizSeriesDifferentiationAction, Ut as syncRippleToControl, st as toggleScbVizFullscreen, Ft as usesScbVizGroupedPointDifferentiation };
|
package/mvc/components/all.js
CHANGED
|
@@ -85,6 +85,8 @@ import './scb-stepper/scb-step.js';
|
|
|
85
85
|
import './scb-stepper/scb-stepper.js';
|
|
86
86
|
import './scb-switch/scb-switch.js';
|
|
87
87
|
import './scb-table-advanced/scb-table-advanced.js';
|
|
88
|
+
import './scb-table-next/read-table.js';
|
|
89
|
+
import './scb-table-next/scb-table-next.js';
|
|
88
90
|
import './scb-table/scb-table.js';
|
|
89
91
|
import './scb-tabs/scb-primary-tab.js';
|
|
90
92
|
import './scb-tabs/scb-secondary-tab.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){try{var r=typeof globalThis<"u"?globalThis:window;if(!r.__scb_ce_guard_installed__){r.__scb_ce_guard_installed__=!0;var l=customElements.define.bind(customElements);customElements.define=function(n,c,s){try{customElements.get(n)||l(n,c,s)}catch(d){var a=String(d||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();function p(r){if(!r.querySelector("a, sup"))return r.textContent?.trim()??"";const l=n=>{if(n.nodeType===Node.TEXT_NODE)return[n.textContent??""];if(!(n instanceof Element))return[];const c=Array.from(n.childNodes).flatMap(l);return n.localName==="sup"?[{tag:"sup",children:c}]:n.localName==="a"?[{tag:"a",children:c,href:n.getAttribute("href"),title:n.getAttribute("title")||void 0,ariaLabel:n.getAttribute("aria-label")||void 0}]:c};return Array.from(r.childNodes).flatMap(l)}var _=r=>r.scope==="row"||r.classList.contains("forspalt")||r.tagName==="TH"&&!r.scope;function C(r,l=1/0){let n=r.tHead?Array.from(r.tHead.rows):[];if(!r.tHead)for(const t of Array.from(r.rows)){if(!t.cells.length||!Array.from(t.cells).every(e=>e.tagName==="TH"))break;n.push(t)}if(!n.length)return;const c=new Set(n),s=Array.from(r.rows).filter(t=>!c.has(t));if(!s.length||s.length>l)return;const a=s.reduce((t,e)=>{const o=Array.from(e.cells).findIndex(i=>!_(i));return Math.max(t,o<0?e.cells.length:o)},1),d=s[0].cells.length-a;if((s.length+n.length+1)*d>l)return;const v=new Set(Array.from(r.querySelectorAll("[id]"),t=>t.id));if(r.querySelector("table, button, input, select, textarea, [tabindex], [contenteditable], [role]")||Array.from(r.querySelectorAll("*")).some(t=>t.localName.includes("-"))||Array.from(r.querySelectorAll("a")).some(t=>{const e=t.getAttribute("href")||"";let o;try{o=decodeURIComponent(e.slice(1))}catch{return!0}return!t.closest("th, td")||v.has(o)||!e.startsWith("#")||t.getAttribute("href")==="#"||t.hasAttribute("target")||t.hasAttribute("download")||t.getAttributeNames().some(i=>i.startsWith("on"))||t.hasAttribute("aria-labelledby")||t.hasAttribute("aria-describedby")})||r.getAttribute("role")&&r.getAttribute("role")!=="table")return;const u=n.map(()=>[]),N=n.map((t,e)=>{let o=0;return Array.from(t.cells).map(i=>{for(;u[e][o];)o++;const S=i.cloneNode(!0);S.querySelectorAll("[hidden], .visually-hidden, .sr-only").forEach(m=>m.remove());const y=i.textContent?.trim()??"",w=!!y&&!S.textContent?.trim(),h={text:y,content:p(i),visuallyHidden:w,ariaLabel:i.getAttribute("aria-label")||(w?y:void 0),column:o,colSpan:i.colSpan,rowSpan:i.rowSpan||n.length-e},A=o+h.colSpan,x=e+h.rowSpan;if(A>256||x>u.length)throw new RangeError("header-grid");for(let m=e;m<x;m++)for(let g=o;g<A;g++){if(u[m][g])throw new RangeError("header-grid");u[m][g]=h}return o=A,h})}),f=u[0].length;if(f<2||u.some(t=>t.length!==f||Array.from({length:f},(e,o)=>!t[o]).some(Boolean))||a>=f||s.some(t=>t.cells.length!==f||Array.from(t.cells).some(e=>e.colSpan!==1||e.rowSpan!==1)||!Array.from(t.cells).slice(0,a).some(e=>e.textContent?.trim())||Array.from(t.cells).slice(a).some(e=>e.tagName==="TH"||_(e))))return;if(s.some(t=>Array.from(t.cells).slice(a).every(e=>!e.textContent?.trim()))){const t=s.map(e=>JSON.stringify(Array.from(e.cells).slice(0,a).map(o=>o.textContent?.trim())));if(new Set(t).size!==t.length)return}const b=Array.from({length:f-a},(t,e)=>[...new Set(u.map(o=>o[e+a]))].filter(o=>o.text));if(!b.some(t=>!t.length))return{label:r.getAttribute("aria-label")||r.caption?.textContent?.trim()||"",headings:N,columns:b,stubCount:a,rows:s.map(t=>({stubs:Array.from(t.cells).slice(0,a).map(p),values:Array.from(t.cells).slice(a).map(p)}))}}export{C as readTable};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as b,f as $,g as _,h as R,m as E,v as s,y as k}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as y}from"../../vendor/decorate.js";import{readTable as S}from"./read-table.js";(function(){try{var v=typeof globalThis<"u"?globalThis:window;if(!v.__scb_ce_guard_installed__){v.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,a,n){try{customElements.get(e)||t(e,a,n)}catch(d){var c=String(d||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var x,C=200,w=new WeakSet,L=k`scb-table-next>table{box-sizing:border-box;inline-size:100%;border-collapse:separate;border-spacing:0;border:0;outline:1px solid var(--scb-tables-strong-outline-color);outline-offset:-1px;border-radius:var(--md-sys-shape-corner-small);overflow:hidden;background:var(--scb-tables-surface-color);color:inherit;font:inherit}scb-table-next>table>:is(thead,tbody,tfoot)>tr>:is(th,td){box-sizing:border-box;padding:var(--spacing-3) var(--spacing-4);min-inline-size:2.5rem;border-block-end:1px solid var(--scb-tables-strong-outline-color);border-inline-end:1px solid var(--scb-tables-strong-outline-color);font-variant-numeric:tabular-nums;font-weight:inherit}scb-table-next>table>:is(thead,tbody,tfoot)>tr>th,scb-table-next>table>tbody>tr>.forspalt{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table>thead>tr>*{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table>thead>tr>th{font-weight:var(--weight-bold);text-align:center}scb-table-next>table>thead>tr:last-child>th{text-align:end}scb-table-next>table>:is(tbody,tfoot)>tr>:is(th,td){text-align:end}scb-table-next>table>:is(tbody,tfoot)>tr>.forspalt,scb-table-next>table>:is(tbody,tfoot)>tr>:first-child,scb-table-next>table>:is(tbody,tfoot)>tr>th:is([scope=row],[scope=rowgroup]){text-align:start}scb-table-next>table>tbody>tr>.forspalt{min-inline-size:0}scb-table-next>table>tbody>tr>:first-child:not(:has(~th,~.forspalt)){min-inline-size:0}scb-table-next>table>tbody>tr:hover>*{background:var(--scb-tables-alternate-surface-color)}scb-table-next>table a{color:inherit;text-decoration:underline}scb-table-next>table a:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}`,m=(x=class extends R{constructor(...t){super(...t),this._mobile=!1,this._widthReady=!1}connectedCallback(){super.connectedCallback();const t=this.getRootNode();if(!w.has(t)){const e=this.ownerDocument.createElement("style");e.textContent=L.cssText,(t instanceof Document?t.head:t).appendChild(e),w.add(t)}this._observer=new MutationObserver(()=>this._queueRead()),this._observer.observe(this,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["colspan","rowspan","aria-label","role","tabindex","contenteditable","scope","class","hidden","href","title","id","target","download","aria-labelledby","aria-describedby"]}),this._resize=new ResizeObserver(([e])=>{const a=e.contentRect.width;if(a<=0){this._widthReady=!1;return}const n=a<=575,c=n!==this._mobile;this._mobile=n,(!this._widthReady||c)&&(this._widthReady=!0,this._read())}),this._resize.observe(this)}disconnectedCallback(){this._observer?.disconnect(),this._resize?.disconnect(),this._frame!==void 0&&cancelAnimationFrame(this._frame),this._frame=void 0,this._widthReady=!1,super.disconnectedCallback()}_queueRead(){!this._mobile||!this._widthReady||this._frame!==void 0||(this._frame=requestAnimationFrame(()=>{this._frame=void 0,this._read()}))}_read(){if(!this._widthReady)return;if(!this._mobile){this._model=void 0;return}const t=this.querySelectorAll("table");try{this._model=t.length===1?S(t[0],C):void 0}catch(e){if(!(e instanceof RangeError))throw e;this._model=void 0}}_content(t){return typeof t=="string"?t:t.map(e=>typeof e=="string"?e:e.tag==="sup"?s`<sup>${this._content(e.children)}</sup>`:s`<a href=${e.href} title=${b(e.title)} aria-label=${b(e.ariaLabel)}>${this._content(e.children)}</a>`)}_mobileRows(t){const e=[],a=t.headings.flat().filter(r=>(r.text||r.ariaLabel)&&r.column+r.colSpan<=t.stubCount),n=a.map(r=>r.ariaLabel||r.text).join(" "),c=a.filter(r=>!r.visuallyHidden&&r.text);let d=[];const f=[];return t.columns.forEach((r,p)=>{let i=0;for(;i<r.length&&r[i]===d[i];)i++;f.length=i,r.forEach((l,o)=>{if(o<i)return;const h=`group-${p}-${o}`;f.push(h);const u=o===0?"outer":`group${i===0?" first":""}`;e.push(s`<tr class=${u}><th id=${h} aria-label=${b(l.ariaLabel)} scope="col" colspan="2">${this._content(l.content)}</th></tr>`)});const g=a.length?`stub-heading-${p}`:void 0;g&&(f.push(g),e.push(s`<tr class="stub-headings"><th id=${g} scope="col" colspan="2" aria-label=${b(n)}>${c.map((l,o)=>s`${o?" ":_}<span>${this._content(l.content)}</span>`)}</th></tr>`)),t.rows.forEach((l,o)=>{const h=`mobile-row-${p}-${o}`;e.push(s`<tr class=${o===t.rows.length-1?"last":""}>
|
|
2
|
+
<th class="stub" scope="row" id=${h} headers=${b(g)}>${l.stubs.filter(u=>u!=="").map((u,z)=>s`${z?" ":_}${this._content(u)}`)}</th>
|
|
3
|
+
<td headers=${[...f,h].join(" ")}>${this._content(l.values[p])}</td></tr>`)}),d=r}),e}render(){const t=this._model;return s`<div class="scroll" tabindex="0" ?hidden=${!!t}><slot @slotchange=${this._queueRead}></slot></div>
|
|
4
|
+
${t?s`<table class="mobile" aria-label=${b(t.label||void 0)}>
|
|
5
|
+
<tbody>${this._mobileRows(t)}</tbody>
|
|
6
|
+
</table>`:_}`}},x.styles=k`:host{display:block;min-inline-size:0;color:var(--scb-tables-content-color, var(--md-sys-color-on-surface));font-family:var(--scb-tables-cell-font, var(--brand-font, Inter, Arial, sans-serif));font-size:var(--scb-tables-cell-size);line-height:var(--scb-tables-cell-line-height);font-weight:var(--weight-regular)}*{box-sizing:border-box}:host([hidden]),[hidden]{display:none!important}.scroll{max-inline-size:100%;overflow-x:auto;padding-bottom:var(--spacing-8, 24px)}.scroll::-webkit-scrollbar{border-radius:var(--md-sys-shape-corner-large);height:8px;width:10px}.scroll::-webkit-scrollbar-thumb{background:var(--scb-tables-scrollbar-thumb-color, var(--md-sys-color-on-surface));border-radius:var(--md-sys-shape-corner-large);cursor:pointer}.scroll::-webkit-scrollbar-track{background:var(--scb-tables-scrollbar-track-color, var(--md-sys-color-secondary-container));border-radius:var(--md-sys-shape-corner-large)}a{color:inherit;text-decoration:underline}.scroll:focus-visible,a:focus-visible{outline:2px solid var(--md-sys-color-primary);outline-offset:2px}table{inline-size:100%;border-collapse:separate;border-spacing:0;border:1px solid var(--scb-tables-strong-outline-color);border-radius:var(--md-sys-shape-corner-small);overflow:hidden;background:var(--scb-tables-surface-color);color:inherit;font:inherit}td,th{min-inline-size:2.5rem;font-variant-numeric:tabular-nums;font-weight:inherit}.stub{text-align:start}td{text-align:end}tbody tr:hover>*{background:var(--scb-tables-alternate-surface-color)}.mobile td,.mobile th{padding-block:var(--spacing-2);padding-inline:var(--spacing-5);border:0;background:0 0;vertical-align:top}.mobile .stub{min-inline-size:0;padding-inline-end:calc(var(--spacing-1)/2)}.mobile td{inline-size:1%;white-space:nowrap}.mobile .stub-headings>th{text-align:start;font-weight:var(--weight-bold)}.mobile .stub-headings>th:empty{padding:0}.mobile .outer>th{padding-block:var(--spacing-5);background:var(--scb-tables-alternate-surface-color);font-weight:var(--weight-bold);text-align:start;border-block-start:1px solid var(--scb-tables-strong-outline-color)}.mobile tbody:first-child>.outer:first-child>th{border-block-start:0}.mobile .group>th{padding-block-start:0;font-weight:var(--weight-bold);text-align:start}.mobile .group.first>th{padding-block-start:calc(var(--spacing-8) + var(--spacing-2))}.mobile .last>*{padding-block-end:calc(var(--spacing-8) + var(--spacing-2))}`,x);y([$()],m.prototype,"_model",void 0);y([$()],m.prototype,"_mobile",void 0);m=y([E("scb-table-next")],m);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.239",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -506,6 +506,16 @@
|
|
|
506
506
|
"import": "./scb-table-advanced/scb-table-advanced.js",
|
|
507
507
|
"require": "./scb-table-advanced/scb-table-advanced.js"
|
|
508
508
|
},
|
|
509
|
+
"./scb-table-next": {
|
|
510
|
+
"types": "./scb-components/scb-table-next/scb-table-next.d.ts",
|
|
511
|
+
"import": "./scb-table-next/scb-table-next.js",
|
|
512
|
+
"require": "./scb-table-next/scb-table-next.js"
|
|
513
|
+
},
|
|
514
|
+
"./scb-table-next/read-table": {
|
|
515
|
+
"types": "./scb-components/scb-table-next/read-table.d.ts",
|
|
516
|
+
"import": "./scb-table-next/read-table.js",
|
|
517
|
+
"require": "./scb-table-next/read-table.js"
|
|
518
|
+
},
|
|
509
519
|
"./scb-tabs": {
|
|
510
520
|
"types": "./scb-components/scb-tabs/scb-tabs.d.ts",
|
|
511
521
|
"import": "./scb-tabs/scb-tabs.js",
|
|
@@ -549,5 +559,5 @@
|
|
|
549
559
|
"./scb-viz/*": null,
|
|
550
560
|
"./mvc/*": "./mvc/*"
|
|
551
561
|
},
|
|
552
|
-
"buildHash": "
|
|
562
|
+
"buildHash": "0048BD20E9914A00E8BA9D8CE97A93E3ABEE22BB8999861DC5A76DC604DCB5C0"
|
|
553
563
|
}
|
|
@@ -86,6 +86,8 @@ export * from './scb-stepper/scb-stepper';
|
|
|
86
86
|
export * from './scb-switch/scb-switch';
|
|
87
87
|
export * from './scb-table/scb-table';
|
|
88
88
|
export * from './scb-table-advanced/scb-table-advanced';
|
|
89
|
+
export * from './scb-table-next/read-table';
|
|
90
|
+
export * from './scb-table-next/scb-table-next';
|
|
89
91
|
export * from './scb-tabs/scb-primary-tab';
|
|
90
92
|
export * from './scb-tabs/scb-secondary-tab';
|
|
91
93
|
export * from './scb-tabs/scb-tabs';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Content = string | Inline[];
|
|
2
|
+
type Inline = string | {
|
|
3
|
+
tag: 'a' | 'sup';
|
|
4
|
+
children: Inline[];
|
|
5
|
+
href?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface Heading {
|
|
10
|
+
text: string;
|
|
11
|
+
content: Content;
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
visuallyHidden: boolean;
|
|
14
|
+
column: number;
|
|
15
|
+
colSpan: number;
|
|
16
|
+
rowSpan: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TableModel {
|
|
19
|
+
label: string;
|
|
20
|
+
headings: Heading[][];
|
|
21
|
+
columns: Heading[][];
|
|
22
|
+
stubCount: number;
|
|
23
|
+
rows: {
|
|
24
|
+
stubs: Content[];
|
|
25
|
+
values: Content[];
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export declare function readTable(table: HTMLTableElement, rowLimit?: number): TableModel | undefined;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from 'lit';
|
|
2
|
+
export declare class ScbTableNext extends LitElement {
|
|
3
|
+
private _model?;
|
|
4
|
+
private _mobile;
|
|
5
|
+
private _resize?;
|
|
6
|
+
private _observer?;
|
|
7
|
+
private _frame?;
|
|
8
|
+
private _widthReady;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
private _queueRead;
|
|
13
|
+
private _read;
|
|
14
|
+
private _content;
|
|
15
|
+
private _mobileRows;
|
|
16
|
+
render(): TemplateResult<1>;
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'scb-table-next': ScbTableNext;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/scb-components/scb-table-next/read-table.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e.querySelector("a, sup")) return e.textContent?.trim() ?? "";
|
|
4
|
+
let t = (e) => {
|
|
5
|
+
if (e.nodeType === Node.TEXT_NODE) return [e.textContent ?? ""];
|
|
6
|
+
if (!(e instanceof Element)) return [];
|
|
7
|
+
let n = Array.from(e.childNodes).flatMap(t);
|
|
8
|
+
return e.localName === "sup" ? [{
|
|
9
|
+
tag: "sup",
|
|
10
|
+
children: n
|
|
11
|
+
}] : e.localName === "a" ? [{
|
|
12
|
+
tag: "a",
|
|
13
|
+
children: n,
|
|
14
|
+
href: e.getAttribute("href"),
|
|
15
|
+
title: e.getAttribute("title") || void 0,
|
|
16
|
+
ariaLabel: e.getAttribute("aria-label") || void 0
|
|
17
|
+
}] : n;
|
|
18
|
+
};
|
|
19
|
+
return Array.from(e.childNodes).flatMap(t);
|
|
20
|
+
}
|
|
21
|
+
var t = (e) => e.scope === "row" || e.classList.contains("forspalt") || e.tagName === "TH" && !e.scope;
|
|
22
|
+
function n(n, r = Infinity) {
|
|
23
|
+
let i = n.tHead ? Array.from(n.tHead.rows) : [];
|
|
24
|
+
if (!n.tHead) for (let e of Array.from(n.rows)) {
|
|
25
|
+
if (!e.cells.length || !Array.from(e.cells).every((e) => e.tagName === "TH")) break;
|
|
26
|
+
i.push(e);
|
|
27
|
+
}
|
|
28
|
+
if (!i.length) return;
|
|
29
|
+
let a = new Set(i), o = Array.from(n.rows).filter((e) => !a.has(e));
|
|
30
|
+
if (!o.length || o.length > r) return;
|
|
31
|
+
let s = o.reduce((e, n) => {
|
|
32
|
+
let r = Array.from(n.cells).findIndex((e) => !t(e));
|
|
33
|
+
return Math.max(e, r < 0 ? n.cells.length : r);
|
|
34
|
+
}, 1), c = o[0].cells.length - s;
|
|
35
|
+
if ((o.length + i.length + 1) * c > r) return;
|
|
36
|
+
let l = new Set(Array.from(n.querySelectorAll("[id]"), (e) => e.id));
|
|
37
|
+
if (n.querySelector("table, button, input, select, textarea, [tabindex], [contenteditable], [role]") || Array.from(n.querySelectorAll("*")).some((e) => e.localName.includes("-")) || Array.from(n.querySelectorAll("a")).some((e) => {
|
|
38
|
+
let t = e.getAttribute("href") || "", n;
|
|
39
|
+
try {
|
|
40
|
+
n = decodeURIComponent(t.slice(1));
|
|
41
|
+
} catch {
|
|
42
|
+
return !0;
|
|
43
|
+
}
|
|
44
|
+
return !e.closest("th, td") || l.has(n) || !t.startsWith("#") || e.getAttribute("href") === "#" || e.hasAttribute("target") || e.hasAttribute("download") || e.getAttributeNames().some((e) => e.startsWith("on")) || e.hasAttribute("aria-labelledby") || e.hasAttribute("aria-describedby");
|
|
45
|
+
}) || n.getAttribute("role") && n.getAttribute("role") !== "table") return;
|
|
46
|
+
let u = i.map(() => []), d = i.map((t, n) => {
|
|
47
|
+
let r = 0;
|
|
48
|
+
return Array.from(t.cells).map((t) => {
|
|
49
|
+
for (; u[n][r];) r++;
|
|
50
|
+
let a = t.cloneNode(!0);
|
|
51
|
+
a.querySelectorAll("[hidden], .visually-hidden, .sr-only").forEach((e) => e.remove());
|
|
52
|
+
let o = t.textContent?.trim() ?? "", s = !!o && !a.textContent?.trim(), c = {
|
|
53
|
+
text: o,
|
|
54
|
+
content: e(t),
|
|
55
|
+
visuallyHidden: s,
|
|
56
|
+
ariaLabel: t.getAttribute("aria-label") || (s ? o : void 0),
|
|
57
|
+
column: r,
|
|
58
|
+
colSpan: t.colSpan,
|
|
59
|
+
rowSpan: t.rowSpan || i.length - n
|
|
60
|
+
}, l = r + c.colSpan, d = n + c.rowSpan;
|
|
61
|
+
if (l > 256 || d > u.length) throw RangeError("header-grid");
|
|
62
|
+
for (let e = n; e < d; e++) for (let t = r; t < l; t++) {
|
|
63
|
+
if (u[e][t]) throw RangeError("header-grid");
|
|
64
|
+
u[e][t] = c;
|
|
65
|
+
}
|
|
66
|
+
return r = l, c;
|
|
67
|
+
});
|
|
68
|
+
}), f = u[0].length;
|
|
69
|
+
if (f < 2 || u.some((e) => e.length !== f || Array.from({ length: f }, (t, n) => !e[n]).some(Boolean)) || s >= f || o.some((e) => e.cells.length !== f || Array.from(e.cells).some((e) => e.colSpan !== 1 || e.rowSpan !== 1) || !Array.from(e.cells).slice(0, s).some((e) => e.textContent?.trim()) || Array.from(e.cells).slice(s).some((e) => e.tagName === "TH" || t(e)))) return;
|
|
70
|
+
if (o.some((e) => Array.from(e.cells).slice(s).every((e) => !e.textContent?.trim()))) {
|
|
71
|
+
let e = o.map((e) => JSON.stringify(Array.from(e.cells).slice(0, s).map((e) => e.textContent?.trim())));
|
|
72
|
+
if (new Set(e).size !== e.length) return;
|
|
73
|
+
}
|
|
74
|
+
let p = Array.from({ length: f - s }, (e, t) => [...new Set(u.map((e) => e[t + s]))].filter((e) => e.text));
|
|
75
|
+
if (!p.some((e) => !e.length)) return {
|
|
76
|
+
label: n.getAttribute("aria-label") || n.caption?.textContent?.trim() || "",
|
|
77
|
+
headings: d,
|
|
78
|
+
columns: p,
|
|
79
|
+
stubCount: s,
|
|
80
|
+
rows: o.map((t) => ({
|
|
81
|
+
stubs: Array.from(t.cells).slice(0, s).map(e),
|
|
82
|
+
values: Array.from(t.cells).slice(s).map(e)
|
|
83
|
+
}))
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { n as readTable };
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import e from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
2
|
+
import { readTable as t } from "./read-table.js";
|
|
3
|
+
import { LitElement as n, css as r, html as i, nothing as a } from "lit";
|
|
4
|
+
import { customElement as o, state as s } from "lit/decorators.js";
|
|
5
|
+
import { ifDefined as c } from "lit/directives/if-defined.js";
|
|
6
|
+
//#region src/scb-components/scb-table-next/scb-table-next.ts
|
|
7
|
+
var l = 200, u = /* @__PURE__ */ new WeakSet(), d = r`
|
|
8
|
+
scb-table-next > table {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
inline-size: 100%;
|
|
11
|
+
border-collapse: separate;
|
|
12
|
+
border-spacing: 0;
|
|
13
|
+
border: 0;
|
|
14
|
+
/* Ramen överlappar cellkanterna så att ytterlinjerna förblir 1 px. */
|
|
15
|
+
outline: 1px solid var(--scb-tables-strong-outline-color);
|
|
16
|
+
outline-offset: -1px;
|
|
17
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
background: var(--scb-tables-surface-color);
|
|
20
|
+
color: inherit;
|
|
21
|
+
font: inherit;
|
|
22
|
+
}
|
|
23
|
+
scb-table-next > table > :is(thead, tbody, tfoot) > tr > :is(th, td) {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
26
|
+
min-inline-size: 2.5rem;
|
|
27
|
+
border-block-end: 1px solid var(--scb-tables-strong-outline-color);
|
|
28
|
+
border-inline-end: 1px solid var(--scb-tables-strong-outline-color);
|
|
29
|
+
font-variant-numeric: tabular-nums;
|
|
30
|
+
font-weight: inherit;
|
|
31
|
+
}
|
|
32
|
+
scb-table-next > table > :is(thead, tbody, tfoot) > tr > th,
|
|
33
|
+
scb-table-next > table > tbody > tr > .forspalt { background: var(--scb-tables-alternate-surface-color); }
|
|
34
|
+
scb-table-next > table > thead > tr > * { background: var(--scb-tables-alternate-surface-color); }
|
|
35
|
+
scb-table-next > table > thead > tr > th { font-weight: var(--weight-bold); text-align: center; }
|
|
36
|
+
scb-table-next > table > thead > tr:last-child > th { text-align: end; }
|
|
37
|
+
scb-table-next > table > :is(tbody, tfoot) > tr > :is(th, td) { text-align: end; }
|
|
38
|
+
scb-table-next > table > :is(tbody, tfoot) > tr > :first-child,
|
|
39
|
+
scb-table-next > table > :is(tbody, tfoot) > tr > .forspalt,
|
|
40
|
+
scb-table-next > table > :is(tbody, tfoot) > tr > th:is([scope="row"], [scope="rowgroup"]) { text-align: start; }
|
|
41
|
+
scb-table-next > table > tbody > tr > .forspalt { min-inline-size: 0; }
|
|
42
|
+
scb-table-next > table > tbody > tr > :first-child:not(:has(~ th, ~ .forspalt)) { min-inline-size: 0; }
|
|
43
|
+
scb-table-next > table > tbody > tr:hover > * { background: var(--scb-tables-alternate-surface-color); }
|
|
44
|
+
scb-table-next > table a { color: inherit; text-decoration: underline; }
|
|
45
|
+
scb-table-next > table a:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }
|
|
46
|
+
`, f = class extends n {
|
|
47
|
+
constructor(...e) {
|
|
48
|
+
super(...e), this._mobile = !1, this._widthReady = !1;
|
|
49
|
+
}
|
|
50
|
+
static {
|
|
51
|
+
this.styles = r`
|
|
52
|
+
:host {
|
|
53
|
+
display: block;
|
|
54
|
+
min-inline-size: 0;
|
|
55
|
+
color: var(--scb-tables-content-color, var(--md-sys-color-on-surface));
|
|
56
|
+
font-family: var(--scb-tables-cell-font, var(--brand-font, Inter, Arial, sans-serif));
|
|
57
|
+
font-size: var(--scb-tables-cell-size);
|
|
58
|
+
line-height: var(--scb-tables-cell-line-height);
|
|
59
|
+
font-weight: var(--weight-regular);
|
|
60
|
+
}
|
|
61
|
+
* { box-sizing: border-box; }
|
|
62
|
+
:host([hidden]), [hidden] { display: none !important; }
|
|
63
|
+
.scroll { max-inline-size: 100%; overflow-x: auto; padding-bottom: var(--spacing-8, 24px); }
|
|
64
|
+
.scroll::-webkit-scrollbar {
|
|
65
|
+
border-radius: var(--md-sys-shape-corner-large);
|
|
66
|
+
height: 8px;
|
|
67
|
+
width: 10px;
|
|
68
|
+
}
|
|
69
|
+
.scroll::-webkit-scrollbar-thumb {
|
|
70
|
+
background: var(--scb-tables-scrollbar-thumb-color, var(--md-sys-color-on-surface));
|
|
71
|
+
border-radius: var(--md-sys-shape-corner-large);
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
.scroll::-webkit-scrollbar-track {
|
|
75
|
+
background: var(--scb-tables-scrollbar-track-color, var(--md-sys-color-secondary-container));
|
|
76
|
+
border-radius: var(--md-sys-shape-corner-large);
|
|
77
|
+
}
|
|
78
|
+
a { color: inherit; text-decoration: underline; }
|
|
79
|
+
a:focus-visible, .scroll:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }
|
|
80
|
+
table {
|
|
81
|
+
inline-size: 100%;
|
|
82
|
+
border-collapse: separate;
|
|
83
|
+
border-spacing: 0;
|
|
84
|
+
border: 1px solid var(--scb-tables-strong-outline-color);
|
|
85
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
background: var(--scb-tables-surface-color);
|
|
88
|
+
color: inherit;
|
|
89
|
+
font: inherit;
|
|
90
|
+
}
|
|
91
|
+
th, td {
|
|
92
|
+
min-inline-size: 2.5rem;
|
|
93
|
+
font-variant-numeric: tabular-nums;
|
|
94
|
+
font-weight: inherit;
|
|
95
|
+
}
|
|
96
|
+
.stub { text-align: start; }
|
|
97
|
+
td { text-align: end; }
|
|
98
|
+
tbody tr:hover > * { background: var(--scb-tables-alternate-surface-color); }
|
|
99
|
+
.mobile th, .mobile td {
|
|
100
|
+
padding-block: var(--spacing-2);
|
|
101
|
+
padding-inline: var(--spacing-5);
|
|
102
|
+
border: 0;
|
|
103
|
+
background: transparent;
|
|
104
|
+
vertical-align: top;
|
|
105
|
+
}
|
|
106
|
+
.mobile .stub {
|
|
107
|
+
min-inline-size: 0;
|
|
108
|
+
padding-inline-end: calc(var(--spacing-1) / 2);
|
|
109
|
+
}
|
|
110
|
+
.mobile td { inline-size: 1%; white-space: nowrap; }
|
|
111
|
+
.mobile .stub-headings > th { text-align: start; font-weight: var(--weight-bold); }
|
|
112
|
+
.mobile .stub-headings > th:empty { padding: 0; }
|
|
113
|
+
.mobile .outer > th {
|
|
114
|
+
padding-block: var(--spacing-5);
|
|
115
|
+
background: var(--scb-tables-alternate-surface-color);
|
|
116
|
+
font-weight: var(--weight-bold);
|
|
117
|
+
text-align: start;
|
|
118
|
+
border-block-start: 1px solid var(--scb-tables-strong-outline-color);
|
|
119
|
+
}
|
|
120
|
+
.mobile tbody:first-child > .outer:first-child > th { border-block-start: 0; }
|
|
121
|
+
.mobile .group > th {
|
|
122
|
+
padding-block-start: 0;
|
|
123
|
+
font-weight: var(--weight-bold);
|
|
124
|
+
text-align: start;
|
|
125
|
+
}
|
|
126
|
+
.mobile .group.first > th { padding-block-start: calc(var(--spacing-8) + var(--spacing-2)); }
|
|
127
|
+
.mobile .last > * { padding-block-end: calc(var(--spacing-8) + var(--spacing-2)); }
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
connectedCallback() {
|
|
131
|
+
super.connectedCallback();
|
|
132
|
+
let e = this.getRootNode();
|
|
133
|
+
if (!u.has(e)) {
|
|
134
|
+
let t = this.ownerDocument.createElement("style");
|
|
135
|
+
t.textContent = d.cssText, (e instanceof Document ? e.head : e).appendChild(t), u.add(e);
|
|
136
|
+
}
|
|
137
|
+
this._observer = new MutationObserver(() => this._queueRead()), this._observer.observe(this, {
|
|
138
|
+
childList: !0,
|
|
139
|
+
characterData: !0,
|
|
140
|
+
subtree: !0,
|
|
141
|
+
attributes: !0,
|
|
142
|
+
attributeFilter: [
|
|
143
|
+
"colspan",
|
|
144
|
+
"rowspan",
|
|
145
|
+
"aria-label",
|
|
146
|
+
"role",
|
|
147
|
+
"tabindex",
|
|
148
|
+
"contenteditable",
|
|
149
|
+
"scope",
|
|
150
|
+
"class",
|
|
151
|
+
"hidden",
|
|
152
|
+
"href",
|
|
153
|
+
"title",
|
|
154
|
+
"id",
|
|
155
|
+
"target",
|
|
156
|
+
"download",
|
|
157
|
+
"aria-labelledby",
|
|
158
|
+
"aria-describedby"
|
|
159
|
+
]
|
|
160
|
+
}), this._resize = new ResizeObserver(([e]) => {
|
|
161
|
+
let t = e.contentRect.width;
|
|
162
|
+
if (t <= 0) {
|
|
163
|
+
this._widthReady = !1;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
let n = t <= 575, r = n !== this._mobile;
|
|
167
|
+
this._mobile = n, (!this._widthReady || r) && (this._widthReady = !0, this._read());
|
|
168
|
+
}), this._resize.observe(this);
|
|
169
|
+
}
|
|
170
|
+
disconnectedCallback() {
|
|
171
|
+
this._observer?.disconnect(), this._resize?.disconnect(), this._frame !== void 0 && cancelAnimationFrame(this._frame), this._frame = void 0, this._widthReady = !1, super.disconnectedCallback();
|
|
172
|
+
}
|
|
173
|
+
_queueRead() {
|
|
174
|
+
!this._mobile || !this._widthReady || this._frame !== void 0 || (this._frame = requestAnimationFrame(() => {
|
|
175
|
+
this._frame = void 0, this._read();
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
_read() {
|
|
179
|
+
if (!this._widthReady) return;
|
|
180
|
+
if (!this._mobile) {
|
|
181
|
+
this._model = void 0;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
let e = this.querySelectorAll("table");
|
|
185
|
+
try {
|
|
186
|
+
this._model = e.length === 1 ? t(e[0], l) : void 0;
|
|
187
|
+
} catch (e) {
|
|
188
|
+
if (!(e instanceof RangeError)) throw e;
|
|
189
|
+
this._model = void 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
_content(e) {
|
|
193
|
+
return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.tag === "sup" ? i`<sup>${this._content(e.children)}</sup>` : i`<a href=${e.href} title=${c(e.title)} aria-label=${c(e.ariaLabel)}>${this._content(e.children)}</a>`);
|
|
194
|
+
}
|
|
195
|
+
_mobileRows(e) {
|
|
196
|
+
let t = [], n = e.headings.flat().filter((t) => (t.text || t.ariaLabel) && t.column + t.colSpan <= e.stubCount), r = n.map((e) => e.ariaLabel || e.text).join(" "), o = n.filter((e) => !e.visuallyHidden && e.text), s = [], l = [];
|
|
197
|
+
return e.columns.forEach((u, d) => {
|
|
198
|
+
let f = 0;
|
|
199
|
+
for (; f < u.length && u[f] === s[f];) f++;
|
|
200
|
+
l.length = f, u.forEach((e, n) => {
|
|
201
|
+
if (n < f) return;
|
|
202
|
+
let r = `group-${d}-${n}`;
|
|
203
|
+
l.push(r);
|
|
204
|
+
let a = n === 0 ? "outer" : `group${f === 0 ? " first" : ""}`;
|
|
205
|
+
t.push(i`<tr class=${a}><th id=${r} aria-label=${c(e.ariaLabel)} scope="col" colspan="2">${this._content(e.content)}</th></tr>`);
|
|
206
|
+
});
|
|
207
|
+
let p = n.length ? `stub-heading-${d}` : void 0;
|
|
208
|
+
p && (l.push(p), t.push(i`<tr class="stub-headings"><th id=${p} scope="col" colspan="2" aria-label=${c(r)}>${o.map((e, t) => i`${t ? " " : a}<span>${this._content(e.content)}</span>`)}</th></tr>`)), e.rows.forEach((n, r) => {
|
|
209
|
+
let o = `mobile-row-${d}-${r}`;
|
|
210
|
+
t.push(i`<tr class=${r === e.rows.length - 1 ? "last" : ""}>
|
|
211
|
+
<th class="stub" scope="row" id=${o} headers=${c(p)}>${n.stubs.filter((e) => e !== "").map((e, t) => i`${t ? " " : a}${this._content(e)}`)}</th>
|
|
212
|
+
<td headers=${[...l, o].join(" ")}>${this._content(n.values[d])}</td></tr>`);
|
|
213
|
+
}), s = u;
|
|
214
|
+
}), t;
|
|
215
|
+
}
|
|
216
|
+
render() {
|
|
217
|
+
let e = this._model;
|
|
218
|
+
return i`<div class="scroll" tabindex="0" ?hidden=${!!e}><slot @slotchange=${this._queueRead}></slot></div>
|
|
219
|
+
${e ? i`<table class="mobile" aria-label=${c(e.label || void 0)}>
|
|
220
|
+
<tbody>${this._mobileRows(e)}</tbody>
|
|
221
|
+
</table>` : a}`;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
e([s()], f.prototype, "_model", void 0), e([s()], f.prototype, "_mobile", void 0), f = e([o("scb-table-next")], f);
|
|
225
|
+
//#endregion
|
|
226
|
+
export { f as ScbTableNext };
|