@bino-bi/bn-template-engine 1.0.0-next.25 → 1.0.0-next.26
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/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-0b2e1661.entry.js → p-461fdffa.entry.js} +1 -1
- package/dist/bn-template-engine/p-829212c3.entry.js +1 -0
- package/dist/bn-template-engine/{p-2fbc2d50.entry.js → p-bfa87b07.entry.js} +1 -1
- package/dist/bn-template-engine/{p-36f1c5f9.entry.js → p-ceb80db3.entry.js} +1 -1
- package/dist/cjs/bn-asset_21.cjs.entry.js +49 -6
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +1 -1
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +1 -1
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +1 -1
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +3 -0
- package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +3 -0
- package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +3 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +3 -0
- package/dist/collection/components/bn-chart-time/bn-chart-time.css +3 -0
- package/dist/collection/components/bn-table/bn-table.css +3 -0
- package/dist/collection/components/bn-table/bn-table.js +46 -3
- package/dist/collection/utils/testing/hostFont.js +20 -0
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/ibcs-chart-structure2.js +1 -1
- package/dist/esm/bn-asset_21.entry.js +49 -6
- package/dist/esm/bn-chart-bubble.entry.js +1 -1
- package/dist/esm/bn-chart-bullet.entry.js +1 -1
- package/dist/esm/bn-chart-scatter.entry.js +1 -1
- package/dist/types/components/bn-table/bn-table.d.ts +19 -0
- package/dist/types/components.d.ts +2 -2
- package/dist/types/utils/testing/hostFont.d.ts +16 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-e30c7251.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,d as i,f as e,h as s,H as r,g as a}from"./p-C5UYpZUU.js";import{o as n}from"./p-BcLsoDrW.js";import{w as o,o as l,c as h}from"./p-DjPXefnq.js";import{a as u}from"./p-D5e8I9Qe.js";import{w as c,a as d,g as p,p as v}from"./p-EtT29btN.js";import{i as m,a as f,w as g,b as y,c as b}from"./p-CsJ84YRk.js";import{w as x,a as _}from"./p-DtLI_CzV.js";import{w}from"./p-BcaI745G.js";import{r as $,s as R}from"./p-BbmobTg0.js";import{t as S,a as E,b as L,c as j,d as C,e as A,p as z}from"./p-CG_Bcm6V.js";import"./index.esm.js";import"./p-B5Jd_eCX.js";const O={rowGroup:0,category:1,subCategory:2},N=["ac","pp","fc","pl"],W=class{validateX(t){this.validateMeasureSpec("x",t,!0,(t=>S(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>S(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>E(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>L(t)))}validateCompareWith(t){const i="ERR_compareWith";m(t)||N.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' — expected ${N.join("/")}; ignored.`})}validateLevel(t){const i="ERR_level",e=["auto","category","subcategory"];m(t)||e.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' — expected ${e.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="ERR_seriesLevel",e=["auto","rowgroup","category","none"];m(t)||e.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' — expected ${e.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>j(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>C(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>A(t)))}validateAspect(t){const i="ERR_aspect";m(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' — expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="ERR_limit";f(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' — expected a non-negative integer; using 0.`})}validateScale(t){const i="ERR_scale";if(m(t))return void this.errors.remove(i);const{mode:e,factor:s}=v(t);"factor"===e&&(void 0===s||s<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' — expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),g(this),x(this),c(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=_(this),w(this),this.componentStyle=y(this),this.ruleSetConfig=o(this),this.t=d(this).t}componentWillLoad(){this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){const{mode:t}=v(this.scale);if("auto"!==t&&"empty"!==t){this._autoScaleGuard=!1;const t=p(this.element),i="WARN_overflow";return void(t.width>0&&this.element.scrollWidth>t.width+1?this.errors.addOrReplace({id:i,type:"warning",message:"Chart exceeds available space and will be cut off. Check the scale value."}):this.errors.remove(i))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{width:s}=p(e);if(s<=0)return;this._lastObservedWidth=s;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),a=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(a)||a<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,n*(s-1)/a);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",r*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=o})))}componentDidLoad(){this.layoutObserver=l(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=p(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=p(this.element);this._lastObservedWidth=t,e(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===i||this.pixelPerUnitGroupMap.has(i)?null:this.t(".bubble-scale-group-unknown",{group:i}))}validateMeasureSpec(t,i,e,s){var r;const a=`ERR_xy_json_${t}`,n=`ERR_xy_measure_${t}`,o=`WARN_xy_fields_${t}`,{data:l,parseError:h}=z(i,"measure");if(h)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(o);if(this.setBlockingError(a,null),null===l)return this.setBlockingError(n,e?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(o);const u=null!==(r=l.measure)&&void 0!==r?r:"";b(u)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:u})),this.reportSpecIssues(o,t,s(l))}validateObjectSpec(t,i,e){const s=`ERR_xy_json_${t}`,r=`WARN_xy_fields_${t}`,{data:a,parseError:n}=z(i,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(s,null),null!==a?this.reportSpecIssues(r,t,e(a)):this.errors.remove(r)}reportSpecIssues(t,i,e){const s=[];null!==e&&e.invalidFields.length>0&&s.push(`invalid: ${e.invalidFields.join(", ")}`),null!==e&&e.unknownKeys.length>0&&s.push(`unknown: ${e.unknownKeys.join(", ")}`),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:e,parseError:s}=z(i,"measure");if(s||null===e)return null;const{config:r}=S(e);return null!==r&&b(r.measure)?(void 0!==r.min&&void 0!==r.max&&r.min>=r.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),r.min=void 0,r.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),r):null}prepareSize(){const{data:t,parseError:i}=z(this.size,"measure");if(i||null===t)return null;const{config:e}=E(t);return null!==e&&b(e.measure)?e:null}prepareShare(){const{data:t,parseError:i}=z(this.share,"measure");if(i||null===t)return null;const{config:e}=L(t);return null!==e&&b(e.measure)?e:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return N.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:e}=z(this.labels,null);return e||null===i?{points:t.points,values:t.values,max:t.max}:C(i,t).config}prepareLegend(){const{data:t,parseError:i}=z(this.legend,null);return i||null===t?{show:!0,position:"right"}:A(t).config}prepareFacet(){const{data:t,parseError:i}=z(this.facet,null);return i||null===t?null:j(t).config}preparePointLevel(){var t,i;const e=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===e)return"category";if("subcategory"===e)return"subCategory";const s=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var i;const e=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===e?null:"rowgroup"===e?"rowGroup":"category"===e||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const e=new Set;let s=!1;for(const i of t){if(void 0===i)continue;const t=$(i);null!==t&&("scenario"===t.kind?e.add(R(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",e.size>1?this.t(".xy-family-mixed",{families:[...e].join(", ")}):null);const r=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==r&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==r&&1===e.size&&e.has(r)?`compare-with: '${r}' is already the primary scenario family.`:null);const a=this.preparePointLevel(),n=this.prepareSeriesLevel(a),o=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let l=null;if(null!==n&&O[n]>=O[a]&&(l=`series '${n}' vs point '${a}'`),null!==o){const t=null!=n?n:a;O[o]>=O[t]&&(l=`facet '${o}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==l?this.t(".xy-level-order",{detail:l}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const e=Number(i[1]),s=Number(i[2]);return e<=0||s<=0?null:e/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===i||!this.pixelPerUnitGroupMap.has(i))return 0;const e=this.pixelPerUnitGroupMap.get(i);if(!(e>0))return 0;const s=this.getEffectiveFontPx();return s*s/e}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(u.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bubble"].axisStyles,seriesColors:i["bn-chart-bubble"].seriesColors,padding:i["bn-chart-bubble"].padding}}))}async getLayoutState(t){var i;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",s=n(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a;return h(this.element,"ibcs-chart-bubble",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:a},s,e)}getEffectiveScaleFactor(){const{mode:t,factor:i}=v(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,r,a;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=i.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=i.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const e of[1,2,3,4])t[`${i}${e}`]={type:"number",isOptional:!0,description:""};const i={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[e,s]of Object.entries(i)){if(null===s)continue;const i=$(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}const e=this.prepareCompareFamily();if(null!==e)for(const[s,r]of Object.entries(i)){if(null===r||"share"===s)continue;const i=$(r.measure);if(null!==i&&"scenario"===i.kind){const r=e+i.slot.replace(/^[a-z]+/,"");""===t[r].description&&(t[r].description=`${s}: compareWith`)}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),i=this.prepareAxis("y",this.y),e=this.prepareSize(),r=this.prepareShare(),a=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==i?void 0:i.measure,null==e?void 0:e.measure,null==r?void 0:r.measure],a),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===i||null===e)return null;const n=this.preparePointLevel(),o=this.prepareI18n(),l=this.prepareStyle(),h=p(this.element).width;return s("ibcs-chart-bubble",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:i,size:e,share:r,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:a,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:l,i18n:o,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translate:this.translateForInner})}render(){return s(r,{key:"0dd049de98d978c2d8223eb8b68faef8568260b6",style:this.getFontStyles()},s("div",{key:"676705ee1711e0780a3a80b01e4f951800742bbd",class:"container"},this.chartTemplate()))}get element(){return a(this)}static get watchers(){return{x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};W.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column}";export{W as bn_chart_bubble}
|
|
1
|
+
import{r as t,d as i,f as e,h as s,H as r,g as a}from"./p-C5UYpZUU.js";import{o as n}from"./p-BcLsoDrW.js";import{w as o,o as l,c as h}from"./p-DjPXefnq.js";import{a as u}from"./p-D5e8I9Qe.js";import{w as c,a as d,g as p,p as v}from"./p-EtT29btN.js";import{i as m,a as f,w as g,b as y,c as b}from"./p-CsJ84YRk.js";import{w as x,a as _}from"./p-DtLI_CzV.js";import{w}from"./p-BcaI745G.js";import{r as $,s as R}from"./p-BbmobTg0.js";import{t as S,a as E,b as L,c as j,d as C,e as z,p as A}from"./p-CG_Bcm6V.js";import"./index.esm.js";import"./p-B5Jd_eCX.js";const N={rowGroup:0,category:1,subCategory:2},O=["ac","pp","fc","pl"],W=class{validateX(t){this.validateMeasureSpec("x",t,!0,(t=>S(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>S(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>E(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>L(t)))}validateCompareWith(t){const i="ERR_compareWith";m(t)||O.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' — expected ${O.join("/")}; ignored.`})}validateLevel(t){const i="ERR_level",e=["auto","category","subcategory"];m(t)||e.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' — expected ${e.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="ERR_seriesLevel",e=["auto","rowgroup","category","none"];m(t)||e.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' — expected ${e.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>j(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>C(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>z(t)))}validateAspect(t){const i="ERR_aspect";m(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' — expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="ERR_limit";f(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' — expected a non-negative integer; using 0.`})}validateScale(t){const i="ERR_scale";if(m(t))return void this.errors.remove(i);const{mode:e,factor:s}=v(t);"factor"===e&&(void 0===s||s<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' — expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),g(this),x(this),c(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=_(this),w(this),this.componentStyle=y(this),this.ruleSetConfig=o(this),this.t=d(this).t}componentWillLoad(){this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){const{mode:t}=v(this.scale);if("auto"!==t&&"empty"!==t){this._autoScaleGuard=!1;const t=p(this.element),i="WARN_overflow";return void(t.width>0&&this.element.scrollWidth>t.width+1?this.errors.addOrReplace({id:i,type:"warning",message:"Chart exceeds available space and will be cut off. Check the scale value."}):this.errors.remove(i))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{width:s}=p(e);if(s<=0)return;this._lastObservedWidth=s;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),a=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(a)||a<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,n*(s-1)/a);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",r*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=o})))}componentDidLoad(){this.layoutObserver=l(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=p(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=p(this.element);this._lastObservedWidth=t,e(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===i||this.pixelPerUnitGroupMap.has(i)?null:this.t(".bubble-scale-group-unknown",{group:i}))}validateMeasureSpec(t,i,e,s){var r;const a=`ERR_xy_json_${t}`,n=`ERR_xy_measure_${t}`,o=`WARN_xy_fields_${t}`,{data:l,parseError:h}=A(i,"measure");if(h)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(o);if(this.setBlockingError(a,null),null===l)return this.setBlockingError(n,e?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(o);const u=null!==(r=l.measure)&&void 0!==r?r:"";b(u)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:u})),this.reportSpecIssues(o,t,s(l))}validateObjectSpec(t,i,e){const s=`ERR_xy_json_${t}`,r=`WARN_xy_fields_${t}`,{data:a,parseError:n}=A(i,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(s,null),null!==a?this.reportSpecIssues(r,t,e(a)):this.errors.remove(r)}reportSpecIssues(t,i,e){const s=[];null!==e&&e.invalidFields.length>0&&s.push(`invalid: ${e.invalidFields.join(", ")}`),null!==e&&e.unknownKeys.length>0&&s.push(`unknown: ${e.unknownKeys.join(", ")}`),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:e,parseError:s}=A(i,"measure");if(s||null===e)return null;const{config:r}=S(e);return null!==r&&b(r.measure)?(void 0!==r.min&&void 0!==r.max&&r.min>=r.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),r.min=void 0,r.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),r):null}prepareSize(){const{data:t,parseError:i}=A(this.size,"measure");if(i||null===t)return null;const{config:e}=E(t);return null!==e&&b(e.measure)?e:null}prepareShare(){const{data:t,parseError:i}=A(this.share,"measure");if(i||null===t)return null;const{config:e}=L(t);return null!==e&&b(e.measure)?e:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return O.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:e}=A(this.labels,null);return e||null===i?{points:t.points,values:t.values,max:t.max}:C(i,t).config}prepareLegend(){const{data:t,parseError:i}=A(this.legend,null);return i||null===t?{show:!0,position:"right"}:z(t).config}prepareFacet(){const{data:t,parseError:i}=A(this.facet,null);return i||null===t?null:j(t).config}preparePointLevel(){var t,i;const e=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===e)return"category";if("subcategory"===e)return"subCategory";const s=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var i;const e=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===e?null:"rowgroup"===e?"rowGroup":"category"===e||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const e=new Set;let s=!1;for(const i of t){if(void 0===i)continue;const t=$(i);null!==t&&("scenario"===t.kind?e.add(R(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",e.size>1?this.t(".xy-family-mixed",{families:[...e].join(", ")}):null);const r=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==r&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==r&&1===e.size&&e.has(r)?`compare-with: '${r}' is already the primary scenario family.`:null);const a=this.preparePointLevel(),n=this.prepareSeriesLevel(a),o=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let l=null;if(null!==n&&N[n]>=N[a]&&(l=`series '${n}' vs point '${a}'`),null!==o){const t=null!=n?n:a;N[o]>=N[t]&&(l=`facet '${o}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==l?this.t(".xy-level-order",{detail:l}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const e=Number(i[1]),s=Number(i[2]);return e<=0||s<=0?null:e/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===i||!this.pixelPerUnitGroupMap.has(i))return 0;const e=this.pixelPerUnitGroupMap.get(i);if(!(e>0))return 0;const s=this.getEffectiveFontPx();return s*s/e}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(u.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bubble"].axisStyles,seriesColors:i["bn-chart-bubble"].seriesColors,padding:i["bn-chart-bubble"].padding}}))}async getLayoutState(t){var i;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",s=n(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a;return h(this.element,"ibcs-chart-bubble",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:a},s,e)}getEffectiveScaleFactor(){const{mode:t,factor:i}=v(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,r,a;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=i.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=i.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const e of[1,2,3,4])t[`${i}${e}`]={type:"number",isOptional:!0,description:""};const i={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[e,s]of Object.entries(i)){if(null===s)continue;const i=$(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}const e=this.prepareCompareFamily();if(null!==e)for(const[s,r]of Object.entries(i)){if(null===r||"share"===s)continue;const i=$(r.measure);if(null!==i&&"scenario"===i.kind){const r=e+i.slot.replace(/^[a-z]+/,"");""===t[r].description&&(t[r].description=`${s}: compareWith`)}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),i=this.prepareAxis("y",this.y),e=this.prepareSize(),r=this.prepareShare(),a=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==i?void 0:i.measure,null==e?void 0:e.measure,null==r?void 0:r.measure],a),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===i||null===e)return null;const n=this.preparePointLevel(),o=this.prepareI18n(),l=this.prepareStyle(),h=p(this.element).width;return s("ibcs-chart-bubble",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:i,size:e,share:r,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:a,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:l,i18n:o,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translate:this.translateForInner})}render(){return s(r,{key:"0dd049de98d978c2d8223eb8b68faef8568260b6",style:this.getFontStyles()},s("div",{key:"676705ee1711e0780a3a80b01e4f951800742bbd",class:"container"},this.chartTemplate()))}get element(){return a(this)}static get watchers(){return{x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};W.style=':host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}';export{W as bn_chart_bubble}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,d as i,f as e,h as s,H as r,g as a}from"./p-C5UYpZUU.js";import{o as n}from"./p-BcLsoDrW.js";import{w as l,o,c as u}from"./p-DjPXefnq.js";import{a as h}from"./p-D5e8I9Qe.js";import{C as d,r as c,A as p}from"./p-BbmobTg0.js";import{O as v,a as g,b as m}from"./p-B5Jd_eCX.js";import{w as f,a as b,g as _,p as y}from"./p-EtT29btN.js";import{v as w,i as R,d as O,a as A,w as E,b as $}from"./p-CsJ84YRk.js";import{w as j,a as T}from"./p-DtLI_CzV.js";import{p as S}from"./p-CG_Bcm6V.js";import"./index.esm.js";const N=["measure","label","unit"];function x(t){const i=[],e=z(t,"measure",i);if(void 0===e||""===e.trim())return i.push("measure"),{config:null,unknownKeys:D(t,N),invalidFields:i};const s={measure:e.trim()};return s.label=z(t,"label",i),s.unit=z(t,"unit",i),{config:s,unknownKeys:D(t,N),invalidFields:i}}const U=["show","decimals"];function L(t,i){const e=[],s={show:i.show,decimals:i.decimals};return d.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:e.push("show")),d.isExisting(t.decimals)&&(d.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):e.push("decimals")),{config:s,unknownKeys:D(t,U),invalidFields:e}}function k(t){var i;const e=null!==(i=null==t?void 0:t.trim())&&void 0!==i?i:"";if(""===e||"null"===e)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(e)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>d.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,i)=>t-i));return n.some(((t,i)=>t!==a[i]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(`${a.length} entries, first 2 kept`),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function D(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function z(t,i,e){if(d.isExisting(t[i]))return d.isString(t[i])?t[i]:void e.push(i)}const C=["pl1","pp1","fc1"],W=class{validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const i="ERR_bullet_json_ranges",e="WARN_bullet_ranges",s=k(t);if(s.parseError)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(e);this.setBlockingError(i,null),s.issues.length>0?this.errors.addOrReplace({id:e,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(e)}validateNormalize(t){this.validateEnum("normalize","ERR_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","ERR_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","ERR_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const i="ERR_order",e=w(t).filter((t=>""!==t));0===e.length?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order: invalid value(s) '${e.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const i="ERR_orderDirection";R(t)||O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order-direction: invalid value '${t}' — expected asc/desc; using asc.`})}validateLimit(t){const i="ERR_limit";A(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' — expected a non-negative integer; using 0.`})}validateLabels(t){const i="ERR_bullet_json_labels",e="WARN_bullet_fields_labels",{data:s,parseError:r}=S(t,null);if(r)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(e);this.setBlockingError(i,null),null!==s?this.reportSpecIssues(e,"labels",L(s,this.labelDefaults())):this.errors.remove(e)}validateScale(t){const i="ERR_scale";if(R(t))return void this.errors.remove(i);const{mode:e,factor:s}=y(t);"factor"===e&&(void 0===s||s<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' — expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalize="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),j(this),f(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=T(this),this.componentStyle=$(this),this.ruleSetConfig=l(this),this.t=b(this).t}componentWillLoad(){this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalize),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=_(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${l.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=o(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=_(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=_(this.element);this._lastScaledParentHeight=t,e(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,i){var e;const s=`ERR_bullet_json_${t}`,r=`ERR_bullet_measure_${t}`,a=`WARN_bullet_fields_${t}`,{data:n,parseError:l}=S(i,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(e=n.measure)&&void 0!==e?e:"").trim(),u=c(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,x(n))}validateEnum(t,i,e,s,r){R(e)||s.includes(e.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`${t}: invalid value '${e}' — expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,i,e){const s=[];null!==e&&e.invalidFields.length>0&&s.push(`invalid: ${e.invalidFields.join(", ")}`),null!==e&&e.unknownKeys.length>0&&s.push(`unknown: ${e.unknownKeys.join(", ")}`),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,i,e,s,r;const{data:a,parseError:n}=S(this.actual,"measure");if(n)return null;const l=null!==a?x(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(e=a.find((t=>t.startsWith("ac"))))&&void 0!==e?e:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:`actual: not set, auto-detected: ${n}`}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=c(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,i,e;const{data:s,parseError:r}=S(this.target,"measure");if(r)return null;const a=null!==s?x(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const e=null!==a,s=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],r=C.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),e||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:`target: not set, auto-detected: ${r}`}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(e=c(a.measure))||void 0===e?void 0:e.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalize)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,i;const e=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===e)return p.ROWGROUP;if("category"===e)return p.CATEGORY;if("subcategory"===e)return p.SUBCATEGORY;const s=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,i,e,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;R(this.order)||r?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=v[null===(e=this.orderDirection)||void 0===e?void 0:e.toUpperCase()])&&void 0!==s?s:v.ASC;if(R(a))return new g([m.CATEGORYINDEX],n);const l=a.split(",").map((t=>m[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new g(l.length>0?l:[m.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:e}=S(this.labels,null);return e||null===i?{show:t.show,decimals:t.decimals}:L(i,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(h.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bullet"].axisStyles,barStyles:i["bn-chart-bullet"].barStyles,varianceStyles:i["bn-chart-bullet"].varianceStyles,rangeColors:i["bn-chart-bullet"].rangeColors,padding:i["bn-chart-bullet"].padding}}))}async getLayoutState(t){var i;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",s=n(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a;return u(this.element,"ibcs-chart-bullet",this.chartTitle||void 0,{fontSizePx:l,appliedScaleFactor:a},s,e)}getEffectiveScaleFactor(){const{mode:t,factor:i}=y(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,r,a;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=i.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=i.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const e of[1,2,3,4])t[`${i}${e}`]={type:"number",isOptional:!0,description:""};const i={actual:this.prepareActual(),target:this.prepareTarget()};for(const[e,s]of Object.entries(i))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${e}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),i=this.prepareTarget(),e=k(this.ranges).ranges,r=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==i&&t.measure===i.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),e.length>0&&"target"===r?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:s("ibcs-chart-bullet",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:i,ranges:e,normalize:r,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:_(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translate:this.translateForInner})}render(){return s(r,{key:"31096e122fe62354e4a9ad0a15af5329a72265ba",style:this.getFontStyles()},s("div",{key:"8288f32a3ac40790136b751a5630787cfd958a9d",class:"container"},this.chartTemplate()))}get element(){return a(this)}static get watchers(){return{actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalize:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}};W.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column}";export{W as bn_chart_bullet}
|
|
1
|
+
import{r as t,d as i,f as e,h as s,H as r,g as a}from"./p-C5UYpZUU.js";import{o as n}from"./p-BcLsoDrW.js";import{w as l,o,c as u}from"./p-DjPXefnq.js";import{a as h}from"./p-D5e8I9Qe.js";import{C as d,r as c,A as p}from"./p-BbmobTg0.js";import{O as v,a as g,b as m}from"./p-B5Jd_eCX.js";import{w as f,a as b,g as _,p as y}from"./p-EtT29btN.js";import{v as w,i as R,d as O,a as A,w as E,b as $}from"./p-CsJ84YRk.js";import{w as j,a as S}from"./p-DtLI_CzV.js";import{p as T}from"./p-CG_Bcm6V.js";import"./index.esm.js";const N=["measure","label","unit"];function x(t){const i=[],e=D(t,"measure",i);if(void 0===e||""===e.trim())return i.push("measure"),{config:null,unknownKeys:z(t,N),invalidFields:i};const s={measure:e.trim()};return s.label=D(t,"label",i),s.unit=D(t,"unit",i),{config:s,unknownKeys:z(t,N),invalidFields:i}}const U=["show","decimals"];function L(t,i){const e=[],s={show:i.show,decimals:i.decimals};return d.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:e.push("show")),d.isExisting(t.decimals)&&(d.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):e.push("decimals")),{config:s,unknownKeys:z(t,U),invalidFields:e}}function k(t){var i;const e=null!==(i=null==t?void 0:t.trim())&&void 0!==i?i:"";if(""===e||"null"===e)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(e)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>d.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,i)=>t-i));return n.some(((t,i)=>t!==a[i]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(`${a.length} entries, first 2 kept`),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function z(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function D(t,i,e){if(d.isExisting(t[i]))return d.isString(t[i])?t[i]:void e.push(i)}const C=["pl1","pp1","fc1"],W=class{validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const i="ERR_bullet_json_ranges",e="WARN_bullet_ranges",s=k(t);if(s.parseError)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(e);this.setBlockingError(i,null),s.issues.length>0?this.errors.addOrReplace({id:e,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(e)}validateNormalize(t){this.validateEnum("normalize","ERR_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","ERR_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","ERR_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const i="ERR_order",e=w(t).filter((t=>""!==t));0===e.length?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order: invalid value(s) '${e.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const i="ERR_orderDirection";R(t)||O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order-direction: invalid value '${t}' — expected asc/desc; using asc.`})}validateLimit(t){const i="ERR_limit";A(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' — expected a non-negative integer; using 0.`})}validateLabels(t){const i="ERR_bullet_json_labels",e="WARN_bullet_fields_labels",{data:s,parseError:r}=T(t,null);if(r)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(e);this.setBlockingError(i,null),null!==s?this.reportSpecIssues(e,"labels",L(s,this.labelDefaults())):this.errors.remove(e)}validateScale(t){const i="ERR_scale";if(R(t))return void this.errors.remove(i);const{mode:e,factor:s}=y(t);"factor"===e&&(void 0===s||s<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' — expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalize="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),j(this),f(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=S(this),this.componentStyle=$(this),this.ruleSetConfig=l(this),this.t=b(this).t}componentWillLoad(){this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalize),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=_(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${l.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=o(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=_(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=_(this.element);this._lastScaledParentHeight=t,e(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,i){var e;const s=`ERR_bullet_json_${t}`,r=`ERR_bullet_measure_${t}`,a=`WARN_bullet_fields_${t}`,{data:n,parseError:l}=T(i,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(e=n.measure)&&void 0!==e?e:"").trim(),u=c(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,x(n))}validateEnum(t,i,e,s,r){R(e)||s.includes(e.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`${t}: invalid value '${e}' — expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,i,e){const s=[];null!==e&&e.invalidFields.length>0&&s.push(`invalid: ${e.invalidFields.join(", ")}`),null!==e&&e.unknownKeys.length>0&&s.push(`unknown: ${e.unknownKeys.join(", ")}`),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,i,e,s,r;const{data:a,parseError:n}=T(this.actual,"measure");if(n)return null;const l=null!==a?x(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(e=a.find((t=>t.startsWith("ac"))))&&void 0!==e?e:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:`actual: not set, auto-detected: ${n}`}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=c(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,i,e;const{data:s,parseError:r}=T(this.target,"measure");if(r)return null;const a=null!==s?x(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const e=null!==a,s=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],r=C.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),e||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:`target: not set, auto-detected: ${r}`}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(e=c(a.measure))||void 0===e?void 0:e.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalize)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,i;const e=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===e)return p.ROWGROUP;if("category"===e)return p.CATEGORY;if("subcategory"===e)return p.SUBCATEGORY;const s=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,i,e,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;R(this.order)||r?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=v[null===(e=this.orderDirection)||void 0===e?void 0:e.toUpperCase()])&&void 0!==s?s:v.ASC;if(R(a))return new g([m.CATEGORYINDEX],n);const l=a.split(",").map((t=>m[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new g(l.length>0?l:[m.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:e}=T(this.labels,null);return e||null===i?{show:t.show,decimals:t.decimals}:L(i,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(h.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bullet"].axisStyles,barStyles:i["bn-chart-bullet"].barStyles,varianceStyles:i["bn-chart-bullet"].varianceStyles,rangeColors:i["bn-chart-bullet"].rangeColors,padding:i["bn-chart-bullet"].padding}}))}async getLayoutState(t){var i;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",s=n(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a;return u(this.element,"ibcs-chart-bullet",this.chartTitle||void 0,{fontSizePx:l,appliedScaleFactor:a},s,e)}getEffectiveScaleFactor(){const{mode:t,factor:i}=y(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,r,a;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=i.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=i.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const e of[1,2,3,4])t[`${i}${e}`]={type:"number",isOptional:!0,description:""};const i={actual:this.prepareActual(),target:this.prepareTarget()};for(const[e,s]of Object.entries(i))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${e}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),i=this.prepareTarget(),e=k(this.ranges).ranges,r=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==i&&t.measure===i.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),e.length>0&&"target"===r?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:s("ibcs-chart-bullet",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:i,ranges:e,normalize:r,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:_(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translate:this.translateForInner})}render(){return s(r,{key:"31096e122fe62354e4a9ad0a15af5329a72265ba",style:this.getFontStyles()},s("div",{key:"8288f32a3ac40790136b751a5630787cfd958a9d",class:"container"},this.chartTemplate()))}get element(){return a(this)}static get watchers(){return{actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalize:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}};W.style=':host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}';export{W as bn_chart_bullet}
|
|
@@ -136,7 +136,7 @@ function buildGenericState(el, origins) {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
139
|
+
const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
140
140
|
|
|
141
141
|
const Chart$1 = class Chart {
|
|
142
142
|
validateScenario(newValue) {
|
|
@@ -1167,7 +1167,7 @@ const Chart$1 = class Chart {
|
|
|
1167
1167
|
};
|
|
1168
1168
|
Chart$1.style = bnChartStructureCss$1();
|
|
1169
1169
|
|
|
1170
|
-
const bnChartTimeCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}`;
|
|
1170
|
+
const bnChartTimeCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}`;
|
|
1171
1171
|
|
|
1172
1172
|
var AggregationLevel;
|
|
1173
1173
|
(function (AggregationLevel) {
|
|
@@ -4757,7 +4757,7 @@ function toDateTime(value) {
|
|
|
4757
4757
|
return undefined;
|
|
4758
4758
|
}
|
|
4759
4759
|
|
|
4760
|
-
const bnTableCss = () => `:host{display:inline-block;position:relative;overflow:hidden}`;
|
|
4760
|
+
const bnTableCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}`;
|
|
4761
4761
|
|
|
4762
4762
|
const Table$1 = class Table {
|
|
4763
4763
|
validateScaling(newValue) {
|
|
@@ -5509,17 +5509,21 @@ const Table$1 = class Table {
|
|
|
5509
5509
|
// Only auto-scale for 'auto' and 'empty' (blank) modes
|
|
5510
5510
|
if (mode !== "auto" && mode !== "empty") {
|
|
5511
5511
|
this._autoScaleGuard = false;
|
|
5512
|
+
this.checkOverflow();
|
|
5512
5513
|
return;
|
|
5513
5514
|
}
|
|
5514
5515
|
// Skip re-measurement after the state-triggered re-render
|
|
5515
5516
|
if (this._autoScaleGuard) {
|
|
5516
5517
|
this._autoScaleGuard = false;
|
|
5518
|
+
this.checkOverflow();
|
|
5517
5519
|
return;
|
|
5518
5520
|
}
|
|
5519
5521
|
const host = this.element;
|
|
5520
5522
|
const { width: parentWidth } = scaling.getParentDimensions(host);
|
|
5521
|
-
if (parentWidth <= 0)
|
|
5523
|
+
if (parentWidth <= 0) {
|
|
5524
|
+
this.checkOverflow();
|
|
5522
5525
|
return;
|
|
5526
|
+
}
|
|
5523
5527
|
this._lastScaledParentWidth = parentWidth;
|
|
5524
5528
|
const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
|
|
5525
5529
|
const currentWidth = host.scrollWidth;
|
|
@@ -5529,6 +5533,7 @@ const Table$1 = class Table {
|
|
|
5529
5533
|
// rounding and causes oscillation (reset → overflow → scale → reset).
|
|
5530
5534
|
if (currentWidth <= parentWidth + 1) {
|
|
5531
5535
|
this.errors.remove("AUTO_scale");
|
|
5536
|
+
this.checkOverflow();
|
|
5532
5537
|
return;
|
|
5533
5538
|
}
|
|
5534
5539
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -5537,6 +5542,7 @@ const Table$1 = class Table {
|
|
|
5537
5542
|
const computedFactor = Math.max(0.3, (currentFactor * (parentWidth - 1)) / currentWidth);
|
|
5538
5543
|
// Only apply if the change is significant (> 0.1% of current factor).
|
|
5539
5544
|
if (Math.abs(computedFactor - currentFactor) < 0.001) {
|
|
5545
|
+
this.checkOverflow();
|
|
5540
5546
|
return;
|
|
5541
5547
|
}
|
|
5542
5548
|
// Apply immediately via CSS var for smooth visual (before state re-render)
|
|
@@ -5558,6 +5564,43 @@ const Table$1 = class Table {
|
|
|
5558
5564
|
index.writeTask(() => {
|
|
5559
5565
|
this.appliedScaleFactor = computedFactor;
|
|
5560
5566
|
});
|
|
5567
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
5568
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
5569
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
5570
|
+
this.checkOverflow();
|
|
5571
|
+
}
|
|
5572
|
+
/**
|
|
5573
|
+
* Reports a WARN_overflow item when the rendered table exceeds its
|
|
5574
|
+
* container. The table only auto-fits its WIDTH, so nothing prevents it
|
|
5575
|
+
* from growing taller than the layout cell, which clips the bottom rows
|
|
5576
|
+
* (grand total included) without a trace — this item is the only signal.
|
|
5577
|
+
* Overflow under a fixed `scale` is an error: the author pinned the size.
|
|
5578
|
+
* In auto mode it is a warning.
|
|
5579
|
+
*/
|
|
5580
|
+
checkOverflow() {
|
|
5581
|
+
const errId = "WARN_overflow";
|
|
5582
|
+
const parent = scaling.getParentDimensions(this.element);
|
|
5583
|
+
const contentWidth = this.element.scrollWidth;
|
|
5584
|
+
const contentHeight = this.element.scrollHeight;
|
|
5585
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
5586
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
5587
|
+
if (!widthOver && !heightOver) {
|
|
5588
|
+
this.errors.remove(errId);
|
|
5589
|
+
return;
|
|
5590
|
+
}
|
|
5591
|
+
const { mode } = scaling.parseScaling(this.scale);
|
|
5592
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
5593
|
+
const dims = [];
|
|
5594
|
+
if (widthOver)
|
|
5595
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
5596
|
+
if (heightOver)
|
|
5597
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
5598
|
+
this.errors.addOrReplace({
|
|
5599
|
+
id: errId,
|
|
5600
|
+
type: fixedScale ? "error" : "warning",
|
|
5601
|
+
message: `Table exceeds available ${dims.join(" and ")}. ` +
|
|
5602
|
+
"Give the component more space, reduce rows (e.g. limit), or set a smaller scale.",
|
|
5603
|
+
});
|
|
5561
5604
|
}
|
|
5562
5605
|
prepareDataFormat() {
|
|
5563
5606
|
var _a;
|
|
@@ -6023,7 +6066,7 @@ const Table$1 = class Table {
|
|
|
6023
6066
|
render() {
|
|
6024
6067
|
const fontStyles = this.getFontStyles();
|
|
6025
6068
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
6026
|
-
return (index.h(index.Host, { key: '
|
|
6069
|
+
return (index.h(index.Host, { key: '10a4b95a0115864ad324efcdffcd10b05b583820', style: fontStyles }, index.h("div", { key: '28456489f9d8200ddc89cdd35ca217df347bc2a5' }, index.h("ibcs-table", { key: 'c2a19bd85883171a3e1baf3110eeefc1072b4a58', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
|
|
6027
6070
|
}
|
|
6028
6071
|
get element() { return index.getElement(this); }
|
|
6029
6072
|
static get watchers() { return {
|
|
@@ -9615,7 +9658,7 @@ class DataFormatDigitsAdapter {
|
|
|
9615
9658
|
}
|
|
9616
9659
|
}
|
|
9617
9660
|
|
|
9618
|
-
const bnChartStructureCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
9661
|
+
const bnChartStructureCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
9619
9662
|
|
|
9620
9663
|
const IbcsChartStructure = class {
|
|
9621
9664
|
constructor(hostRef) {
|
|
@@ -13,7 +13,7 @@ var AxisConfig = require('./AxisConfig-DwiNUyYG.js');
|
|
|
13
13
|
require('./index.cjs.js');
|
|
14
14
|
require('./Order-2wRydarc.js');
|
|
15
15
|
|
|
16
|
-
const bnChartBubbleCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column}`;
|
|
16
|
+
const bnChartBubbleCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}`;
|
|
17
17
|
|
|
18
18
|
const HIERARCHY_DEPTH = { rowGroup: 0, category: 1, subCategory: 2 };
|
|
19
19
|
const COMPARE_FAMILIES = ["ac", "pp", "fc", "pl"];
|
|
@@ -101,7 +101,7 @@ function readString(data, key, invalid) {
|
|
|
101
101
|
return undefined;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const bnChartBulletCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column}`;
|
|
104
|
+
const bnChartBulletCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}`;
|
|
105
105
|
|
|
106
106
|
/** Auto-detection preference for the target scenario. */
|
|
107
107
|
const TARGET_SLOT_PREFERENCE = ["pl1", "pp1", "fc1"];
|
|
@@ -12,7 +12,7 @@ var AxisConfig = require('./AxisConfig-DwiNUyYG.js');
|
|
|
12
12
|
require('./index.cjs.js');
|
|
13
13
|
require('./Order-2wRydarc.js');
|
|
14
14
|
|
|
15
|
-
const bnChartScatterCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column}`;
|
|
15
|
+
const bnChartScatterCss = () => `:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}`;
|
|
16
16
|
|
|
17
17
|
const HIERARCHY_DEPTH = { rowGroup: 0, category: 1, subCategory: 2 };
|
|
18
18
|
const ChartScatter = class {
|
|
@@ -777,17 +777,21 @@ export class Table {
|
|
|
777
777
|
// Only auto-scale for 'auto' and 'empty' (blank) modes
|
|
778
778
|
if (mode !== "auto" && mode !== "empty") {
|
|
779
779
|
this._autoScaleGuard = false;
|
|
780
|
+
this.checkOverflow();
|
|
780
781
|
return;
|
|
781
782
|
}
|
|
782
783
|
// Skip re-measurement after the state-triggered re-render
|
|
783
784
|
if (this._autoScaleGuard) {
|
|
784
785
|
this._autoScaleGuard = false;
|
|
786
|
+
this.checkOverflow();
|
|
785
787
|
return;
|
|
786
788
|
}
|
|
787
789
|
const host = this.element;
|
|
788
790
|
const { width: parentWidth } = getParentDimensions(host);
|
|
789
|
-
if (parentWidth <= 0)
|
|
791
|
+
if (parentWidth <= 0) {
|
|
792
|
+
this.checkOverflow();
|
|
790
793
|
return;
|
|
794
|
+
}
|
|
791
795
|
this._lastScaledParentWidth = parentWidth;
|
|
792
796
|
const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
|
|
793
797
|
const currentWidth = host.scrollWidth;
|
|
@@ -797,6 +801,7 @@ export class Table {
|
|
|
797
801
|
// rounding and causes oscillation (reset → overflow → scale → reset).
|
|
798
802
|
if (currentWidth <= parentWidth + 1) {
|
|
799
803
|
this.errors.remove("AUTO_scale");
|
|
804
|
+
this.checkOverflow();
|
|
800
805
|
return;
|
|
801
806
|
}
|
|
802
807
|
// Content overflows. Compute a new factor based on the ratio of
|
|
@@ -805,6 +810,7 @@ export class Table {
|
|
|
805
810
|
const computedFactor = Math.max(0.3, (currentFactor * (parentWidth - 1)) / currentWidth);
|
|
806
811
|
// Only apply if the change is significant (> 0.1% of current factor).
|
|
807
812
|
if (Math.abs(computedFactor - currentFactor) < 0.001) {
|
|
813
|
+
this.checkOverflow();
|
|
808
814
|
return;
|
|
809
815
|
}
|
|
810
816
|
// Apply immediately via CSS var for smooth visual (before state re-render)
|
|
@@ -826,6 +832,43 @@ export class Table {
|
|
|
826
832
|
writeTask(() => {
|
|
827
833
|
this.appliedScaleFactor = computedFactor;
|
|
828
834
|
});
|
|
835
|
+
// Check with the current (pre-factor) content so overflow is reported
|
|
836
|
+
// even if the scheduled re-render stalls; the follow-up render re-checks
|
|
837
|
+
// in the guard branch and clears any transiently reported overflow.
|
|
838
|
+
this.checkOverflow();
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Reports a WARN_overflow item when the rendered table exceeds its
|
|
842
|
+
* container. The table only auto-fits its WIDTH, so nothing prevents it
|
|
843
|
+
* from growing taller than the layout cell, which clips the bottom rows
|
|
844
|
+
* (grand total included) without a trace — this item is the only signal.
|
|
845
|
+
* Overflow under a fixed `scale` is an error: the author pinned the size.
|
|
846
|
+
* In auto mode it is a warning.
|
|
847
|
+
*/
|
|
848
|
+
checkOverflow() {
|
|
849
|
+
const errId = "WARN_overflow";
|
|
850
|
+
const parent = getParentDimensions(this.element);
|
|
851
|
+
const contentWidth = this.element.scrollWidth;
|
|
852
|
+
const contentHeight = this.element.scrollHeight;
|
|
853
|
+
const widthOver = parent.width > 0 && contentWidth > parent.width + 1;
|
|
854
|
+
const heightOver = parent.height > 0 && contentHeight > parent.height + 1;
|
|
855
|
+
if (!widthOver && !heightOver) {
|
|
856
|
+
this.errors.remove(errId);
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const { mode } = parseScaling(this.scale);
|
|
860
|
+
const fixedScale = mode !== "auto" && mode !== "empty";
|
|
861
|
+
const dims = [];
|
|
862
|
+
if (widthOver)
|
|
863
|
+
dims.push(`width (${Math.round(contentWidth)}px > ${Math.round(parent.width)}px)`);
|
|
864
|
+
if (heightOver)
|
|
865
|
+
dims.push(`height (${Math.round(contentHeight)}px > ${Math.round(parent.height)}px)`);
|
|
866
|
+
this.errors.addOrReplace({
|
|
867
|
+
id: errId,
|
|
868
|
+
type: fixedScale ? "error" : "warning",
|
|
869
|
+
message: `Table exceeds available ${dims.join(" and ")}. ` +
|
|
870
|
+
"Give the component more space, reduce rows (e.g. limit), or set a smaller scale.",
|
|
871
|
+
});
|
|
829
872
|
}
|
|
830
873
|
prepareDataFormat() {
|
|
831
874
|
var _a;
|
|
@@ -1291,7 +1334,7 @@ export class Table {
|
|
|
1291
1334
|
render() {
|
|
1292
1335
|
const fontStyles = this.getFontStyles();
|
|
1293
1336
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
1294
|
-
return (h(Host, { key: '
|
|
1337
|
+
return (h(Host, { key: '10a4b95a0115864ad324efcdffcd10b05b583820', style: fontStyles }, h("div", { key: '28456489f9d8200ddc89cdd35ca217df347bc2a5' }, h("ibcs-table", { key: 'c2a19bd85883171a3e1baf3110eeefc1072b4a58', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
|
|
1295
1338
|
}
|
|
1296
1339
|
static get is() { return "bn-table"; }
|
|
1297
1340
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1322,7 +1365,7 @@ export class Table {
|
|
|
1322
1365
|
"name": "example",
|
|
1323
1366
|
"text": "// Auto-scale to parent (silent)\n<bn-table scale=\"auto\" ...></bn-table>\n\n// Fixed 50 % reduction\n<bn-table scale=\"0.5\" ...></bn-table>\n\n// Double size\n<bn-table scale=\"2\" ...></bn-table>\n\n// No scaling \u2014 always render at base font size\n<bn-table scale=\"none\" ...></bn-table>"
|
|
1324
1367
|
}],
|
|
1325
|
-
"text": "Controls proportional scaling of the entire table relative to the\navailable parent width. All visual dimensions scale together: font size,\nem-based spacing/padding, SVG bar-chart widths, pin lengths, dot radii,\npattern fills, axis strokes, and label offsets.\n\nScaling is driven by a single factor applied to the base font size\n(`global.fontSizePx` from the component-style store, default 13.3333 px).\nBecause the table's SCSS uses `em` units for padding, borders, and\ncolumn widths, changing the font size cascades to all layout dimensions.\nSVG elements (bars, pins, patterns) receive the factor via the\n`scaleFactor` prop on `ibcs-table` and multiply every pixel constant\nby it, so they stay proportional to the surrounding text.\n\n| Value | Behavior |\n|---------------------|----------------------------------------------------------------------------------|\n| not set / `\"\"` | Auto-scale to fit parent width; emit `AUTO_scale` warning with the applied factor |\n| `\"none\"` | No scaling (render at base font size regardless of available space) |\n| `\"auto\"` | Auto-scale to fit parent width silently (no warning) |\n| `\"0.5\"`, `\"1.2\"`, \u2026 | Fixed factor \u2014 apply `baseFontSize \u00D7 factor` |\n\n**Auto-scale algorithm** (modes `\"\"` and `\"auto\"`):\n1. After each render, the current `scrollWidth` of the host element is\n divided by the current `appliedScaleFactor` to derive the unscaled\n content width. This avoids resetting `--bn-font-size` to base (which\n would only affect em-based widths but not SVG pixel attributes).\n2. This unscaled width is compared against the parent's content-box\n width (via `getParentDimensions`).\n3. If the table overflows, `factor = parentWidth / unscaledWidth`\n is computed and applied to both the CSS variable and the\n `appliedScaleFactor` state (which re-renders the SVG charts).\n4. A guard flag (`_autoScaleGuard`) prevents the subsequent\n state-triggered re-render from re-measuring, avoiding an infinite\n measure \u2192 scale \u2192 fits \u2192 reset \u2192 overflow loop.\n\nInvalid values (negative numbers, non-numeric strings that are not\n`\"none\"` or `\"auto\"`) fall back to the default behaviour (auto + warning)\nand emit an `ERR_scale` warning."
|
|
1368
|
+
"text": "Controls proportional scaling of the entire table relative to the\navailable parent width. All visual dimensions scale together: font size,\nem-based spacing/padding, SVG bar-chart widths, pin lengths, dot radii,\npattern fills, axis strokes, and label offsets.\n\nScaling is driven by a single factor applied to the base font size\n(`global.fontSizePx` from the component-style store, default 13.3333 px).\nBecause the table's SCSS uses `em` units for padding, borders, and\ncolumn widths, changing the font size cascades to all layout dimensions.\nSVG elements (bars, pins, patterns) receive the factor via the\n`scaleFactor` prop on `ibcs-table` and multiply every pixel constant\nby it, so they stay proportional to the surrounding text.\n\n| Value | Behavior |\n|---------------------|----------------------------------------------------------------------------------|\n| not set / `\"\"` | Auto-scale to fit parent width; emit `AUTO_scale` warning with the applied factor |\n| `\"none\"` | No scaling (render at base font size regardless of available space) |\n| `\"auto\"` | Auto-scale to fit parent width silently (no warning) |\n| `\"0.5\"`, `\"1.2\"`, \u2026 | Fixed factor \u2014 apply `baseFontSize \u00D7 factor` |\n\n**Auto-scale algorithm** (modes `\"\"` and `\"auto\"`):\n1. After each render, the current `scrollWidth` of the host element is\n divided by the current `appliedScaleFactor` to derive the unscaled\n content width. This avoids resetting `--bn-font-size` to base (which\n would only affect em-based widths but not SVG pixel attributes).\n2. This unscaled width is compared against the parent's content-box\n width (via `getParentDimensions`).\n3. If the table overflows, `factor = parentWidth / unscaledWidth`\n is computed and applied to both the CSS variable and the\n `appliedScaleFactor` state (which re-renders the SVG charts).\n4. A guard flag (`_autoScaleGuard`) prevents the subsequent\n state-triggered re-render from re-measuring, avoiding an infinite\n measure \u2192 scale \u2192 fits \u2192 reset \u2192 overflow loop.\n\nInvalid values (negative numbers, non-numeric strings that are not\n`\"none\"` or `\"auto\"`) fall back to the default behaviour (auto + warning)\nand emit an `ERR_scale` warning.\n\n**Only the width is fitted.** A table that renders taller than its\nconstrained parent is clipped by the layout cell \u2014 bottom rows and the\ngrand total simply disappear \u2014 so every render reports the measured\noverflow as a `WARN_overflow` item in `has-error`: an `error` when the\nsize is pinned by `scale` (`\"none\"` or a factor), a `warning` in auto\nmode. The same item reports a width overflow, which only a fixed `scale`\ncan produce. Setting `scale=\"auto\"` does not fix a height overflow: give\nthe component more space, reduce rows (`limit`), or set a smaller fixed\n`scale`."
|
|
1326
1369
|
},
|
|
1327
1370
|
"getter": false,
|
|
1328
1371
|
"setter": false,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
const VAR = /var\(\s*(--[\w-]+)\s*,\s*([^)]+)\)/g;
|
|
3
|
+
export const resolveHostFont = (stylesheetPath, host) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const css = readFileSync(stylesheetPath, "utf8");
|
|
6
|
+
const hostBlock = (_b = (_a = /:host\s*\{([^}]*)\}/.exec(css)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : "";
|
|
7
|
+
const declaration = (property) => {
|
|
8
|
+
const match = new RegExp(`(?:^|[;\\n])\\s*${property}\\s*:\\s*([^;]+);`).exec(hostBlock);
|
|
9
|
+
if (!match)
|
|
10
|
+
return undefined;
|
|
11
|
+
return match[1]
|
|
12
|
+
.replace(VAR, (_, name, fallback) => host.style.getPropertyValue(name).trim() || fallback.trim())
|
|
13
|
+
.trim();
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
fontFamily: declaration("font-family"),
|
|
17
|
+
fontSize: declaration("font-size"),
|
|
18
|
+
color: declaration("color"),
|
|
19
|
+
};
|
|
20
|
+
};
|