scb-wc-test 0.1.291 → 0.1.293
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 +149 -131
- package/package.json +2 -2
- package/scb-viz/scb-viz.d.ts +2 -0
- package/scb-viz/scb-viz.js +404 -359
- package/scb-wc-test.bundle.js +553 -535
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as ct,n as y,r as P,i as ht,x as f,k as N,l as dt,t as gt}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,a,n){try{customElements.get(i)||e(i,a,n)}catch(r){var h=String(r||"");if(h.indexOf("already been used")===-1&&h.indexOf("NotSupportedError")===-1)throw r}}}}catch{}})();var pt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,W=t=>{throw TypeError(t)},b=(t,e,i,a)=>{for(var n=a>1?void 0:a?ft(e,i):e,h=t.length-1,r;h>=0;h--)(r=t[h])&&(n=(a?r(e,i,n):r(n))||n);return a&&n&&pt(e,i,n),n},ut=(t,e,i)=>e.has(t)||W("Cannot "+i),mt=(t,e,i)=>e.has(t)?W("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),l=(t,e,i)=>(ut(t,e,"access private method"),i),o,k,I,F,M,A,O,U,$,K,J,D,E,_,X,Q,Y,Z,tt,et,it,st,q,at,R,T,nt,rt,j,B,H,C,V;const ot=`<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 rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}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 b=class extends ot{constructor(){super(...arguments),pt(this,o),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 l(this,o,Y).call(this)},this._onDownloadPngClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await l(this,o,A).call(this,"png"))},this._onDownloadJpgClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await l(this,o,A).call(this,"jpeg"))},this._onDownloadCsvClick=()=>{this._canExportCsv()&&(this._closeActionsMenu(),l(this,o,Z).call(this))},this._onToggleSeriesDifferentiationClick=()=>{this._seriesDifferentiationEnabled=!this._seriesDifferentiationEnabled,this._closeActionsMenu(),l(this,o,M).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){this._readTableDataFromSlot(),l(this,o,T).call(this),l(this,o,H).call(this),l(this,o,D).call(this),this._syncChipClass(),l(this,o,L).call(this),l(this,o,C).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"))&&l(this,o,T).call(this),t.has("containerMaxWidth")&&l(this,o,H).call(this),t.has("variant")&&l(this,o,L).call(this),(t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode")||t.has("variant"))&&l(this,o,D).call(this),(t.has("selectedChip")||t.has("variant")||t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode"))&&l(this,o,C).call(this),(t.has("selectedChip")||t.has("variant"))&&this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{l(this,o,M).call(this)})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown),l(this,o,P).call(this),l(this,o,I).call(this)}_onTableSlotChange(t){const e=t.target;e&&(this._readTableDataFromSlot(e),this.requestUpdate())}_onDiagramSlotChange(){l(this,o,D).call(this),l(this,o,C).call(this),this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{l(this,o,M).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}),a=[];i.forEach(d=>{if(d.tagName==="TABLE"){a.push(d);return}d.querySelectorAll("table").forEach(u=>a.push(u))});const n=a[0];if(!n){this._slottedTableData=void 0;return}const h=[],r=[],s=[],c=d=>d?(d.textContent??"").replace(/\s+/g," ").trim():"",g=d=>d?{html:(d.innerHTML??"").trim(),text:c(d)}:{html:"",text:""},v=n.querySelector("thead tr");v&&Array.from(v.querySelectorAll("th, td")).forEach(u=>h.push(g(u)));const z=Array.from(n.querySelectorAll("tbody tr")),w=z.length>0?z:Array.from(n.querySelectorAll("tr")).filter(d=>d.closest("thead")===null);if(w.forEach(d=>{const u=Array.from(d.querySelectorAll("th, td"));if(u.length===0)return;const m=u[0].tagName==="TH"&&d.closest("thead")===null&&d.closest("tfoot")===null;s.push(m);const S=[];u.forEach($=>S.push(g($))),r.push(S)}),!v&&r.length>0){const d=r[0],u=w[0],m=Array.from(u?.querySelectorAll("th, td")??[]);m.length>0&&m.every($=>$.tagName==="TH")&&u?.closest("tbody")===null&&(h.splice(0,h.length,...d),r.shift(),s.shift())}this._slottedTableData={headers:h.length>0?h:void 0,rows:r,rowHeaderRows:s.length>0?s:void 0}}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(n=>n.length)),i=n=>{if(n==null)return!1;if(typeof n=="number")return!0;const h=String(n).replace(/[\u00A0\u202F\s]+/g,"").trim();return h?/^-?\d+(?:[.,]\d+)?$/.test(h):!1},a=[];for(let n=0;n<e;n+=1){if(n===0){a.push("left");continue}const h=t.rows.map(s=>this._normalizeRenderableCell(s[n]).text).filter(s=>s!==""&&s!==null&&s!==void 0),r=h.length>0&&h.every(i);a.push(r?"right":"left")}return a}_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())}_getCurrentHighchartsChart(){if(this._getCurrentPrintableView()!=="diagram")return;const t=l(this,o,F).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||!this._isHighchartsStyledMode(t)?!1:t.series.some(e=>this._getSeriesDifferentiationGroup(e,t)!==null)}_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{marker:e&&Object.keys(e).length>0?e:{enabled:!1}}}_getHighchartsSvgElement(t){const e=t?.element??t;return e instanceof SVGElement?e:null}_isHighchartsStyledMode(t){return!!(t?.styledMode||t?.renderer?.styledMode||t?.options?.chart?.styledMode)}_getHighchartsSvgRoot(t){if(t?.container instanceof SVGSVGElement)return t.container;const e=t?.renderTo?.querySelector("svg")??t?.container?.querySelector?.("svg");return e instanceof SVGSVGElement?e:null}_getHighchartsColorClassName(t,e){const i=this._getHighchartsSvgElement(t);return Array.from(i?.classList??[]).find(n=>/^highcharts-color-\d+$/.test(n))??`highcharts-color-${e}`}_setSeriesDifferentiationMetadata(t,e){const i=this._getHighchartsSvgElement(t);i&&(i.setAttribute("data-scb-viz-role",e.role),e.dashStyle?i.setAttribute("data-scb-viz-dash-style",e.dashStyle):i.removeAttribute("data-scb-viz-dash-style"),e.patternKind?i.setAttribute("data-scb-viz-pattern-kind",e.patternKind):i.removeAttribute("data-scb-viz-pattern-kind"))}_clearSeriesDifferentiationMetadata(t){const e=this._getHighchartsSvgElement(t);e&&(e.removeAttribute("data-scb-viz-role"),e.removeAttribute("data-scb-viz-dash-style"),e.removeAttribute("data-scb-viz-pattern-kind"))}_getSeriesDifferentiationDashStyles(){return["Solid","ShortDash","ShortDot","ShortDashDot","ShortDashDotDot","Dot","LongDash","LongDashDot","Dash","DashDot"]}_getSeriesDifferentiationMarkerSymbols(){return["circle","diamond","square","triangle","triangle-down"]}_getSeriesDifferentiationPatternKinds(){return["diagonal","dots","cross","vertical","horizontal","grid","diagonal-reverse","dots-dense","checker","zigzag"]}_setSeriesDifferentiationColorClass(t,e){const i=this._getHighchartsSvgElement(t);if(!i||!e)return;const a=Array.from(i.classList).find(n=>/^highcharts-color-\d+$/.test(n));a!==e&&(a&&(i.classList.remove(a),i.setAttribute("data-scb-viz-prev-color-class",a)),i.classList.add(e),i.setAttribute("data-scb-viz-added-color-class",e))}_clearSeriesDifferentiationColorClass(t){const e=this._getHighchartsSvgElement(t);if(!e)return;const i=e.getAttribute("data-scb-viz-added-color-class"),a=e.getAttribute("data-scb-viz-prev-color-class");i&&(e.classList.remove(i),e.removeAttribute("data-scb-viz-added-color-class")),a&&(e.classList.add(a),e.removeAttribute("data-scb-viz-prev-color-class"))}_getLegendSeriesDifferentiationTargets(t){const e=[],i=[],a=this._getHighchartsSvgElement(t?.legendItem?.group),n=(r,s)=>{const c=this._getHighchartsSvgElement(s);!c||r.includes(c)||r.push(c)};if(n(e,t?.legendLine),n(e,t?.legendItem?.line),n(i,t?.legendSymbol),n(i,t?.legendItem?.symbol),n(i,t?.legendArea),n(i,t?.legendItem?.area),a){const r=a.querySelector(".highcharts-graph, .highcharts-legend-graph, line, path");r&&n(e,r),a.querySelectorAll("rect, circle, .highcharts-point, .highcharts-area, .highcharts-legend-symbol, path").forEach(s=>{n(i,s)})}const h=i.filter(r=>!e.includes(r));return{graphTargets:e,fillTargets:h}}_ensureStyledModeSeriesPattern(t,e,i){const a=this._getHighchartsSvgRoot(t);if(!a)return;const n="http://www.w3.org/2000/svg";let h=a.querySelector("defs");h instanceof SVGDefsElement||(h=document.createElementNS(n,"defs"),a.insertBefore(h,a.firstChild));const r=`scb-viz-pattern-${e}-${i}`;if(h.querySelector(`#${r}`))return;const s=document.createElementNS(n,"pattern");s.setAttribute("id",r),s.setAttribute("patternUnits","userSpaceOnUse"),s.setAttribute("width","10"),s.setAttribute("height","10"),s.classList.add(e);const c=document.createElementNS(n,"rect");c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("class","scb-viz-highcharts-pattern__background"),s.appendChild(c);const g=(w,d="1.25")=>{const u=document.createElementNS(n,"path");return u.setAttribute("d",w),u.setAttribute("class","scb-viz-highcharts-pattern__mark"),u.setAttribute("stroke-width",d),u.setAttribute("stroke-linecap","square"),u},v=(w,d,u)=>{const m=document.createElementNS(n,"circle");return m.setAttribute("cx",w),m.setAttribute("cy",d),m.setAttribute("r",u),m.setAttribute("class","scb-viz-highcharts-pattern__mark--dot"),m},z=(w,d,u,m)=>{const S=document.createElementNS(n,"rect");return S.setAttribute("x",w),S.setAttribute("y",d),S.setAttribute("width",u),S.setAttribute("height",m),S.setAttribute("class","scb-viz-highcharts-pattern__mark--square"),S};switch(i){case"diagonal":s.appendChild(g("M-2,8 l10,-10 M0,10 l10,-10 M8,12 l4,-4"));break;case"dots":s.appendChild(v("2","2","1.2")),s.appendChild(v("7","7","1.2"));break;case"cross":s.appendChild(g("M0,0 L10,10 M10,0 L0,10"));break;case"vertical":s.appendChild(g("M2,0 L2,10 M7,0 L7,10"));break;case"horizontal":s.appendChild(g("M0,2 L10,2 M0,7 L10,7"));break;case"diagonal-reverse":s.appendChild(g("M0,0 L10,10 M-2,2 L8,12 M2,-2 L12,8"));break;case"dots-dense":s.appendChild(v("2","2","1")),s.appendChild(v("7","2","1")),s.appendChild(v("2","7","1")),s.appendChild(v("7","7","1"));break;case"checker":s.appendChild(z("0","0","4","4")),s.appendChild(z("5","5","4","4"));break;case"zigzag":s.appendChild(g("M-2,8 L2,4 L6,8 L10,4 L14,8 M-2,3 L2,-1 L6,3 L10,-1 L14,3"));break;default:s.appendChild(g("M0,0 L10,0 M0,5 L10,5 M0,10 L10,10","1"));break}h.appendChild(s)}_applyStyledModeSeriesDifferentiation(t){const e=this._getHighchartsSvgRoot(t);if(!e)return;e.classList.add("scb-viz-series-differentiation-enabled");const i=this._getSeriesDifferentiationDashStyles(),a=this._getSeriesDifferentiationMarkerSymbols(),n=this._getSeriesDifferentiationPatternKinds(),h=this._getSeriesDifferentiationSnapshotStore(t);t.series?.forEach((r,s)=>{const c=this._getSeriesDifferentiationGroup(r,t);if(!c)return;const g=String(r?.index??s);h.has(g)||h.set(g,this._captureSeriesDifferentiationSnapshot(r));const v=i[s%i.length],z=n[s%n.length],w=a[s%a.length],d=this._getHighchartsColorClassName(r?.graph??r?.area??r?.group,s),u=this._getLegendSeriesDifferentiationTargets(r);this._setSeriesDifferentiationMetadata(r?.graph,{role:"graph",dashStyle:v}),c==="area"&&(this._setSeriesDifferentiationMetadata(r?.area,{role:"area",patternKind:z}),this._setSeriesDifferentiationColorClass(r?.area,d),this._ensureStyledModeSeriesPattern(t,d,z)),c==="fill"&&(r.points?.forEach(m=>{this._setSeriesDifferentiationMetadata(m?.graphic,{role:"fill",patternKind:z}),this._setSeriesDifferentiationColorClass(m?.graphic,d)}),this._ensureStyledModeSeriesPattern(t,d,z)),(c==="line"||c==="area")&&u.graphTargets.forEach(m=>{this._setSeriesDifferentiationMetadata(m,{role:"legend-symbol",dashStyle:v})}),(c==="area"||c==="fill")&&u.fillTargets.forEach(m=>{this._setSeriesDifferentiationMetadata(m,{role:"legend-fill",patternKind:z}),this._setSeriesDifferentiationColorClass(m,d)}),(c==="line"||c==="area")&&r.update({marker:{enabled:!0,symbol:w}},!1)}),t.redraw(!1)}_restoreStyledModeSeriesDifferentiation(t){this._getHighchartsSvgRoot(t)?.classList.remove("scb-viz-series-differentiation-enabled");const i=this._getSeriesDifferentiationSnapshotStore(t);t.series?.forEach((a,n)=>{const h=this._getSeriesDifferentiationGroup(a,t);if(!h)return;const r=this._getLegendSeriesDifferentiationTargets(a);if(this._clearSeriesDifferentiationMetadata(a?.graph),this._clearSeriesDifferentiationMetadata(a?.area),this._clearSeriesDifferentiationColorClass(a?.area),a.points?.forEach(s=>{this._clearSeriesDifferentiationMetadata(s?.graphic),this._clearSeriesDifferentiationColorClass(s?.graphic)}),r.graphTargets.forEach(s=>{this._clearSeriesDifferentiationMetadata(s)}),r.fillTargets.forEach(s=>{this._clearSeriesDifferentiationMetadata(s),this._clearSeriesDifferentiationColorClass(s)}),h==="line"||h==="area"){const s=i.get(String(a?.index??n));a.update({marker:this._cloneSeriesOptionValue(s?.marker)},!1)}}),t.redraw(!1)}_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._getCurrentPrintableView(),e=this._canExportRaster(),i=this._canExportCsv(),a=e&&(t==="diagram"||t==="image"),n=i&&t==="table",h=this._shouldShowSeriesDifferentiationAction();return p`
|
|
116
|
+
`;let u=class extends ht{constructor(){super(...arguments),mt(this,o),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 l(this,o,tt).call(this)},this._onDownloadPngClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await l(this,o,E).call(this,"png"))},this._onDownloadJpgClick=async()=>{this._canExportRaster()&&(this._closeActionsMenu(),await l(this,o,E).call(this,"jpeg"))},this._onDownloadCsvClick=()=>{this._canExportCsv()&&(this._closeActionsMenu(),l(this,o,et).call(this))},this._onToggleSeriesDifferentiationClick=()=>{this._seriesDifferentiationEnabled=!this._seriesDifferentiationEnabled,this._closeActionsMenu(),l(this,o,D).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){this._readTableDataFromSlot(),l(this,o,H).call(this),l(this,o,V).call(this),l(this,o,$).call(this),this._syncChipClass(),l(this,o,k).call(this),l(this,o,M).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"))&&l(this,o,H).call(this),t.has("containerMaxWidth")&&l(this,o,V).call(this),t.has("variant")&&l(this,o,k).call(this),(t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode")||t.has("variant"))&&l(this,o,$).call(this),(t.has("selectedChip")||t.has("variant")||t.has("contentMaxWidth")||t.has("contentHeight")||t.has("toggleHeightMode"))&&l(this,o,M).call(this),(t.has("selectedChip")||t.has("variant"))&&this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{l(this,o,D).call(this)})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown),l(this,o,I).call(this),l(this,o,F).call(this)}_onTableSlotChange(t){const e=t.target;e&&(this._readTableDataFromSlot(e),this.requestUpdate())}_onDiagramSlotChange(){l(this,o,$).call(this),l(this,o,M).call(this),this._seriesDifferentiationEnabled&&requestAnimationFrame(()=>{l(this,o,D).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}),a=[];i.forEach(g=>{if(g.tagName==="TABLE"){a.push(g);return}g.querySelectorAll("table").forEach(m=>a.push(m))});const n=a[0];if(!n){this._slottedTableData=void 0;return}const h=[],r=[],s=[],c=g=>g?(g.textContent??"").replace(/\s+/g," ").trim():"",d=g=>g?{html:(g.innerHTML??"").trim(),text:c(g)}:{html:"",text:""},v=n.querySelector("thead tr");v&&Array.from(v.querySelectorAll("th, td")).forEach(m=>h.push(d(m)));const z=Array.from(n.querySelectorAll("tbody tr")),w=z.length>0?z:Array.from(n.querySelectorAll("tr")).filter(g=>g.closest("thead")===null);if(w.forEach(g=>{const m=Array.from(g.querySelectorAll("th, td"));if(m.length===0)return;const p=m[0].tagName==="TH"&&g.closest("thead")===null&&g.closest("tfoot")===null;s.push(p);const S=[];m.forEach(x=>S.push(d(x))),r.push(S)}),!v&&r.length>0){const g=r[0],m=w[0],p=Array.from(m?.querySelectorAll("th, td")??[]);p.length>0&&p.every(x=>x.tagName==="TH")&&m?.closest("tbody")===null&&(h.splice(0,h.length,...g),r.shift(),s.shift())}this._slottedTableData={headers:h.length>0?h:void 0,rows:r,rowHeaderRows:s.length>0?s:void 0}}_inferTableAlignments(t){const e=Math.max(t.headers?.length??0,...t.rows.map(n=>n.length)),i=n=>{if(n==null)return!1;if(typeof n=="number")return!0;const h=String(n).replace(/[\u00A0\u202F\s]+/g,"").trim();return h?/^-?\d+(?:[.,]\d+)?$/.test(h):!1},a=[];for(let n=0;n<e;n+=1){if(n===0){a.push("left");continue}const h=t.rows.map(s=>this._normalizeRenderableCell(s[n]).text).filter(s=>s!==""&&s!==null&&s!==void 0),r=h.length>0&&h.every(i);a.push(r?"right":"left")}return a}_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())}_getCurrentHighchartsChart(){if(this._getCurrentPrintableView()!=="diagram")return;const t=l(this,o,O).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":["pie","variablepie"].includes(i)?"point-fill":null}_shouldShowSeriesDifferentiationAction(){if(this._getCurrentPrintableView()!=="diagram")return!1;const t=this._getCurrentHighchartsChart();return!t?.series?.length||!this._isHighchartsStyledMode(t)?!1:t.series.some(e=>this._getSeriesDifferentiationGroup(e,t)!==null)}_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{marker:e&&Object.keys(e).length>0?e:{enabled:!1}}}_getHighchartsSvgElement(t){const e=t?.element??t;return e instanceof SVGElement?e:null}_isHighchartsStyledMode(t){return!!(t?.styledMode||t?.renderer?.styledMode||t?.options?.chart?.styledMode)}_getHighchartsSvgRoot(t){if(t?.container instanceof SVGSVGElement)return t.container;const e=t?.renderTo?.querySelector("svg")??t?.container?.querySelector?.("svg");return e instanceof SVGSVGElement?e:null}_getHighchartsColorClassName(t,e){const i=this._getHighchartsSvgElement(t);return Array.from(i?.classList??[]).find(n=>/^highcharts-color-\d+$/.test(n))??`highcharts-color-${e}`}_setSeriesDifferentiationMetadata(t,e){const i=this._getHighchartsSvgElement(t);i&&(i.setAttribute("data-scb-viz-role",e.role),e.dashStyle?i.setAttribute("data-scb-viz-dash-style",e.dashStyle):i.removeAttribute("data-scb-viz-dash-style"),e.patternKind?i.setAttribute("data-scb-viz-pattern-kind",e.patternKind):i.removeAttribute("data-scb-viz-pattern-kind"))}_clearSeriesDifferentiationMetadata(t){const e=this._getHighchartsSvgElement(t);e&&(e.removeAttribute("data-scb-viz-role"),e.removeAttribute("data-scb-viz-dash-style"),e.removeAttribute("data-scb-viz-pattern-kind"))}_getSeriesDifferentiationDashStyles(){return["Solid","ShortDash","ShortDot","ShortDashDot","ShortDashDotDot","Dot","LongDash","LongDashDot","Dash","DashDot"]}_getSeriesDifferentiationMarkerSymbols(){return["circle","diamond","square","triangle","triangle-down"]}_getSeriesDifferentiationPatternKinds(){return["diagonal","dots","cross","vertical","horizontal","grid","diagonal-reverse","dots-dense","checker","zigzag"]}_setSeriesDifferentiationColorClass(t,e){const i=this._getHighchartsSvgElement(t);if(!i||!e)return;const a=Array.from(i.classList).find(n=>/^highcharts-color-\d+$/.test(n));a!==e&&(a&&(i.classList.remove(a),i.setAttribute("data-scb-viz-prev-color-class",a)),i.classList.add(e),i.setAttribute("data-scb-viz-added-color-class",e))}_clearSeriesDifferentiationColorClass(t){const e=this._getHighchartsSvgElement(t);if(!e)return;const i=e.getAttribute("data-scb-viz-added-color-class"),a=e.getAttribute("data-scb-viz-prev-color-class");i&&(e.classList.remove(i),e.removeAttribute("data-scb-viz-added-color-class")),a&&(e.classList.add(a),e.removeAttribute("data-scb-viz-prev-color-class"))}_getLegendSeriesDifferentiationTargets(t){const e=[],i=[],a=this._getHighchartsSvgElement(t?.legendItem?.group),n=(r,s)=>{const c=this._getHighchartsSvgElement(s);!c||r.includes(c)||r.push(c)};if(n(e,t?.legendLine),n(e,t?.legendItem?.line),n(i,t?.legendSymbol),n(i,t?.legendItem?.symbol),n(i,t?.legendArea),n(i,t?.legendItem?.area),a){const r=a.querySelector(".highcharts-graph, .highcharts-legend-graph, line, path");r&&n(e,r),a.querySelectorAll("rect, circle, .highcharts-point, .highcharts-area, .highcharts-legend-symbol, path").forEach(s=>{n(i,s)})}const h=i.filter(r=>!e.includes(r));return{graphTargets:e,fillTargets:h}}_ensureStyledModeSeriesPattern(t,e,i){const a=this._getHighchartsSvgRoot(t);if(!a)return;const n="http://www.w3.org/2000/svg";let h=a.querySelector("defs");h instanceof SVGDefsElement||(h=document.createElementNS(n,"defs"),a.insertBefore(h,a.firstChild));const r=`scb-viz-pattern-${e}-${i}`;if(h.querySelector(`#${r}`))return;const s=document.createElementNS(n,"pattern");s.setAttribute("id",r),s.setAttribute("patternUnits","userSpaceOnUse"),s.setAttribute("width","10"),s.setAttribute("height","10"),s.classList.add(e);const c=document.createElementNS(n,"rect");c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("class","scb-viz-highcharts-pattern__background"),s.appendChild(c);const d=(w,g="1.25")=>{const m=document.createElementNS(n,"path");return m.setAttribute("d",w),m.setAttribute("class","scb-viz-highcharts-pattern__mark"),m.setAttribute("stroke-width",g),m.setAttribute("stroke-linecap","square"),m},v=(w,g,m)=>{const p=document.createElementNS(n,"circle");return p.setAttribute("cx",w),p.setAttribute("cy",g),p.setAttribute("r",m),p.setAttribute("class","scb-viz-highcharts-pattern__mark--dot"),p},z=(w,g,m,p)=>{const S=document.createElementNS(n,"rect");return S.setAttribute("x",w),S.setAttribute("y",g),S.setAttribute("width",m),S.setAttribute("height",p),S.setAttribute("class","scb-viz-highcharts-pattern__mark--square"),S};switch(i){case"diagonal":s.appendChild(d("M-2,8 l10,-10 M0,10 l10,-10 M8,12 l4,-4"));break;case"dots":s.appendChild(v("2","2","1.2")),s.appendChild(v("7","7","1.2"));break;case"cross":s.appendChild(d("M0,0 L10,10 M10,0 L0,10"));break;case"vertical":s.appendChild(d("M2,0 L2,10 M7,0 L7,10"));break;case"horizontal":s.appendChild(d("M0,2 L10,2 M0,7 L10,7"));break;case"diagonal-reverse":s.appendChild(d("M0,0 L10,10 M-2,2 L8,12 M2,-2 L12,8"));break;case"dots-dense":s.appendChild(v("2","2","1")),s.appendChild(v("7","2","1")),s.appendChild(v("2","7","1")),s.appendChild(v("7","7","1"));break;case"checker":s.appendChild(z("0","0","4","4")),s.appendChild(z("5","5","4","4"));break;case"zigzag":s.appendChild(d("M-2,8 L2,4 L6,8 L10,4 L14,8 M-2,3 L2,-1 L6,3 L10,-1 L14,3"));break;default:s.appendChild(d("M0,0 L10,0 M0,5 L10,5 M0,10 L10,10","1"));break}h.appendChild(s)}_applyStyledModeSeriesDifferentiation(t){const e=this._getHighchartsSvgRoot(t);if(!e)return;e.classList.add("scb-viz-series-differentiation-enabled");const i=this._getSeriesDifferentiationDashStyles(),a=this._getSeriesDifferentiationMarkerSymbols(),n=this._getSeriesDifferentiationPatternKinds(),h=this._getSeriesDifferentiationSnapshotStore(t);t.series?.forEach((r,s)=>{const c=this._getSeriesDifferentiationGroup(r,t);if(!c)return;const d=String(r?.index??s);h.has(d)||h.set(d,this._captureSeriesDifferentiationSnapshot(r));const v=i[s%i.length],z=n[s%n.length],w=a[s%a.length],g=this._getHighchartsColorClassName(r?.graph??r?.area??r?.group,s),m=this._getLegendSeriesDifferentiationTargets(r);this._setSeriesDifferentiationMetadata(r?.graph,{role:"graph",dashStyle:v}),c==="area"&&(this._setSeriesDifferentiationMetadata(r?.area,{role:"area",patternKind:z}),this._setSeriesDifferentiationColorClass(r?.area,g),this._ensureStyledModeSeriesPattern(t,g,z)),c==="fill"&&(r.points?.forEach(p=>{this._setSeriesDifferentiationMetadata(p?.graphic,{role:"fill",patternKind:z}),this._setSeriesDifferentiationColorClass(p?.graphic,g)}),this._ensureStyledModeSeriesPattern(t,g,z)),c==="point-fill"&&r.points?.forEach((p,S)=>{const x=n[S%n.length],L=this._getHighchartsColorClassName(p?.graphic??p?.legendSymbol??p?.legendItem?.symbol??p?.legendItem?.group,S),lt=this._getLegendSeriesDifferentiationTargets(p);this._setSeriesDifferentiationMetadata(p?.graphic,{role:"fill",patternKind:x}),this._setSeriesDifferentiationColorClass(p?.graphic,L),this._ensureStyledModeSeriesPattern(t,L,x),lt.fillTargets.forEach(G=>{this._setSeriesDifferentiationMetadata(G,{role:"legend-fill",patternKind:x}),this._setSeriesDifferentiationColorClass(G,L)})}),(c==="line"||c==="area")&&m.graphTargets.forEach(p=>{this._setSeriesDifferentiationMetadata(p,{role:"legend-symbol",dashStyle:v})}),(c==="area"||c==="fill")&&m.fillTargets.forEach(p=>{this._setSeriesDifferentiationMetadata(p,{role:"legend-fill",patternKind:z}),this._setSeriesDifferentiationColorClass(p,g)}),(c==="line"||c==="area")&&r.update({marker:{enabled:!0,symbol:w}},!1)}),t.redraw(!1)}_restoreStyledModeSeriesDifferentiation(t){this._getHighchartsSvgRoot(t)?.classList.remove("scb-viz-series-differentiation-enabled");const i=this._getSeriesDifferentiationSnapshotStore(t);t.series?.forEach((a,n)=>{const h=this._getSeriesDifferentiationGroup(a,t);if(!h)return;const r=this._getLegendSeriesDifferentiationTargets(a);if(this._clearSeriesDifferentiationMetadata(a?.graph),this._clearSeriesDifferentiationMetadata(a?.area),this._clearSeriesDifferentiationColorClass(a?.area),a.points?.forEach(s=>{const c=this._getLegendSeriesDifferentiationTargets(s);this._clearSeriesDifferentiationMetadata(s?.graphic),this._clearSeriesDifferentiationColorClass(s?.graphic),c.graphTargets.forEach(d=>{this._clearSeriesDifferentiationMetadata(d)}),c.fillTargets.forEach(d=>{this._clearSeriesDifferentiationMetadata(d),this._clearSeriesDifferentiationColorClass(d)})}),r.graphTargets.forEach(s=>{this._clearSeriesDifferentiationMetadata(s)}),r.fillTargets.forEach(s=>{this._clearSeriesDifferentiationMetadata(s),this._clearSeriesDifferentiationColorClass(s)}),h==="line"||h==="area"){const s=i.get(String(a?.index??n));a.update({marker:this._cloneSeriesOptionValue(s?.marker)},!1)}}),t.redraw(!1)}_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(),a=e&&(t==="diagram"||t==="image"),n=i&&t==="table",h=this._shouldShowSeriesDifferentiationAction();return f`
|
|
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=${r=>this._toggleActionsMenu(r)}
|
|
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
|
+
${a?f`
|
|
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
|
+
${n?f`
|
|
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?f`
|
|
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 f`
|
|
117
204
|
<div class="actions-row">
|
|
118
|
-
${this.variant==="Standard"&&!this.disableToggle?
|
|
205
|
+
${this.variant==="Standard"&&!this.disableToggle?f`
|
|
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,133 +220,58 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
133
220
|
></scb-segmented-item>
|
|
134
221
|
</scb-segmented-button>
|
|
135
222
|
</div>
|
|
136
|
-
`:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
@click=${r=>this._toggleActionsMenu(r)}
|
|
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
|
-
${a?p`
|
|
168
|
-
<li>
|
|
169
|
-
<button
|
|
170
|
-
type="button"
|
|
171
|
-
class="actions-menu-item"
|
|
172
|
-
role="menuitem"
|
|
173
|
-
@click=${this._onDownloadPngClick}
|
|
174
|
-
>
|
|
175
|
-
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
176
|
-
<span class="actions-menu-item-label">${this.downloadPngLabel}</span>
|
|
177
|
-
</button>
|
|
178
|
-
</li>
|
|
179
|
-
<li>
|
|
180
|
-
<button
|
|
181
|
-
type="button"
|
|
182
|
-
class="actions-menu-item"
|
|
183
|
-
role="menuitem"
|
|
184
|
-
@click=${this._onDownloadJpgClick}
|
|
185
|
-
>
|
|
186
|
-
<span class="actions-menu-item-icon" aria-hidden="true">image</span>
|
|
187
|
-
<span class="actions-menu-item-label">${this.downloadJpgLabel}</span>
|
|
188
|
-
</button>
|
|
189
|
-
</li>
|
|
190
|
-
`:""}
|
|
191
|
-
${n?p`
|
|
192
|
-
<li>
|
|
193
|
-
<button
|
|
194
|
-
type="button"
|
|
195
|
-
class="actions-menu-item"
|
|
196
|
-
role="menuitem"
|
|
197
|
-
@click=${this._onDownloadCsvClick}
|
|
198
|
-
>
|
|
199
|
-
<span class="actions-menu-item-icon" aria-hidden="true">table_view</span>
|
|
200
|
-
<span class="actions-menu-item-label">${this.downloadCsvLabel}</span>
|
|
201
|
-
</button>
|
|
202
|
-
</li>
|
|
203
|
-
`:""}
|
|
204
|
-
${h?p`
|
|
205
|
-
<li>
|
|
206
|
-
<button
|
|
207
|
-
type="button"
|
|
208
|
-
class="actions-menu-item"
|
|
209
|
-
role="menuitemcheckbox"
|
|
210
|
-
aria-checked=${this._seriesDifferentiationEnabled?"true":"false"}
|
|
211
|
-
@click=${this._onToggleSeriesDifferentiationClick}
|
|
212
|
-
>
|
|
213
|
-
<span class="actions-menu-item-icon" aria-hidden="true">texture</span>
|
|
214
|
-
<span class="actions-menu-item-label"
|
|
215
|
-
>${this._seriesDifferentiationEnabled?this.disableSeriesDifferentiationLabel:this.enableSeriesDifferentiationLabel}</span
|
|
216
|
-
>
|
|
217
|
-
</button>
|
|
218
|
-
</li>
|
|
219
|
-
`:""}
|
|
220
|
-
</ul>
|
|
221
|
-
</div>
|
|
222
|
-
</div>
|
|
223
|
+
`:f`<div></div>`}
|
|
224
|
+
${this._renderActionsMenu()}
|
|
225
|
+
</div>
|
|
226
|
+
`}_renderHeader(t=!1){const e=f`
|
|
227
|
+
<div class="header">
|
|
228
|
+
${this.title?f` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
229
|
+
${this.subtitle?f` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
230
|
+
</div>
|
|
231
|
+
`;return t?f`
|
|
232
|
+
<div class="header-row">
|
|
233
|
+
${e}
|
|
234
|
+
${this._renderActionsMenu()}
|
|
223
235
|
</div>
|
|
224
|
-
|
|
236
|
+
`:e}_renderTable(){const t=this.tableData??this._slottedTableData;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(s=>s.length)),a=(t.headers??[]).map(s=>this._normalizeRenderableCell(s)),n=t.rows.map(s=>{const c=s.map(d=>this._normalizeRenderableCell(d));for(;c.length<i;)c.push({html:"",text:""});return c}),h=t.rowHeaderRows??[],r=[this.title,this.subtitle].map(s=>typeof s=="string"?s.trim():"").filter(Boolean).join(". ");return f`
|
|
225
237
|
<table class="scb-viz-table" part="table">
|
|
226
|
-
${r?
|
|
227
|
-
${a.length>0?
|
|
238
|
+
${r?f`<caption class="visually-hidden">${r}</caption>`:""}
|
|
239
|
+
${a.length>0?f`
|
|
228
240
|
<thead>
|
|
229
241
|
<tr>
|
|
230
|
-
${a.map((s,c)=>{const
|
|
242
|
+
${a.map((s,c)=>{const d=e[c]==="right"?"align-right":"align-left";return f`<th scope="col" class=${d}>${s.html?N(s.html):s.text}</th>`})}
|
|
231
243
|
</tr>
|
|
232
244
|
</thead>
|
|
233
245
|
`:""}
|
|
234
246
|
<tbody>
|
|
235
|
-
${n.map((s,c)=>{const
|
|
247
|
+
${n.map((s,c)=>{const d=h[c]===!0;return f`
|
|
236
248
|
<tr>
|
|
237
|
-
${s.map((v,z)=>{const w=e[z]==="right"?"align-right":"align-left",
|
|
249
|
+
${s.map((v,z)=>{const w=e[z]==="right"?"align-right":"align-left",g=v.html?N(v.html):v.text;return z===0&&d?f`<th scope="row" class=${w}>${g}</th>`:f`<td class=${w}>${g}</td>`})}
|
|
238
250
|
</tr>
|
|
239
251
|
`})}
|
|
240
252
|
</tbody>
|
|
241
253
|
</table>
|
|
242
|
-
`}_hasMoreAboutStats(){return!!(this.comment||this.source||this.footnote||this.officialStatistics)}_renderMoreAboutStatsContent(){return
|
|
254
|
+
`}_hasMoreAboutStats(){return!!(this.comment||this.source||this.footnote||this.officialStatistics)}_renderMoreAboutStatsContent(){return f`
|
|
243
255
|
<div class="more-about-stats-content">
|
|
244
|
-
${this.comment?
|
|
256
|
+
${this.comment?f`
|
|
245
257
|
<div class="section">
|
|
246
258
|
<div class="secondary-label" role="heading" aria-level="3">${this.commentLabel}</div>
|
|
247
259
|
<div class="body-text">${this.comment}</div>
|
|
248
260
|
</div>
|
|
249
261
|
`:""}
|
|
250
|
-
${this.source?
|
|
262
|
+
${this.source?f`
|
|
251
263
|
<div class="section">
|
|
252
264
|
<div class="secondary-label" role="heading" aria-level="3">${this.sourceLabel}</div>
|
|
253
265
|
<div class="body-text">${this.source}</div>
|
|
254
266
|
</div>
|
|
255
267
|
`:""}
|
|
256
|
-
${this.footnote?
|
|
268
|
+
${this.footnote?f`
|
|
257
269
|
<div class="section">
|
|
258
270
|
<div class="secondary-label" role="heading" aria-level="3">${this.footnoteLabel}</div>
|
|
259
271
|
<div class="body-text">${this.footnote}</div>
|
|
260
272
|
</div>
|
|
261
273
|
`:""}
|
|
262
|
-
${this.officialStatistics?
|
|
274
|
+
${this.officialStatistics?f`
|
|
263
275
|
<a
|
|
264
276
|
class="sos-logotype-link"
|
|
265
277
|
href="https://www.scb.se/sos"
|
|
@@ -269,12 +281,12 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
269
281
|
aria-label="${this.officialStatisticsAlt}"
|
|
270
282
|
>
|
|
271
283
|
<span class="sos-logotype-small" aria-hidden="true">
|
|
272
|
-
${
|
|
284
|
+
${dt(ot)}
|
|
273
285
|
</span>
|
|
274
286
|
</a>
|
|
275
287
|
`:""}
|
|
276
288
|
</div>
|
|
277
|
-
`}_renderMoreAboutStatsScreen(){return this._hasMoreAboutStats()?
|
|
289
|
+
`}_renderMoreAboutStatsScreen(){return this._hasMoreAboutStats()?f`
|
|
278
290
|
<div class="footer-statistics-screen">
|
|
279
291
|
<scb-divider></scb-divider>
|
|
280
292
|
<scb-accordion>
|
|
@@ -283,16 +295,16 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
283
295
|
</scb-accordion-item>
|
|
284
296
|
</scb-accordion>
|
|
285
297
|
</div>
|
|
286
|
-
`:""}_renderMoreAboutStatsPrint(){return this._hasMoreAboutStats()?
|
|
298
|
+
`:""}_renderMoreAboutStatsPrint(){return this._hasMoreAboutStats()?f`
|
|
287
299
|
<div class="footer-statistics-print print-more-about-stats">
|
|
288
300
|
<div class="secondary-label print-more-about-stats-heading" role="heading" aria-level="3">
|
|
289
301
|
${this.moreAboutStatsLabel}
|
|
290
302
|
</div>
|
|
291
303
|
${this._renderMoreAboutStatsContent()}
|
|
292
304
|
</div>
|
|
293
|
-
`:""}_renderFooter(){return
|
|
305
|
+
`:""}_renderFooter(){return f`
|
|
294
306
|
<div class="footer">
|
|
295
|
-
${this.description?
|
|
307
|
+
${this.description?f`
|
|
296
308
|
<div class="description section">
|
|
297
309
|
<div class="secondary-label" role="heading" aria-level="3">${this.descriptionLabel}</div>
|
|
298
310
|
<div class="body-text">${this.description}</div>
|
|
@@ -301,13 +313,9 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
301
313
|
${this._renderMoreAboutStatsScreen()}
|
|
302
314
|
${this._renderMoreAboutStatsPrint()}
|
|
303
315
|
</div>
|
|
304
|
-
`}render(){switch(this.variant){case"Table":return
|
|
316
|
+
`}render(){switch(this.variant){case"Table":return f`
|
|
305
317
|
<div part="container" class="viz-container">
|
|
306
|
-
|
|
307
|
-
${this.title?p` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
308
|
-
${this.subtitle?p` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
309
|
-
</div>
|
|
310
|
-
${this._renderActions()}
|
|
318
|
+
${this._renderHeader(!0)}
|
|
311
319
|
<div class="content">
|
|
312
320
|
<scb-horizontal-scroller
|
|
313
321
|
width="600px"
|
|
@@ -326,13 +334,9 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
326
334
|
></slot>
|
|
327
335
|
<slot></slot>
|
|
328
336
|
</div>
|
|
329
|
-
`;case"Image":return
|
|
337
|
+
`;case"Image":return f`
|
|
330
338
|
<div part="container" class="viz-container">
|
|
331
|
-
|
|
332
|
-
${this.title?p` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
333
|
-
${this.subtitle?p` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
334
|
-
</div>
|
|
335
|
-
${this._renderActions()}
|
|
339
|
+
${this._renderHeader(!0)}
|
|
336
340
|
<div
|
|
337
341
|
class="content image-content"
|
|
338
342
|
style=${this._getResolvedContentMaxWidth()?`max-width: ${this._getResolvedContentMaxWidth()}; --scb-viz-content-max-width: ${this._getResolvedContentMaxWidth()};`:""}
|
|
@@ -347,12 +351,9 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
347
351
|
></slot>
|
|
348
352
|
<slot></slot>
|
|
349
353
|
</div>
|
|
350
|
-
`;default:return
|
|
354
|
+
`;default:return f`
|
|
351
355
|
<div part="container" class="viz-container">
|
|
352
|
-
|
|
353
|
-
${this.title?p` <div class="label" role="heading" aria-level="2">${this.title}</div> `:""}
|
|
354
|
-
${this.subtitle?p` <div class="sub-label">${this.subtitle}</div> `:""}
|
|
355
|
-
</div>
|
|
356
|
+
${this._renderHeader()}
|
|
356
357
|
${this._renderActions()}
|
|
357
358
|
<div class="content">
|
|
358
359
|
<div
|
|
@@ -399,7 +400,7 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
399
400
|
></slot>
|
|
400
401
|
<slot></slot>
|
|
401
402
|
</div>
|
|
402
|
-
`}}_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"}};o=new WeakSet;
|
|
403
|
+
`}}_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"}};o=new WeakSet;k=function(){if(l(this,o,I).call(this),typeof ResizeObserver>"u")return;const t=this.shadowRoot?.querySelector(".diagram-content");t&&(this._diagramResizeObserver=new ResizeObserver(()=>{l(this,o,M).call(this)}),this._diagramResizeObserver.observe(this),this._diagramResizeObserver.observe(t))};I=function(){this._diagramResizeObserver?.disconnect(),this._diagramResizeObserver=void 0};F=function(){this._diagramReflowFrame&&(cancelAnimationFrame(this._diagramReflowFrame),this._diagramReflowFrame=0)};M=function(){this.variant!=="Standard"||this.selectedChip!=="Diagram"||(l(this,o,F).call(this),this._diagramReflowFrame=requestAnimationFrame(()=>{this._diagramReflowFrame=requestAnimationFrame(()=>{this._diagramReflowFrame=0,l(this,o,U).call(this)})}))};A=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};O=function(t){for(const e of t){const i=l(this,o,A).call(this,e);if(i!==void 0)return i;const a=e.querySelector("[data-highcharts-chart]"),n=l(this,o,A).call(this,a);if(n!==void 0)return n}};U=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=l(this,o,O).call(this,e);if(i===void 0)return;const n=window.Highcharts?.charts?.[i];n&&(n.setSize?.(null,null,!1),n.reflow?.(),this._seriesDifferentiationEnabled&&l(this,o,D).call(this))};$=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")};K=function(t){this._isHighchartsStyledMode(t)&&this._applyStyledModeSeriesDifferentiation(t)};J=function(t){this._isHighchartsStyledMode(t)&&this._restoreStyledModeSeriesDifferentiation(t)};D=function(){const t=this._getCurrentHighchartsChart();if(t){if(this._seriesDifferentiationEnabled){l(this,o,K).call(this,t);return}l(this,o,J).call(this,t)}};E=async function(t){const e=this._getExportableVisualElement();if(!e)return;const i=await l(this,o,it).call(this,e,t);i&&l(this,o,B).call(this,i,this._buildExportFileName(t==="jpeg"?"jpg":"png"))};_=function(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")};X=function(t){const e=this._inferTableAlignments(t),i=Math.max(t.headers?.length??0,...t.rows.map(c=>c.length)),a=(t.headers??[]).map(c=>this._normalizeRenderableCell(c)),n=t.rows.map(c=>{const d=c.map(v=>this._normalizeRenderableCell(v));for(;d.length<i;)d.push({html:"",text:""});return d}),h=t.rowHeaderRows??[],r=a.length?`<thead><tr>${a.map((c,d)=>`<th scope="col" class="${e[d]==="right"?"align-right":"align-left"}">${c.html||l(this,o,_).call(this,c.text)}</th>`).join("")}</tr></thead>`:"",s=`<tbody>${n.map((c,d)=>{const v=h[d]===!0;return`<tr>${c.map((w,g)=>{const m=e[g]==="right"?"align-right":"align-left",p=w.html||l(this,o,_).call(this,w.text);return g===0&&v?`<th scope="row" class="${m}">${p}</th>`:`<td class="${m}">${p}</td>`}).join("")}</tr>`}).join("")}</tbody>`;return`<table class="scb-viz-print-table">${r}${s}</table>`};Q=function(){const t=[];if(this.description&&t.push(`
|
|
403
404
|
<section class="print-section">
|
|
404
405
|
<h2>${l(this,o,_).call(this,this.descriptionLabel)}</h2>
|
|
405
406
|
<div>${l(this,o,_).call(this,this.description)}</div>
|
|
@@ -420,13 +421,13 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
420
421
|
<div>${l(this,o,_).call(this,this.footnote)}</div>
|
|
421
422
|
</section>
|
|
422
423
|
`),this.officialStatistics&&e.push(`
|
|
423
|
-
<div class="print-sos">${
|
|
424
|
+
<div class="print-sos">${ot}</div>
|
|
424
425
|
`),t.push(`
|
|
425
426
|
<section class="print-section print-more-about-stats">
|
|
426
427
|
<h2>${l(this,o,_).call(this,this.moreAboutStatsLabel)}</h2>
|
|
427
428
|
${e.join("")}
|
|
428
429
|
</section>
|
|
429
|
-
`)}return t.join("")};
|
|
430
|
+
`)}return t.join("")};Y=function(t){return`<!doctype html>
|
|
430
431
|
<html lang="${l(this,o,_).call(this,this.lang||"sv")}">
|
|
431
432
|
<head>
|
|
432
433
|
<meta charset="utf-8">
|
|
@@ -473,11 +474,11 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
473
474
|
${this.subtitle?`<div class="viz-subtitle">${l(this,o,_).call(this,this.subtitle)}</div>`:""}
|
|
474
475
|
</header>
|
|
475
476
|
<div class="viz-content">${t}</div>
|
|
476
|
-
${l(this,o,
|
|
477
|
+
${l(this,o,Q).call(this)}
|
|
477
478
|
</article>
|
|
478
479
|
</body>
|
|
479
|
-
</html>`};
|
|
480
|
-
`)}`,h=new Blob([n],{type:"text/csv;charset=utf-8;"});l(this,o,
|
|
480
|
+
</html>`};Z=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()},a=e.contentDocument,n=e.contentWindow;if(!a||!n){i();return}a.open(),a.write(t),a.close();const h=Array.from(a.images||[]);await Promise.all(h.map(s=>s.complete?Promise.resolve():new Promise(c=>{s.addEventListener("load",()=>c(null),{once:!0}),s.addEventListener("error",()=>c(null),{once:!0})})));const r=()=>{n.removeEventListener("afterprint",r),i()};n.addEventListener("afterprint",r,{once:!0}),setTimeout(()=>{n.focus(),n.print(),setTimeout(i,1e3)},50)};tt=async function(){const t=this._getCurrentPrintableView();let e="";if(t==="table"){const i=this._getResolvedTableData();if(!i?.rows?.length)return;e=l(this,o,X).call(this,i)}else if(t==="image"){const i=this.shadowRoot?.querySelector(".image-content img"),a=i?.currentSrc||i?.src||this.imageHref;if(!a)return;e=`<img class="viz-image" src="${l(this,o,_).call(this,a)}" alt="${l(this,o,_).call(this,this._getImageAltText())}">`}else{const i=this._getExportableVisualElement();if(!i)return;const a=await l(this,o,st).call(this,i,"png");if(!a)return;e=`<img class="viz-chart-image" src="${a}" alt="${l(this,o,_).call(this,this._getImageAltText())}">`}await l(this,o,Z).call(this,l(this,o,Y).call(this,e))};et=function(){const t=this._getResolvedTableData();if(!t?.rows?.length)return;const e=this.lang==="en"?",":";",i=[];t.headers?.length&&i.push(t.headers.map(r=>this._normalizeRenderableCell(r).text)),t.rows.forEach(r=>{i.push(r.map(s=>this._normalizeRenderableCell(s).text))});const a=r=>`"${String(r??"").replace(/\r?\n/g," ").replace(/"/g,'""')}"`,n=`\uFEFF${i.map(r=>r.map(a).join(e)).join(`\r
|
|
481
|
+
`)}`,h=new Blob([n],{type:"text/csv;charset=utf-8;"});l(this,o,B).call(this,h,this._buildExportFileName("csv"))};it=async function(t,e){const i=await l(this,o,q).call(this,t);return i?l(this,o,rt).call(this,i,e==="jpeg"?"image/jpeg":"image/png",e==="jpeg"?.92:void 0):null};st=async function(t,e){const i=await l(this,o,q).call(this,t);return i?i.toDataURL(e==="jpeg"?"image/jpeg":"image/png",e==="jpeg"?.92:void 0):null};q=async function(t){if(t instanceof HTMLCanvasElement){const r=t.width||Math.round(t.getBoundingClientRect().width),s=t.height||Math.round(t.getBoundingClientRect().height);if(!r||!s)return null;const c=document.createElement("canvas");c.width=r,c.height=s;const d=c.getContext("2d");return d?(d.fillStyle=l(this,o,j).call(this),d.fillRect(0,0,r,s),d.drawImage(t,0,0,r,s),c):null}if(t instanceof HTMLImageElement){const r=t.naturalWidth||t.width,s=t.naturalHeight||t.height;return!r||!s?null:l(this,o,T).call(this,t.currentSrc||t.src,r,s)}const{width:e,height:i,serialized:a}=l(this,o,at).call(this,t);if(!e||!i||!a)return null;const n=new Blob([a],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(n);try{return await l(this,o,T).call(this,h,e,i)}finally{URL.revokeObjectURL(h)}};at=function(t){const e=t.cloneNode(!0),i=t.getBoundingClientRect(),a=t.viewBox?.baseVal,n=Math.round(a?.width||i.width||Number(t.getAttribute("width"))||0),h=Math.round(a?.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")&&n&&e.setAttribute("width",String(n)),!e.getAttribute("height")&&h&&e.setAttribute("height",String(h)),!e.getAttribute("viewBox")&&n&&h&&e.setAttribute("viewBox",`0 0 ${n} ${h}`),l(this,o,R).call(this,t,e),e.querySelectorAll(".highcharts-tooltip, .highcharts-contextmenu, .highcharts-a11y-proxy-container, .highcharts-a11y-dummy-point").forEach(r=>r.remove()),{width:n,height:h,serialized:new XMLSerializer().serializeToString(e)}};R=function(t,e){const i=getComputedStyle(t);let a="";for(let r=0;r<i.length;r+=1){const s=i[r],c=i.getPropertyValue(s);c&&(a+=`${s}:${c};`)}a&&e.setAttribute("style",a);const n=Array.from(t.children),h=Array.from(e.children);for(let r=0;r<n.length;r+=1){const s=n[r],c=h[r];s&&c&&l(this,o,R).call(this,s,c)}};T=async function(t,e,i){const a=Math.max(1,Math.min(2,window.devicePixelRatio||1)),n=Math.max(1,Math.round(e)),h=Math.max(1,Math.round(i)),r=document.createElement("canvas");r.width=Math.max(1,Math.round(n*a)),r.height=Math.max(1,Math.round(h*a));const s=r.getContext("2d");if(!s)return null;const c=await l(this,o,nt).call(this,t);return c?(s.scale(a,a),s.fillStyle=l(this,o,j).call(this),s.fillRect(0,0,n,h),s.drawImage(c,0,0,n,h),r):null};nt=function(t){return new Promise(e=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>e(null),i.src=t})};rt=function(t,e,i){return new Promise(a=>{t.toBlob(n=>a(n),e,i)})};j=function(){const t=this.shadowRoot?.querySelector(".viz-container"),e=getComputedStyle(t??this).backgroundColor;return e&&e!=="rgba(0, 0, 0, 0)"?e:"#ffffff"};B=function(t,e){const i=URL.createObjectURL(t),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),0)};H=function(){const t=l(this,o,C).call(this,this.spacing),e=l(this,o,C).call(this,this.spacingTop)??t,i=l(this,o,C).call(this,this.spacingBottom)??t,a=l(this,o,C).call(this,this.spacingLeft),n=l(this,o,C).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"),a?this.style.setProperty("--scb-viz-spacing-inline-start",a):this.style.removeProperty("--scb-viz-spacing-inline-start"),n?this.style.setProperty("--scb-viz-spacing-inline-end",n):this.style.removeProperty("--scb-viz-spacing-inline-end")};C=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};V=function(){const t=this.containerMaxWidth?.trim();t?this.style.setProperty("--scb-viz-container-max-width",t):this.style.removeProperty("--scb-viz-container-max-width")};u.styles=ct`
|
|
481
482
|
:host {
|
|
482
483
|
display: block;
|
|
483
484
|
box-sizing: border-box;
|
|
@@ -666,6 +667,23 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
666
667
|
text-align: start;
|
|
667
668
|
}
|
|
668
669
|
|
|
670
|
+
.header-row {
|
|
671
|
+
display: flex;
|
|
672
|
+
align-items: flex-start;
|
|
673
|
+
justify-content: space-between;
|
|
674
|
+
gap: var(--spacing-4, 16px);
|
|
675
|
+
margin-bottom: var(--spacing-7, 24px);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.header-row .header {
|
|
679
|
+
flex: 1 1 auto;
|
|
680
|
+
margin-bottom: 0;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.header-row .actions-menu {
|
|
684
|
+
margin-block-start: 0;
|
|
685
|
+
}
|
|
686
|
+
|
|
669
687
|
.actions-row {
|
|
670
688
|
display: flex;
|
|
671
689
|
align-items: flex-start;
|
|
@@ -1102,4 +1120,4 @@ import{a as rt,n as y,r as V,i as ot,x as p,k as B,l as lt,t as ct}from"../../ve
|
|
|
1102
1120
|
width: calc(100% / var(--scb-viz-print-scale, 1));
|
|
1103
1121
|
}
|
|
1104
1122
|
}
|
|
1105
|
-
`;
|
|
1123
|
+
`;b([y({type:String,reflect:!0})],u.prototype,"variant",2);b([y({type:String,reflect:!0,attribute:"selected-chip"})],u.prototype,"selectedChip",2);b([y({type:String,reflect:!0})],u.prototype,"title",2);b([y({type:String,reflect:!0})],u.prototype,"subtitle",2);b([y({type:String,reflect:!0})],u.prototype,"description",2);b([y({type:String,reflect:!0})],u.prototype,"comment",2);b([y({type:String,reflect:!0})],u.prototype,"source",2);b([y({type:String,reflect:!0})],u.prototype,"footnote",2);b([y({type:String,reflect:!0,attribute:"lang"})],u.prototype,"lang",2);b([y({type:String,reflect:!0,attribute:"image-href"})],u.prototype,"imageHref",2);b([y({type:Boolean,reflect:!0,attribute:"official-statistics"})],u.prototype,"officialStatistics",2);b([y({type:Boolean,reflect:!0,attribute:"disable-toggle"})],u.prototype,"disableToggle",2);b([y({type:String,attribute:"content-max-width"})],u.prototype,"contentMaxWidth",2);b([y({type:String,attribute:"container-max-width"})],u.prototype,"containerMaxWidth",2);b([y({type:String,attribute:"content-height"})],u.prototype,"contentHeight",2);b([y({type:String,reflect:!0,attribute:"toggle-height-mode"})],u.prototype,"toggleHeightMode",2);b([y({attribute:!1})],u.prototype,"tableData",2);b([P()],u.prototype,"_slottedTableData",2);b([P()],u.prototype,"_actionsMenuOpen",2);b([P()],u.prototype,"_seriesDifferentiationEnabled",2);b([y({type:String,reflect:!0})],u.prototype,"spacing",2);b([y({type:String,attribute:"spacing-top",reflect:!0})],u.prototype,"spacingTop",2);b([y({type:String,attribute:"spacing-bottom",reflect:!0})],u.prototype,"spacingBottom",2);b([y({type:String,attribute:"spacing-left",reflect:!0})],u.prototype,"spacingLeft",2);b([y({type:String,attribute:"spacing-right",reflect:!0})],u.prototype,"spacingRight",2);u=b([gt("scb-viz")],u);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.293",
|
|
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": "9E48E4698E0DC84488F1C65168244A0CED6C51CC5C0D9B42E204F75A54BE5ABB"
|
|
390
390
|
}
|
package/scb-viz/scb-viz.d.ts
CHANGED
|
@@ -104,7 +104,9 @@ export declare class ScbViz extends LitElement {
|
|
|
104
104
|
private _canExportCsv;
|
|
105
105
|
private _getExportBaseFileName;
|
|
106
106
|
private _buildExportFileName;
|
|
107
|
+
private _renderActionsMenu;
|
|
107
108
|
private _renderActions;
|
|
109
|
+
private _renderHeader;
|
|
108
110
|
private _renderTable;
|
|
109
111
|
private _hasMoreAboutStats;
|
|
110
112
|
private _renderMoreAboutStatsContent;
|