scb-wc-test 0.1.235 → 0.1.237
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 +187 -232
- package/package.json +2 -2
- package/scb-viz/scb-viz.d.ts +22 -1
- package/scb-viz/scb-viz.js +411 -338
- package/scb-wc-test.bundle.js +780 -825
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as $,n as p,r as M,i as T,x as r,k as z,l as L,t as k}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(s,c,i){try{customElements.get(s)||e(s,c,i)}catch(a){var l=String(a||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var H=Object.defineProperty,D=Object.getOwnPropertyDescriptor,x=t=>{throw TypeError(t)},o=(t,e,s,c)=>{for(var i=c>1?void 0:c?D(e,s):e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(i=(c?a(e,s,i):a(i))||i);return c&&i&&H(e,s,i),i},V=(t,e,s)=>e.has(t)||x("Cannot "+s),A=(t,e,s)=>e.has(t)?x("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),m=(t,e,s)=>(V(t,e,"access private method"),s),b,C,f;const I=`<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,158 +113,138 @@ import{a as _,n as o,i as w,x as s,l as f,t as z}from"../../vendor/vendor.js";im
|
|
|
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 n=class extends T{constructor(){super(...arguments),A(this,b),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.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(),m(this,b,C).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"))&&m(this,b,C).call(this)}_onTableSlotChange(t){const e=t.target;e&&this._readTableDataFromSlot(e)}_readTableDataFromSlot(t){const e=t||this.shadowRoot?.querySelector('slot[name="table"]');if(!e)return;const s=e.assignedElements({flatten:!0}),c=[];s.forEach(h=>{if(h.tagName==="TABLE"){c.push(h);return}h.querySelectorAll("table").forEach(g=>c.push(g))});const i=c[0];if(!i){this._slottedTableData=void 0;return}const l=[],a=[],d=h=>{if(!h)return{text:"",html:""};const g=h.innerHTML??"",_=(h.textContent??"").replace(/\s+/g," ").trim(),w=(h.getAttribute("align")??"").trim().toLowerCase(),S=(h.style?.textAlign??"").trim().toLowerCase()||w;return{text:_,html:g,align:S==="left"||S==="center"||S==="right"?S:void 0}},v=i.querySelector("thead tr");v&&Array.from(v.querySelectorAll("th, td")).forEach(g=>l.push(d(g)));const u=Array.from(i.querySelectorAll("tbody tr")),y=u.length>0?u:Array.from(i.querySelectorAll("tr")).filter(h=>h.closest("thead")===null);if(y.forEach(h=>{const g=Array.from(h.querySelectorAll("th, td"));g.length!==0&&a.push({cells:g.map(_=>d(_)),firstCellIsRowHeader:g[0].tagName==="TH"&&h.closest("thead")===null&&h.closest("tfoot")===null})}),!v&&a.length>0){const h=y[0],g=Array.from(h?.querySelectorAll("th, td")??[]);g.length>0&&g.every(w=>w.tagName==="TH")&&h?.closest("tbody")===null&&(l.splice(0,l.length,...a[0].cells),a.shift())}this._slottedTableData={headers:l.length>0?l:void 0,rows:a}}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(i=>i.cells.length)),s=i=>{const l=i.replace(/[ \s]+/g,"").trim();return l?/^-?\d+(?:[.,]\d+)?$/.test(l):!1},c=[];for(let i=0;i<e;i+=1){const l=t.rows.map(d=>d.cells[i]?.text??"").filter(d=>d!==""),a=l.length>0&&l.every(s);c.push(a?"right":"left")}return c}_getColumnWidthHints(t,e){const s=t.headers&&t.headers.length>0?t.headers:t.rows[0]?.cells??[];return Array.from({length:e},(c,i)=>{const l=(s[i]?.text??"").replace(/\s+/g," ").trim();return`${Math.max(6,Math.min(40,l.length+4))}ch`})}_renderTable(){const t=this.tableData?this._mapTableDataToRenderedData(this.tableData):this._slottedTableData;if(!t||!t.rows||t.rows.length===0)return null;const e=this._inferTableAlignments(t),s=Math.max(t.headers?.length??0,...t.rows.map(a=>a.cells.length)),c=t.headers??[],i=t.rows.map(a=>{const d=[...a.cells];for(;d.length<s;)d.push({text:"",html:""});return{cells:d,firstCellIsRowHeader:a.firstCellIsRowHeader===!0}}),l=this._getColumnWidthHints(t,s);return r`
|
|
117
|
+
<table class="scb-viz-table" part="table">
|
|
118
|
+
<colgroup>
|
|
119
|
+
${l.map(a=>r`<col style=${`width: ${a}; min-width: ${a};`}>`)}
|
|
120
|
+
</colgroup>
|
|
121
|
+
${c.length>0?r`
|
|
122
|
+
<thead>
|
|
123
|
+
<tr>
|
|
124
|
+
${c.map((a,d)=>{const v=a.align??e[d];return r`<th scope="col" class=${v==="right"?"align-right":v==="center"?"align-center":"align-left"}>${z(a.html||a.text)}</th>`})}
|
|
125
|
+
</tr>
|
|
126
|
+
</thead>
|
|
127
|
+
`:""}
|
|
128
|
+
<tbody>
|
|
129
|
+
${i.map(a=>r`
|
|
130
|
+
<tr>
|
|
131
|
+
${a.cells.map((d,v)=>{const u=d.align??e[v],y=u==="right"?"align-right":u==="center"?"align-center":"align-left";return v===0&&a.firstCellIsRowHeader?r`<th scope="row" class=${y}>${z(d.html||d.text)}</th>`:r`<td class=${y}>${z(d.html||d.text)}</td>`})}
|
|
132
|
+
</tr>
|
|
133
|
+
`)}
|
|
134
|
+
</tbody>
|
|
135
|
+
</table>
|
|
136
|
+
`}_mapTableDataToRenderedData(t){const e=s=>{const c=s==null?"":String(s);return{text:c,html:c}};return{headers:t.headers?.map(s=>e(s)),rows:t.rows.map((s,c)=>({cells:s.map(i=>e(i)),firstCellIsRowHeader:t.rowHeaderRows?.[c]===!0}))}}_renderHeader(){return r`
|
|
137
|
+
<div class="header">
|
|
138
|
+
${this.title?r` <div class="label">${this.title}</div> `:""}
|
|
139
|
+
${this.subtitle?r` <div class="subtitle">${this.subtitle}</div> `:""}
|
|
140
|
+
</div>
|
|
141
|
+
`}_renderDescription(){return this.description?r`
|
|
142
|
+
<div class="description section">
|
|
143
|
+
<div class="secondary-label">${this.descriptionLabel}</div>
|
|
144
|
+
<div>${this.description}</div>
|
|
145
|
+
</div>
|
|
146
|
+
`:null}_renderOfficialStatisticsLink(){return this.officialStatistics?r`
|
|
147
|
+
<a
|
|
148
|
+
class="sos-logotype-link"
|
|
149
|
+
href="https://www.scb.se/sos"
|
|
150
|
+
target="_blank"
|
|
151
|
+
rel="noopener"
|
|
152
|
+
title="${this.officialStatisticsTitle}"
|
|
153
|
+
aria-label="${this.officialStatisticsAlt}"
|
|
154
|
+
>
|
|
155
|
+
<span class="sos-logotype-small" aria-hidden="true">
|
|
156
|
+
${L(I)}
|
|
157
|
+
</span>
|
|
158
|
+
</a>
|
|
159
|
+
`:null}_renderMoreAboutStats(){return!this.comment&&!this.source&&!this.footnote&&!this.officialStatistics?null:r`
|
|
160
|
+
<scb-divider></scb-divider>
|
|
161
|
+
<scb-accordion>
|
|
162
|
+
<scb-accordion-item title="${this.moreAboutStatsLabel}">
|
|
163
|
+
<div class="more-about-stats-content">
|
|
164
|
+
${this.comment?r`
|
|
165
|
+
<div class="section">
|
|
166
|
+
<div class="secondary-label">${this.commentLabel}</div>
|
|
167
|
+
<div>${this.comment}</div>
|
|
168
|
+
</div>
|
|
169
|
+
`:""}
|
|
170
|
+
${this.source?r`
|
|
171
|
+
<div class="section">
|
|
172
|
+
<div class="secondary-label">${this.sourceLabel}</div>
|
|
173
|
+
<div>${this.source}</div>
|
|
174
|
+
</div>
|
|
175
|
+
`:""}
|
|
176
|
+
${this.footnote?r`
|
|
177
|
+
<div class="section">
|
|
178
|
+
<div class="secondary-label">${this.footnoteLabel}</div>
|
|
179
|
+
<div>${this.footnote}</div>
|
|
180
|
+
</div>
|
|
181
|
+
`:""}
|
|
182
|
+
${this._renderOfficialStatisticsLink()}
|
|
183
|
+
</div>
|
|
184
|
+
</scb-accordion-item>
|
|
185
|
+
</scb-accordion>
|
|
186
|
+
`}_renderFooter(){const t=this._renderDescription(),e=this._renderMoreAboutStats();return!t&&!e?null:r`
|
|
187
|
+
<div class="footer">
|
|
188
|
+
${t}
|
|
189
|
+
${e}
|
|
190
|
+
</div>
|
|
191
|
+
`}_renderHiddenTableSlot(){return r`
|
|
192
|
+
<slot
|
|
193
|
+
name="table"
|
|
194
|
+
class="table-source"
|
|
195
|
+
@slotchange=${t=>this._onTableSlotChange(t)}
|
|
196
|
+
></slot>
|
|
197
|
+
`}_renderTableScroller(){return r`
|
|
198
|
+
<scb-horizontal-scroller
|
|
199
|
+
width="600px"
|
|
200
|
+
class="table-scroller"
|
|
201
|
+
variant="inline"
|
|
202
|
+
show-scrollbar
|
|
203
|
+
>
|
|
204
|
+
${this._renderTable()}
|
|
205
|
+
</scb-horizontal-scroller>
|
|
206
|
+
`}_renderStandardToggle(){return this.variant!=="Standard"||this.disableToggle?null:r`
|
|
207
|
+
<div class="flipp-wrapper">
|
|
208
|
+
<scb-segmented-button
|
|
209
|
+
.value=${this.selectedChip||""}
|
|
210
|
+
@change=${t=>this._onSegmentedChange(t)}
|
|
211
|
+
>
|
|
212
|
+
<scb-segmented-item
|
|
213
|
+
label=${this.lang==="en"?"Figure":"Diagram"}
|
|
214
|
+
value="Diagram"
|
|
215
|
+
icon="bar_chart"
|
|
216
|
+
></scb-segmented-item>
|
|
217
|
+
<scb-segmented-item
|
|
218
|
+
label="${this.lang==="en"?"Table":"Tabell"}"
|
|
219
|
+
value="Table"
|
|
220
|
+
icon="table"
|
|
221
|
+
></scb-segmented-item>
|
|
222
|
+
</scb-segmented-button>
|
|
223
|
+
</div>
|
|
224
|
+
`}render(){switch(this.variant){case"Table":return r`
|
|
117
225
|
<div part="container">
|
|
118
|
-
|
|
119
|
-
${this.title?s` <div class="label">${this.title}</div> `:""}
|
|
120
|
-
${this.subtitle?s` <div class="subtitle">${this.subtitle}</div> `:""}
|
|
121
|
-
</div>
|
|
226
|
+
${this._renderHeader()}
|
|
122
227
|
<div class="content">
|
|
123
|
-
|
|
124
|
-
width="600px"
|
|
125
|
-
class="table-scroller"
|
|
126
|
-
variant="inline"
|
|
127
|
-
show-scrollbar
|
|
128
|
-
>
|
|
129
|
-
<slot name="table"></slot>
|
|
130
|
-
</scb-horizontal-scroller>
|
|
131
|
-
</div>
|
|
132
|
-
<div class="footer">
|
|
133
|
-
${this.description?s`
|
|
134
|
-
<div class="description section">
|
|
135
|
-
<div class="secondary-label">${this.descriptionLabel}</div>
|
|
136
|
-
<div>${this.description}</div>
|
|
137
|
-
</div>
|
|
138
|
-
`:""}
|
|
139
|
-
${this.comment||this.source||this.footnote||this.officialStatistics?s`
|
|
140
|
-
<scb-divider></scb-divider>
|
|
141
|
-
<scb-accordion>
|
|
142
|
-
<scb-accordion-item title="${this.moreAboutStatsLabel}">
|
|
143
|
-
<div class="more-about-stats-content">
|
|
144
|
-
${this.comment?s`
|
|
145
|
-
<div class="section">
|
|
146
|
-
<div class="secondary-label">${this.commentLabel}</div>
|
|
147
|
-
<div>${this.comment}</div>
|
|
148
|
-
</div>
|
|
149
|
-
`:""}
|
|
150
|
-
${this.source?s`
|
|
151
|
-
<div class="section">
|
|
152
|
-
<div class="secondary-label">${this.sourceLabel}</div>
|
|
153
|
-
<div>${this.source}</div>
|
|
154
|
-
</div>
|
|
155
|
-
`:""}
|
|
156
|
-
${this.footnote?s`
|
|
157
|
-
<div class="section">
|
|
158
|
-
<div class="secondary-label">${this.footnoteLabel}</div>
|
|
159
|
-
<div>${this.footnote}</div>
|
|
160
|
-
</div>
|
|
161
|
-
`:""}
|
|
162
|
-
${this.officialStatistics?s`
|
|
163
|
-
<a
|
|
164
|
-
class="sos-logotype-link"
|
|
165
|
-
href="https://www.scb.se/sos"
|
|
166
|
-
target="_blank"
|
|
167
|
-
rel="noopener"
|
|
168
|
-
title="${this.officialStatisticsTitle}"
|
|
169
|
-
aria-label="${this.officialStatisticsAlt}"
|
|
170
|
-
>
|
|
171
|
-
<span class="sos-logotype-small" aria-hidden="true">
|
|
172
|
-
${f(u)}
|
|
173
|
-
</span>
|
|
174
|
-
</a>
|
|
175
|
-
`:""}
|
|
176
|
-
</div>
|
|
177
|
-
</scb-accordion-item>
|
|
178
|
-
</scb-accordion>
|
|
179
|
-
`:""}
|
|
228
|
+
${this._renderTableScroller()}
|
|
180
229
|
</div>
|
|
230
|
+
${this._renderFooter()}
|
|
231
|
+
${this._renderHiddenTableSlot()}
|
|
181
232
|
<slot></slot>
|
|
182
233
|
</div>
|
|
183
|
-
`;case"Image":return
|
|
234
|
+
`;case"Image":return r`
|
|
184
235
|
<div part="container">
|
|
185
|
-
|
|
186
|
-
${this.title?s` <div class="label">${this.title}</div> `:""}
|
|
187
|
-
${this.subtitle?s` <div class="subtitle">${this.subtitle}</div> `:""}
|
|
188
|
-
</div>
|
|
236
|
+
${this._renderHeader()}
|
|
189
237
|
<div class="content image-content">
|
|
190
238
|
<img src="${this.imageHref}" alt="Image figure" />
|
|
191
239
|
</div>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
<div class="description section">
|
|
195
|
-
<div class="secondary-label">${this.descriptionLabel}</div>
|
|
196
|
-
<div>${this.description}</div>
|
|
197
|
-
</div>
|
|
198
|
-
`:""}
|
|
199
|
-
${this.comment||this.source||this.footnote||this.officialStatistics?s`
|
|
200
|
-
<scb-divider></scb-divider>
|
|
201
|
-
<scb-accordion>
|
|
202
|
-
<scb-accordion-item title="${this.moreAboutStatsLabel}">
|
|
203
|
-
<div class="more-about-stats-content">
|
|
204
|
-
${this.comment?s`
|
|
205
|
-
<div class="section">
|
|
206
|
-
<div class="secondary-label">${this.commentLabel}</div>
|
|
207
|
-
<div>${this.comment}</div>
|
|
208
|
-
</div>
|
|
209
|
-
`:""}
|
|
210
|
-
${this.source?s`
|
|
211
|
-
<div class="section">
|
|
212
|
-
<div class="secondary-label">${this.sourceLabel}</div>
|
|
213
|
-
<div>${this.source}</div>
|
|
214
|
-
</div>
|
|
215
|
-
`:""}
|
|
216
|
-
${this.footnote?s`
|
|
217
|
-
<div class="section">
|
|
218
|
-
<div class="secondary-label">${this.footnoteLabel}</div>
|
|
219
|
-
<div>${this.footnote}</div>
|
|
220
|
-
</div>
|
|
221
|
-
`:""}
|
|
222
|
-
${this.officialStatistics?s`
|
|
223
|
-
<a
|
|
224
|
-
class="sos-logotype-link"
|
|
225
|
-
href="https://www.scb.se/sos"
|
|
226
|
-
target="_blank"
|
|
227
|
-
rel="noopener"
|
|
228
|
-
title="${this.officialStatisticsTitle}"
|
|
229
|
-
aria-label="${this.officialStatisticsAlt}"
|
|
230
|
-
>
|
|
231
|
-
<span class="sos-logotype-small" aria-hidden="true">
|
|
232
|
-
${f(u)}
|
|
233
|
-
</span>
|
|
234
|
-
</a>
|
|
235
|
-
`:""}
|
|
236
|
-
</div>
|
|
237
|
-
</scb-accordion-item>
|
|
238
|
-
</scb-accordion>
|
|
239
|
-
`:""}
|
|
240
|
-
</div>
|
|
240
|
+
${this._renderFooter()}
|
|
241
|
+
${this._renderHiddenTableSlot()}
|
|
241
242
|
<slot></slot>
|
|
242
243
|
</div>
|
|
243
|
-
`;default:return
|
|
244
|
+
`;default:return r`
|
|
244
245
|
<div part="container">
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
${this.subtitle?s` <div class="subtitle">${this.subtitle}</div> `:""}
|
|
248
|
-
</div>
|
|
249
|
-
${this.variant==="Standard"&&!this.disableToggle?s`
|
|
250
|
-
<div class="flipp-wrapper">
|
|
251
|
-
<scb-segmented-button
|
|
252
|
-
.value=${this.selectedChip||""}
|
|
253
|
-
@change=${t=>this._onSegmentedChange(t)}
|
|
254
|
-
>
|
|
255
|
-
<scb-segmented-item
|
|
256
|
-
label=${this.lang==="en"?"Figure":"Diagram"}
|
|
257
|
-
value="Diagram"
|
|
258
|
-
icon="bar_chart"
|
|
259
|
-
></scb-segmented-item>
|
|
260
|
-
<scb-segmented-item
|
|
261
|
-
label="${this.lang==="en"?"Table":"Tabell"}"
|
|
262
|
-
value="Table"
|
|
263
|
-
icon="table"
|
|
264
|
-
></scb-segmented-item>
|
|
265
|
-
</scb-segmented-button>
|
|
266
|
-
</div>
|
|
267
|
-
`:""}
|
|
246
|
+
${this._renderHeader()}
|
|
247
|
+
${this._renderStandardToggle()}
|
|
268
248
|
<div class="content">
|
|
269
249
|
<scb-horizontal-scroller
|
|
270
250
|
width="600px"
|
|
@@ -274,67 +254,13 @@ import{a as _,n as o,i as w,x as s,l as f,t as z}from"../../vendor/vendor.js";im
|
|
|
274
254
|
>
|
|
275
255
|
<slot name="diagram"></slot>
|
|
276
256
|
</scb-horizontal-scroller>
|
|
277
|
-
|
|
278
|
-
width="600px"
|
|
279
|
-
class="table-scroller"
|
|
280
|
-
variant="inline"
|
|
281
|
-
show-scrollbar
|
|
282
|
-
>
|
|
283
|
-
<slot name="table"></slot>
|
|
284
|
-
</scb-horizontal-scroller>
|
|
285
|
-
</div>
|
|
286
|
-
<div class="footer">
|
|
287
|
-
${this.description?s`
|
|
288
|
-
<div class="description section">
|
|
289
|
-
<div class="secondary-label">${this.descriptionLabel}</div>
|
|
290
|
-
<div>${this.description}</div>
|
|
291
|
-
</div>
|
|
292
|
-
`:""}
|
|
293
|
-
${this.comment||this.source||this.footnote||this.officialStatistics?s`
|
|
294
|
-
<scb-divider></scb-divider>
|
|
295
|
-
<scb-accordion>
|
|
296
|
-
<scb-accordion-item title="${this.moreAboutStatsLabel}">
|
|
297
|
-
<div class="more-about-stats-content">
|
|
298
|
-
${this.comment?s`
|
|
299
|
-
<div class="section">
|
|
300
|
-
<div class="secondary-label">${this.commentLabel}</div>
|
|
301
|
-
<div>${this.comment}</div>
|
|
302
|
-
</div>
|
|
303
|
-
`:""}
|
|
304
|
-
${this.source?s`
|
|
305
|
-
<div class="section">
|
|
306
|
-
<div class="secondary-label">${this.sourceLabel}</div>
|
|
307
|
-
<div>${this.source}</div>
|
|
308
|
-
</div>
|
|
309
|
-
`:""}
|
|
310
|
-
${this.footnote?s`
|
|
311
|
-
<div class="section">
|
|
312
|
-
<div class="secondary-label">${this.footnoteLabel}</div>
|
|
313
|
-
<div>${this.footnote}</div>
|
|
314
|
-
</div>
|
|
315
|
-
`:""}
|
|
316
|
-
${this.officialStatistics?s`
|
|
317
|
-
<a
|
|
318
|
-
class="sos-logotype-link"
|
|
319
|
-
href="https://www.scb.se/sos"
|
|
320
|
-
target="_blank"
|
|
321
|
-
rel="noopener"
|
|
322
|
-
title="${this.officialStatisticsTitle}"
|
|
323
|
-
aria-label="${this.officialStatisticsAlt}"
|
|
324
|
-
>
|
|
325
|
-
<span class="sos-logotype-small" aria-hidden="true">
|
|
326
|
-
${f(u)}
|
|
327
|
-
</span>
|
|
328
|
-
</a>
|
|
329
|
-
`:""}
|
|
330
|
-
</div>
|
|
331
|
-
</scb-accordion-item>
|
|
332
|
-
</scb-accordion>
|
|
333
|
-
`:""}
|
|
257
|
+
${this._renderTableScroller()}
|
|
334
258
|
</div>
|
|
259
|
+
${this._renderFooter()}
|
|
260
|
+
${this._renderHiddenTableSlot()}
|
|
335
261
|
<slot></slot>
|
|
336
262
|
</div>
|
|
337
|
-
`}}_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}};
|
|
263
|
+
`}}_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}};b=new WeakSet;C=function(){const t=m(this,b,f).call(this,this.spacing),e=m(this,b,f).call(this,this.spacingTop)??t,s=m(this,b,f).call(this,this.spacingBottom)??t,c=m(this,b,f).call(this,this.spacingLeft),i=m(this,b,f).call(this,this.spacingRight);e?this.style.setProperty("--scb-viz-spacing-block-start",e):this.style.removeProperty("--scb-viz-spacing-block-start"),s?this.style.setProperty("--scb-viz-spacing-block-end",s):this.style.removeProperty("--scb-viz-spacing-block-end"),c?this.style.setProperty("--scb-viz-spacing-inline-start",c):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")};f=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};n.styles=$`
|
|
338
264
|
:host {
|
|
339
265
|
display: block;
|
|
340
266
|
font-family: var(--brand-font);
|
|
@@ -362,7 +288,7 @@ import{a as _,n as o,i as w,x as s,l as f,t as z}from"../../vendor/vendor.js";im
|
|
|
362
288
|
letter-spacing: var(--md-sys-typescale-title-large-tracking);
|
|
363
289
|
}
|
|
364
290
|
|
|
365
|
-
.
|
|
291
|
+
.subtitle {
|
|
366
292
|
font-size: var(--md-sys-typescale-body-large-size);
|
|
367
293
|
line-height: var(--md-sys-typescale-body-large-line-height);
|
|
368
294
|
letter-spacing: var(--md-sys-typescale-body-large-tracking);
|
|
@@ -446,33 +372,25 @@ import{a as _,n as o,i as w,x as s,l as f,t as z}from"../../vendor/vendor.js";im
|
|
|
446
372
|
display: none;
|
|
447
373
|
}
|
|
448
374
|
|
|
449
|
-
:host([variant='Table']) slot[name='table'] {
|
|
450
|
-
display: block;
|
|
451
|
-
}
|
|
452
375
|
:host([variant='Table']) .table-scroller {
|
|
453
376
|
display: flex;
|
|
454
377
|
}
|
|
455
378
|
|
|
456
|
-
:host([variant='Image']) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
display: none;
|
|
472
|
-
}
|
|
473
|
-
.table-scroller {
|
|
474
|
-
display: none;
|
|
475
|
-
}
|
|
379
|
+
:host([variant='Image']) img {
|
|
380
|
+
height: auto;
|
|
381
|
+
max-width: 100%;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
:host([variant='Image']) .image-content {
|
|
385
|
+
display: block;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
:host([variant='Image']) .diagram-scroller {
|
|
389
|
+
display: none;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
:host([variant='Image']) .table-scroller {
|
|
393
|
+
display: none;
|
|
476
394
|
}
|
|
477
395
|
|
|
478
396
|
:host([variant='Standard'].chip-diagram) .diagram-scroller {
|
|
@@ -481,16 +399,53 @@ import{a as _,n as o,i as w,x as s,l as f,t as z}from"../../vendor/vendor.js";im
|
|
|
481
399
|
:host([variant='Standard'].chip-table) .table-scroller {
|
|
482
400
|
display: flex;
|
|
483
401
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
:host([variant='Standard'].chip-table) slot[name='diagram'] {
|
|
402
|
+
|
|
403
|
+
.table-source {
|
|
488
404
|
display: none;
|
|
489
405
|
}
|
|
490
|
-
|
|
491
|
-
|
|
406
|
+
|
|
407
|
+
.scb-viz-table {
|
|
408
|
+
border-collapse: collapse;
|
|
409
|
+
table-layout: fixed;
|
|
410
|
+
width: max-content;
|
|
411
|
+
max-width: none;
|
|
492
412
|
}
|
|
493
|
-
|
|
494
|
-
|
|
413
|
+
|
|
414
|
+
.scb-viz-table th,
|
|
415
|
+
.scb-viz-table td {
|
|
416
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
417
|
+
padding-block: var(--spacing-2, 8px);
|
|
418
|
+
padding-inline: var(--spacing-3, 12px);
|
|
419
|
+
background-color: inherit;
|
|
420
|
+
overflow-wrap: anywhere;
|
|
421
|
+
vertical-align: top;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.scb-viz-table thead th {
|
|
425
|
+
font-weight: var(--weight-bold);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.scb-viz-table tbody th {
|
|
429
|
+
font-weight: var(--weight-regular);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.scb-viz-table tbody tr:nth-child(odd) {
|
|
433
|
+
background: var(--md-sys-color-surface-container);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.scb-viz-table tbody tr:nth-child(even) {
|
|
437
|
+
background: var(--md-sys-color-surface);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.scb-viz-table .align-left {
|
|
441
|
+
text-align: left;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.scb-viz-table .align-center {
|
|
445
|
+
text-align: center;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.scb-viz-table .align-right {
|
|
449
|
+
text-align: right;
|
|
495
450
|
}
|
|
496
|
-
`;
|
|
451
|
+
`;o([p({type:String,reflect:!0})],n.prototype,"variant",2);o([p({type:String,reflect:!0,attribute:"selected-chip"})],n.prototype,"selectedChip",2);o([p({type:String,reflect:!0})],n.prototype,"title",2);o([p({type:String,reflect:!0})],n.prototype,"subtitle",2);o([p({type:String,reflect:!0})],n.prototype,"description",2);o([p({type:String,reflect:!0})],n.prototype,"comment",2);o([p({type:String,reflect:!0})],n.prototype,"source",2);o([p({type:String,reflect:!0})],n.prototype,"footnote",2);o([p({type:String,reflect:!0,attribute:"lang"})],n.prototype,"lang",2);o([p({type:String,reflect:!0,attribute:"image-href"})],n.prototype,"imageHref",2);o([p({type:Boolean,reflect:!0,attribute:"official-statistics"})],n.prototype,"officialStatistics",2);o([p({type:Boolean,reflect:!0,attribute:"disable-toggle"})],n.prototype,"disableToggle",2);o([p({attribute:!1})],n.prototype,"tableData",2);o([M()],n.prototype,"_slottedTableData",2);o([p({type:String,reflect:!0})],n.prototype,"spacing",2);o([p({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",2);o([p({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",2);o([p({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",2);o([p({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",2);n=o([k("scb-viz")],n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.237",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -378,5 +378,5 @@
|
|
|
378
378
|
},
|
|
379
379
|
"./mvc/*": "./mvc/*"
|
|
380
380
|
},
|
|
381
|
-
"buildHash": "
|
|
381
|
+
"buildHash": "3D5CF6D2AA58A343837477969DFF16DAF6DAC45EEB42E0DFCB7ADD6561A18998"
|
|
382
382
|
}
|
package/scb-viz/scb-viz.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export type ScbVizTableCell = string | number | null | undefined;
|
|
3
|
+
export interface ScbVizTableData {
|
|
4
|
+
headers?: string[];
|
|
5
|
+
rows: ScbVizTableCell[][];
|
|
6
|
+
rowHeaderRows?: boolean[];
|
|
7
|
+
}
|
|
2
8
|
export declare class ScbViz extends LitElement {
|
|
3
9
|
#private;
|
|
4
10
|
variant: 'Standard' | 'Table' | 'Image';
|
|
@@ -13,6 +19,8 @@ export declare class ScbViz extends LitElement {
|
|
|
13
19
|
imageHref: string;
|
|
14
20
|
officialStatistics: boolean;
|
|
15
21
|
disableToggle: boolean;
|
|
22
|
+
tableData: ScbVizTableData | undefined;
|
|
23
|
+
private _slottedTableData;
|
|
16
24
|
/** Vertikalt avstånd ovanför/under komponenten. 0–14 mappar till spacing-tokens, annars CSS-värde. */
|
|
17
25
|
spacing: undefined;
|
|
18
26
|
/** Överkantens avstånd. Om satt går före spacing. 0–14 mappar till spacing-tokens, annars CSS-värde. */
|
|
@@ -34,7 +42,20 @@ export declare class ScbViz extends LitElement {
|
|
|
34
42
|
static styles: import('lit').CSSResult;
|
|
35
43
|
protected firstUpdated(_changed: PropertyValues): void;
|
|
36
44
|
protected updated(changed: PropertyValues): void;
|
|
37
|
-
private
|
|
45
|
+
private _onTableSlotChange;
|
|
46
|
+
private _readTableDataFromSlot;
|
|
47
|
+
private _inferTableAlignments;
|
|
48
|
+
private _getColumnWidthHints;
|
|
49
|
+
private _renderTable;
|
|
50
|
+
private _mapTableDataToRenderedData;
|
|
51
|
+
private _renderHeader;
|
|
52
|
+
private _renderDescription;
|
|
53
|
+
private _renderOfficialStatisticsLink;
|
|
54
|
+
private _renderMoreAboutStats;
|
|
55
|
+
private _renderFooter;
|
|
56
|
+
private _renderHiddenTableSlot;
|
|
57
|
+
private _renderTableScroller;
|
|
58
|
+
private _renderStandardToggle;
|
|
38
59
|
render(): import('lit-html').TemplateResult<1>;
|
|
39
60
|
private _syncChipClass;
|
|
40
61
|
private _dispatchSelectedChipChanged;
|