scb-wc-test 0.1.285 → 0.1.287
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 +162 -131
- package/package.json +2 -2
- package/scb-viz/scb-viz.d.ts +18 -0
- package/scb-viz/scb-viz.js +606 -388
- package/scb-wc-test.bundle.js +863 -832
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as at,n as m,r as T,i as nt,x as p,k as W,l as rt,t as ot}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"../scb-icon-button/scb-icon-button.js";import"../../vendor/preload-helper.js";import"../../vendor/vendor-material.js";import"../scb-accordion/scb-accordion-item.js";import"../scb-button/scb-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(i,s,a){try{customElements.get(i)||e(i,s,a)}catch(n){var h=String(n||"");if(h.indexOf("already been used")===-1&&h.indexOf("NotSupportedError")===-1)throw n}}}}catch{}})();var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,B=t=>{throw TypeError(t)},b=(t,e,i,s)=>{for(var a=s>1?void 0:s?ct(e,i):e,h=t.length-1,n;h>=0;h--)(n=t[h])&&(a=(s?n(e,i,a):n(a))||a);return s&&a&<(e,i,a),a},ht=(t,e,i)=>e.has(t)||B("Cannot "+i),dt=(t,e,i)=>e.has(t)?B("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),o=(t,e,i)=>(ht(t,e,"access private method"),i),r,$,H,V,S,D,P,j,M,q,G,C,k,v,N,U,J,K,X,Q,Y,Z,F,tt,A,L,et,it,O,I,E,x,R;const st=`<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,13 +113,100 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
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 p=class extends at{constructor(){super(...arguments),ht(this,a),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.contentHeight="",this.toggleHeightMode="auto",this._actionsMenuOpen=!1,this._diagramReflowFrame=0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onDocumentPointerDown=t=>{if(!this._actionsMenuOpen)return;const e=t.composedPath(),i=this.shadowRoot?.querySelector(".actions-menu");i&&e.includes(i)||this._closeActionsMenu()},this._onDocumentKeyDown=t=>{this._actionsMenuOpen&&t.key==="Escape"&&(t.preventDefault(),this._closeActionsMenu(),this._focusMenuButton())},this._onPrintClick=async()=>{this._closeActionsMenu(),await n(this,a,K).call(this)},this._onDownloadPngClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await n(this,a,k).call(this,"png"))},this._onDownloadJpgClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await n(this,a,k).call(this,"jpeg"))},this._onDownloadCsvClick=()=>{this._canExportCsv()&&(this._closeActionsMenu(),n(this,a,X).call(this))}}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"}get actionsMenuLabel(){return this.lang==="en"?"Open menu":"Öppna meny"}get printLabel(){return this.lang==="en"?"Print":"Skriv ut"}get downloadPngLabel(){return this.lang==="en"?"Download PNG":"Ladda ner PNG"}get downloadJpgLabel(){return this.lang==="en"?"Download JPG":"Ladda ner JPG"}get downloadCsvLabel(){return this.lang==="en"?"Download CSV":"Ladda ner CSV"}_getImageAltText(){return[this.title,this.subtitle,this.description].map(e=>typeof e=="string"?e.trim():"").filter(Boolean).join(". ")||(this.lang==="en"?"Image figure":"Bildfigur")}connectedCallback(){super.connectedCallback(),document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown)}firstUpdated(t){this._readTableDataFromSlot(),n(this,a,T).call(this),n(this,a,D).call(this),n(this,a,C).call(this),this._syncChipClass(),n(this,a,L).call(this),n(this,a,S).call(this)}updated(t){super.updated(t),(t.has("selectedChip")||t.has("variant"))&&(this._syncChipClass(),this._closeActionsMenu()),t.has("selectedChip")&&this._dispatchSelectedChipChanged(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&n(this,a,T).call(this),t.has("containerMaxWidth")&&n(this,a,D).call(this),t.has("variant")&&n(this,a,L).call(this),(t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode")||t.has("variant"))&&n(this,a,C).call(this),(t.has("selectedChip")||t.has("variant")||t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode"))&&n(this,a,S).call(this)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown),n(this,a,H).call(this),n(this,a,P).call(this)}_onTableSlotChange(t){const e=t.target;e&&(this._readTableDataFromSlot(e),this.requestUpdate())}_onDiagramSlotChange(){n(this,a,C).call(this),n(this,a,S).call(this),this.requestUpdate()}_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 i=e.assignedElements({flatten:!0}),r=[];i.forEach(g=>{if(g.tagName==="TABLE"){r.push(g);return}g.querySelectorAll("table").forEach(f=>r.push(f))});const s=r[0];if(!s){this._slottedTableData=void 0;return}const c=[],o=[],l=[],h=g=>g?(g.textContent??"").replace(/\s+/g," ").trim():"",b=g=>g?{html:(g.innerHTML??"").trim(),text:h(g)}:{html:"",text:""},y=s.querySelector("thead tr");y&&Array.from(y.querySelectorAll("th, td")).forEach(f=>c.push(b(f)));const z=Array.from(s.querySelectorAll("tbody tr")),w=z.length>0?z:Array.from(s.querySelectorAll("tr")).filter(g=>g.closest("thead")===null);if(w.forEach(g=>{const f=Array.from(g.querySelectorAll("th, td"));if(f.length===0)return;const _=f[0].tagName==="TH"&&g.closest("thead")===null&&g.closest("tfoot")===null;l.push(_);const $=[];f.forEach(M=>$.push(b(M))),o.push($)}),!y&&o.length>0){const g=o[0],f=w[0],_=Array.from(f?.querySelectorAll("th, td")??[]);_.length>0&&_.every(M=>M.tagName==="TH")&&f?.closest("tbody")===null&&(c.splice(0,c.length,...g),o.shift(),l.shift())}this._slottedTableData={headers:c.length>0?c:void 0,rows:o,rowHeaderRows:l.length>0?l:void 0}}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(s=>s.length)),i=s=>{if(s==null)return!1;if(typeof s=="number")return!0;const c=String(s).replace(/[\u00A0\u202F\s]+/g,"").trim();return c?/^-?\d+(?:[.,]\d+)?$/.test(c):!1},r=[];for(let s=0;s<e;s+=1){if(s===0){r.push("left");continue}const c=t.rows.map(l=>this._normalizeRenderableCell(l[s]).text).filter(l=>l!==""&&l!==null&&l!==void 0),o=c.length>0&&c.every(i);r.push(o?"right":"left")}return r}_getResolvedContentMaxWidth(){return this.contentMaxWidth?.trim()||""}_getResolvedDiagramHeight(){return this.contentHeight?.trim()||""}_getResolvedToggleHeightMode(){return this.toggleHeightMode==="auto"?"auto":"stable"}_getResolvedStandardContentHeight(){return this._getResolvedDiagramHeight()||"420px"}_getResolvedTableData(){return this.tableData??this._slottedTableData}_getDiagramAssignedElements(){const t=this.shadowRoot?.querySelector('slot[name="diagram"]');return t?t.assignedElements({flatten:!0}):[]}_findExportableVisualElement(t){for(const e of t){if(e instanceof SVGSVGElement||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)return e;const i=e.querySelector("svg, canvas, img");if(i instanceof SVGSVGElement||i instanceof HTMLCanvasElement||i instanceof HTMLImageElement)return i}return null}_getExportableVisualElement(){if(this.variant==="Table")return null;if(this.variant==="Image"){const t=this.shadowRoot?.querySelector(".image-content img");return t instanceof HTMLImageElement?t:null}return this._findExportableVisualElement(this._getDiagramAssignedElements())}_canExportRaster(){return this._getExportableVisualElement()!==null}_canExportCsv(){return!!this._getResolvedTableData()?.rows?.length}_getExportBaseFileName(){const t=this.lang==="en"?"visualization":"visualisering";return(this.title||t).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}_buildExportFileName(t){const e=t==="csv"?this.lang==="en"?"-table":"-tabell":"";return`${this._getExportBaseFileName()}${e}.${t}`}_renderActions(){const t=this._canExportRaster(),e=this._canExportCsv(),i=this.variant==="Standard"||this.variant==="Image",r=this.variant==="Standard"||this.variant==="Table";return d`
|
|
116
|
+
`;let g=class extends nt{constructor(){super(...arguments),dt(this,r),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.contentHeight="",this.toggleHeightMode="auto",this._actionsMenuOpen=!1,this._seriesDifferentiationEnabled=!1,this._seriesDifferentiationSnapshots=new WeakMap,this._diagramReflowFrame=0,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._onDocumentPointerDown=t=>{if(!this._actionsMenuOpen)return;const e=t.composedPath(),i=this.shadowRoot?.querySelector(".actions-menu");i&&e.includes(i)||this._closeActionsMenu()},this._onDocumentKeyDown=t=>{this._actionsMenuOpen&&t.key==="Escape"&&(t.preventDefault(),this._closeActionsMenu(),this._focusMenuButton())},this._onPrintClick=async()=>{this._closeActionsMenu(),await o(this,r,X).call(this)},this._onDownloadPngClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await o(this,r,k).call(this,"png"))},this._onDownloadJpgClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await o(this,r,k).call(this,"jpeg"))},this._onDownloadCsvClick=()=>{this._canExportCsv()&&(this._closeActionsMenu(),o(this,r,Q).call(this))},this._onToggleSeriesDifferentiationClick=()=>{this._seriesDifferentiationEnabled=!this._seriesDifferentiationEnabled,this._closeActionsMenu(),o(this,r,C).call(this)}}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"}get actionsMenuLabel(){return this.lang==="en"?"Open menu":"Öppna meny"}get printLabel(){return this.lang==="en"?"Print":"Skriv ut"}get downloadPngLabel(){return this.lang==="en"?"Download PNG":"Ladda ner PNG"}get downloadJpgLabel(){return this.lang==="en"?"Download JPG":"Ladda ner JPG"}get downloadCsvLabel(){return this.lang==="en"?"Download CSV":"Ladda ner CSV"}get enableSeriesDifferentiationLabel(){return this.lang==="en"?"Show symbols and patterns":"Visa symboler och mönster"}get disableSeriesDifferentiationLabel(){return this.lang==="en"?"Hide symbols and patterns":"Dölj symboler och mönster"}_getImageAltText(){return[this.title,this.subtitle,this.description].map(e=>typeof e=="string"?e.trim():"").filter(Boolean).join(". ")||(this.lang==="en"?"Image figure":"Bildfigur")}connectedCallback(){super.connectedCallback(),document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown)}firstUpdated(t){o(this,r,E).call(this),o(this,r,R).call(this),o(this,r,M).call(this),this._syncChipClass(),o(this,r,$).call(this),o(this,r,S).call(this)}updated(t){super.updated(t),(t.has("selectedChip")||t.has("variant"))&&(this._syncChipClass(),this._closeActionsMenu()),t.has("selectedChip")&&this._dispatchSelectedChipChanged(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&o(this,r,E).call(this),t.has("containerMaxWidth")&&o(this,r,R).call(this),t.has("variant")&&o(this,r,$).call(this),(t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode")||t.has("variant"))&&o(this,r,M).call(this),(t.has("selectedChip")||t.has("variant")||t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode"))&&o(this,r,S).call(this),(t.has("selectedChip")||t.has("variant"))&&this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{o(this,r,C).call(this)})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown),o(this,r,H).call(this),o(this,r,V).call(this)}_onTableSlotChange(t){const e=t.target;e&&this._readTableDataFromSlot(e)}_onDiagramSlotChange(){o(this,r,M).call(this),o(this,r,S).call(this),this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{o(this,r,C).call(this)})}_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)}}_findFirstTable(t){const e=[];return t.forEach(i=>{if(i.tagName==="TABLE"){e.push(i);return}i.querySelectorAll("table").forEach(s=>e.push(s))}),e[0]??null}_extractTableData(t){if(!t)return;const e=[],i=[],s=[],a=d=>d?(d.textContent??"").replace(/\s+/g," ").trim():"",h=d=>d?{html:(d.innerHTML??"").trim(),text:a(d)}:{html:"",text:""},n=t.querySelector("thead tr");n&&Array.from(n.querySelectorAll("th, td")).forEach(u=>e.push(h(u)));const l=Array.from(t.querySelectorAll("tbody tr")),c=l.length>0?l:Array.from(t.querySelectorAll("tr")).filter(d=>d.closest("thead")===null);if(c.forEach(d=>{const u=Array.from(d.querySelectorAll("th, td"));if(u.length===0)return;const _=u[0].tagName==="TH"&&d.closest("thead")===null&&d.closest("tfoot")===null;s.push(_);const y=[];u.forEach(w=>y.push(h(w))),i.push(y)}),!n&&i.length>0){const d=i[0],u=c[0],_=Array.from(u?.querySelectorAll("th, td")??[]);_.length>0&&_.every(w=>w.tagName==="TH")&&u?.closest("tbody")===null&&(e.splice(0,e.length,...d),i.shift(),s.shift())}return{headers:e.length>0?e:void 0,rows:i,rowHeaderRows:s.length>0?s:void 0}}_readTableDataFromSlot(t){const e=t||this.shadowRoot?.querySelector('slot[name="table"]');e&&(this._slottedTableData=this._extractTableData(this._findFirstTable(e.assignedElements({flatten:!0}))))}_readTableDataFromLightDom(){return this._extractTableData(this._findFirstTable(Array.from(this.querySelectorAll('[slot="table"]'))))}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(a=>a.length)),i=a=>{if(a==null)return!1;if(typeof a=="number")return!0;const h=String(a).replace(/[\u00A0\u202F\s]+/g,"").trim();return h?/^-?\d+(?:[.,]\d+)?$/.test(h):!1},s=[];for(let a=0;a<e;a+=1){if(a===0){s.push("left");continue}const h=t.rows.map(l=>this._normalizeRenderableCell(l[a]).text).filter(l=>l!==""&&l!==null&&l!==void 0),n=h.length>0&&h.every(i);s.push(n?"right":"left")}return s}_getResolvedContentMaxWidth(){return this.contentMaxWidth?.trim()||""}_getResolvedDiagramHeight(){return this.contentHeight?.trim()||""}_getResolvedToggleHeightMode(){return this.toggleHeightMode==="auto"?"auto":"stable"}_getResolvedStandardContentHeight(){return this._getResolvedDiagramHeight()||"420px"}_getResolvedTableData(){return this.tableData??this._slottedTableData??this._readTableDataFromLightDom()}_getDiagramAssignedElements(){const t=this.shadowRoot?.querySelector('slot[name="diagram"]');return t?t.assignedElements({flatten:!0}):[]}_findExportableVisualElement(t){for(const e of t){if(e instanceof SVGSVGElement||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)return e;const i=e.querySelector("svg, canvas, img");if(i instanceof SVGSVGElement||i instanceof HTMLCanvasElement||i instanceof HTMLImageElement)return i}return null}_getExportableVisualElement(){if(this.variant==="Table")return null;if(this.variant==="Image"){const t=this.shadowRoot?.querySelector(".image-content img");return t instanceof HTMLImageElement?t:null}return this._findExportableVisualElement(this._getDiagramAssignedElements())}_getCurrentHighchartsChart(){if(this._getCurrentPrintableView()!=="diagram")return;const t=o(this,r,P).call(this,this._getDiagramAssignedElements());return t===void 0?void 0:window.Highcharts?.charts?.[t]}_getSeriesDifferentiationGroup(t,e){const i=String(t?.type||t?.options?.type||e?.options?.chart?.type||"").trim().toLowerCase();return["line","spline","scatter"].includes(i)?"line":["area","areaspline"].includes(i)?"area":["column","bar"].includes(i)?"fill":null}_shouldShowSeriesDifferentiationAction(){if(this._getCurrentPrintableView()!=="diagram")return!1;const t=this._getCurrentHighchartsChart();return t?.series?.length?t.series.some(e=>this._getSeriesDifferentiationGroup(e,t)!==null):!1}_getSeriesDifferentiationSnapshotStore(t){let e=this._seriesDifferentiationSnapshots.get(t);return e||(e=new Map,this._seriesDifferentiationSnapshots.set(t,e)),e}_cloneSeriesOptionValue(t){return Array.isArray(t)?t.map(e=>this._cloneSeriesOptionValue(e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,i])=>[e,this._cloneSeriesOptionValue(i)])):t}_captureSeriesDifferentiationSnapshot(t){const e=this._cloneSeriesOptionValue(t?.options?.marker);return{color:t?.options?.color??t?.userOptions?.color??t?.color,borderColor:t?.options?.borderColor??t?.borderColor,borderWidth:t?.options?.borderWidth??t?.borderWidth,fillColor:t?.options?.fillColor??t?.fillColor,dashStyle:t?.options?.dashStyle??"Solid",lineWidth:t?.options?.lineWidth??t?.lineWidth,marker:e&&Object.keys(e).length>0?e:{enabled:!1}}}_resolveSeriesBaseColor(t,e,i,s){const a=[s?.color,e?.userOptions?.color,e?.color,t?.options?.colors?.[i]];for(const h of a)if(typeof h=="string"&&h&&!h.startsWith("url("))return h;return"#0F0865"}_ensureSeriesPattern(t,e,i,s){const a=t?.container?.querySelector("svg");if(!(a instanceof SVGSVGElement))return i;const h="http://www.w3.org/2000/svg";let n=a.querySelector("defs");n instanceof SVGDefsElement||(n=document.createElementNS(h,"defs"),a.insertBefore(n,a.firstChild));const l=`scb-viz-pattern-${t?.index??"chart"}-${e}-${s}`;let c=n.querySelector(`[id="${l}"]`);if(!(c instanceof SVGPatternElement)){c=document.createElementNS(h,"pattern"),c.setAttribute("id",l),c.setAttribute("patternUnits","userSpaceOnUse"),c.setAttribute("width","10"),c.setAttribute("height","10");const d=document.createElementNS(h,"rect");d.setAttribute("x","0"),d.setAttribute("y","0"),d.setAttribute("width","10"),d.setAttribute("height","10"),d.setAttribute("fill",i),d.setAttribute("fill-opacity","0.14"),c.appendChild(d);const u=(y,w="1.25")=>{const f=document.createElementNS(h,"path");return f.setAttribute("d",y),f.setAttribute("fill","none"),f.setAttribute("stroke",i),f.setAttribute("stroke-width",w),f.setAttribute("stroke-opacity","0.78"),f.setAttribute("stroke-linecap","square"),f},_=(y,w,f)=>{const z=document.createElementNS(h,"circle");return z.setAttribute("cx",y),z.setAttribute("cy",w),z.setAttribute("r",f),z.setAttribute("fill",i),z.setAttribute("fill-opacity","0.78"),z};switch(s){case"diagonal":c.appendChild(u("M-2,8 l10,-10 M0,10 l10,-10 M8,12 l4,-4"));break;case"dots":c.appendChild(_("2","2","1.2")),c.appendChild(_("7","7","1.2"));break;case"cross":c.appendChild(u("M0,0 L10,10 M10,0 L0,10"));break;case"vertical":c.appendChild(u("M2,0 L2,10 M7,0 L7,10"));break;case"horizontal":c.appendChild(u("M0,2 L10,2 M0,7 L10,7"));break;default:c.appendChild(u("M0,0 L10,0 M0,5 L10,5 M0,10 L10,10","1"));break}n.appendChild(c)}return`url(#${l})`}_canExportRaster(){return this._getExportableVisualElement()!==null}_canExportCsv(){return!!this._getResolvedTableData()?.rows?.length}_getExportBaseFileName(){const t=this.lang==="en"?"visualization":"visualisering";return(this.title||t).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}_buildExportFileName(t){const e=t==="csv"?this.lang==="en"?"-table":"-tabell":"";return`${this._getExportBaseFileName()}${e}.${t}`}_renderActionsMenu(){const t=this._getCurrentPrintableView(),e=this._canExportRaster(),i=this._canExportCsv(),s=e&&(t==="diagram"||t==="image"),a=i&&t==="table",h=this._shouldShowSeriesDifferentiationAction();return p`
|
|
117
|
+
<div class="actions-menu">
|
|
118
|
+
<scb-icon-button
|
|
119
|
+
icon="more_vert"
|
|
120
|
+
variant="outlined"
|
|
121
|
+
size="medium"
|
|
122
|
+
shape="square"
|
|
123
|
+
label=${this.actionsMenuLabel}
|
|
124
|
+
title=${this.actionsMenuLabel}
|
|
125
|
+
aria-label=${this.actionsMenuLabel}
|
|
126
|
+
aria-haspopup="menu"
|
|
127
|
+
aria-expanded=${this._actionsMenuOpen?"true":"false"}
|
|
128
|
+
@click=${n=>this._toggleActionsMenu(n)}
|
|
129
|
+
></scb-icon-button>
|
|
130
|
+
<div
|
|
131
|
+
class=${`actions-menu-panel ${this._actionsMenuOpen?"actions-menu-panel--open":""}`}
|
|
132
|
+
role="menu"
|
|
133
|
+
aria-label=${this.actionsMenuLabel}
|
|
134
|
+
>
|
|
135
|
+
<ul class="actions-menu-list">
|
|
136
|
+
<li>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
class="actions-menu-item"
|
|
140
|
+
role="menuitem"
|
|
141
|
+
@click=${this._onPrintClick}
|
|
142
|
+
>
|
|
143
|
+
<span class="actions-menu-item-icon" aria-hidden="true">print</span>
|
|
144
|
+
<span class="actions-menu-item-label">${this.printLabel}</span>
|
|
145
|
+
</button>
|
|
146
|
+
</li>
|
|
147
|
+
${s?p`
|
|
148
|
+
<li>
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
class="actions-menu-item"
|
|
152
|
+
role="menuitem"
|
|
153
|
+
@click=${this._onDownloadPngClick}
|
|
154
|
+
>
|
|
155
|
+
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
156
|
+
<span class="actions-menu-item-label">${this.downloadPngLabel}</span>
|
|
157
|
+
</button>
|
|
158
|
+
</li>
|
|
159
|
+
<li>
|
|
160
|
+
<button
|
|
161
|
+
type="button"
|
|
162
|
+
class="actions-menu-item"
|
|
163
|
+
role="menuitem"
|
|
164
|
+
@click=${this._onDownloadJpgClick}
|
|
165
|
+
>
|
|
166
|
+
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
167
|
+
<span class="actions-menu-item-label">${this.downloadJpgLabel}</span>
|
|
168
|
+
</button>
|
|
169
|
+
</li>
|
|
170
|
+
`:""}
|
|
171
|
+
${a?p`
|
|
172
|
+
<li>
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
class="actions-menu-item"
|
|
176
|
+
role="menuitem"
|
|
177
|
+
@click=${this._onDownloadCsvClick}
|
|
178
|
+
>
|
|
179
|
+
<span class="actions-menu-item-icon" aria-hidden="true">table_view</span>
|
|
180
|
+
<span class="actions-menu-item-label">${this.downloadCsvLabel}</span>
|
|
181
|
+
</button>
|
|
182
|
+
</li>
|
|
183
|
+
`:""}
|
|
184
|
+
${h?p`
|
|
185
|
+
<li>
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
class="actions-menu-item"
|
|
189
|
+
role="menuitemcheckbox"
|
|
190
|
+
aria-checked=${this._seriesDifferentiationEnabled?"true":"false"}
|
|
191
|
+
@click=${this._onToggleSeriesDifferentiationClick}
|
|
192
|
+
>
|
|
193
|
+
<span class="actions-menu-item-icon" aria-hidden="true">texture</span>
|
|
194
|
+
<span class="actions-menu-item-label"
|
|
195
|
+
>${this._seriesDifferentiationEnabled?this.disableSeriesDifferentiationLabel:this.enableSeriesDifferentiationLabel}</span
|
|
196
|
+
>
|
|
197
|
+
</button>
|
|
198
|
+
</li>
|
|
199
|
+
`:""}
|
|
200
|
+
</ul>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
`}_renderActions(){return p`
|
|
117
204
|
<div class="actions-row">
|
|
118
|
-
${this.variant==="Standard"&&!this.disableToggle?
|
|
205
|
+
${this.variant==="Standard"&&!this.disableToggle?p`
|
|
119
206
|
<div class="flipp-wrapper">
|
|
120
207
|
<scb-segmented-button
|
|
121
208
|
.value=${this.selectedChip||""}
|
|
122
|
-
@change=${
|
|
209
|
+
@change=${t=>this._onSegmentedChange(t)}
|
|
123
210
|
>
|
|
124
211
|
<scb-segmented-item
|
|
125
212
|
label=${this.lang==="en"?"Figure":"Diagram"}
|
|
@@ -133,120 +220,56 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
133
220
|
></scb-segmented-item>
|
|
134
221
|
</scb-segmented-button>
|
|
135
222
|
</div>
|
|
136
|
-
`:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
title=${this.actionsMenuLabel}
|
|
145
|
-
aria-label=${this.actionsMenuLabel}
|
|
146
|
-
aria-haspopup="menu"
|
|
147
|
-
aria-expanded=${this._actionsMenuOpen?"true":"false"}
|
|
148
|
-
@click=${s=>this._toggleActionsMenu(s)}
|
|
149
|
-
></scb-icon-button>
|
|
150
|
-
<div
|
|
151
|
-
class=${`actions-menu-panel ${this._actionsMenuOpen?"actions-menu-panel--open":""}`}
|
|
152
|
-
role="menu"
|
|
153
|
-
aria-label=${this.actionsMenuLabel}
|
|
154
|
-
>
|
|
155
|
-
<ul class="actions-menu-list">
|
|
156
|
-
<li>
|
|
157
|
-
<button
|
|
158
|
-
type="button"
|
|
159
|
-
class="actions-menu-item"
|
|
160
|
-
role="menuitem"
|
|
161
|
-
@click=${this._onPrintClick}
|
|
162
|
-
>
|
|
163
|
-
<span class="actions-menu-item-icon" aria-hidden="true">print</span>
|
|
164
|
-
<span class="actions-menu-item-label">${this.printLabel}</span>
|
|
165
|
-
</button>
|
|
166
|
-
</li>
|
|
167
|
-
${i?d`
|
|
168
|
-
<li>
|
|
169
|
-
<button
|
|
170
|
-
type="button"
|
|
171
|
-
class="actions-menu-item"
|
|
172
|
-
role="menuitem"
|
|
173
|
-
?disabled=${!t}
|
|
174
|
-
@click=${this._onDownloadPngClick}
|
|
175
|
-
>
|
|
176
|
-
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
177
|
-
<span class="actions-menu-item-label">${this.downloadPngLabel}</span>
|
|
178
|
-
</button>
|
|
179
|
-
</li>
|
|
180
|
-
<li>
|
|
181
|
-
<button
|
|
182
|
-
type="button"
|
|
183
|
-
class="actions-menu-item"
|
|
184
|
-
role="menuitem"
|
|
185
|
-
?disabled=${!t}
|
|
186
|
-
@click=${this._onDownloadJpgClick}
|
|
187
|
-
>
|
|
188
|
-
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
189
|
-
<span class="actions-menu-item-label">${this.downloadJpgLabel}</span>
|
|
190
|
-
</button>
|
|
191
|
-
</li>
|
|
192
|
-
`:""}
|
|
193
|
-
${r?d`
|
|
194
|
-
<li>
|
|
195
|
-
<button
|
|
196
|
-
type="button"
|
|
197
|
-
class="actions-menu-item"
|
|
198
|
-
role="menuitem"
|
|
199
|
-
?disabled=${!e}
|
|
200
|
-
@click=${this._onDownloadCsvClick}
|
|
201
|
-
>
|
|
202
|
-
<span class="actions-menu-item-icon" aria-hidden="true">table_view</span>
|
|
203
|
-
<span class="actions-menu-item-label">${this.downloadCsvLabel}</span>
|
|
204
|
-
</button>
|
|
205
|
-
</li>
|
|
206
|
-
`:""}
|
|
207
|
-
</ul>
|
|
208
|
-
</div>
|
|
223
|
+
`:p`<div></div>`}
|
|
224
|
+
${this._renderActionsMenu()}
|
|
225
|
+
</div>
|
|
226
|
+
`}_renderHeader(t=!1){return p`
|
|
227
|
+
<div class=${`header ${t?"header--with-actions":""}`}>
|
|
228
|
+
<div class="header__text">
|
|
229
|
+
${this.title?p` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
230
|
+
${this.subtitle?p` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
209
231
|
</div>
|
|
232
|
+
${t?this._renderActionsMenu():""}
|
|
210
233
|
</div>
|
|
211
|
-
`}_renderTable(){const t=this.
|
|
234
|
+
`}_renderTable(){const t=this._getResolvedTableData();if(!t||!t.rows||t.rows.length===0)return null;const e=this._inferTableAlignments(t),i=Math.max(t.headers?.length??0,...t.rows.map(l=>l.length)),s=(t.headers??[]).map(l=>this._normalizeRenderableCell(l)),a=t.rows.map(l=>{const c=l.map(d=>this._normalizeRenderableCell(d));for(;c.length<i;)c.push({html:"",text:""});return c}),h=t.rowHeaderRows??[],n=[this.title,this.subtitle].map(l=>typeof l=="string"?l.trim():"").filter(Boolean).join(". ");return p`
|
|
212
235
|
<table class="scb-viz-table" part="table">
|
|
213
|
-
${
|
|
214
|
-
${
|
|
236
|
+
${n?p`<caption class="visually-hidden">${n}</caption>`:""}
|
|
237
|
+
${s.length>0?p`
|
|
215
238
|
<thead>
|
|
216
239
|
<tr>
|
|
217
|
-
${
|
|
240
|
+
${s.map((l,c)=>{const d=e[c]==="right"?"align-right":"align-left";return p`<th scope="col" class=${d}>${l.html?W(l.html):l.text}</th>`})}
|
|
218
241
|
</tr>
|
|
219
242
|
</thead>
|
|
220
243
|
`:""}
|
|
221
244
|
<tbody>
|
|
222
|
-
${
|
|
245
|
+
${a.map((l,c)=>{const d=h[c]===!0;return p`
|
|
223
246
|
<tr>
|
|
224
|
-
${l.map((
|
|
247
|
+
${l.map((u,_)=>{const y=e[_]==="right"?"align-right":"align-left",w=u.html?W(u.html):u.text;return _===0&&d?p`<th scope="row" class=${y}>${w}</th>`:p`<td class=${y}>${w}</td>`})}
|
|
225
248
|
</tr>
|
|
226
249
|
`})}
|
|
227
250
|
</tbody>
|
|
228
251
|
</table>
|
|
229
|
-
`}_hasMoreAboutStats(){return!!(this.comment||this.source||this.footnote||this.officialStatistics)}_renderMoreAboutStatsContent(){return
|
|
252
|
+
`}_hasMoreAboutStats(){return!!(this.comment||this.source||this.footnote||this.officialStatistics)}_renderMoreAboutStatsContent(){return p`
|
|
230
253
|
<div class="more-about-stats-content">
|
|
231
|
-
${this.comment?
|
|
254
|
+
${this.comment?p`
|
|
232
255
|
<div class="section">
|
|
233
256
|
<div class="secondary-label" role="heading" aria-level="3">${this.commentLabel}</div>
|
|
234
257
|
<div class="body-text">${this.comment}</div>
|
|
235
258
|
</div>
|
|
236
259
|
`:""}
|
|
237
|
-
${this.source?
|
|
260
|
+
${this.source?p`
|
|
238
261
|
<div class="section">
|
|
239
262
|
<div class="secondary-label" role="heading" aria-level="3">${this.sourceLabel}</div>
|
|
240
263
|
<div class="body-text">${this.source}</div>
|
|
241
264
|
</div>
|
|
242
265
|
`:""}
|
|
243
|
-
${this.footnote?
|
|
266
|
+
${this.footnote?p`
|
|
244
267
|
<div class="section">
|
|
245
268
|
<div class="secondary-label" role="heading" aria-level="3">${this.footnoteLabel}</div>
|
|
246
269
|
<div class="body-text">${this.footnote}</div>
|
|
247
270
|
</div>
|
|
248
271
|
`:""}
|
|
249
|
-
${this.officialStatistics?
|
|
272
|
+
${this.officialStatistics?p`
|
|
250
273
|
<a
|
|
251
274
|
class="sos-logotype-link"
|
|
252
275
|
href="https://www.scb.se/sos"
|
|
@@ -256,12 +279,12 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
256
279
|
aria-label="${this.officialStatisticsAlt}"
|
|
257
280
|
>
|
|
258
281
|
<span class="sos-logotype-small" aria-hidden="true">
|
|
259
|
-
${
|
|
282
|
+
${rt(st)}
|
|
260
283
|
</span>
|
|
261
284
|
</a>
|
|
262
285
|
`:""}
|
|
263
286
|
</div>
|
|
264
|
-
`}_renderMoreAboutStatsScreen(){return this._hasMoreAboutStats()?
|
|
287
|
+
`}_renderMoreAboutStatsScreen(){return this._hasMoreAboutStats()?p`
|
|
265
288
|
<div class="footer-statistics-screen">
|
|
266
289
|
<scb-divider></scb-divider>
|
|
267
290
|
<scb-accordion>
|
|
@@ -270,16 +293,16 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
270
293
|
</scb-accordion-item>
|
|
271
294
|
</scb-accordion>
|
|
272
295
|
</div>
|
|
273
|
-
`:""}_renderMoreAboutStatsPrint(){return this._hasMoreAboutStats()?
|
|
296
|
+
`:""}_renderMoreAboutStatsPrint(){return this._hasMoreAboutStats()?p`
|
|
274
297
|
<div class="footer-statistics-print print-more-about-stats">
|
|
275
298
|
<div class="secondary-label print-more-about-stats-heading" role="heading" aria-level="3">
|
|
276
299
|
${this.moreAboutStatsLabel}
|
|
277
300
|
</div>
|
|
278
301
|
${this._renderMoreAboutStatsContent()}
|
|
279
302
|
</div>
|
|
280
|
-
`:""}_renderFooter(){return
|
|
303
|
+
`:""}_renderFooter(){return p`
|
|
281
304
|
<div class="footer">
|
|
282
|
-
${this.description?
|
|
305
|
+
${this.description?p`
|
|
283
306
|
<div class="description section">
|
|
284
307
|
<div class="secondary-label" role="heading" aria-level="3">${this.descriptionLabel}</div>
|
|
285
308
|
<div class="body-text">${this.description}</div>
|
|
@@ -288,13 +311,9 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
288
311
|
${this._renderMoreAboutStatsScreen()}
|
|
289
312
|
${this._renderMoreAboutStatsPrint()}
|
|
290
313
|
</div>
|
|
291
|
-
`}render(){switch(this.variant){case"Table":return
|
|
314
|
+
`}render(){switch(this.variant){case"Table":return p`
|
|
292
315
|
<div part="container" class="viz-container">
|
|
293
|
-
|
|
294
|
-
${this.title?d` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
295
|
-
${this.subtitle?d` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
296
|
-
</div>
|
|
297
|
-
${this._renderActions()}
|
|
316
|
+
${this._renderHeader(!0)}
|
|
298
317
|
<div class="content">
|
|
299
318
|
<scb-horizontal-scroller
|
|
300
319
|
width="600px"
|
|
@@ -313,13 +332,9 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
313
332
|
></slot>
|
|
314
333
|
<slot></slot>
|
|
315
334
|
</div>
|
|
316
|
-
`;case"Image":return
|
|
335
|
+
`;case"Image":return p`
|
|
317
336
|
<div part="container" class="viz-container">
|
|
318
|
-
|
|
319
|
-
${this.title?d` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
320
|
-
${this.subtitle?d` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
321
|
-
</div>
|
|
322
|
-
${this._renderActions()}
|
|
337
|
+
${this._renderHeader(!0)}
|
|
323
338
|
<div
|
|
324
339
|
class="content image-content"
|
|
325
340
|
style=${this._getResolvedContentMaxWidth()?`max-width: ${this._getResolvedContentMaxWidth()}; --scb-viz-content-max-width: ${this._getResolvedContentMaxWidth()};`:""}
|
|
@@ -334,12 +349,9 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
334
349
|
></slot>
|
|
335
350
|
<slot></slot>
|
|
336
351
|
</div>
|
|
337
|
-
`;default:return
|
|
352
|
+
`;default:return p`
|
|
338
353
|
<div part="container" class="viz-container">
|
|
339
|
-
|
|
340
|
-
${this.title?d` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
341
|
-
${this.subtitle?d` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
342
|
-
</div>
|
|
354
|
+
${this._renderHeader()}
|
|
343
355
|
${this._renderActions()}
|
|
344
356
|
<div class="content">
|
|
345
357
|
<div
|
|
@@ -386,39 +398,39 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
386
398
|
></slot>
|
|
387
399
|
<slot></slot>
|
|
388
400
|
</div>
|
|
389
|
-
`}}_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}_toggleActionsMenu(t){t.stopPropagation(),this._actionsMenuOpen=!this._actionsMenuOpen,this._actionsMenuOpen&&requestAnimationFrame(()=>{this._focusFirstMenuItem()})}_closeActionsMenu(){this._actionsMenuOpen=!1}_focusMenuButton(){this.shadowRoot?.querySelector(".actions-menu scb-icon-button")?.focus()}_focusFirstMenuItem(){this.shadowRoot?.querySelector(".actions-menu-item")?.focus()}_getCurrentPrintableView(){return this.variant==="Table"?"table":this.variant==="Image"?"image":this.selectedChip==="Table"?"table":"diagram"}};
|
|
401
|
+
`}}_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}_toggleActionsMenu(t){t.stopPropagation(),this._actionsMenuOpen=!this._actionsMenuOpen,this._actionsMenuOpen&&requestAnimationFrame(()=>{this._focusFirstMenuItem()})}_closeActionsMenu(){this._actionsMenuOpen=!1}_focusMenuButton(){this.shadowRoot?.querySelector(".actions-menu scb-icon-button")?.focus()}_focusFirstMenuItem(){this.shadowRoot?.querySelector(".actions-menu-item")?.focus()}_getCurrentPrintableView(){return this.variant==="Table"?"table":this.variant==="Image"?"image":this.selectedChip==="Table"?"table":"diagram"}};r=new WeakSet;$=function(){if(o(this,r,H).call(this),typeof ResizeObserver>"u")return;const t=this.shadowRoot?.querySelector(".diagram-content");t&&(this._diagramResizeObserver=new ResizeObserver(()=>{o(this,r,S).call(this)}),this._diagramResizeObserver.observe(this),this._diagramResizeObserver.observe(t))};H=function(){this._diagramResizeObserver?.disconnect(),this._diagramResizeObserver=void 0};V=function(){this._diagramReflowFrame&&(cancelAnimationFrame(this._diagramReflowFrame),this._diagramReflowFrame=0)};S=function(){this.variant!=="Standard"||this.selectedChip!=="Diagram"||(o(this,r,V).call(this),this._diagramReflowFrame=requestAnimationFrame(()=>{this._diagramReflowFrame=requestAnimationFrame(()=>{this._diagramReflowFrame=0,o(this,r,j).call(this)})}))};D=function(t){const e=t?.getAttribute("data-highcharts-chart");if(!e)return;const i=Number.parseInt(e,10);return Number.isNaN(i)?void 0:i};P=function(t){for(const e of t){const i=o(this,r,D).call(this,e);if(i!==void 0)return i;const s=e.querySelector("[data-highcharts-chart]"),a=o(this,r,D).call(this,s);if(a!==void 0)return a}};j=function(){if(this.variant!=="Standard"||this.selectedChip!=="Diagram")return;const t=this.shadowRoot?.querySelector('slot[name="diagram"]');if(!t)return;const e=t.assignedElements({flatten:!0});if(e.length===0)return;const i=o(this,r,P).call(this,e);if(i===void 0)return;const a=window.Highcharts?.charts?.[i];a&&(a.setSize?.(null,null,!1),a.reflow?.(),this._seriesDifferentiationEnabled&&o(this,r,C).call(this))};M=function(){const t=this.variant==="Standard"?this._getResolvedDiagramHeight():"",e=this.variant==="Standard"&&this._getResolvedToggleHeightMode()==="stable"?this._getResolvedStandardContentHeight():"";this.variant==="Standard"?this.style.setProperty("--scb-viz-diagram-min-height",t||"420px"):this.style.removeProperty("--scb-viz-diagram-min-height"),t?(this.style.setProperty("--scb-viz-diagram-height",t),this.style.setProperty("--scb-viz-diagram-overflow","hidden")):(this.style.removeProperty("--scb-viz-diagram-height"),this.style.removeProperty("--scb-viz-diagram-overflow")),e?this.style.setProperty("--scb-viz-standard-content-height",e):this.style.removeProperty("--scb-viz-standard-content-height")};q=function(t){const e=this._getSeriesDifferentiationSnapshotStore(t),i=["Solid","ShortDash","ShortDot","ShortDashDot","ShortDashDotDot","Dot"],s=["circle","diamond","square","triangle","triangle-down"],a=["diagonal","dots","cross","vertical","horizontal","grid"];let h=!1;t.series?.forEach((n,l)=>{const c=this._getSeriesDifferentiationGroup(n,t);if(!c)return;const d=String(n?.index??l);e.has(d)||e.set(d,this._captureSeriesDifferentiationSnapshot(n));const u=e.get(d),_=this._resolveSeriesBaseColor(t,n,l,u),y=this._ensureSeriesPattern(t,l,_,a[l%a.length]),w={...this._cloneSeriesOptionValue(u?.marker),enabled:!0,symbol:s[l%s.length]},f={color:_};(c==="line"||c==="area")&&(f.dashStyle=i[l%i.length],f.marker=w),c==="area"&&(f.fillColor=y),c==="fill"&&(f.color=y,f.borderColor=_,f.borderWidth=u?.borderWidth??1),n.update(f,!1),h=!0}),h&&t.redraw(!1)};G=function(t){const e=this._seriesDifferentiationSnapshots.get(t);if(!e)return;let i=!1;t.series?.forEach((s,a)=>{if(!this._getSeriesDifferentiationGroup(s,t))return;const n=e.get(String(s?.index??a));if(!n)return;const l=this._resolveSeriesBaseColor(t,s,a,n);s.update({color:n.color??l,borderColor:n.borderColor??l,borderWidth:n.borderWidth,fillColor:n.fillColor,dashStyle:n.dashStyle??"Solid",lineWidth:n.lineWidth,marker:this._cloneSeriesOptionValue(n.marker)},!1),i=!0}),i&&t.redraw(!1)};C=function(){const t=this._getCurrentHighchartsChart();if(t){if(this._seriesDifferentiationEnabled){o(this,r,q).call(this,t);return}o(this,r,G).call(this,t)}};k=async function(t){const e=this._getExportableVisualElement();if(!e)return;const i=await o(this,r,Y).call(this,e,t);i&&o(this,r,I).call(this,i,this._buildExportFileName(t==="jpeg"?"jpg":"png"))};v=function(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")};N=function(t){const e=this._inferTableAlignments(t),i=Math.max(t.headers?.length??0,...t.rows.map(c=>c.length)),s=(t.headers??[]).map(c=>this._normalizeRenderableCell(c)),a=t.rows.map(c=>{const d=c.map(u=>this._normalizeRenderableCell(u));for(;d.length<i;)d.push({html:"",text:""});return d}),h=t.rowHeaderRows??[],n=s.length?`<thead><tr>${s.map((c,d)=>`<th scope="col" class="${e[d]==="right"?"align-right":"align-left"}">${c.html||o(this,r,v).call(this,c.text)}</th>`).join("")}</tr></thead>`:"",l=`<tbody>${a.map((c,d)=>{const u=h[d]===!0;return`<tr>${c.map((y,w)=>{const f=e[w]==="right"?"align-right":"align-left",z=y.html||o(this,r,v).call(this,y.text);return w===0&&u?`<th scope="row" class="${f}">${z}</th>`:`<td class="${f}">${z}</td>`}).join("")}</tr>`}).join("")}</tbody>`;return`<table class="scb-viz-print-table">${n}${l}</table>`};U=function(){const t=[];if(this.description&&t.push(`
|
|
390
402
|
<section class="print-section">
|
|
391
|
-
<h2>${
|
|
392
|
-
<div>${
|
|
403
|
+
<h2>${o(this,r,v).call(this,this.descriptionLabel)}</h2>
|
|
404
|
+
<div>${o(this,r,v).call(this,this.description)}</div>
|
|
393
405
|
</section>
|
|
394
406
|
`),this._hasMoreAboutStats()){const e=[];this.comment&&e.push(`
|
|
395
407
|
<section class="print-section print-meta-section">
|
|
396
|
-
<h3>${
|
|
397
|
-
<div>${
|
|
408
|
+
<h3>${o(this,r,v).call(this,this.commentLabel)}</h3>
|
|
409
|
+
<div>${o(this,r,v).call(this,this.comment)}</div>
|
|
398
410
|
</section>
|
|
399
411
|
`),this.source&&e.push(`
|
|
400
412
|
<section class="print-section print-meta-section">
|
|
401
|
-
<h3>${
|
|
402
|
-
<div>${
|
|
413
|
+
<h3>${o(this,r,v).call(this,this.sourceLabel)}</h3>
|
|
414
|
+
<div>${o(this,r,v).call(this,this.source)}</div>
|
|
403
415
|
</section>
|
|
404
416
|
`),this.footnote&&e.push(`
|
|
405
417
|
<section class="print-section print-meta-section">
|
|
406
|
-
<h3>${
|
|
407
|
-
<div>${
|
|
418
|
+
<h3>${o(this,r,v).call(this,this.footnoteLabel)}</h3>
|
|
419
|
+
<div>${o(this,r,v).call(this,this.footnote)}</div>
|
|
408
420
|
</section>
|
|
409
421
|
`),this.officialStatistics&&e.push(`
|
|
410
|
-
<div class="print-sos">${
|
|
422
|
+
<div class="print-sos">${st}</div>
|
|
411
423
|
`),t.push(`
|
|
412
424
|
<section class="print-section print-more-about-stats">
|
|
413
|
-
<h2>${
|
|
425
|
+
<h2>${o(this,r,v).call(this,this.moreAboutStatsLabel)}</h2>
|
|
414
426
|
${e.join("")}
|
|
415
427
|
</section>
|
|
416
|
-
`)}return t.join("")};
|
|
417
|
-
<html lang="${
|
|
428
|
+
`)}return t.join("")};J=function(t){return`<!doctype html>
|
|
429
|
+
<html lang="${o(this,r,v).call(this,this.lang||"sv")}">
|
|
418
430
|
<head>
|
|
419
431
|
<meta charset="utf-8">
|
|
420
432
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
421
|
-
<title>${
|
|
433
|
+
<title>${o(this,r,v).call(this,this.title||(this.lang==="en"?"Visualization":"Visualisering"))}</title>
|
|
422
434
|
<style>
|
|
423
435
|
:root { color-scheme: light; }
|
|
424
436
|
@page { margin: 16mm; }
|
|
@@ -456,15 +468,15 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
456
468
|
<body>
|
|
457
469
|
<article class="viz-print">
|
|
458
470
|
<header class="viz-header">
|
|
459
|
-
${this.title?`<h1 class="viz-title">${
|
|
460
|
-
${this.subtitle?`<div class="viz-subtitle">${
|
|
471
|
+
${this.title?`<h1 class="viz-title">${o(this,r,v).call(this,this.title)}</h1>`:""}
|
|
472
|
+
${this.subtitle?`<div class="viz-subtitle">${o(this,r,v).call(this,this.subtitle)}</div>`:""}
|
|
461
473
|
</header>
|
|
462
474
|
<div class="viz-content">${t}</div>
|
|
463
|
-
${
|
|
475
|
+
${o(this,r,U).call(this)}
|
|
464
476
|
</article>
|
|
465
477
|
</body>
|
|
466
|
-
</html>`};
|
|
467
|
-
`)}`,
|
|
478
|
+
</html>`};K=async function(t){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.position="fixed",e.style.right="0",e.style.bottom="0",e.style.width="0",e.style.height="0",e.style.border="0",e.style.visibility="hidden",document.body.appendChild(e);const i=()=>{e.remove()},s=e.contentDocument,a=e.contentWindow;if(!s||!a){i();return}s.open(),s.write(t),s.close();const h=Array.from(s.images||[]);await Promise.all(h.map(l=>l.complete?Promise.resolve():new Promise(c=>{l.addEventListener("load",()=>c(null),{once:!0}),l.addEventListener("error",()=>c(null),{once:!0})})));const n=()=>{a.removeEventListener("afterprint",n),i()};a.addEventListener("afterprint",n,{once:!0}),setTimeout(()=>{a.focus(),a.print(),setTimeout(i,1e3)},50)};X=async function(){const t=this._getCurrentPrintableView();let e="";if(t==="table"){const i=this._getResolvedTableData();if(!i?.rows?.length)return;e=o(this,r,N).call(this,i)}else if(t==="image"){const i=this.shadowRoot?.querySelector(".image-content img"),s=i?.currentSrc||i?.src||this.imageHref;if(!s)return;e=`<img class="viz-image" src="${o(this,r,v).call(this,s)}" alt="${o(this,r,v).call(this,this._getImageAltText())}">`}else{const i=this._getExportableVisualElement();if(!i)return;const s=await o(this,r,Z).call(this,i,"png");if(!s)return;e=`<img class="viz-chart-image" src="${s}" alt="${o(this,r,v).call(this,this._getImageAltText())}">`}await o(this,r,K).call(this,o(this,r,J).call(this,e))};Q=function(){const t=this._getResolvedTableData();if(!t?.rows?.length)return;const e=this.lang==="en"?",":";",i=[];t.headers?.length&&i.push(t.headers.map(n=>this._normalizeRenderableCell(n).text)),t.rows.forEach(n=>{i.push(n.map(l=>this._normalizeRenderableCell(l).text))});const s=n=>`"${String(n??"").replace(/\r?\n/g," ").replace(/"/g,'""')}"`,a=`\uFEFF${i.map(n=>n.map(s).join(e)).join(`\r
|
|
479
|
+
`)}`,h=new Blob([a],{type:"text/csv;charset=utf-8;"});o(this,r,I).call(this,h,this._buildExportFileName("csv"))};Y=async function(t,e){const i=await o(this,r,F).call(this,t);return i?o(this,r,it).call(this,i,e==="jpeg"?"image/jpeg":"image/png",e==="jpeg"?.92:void 0):null};Z=async function(t,e){const i=await o(this,r,F).call(this,t);return i?i.toDataURL(e==="jpeg"?"image/jpeg":"image/png",e==="jpeg"?.92:void 0):null};F=async function(t){if(t instanceof HTMLCanvasElement){const n=t.width||Math.round(t.getBoundingClientRect().width),l=t.height||Math.round(t.getBoundingClientRect().height);if(!n||!l)return null;const c=document.createElement("canvas");c.width=n,c.height=l;const d=c.getContext("2d");return d?(d.fillStyle=o(this,r,O).call(this),d.fillRect(0,0,n,l),d.drawImage(t,0,0,n,l),c):null}if(t instanceof HTMLImageElement){const n=t.naturalWidth||t.width,l=t.naturalHeight||t.height;return!n||!l?null:o(this,r,L).call(this,t.currentSrc||t.src,n,l)}const{width:e,height:i,serialized:s}=o(this,r,tt).call(this,t);if(!e||!i||!s)return null;const a=new Blob([s],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(a);try{return await o(this,r,L).call(this,h,e,i)}finally{URL.revokeObjectURL(h)}};tt=function(t){const e=t.cloneNode(!0),i=t.getBoundingClientRect(),s=t.viewBox?.baseVal,a=Math.round(s?.width||i.width||Number(t.getAttribute("width"))||0),h=Math.round(s?.height||i.height||Number(t.getAttribute("height"))||0);return e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),!e.getAttribute("width")&&a&&e.setAttribute("width",String(a)),!e.getAttribute("height")&&h&&e.setAttribute("height",String(h)),!e.getAttribute("viewBox")&&a&&h&&e.setAttribute("viewBox",`0 0 ${a} ${h}`),o(this,r,A).call(this,t,e),e.querySelectorAll(".highcharts-tooltip, .highcharts-contextmenu, .highcharts-a11y-proxy-container, .highcharts-a11y-dummy-point").forEach(n=>n.remove()),{width:a,height:h,serialized:new XMLSerializer().serializeToString(e)}};A=function(t,e){const i=getComputedStyle(t);let s="";for(let n=0;n<i.length;n+=1){const l=i[n],c=i.getPropertyValue(l);c&&(s+=`${l}:${c};`)}s&&e.setAttribute("style",s);const a=Array.from(t.children),h=Array.from(e.children);for(let n=0;n<a.length;n+=1){const l=a[n],c=h[n];l&&c&&o(this,r,A).call(this,l,c)}};L=async function(t,e,i){const s=Math.max(1,Math.min(2,window.devicePixelRatio||1)),a=Math.max(1,Math.round(e)),h=Math.max(1,Math.round(i)),n=document.createElement("canvas");n.width=Math.max(1,Math.round(a*s)),n.height=Math.max(1,Math.round(h*s));const l=n.getContext("2d");if(!l)return null;const c=await o(this,r,et).call(this,t);return c?(l.scale(s,s),l.fillStyle=o(this,r,O).call(this),l.fillRect(0,0,a,h),l.drawImage(c,0,0,a,h),n):null};et=function(t){return new Promise(e=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>e(null),i.src=t})};it=function(t,e,i){return new Promise(s=>{t.toBlob(a=>s(a),e,i)})};O=function(){const t=this.shadowRoot?.querySelector(".viz-container"),e=getComputedStyle(t??this).backgroundColor;return e&&e!=="rgba(0, 0, 0, 0)"?e:"#ffffff"};I=function(t,e){const i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download=e,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(i),0)};E=function(){const t=o(this,r,x).call(this,this.spacing),e=o(this,r,x).call(this,this.spacingTop)??t,i=o(this,r,x).call(this,this.spacingBottom)??t,s=o(this,r,x).call(this,this.spacingLeft),a=o(this,r,x).call(this,this.spacingRight);e?this.style.setProperty("--scb-viz-spacing-block-start",e):this.style.removeProperty("--scb-viz-spacing-block-start"),i?this.style.setProperty("--scb-viz-spacing-block-end",i):this.style.removeProperty("--scb-viz-spacing-block-end"),s?this.style.setProperty("--scb-viz-spacing-inline-start",s):this.style.removeProperty("--scb-viz-spacing-inline-start"),a?this.style.setProperty("--scb-viz-spacing-inline-end",a):this.style.removeProperty("--scb-viz-spacing-inline-end")};x=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};R=function(){const t=this.containerMaxWidth?.trim();t?this.style.setProperty("--scb-viz-container-max-width",t):this.style.removeProperty("--scb-viz-container-max-width")};g.styles=at`
|
|
468
480
|
:host {
|
|
469
481
|
display: block;
|
|
470
482
|
box-sizing: border-box;
|
|
@@ -646,13 +658,24 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
646
658
|
|
|
647
659
|
.header {
|
|
648
660
|
margin-bottom: var(--spacing-7, 24px);
|
|
649
|
-
max-width: 600px;
|
|
650
661
|
color: var(--_scb-viz-text-color);
|
|
651
662
|
font-family: var(--_scb-viz-font-family);
|
|
652
663
|
font-style: normal;
|
|
653
664
|
text-align: start;
|
|
654
665
|
}
|
|
655
666
|
|
|
667
|
+
.header--with-actions {
|
|
668
|
+
display: flex;
|
|
669
|
+
align-items: flex-start;
|
|
670
|
+
justify-content: space-between;
|
|
671
|
+
gap: var(--spacing-4, 16px);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.header__text {
|
|
675
|
+
max-width: 600px;
|
|
676
|
+
min-width: 0;
|
|
677
|
+
}
|
|
678
|
+
|
|
656
679
|
.actions-row {
|
|
657
680
|
display: flex;
|
|
658
681
|
align-items: flex-start;
|
|
@@ -985,6 +1008,10 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
985
1008
|
display: none !important;
|
|
986
1009
|
}
|
|
987
1010
|
|
|
1011
|
+
:host([data-scb-viz-print-preview]) .actions-menu {
|
|
1012
|
+
display: none !important;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
988
1015
|
:host([data-scb-viz-print-preview]) .actions-menu-panel {
|
|
989
1016
|
display: none !important;
|
|
990
1017
|
}
|
|
@@ -1044,6 +1071,10 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
1044
1071
|
display: none !important;
|
|
1045
1072
|
}
|
|
1046
1073
|
|
|
1074
|
+
.actions-menu {
|
|
1075
|
+
display: none !important;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1047
1078
|
.actions-menu-panel {
|
|
1048
1079
|
display: none !important;
|
|
1049
1080
|
}
|
|
@@ -1089,4 +1120,4 @@ import{a as st,n as m,r as B,i as at,x as d,k as O,l as nt,t as rt}from"../../ve
|
|
|
1089
1120
|
width: calc(100% / var(--scb-viz-print-scale, 1));
|
|
1090
1121
|
}
|
|
1091
1122
|
}
|
|
1092
|
-
`;
|
|
1123
|
+
`;b([m({type:String,reflect:!0})],g.prototype,"variant",2);b([m({type:String,reflect:!0,attribute:"selected-chip"})],g.prototype,"selectedChip",2);b([m({type:String,reflect:!0})],g.prototype,"title",2);b([m({type:String,reflect:!0})],g.prototype,"subtitle",2);b([m({type:String,reflect:!0})],g.prototype,"description",2);b([m({type:String,reflect:!0})],g.prototype,"comment",2);b([m({type:String,reflect:!0})],g.prototype,"source",2);b([m({type:String,reflect:!0})],g.prototype,"footnote",2);b([m({type:String,reflect:!0,attribute:"lang"})],g.prototype,"lang",2);b([m({type:String,reflect:!0,attribute:"image-href"})],g.prototype,"imageHref",2);b([m({type:Boolean,reflect:!0,attribute:"official-statistics"})],g.prototype,"officialStatistics",2);b([m({type:Boolean,reflect:!0,attribute:"disable-toggle"})],g.prototype,"disableToggle",2);b([m({type:String,attribute:"content-max-width"})],g.prototype,"contentMaxWidth",2);b([m({type:String,attribute:"container-max-width"})],g.prototype,"containerMaxWidth",2);b([m({type:String,attribute:"content-height"})],g.prototype,"contentHeight",2);b([m({type:String,reflect:!0,attribute:"toggle-height-mode"})],g.prototype,"toggleHeightMode",2);b([m({attribute:!1})],g.prototype,"tableData",2);b([T()],g.prototype,"_slottedTableData",2);b([T()],g.prototype,"_actionsMenuOpen",2);b([T()],g.prototype,"_seriesDifferentiationEnabled",2);b([m({type:String,reflect:!0})],g.prototype,"spacing",2);b([m({type:String,attribute:"spacing-top",reflect:!0})],g.prototype,"spacingTop",2);b([m({type:String,attribute:"spacing-bottom",reflect:!0})],g.prototype,"spacingBottom",2);b([m({type:String,attribute:"spacing-left",reflect:!0})],g.prototype,"spacingLeft",2);b([m({type:String,attribute:"spacing-right",reflect:!0})],g.prototype,"spacingRight",2);g=b([ot("scb-viz")],g);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.287",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -386,5 +386,5 @@
|
|
|
386
386
|
},
|
|
387
387
|
"./mvc/*": "./mvc/*"
|
|
388
388
|
},
|
|
389
|
-
"buildHash": "
|
|
389
|
+
"buildHash": "888A8D813265C6957EF7201576978AAD7521907BC8A4C494228AFCC3CE637170"
|
|
390
390
|
}
|