scb-wc-test 0.1.246 → 0.1.247
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/mvc/components/scb-viz/scb-viz.js +39 -15
- package/package.json +2 -2
- package/scb-viz/scb-viz.d.ts +3 -0
- package/scb-viz/scb-viz.js +183 -144
- package/scb-wc-test.bundle.js +371 -347
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as V,n as h,r as R,i as D,k as T,x as s,E as A,l as z,t as H}from"../../vendor/vendor.js";import"../scb-chip/scb-chip.js";import"../scb-segmented-button/scb-segmented-button.js";import"../scb-segmented-button/scb-segmented-item.js";import"../scb-accordion/scb-accordion.js";import"../scb-divider/scb-divider.js";import"../scb-horizontal-scroller/scb-horizontal-scroller.js";import"../../vendor/preload-helper.js";import"../../vendor/vendor-material.js";import"../scb-accordion/scb-accordion-item.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.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(l,r,i){try{customElements.get(l)||e(l,r,i)}catch(a){var n=String(a||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var E=Object.defineProperty,P=Object.getOwnPropertyDescriptor,k=t=>{throw TypeError(t)},o=(t,e,l,r)=>{for(var i=r>1?void 0:r?P(e,l):e,n=t.length-1,a;n>=0;n--)(a=t[n])&&(i=(r?a(e,l,i):a(i))||i);return r&&i&&E(e,l,i),i},I=(t,e,l)=>e.has(t)||k("Cannot "+l),W=(t,e,l)=>e.has(t)?k("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,l),b=(t,e,l)=>(I(t,e,"access private method"),l),v,M,y,L;const C=`<svg version="1.1" id="Lager_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
2
2
|
viewBox="0 0 727.3 87.3" style="enable-background:new 0 0 727.3 87.3;" xml:space="preserve" fill="currentColor">
|
|
3
3
|
<style type="text/css">
|
|
4
4
|
.st0{clip-path:url(#SVGID_00000118375311472882578510000008414848687067442345_);}
|
|
@@ -113,19 +113,19 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
113
113
|
<path d="M688.2,24.4h5.8v6h-5.8V24.4z M688.2,36.6h5.8v30.1h-5.8V36.6z"/>
|
|
114
114
|
<path d="M701.8,24.4h5.8v26.3h0.1l11.2-14.1h7l-10,11.7l11.4,18.3H720l-7.7-14l-4.6,5.4v8.7h-5.8V24.4H701.8z"/>
|
|
115
115
|
</svg>
|
|
116
|
-
`;let
|
|
116
|
+
`;let c=class extends D{constructor(){super(...arguments),W(this,v),this.variant="Standard",this.selectedChip="Diagram",this.title="",this.subtitle="",this.description="",this.comment="",this.source="",this.footnote="",this.lang="sv",this.imageHref="",this.officialStatistics=!1,this.disableToggle=!1,this.contentMaxWidth="",this.containerMaxWidth="",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0}get descriptionLabel(){return this.lang==="en"?"Description of the chart":"Beskrivning av diagrammet"}get moreAboutStatsLabel(){return this.lang==="en"?"More about the statistics":"Mer om statistiken"}get commentLabel(){return this.lang==="en"?"Comments":"Kommentar"}get sourceLabel(){return this.lang==="en"?"Source":"Källa"}get footnoteLabel(){return this.lang==="en"?"Footnotes":"Fotnot"}get officialStatisticsLabel(){return this.lang==="en"?"Official statistics of Sweden":"Sveriges officiella statistik"}get officialStatisticsTitle(){return this.lang==="en"?"Part of Official statistics of Sweden":"Tillhör Sveriges officiella statistik"}get officialStatisticsAlt(){return this.lang==="en"?"Read more about Official statistics of Sweden":"Läs mer om Sveriges officiella statistik"}firstUpdated(t){this._readTableDataFromSlot(),b(this,v,M).call(this),b(this,v,L).call(this),this._syncChipClass()}updated(t){super.updated(t),(t.has("selectedChip")||t.has("variant"))&&this._syncChipClass(),t.has("selectedChip")&&this._dispatchSelectedChipChanged(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&b(this,v,M).call(this),t.has("containerMaxWidth")&&b(this,v,L).call(this)}_onTableSlotChange(t){const e=t.target;e&&this._readTableDataFromSlot(e)}_normalizeRenderableCell(t){return t&&typeof t=="object"&&"html"in t&&"text"in t?{html:typeof t.html=="string"?t.html:"",text:typeof t.text=="string"?t.text:""}:{html:"",text:t==null?"":String(t)}}_readTableDataFromSlot(t){const e=t||this.shadowRoot?.querySelector('slot[name="table"]');if(!e)return;const l=e.assignedElements({flatten:!0}),r=[];l.forEach(d=>{if(d.tagName==="TABLE"){r.push(d);return}d.querySelectorAll("table").forEach(g=>r.push(g))});const i=r[0];if(!i){this._slottedTableData=void 0;return}const n=[],a=[],p=[],m=d=>d?(d.textContent??"").replace(/\s+/g," ").trim():"",f=d=>d?{html:(d.innerHTML??"").trim(),text:m(d)}:{html:"",text:""},u=i.querySelector("thead tr");u&&Array.from(u.querySelectorAll("th, td")).forEach(g=>n.push(f(g)));const w=Array.from(i.querySelectorAll("tbody tr")),$=w.length>0?w:Array.from(i.querySelectorAll("tr")).filter(d=>d.closest("thead")===null);if($.forEach(d=>{const g=Array.from(d.querySelectorAll("th, td"));if(g.length===0)return;const S=g[0].tagName==="TH"&&d.closest("thead")===null&&d.closest("tfoot")===null;p.push(S);const _=[];g.forEach(x=>_.push(f(x))),a.push(_)}),!u&&a.length>0){const d=a[0],g=$[0],S=Array.from(g?.querySelectorAll("th, td")??[]);S.length>0&&S.every(x=>x.tagName==="TH")&&g?.closest("tbody")===null&&(n.splice(0,n.length,...d),a.shift(),p.shift())}this._slottedTableData={headers:n.length>0?n:void 0,rows:a,rowHeaderRows:p.length>0?p:void 0}}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(i=>i.length)),l=i=>{if(i==null)return!1;if(typeof i=="number")return!0;const n=String(i).replace(/[\u00A0\u202F\s]+/g,"").trim();return n?/^-?\d+(?:[.,]\d+)?$/.test(n):!1},r=[];for(let i=0;i<e;i+=1){if(i===0){r.push("left");continue}const n=t.rows.map(p=>this._normalizeRenderableCell(p[i]).text).filter(p=>p!==""&&p!==null&&p!==void 0),a=n.length>0&&n.every(l);r.push(a?"right":"left")}return r}_getResolvedContentMaxWidth(){return this.contentMaxWidth?.trim()||""}_renderTable(){const t=this.tableData??this._slottedTableData;if(!t||!t.rows||t.rows.length===0)return null;const e=this._inferTableAlignments(t),l=Math.max(t.headers?.length??0,...t.rows.map(a=>a.length)),r=(t.headers??[]).map(a=>this._normalizeRenderableCell(a)),i=t.rows.map(a=>{const p=a.map(m=>this._normalizeRenderableCell(m));for(;p.length<l;)p.push({html:"",text:""});return p}),n=t.rowHeaderRows??[];return s`
|
|
117
117
|
<table class="scb-viz-table" part="table">
|
|
118
|
-
${
|
|
118
|
+
${r.length>0?s`
|
|
119
119
|
<thead>
|
|
120
120
|
<tr>
|
|
121
|
-
${
|
|
121
|
+
${r.map((a,p)=>{const m=e[p]==="right"?"align-right":"align-left";return s`<th scope="col" class=${m}>${a.html?T(a.html):a.text}</th>`})}
|
|
122
122
|
</tr>
|
|
123
123
|
</thead>
|
|
124
124
|
`:""}
|
|
125
125
|
<tbody>
|
|
126
|
-
${i.map((a,
|
|
126
|
+
${i.map((a,p)=>{const m=n[p]===!0;return s`
|
|
127
127
|
<tr>
|
|
128
|
-
${a.map((f,u)=>{const
|
|
128
|
+
${a.map((f,u)=>{const w=e[u]==="right"?"align-right":"align-left",$=f.html?T(f.html):f.text;return u===0&&m?s`<th scope="row" class=${w}>${$}</th>`:s`<td class=${w}>${$}</td>`})}
|
|
129
129
|
</tr>
|
|
130
130
|
`})}
|
|
131
131
|
</tbody>
|
|
@@ -186,7 +186,7 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
186
186
|
aria-label="${this.officialStatisticsAlt}"
|
|
187
187
|
>
|
|
188
188
|
<span class="sos-logotype-small" aria-hidden="true">
|
|
189
|
-
${
|
|
189
|
+
${z(C)}
|
|
190
190
|
</span>
|
|
191
191
|
</a>
|
|
192
192
|
`:""}
|
|
@@ -208,7 +208,10 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
208
208
|
${this.title?s` <div class="label">${this.title}</div> `:""}
|
|
209
209
|
${this.subtitle?s` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
210
210
|
</div>
|
|
211
|
-
<div
|
|
211
|
+
<div
|
|
212
|
+
class="content image-content"
|
|
213
|
+
style=${this._getResolvedContentMaxWidth()?`max-width: ${this._getResolvedContentMaxWidth()}; --scb-viz-content-max-width: ${this._getResolvedContentMaxWidth()};`:""}
|
|
214
|
+
>
|
|
212
215
|
<img src="${this.imageHref}" alt="Image figure" />
|
|
213
216
|
</div>
|
|
214
217
|
<div class="footer">
|
|
@@ -251,7 +254,7 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
251
254
|
aria-label="${this.officialStatisticsAlt}"
|
|
252
255
|
>
|
|
253
256
|
<span class="sos-logotype-small" aria-hidden="true">
|
|
254
|
-
${
|
|
257
|
+
${z(C)}
|
|
255
258
|
</span>
|
|
256
259
|
</a>
|
|
257
260
|
`:""}
|
|
@@ -294,12 +297,17 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
294
297
|
`:""}
|
|
295
298
|
<div class="content">
|
|
296
299
|
<scb-horizontal-scroller
|
|
297
|
-
width
|
|
300
|
+
width=${this._getResolvedContentMaxWidth()||A}
|
|
298
301
|
class="diagram-scroller"
|
|
299
302
|
variant="inline"
|
|
300
303
|
show-scrollbar
|
|
301
304
|
>
|
|
302
|
-
<
|
|
305
|
+
<div
|
|
306
|
+
class="diagram-content"
|
|
307
|
+
style=${this._getResolvedContentMaxWidth()?`--scb-viz-content-max-width: ${this._getResolvedContentMaxWidth()};`:""}
|
|
308
|
+
>
|
|
309
|
+
<slot name="diagram"></slot>
|
|
310
|
+
</div>
|
|
303
311
|
</scb-horizontal-scroller>
|
|
304
312
|
<scb-horizontal-scroller
|
|
305
313
|
width="600px"
|
|
@@ -350,7 +358,7 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
350
358
|
aria-label="${this.officialStatisticsAlt}"
|
|
351
359
|
>
|
|
352
360
|
<span class="sos-logotype-small" aria-hidden="true">
|
|
353
|
-
${
|
|
361
|
+
${z(C)}
|
|
354
362
|
</span>
|
|
355
363
|
</a>
|
|
356
364
|
`:""}
|
|
@@ -366,14 +374,14 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
366
374
|
></slot>
|
|
367
375
|
<slot></slot>
|
|
368
376
|
</div>
|
|
369
|
-
`}}_syncChipClass(){const t=this.variant==="Standard";this.classList.toggle("chip-diagram",t&&this.selectedChip==="Diagram"),this.classList.toggle("chip-table",t&&this.selectedChip==="Table")}_dispatchSelectedChipChanged(){const t={selectedChip:this.selectedChip};this.dispatchEvent(new CustomEvent("selected-chip-changed",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("selectedchipchanged",{detail:t,bubbles:!0,composed:!0}))}_onSegmentedChange(t){const e=t.detail?.value;this.selectedChip===e?this.selectedChip=null:this.selectedChip=e}};
|
|
377
|
+
`}}_syncChipClass(){const t=this.variant==="Standard";this.classList.toggle("chip-diagram",t&&this.selectedChip==="Diagram"),this.classList.toggle("chip-table",t&&this.selectedChip==="Table")}_dispatchSelectedChipChanged(){const t={selectedChip:this.selectedChip};this.dispatchEvent(new CustomEvent("selected-chip-changed",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("selectedchipchanged",{detail:t,bubbles:!0,composed:!0}))}_onSegmentedChange(t){const e=t.detail?.value;this.selectedChip===e?this.selectedChip=null:this.selectedChip=e}};v=new WeakSet;M=function(){const t=b(this,v,y).call(this,this.spacing),e=b(this,v,y).call(this,this.spacingTop)??t,l=b(this,v,y).call(this,this.spacingBottom)??t,r=b(this,v,y).call(this,this.spacingLeft),i=b(this,v,y).call(this,this.spacingRight);e?this.style.setProperty("--scb-viz-spacing-block-start",e):this.style.removeProperty("--scb-viz-spacing-block-start"),l?this.style.setProperty("--scb-viz-spacing-block-end",l):this.style.removeProperty("--scb-viz-spacing-block-end"),r?this.style.setProperty("--scb-viz-spacing-inline-start",r):this.style.removeProperty("--scb-viz-spacing-inline-start"),i?this.style.setProperty("--scb-viz-spacing-inline-end",i):this.style.removeProperty("--scb-viz-spacing-inline-end")};y=function(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};L=function(){const t=this.containerMaxWidth?.trim();t?this.style.setProperty("--scb-viz-container-max-width",t):this.style.removeProperty("--scb-viz-container-max-width")};c.styles=V`
|
|
370
378
|
:host {
|
|
371
379
|
display: block;
|
|
372
380
|
font-family: var(--brand-font);
|
|
373
381
|
color: var(--md-sys-color-on-surface);
|
|
374
382
|
background: var(--md-sys-color-surface);
|
|
375
383
|
padding: var(--spacing-7);
|
|
376
|
-
max-width: 100
|
|
384
|
+
max-width: var(--scb-viz-container-max-width, 100%);
|
|
377
385
|
border-radius: var(--spacing-04, 16px);
|
|
378
386
|
border: 1px solid var(--md-sys-color-outline-variant);
|
|
379
387
|
/* Avstånd till omgivande innehåll styrs av spacing-attributen via CSS-variabler */
|
|
@@ -478,6 +486,22 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
478
486
|
display: none;
|
|
479
487
|
}
|
|
480
488
|
|
|
489
|
+
.image-content {
|
|
490
|
+
display: none;
|
|
491
|
+
width: 100%;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.diagram-content {
|
|
495
|
+
width: 100%;
|
|
496
|
+
max-width: var(--scb-viz-content-max-width, 100%);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
::slotted([slot='diagram']) {
|
|
500
|
+
display: block;
|
|
501
|
+
width: 100%;
|
|
502
|
+
max-width: 100%;
|
|
503
|
+
}
|
|
504
|
+
|
|
481
505
|
:host([variant='Table']) .table-scroller {
|
|
482
506
|
display: flex;
|
|
483
507
|
}
|
|
@@ -548,4 +572,4 @@ import{a as k,n as p,r as V,i as D,k as M,x as s,l as x,t as A}from"../../vendor
|
|
|
548
572
|
text-align: right;
|
|
549
573
|
white-space: nowrap;
|
|
550
574
|
}
|
|
551
|
-
`;
|
|
575
|
+
`;o([h({type:String,reflect:!0})],c.prototype,"variant",2);o([h({type:String,reflect:!0,attribute:"selected-chip"})],c.prototype,"selectedChip",2);o([h({type:String,reflect:!0})],c.prototype,"title",2);o([h({type:String,reflect:!0})],c.prototype,"subtitle",2);o([h({type:String,reflect:!0})],c.prototype,"description",2);o([h({type:String,reflect:!0})],c.prototype,"comment",2);o([h({type:String,reflect:!0})],c.prototype,"source",2);o([h({type:String,reflect:!0})],c.prototype,"footnote",2);o([h({type:String,reflect:!0,attribute:"lang"})],c.prototype,"lang",2);o([h({type:String,reflect:!0,attribute:"image-href"})],c.prototype,"imageHref",2);o([h({type:Boolean,reflect:!0,attribute:"official-statistics"})],c.prototype,"officialStatistics",2);o([h({type:Boolean,reflect:!0,attribute:"disable-toggle"})],c.prototype,"disableToggle",2);o([h({type:String,attribute:"content-max-width"})],c.prototype,"contentMaxWidth",2);o([h({type:String,attribute:"container-max-width"})],c.prototype,"containerMaxWidth",2);o([h({attribute:!1})],c.prototype,"tableData",2);o([R()],c.prototype,"_slottedTableData",2);o([h({type:String,reflect:!0})],c.prototype,"spacing",2);o([h({type:String,attribute:"spacing-top",reflect:!0})],c.prototype,"spacingTop",2);o([h({type:String,attribute:"spacing-bottom",reflect:!0})],c.prototype,"spacingBottom",2);o([h({type:String,attribute:"spacing-left",reflect:!0})],c.prototype,"spacingLeft",2);o([h({type:String,attribute:"spacing-right",reflect:!0})],c.prototype,"spacingRight",2);c=o([H("scb-viz")],c);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.247",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -382,5 +382,5 @@
|
|
|
382
382
|
},
|
|
383
383
|
"./mvc/*": "./mvc/*"
|
|
384
384
|
},
|
|
385
|
-
"buildHash": "
|
|
385
|
+
"buildHash": "9A67DE3C4F1EBD1A13CC87D2134B1FC204D73222BC8DBC1F01F73E706573F584"
|
|
386
386
|
}
|
package/scb-viz/scb-viz.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export declare class ScbViz extends LitElement {
|
|
|
24
24
|
imageHref: string;
|
|
25
25
|
officialStatistics: boolean;
|
|
26
26
|
disableToggle: boolean;
|
|
27
|
+
contentMaxWidth: string;
|
|
28
|
+
containerMaxWidth: string;
|
|
27
29
|
tableData: ScbVizTableData | undefined;
|
|
28
30
|
private _slottedTableData;
|
|
29
31
|
/** Vertikalt avstånd ovanför/under komponenten. 0–14 mappar till spacing-tokens, annars CSS-värde. */
|
|
@@ -51,6 +53,7 @@ export declare class ScbViz extends LitElement {
|
|
|
51
53
|
private _normalizeRenderableCell;
|
|
52
54
|
private _readTableDataFromSlot;
|
|
53
55
|
private _inferTableAlignments;
|
|
56
|
+
private _getResolvedContentMaxWidth;
|
|
54
57
|
private _renderTable;
|
|
55
58
|
render(): import('lit-html').TemplateResult<1>;
|
|
56
59
|
private _syncChipClass;
|