@bino-bi/bn-template-engine 1.0.0-next.32 → 1.0.0-next.33
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-b4efbcb5.entry.js +1 -0
- package/dist/bn-template-engine/{p-225cd474.entry.js → p-fcc42077.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1 -1
- package/dist/cjs/bn-grid.cjs.entry.js +51 -14
- package/dist/collection/components/bn-grid/bn-grid.js +51 -14
- package/dist/collection/components/bn-layout-card/bn-layout-card.css +8 -0
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +1 -1
- package/dist/esm/bn-grid.entry.js +51 -14
- package/dist/types/components/bn-grid/bn-grid.d.ts +6 -2
- package/package.json +1 -1
- package/dist/bn-template-engine/p-ce39e111.entry.js +0 -1
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as i,a as e,g as s}from"./p-CCZcKl0Q.js";import{LAYOUT_STATE_VERSION as o}from"./index.esm.js";import{l,o as n,r,m as a,a as d}from"./p-CHZ50kEY.js";import{w as h,a as c}from"./p-CJfJQT0m.js";import{w as u,a as v}from"./p-BjR3nkhl.js";function g(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);return Array.isArray(i)?i.map(((t,i)=>{var e,s,o;return"string"==typeof t?{label:t,id:String(i)}:"object"==typeof t&&null!==t?{label:null!==(s=null!==(e=t.label)&&void 0!==e?e:t.name)&&void 0!==s?s:String(i),id:null!==(o=t.id)&&void 0!==o?o:String(i)}:{label:String(t),id:String(i)}})):[]}catch(t){return console.error("parseHeaders: failed to parse JSON",t),[]}}function f(t,i){return`${t.id}-${i.id}`}function p(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);if(!Array.isArray(i))return["Headers must be an array"];const e=[],s=new Set;return i.forEach(((t,i)=>{"object"==typeof t&&null!==t&&void 0!==t.id&&("string"!=typeof t.id?e.push(`Header[${i}]: 'id' must be a string`):s.has(t.id)?e.push(`Header[${i}]: duplicate id '${t.id}'`):s.add(t.id),void 0!==t.label&&"string"!=typeof t.label&&e.push(`Header[${i}]: 'label' must be a string`))})),e}catch(t){return console.error("validateHeadersJson: failed to parse JSON",t),["Invalid JSON structure"]}}const b=["auto","equal"],m=["top","center","bottom","baseline"],y=["left","center","right","baseline"],w={top:"flex-start",center:"center",bottom:"flex-end",baseline:"flex-start"},x={left:"stretch",center:"center",right:"flex-end",baseline:"stretch"},C=t=>Math.round(100*t)/100,S=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]),$=class{validateRowHeaders(t){const i="ERR_rowHeaders",e=p(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`row-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateColumnHeaders(t){const i="ERR_columnHeaders",e=p(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`column-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateCellHeight(t){this.resolvedHeight=this.validateChoice("cell-height","ERR_cellHeight",t,b,"auto")}validateCellWidth(t){this.resolvedWidth=this.validateChoice("cell-width","ERR_cellWidth",t,b,"auto")}validateCellVerticalAlign(t){this.resolvedVertical=this.validateChoice("cell-vertical-align","ERR_cellVerticalAlign",t,m,"top"),this.schedule()}validateCellHorizontalAlign(t){this.resolvedHorizontal=this.validateChoice("cell-horizontal-align","ERR_cellHorizontalAlign",t,y,"left"),this.schedule()}validateCellCaptions(t){const i=function(t){if(void 0===t||""===t.trim())return{};let i;try{i=JSON.parse(t)}catch(t){return}if("object"!=typeof i||null===i||Array.isArray(i))return;const e={};for(const[t,s]of Object.entries(i)){if("string"!=typeof s)return;""!==s&&(e[t]=s)}return e}(t);i?this.errors.remove("ERR_cellCaptions"):this.errors.addOrReplace({id:"ERR_cellCaptions",type:"error",message:"cell-captions: not a JSON object from slot name to text."}),this.captions=null!=i?i:{}}constructor(i){t(this,i),this.gridConfig={rows:[],columns:[]},this.resolvedHeight="auto",this.resolvedWidth="auto",this.resolvedVertical="top",this.resolvedHorizontal="left",this.captions={},this.offsets={},this.observed=new WeakSet,this.scheduled=!1,this.run=0,this.adjustments=0,this.chartTitle="",this.rowHeaders="[]",this.columnHeaders="[]",this.showRowHeaders=!0,this.showColumnHeaders=!0,this.showBorders=!0,this.rowHeaderWidth="auto",this.cellGap="0px",this.cellHeight="auto",this.cellWidth="auto",this.cellVerticalAlign="top",this.cellHorizontalAlign="left",this.cellCaptions="",this.schedule=()=>{if(!this.isBaselineMode())return this.run++,void(Object.keys(this.offsets).length>0&&(this.offsets={}));this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.align().catch((t=>console.error("bn-grid: aligning the baselines failed",t))).finally(t)}))}))))},u(this),this.holdStatus=h(this),this.errors=c(this),this.componentStyle=v(this)}connectedCallback(){var t;this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.mutationObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,i,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",this.schedule),this.run++}componentDidRender(){this.schedule()}validateChoice(t,i,e,s,o){return null==e||""===e?(this.errors.remove(i),o):s.includes(e)?(this.errors.remove(i),e):(this.errors.addOrReplace({id:i,type:"error",message:`${t}: "${e}" is not one of ${s.join(", ")}.`}),o)}isBaselineMode(){return"baseline"===this.resolvedVertical||"baseline"===this.resolvedHorizontal}visualIn(t){var i;const e=Array.from(this.element.children).find((i=>i.getAttribute("slot")===t));if(!e)return;const s=t=>t.localName.startsWith("bn-")&&!S.has(t.localName);return s(e)?e:null!==(i=Array.from(e.querySelectorAll("*")).find(s))&&void 0!==i?i:void 0}async align(){var t;const i=++this.run;if(!this.element.isConnected||!this.isBaselineMode())return;const{rows:e,columns:s}=this.gridConfig,o=e.flatMap(((t,i)=>s.map(((e,s)=>({slot:f(t,e),row:i,column:s}))))),n=o.map((({slot:t})=>this.visualIn(t)));if(await Promise.all(n.map((t=>{var i;return null===(i=null==t?void 0:t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;n.forEach((t=>t&&this.observe(t)));const r=await Promise.all(n.map((t=>"function"==typeof(null==t?void 0:t.getBaseline)?t.getBaseline().catch((()=>({}))):Promise.resolve({}))));if(i!==this.run)return;const a=l(this.element),d=new Map;null===(t=this.element.shadowRoot)||void 0===t||t.querySelectorAll(".grid-slot").forEach((t=>{var i;d.set(null!==(i=t.getAttribute("data-slot"))&&void 0!==i?i:"",t)}));const h=function(t,i,e){const s={};for(const i of t)s[i.slot]={};const o=(i,e,o,l)=>{var n;const r=new Map;for(const e of t)r.set(e[i],[...null!==(n=r.get(e[i]))&&void 0!==n?n:[],e]);for(const t of r.values()){const i=t.map((t=>{const i=e(t);return void 0===i?void 0:i-o(t)})),n=i.filter((t=>void 0!==t)),r=n.length>0?Math.max(...n):0,a=i.map((t=>void 0===t?void 0:C(r-t))),d=Math.max(0,...a.filter((t=>void 0!==t)));t.forEach(((t,i)=>l(s[t.slot],a[i],d)))}};return i&&o("row",(t=>t.y),(t=>t.top),((t,i)=>{void 0===i?t.bottom=!0:t.top=i})),e&&o("column",(t=>t.x),(t=>t.left),((t,i,e)=>{void 0!==i&&(t.left=i);const s=C(e-(null!=i?i:0));s>0&&(t.right=s)})),s}(o.map((({slot:t,row:i,column:e},s)=>{const o=n[s],l=r[s],h=d.get(t),c=t=>parseFloat((null==h?void 0:h.style.getPropertyValue(t))||"0")||0,u={slot:t,row:i,column:e,top:c("padding-top"),left:c("margin-left")};if(o){const t=a.toLocal(o.getBoundingClientRect());void 0!==l.y&&(u.y=t.y+l.y),void 0!==l.x&&(u.x=t.x+l.x)}return u})),"baseline"===this.resolvedVertical,"baseline"===this.resolvedHorizontal);if(function(t,i){var e,s,o,l,n,r,a,d;const h=new Set([...Object.keys(t),...Object.keys(i)]);for(const c of h){const h=null!==(e=t[c])&&void 0!==e?e:{},u=null!==(s=i[c])&&void 0!==s?s:{};if(Boolean(h.bottom)!==Boolean(u.bottom))return!1;if(Math.abs((null!==(o=h.top)&&void 0!==o?o:0)-(null!==(l=u.top)&&void 0!==l?l:0))>=.5)return!1;if(Math.abs((null!==(n=h.left)&&void 0!==n?n:0)-(null!==(r=u.left)&&void 0!==r?r:0))>=.5)return!1;if(Math.abs((null!==(a=h.right)&&void 0!==a?a:0)-(null!==(d=u.right)&&void 0!==d?d:0))>=.5)return!1}return!0}(h,this.offsets))this.adjustments=0;else{if(this.adjustments>=5)return console.warn("bn-grid: the baselines did not settle; the cells keep their last alignment."),void(this.adjustments=0);this.adjustments++,this.offsets=h,this.schedule()}}observe(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t));const e=t=>{var i;t&&(this.observed.has(t)||(this.observed.add(t),null===(i=this.mutationObserver)||void 0===i||i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["x1","y1","x2","y2","x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}async getLayoutState(t){var i,e,s,l;const h=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",c=n(this.element),u=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),{rows:v,columns:g}=this.gridConfig,f={version:o,tag:this.element.localName,id:d(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:a(this.element,c),em:{fontSizePx:u,appliedScaleFactor:1},regions:[],metadata:{title:this.chartTitle||void 0,rowCount:v.length,columnCount:g.length,cellCount:v.length*g.length},diagnostics:r(this.element)},p=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector(".grid-container");if(p&&f.regions.push({id:"grid",rect:a(p,c)}),"full"!==h||!p)return f;const b=[],m=t=>b.push(t),y=p.querySelector(".grid-title");return y&&m({kind:"gridTitle",label:(null===(l=y.textContent)||void 0===l?void 0:l.trim())||void 0,rect:a(y,c)}),p.querySelectorAll(".grid-header-col").forEach(((t,i)=>{var e,s;m({kind:"gridHeader",columnId:null===(e=g[i])||void 0===e?void 0:e.id,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:a(t,c)})})),p.querySelectorAll(".grid-header-row").forEach(((t,i)=>{var e,s;m({kind:"gridHeader",rowId:null===(e=v[i])||void 0===e?void 0:e.id,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:a(t,c)})})),p.querySelectorAll(".grid-cell").forEach(((t,i)=>{var e,s,o,l;m({kind:"gridCell",rowId:g.length>0?null===(e=v[Math.floor(i/g.length)])||void 0===e?void 0:e.id:void 0,columnId:g.length>0?null===(s=g[i%g.length])||void 0===s?void 0:s.id:void 0,slot:null!==(l=null===(o=t.querySelector("slot"))||void 0===o?void 0:o.getAttribute("name"))&&void 0!==l?l:void 0,rect:a(t,c)})})),p.querySelectorAll(".grid-caption").forEach((t=>{var i,e,s,o;m({kind:"gridCaption",slot:null!==(s=null===(e=null===(i=t.parentElement)||void 0===i?void 0:i.querySelector("slot"))||void 0===e?void 0:e.getAttribute("name"))&&void 0!==s?s:void 0,label:(null===(o=t.textContent)||void 0===o?void 0:o.trim())||void 0,rect:a(t,c)})})),f.elements=b,f}getGridStyle(){return this.componentStyle((t=>t["bn-grid"]))}componentWillLoad(){this.validateRowHeaders(this.rowHeaders),this.validateColumnHeaders(this.columnHeaders),this.validateCellHeight(this.cellHeight),this.validateCellWidth(this.cellWidth),this.validateCellVerticalAlign(this.cellVerticalAlign),this.validateCellHorizontalAlign(this.cellHorizontalAlign),this.validateCellCaptions(this.cellCaptions)}updateGridConfig(){var t;this.gridConfig=(t=this.columnHeaders,{rows:g(this.rowHeaders),columns:g(t)})}shouldShowRowHeaders(){return this.showRowHeaders&&this.gridConfig.rows.length>0}shouldShowColumnHeaders(){return this.showColumnHeaders&&this.gridConfig.columns.length>0}shouldShowBorders(){return this.showBorders}getGridTemplateColumns(){const t=[];this.shouldShowRowHeaders()&&t.push(this.rowHeaderWidth);const i=this.gridConfig.columns.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedWidth?"minmax(0, 1fr)":"auto");return t.join(" ")}getGridTemplateRows(){const t=[];this.chartTitle&&t.push("auto"),this.shouldShowColumnHeaders()&&t.push("auto");const i=this.gridConfig.rows.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedHeight?"1fr":"auto");return t.join(" ")}renderTitle(){if(!this.chartTitle)return null;const t=(this.shouldShowRowHeaders()?1:0)+this.gridConfig.columns.length;return i("div",{class:"grid-title",style:{"grid-column":`1 / span ${t}`,"grid-row":"1"}},this.chartTitle)}renderColumnHeaders(){if(!this.shouldShowColumnHeaders())return null;const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",s=this.shouldShowRowHeaders()?2:1,o=this.chartTitle?2:1;return this.gridConfig.columns.map(((l,n)=>{const r=n>0;return i("div",{key:`col-header-${l.id}`,class:"grid-header grid-header-col",style:{"grid-column":String(s+n),"grid-row":String(o),"border-left":r?e:"none",padding:`${t.cellPadding}px`,"padding-left":r?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},l.label)}))}renderDataCells(){const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",s=this.shouldShowRowHeaders()?2:1,o=(this.chartTitle?1:0)+(this.shouldShowColumnHeaders()?1:0)+1,l=[];return this.gridConfig.rows.length>0&&this.gridConfig.columns.length>0&&this.gridConfig.rows.forEach(((n,r)=>{if(this.shouldShowRowHeaders()){const s=r>0;l.push(i("div",{key:`row-header-${n.id}`,class:"grid-header grid-header-row",style:{"grid-column":"1","grid-row":String(o+r),"border-top":s?e:"none",padding:`${t.cellPadding}px`,"padding-top":s?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},n.label))}this.gridConfig.columns.forEach(((a,d)=>{const h=f(n,a),c=d>0,u=r>0;l.push(i("div",{key:`cell-${h}`,class:"grid-cell",style:Object.assign({"grid-column":String(s+d),"grid-row":String(o+r),"border-left":c?e:"none","border-top":u?e:"none","padding-left":c?`${t.cellPadding+4}px`:"0","padding-top":u?`${t.cellPadding+4}px`:"0"},this.cellAlignStyle())},this.renderCellContent(h,t)))}))})),l}cellAlignStyle(){return"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal?{}:{display:"flex","flex-direction":"column","justify-content":w[this.resolvedVertical],"align-items":x[this.resolvedHorizontal]}}renderCellContent(t,e){const s=this.captions[t],o=void 0!==s?i("div",{class:"grid-caption",style:{"font-size":`${e.captionFontSize}px`,"font-weight":String(e.captionFontWeight),color:e.captionColor,"margin-bottom":`${e.captionGap}px`,"align-self":"flex-start"}},s):null,l={};"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal||(l["align-self"]="stretch","center"!==this.resolvedHorizontal&&"right"!==this.resolvedHorizontal||(l.display="flex",l["flex-direction"]="column",l["align-items"]=x[this.resolvedHorizontal])),"center"===this.resolvedVertical?(l["margin-top"]="auto",l["margin-bottom"]="auto"):"bottom"===this.resolvedVertical&&(l["margin-top"]="auto");const n=this.offsets[t];return(null==n?void 0:n.bottom)&&(l["margin-top"]="auto"),(null==n?void 0:n.top)&&(l["padding-top"]=`${n.top}px`),(null==n?void 0:n.left)&&(l["margin-left"]=`${n.left}px`),(null==n?void 0:n.right)&&(l["margin-right"]=`${n.right}px`),[o,i("div",{class:"grid-slot","data-slot":t,style:l},i("slot",{name:t}))]}getFontStyles(){return this.componentStyle((t=>{var i,e,s,o;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(s=t.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(o=t.global)||void 0===o?void 0:o.fontBackgroundColor)||"#ffffff"}}))}render(){const t="equal"===this.resolvedWidth,s=Object.assign(Object.assign({display:t?"grid":"inline-grid"},t?{width:"100%"}:{}),{"grid-template-columns":this.getGridTemplateColumns(),"grid-template-rows":this.getGridTemplateRows(),gap:this.cellGap});return i(e,{key:"3fcfe5d215a02a65652c00e37a2873377b708043",style:t?Object.assign(Object.assign({},this.getFontStyles()),{display:"block"}):this.getFontStyles()},i("div",{key:"55a2ae64a80a2f660601eaddbb5bd6e90e224796",class:"grid-container",style:s},this.renderTitle(),this.renderColumnHeaders(),this.renderDataCells()),i("slot",{key:"1c47b472d38b8e12a42e7f1609466681cdde98f3"}))}get element(){return s(this)}static get watchers(){return{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}}};$.style=':host{display:inline-block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.grid-container{display:inline-grid;box-sizing:border-box}.grid-title{font-weight:normal;padding-bottom:8px}.grid-header{display:flex;align-items:flex-end;box-sizing:border-box}.grid-header-row{justify-content:flex-end;padding-right:8px}.grid-header-col{white-space:nowrap;justify-content:flex-start}.grid-cell{position:relative;box-sizing:border-box}';export{$ as bn_grid}
|