@agile-team/mach-table 0.32.1 → 0.34.0
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/README.md +33 -2
- package/dist/adapter.cjs +1 -1
- package/dist/adapter.d.cts +28 -26
- package/dist/adapter.d.ts +28 -26
- package/dist/adapter.js +1 -1
- package/dist/analysis.cjs +2 -2
- package/dist/analysis.d.cts +2 -2
- package/dist/analysis.d.ts +2 -2
- package/dist/analysis.js +2 -2
- package/dist/{api-pOhyuSQk.d.cts → api-CfZinb9Q.d.cts} +39 -4
- package/dist/{api-pOhyuSQk.d.ts → api-CfZinb9Q.d.ts} +39 -4
- package/dist/business.cjs +1 -0
- package/dist/business.d.cts +61 -0
- package/dist/business.d.ts +61 -0
- package/dist/business.js +1 -0
- package/dist/cachedDictionary-HXvqrDI0.d.cts +30 -0
- package/dist/cachedDictionary-HXvqrDI0.d.ts +30 -0
- package/dist/{configuration-gAE1eZuB.d.cts → configuration-D2lEYcli.d.cts} +5 -2
- package/dist/{configuration-SYWVjGft.d.ts → configuration-WTbQcWck.d.ts} +5 -2
- package/dist/import.cjs +1 -0
- package/dist/import.d.cts +47 -0
- package/dist/import.d.ts +47 -0
- package/dist/import.js +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +10 -27
- package/dist/index.d.ts +10 -27
- package/dist/index.js +6 -6
- package/dist/multi-range.cjs +2 -2
- package/dist/multi-range.d.cts +1 -1
- package/dist/multi-range.d.ts +1 -1
- package/dist/multi-range.js +3 -3
- package/dist/ordering.cjs +1 -1
- package/dist/ordering.d.cts +1 -1
- package/dist/ordering.d.ts +1 -1
- package/dist/ordering.js +1 -1
- package/dist/preferences.cjs +1 -1
- package/dist/preferences.d.cts +1 -1
- package/dist/preferences.d.ts +1 -1
- package/dist/preferences.js +1 -1
- package/dist/server-side.cjs +1 -1
- package/dist/server-side.d.cts +1 -1
- package/dist/server-side.d.ts +1 -1
- package/dist/server-side.js +1 -1
- package/dist/{shared-Bi8hAuzn.d.cts → shared-D-DnodkE.d.cts} +1 -1
- package/dist/{shared-Bn77TiBm.d.ts → shared-buw2Rj4E.d.ts} +1 -1
- package/dist/workbench.cjs +1 -1
- package/dist/workbench.d.cts +3 -3
- package/dist/workbench.d.ts +3 -3
- package/dist/workbench.js +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +4 -2
- package/dist/worker.d.ts +4 -2
- package/dist/worker.js +1 -1
- package/package.json +22 -2
package/dist/analysis.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var J=new Set(["__proto__","prototype","constructor"]);function E(n){return typeof n!="string"||n.length===0?!1:n.split(".").every(t=>t.length>0&&!J.has(t))}function x(n,e){if(n==null||!E(e))return;if(e.indexOf(".")<0)return n[e];let r=n,i=0;for(;i<e.length;){if(r==null)return;let o=e.indexOf(".",i);if(o<0){r=r[e.slice(i)];break}r=r[e.slice(i,o)],i=o+1}return r}var Z=new Set(["sum","count","avg","min","max"]);function V(n){return JSON.stringify(n.map(e=>[e===null?"null":typeof e,e]))}function H(n){if(n==null)return null;if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"||typeof n=="boolean")return n;if(n instanceof Date&&!Number.isNaN(n.getTime()))return n.toISOString();throw new TypeError("Pivot dimensions must be primitive values or valid Dates")}function Q(n,e){if(n.length>1e4)throw new RangeError("Pivot supports at most 10000 input rows; aggregate remotely for larger datasets");let t=[...e.rowFields,...e.columnFields??[]];if(t.length>12||e.values.length>16||!e.values.length)throw new RangeError("Pivot supports 12 dimensions and 1\u201316 measures");for(let i of t)if(!E(i))throw new TypeError(`Invalid pivot field: ${i}`);let r=new Set;for(let i of e.values){ee(i);let o=JSON.stringify([i.field??null,i.aggregate]);if(r.has(o))throw new TypeError("Duplicate pivot measure");r.add(o)}}function ee(n){if(!Z.has(n.aggregate))throw new TypeError(`Unknown pivot aggregate: ${String(n.aggregate)}`);if(n.field!=null&&!E(n.field))throw new TypeError(`Invalid pivot field: ${n.field}`);if(!n.field&&n.aggregate!=="count")throw new TypeError("Numeric pivot measures require a field")}function j(n,e,t){let r=n.get(e);r||(r={count:0,numeric:0,sum:0,min:1/0,max:-1/0},n.set(e,r)),r.count++,!(typeof t!="number"||!Number.isFinite(t))&&(r.numeric++,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t))}function te(n,e){return e==="count"?n?.count??0:n?.numeric?e==="avg"?Number.isFinite(n.sum)?n.sum/n.numeric:null:e==="sum"?Number.isFinite(n.sum)?n.sum:null:e==="min"?n.min:n.max:null}function ne(n,e){return JSON.stringify([n===null?"total":V(n),e.field??null,e.aggregate])}function N(n,e){Q(n,e);let t=new Map,r=new Map,i=new Map,o=e.columnFields??[];for(let s of n){let u=e.rowFields.map(p=>H(x(s,p))),m=V(u),d=t.get(m);if(d||(d={dimensions:u,cells:new Map},t.set(m,d)),t.size>2e3)throw new RangeError("Pivot supports at most 2000 result row groups");let h=o.map(p=>H(x(s,p)));for(let p of e.values){let g=p.field?x(s,p.field):void 0;G(d,r,i,h,p,g),o.length&&G(d,r,i,null,p,g)}if(r.size>128)throw new RangeError("Pivot supports at most 128 result columns")}if(!n.length&&!o.length)for(let s of e.values)z(r,[],s);let a=[...r.values()].sort((s,u)=>Number(s.total)-Number(u.total)||s.id.localeCompare(u.id)),l=[...t.entries()].sort(([s],[u])=>s.localeCompare(u)).map(([s,u])=>({id:s,dimensions:u.dimensions,values:U(a,u.cells)}));return{columns:a,rows:l,totals:U(a,i),inputCount:n.length}}function z(n,e,t){let r=ne(e,t);if(!n.has(r)){let i=t.label??`${t.field??"\u8BB0\u5F55"} \xB7 ${t.aggregate}`,o=e===null?"\u5408\u8BA1":e.map(a=>a==null?"\u7A7A\u503C":String(a)).join(" / ");n.set(r,{id:r,label:o?`${o} / ${i}`:i,dimensions:e??[],total:e===null,measure:{...t}})}return r}function G(n,e,t,r,i,o){let a=z(e,r,i);j(n.cells,a,o),j(t,a,o)}function U(n,e){let t=Object.create(null);for(let r of n)t[r.id]=te(e.get(r.id),r.measure.aggregate);return t}var f=class extends Error{constructor(t,r){super(r);this.code=t}},W={"+":1,"-":1,"*":2,"/":2,"%":2,"^":3},re=new Set(["SUM","MIN","MAX","AVG"]);function ie(n){if(n.length>4096)throw new f("LIMIT","Formula exceeds 4096 characters");let e=[],t=n.startsWith("=")?1:0;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}let r=oe(n.slice(t));if(e.push(r),t+=r.kind==="field"?r.value.length+2:r.value.length,e.length>256)throw new f("LIMIT","Formula exceeds 256 tokens")}return e}function oe(n){let e=/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i.exec(n);if(e)return{kind:"number",value:e[0]};let t=/^\[([^\]\r\n]+)\]/.exec(n);if(t)return{kind:"field",value:t[1]};let r=/^[A-Za-z_\u4e00-\u9fff][\w.\u4e00-\u9fff]*/.exec(n);if(r)return{kind:"name",value:r[0]};if("+-*/%^(),".includes(n[0]))return{kind:"symbol",value:n[0]};throw new f("SYNTAX",`Unexpected token: ${n.slice(0,12)}`)}function B(n){let e=ie(n),t=0,r=s=>{if(e[t++]?.value!==s)throw new f("SYNTAX",`Expected ${s}`)},i=(s,u)=>{if(u>32)throw new f("LIMIT","Formula exceeds 32 nesting levels");let m=a(u);for(;t<e.length;){let d=e[t].value,h=Object.prototype.hasOwnProperty.call(W,d)?W[d]:void 0;if(h==null||h<s)break;t++;let p=i(h+(d==="^"?0:1),u+1);m={kind:"binary",operator:d,left:m,right:p}}return m},o=(s,u)=>{let m=s.toUpperCase();if(!re.has(m))throw new f("SYNTAX",`Unsupported function: ${s}`);r("(");let d=[];if(e[t]?.value!==")")do d.push(i(0,u+1));while(e[t]?.value===","&&++t);if(r(")"),!d.length&&m!=="SUM")throw new f("SYNTAX",`${m} requires arguments`);return{kind:"call",name:m,args:d}},a=s=>{let u=e[t++];if(!u)throw new f("SYNTAX","Expected a value");if(u.kind==="number")return{kind:"number",value:Number(u.value)};if(u.kind==="field")return{kind:"field",name:u.value};if(u.kind==="name")return e[t]?.value==="("?o(u.value,s):{kind:"field",name:u.value};if(u.value==="+"||u.value==="-")return{kind:"unary",operator:u.value,operand:i(3,s+1)};if(u.value==="("){let m=i(0,s+1);return r(")"),m}throw new f("SYNTAX",`Unexpected token: ${u.value}`)},l=i(0,0);if(t!==e.length)throw new f("SYNTAX","Unexpected trailing tokens");return l}function k(n){if(!Number.isFinite(n))throw new f("NON_FINITE","Formula result is not a finite number");return n}function se(n,e,t){if((n==="/"||n==="%")&&t===0)throw new f("DIV_ZERO","Division by zero");return n==="+"?e+t:n==="-"?e-t:n==="*"?e*t:n==="/"?e/t:n==="%"?e%t:e**t}function T(n,e){if(n.kind==="number")return k(n.value);if(n.kind==="field")return e(n.name);if(n.kind==="unary")return k((n.operator==="-"?-1:1)*T(n.operand,e));if(n.kind==="binary")return k(se(n.operator,T(n.left,e),T(n.right,e)));let t=n.args.map(i=>T(i,e));if(n.name==="MIN")return Math.min(...t);if(n.name==="MAX")return Math.max(...t);let r=t.reduce((i,o)=>i+o,0);return k(n.name==="AVG"?r/t.length:r)}function S(n,e){let t=Object.entries(e);if(t.length>32||n.length>1e4||t.length*n.length>1e5)throw new f("LIMIT","Formulas support 32 columns, 10000 rows and 100000 result cells");let r=new Map;for(let[a,l]of t){if(!E(a)||/[.\[\]]/.test(a))throw new f("SYNTAX",`Invalid formula column: ${a}; use a single-level ID without dots or brackets`);try{r.set(a,B(l))}catch(s){r.set(a,X(s))}}let i=[];return{rows:n.map((a,l)=>{let s={...a},u=le(a,r);for(let[m,d]of u)d instanceof f&&i.push({rowIndex:l,colId:m,code:d.code,message:d.message}),Object.defineProperty(s,m,{value:d instanceof f?null:d,enumerable:!0,configurable:!0,writable:!0});return s}),errors:i}}function X(n){return n instanceof f?n:new f("SYNTAX",n instanceof Error?n.message:String(n))}function ae(n,e){if(!E(e))throw new f("UNKNOWN_FIELD",`Unknown field: ${e}`);let t=x(n,e);if(t===void 0)throw new f("UNKNOWN_FIELD",`Unknown field: ${e}`);if(typeof t!="number")throw new f("NON_NUMERIC",`Field is not numeric: ${e}`);return k(t)}function le(n,e){let t=new Map,r=new Set,i=o=>{if(!e.has(o))return ae(n,o);let a=t.get(o);if(a instanceof f)throw a;if(a!=null)return a;if(r.has(o))throw new f("CYCLE",`Cyclic formula: ${[...r,o].join(" \u2192 ")}`);r.add(o);try{let l=e.get(o);if(l instanceof f)throw l;let s=k(T(l,i));return t.set(o,s),s}catch(l){let s=X(l);throw t.set(o,s),s}finally{r.delete(o)}};for(let o of e.keys())try{i(o)}catch{}return t}var ue=["--mach-font-family","--mach-font-size","--mach-font-size-sm","--mach-header-font-weight","--mach-cell-padding","--mach-header-h","--mach-primary","--mach-primary-weak","--mach-success","--mach-warning","--mach-danger","--mach-info","--mach-border-color","--mach-border-width","--mach-header-bg","--mach-header-fg","--mach-body-bg","--mach-body-fg","--mach-row-hover-bg","--mach-radius-sm","--mach-radius","--mach-radius-lg","--mach-shadow-sm","--mach-shadow","--mach-transition","--mach-z-popup","--mach-z-menu"];function Y(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let r of ue){let i=t.getPropertyValue(r).trim();i&&n.style.setProperty(r,i)}n.style.colorScheme=t.colorScheme}function c(n,e,t){let r=document.createElement(n);return e&&(r.className=e),t!=null&&(r.textContent=t),r}function y(n,e,t=""){let r=c("button",`mach-workbench__button ${t}`.trim(),n);return r.type="button",r.addEventListener("click",e),r}function P(n,e,t,r){let i=c("select","mach-workbench__input");i.setAttribute("aria-label",n);for(let o of e){let a=c("option",void 0,o.label);a.value=o.value,i.append(a)}return i.value=t,i.addEventListener("change",()=>r(i.value)),i}function _(n,e){let t=[...n.querySelectorAll("button,select,input")].filter(i=>!i.disabled);(t.find(i=>i.getAttribute("aria-label")===e||i.textContent===e)??t[0])?.focus()}function K(n,e,t,r){let i=document.activeElement,o=c("section","mach-workbench");o.setAttribute("aria-label",e),o.tabIndex=-1;let a=c("header","mach-workbench__header");a.append(c("h2","mach-workbench__title",e),y("\u5173\u95ED",t));let l=c("div","mach-workbench__body"),s=c("p","mach-workbench__status");s.setAttribute("role","status"),s.setAttribute("aria-live","polite");let u=c("footer","mach-workbench__footer");o.append(a,l,s,u);let m=v=>{v.key!=="Escape"||v.isComposing||(v.preventDefault(),v.stopPropagation(),t())};o.addEventListener("keydown",m);let d=!1,h=r.view.getRoot(),p=()=>{d||(o.dataset.theme=h?.classList.contains("mach-theme-dark")?"dark":"light",Y(o,h))},g=null;try{p(),h&&(g=new MutationObserver(p),g.observe(h,{attributes:!0,attributeFilter:["class","style"]})),n.append(o)}catch(v){throw g?.disconnect(),o.remove(),v}return{root:o,body:l,status:s,footer:u,syncTheme:p,destroy(){if(d)return;d=!0,g?.disconnect();let v=o.contains(document.activeElement);o.removeEventListener("keydown",m),o.remove(),v&&i?.isConnected&&i.focus()}}}function w(n,e,t){let r=document.createElementNS("http://www.w3.org/2000/svg",n);for(let[i,o]of Object.entries(e))r.setAttribute(i,String(o));return t!=null&&(r.textContent=t),r}function q(n,e,t){let r=c("figure","mach-analysis__chart"),i=n.columns.find(b=>b.id===e);if(!i)return r.append(c("p",void 0,"\u5C1A\u65E0\u53EF\u7ED8\u5236\u7684\u6307\u6807")),r;let o=n.rows.slice(0,40),a=`${i.label} \xB7 ${t==="bar"?"\u67F1\u72B6\u56FE":"\u6298\u7EBF\u56FE"}\uFF0C${o.length} \u7EC4`,l=w("svg",{viewBox:"0 0 680 260",role:"img","aria-label":a});l.append(w("title",{},a));let s=o.map(b=>b.values[e]).filter(b=>b!=null&&Number.isFinite(b)),u=Math.min(0,...s),m=Math.max(0,...s),d=Math.max(Math.abs(m),Math.abs(u))||1,h=m/d-u/d||1,p=b=>210-(b/d-u/d)/h*180,g=p(0);l.append(w("line",{x1:50,x2:660,y1:g,y2:g,stroke:"currentColor",opacity:".4"})),l.append(w("text",{x:2,y:25,"font-size":11},String(m)),w("text",{x:2,y:212,"font-size":11},String(u)));let v=600/Math.max(o.length,1),M=[],D=()=>{M.length&&l.append(w("polyline",{points:M.join(" "),fill:"none",stroke:"currentColor","stroke-width":2})),M=[]};return o.forEach((b,O)=>{let C=b.values[e];if(C==null){D();return}let F=55+v*(O+.5),A=p(C),L=b.dimensions.map($=>$==null?"\u7A7A\u503C":String($)).join(" / ")||"\u5168\u90E8",I=t==="bar"?w("rect",{x:F-v*.35,y:Math.min(g,A),width:Math.max(1,v*.7),height:Math.max(1,Math.abs(A-g)),fill:"currentColor",rx:2}):w("circle",{cx:F,cy:A,r:3,fill:"currentColor"});I.append(w("title",{},`${L}: ${C}`)),l.append(I),t==="line"&&M.push(`${F},${A}`),(o.length<=10||O%Math.ceil(o.length/10)===0)&&l.append(w("text",{x:F,y:238,"text-anchor":"middle","font-size":10},L.slice(0,12)))}),D(),r.append(l,c("figcaption","mach-workbench__hint",`${a}\u3002${n.rows.length>40?"\u56FE\u8868\u4EC5\u5C55\u793A\u524D 40 \u7EC4\uFF0C":""}\u5B8C\u6574\u6570\u503C\u89C1\u4E0B\u65B9\u6570\u636E\u8868\u3002`)),r}var ce={sum:"\u6C42\u548C",count:"\u8BB0\u5F55\u6570",avg:"\u5E73\u5747\u503C",min:"\u6700\u5C0F\u503C",max:"\u6700\u5927\u503C"};function de(n,e){return new R(n,e)}var R=class{constructor(e,t){this.options=t;this.fields=[];this.result=null;this.results=c("div","mach-analysis__results");this.page=0;this.i="bar";this.t="";this.destroyed=!1;if(t.api.isDestroyed())throw new Error("Cannot mount analysis on a destroyed grid");this.config={rowFields:[...t.pivot?.rowFields??[]],columnFields:[...t.pivot?.columnFields??[]],values:t.pivot?.values.map(r=>({...r}))??[{aggregate:"count"}]},this.formulas=Object.entries(t.formulas??{}).map(([r,i])=>({field:r,expression:i})),this.e=K(e,"\u6570\u636E\u5206\u6790",()=>{this.destroy(),t.onClose?.()},t.api),this.e.footer.append(y("\u8FD0\u884C\u5206\u6790",()=>this.s(),"mach-workbench__button--primary")),this.o=[t.api.on("gridDestroyed",()=>this.destroy()),t.api.on("modelUpdated",()=>{!this.destroyed&&this.result&&(this.e.status.textContent="\u8868\u683C\u6570\u636E\u5DF2\u66F4\u65B0\uFF1B\u91CD\u65B0\u8FD0\u884C\u5206\u6790\u4EE5\u5237\u65B0\u7ED3\u679C\u3002")})],this.refresh(),this.s(),this.e.root.focus()}refresh(){this.a()&&(this.fields=this.l(),this.e.syncTheme(),this.e.body.replaceChildren(),this.c(),this.e.body.append(this.results),this.n())}destroy(){this.destroyed||(this.destroyed=!0,this.o.splice(0).forEach(e=>e()),this.e.destroy())}a(){return!this.destroyed&&!this.options.api.isDestroyed()}l(){let e=[],t=r=>{for(let i of r){if("children"in i){t(i.children);continue}if(!i.field)continue;let o=x(this.options.api.rows.getAt(0)?.data,i.field);e.push({field:i.field,label:i.headerName??i.field,numeric:typeof o=="number"||i.cellEditor==="number"||i.filter==="number"})}};t(this.options.api.columns.getDefinitions()??[]);for(let r of this.formulas)r.field&&!e.some(i=>i.field===r.field)&&e.push({field:r.field,label:`${r.field}\uFF08\u516C\u5F0F\uFF09`,numeric:!0});return e}c(){let e=c("div","mach-analysis__settings");e.append(this.dimensions("\u884C\u7EF4\u5EA6",this.config.rowFields,i=>{this.config.rowFields=i}),this.dimensions("\u5217\u7EF4\u5EA6",this.config.columnFields??[],i=>{this.config.columnFields=i}));let t=c("fieldset","mach-workbench__group");t.append(c("legend",void 0,"\u805A\u5408\u6307\u6807")),this.config.values.forEach((i,o)=>t.append(this.measure(i,o)));let r=y("\u6DFB\u52A0\u6307\u6807",()=>{this.config.values=[...this.config.values,{aggregate:"count"}],this.refresh()});r.disabled=this.config.values.length>=16,t.append(r),e.append(t,this.d()),this.e.body.append(e)}dimensions(e,t,r){let i=c("label","mach-analysis__dimension",e),o=c("select","mach-workbench__input");o.multiple=!0,o.setAttribute("aria-label",e);let a=[...this.fields];for(let l of t)a.some(s=>s.field===l)||a.push({field:l,label:`${l}\uFF08\u5DF2\u79FB\u9664\uFF09`,numeric:!1});for(let l of a){let s=c("option",void 0,l.label);s.value=l.field,s.selected=t.includes(l.field),o.append(s)}return o.addEventListener("change",()=>r([...o.selectedOptions].map(l=>l.value))),i.append(o,c("small","mach-workbench__hint","\u652F\u6301\u591A\u9009\uFF1B\u4E0D\u9009\u62E9\u8868\u793A\u5168\u90E8\u8BB0\u5F55\u3002")),i}measure(e,t){let r=c("div","mach-workbench__values"),i=[{value:"",label:"\u5168\u90E8\u8BB0\u5F55"},...this.fields.map(o=>({value:o.field,label:o.label}))];return e.field&&!i.some(o=>o.value===e.field)&&i.push({value:e.field,label:`${e.field}\uFF08\u5DF2\u79FB\u9664\uFF09`}),r.append(P("\u6307\u6807\u5B57\u6BB5",i,e.field??"",o=>{e.field=o||void 0}),P("\u805A\u5408\u65B9\u5F0F",Object.entries(ce).map(([o,a])=>({value:o,label:a})),e.aggregate,o=>{e.aggregate=o}),y("\u5220\u9664\u6307\u6807",()=>{this.config.values=this.config.values.filter((o,a)=>a!==t),this.refresh()})),r}d(){let e=c("fieldset","mach-workbench__group");e.append(c("legend",void 0,"\u516C\u5F0F\u5217"),c("p","mach-workbench__hint","\u4F7F\u7528 [\u5B57\u6BB5]\u3001+ - * / % ^\u3001\u62EC\u53F7\u548C SUM / MIN / MAX / AVG\u3002\u7ED3\u679C\u5217\u4F7F\u7528\u5355\u5C42 ID\uFF0C\u4E0D\u542B . \u6216 []\uFF1B\u5D4C\u5957\u8F93\u5165\u53EF\u5F15\u7528 [tax.total]\u3002\u53EA\u8BA1\u7B97\u5F53\u524D\u8BB0\u5F55\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u8DE8\u884C\u5F15\u7528\u3002")),this.formulas.forEach((r,i)=>{let o=c("div","mach-workbench__values"),a=c("input","mach-workbench__input");a.setAttribute("aria-label","\u516C\u5F0F\u7ED3\u679C\u5217"),a.placeholder="\u5982 total",a.value=r.field,a.addEventListener("input",()=>{r.field=a.value.trim()});let l=c("input","mach-workbench__input");l.setAttribute("aria-label","\u516C\u5F0F\u8868\u8FBE\u5F0F"),l.placeholder="\u5982 [quantity] * [price]",l.value=r.expression,l.addEventListener("input",()=>{r.expression=l.value}),o.append(a,l,y("\u5220\u9664\u516C\u5F0F",()=>{this.formulas.splice(i,1),this.refresh()})),e.append(o)});let t=y("\u6DFB\u52A0\u516C\u5F0F",()=>{this.formulas.push({field:"",expression:""}),this.refresh()});return t.disabled=this.formulas.length>=32,e.append(t),e}s(){if(!this.a())return;let e=[],t=0;this.options.api.rows.forEach(r=>{r.data==null||r.isGroup||r.isDetail||(t++,e.length<1e4&&e.push(r.data))});try{let r=this.f(),i=S(e,r);if(i.errors.length){let l=i.errors.slice(0,20).map(s=>`\u7B2C ${s.rowIndex+1} \u884C / ${s.colId}\uFF1A${s.code} ${s.message}`);throw new Error(`\u516C\u5F0F\u9519\u8BEF ${i.errors.length} \u9879${i.errors.length>20?"\uFF08\u663E\u793A\u524D 20 \u9879\uFF09":""}\uFF1A
|
|
1
|
+
var ne=new Set(["__proto__","prototype","constructor"]),M=new Map;function j(t){if(typeof t!="string"||t.length===0)return null;let e=M.get(t);if(e!==void 0)return e;let n=t.split("."),r=n.every(o=>o.length>0&&!ne.has(o))?n:null;return t.length<=1024&&(M.size>=256&&M.delete(M.keys().next().value),M.set(t,r)),r}function E(t){return j(t)!==null}function x(t,e){if(t==null)return;let n=j(e);if(!n)return;let r=t;for(let o of n){if(r==null)return;r=r[o]}return r}function G(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function U(t,e){t.count++,!(typeof e!="number"||!Number.isFinite(e))&&(t.numeric++,t.sum+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e))}function V(t,e){return e==="count"?t?.count??0:t?.numeric?e==="min"?t.min:e==="max"?t.max:Number.isFinite(t.sum)?e==="avg"?t.sum/t.numeric:t.sum:null:null}var re=new Set(["sum","count","avg","min","max"]);function X(t){return JSON.stringify(t.map(e=>[e===null?"null":typeof e,e]))}function B(t){if(t==null)return null;if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"||typeof t=="boolean")return t;if(t instanceof Date&&!Number.isNaN(t.getTime()))return t.toISOString();throw new TypeError("Pivot dimensions must be primitive values or valid Dates")}function oe(t,e){if(t.length>1e4)throw new RangeError("Pivot supports at most 10000 input rows; aggregate remotely for larger datasets");let n=[...e.rowFields,...e.columnFields??[]];if(n.length>12||e.values.length>16||!e.values.length)throw new RangeError("Pivot supports 12 dimensions and 1\u201316 measures");for(let o of n)if(!E(o))throw new TypeError(`Invalid pivot field: ${o}`);let r=new Set;for(let o of e.values){ie(o);let i=JSON.stringify([o.field??null,o.aggregate]);if(r.has(i))throw new TypeError("Duplicate pivot measure");r.add(i)}}function ie(t){if(!re.has(t.aggregate))throw new TypeError(`Unknown pivot aggregate: ${String(t.aggregate)}`);if(t.field!=null&&!E(t.field))throw new TypeError(`Invalid pivot field: ${t.field}`);if(!t.field&&t.aggregate!=="count")throw new TypeError("Numeric pivot measures require a field")}function W(t,e,n){let r=t.get(e);r||(r=G(),t.set(e,r)),U(r,n)}function se(t,e){return JSON.stringify([t===null?"total":X(t),e.field??null,e.aggregate])}function S(t,e){oe(t,e);let n=new Map,r=new Map,o=new Map,i=e.columnFields??[];for(let s of t){let u=e.rowFields.map(p=>B(x(s,p))),f=X(u),d=n.get(f);if(d||(d={dimensions:u,cells:new Map},n.set(f,d)),n.size>2e3)throw new RangeError("Pivot supports at most 2000 result row groups");let h=i.map(p=>B(x(s,p)));for(let p of e.values){let g=p.field?x(s,p.field):void 0;z(d,r,o,h,p,g),i.length&&z(d,r,o,null,p,g)}if(r.size>128)throw new RangeError("Pivot supports at most 128 result columns")}if(!t.length&&!i.length)for(let s of e.values)Y(r,[],s);let a=[...r.values()].sort((s,u)=>Number(s.total)-Number(u.total)||s.id.localeCompare(u.id)),l=[...n.entries()].sort(([s],[u])=>s.localeCompare(u)).map(([s,u])=>({id:s,dimensions:u.dimensions,values:K(a,u.cells)}));return{columns:a,rows:l,totals:K(a,o),inputCount:t.length}}function Y(t,e,n){let r=se(e,n);if(!t.has(r)){let o=n.label??`${n.field??"\u8BB0\u5F55"} \xB7 ${n.aggregate}`,i=e===null?"\u5408\u8BA1":e.map(a=>a==null?"\u7A7A\u503C":String(a)).join(" / ");t.set(r,{id:r,label:i?`${i} / ${o}`:o,dimensions:e??[],total:e===null,measure:{...n}})}return r}function z(t,e,n,r,o,i){let a=Y(e,r,o);W(t.cells,a,i),W(n,a,i)}function K(t,e){let n=Object.create(null);for(let r of t)n[r.id]=V(e.get(r.id),r.measure.aggregate);return n}var m=class extends Error{constructor(n,r){super(r);this.code=n}},q={"+":1,"-":1,"*":2,"/":2,"%":2,"^":3},ae=new Set(["SUM","MIN","MAX","AVG"]);function le(t){if(t.length>4096)throw new m("LIMIT","Formula exceeds 4096 characters");let e=[],n=t.startsWith("=")?1:0;for(;n<t.length;){if(/\s/.test(t[n])){n++;continue}let r=ue(t.slice(n));if(e.push(r),n+=r.kind==="field"?r.value.length+2:r.value.length,e.length>256)throw new m("LIMIT","Formula exceeds 256 tokens")}return e}function ue(t){let e=/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i.exec(t);if(e)return{kind:"number",value:e[0]};let n=/^\[([^\]\r\n]+)\]/.exec(t);if(n)return{kind:"field",value:n[1]};let r=/^[A-Za-z_\u4e00-\u9fff][\w.\u4e00-\u9fff]*/.exec(t);if(r)return{kind:"name",value:r[0]};if("+-*/%^(),".includes(t[0]))return{kind:"symbol",value:t[0]};throw new m("SYNTAX",`Unexpected token: ${t.slice(0,12)}`)}function J(t){let e=le(t),n=0,r=s=>{if(e[n++]?.value!==s)throw new m("SYNTAX",`Expected ${s}`)},o=(s,u)=>{if(u>32)throw new m("LIMIT","Formula exceeds 32 nesting levels");let f=a(u);for(;n<e.length;){let d=e[n].value,h=Object.prototype.hasOwnProperty.call(q,d)?q[d]:void 0;if(h==null||h<s)break;n++;let p=o(h+(d==="^"?0:1),u+1);f={kind:"binary",operator:d,left:f,right:p}}return f},i=(s,u)=>{let f=s.toUpperCase();if(!ae.has(f))throw new m("SYNTAX",`Unsupported function: ${s}`);r("(");let d=[];if(e[n]?.value!==")")do d.push(o(0,u+1));while(e[n]?.value===","&&++n);if(r(")"),!d.length&&f!=="SUM")throw new m("SYNTAX",`${f} requires arguments`);return{kind:"call",name:f,args:d}},a=s=>{let u=e[n++];if(!u)throw new m("SYNTAX","Expected a value");if(u.kind==="number")return{kind:"number",value:Number(u.value)};if(u.kind==="field")return{kind:"field",name:u.value};if(u.kind==="name")return e[n]?.value==="("?i(u.value,s):{kind:"field",name:u.value};if(u.value==="+"||u.value==="-")return{kind:"unary",operator:u.value,operand:o(3,s+1)};if(u.value==="("){let f=o(0,s+1);return r(")"),f}throw new m("SYNTAX",`Unexpected token: ${u.value}`)},l=o(0,0);if(n!==e.length)throw new m("SYNTAX","Unexpected trailing tokens");return l}function k(t){if(!Number.isFinite(t))throw new m("NON_FINITE","Formula result is not a finite number");return t}function ce(t,e,n){if((t==="/"||t==="%")&&n===0)throw new m("DIV_ZERO","Division by zero");return t==="+"?e+n:t==="-"?e-n:t==="*"?e*n:t==="/"?e/n:t==="%"?e%n:e**n}function T(t,e){if(t.kind==="number")return k(t.value);if(t.kind==="field")return e(t.name);if(t.kind==="unary")return k((t.operator==="-"?-1:1)*T(t.operand,e));if(t.kind==="binary")return k(ce(t.operator,T(t.left,e),T(t.right,e)));let n=t.args.map(o=>T(o,e));if(t.name==="MIN")return Math.min(...n);if(t.name==="MAX")return Math.max(...n);let r=n.reduce((o,i)=>o+i,0);return k(t.name==="AVG"?r/n.length:r)}function R(t,e){let n=Object.entries(e);if(n.length>32||t.length>1e4||n.length*t.length>1e5)throw new m("LIMIT","Formulas support 32 columns, 10000 rows and 100000 result cells");let r=new Map;for(let[a,l]of n){if(!E(a)||/[.\[\]]/.test(a))throw new m("SYNTAX",`Invalid formula column: ${a}; use a single-level ID without dots or brackets`);try{r.set(a,J(l))}catch(s){r.set(a,Z(s))}}let o=[];return{rows:t.map((a,l)=>{let s={...a},u=me(a,r);for(let[f,d]of u)d instanceof m&&o.push({rowIndex:l,colId:f,code:d.code,message:d.message}),Object.defineProperty(s,f,{value:d instanceof m?null:d,enumerable:!0,configurable:!0,writable:!0});return s}),errors:o}}function Z(t){return t instanceof m?t:new m("SYNTAX",t instanceof Error?t.message:String(t))}function de(t,e){if(!E(e))throw new m("UNKNOWN_FIELD",`Unknown field: ${e}`);let n=x(t,e);if(n===void 0)throw new m("UNKNOWN_FIELD",`Unknown field: ${e}`);if(typeof n!="number")throw new m("NON_NUMERIC",`Field is not numeric: ${e}`);return k(n)}function me(t,e){let n=new Map,r=new Set,o=i=>{if(!e.has(i))return de(t,i);let a=n.get(i);if(a instanceof m)throw a;if(a!=null)return a;if(r.has(i))throw new m("CYCLE",`Cyclic formula: ${[...r,i].join(" \u2192 ")}`);r.add(i);try{let l=e.get(i);if(l instanceof m)throw l;let s=k(T(l,o));return n.set(i,s),s}catch(l){let s=Z(l);throw n.set(i,s),s}finally{r.delete(i)}};for(let i of e.keys())try{o(i)}catch{}return n}function Q(t,e){if(t.classList.add("mach-portal"),!e)return;let n=window.getComputedStyle(e);for(let r=0;r<n.length;r++){let o=n.item(r);if(!o.startsWith("--mach-"))continue;let i=n.getPropertyValue(o).trim();i&&t.style.setProperty(o,i)}t.style.colorScheme=n.colorScheme}function c(t,e,n){let r=document.createElement(t);return e&&(r.className=e),n!=null&&(r.textContent=n),r}function w(t,e,n=""){let r=c("button",`mach-workbench__button ${n}`.trim(),t);return r.type="button",r.addEventListener("click",e),r}function A(t,e,n,r){let o=c("select","mach-workbench__input");o.setAttribute("aria-label",t);for(let i of e){let a=c("option",void 0,i.label);a.value=i.value,o.append(a)}return o.value=n,o.addEventListener("change",()=>r(o.value)),o}function _(t,e){let n=[...t.querySelectorAll("button,select,input")].filter(o=>!o.disabled);(n.find(o=>o.getAttribute("aria-label")===e||o.textContent===e)??n[0])?.focus()}function ee(t,e,n,r){let o=document.activeElement,i=c("section","mach-workbench");i.setAttribute("aria-label",e),i.tabIndex=-1;let a=c("header","mach-workbench__header");a.append(c("h2","mach-workbench__title",e),w("\u5173\u95ED",n));let l=c("div","mach-workbench__body"),s=c("p","mach-workbench__status");s.setAttribute("role","status"),s.setAttribute("aria-live","polite");let u=c("footer","mach-workbench__footer");i.append(a,l,s,u);let f=v=>{v.key!=="Escape"||v.isComposing||(v.preventDefault(),v.stopPropagation(),n())};i.addEventListener("keydown",f);let d=!1,h=r.view.getRoot(),p=()=>{d||(i.dataset.theme=h?.classList.contains("mach-theme-dark")?"dark":"light",Q(i,h))},g=null;try{p(),h&&(g=new MutationObserver(p),g.observe(h,{attributes:!0,attributeFilter:["class","style"]})),t.append(i)}catch(v){throw g?.disconnect(),i.remove(),v}return{root:i,body:l,status:s,footer:u,syncTheme:p,destroy(){if(d)return;d=!0,g?.disconnect();let v=i.contains(document.activeElement);i.removeEventListener("keydown",f),i.remove(),v&&o?.isConnected&&o.focus()}}}function y(t,e,n){let r=document.createElementNS("http://www.w3.org/2000/svg",t);for(let[o,i]of Object.entries(e))r.setAttribute(o,String(i));return n!=null&&(r.textContent=n),r}function te(t,e,n){let r=c("figure","mach-analysis__chart"),o=t.columns.find(b=>b.id===e);if(!o)return r.append(c("p",void 0,"\u5C1A\u65E0\u53EF\u7ED8\u5236\u7684\u6307\u6807")),r;let i=t.rows.slice(0,40),a=`${o.label} \xB7 ${n==="bar"?"\u67F1\u72B6\u56FE":"\u6298\u7EBF\u56FE"}\uFF0C${i.length} \u7EC4`,l=y("svg",{viewBox:"0 0 680 260",role:"img","aria-label":a});l.append(y("title",{},a));let s=i.map(b=>b.values[e]).filter(b=>b!=null&&Number.isFinite(b)),u=Math.min(0,...s),f=Math.max(0,...s),d=Math.max(Math.abs(f),Math.abs(u))||1,h=f/d-u/d||1,p=b=>210-(b/d-u/d)/h*180,g=p(0);l.append(y("line",{x1:50,x2:660,y1:g,y2:g,stroke:"currentColor",opacity:".4"})),l.append(y("text",{x:2,y:25,"font-size":11},String(f)),y("text",{x:2,y:212,"font-size":11},String(u)));let v=600/Math.max(i.length,1),P=[],L=()=>{P.length&&l.append(y("polyline",{points:P.join(" "),fill:"none",stroke:"currentColor","stroke-width":2})),P=[]};return i.forEach((b,O)=>{let C=b.values[e];if(C==null){L();return}let N=55+v*(O+.5),F=p(C),I=b.dimensions.map(H=>H==null?"\u7A7A\u503C":String(H)).join(" / ")||"\u5168\u90E8",$=n==="bar"?y("rect",{x:N-v*.35,y:Math.min(g,F),width:Math.max(1,v*.7),height:Math.max(1,Math.abs(F-g)),fill:"currentColor",rx:2}):y("circle",{cx:N,cy:F,r:3,fill:"currentColor"});$.append(y("title",{},`${I}: ${C}`)),l.append($),n==="line"&&P.push(`${N},${F}`),(i.length<=10||O%Math.ceil(i.length/10)===0)&&l.append(y("text",{x:N,y:238,"text-anchor":"middle","font-size":10},I.slice(0,12)))}),L(),r.append(l,c("figcaption","mach-workbench__hint",`${a}\u3002${t.rows.length>40?"\u56FE\u8868\u4EC5\u5C55\u793A\u524D 40 \u7EC4\uFF0C":""}\u5B8C\u6574\u6570\u503C\u89C1\u4E0B\u65B9\u6570\u636E\u8868\u3002`)),r}var fe={sum:"\u6C42\u548C",count:"\u8BB0\u5F55\u6570",avg:"\u5E73\u5747\u503C",min:"\u6700\u5C0F\u503C",max:"\u6700\u5927\u503C"};function pe(t,e){return new D(t,e)}var D=class{constructor(e,n){this.options=n;this.fields=[];this.result=null;this.results=c("div","mach-analysis__results");this.page=0;this.o="bar";this.t="";this.destroyed=!1;if(n.api.isDestroyed())throw new Error("Cannot mount analysis on a destroyed grid");this.config={rowFields:[...n.pivot?.rowFields??[]],columnFields:[...n.pivot?.columnFields??[]],values:n.pivot?.values.map(r=>({...r}))??[{aggregate:"count"}]},this.formulas=Object.entries(n.formulas??{}).map(([r,o])=>({field:r,expression:o})),this.e=ee(e,"\u6570\u636E\u5206\u6790",()=>{this.destroy(),n.onClose?.()},n.api),this.e.footer.append(w("\u8FD0\u884C\u5206\u6790",()=>this.s(),"mach-workbench__button--primary")),this.i=[n.api.on("gridDestroyed",()=>this.destroy()),n.api.on("modelUpdated",()=>{!this.destroyed&&this.result&&(this.e.status.textContent="\u8868\u683C\u6570\u636E\u5DF2\u66F4\u65B0\uFF1B\u91CD\u65B0\u8FD0\u884C\u5206\u6790\u4EE5\u5237\u65B0\u7ED3\u679C\u3002")})],this.refresh(),this.s(),this.e.root.focus()}refresh(){this.a()&&(this.fields=this.l(),this.e.syncTheme(),this.e.body.replaceChildren(),this.c(),this.e.body.append(this.results),this.n())}destroy(){this.destroyed||(this.destroyed=!0,this.i.splice(0).forEach(e=>e()),this.e.destroy())}a(){return!this.destroyed&&!this.options.api.isDestroyed()}l(){let e=[],n=r=>{for(let o of r){if("children"in o){n(o.children);continue}if(!o.field)continue;let i=x(this.options.api.rows.getAt(0)?.data,o.field);e.push({field:o.field,label:o.headerName??o.field,numeric:typeof i=="number"||o.cellEditor==="number"||o.filter==="number"})}};n(this.options.api.columns.getDefinitions()??[]);for(let r of this.formulas)r.field&&!e.some(o=>o.field===r.field)&&e.push({field:r.field,label:`${r.field}\uFF08\u516C\u5F0F\uFF09`,numeric:!0});return e}c(){let e=c("div","mach-analysis__settings");e.append(this.dimensions("\u884C\u7EF4\u5EA6",this.config.rowFields,o=>{this.config.rowFields=o}),this.dimensions("\u5217\u7EF4\u5EA6",this.config.columnFields??[],o=>{this.config.columnFields=o}));let n=c("fieldset","mach-workbench__group");n.append(c("legend",void 0,"\u805A\u5408\u6307\u6807")),this.config.values.forEach((o,i)=>n.append(this.measure(o,i)));let r=w("\u6DFB\u52A0\u6307\u6807",()=>{this.config.values=[...this.config.values,{aggregate:"count"}],this.refresh()});r.disabled=this.config.values.length>=16,n.append(r),e.append(n,this.d()),this.e.body.append(e)}dimensions(e,n,r){let o=c("label","mach-analysis__dimension",e),i=c("select","mach-workbench__input");i.multiple=!0,i.setAttribute("aria-label",e);let a=[...this.fields];for(let l of n)a.some(s=>s.field===l)||a.push({field:l,label:`${l}\uFF08\u5DF2\u79FB\u9664\uFF09`,numeric:!1});for(let l of a){let s=c("option",void 0,l.label);s.value=l.field,s.selected=n.includes(l.field),i.append(s)}return i.addEventListener("change",()=>r([...i.selectedOptions].map(l=>l.value))),o.append(i,c("small","mach-workbench__hint","\u652F\u6301\u591A\u9009\uFF1B\u4E0D\u9009\u62E9\u8868\u793A\u5168\u90E8\u8BB0\u5F55\u3002")),o}measure(e,n){let r=c("div","mach-workbench__values"),o=[{value:"",label:"\u5168\u90E8\u8BB0\u5F55"},...this.fields.map(i=>({value:i.field,label:i.label}))];return e.field&&!o.some(i=>i.value===e.field)&&o.push({value:e.field,label:`${e.field}\uFF08\u5DF2\u79FB\u9664\uFF09`}),r.append(A("\u6307\u6807\u5B57\u6BB5",o,e.field??"",i=>{e.field=i||void 0}),A("\u805A\u5408\u65B9\u5F0F",Object.entries(fe).map(([i,a])=>({value:i,label:a})),e.aggregate,i=>{e.aggregate=i}),w("\u5220\u9664\u6307\u6807",()=>{this.config.values=this.config.values.filter((i,a)=>a!==n),this.refresh()})),r}d(){let e=c("fieldset","mach-workbench__group");e.append(c("legend",void 0,"\u516C\u5F0F\u5217"),c("p","mach-workbench__hint","\u4F7F\u7528 [\u5B57\u6BB5]\u3001+ - * / % ^\u3001\u62EC\u53F7\u548C SUM / MIN / MAX / AVG\u3002\u7ED3\u679C\u5217\u4F7F\u7528\u5355\u5C42 ID\uFF0C\u4E0D\u542B . \u6216 []\uFF1B\u5D4C\u5957\u8F93\u5165\u53EF\u5F15\u7528 [tax.total]\u3002\u53EA\u8BA1\u7B97\u5F53\u524D\u8BB0\u5F55\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u8DE8\u884C\u5F15\u7528\u3002")),this.formulas.forEach((r,o)=>{let i=c("div","mach-workbench__values"),a=c("input","mach-workbench__input");a.setAttribute("aria-label","\u516C\u5F0F\u7ED3\u679C\u5217"),a.placeholder="\u5982 total",a.value=r.field,a.addEventListener("input",()=>{r.field=a.value.trim()});let l=c("input","mach-workbench__input");l.setAttribute("aria-label","\u516C\u5F0F\u8868\u8FBE\u5F0F"),l.placeholder="\u5982 [quantity] * [price]",l.value=r.expression,l.addEventListener("input",()=>{r.expression=l.value}),i.append(a,l,w("\u5220\u9664\u516C\u5F0F",()=>{this.formulas.splice(o,1),this.refresh()})),e.append(i)});let n=w("\u6DFB\u52A0\u516C\u5F0F",()=>{this.formulas.push({field:"",expression:""}),this.refresh()});return n.disabled=this.formulas.length>=32,e.append(n),e}s(){if(!this.a())return;let e=[],n=0;this.options.api.rows.forEach(r=>{r.data==null||r.isGroup||r.isDetail||(n++,e.length<1e4&&e.push(r.data))});try{let r=this.m(),o=R(e,r);if(o.errors.length){let l=o.errors.slice(0,20).map(s=>`\u7B2C ${s.rowIndex+1} \u884C / ${s.colId}\uFF1A${s.code} ${s.message}`);throw new Error(`\u516C\u5F0F\u9519\u8BEF ${o.errors.length} \u9879${o.errors.length>20?"\uFF08\u663E\u793A\u524D 20 \u9879\uFF09":""}\uFF1A
|
|
2
2
|
${l.join(`
|
|
3
|
-
`)}`)}this.
|
|
3
|
+
`)}`)}this.f(r),this.result=S(o.rows,this.config),this.page=0,this.refresh();let i=this.options.api.rows.isRemote()?"\u8FDC\u7A0B\u6A21\u5F0F\u4EC5\u5305\u542B\u5DF2\u52A0\u8F7D\u884C\uFF0C\u4E0D\u4EE3\u8868\u670D\u52A1\u7AEF\u5168\u91CF\u3002":"",a=n>e.length?`\u5DF2\u52A0\u8F7D ${n} \u884C\uFF0C\u672C\u6B21\u4EC5\u5206\u6790\u524D ${e.length} \u884C\u3002`:`\u5206\u6790\u5DF2\u52A0\u8F7D\u7684 ${e.length} \u884C\u3002`;this.e.status.textContent=`${a}${i} \u751F\u6210 ${this.result.rows.length} \u4E2A\u884C\u7EC4\u3001${this.result.columns.length} \u4E2A\u7ED3\u679C\u5217\u3002`,this.e.status.classList.remove("mach-workbench__status--error"),this.e.status.setAttribute("role","status")}catch(r){this.result=null,this.results.replaceChildren(),this.e.status.textContent=r instanceof Error?r.message:String(r),this.e.status.classList.add("mach-workbench__status--error"),this.e.status.setAttribute("role","alert")}}m(){let e=Object.create(null);for(let n of this.formulas){if(!n.field||Object.prototype.hasOwnProperty.call(e,n.field))throw new Error("\u516C\u5F0F\u7ED3\u679C\u5217\u4E0D\u80FD\u4E3A\u7A7A\u6216\u91CD\u590D");e[n.field]=n.expression}return e}f(e){let n=new Set([...this.l().map(o=>o.field),...Object.keys(e)]),r=[...this.config.rowFields,...this.config.columnFields??[],...this.config.values.flatMap(o=>o.field?[o.field]:[])];for(let o of r)if(!n.has(o))throw new Error(`\u5B57\u6BB5\u5DF2\u79FB\u9664\u6216\u4E0D\u53EF\u5206\u6790\uFF1A${o}`)}n(){if(this.results.replaceChildren(),!this.result)return;let e=this.result;e.columns.some(l=>l.id===this.t)||(this.t=e.columns[0]?.id??"");let n=c("div","mach-workbench__tools");n.append(A("\u56FE\u8868\u7C7B\u578B",[{value:"bar",label:"\u67F1\u72B6\u56FE"},{value:"line",label:"\u6298\u7EBF\u56FE"}],this.o,l=>{this.o=l,this.n(),_(this.results,"\u56FE\u8868\u7C7B\u578B")}),A("\u56FE\u8868\u6307\u6807",e.columns.map(l=>({value:l.id,label:l.label})),this.t,l=>{this.t=l,this.n(),_(this.results,"\u56FE\u8868\u6307\u6807")})),this.results.append(n,te(e,this.t,this.o),this.table(e));let r=Math.max(1,Math.ceil(e.rows.length/50)),o=c("nav","mach-workbench__tools");o.setAttribute("aria-label","\u5206\u6790\u7ED3\u679C\u5206\u9875");let i=w("\u4E0A\u4E00\u9875",()=>{this.page--,this.n(),_(this.results.querySelector("nav"),"\u4E0A\u4E00\u9875")}),a=w("\u4E0B\u4E00\u9875",()=>{this.page++,this.n(),_(this.results.querySelector("nav"),"\u4E0B\u4E00\u9875")});i.disabled=this.page<=0,a.disabled=this.page>=r-1,o.append(i,c("span",void 0,`\u7B2C ${this.page+1} / ${r} \u9875 \xB7 \u6BCF\u9875 50 \u7EC4`),a),this.results.append(o)}table(e){let n=c("div","mach-analysis__table-wrap"),r=c("table","mach-analysis__table");r.append(c("caption",void 0,"\u900F\u89C6\u7ED3\u679C\u6570\u636E\u8868\uFF08\u5B8C\u6574\u7ED3\u679C\u53EF\u5206\u9875\u67E5\u770B\uFF09"));let o=c("thead"),i=c("tr");for(let s of["\u884C\u7EF4\u5EA6",...e.columns.map(u=>u.label)]){let u=c("th",void 0,s);u.scope="col",i.append(u)}o.append(i);let a=c("tbody");for(let s of e.rows.slice(this.page*50,(this.page+1)*50))a.append(this.u(s.dimensions.map(u=>u==null?"\u7A7A\u503C":String(u)).join(" / ")||"\u5168\u90E8",e,s.values));let l=c("tfoot");return l.append(this.u("\u5408\u8BA1",e,e.totals)),r.append(o,a,l),n.append(r),n}u(e,n,r){let o=c("tr"),i=c("th",void 0,e);i.scope="row",o.append(i);for(let a of n.columns){let l=r[a.id],s=c("td",void 0,l==null?"\u2014":l.toLocaleString("zh-CN",{maximumFractionDigits:6}));s.title=l==null?"\u65E0\u6570\u503C":String(l),o.append(s)}return o}};export{S as createPivot,R as evaluateFormulas,pe as mountAnalysis};
|
|
@@ -147,6 +147,16 @@ type SortDirection = "asc" | "desc";
|
|
|
147
147
|
type PinnedDirection = "left" | "right";
|
|
148
148
|
type FilterType = "text" | "number" | "date" | "set";
|
|
149
149
|
type CellAlign = "left" | "center" | "right";
|
|
150
|
+
type ValueInputSource = "editor" | "clipboard" | "import";
|
|
151
|
+
type ValueOutputTarget = "clipboard" | "csv" | "xlsx";
|
|
152
|
+
interface ValueParserParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
|
|
153
|
+
value: unknown;
|
|
154
|
+
oldValue: TValue | undefined;
|
|
155
|
+
source: ValueInputSource;
|
|
156
|
+
}
|
|
157
|
+
interface ValueSerializerParams<TData = any, TValue = any> extends ValueFormatterParams<TData, TValue> {
|
|
158
|
+
target: ValueOutputTarget;
|
|
159
|
+
}
|
|
150
160
|
type TextFilterMatch = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
|
|
151
161
|
type NumberFilterMatch = "equals" | "notEquals" | "lessThan" | "lessThanOrEqual" | "greaterThan" | "greaterThanOrEqual" | "inRange" | "blank" | "notBlank";
|
|
152
162
|
type DateFilterMatch = "equals" | "notEquals" | "lessThan" | "greaterThan" | "inRange" | "blank" | "notBlank";
|
|
@@ -255,6 +265,10 @@ interface ColDef<TData = any, TValue = any> {
|
|
|
255
265
|
rowDrag?: boolean;
|
|
256
266
|
valueGetter?: (params: ValueGetterParams<TData, TValue>) => TValue;
|
|
257
267
|
valueSetter?: (params: ValueSetterParams<TData, TValue>) => boolean;
|
|
268
|
+
/** Synchronous user-input normalization. Not called by trusted transactions or undo replay. */
|
|
269
|
+
valueParser?: (params: ValueParserParams<TData, TValue>) => TValue;
|
|
270
|
+
/** Clipboard/file output; display formatting and sort/filter continue to use stored values. */
|
|
271
|
+
valueSerializer?: (params: ValueSerializerParams<TData, TValue>) => unknown;
|
|
258
272
|
valueFormatter?: (params: ValueFormatterParams<TData, TValue>) => any;
|
|
259
273
|
cellRenderer?: CellRendererFn | string;
|
|
260
274
|
cellRendererParams?: Record<string, any>;
|
|
@@ -740,7 +754,7 @@ interface GridDataProcessorResult {
|
|
|
740
754
|
/** Filtered and sorted stable row IDs, in final display order. */
|
|
741
755
|
rowIds: readonly string[];
|
|
742
756
|
}
|
|
743
|
-
/** Optional async/Worker boundary
|
|
757
|
+
/** Optional async/Worker boundary. Each instance is owned and destroyed by exactly one grid. */
|
|
744
758
|
interface GridDataProcessor<TData = any> {
|
|
745
759
|
process(request: GridDataProcessorRequest<TData>): Promise<GridDataProcessorResult>;
|
|
746
760
|
destroy?(): void;
|
|
@@ -941,8 +955,8 @@ interface GridOptions<TData = any> extends EventHandlers<TData> {
|
|
|
941
955
|
blockPrefetch?: number;
|
|
942
956
|
/** Optional initial total enables immediate scrollbar range before the first response. */
|
|
943
957
|
datasourceRowCount?: number;
|
|
944
|
-
/**
|
|
945
|
-
dataProcessor?: GridDataProcessor<TData
|
|
958
|
+
/** Per-grid processor or factory. Reusable application defaults must use a factory returning a fresh instance. */
|
|
959
|
+
dataProcessor?: GridDataProcessor<TData> | (() => GridDataProcessor<TData>);
|
|
946
960
|
/** Minimum local row count before dataProcessor is used. Defaults to 5,000. */
|
|
947
961
|
dataProcessorMinRows?: number;
|
|
948
962
|
/** Number of automatic retries after an infinite datasource request fails. */
|
|
@@ -1104,6 +1118,24 @@ interface ImportCsvOptions {
|
|
|
1104
1118
|
columnIndex: number;
|
|
1105
1119
|
}) => any;
|
|
1106
1120
|
}
|
|
1121
|
+
interface ImportMatrixOptions {
|
|
1122
|
+
mode?: "replace" | "append" | "paste";
|
|
1123
|
+
/** -1 means no header. Explicit columns default to -1; otherwise the first row is a header. */
|
|
1124
|
+
headerRowIndex?: number;
|
|
1125
|
+
/** Explicit destination column IDs/fields, in matrix order. */
|
|
1126
|
+
columns?: readonly string[];
|
|
1127
|
+
coerceNumbers?: boolean;
|
|
1128
|
+
/** Per-operation override; takes priority over the column parser. */
|
|
1129
|
+
parseValue?: (params: {
|
|
1130
|
+
value: unknown;
|
|
1131
|
+
field: string;
|
|
1132
|
+
rowIndex: number;
|
|
1133
|
+
columnIndex: number;
|
|
1134
|
+
}) => any;
|
|
1135
|
+
}
|
|
1136
|
+
interface MatrixExportParams extends CsvExportParams {
|
|
1137
|
+
target?: "csv" | "xlsx";
|
|
1138
|
+
}
|
|
1107
1139
|
interface PrintOptions {
|
|
1108
1140
|
title?: string;
|
|
1109
1141
|
includeHeader?: boolean;
|
|
@@ -1336,6 +1368,9 @@ interface GridViewApi<TData = any> {
|
|
|
1336
1368
|
interface GridIoApi {
|
|
1337
1369
|
exportCsv(params?: CsvExportParams): string;
|
|
1338
1370
|
importCsv(text: string, options?: ImportCsvOptions): boolean;
|
|
1371
|
+
exportMatrix(params?: MatrixExportParams): unknown[][];
|
|
1372
|
+
/** Synchronous result: replace/append load parser-normalized records; paste starts interactive validation, which may finish later. */
|
|
1373
|
+
importMatrix(rows: readonly (readonly unknown[])[], options?: ImportMatrixOptions): boolean;
|
|
1339
1374
|
print(options?: PrintOptions): boolean;
|
|
1340
1375
|
copyRange(): Promise<boolean>;
|
|
1341
1376
|
}
|
|
@@ -1388,4 +1423,4 @@ interface GridApi<TData = any> {
|
|
|
1388
1423
|
isDestroyed(): boolean;
|
|
1389
1424
|
}
|
|
1390
1425
|
|
|
1391
|
-
export {
|
|
1426
|
+
export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ValueOutputTarget as V, type ColumnLayoutMode as W, type ColumnMovedEvent as X, type ColumnResizedEvent as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueParserParams as bI, type ValueSerializerParams as bJ, type ValueSetterParams as bK, type WatermarkConfig as bL, formatText as bM, formatTwo as bN, isColDefGroup as bO, matchLocaleKey as bP, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type GridEventType as j, type SaveChangesHandler as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
|
|
@@ -147,6 +147,16 @@ type SortDirection = "asc" | "desc";
|
|
|
147
147
|
type PinnedDirection = "left" | "right";
|
|
148
148
|
type FilterType = "text" | "number" | "date" | "set";
|
|
149
149
|
type CellAlign = "left" | "center" | "right";
|
|
150
|
+
type ValueInputSource = "editor" | "clipboard" | "import";
|
|
151
|
+
type ValueOutputTarget = "clipboard" | "csv" | "xlsx";
|
|
152
|
+
interface ValueParserParams<TData = any, TValue = any> extends ValueGetterParams<TData, TValue> {
|
|
153
|
+
value: unknown;
|
|
154
|
+
oldValue: TValue | undefined;
|
|
155
|
+
source: ValueInputSource;
|
|
156
|
+
}
|
|
157
|
+
interface ValueSerializerParams<TData = any, TValue = any> extends ValueFormatterParams<TData, TValue> {
|
|
158
|
+
target: ValueOutputTarget;
|
|
159
|
+
}
|
|
150
160
|
type TextFilterMatch = "contains" | "notContains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "blank" | "notBlank";
|
|
151
161
|
type NumberFilterMatch = "equals" | "notEquals" | "lessThan" | "lessThanOrEqual" | "greaterThan" | "greaterThanOrEqual" | "inRange" | "blank" | "notBlank";
|
|
152
162
|
type DateFilterMatch = "equals" | "notEquals" | "lessThan" | "greaterThan" | "inRange" | "blank" | "notBlank";
|
|
@@ -255,6 +265,10 @@ interface ColDef<TData = any, TValue = any> {
|
|
|
255
265
|
rowDrag?: boolean;
|
|
256
266
|
valueGetter?: (params: ValueGetterParams<TData, TValue>) => TValue;
|
|
257
267
|
valueSetter?: (params: ValueSetterParams<TData, TValue>) => boolean;
|
|
268
|
+
/** Synchronous user-input normalization. Not called by trusted transactions or undo replay. */
|
|
269
|
+
valueParser?: (params: ValueParserParams<TData, TValue>) => TValue;
|
|
270
|
+
/** Clipboard/file output; display formatting and sort/filter continue to use stored values. */
|
|
271
|
+
valueSerializer?: (params: ValueSerializerParams<TData, TValue>) => unknown;
|
|
258
272
|
valueFormatter?: (params: ValueFormatterParams<TData, TValue>) => any;
|
|
259
273
|
cellRenderer?: CellRendererFn | string;
|
|
260
274
|
cellRendererParams?: Record<string, any>;
|
|
@@ -740,7 +754,7 @@ interface GridDataProcessorResult {
|
|
|
740
754
|
/** Filtered and sorted stable row IDs, in final display order. */
|
|
741
755
|
rowIds: readonly string[];
|
|
742
756
|
}
|
|
743
|
-
/** Optional async/Worker boundary
|
|
757
|
+
/** Optional async/Worker boundary. Each instance is owned and destroyed by exactly one grid. */
|
|
744
758
|
interface GridDataProcessor<TData = any> {
|
|
745
759
|
process(request: GridDataProcessorRequest<TData>): Promise<GridDataProcessorResult>;
|
|
746
760
|
destroy?(): void;
|
|
@@ -941,8 +955,8 @@ interface GridOptions<TData = any> extends EventHandlers<TData> {
|
|
|
941
955
|
blockPrefetch?: number;
|
|
942
956
|
/** Optional initial total enables immediate scrollbar range before the first response. */
|
|
943
957
|
datasourceRowCount?: number;
|
|
944
|
-
/**
|
|
945
|
-
dataProcessor?: GridDataProcessor<TData
|
|
958
|
+
/** Per-grid processor or factory. Reusable application defaults must use a factory returning a fresh instance. */
|
|
959
|
+
dataProcessor?: GridDataProcessor<TData> | (() => GridDataProcessor<TData>);
|
|
946
960
|
/** Minimum local row count before dataProcessor is used. Defaults to 5,000. */
|
|
947
961
|
dataProcessorMinRows?: number;
|
|
948
962
|
/** Number of automatic retries after an infinite datasource request fails. */
|
|
@@ -1104,6 +1118,24 @@ interface ImportCsvOptions {
|
|
|
1104
1118
|
columnIndex: number;
|
|
1105
1119
|
}) => any;
|
|
1106
1120
|
}
|
|
1121
|
+
interface ImportMatrixOptions {
|
|
1122
|
+
mode?: "replace" | "append" | "paste";
|
|
1123
|
+
/** -1 means no header. Explicit columns default to -1; otherwise the first row is a header. */
|
|
1124
|
+
headerRowIndex?: number;
|
|
1125
|
+
/** Explicit destination column IDs/fields, in matrix order. */
|
|
1126
|
+
columns?: readonly string[];
|
|
1127
|
+
coerceNumbers?: boolean;
|
|
1128
|
+
/** Per-operation override; takes priority over the column parser. */
|
|
1129
|
+
parseValue?: (params: {
|
|
1130
|
+
value: unknown;
|
|
1131
|
+
field: string;
|
|
1132
|
+
rowIndex: number;
|
|
1133
|
+
columnIndex: number;
|
|
1134
|
+
}) => any;
|
|
1135
|
+
}
|
|
1136
|
+
interface MatrixExportParams extends CsvExportParams {
|
|
1137
|
+
target?: "csv" | "xlsx";
|
|
1138
|
+
}
|
|
1107
1139
|
interface PrintOptions {
|
|
1108
1140
|
title?: string;
|
|
1109
1141
|
includeHeader?: boolean;
|
|
@@ -1336,6 +1368,9 @@ interface GridViewApi<TData = any> {
|
|
|
1336
1368
|
interface GridIoApi {
|
|
1337
1369
|
exportCsv(params?: CsvExportParams): string;
|
|
1338
1370
|
importCsv(text: string, options?: ImportCsvOptions): boolean;
|
|
1371
|
+
exportMatrix(params?: MatrixExportParams): unknown[][];
|
|
1372
|
+
/** Synchronous result: replace/append load parser-normalized records; paste starts interactive validation, which may finish later. */
|
|
1373
|
+
importMatrix(rows: readonly (readonly unknown[])[], options?: ImportMatrixOptions): boolean;
|
|
1339
1374
|
print(options?: PrintOptions): boolean;
|
|
1340
1375
|
copyRange(): Promise<boolean>;
|
|
1341
1376
|
}
|
|
@@ -1388,4 +1423,4 @@ interface GridApi<TData = any> {
|
|
|
1388
1423
|
isDestroyed(): boolean;
|
|
1389
1424
|
}
|
|
1390
1425
|
|
|
1391
|
-
export {
|
|
1426
|
+
export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ValueOutputTarget as V, type ColumnLayoutMode as W, type ColumnMovedEvent as X, type ColumnResizedEvent as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueParserParams as bI, type ValueSerializerParams as bJ, type ValueSetterParams as bK, type WatermarkConfig as bL, formatText as bM, formatTwo as bN, isColDefGroup as bO, matchLocaleKey as bP, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type GridEventType as j, type SaveChangesHandler as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var o in e)T(t,o,{get:e[o],enumerable:!0})},R=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!E.call(t,r)&&r!==o&&T(t,r,{get:()=>e[r],enumerable:!(a=C(e,r))||a.enumerable});return t};var O=t=>R(T({},"__esModule",{value:!0}),t);var A={};N(A,{createDictionaryColumn:()=>V,summarizeRows:()=>k});module.exports=O(A);var f=Symbol("ambiguous dictionary input");function p(t,e,o){let a=t.get(e);t.set(e,a!==void 0&&a!==o?f:o)}function z(t,e){return t===void 0?e:e===void 0||e===t?t:f}function V(t,e={}){let o=[],a=o,r=new Map,i=new Map,u=new Map,s=new Map,g=()=>{let n=typeof e.options=="function"?e.options():e.options??o;if(n===a)return;let y=new Map(n.map(m=>[m.value,m])),c=new Map,l=new Map,K=new Map;for(let[m,w]of y)p(c,String(m),m),p(l,w.label,m),p(K,`${String(m)} \xB7 ${w.label}`,m);a=n,r=y,i=c,u=l,s=K},b=n=>typeof n=="string"||typeof n=="number",h=n=>(g(),t.get(n)??r.get(n)?.label),D=(n,y)=>{if(n==null||n==="")return"";if(!b(n))return typeof n=="boolean"?String(n):"";let c=String(n);if(y==="code")return c;let l=h(n);return l===void 0?c:y==="label"?l:`${c} \xB7 ${l}`},x=n=>{if(!b(n)||n===""||(g(),r.has(n)||t.get(n)!==void 0||typeof n!="string"))return n;let y=i.get(n)??z(u.get(n),s.get(n));if(y===f)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${n}`);return y??n};return{valueFormatter:({value:n})=>D(n,e.display??"label"),valueParser:({value:n})=>x(n),valueSerializer:({value:n,target:y})=>{let c=e.output?.[y]??"code";return c==="code"?n:D(n,c)}}}function S(t){if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>Number.MAX_SAFE_INTEGER)throw new TypeError("[MachTable] Summary arithmetic requires finite numbers within the safe range; provide numeric for decimal strings or exact arithmetic.");return t}function d(t){if(t!=null&&typeof t.then=="function")throw Promise.resolve(t).catch(()=>{}),new TypeError("[MachTable] Summary numeric callbacks must return synchronous values.");return t}var G={zero:()=>0,add:(t,e)=>S(t+S(e)),divide:(t,e)=>e===0?null:S(t/e)};function M(t,e){let o=new Map;for(let a of t)(a.kind==="sum"||a.kind==="ratio")&&o.set(a.id,{value:d(e.zero()),denominator:d(e.zero())});return{rowCount:0,totals:o}}function $(t,e,o,a){e.rowCount++;for(let r of o){if(r.kind==="count"||r.kind==="none")continue;let i=e.totals.get(r.id),u=r.kind==="sum"?r.value(t):r.numerator(t);if(u!=null&&u!==""&&(i.value=d(a.add(i.value,u))),r.kind==="ratio"){let s=r.denominator(t);s!=null&&s!==""&&(i.denominator=d(a.add(i.denominator,s)))}}}function v(t,e,o){let a=Object.create(null);for(let r of e)if(r.kind!=="none")if(r.kind==="count")a[r.id]=t.rowCount;else{let i=t.totals.get(r.id);a[r.id]=r.kind==="sum"?i.value:d(o.divide(i.value,i.denominator))}return a}function k(t,e){let o=new Set;for(let i of e.metrics){if(!i.id||o.has(i.id))throw new TypeError("[MachTable] Summary metric IDs must be non-empty and unique.");o.add(i.id)}let a=e.numeric??G,r=new Map;e.groupBy||r.set(void 0,M(e.metrics,a));for(let i of t){let u=e.groupBy?.(i);if(e.groupBy&&typeof u!="string"&&(typeof u!="number"||!Number.isFinite(u)))throw new TypeError("[MachTable] Summary group keys must be strings or finite numbers.");let s=r.get(u);s||(s=M(e.metrics,a),r.set(u,s)),$(i,s,e.metrics,a)}return{scope:e.scope,groups:[...r].map(([i,u])=>({key:i,rowCount:u.rowCount,values:v(u,e.metrics,a)}))}}0&&(module.exports={createDictionaryColumn,summarizeRows});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { V as ValueOutputTarget, C as ColDef } from './api-CfZinb9Q.cjs';
|
|
2
|
+
import { D as DictionaryKey, a as DictionaryEntry } from './cachedDictionary-HXvqrDI0.cjs';
|
|
3
|
+
|
|
4
|
+
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
+
interface DictionaryColumnSource<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
get(key: TKey): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface DictionaryColumnOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
10
|
+
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
+
options?: readonly DictionaryEntry<TKey>[] | (() => readonly DictionaryEntry<TKey>[]);
|
|
12
|
+
display?: DictionaryDisplay;
|
|
13
|
+
/** Omitted targets preserve the original code and its type. */
|
|
14
|
+
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
|
+
}
|
|
16
|
+
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
+
declare function createDictionaryColumn<TData = any, TKey extends DictionaryKey = DictionaryKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
|
+
|
|
19
|
+
type SummaryScope = "page" | "selected" | "query";
|
|
20
|
+
type SemanticSummaryMetric<TData> = {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: "sum";
|
|
23
|
+
value(row: TData): unknown;
|
|
24
|
+
} | {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: "count";
|
|
27
|
+
} | {
|
|
28
|
+
id: string;
|
|
29
|
+
kind: "ratio";
|
|
30
|
+
numerator(row: TData): unknown;
|
|
31
|
+
denominator(row: TData): unknown;
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: "none";
|
|
35
|
+
};
|
|
36
|
+
/** Inject existing decimal arithmetic here; validation and divide-by-zero policy belong to the adapter. */
|
|
37
|
+
interface SummaryNumericStrategy<TValue> {
|
|
38
|
+
zero(): TValue;
|
|
39
|
+
add(total: TValue, value: unknown): TValue;
|
|
40
|
+
divide(numerator: TValue, denominator: TValue): TValue | null;
|
|
41
|
+
}
|
|
42
|
+
interface SemanticSummaryOptions<TData, TValue = number> {
|
|
43
|
+
/** Describes rows supplied by the caller; "query" never fetches more rows. */
|
|
44
|
+
scope: SummaryScope;
|
|
45
|
+
metrics: readonly SemanticSummaryMetric<TData>[];
|
|
46
|
+
/** Stable currency/unit composition is an application decision; typed keys stay distinct. */
|
|
47
|
+
groupBy?: (row: TData) => string | number;
|
|
48
|
+
numeric?: SummaryNumericStrategy<TValue>;
|
|
49
|
+
}
|
|
50
|
+
interface SemanticSummaryResult<TValue = number> {
|
|
51
|
+
scope: SummaryScope;
|
|
52
|
+
groups: Array<{
|
|
53
|
+
key: string | number | undefined;
|
|
54
|
+
rowCount: number;
|
|
55
|
+
values: Record<string, TValue | number | null>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** O(rows × metrics) local aggregation, with explicit scope and no implicit currency/unit mixing. */
|
|
59
|
+
declare function summarizeRows<TData, TValue = number>(rows: readonly TData[], options: SemanticSummaryOptions<TData, TValue>): SemanticSummaryResult<TValue>;
|
|
60
|
+
|
|
61
|
+
export { type DictionaryColumnOptions, type DictionaryColumnSource, type DictionaryDisplay, type SemanticSummaryMetric, type SemanticSummaryOptions, type SemanticSummaryResult, type SummaryNumericStrategy, type SummaryScope, createDictionaryColumn, summarizeRows };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { V as ValueOutputTarget, C as ColDef } from './api-CfZinb9Q.js';
|
|
2
|
+
import { D as DictionaryKey, a as DictionaryEntry } from './cachedDictionary-HXvqrDI0.js';
|
|
3
|
+
|
|
4
|
+
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
+
interface DictionaryColumnSource<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
get(key: TKey): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface DictionaryColumnOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
10
|
+
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
+
options?: readonly DictionaryEntry<TKey>[] | (() => readonly DictionaryEntry<TKey>[]);
|
|
12
|
+
display?: DictionaryDisplay;
|
|
13
|
+
/** Omitted targets preserve the original code and its type. */
|
|
14
|
+
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
|
+
}
|
|
16
|
+
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
+
declare function createDictionaryColumn<TData = any, TKey extends DictionaryKey = DictionaryKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
|
+
|
|
19
|
+
type SummaryScope = "page" | "selected" | "query";
|
|
20
|
+
type SemanticSummaryMetric<TData> = {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: "sum";
|
|
23
|
+
value(row: TData): unknown;
|
|
24
|
+
} | {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: "count";
|
|
27
|
+
} | {
|
|
28
|
+
id: string;
|
|
29
|
+
kind: "ratio";
|
|
30
|
+
numerator(row: TData): unknown;
|
|
31
|
+
denominator(row: TData): unknown;
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: "none";
|
|
35
|
+
};
|
|
36
|
+
/** Inject existing decimal arithmetic here; validation and divide-by-zero policy belong to the adapter. */
|
|
37
|
+
interface SummaryNumericStrategy<TValue> {
|
|
38
|
+
zero(): TValue;
|
|
39
|
+
add(total: TValue, value: unknown): TValue;
|
|
40
|
+
divide(numerator: TValue, denominator: TValue): TValue | null;
|
|
41
|
+
}
|
|
42
|
+
interface SemanticSummaryOptions<TData, TValue = number> {
|
|
43
|
+
/** Describes rows supplied by the caller; "query" never fetches more rows. */
|
|
44
|
+
scope: SummaryScope;
|
|
45
|
+
metrics: readonly SemanticSummaryMetric<TData>[];
|
|
46
|
+
/** Stable currency/unit composition is an application decision; typed keys stay distinct. */
|
|
47
|
+
groupBy?: (row: TData) => string | number;
|
|
48
|
+
numeric?: SummaryNumericStrategy<TValue>;
|
|
49
|
+
}
|
|
50
|
+
interface SemanticSummaryResult<TValue = number> {
|
|
51
|
+
scope: SummaryScope;
|
|
52
|
+
groups: Array<{
|
|
53
|
+
key: string | number | undefined;
|
|
54
|
+
rowCount: number;
|
|
55
|
+
values: Record<string, TValue | number | null>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** O(rows × metrics) local aggregation, with explicit scope and no implicit currency/unit mixing. */
|
|
59
|
+
declare function summarizeRows<TData, TValue = number>(rows: readonly TData[], options: SemanticSummaryOptions<TData, TValue>): SemanticSummaryResult<TValue>;
|
|
60
|
+
|
|
61
|
+
export { type DictionaryColumnOptions, type DictionaryColumnSource, type DictionaryDisplay, type SemanticSummaryMetric, type SemanticSummaryOptions, type SemanticSummaryResult, type SummaryNumericStrategy, type SummaryScope, createDictionaryColumn, summarizeRows };
|
package/dist/business.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Symbol("ambiguous dictionary input");function T(n,t,i){let a=n.get(t);n.set(t,a!==void 0&&a!==i?p:i)}function k(n,t){return n===void 0?t:t===void 0||t===n?n:p}function h(n,t={}){let i=[],a=i,r=new Map,o=new Map,u=new Map,s=new Map,S=()=>{let e=typeof t.options=="function"?t.options():t.options??i;if(e===a)return;let y=new Map(e.map(m=>[m.value,m])),c=new Map,l=new Map,D=new Map;for(let[m,K]of y)T(c,String(m),m),T(l,K.label,m),T(D,`${String(m)} \xB7 ${K.label}`,m);a=e,r=y,o=c,u=l,s=D},g=e=>typeof e=="string"||typeof e=="number",V=e=>(S(),n.get(e)??r.get(e)?.label),b=(e,y)=>{if(e==null||e==="")return"";if(!g(e))return typeof e=="boolean"?String(e):"";let c=String(e);if(y==="code")return c;let l=V(e);return l===void 0?c:y==="label"?l:`${c} \xB7 ${l}`},M=e=>{if(!g(e)||e===""||(S(),r.has(e)||n.get(e)!==void 0||typeof e!="string"))return e;let y=o.get(e)??k(u.get(e),s.get(e));if(y===p)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${e}`);return y??e};return{valueFormatter:({value:e})=>b(e,t.display??"label"),valueParser:({value:e})=>M(e),valueSerializer:({value:e,target:y})=>{let c=t.output?.[y]??"code";return c==="code"?e:b(e,c)}}}function f(n){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>Number.MAX_SAFE_INTEGER)throw new TypeError("[MachTable] Summary arithmetic requires finite numbers within the safe range; provide numeric for decimal strings or exact arithmetic.");return n}function d(n){if(n!=null&&typeof n.then=="function")throw Promise.resolve(n).catch(()=>{}),new TypeError("[MachTable] Summary numeric callbacks must return synchronous values.");return n}var x={zero:()=>0,add:(n,t)=>f(n+f(t)),divide:(n,t)=>t===0?null:f(n/t)};function w(n,t){let i=new Map;for(let a of n)(a.kind==="sum"||a.kind==="ratio")&&i.set(a.id,{value:d(t.zero()),denominator:d(t.zero())});return{rowCount:0,totals:i}}function C(n,t,i,a){t.rowCount++;for(let r of i){if(r.kind==="count"||r.kind==="none")continue;let o=t.totals.get(r.id),u=r.kind==="sum"?r.value(n):r.numerator(n);if(u!=null&&u!==""&&(o.value=d(a.add(o.value,u))),r.kind==="ratio"){let s=r.denominator(n);s!=null&&s!==""&&(o.denominator=d(a.add(o.denominator,s)))}}}function P(n,t,i){let a=Object.create(null);for(let r of t)if(r.kind!=="none")if(r.kind==="count")a[r.id]=n.rowCount;else{let o=n.totals.get(r.id);a[r.id]=r.kind==="sum"?o.value:d(i.divide(o.value,o.denominator))}return a}function E(n,t){let i=new Set;for(let o of t.metrics){if(!o.id||i.has(o.id))throw new TypeError("[MachTable] Summary metric IDs must be non-empty and unique.");i.add(o.id)}let a=t.numeric??x,r=new Map;t.groupBy||r.set(void 0,w(t.metrics,a));for(let o of n){let u=t.groupBy?.(o);if(t.groupBy&&typeof u!="string"&&(typeof u!="number"||!Number.isFinite(u)))throw new TypeError("[MachTable] Summary group keys must be strings or finite numbers.");let s=r.get(u);s||(s=w(t.metrics,a),r.set(u,s)),C(o,s,t.metrics,a)}return{scope:t.scope,groups:[...r].map(([o,u])=>({key:o,rowCount:u.rowCount,values:P(u,t.metrics,a)}))}}export{h as createDictionaryColumn,E as summarizeRows};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type DictionaryKey = string | number;
|
|
2
|
+
interface DictionaryEntry<TKey extends DictionaryKey = DictionaryKey> {
|
|
3
|
+
value: TKey;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
interface CachedDictionaryOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
load(keys: readonly TKey[], signal: AbortSignal): Promise<readonly DictionaryEntry<TKey>[]>;
|
|
8
|
+
/** Positive values expire labels and missing keys; 0 caches until invalidation. */
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
/** LRU capacity shared by resolved labels and missing keys. */
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
batchDelayMs?: number;
|
|
13
|
+
onError?(error: unknown, keys: readonly TKey[]): void;
|
|
14
|
+
}
|
|
15
|
+
interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
16
|
+
get(key: TKey): string | undefined;
|
|
17
|
+
resolve(key: TKey): Promise<string | undefined>;
|
|
18
|
+
resolveMany(keys: readonly TKey[]): Promise<ReadonlyMap<TKey, string>>;
|
|
19
|
+
/** Explicit entries supersede queued/in-flight work for the same keys. */
|
|
20
|
+
prime(entries: readonly DictionaryEntry<TKey>[]): void;
|
|
21
|
+
/** Evicts keys and settles their pending lookups with undefined; later resolves load anew. */
|
|
22
|
+
invalidate(keys?: readonly TKey[]): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
/** Cached labels and missing keys, bounded by maxSize. */
|
|
25
|
+
readonly size: number;
|
|
26
|
+
}
|
|
27
|
+
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
|
+
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
|
+
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type DictionaryEntry as a, type CachedDictionaryOptions as b, createCachedDictionary as c };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type DictionaryKey = string | number;
|
|
2
|
+
interface DictionaryEntry<TKey extends DictionaryKey = DictionaryKey> {
|
|
3
|
+
value: TKey;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
interface CachedDictionaryOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
load(keys: readonly TKey[], signal: AbortSignal): Promise<readonly DictionaryEntry<TKey>[]>;
|
|
8
|
+
/** Positive values expire labels and missing keys; 0 caches until invalidation. */
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
/** LRU capacity shared by resolved labels and missing keys. */
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
batchDelayMs?: number;
|
|
13
|
+
onError?(error: unknown, keys: readonly TKey[]): void;
|
|
14
|
+
}
|
|
15
|
+
interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
16
|
+
get(key: TKey): string | undefined;
|
|
17
|
+
resolve(key: TKey): Promise<string | undefined>;
|
|
18
|
+
resolveMany(keys: readonly TKey[]): Promise<ReadonlyMap<TKey, string>>;
|
|
19
|
+
/** Explicit entries supersede queued/in-flight work for the same keys. */
|
|
20
|
+
prime(entries: readonly DictionaryEntry<TKey>[]): void;
|
|
21
|
+
/** Evicts keys and settles their pending lookups with undefined; later resolves load anew. */
|
|
22
|
+
invalidate(keys?: readonly TKey[]): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
/** Cached labels and missing keys, bounded by maxSize. */
|
|
25
|
+
readonly size: number;
|
|
26
|
+
}
|
|
27
|
+
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
|
+
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
|
+
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type DictionaryEntry as a, type CachedDictionaryOptions as b, createCachedDictionary as c };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { c as GridOptions, C as ColDef,
|
|
1
|
+
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-CfZinb9Q.cjs';
|
|
2
2
|
|
|
3
3
|
type MachTablePresetSelection = string | readonly string[] | false;
|
|
4
4
|
type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
|
|
5
5
|
/** Safe application/preset defaults. Data, request state and persistence identity stay per table. */
|
|
6
|
-
type MachTableDefaults = Omit<Partial<GridOptions<any>>, MachTableInstanceOptionKey
|
|
6
|
+
type MachTableDefaults = Omit<Partial<GridOptions<any>>, MachTableInstanceOptionKey | "dataProcessor"> & {
|
|
7
|
+
/** Called once for each grid; a processor instance belongs to only that grid. */
|
|
8
|
+
dataProcessor?: () => GridDataProcessor<any>;
|
|
9
|
+
};
|
|
7
10
|
type MachTablePreset = MachTableDefaults;
|
|
8
11
|
interface MachTableConfigWarning {
|
|
9
12
|
code: "UNKNOWN_PRESET" | "INVALID_DEFAULT_OPTION" | "INVALID_PRESET_OPTION";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { c as GridOptions, C as ColDef,
|
|
1
|
+
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-CfZinb9Q.js';
|
|
2
2
|
|
|
3
3
|
type MachTablePresetSelection = string | readonly string[] | false;
|
|
4
4
|
type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
|
|
5
5
|
/** Safe application/preset defaults. Data, request state and persistence identity stay per table. */
|
|
6
|
-
type MachTableDefaults = Omit<Partial<GridOptions<any>>, MachTableInstanceOptionKey
|
|
6
|
+
type MachTableDefaults = Omit<Partial<GridOptions<any>>, MachTableInstanceOptionKey | "dataProcessor"> & {
|
|
7
|
+
/** Called once for each grid; a processor instance belongs to only that grid. */
|
|
8
|
+
dataProcessor?: () => GridDataProcessor<any>;
|
|
9
|
+
};
|
|
7
10
|
type MachTablePreset = MachTableDefaults;
|
|
8
11
|
interface MachTableConfigWarning {
|
|
9
12
|
code: "UNKNOWN_PRESET" | "INVALID_DEFAULT_OPTION" | "INVALID_PRESET_OPTION";
|