@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/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# @agile-team/mach-table
|
|
6
6
|
|
|
7
|
-
MachTable 0.
|
|
7
|
+
MachTable 0.34.0 的框架无关 TypeScript Core:零运行时依赖,提供行列双虚拟化、领域化 API、单元格/整行编辑、树与分组、随机访问远程数据、区段隔离状态持久化和可诊断扩展系统。本版新增可选 `/business` 的字典列策略与本地语义合计,完善字典缓存的请求复用、失效代次、缺失项缓存与销毁边界;普通根入口 API 和既有默认行为保持兼容。
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add @agile-team/mach-table
|
|
@@ -82,7 +82,7 @@ const options: GridOptions<Plan> = {
|
|
|
82
82
|
|
|
83
83
|
文档:[快速开始](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/getting-started.md) · [企业接入](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/enterprise-integration.md) · [API](https://github.com/ChenyCHENYU/MachTable/tree/main/docs/api)
|
|
84
84
|
|
|
85
|
-
## 按需高级入口(0.
|
|
85
|
+
## 按需高级入口(0.34)
|
|
86
86
|
|
|
87
87
|
仍从本包导入,无需另装高级功能包。普通根入口不加载这些实现或附加 CSS。
|
|
88
88
|
|
|
@@ -93,6 +93,8 @@ const options: GridOptions<Plan> = {
|
|
|
93
93
|
| `/ordering` | 多行/树移动、防环与业务约束、失败回滚、持久化撤销/重做 |
|
|
94
94
|
| `/server-side` | 服务端分组/聚合、route 分页、缓存/刷新/事务及层级选择 |
|
|
95
95
|
| `/multi-range` | Ctrl/Cmd 追加范围、格式化复制、校验清空及撤销 |
|
|
96
|
+
| `/import` | 有界数据预览、共享同步/异步校验、结构化错误与过期保护 |
|
|
97
|
+
| `/business` | 显式字典显示/解析/输出策略、范围与币种/单位分组的本地语义合计 |
|
|
96
98
|
| `/analysis` | Pivot、安全公式、柱/折线图和数据表回退 |
|
|
97
99
|
|
|
98
100
|
```ts
|
|
@@ -109,3 +111,32 @@ filters.destroy();
|
|
|
109
111
|
完整示例与限制:[工作台](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/workbench.md) · [排序](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/row-presentation.md) · [企业偏好](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/enterprise-preferences.md) · [服务端 Store](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/server-side-store.md) · [多范围](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/multi-range.md) · [分析](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/analysis.md)。
|
|
110
112
|
|
|
111
113
|
Source-available © ChenyCHENYU (Agile Team). 任何使用均须事先取得书面授权。详见 [LICENSE](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSE) 与[授权流程](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSING.md)。
|
|
114
|
+
|
|
115
|
+
## 0.34 字典列策略与语义合计
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { createDictionaryColumn, summarizeRows } from "@agile-team/mach-table/business";
|
|
119
|
+
|
|
120
|
+
const options = [{ value: "ready", label: "已就绪" }];
|
|
121
|
+
const labels = new Map(options.map(entry => [entry.value, entry.label]));
|
|
122
|
+
const statusColumn = {
|
|
123
|
+
field: "status",
|
|
124
|
+
...createDictionaryColumn({ get: key => labels.get(key) }, {
|
|
125
|
+
options,
|
|
126
|
+
display: "label",
|
|
127
|
+
output: { clipboard: "label", csv: "code-label" }
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`/business` 无 UI、请求或缓存,连接已有 Provider;异步标签先预热,动态选项用新数组替换快照。原始数字/文本编码保留类型,重复标签拒绝歧义;未配置的输出通道保留原码,旧 renderer 的导出行为不变。
|
|
133
|
+
|
|
134
|
+
`summarizeRows(rows, { scope, metrics, groupBy?, numeric? })` 只计算传入记录,支持 sum/count/ratio/none;ratio 先分别汇总分子分母。业务按币种、单位分组,scope 仅声明 page/selected/query,不自动获取全量。默认有限 number 仍遵循浮点语义,精确金额使用已有同步 numeric 策略;结果接入原 summaryMethod 或固定行。详见[业务列与字典](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/recipes/business-columns.md)。
|
|
135
|
+
|
|
136
|
+
根入口的 `createCachedDictionary()` 现在复用同 key 在途请求,失效隔离旧响应并结束旧等待,缺失项受同一 TTL/LRU 约束。失败可重试,销毁拒绝未完成请求,错误观察回调不会阻塞清理。具体升级边界见[升级指南](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/upgrading.md)。
|
|
137
|
+
|
|
138
|
+
## 列值与运行边界(自 0.33)
|
|
139
|
+
|
|
140
|
+
`ColDef.valueParser` 统一编辑、粘贴和导入的规范值;`valueSerializer` 按 clipboard/csv/xlsx 定义输出,沿用已有 `columnTypes` 优先级。排序/过滤读取规范值,可信事务与撤销不重复解析。`api.io.importMatrix()` / `exportMatrix()` 直传类型,完整导入预览从当前包的 `/import` 导入 `createImportPlan()`,不加载到默认入口。
|
|
141
|
+
|
|
142
|
+
`sum` / `avg` / `min` / `max` 只聚合有限数,空数值集合返回 null,sum/avg 溢出返回 null;`count` 计全部记录,空集合为 0。自定义聚合保留原始输入。分组 ID 区分数字/文本/空值,旧展开路径仅在唯一时迁移,歧义报告错误。超大远程滚动使用有界物理坐标,API、滚轮和交互共用逻辑偏移;应用默认配置的 `dataProcessor` 使用每表工厂。完整边界与升级说明见[升级指南](https://github.com/ChenyCHENYU/MachTable/blob/main/docs/guide/upgrading.md)。
|
package/dist/adapter.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var n in t)S(e,n,{get:t[n],enumerable:!0})},de=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of re(t))!se.call(e,a)&&a!==n&&S(e,a,{get:()=>t[a],enumerable:!(o=ae(t,a))||o.enumerable});return e};var ce=e=>de(S({},"__esModule",{value:!0}),e);var ve={};le(ve,{GRID_OPTION_KEYS:()=>G,GRID_OPTION_META:()=>E,canReplaceGridData:()=>X,createSelectControl:()=>Y,mergeMachTableConfig:()=>te,normalizeMachTableConfig:()=>L,readGridCell:()=>Z,resolveMachTableGridOptions:()=>ne,resumeGrid:()=>J,suspendGrid:()=>q,writeGridInput:()=>Q});module.exports=ce(ve);function h(e,t,n){let o=document.createElement(e);if(t&&(o.className=t),n)for(let a of Object.keys(n))o.setAttribute(a,n[a]);return o}var pe=["--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 W(e,t){if(e.classList.add("mach-portal"),!t)return;let n=window.getComputedStyle(t);for(let o of pe){let a=n.getPropertyValue(o).trim();a&&e.style.setProperty(o,a)}e.style.colorScheme=n.colorScheme}function B(e,t,n){return e<t?t:e>n?n:e}var F=0;function K(e="rg"){return F++,`${e}-${F}`}var p=null;function V(e){p?.owner&&(e===p.owner||e.contains(p.owner))&&p.close()}function $(e){let t=e.target;p?.contains(t)||p?.close()}function R(){p?.reposition()}function U(e){e.key!=="Escape"||!p||(e.preventDefault(),e.stopImmediatePropagation(),p.close(!0))}function ue(e){p?.close!==e.close&&p?.close(),!p&&(p=e,document.addEventListener("mousedown",$,!0),document.addEventListener("keydown",U,!0),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0))}function fe(e){p?.close===e&&(p=null,document.removeEventListener("mousedown",$,!0),document.removeEventListener("keydown",U,!0),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0))}function k(e,t){return t?`${e} ${t}`:e}function x(e){let t=[];return e.forEach((n,o)=>{n.disabled||t.push(o)}),t}function z(e,t,n){let o=x(e);if(o.length===0)return-1;let a=o.indexOf(t);return a<0?n>0?o[0]:o[o.length-1]:o[Math.max(0,Math.min(o.length-1,a+n))]}function M(e,t){return e.findIndex(n=>n.value===t&&!n.disabled)}function Y(e){let t=h("div",k("mach-select-control",e.classNames?.root)),n=h("select",k("mach-select-native",e.classNames?.native));n.hidden=!0,n.tabIndex=-1,n.setAttribute("aria-hidden","true");let o=h("button",k("mach-select-trigger",e.classNames?.trigger));o.type="button",o.setAttribute("role","combobox"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-label",e.ariaLabel);let a=h("span",k("mach-select-value",e.classNames?.value)),u=h("span",k("mach-select-caret",e.classNames?.caret));u.setAttribute("aria-hidden","true"),o.append(a,u);let r=h("div",k("mach-select-listbox",e.classNames?.listbox));r.id=K("mach-select-listbox"),r.setAttribute("role","listbox"),r.setAttribute("aria-hidden","true"),o.setAttribute("aria-controls",r.id),t.append(n,o);let s=[...e.options],m=[],d=-1,g=!1,P=()=>e.themeSource??t.closest(".mach-root")??t,v=()=>{let i=s.find(l=>l.value===n.value);a.textContent=i?.label??n.value,m.forEach((l,b)=>{let c=s[b]?.value===n.value;l.setAttribute("aria-selected",c?"true":"false"),l.classList.toggle("mach-select-option--selected",c),l.classList.toggle("mach-select-option--active",b===d)}),o.setAttribute("aria-activedescendant",d>=0?m[d]?.id??"":"")},I=()=>{let i=o.getBoundingClientRect(),l=r.getBoundingClientRect(),b=Math.max(i.width,l.width),c=B(i.left,8,Math.max(8,window.innerWidth-b-8)),D=window.innerHeight-i.bottom-8,T=D<Math.min(l.height,240)&&i.top>D,f=T?Math.max(8,i.top-l.height-5):Math.min(window.innerHeight-l.height-8,i.bottom+5);r.style.minWidth=`${i.width}px`,r.style.left=`${c}px`,r.style.top=`${Math.max(8,f)}px`,r.classList.toggle("mach-select-listbox--above",T)},y=(i=!1)=>r.classList.contains("mach-select-listbox--open")?(r.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),r.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-activedescendant"),r.remove(),fe(y),i&&!g&&o.focus({preventScroll:!0}),!0):!1,oe=(i,l=!0)=>{!s[i]||s[i].disabled||(d=i,v(),l&&m[i]?.scrollIntoView?.({block:"nearest"}))},O=()=>{g||o.disabled||r.classList.contains("mach-select-listbox--open")||(ue({owner:P(),close:y,contains:i=>t.contains(i)||r.contains(i),reposition:I}),d=M(s,n.value),d<0&&(d=x(s)[0]??-1),W(r,P()),document.body.appendChild(r),r.classList.add("mach-select-listbox--open"),r.setAttribute("aria-hidden","false"),o.setAttribute("aria-expanded","true"),I(),v(),m[d]?.scrollIntoView?.({block:"nearest"}))},N=i=>{let l=s[i];!l||l.disabled||(n.value=l.value,d=i,v(),y(!0),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})))},j=(i,l)=>{s=[...i],n.replaceChildren(),r.replaceChildren(),m=s.map((c,D)=>{let T=document.createElement("option");T.value=c.value,T.textContent=c.label,T.disabled=c.disabled===!0,n.appendChild(T);let f=h("button",k("mach-select-option",e.classNames?.option));return f.id=`${r.id}-option-${D}`,f.type="button",f.tabIndex=-1,f.dataset.value=c.value,f.disabled=c.disabled===!0,f.setAttribute("role","option"),f.textContent=c.label,f.addEventListener("mousedown",ie=>ie.preventDefault()),f.addEventListener("click",()=>N(D)),r.appendChild(f),f});let b=s.find(c=>!c.disabled)?.value??"";n.value=l!=null&&s.some(c=>c.value===l)?l:b,d=M(s,n.value),v()},H=i=>{if(i.key==="Tab"){y();return}if(i.key==="Escape"){if(!y(!0))return;i.preventDefault(),i.stopPropagation();return}if(i.key==="Enter"||i.key===" "){i.preventDefault(),i.stopPropagation(),r.classList.contains("mach-select-listbox--open")?N(d):O();return}let l=d;if(i.key==="ArrowDown")l=z(s,d,1);else if(i.key==="ArrowUp")l=z(s,d,-1);else if(i.key==="Home")l=x(s)[0]??-1;else if(i.key==="End"){let b=x(s);l=b[b.length-1]??-1}else return;i.preventDefault(),i.stopPropagation(),r.classList.contains("mach-select-listbox--open")||O(),oe(l)},_=()=>{d=M(s,n.value),v(),e.onChange?.(n.value)};return o.addEventListener("click",()=>{y()||O()}),o.addEventListener("keydown",H),n.addEventListener("change",_),j(s,e.value),{el:t,native:n,trigger:o,listbox:r,contains:i=>t.contains(i)||r.contains(i),isOpen:()=>r.classList.contains("mach-select-listbox--open"),open:O,close:y,focus:()=>o.focus({preventScroll:!0}),getValue:()=>n.value,setValue:i=>{n.value=i,d=M(s,i),v()},setOptions:j,destroy:()=>{g||(g=!0,y(),o.removeEventListener("keydown",H),n.removeEventListener("change",_),t.remove())}}}var C=Symbol.for("mach-table.adapter.lifecycle.v1");function q(e){if(e.isDestroyed())return;let t=e.view.getRoot();t&&V(t),e[C]?.suspend()}function J(e){e.isDestroyed()||e[C]?.resume()}function Z(e,t,n){return e.isDestroyed()?"":e[C]?.readCell(t,n)??""}function Q(e,t){e.isDestroyed()||e[C]?.writeInput(t)}function X(e){return!e.isDestroyed()&&(e[C]?.canReplaceData()??!1)}var E={columnDefs:{kind:"array",update:"columnDefs"},rowData:{kind:"array",update:"rowData"},defaultColDef:{kind:"object",update:"options"},columnTypes:{kind:"object",update:"options"},rowKey:{kind:"unknown",update:"options"},rowHeight:{kind:"number",update:"options"},headerHeight:{kind:"number",update:"options"},rowBuffer:{kind:"number",update:"options"},columnLayout:{kind:"string",update:"options"},enableColumnResize:{kind:"boolean",update:"options"},domLayout:{kind:"string",update:"options"},rowSelection:{kind:"string",update:"options"},multiSort:{kind:"boolean",update:"options"},size:{kind:"string",update:"options"},stripedRows:{kind:"boolean",update:"options"},rowStyleRules:{kind:"array",update:"options"},showCellBorders:{kind:"boolean",update:"options"},theme:{kind:"string",update:"options"},quickFilterText:{kind:"string",update:"quickFilter"},advancedFilterModel:{kind:"object",update:"options"},masterDetail:{kind:"boolean",update:"options"},detailRowHeight:{kind:"number",update:"options"},detailRowRenderer:{kind:"function",update:"options"},isRowExpandable:{kind:"function",update:"options"},detailToggleColumn:{kind:"boolean",update:"options"},columnMenu:{kind:"boolean",update:"options"},aggFuncs:{kind:"object",update:"options"},components:{kind:"object",update:"options"},actionPolicy:{kind:"object",update:"options"},features:{kind:"array",update:"options"},initialState:{kind:"object",update:"options"},persistence:{kind:"boolean-object",update:"options"},locale:{kind:"object",update:"options"},editType:{kind:"string",update:"options"},editableIndicator:{kind:"string",update:"options"},rowEditValidator:{kind:"function",update:"options"},singleClickEdit:{kind:"boolean",update:"options"},manualSorting:{kind:"boolean",update:"options"},manualFiltering:{kind:"boolean",update:"options"},showSummary:{kind:"boolean",update:"options"},summaryMethod:{kind:"function",update:"options"},treeData:{kind:"boolean",update:"options"},childrenKey:{kind:"string",update:"options"},isTreeRowExpandable:{kind:"function",update:"options"},loadTreeChildren:{kind:"function",update:"options"},autoCheckedChildren:{kind:"boolean",update:"options"},defaultExpandAll:{kind:"boolean",update:"options"},indexOffset:{kind:"number",update:"options"},applyRowDrag:{kind:"boolean",update:"options"},rowDragPolicy:{kind:"object",update:"options"},undoStackSize:{kind:"number",update:"options"},asyncTransactionWaitMillis:{kind:"number",update:"options"},getRowHeight:{kind:"function",update:"options"},pinnedTopRowData:{kind:"array",update:"options"},pinnedBottomRowData:{kind:"array",update:"options"},pagination:{kind:"boolean-object",update:"options"},watermark:{kind:"boolean-object",update:"options"},suppressWarnings:{kind:"boolean",update:"options"},enableRangeSelection:{kind:"boolean",update:"options"},suppressClipboard:{kind:"boolean",update:"options"},contextMenu:{kind:"boolean",update:"options"},getContextMenuItems:{kind:"function",update:"options"},tooltipComponent:{kind:"function",update:"options"},tooltipShowDelay:{kind:"number",update:"options"},flashCells:{kind:"boolean",update:"options"},fillHandle:{kind:"boolean",update:"options"},statusBar:{kind:"boolean-object",update:"options"},datasource:{kind:"object",update:"options"},datasourceMode:{kind:"string",update:"options"},blockSize:{kind:"number",update:"options"},infiniteBufferRows:{kind:"number",update:"options"},maxBlocksInCache:{kind:"number",update:"options"},datasourceMaxConcurrentRequests:{kind:"number",update:"options"},blockPrefetch:{kind:"number",update:"options"},datasourceRowCount:{kind:"number",update:"options"},dataProcessor:{kind:"object",update:"options"},dataProcessorMinRows:{kind:"number",update:"options"},datasourceRetryCount:{kind:"number",update:"options"},datasourceRetryDelay:{kind:"number",update:"options"},datasourceRetryJitter:{kind:"number",update:"options"},suppressCellFocus:{kind:"boolean",update:"options"},suppressRowHoverHighlight:{kind:"boolean",update:"options"},suppressNoRowsOverlay:{kind:"boolean",update:"options"},suppressHeaderFocus:{kind:"boolean",update:"options"},ariaLabel:{kind:"string",update:"options"},ariaLabelledBy:{kind:"string",update:"options"},ariaDescribedBy:{kind:"string",update:"options"},loading:{kind:"boolean",update:"options"},error:{kind:"unknown",update:"options"},overlayNoRowsTemplate:{kind:"unknown",update:"options"},overlayLoadingTemplate:{kind:"unknown",update:"options"},overlayErrorTemplate:{kind:"unknown",update:"options"},allowUnsafeOverlayHtml:{kind:"boolean",update:"options"},className:{kind:"string",update:"options"}},G=Object.freeze(Object.keys(E)),Re=Object.freeze(G.filter(e=>E[e].update==="options"));function A(e,t){return t===void 0?e:typeof t!="object"||t===null||typeof e!="object"||e===null?t:{...e,...t}}function me(e,t){return typeof e!="function"?t:typeof t!="function"?e:(...n)=>{let o;try{e(...n)}catch(a){o=a}try{t(...n)}catch(a){o??(o=a)}if(o!==void 0)throw o}}function ge(e,t){if(!(!e.components&&!t.components))return{cellRenderers:{...e.components?.cellRenderers,...t.components?.cellRenderers},cellEditors:{...e.components?.cellEditors,...t.components?.cellEditors}}}function be(e,t){if(!e.columnTypes&&!t.columnTypes)return;let n={},o=new Set([...Object.keys(e.columnTypes??{}),...Object.keys(t.columnTypes??{})]);for(let a of o)n[a]={...e.columnTypes?.[a],...t.columnTypes?.[a]};return n}function ye(e,t,n){for(let o of new Set([...Object.keys(t),...Object.keys(n)])){if(!/^on[A-Z]/.test(o))continue;let a=t[o],u=n[o];typeof a!="function"||typeof u!="function"||(e[o]=me(a,u))}}function he(e,t){let n={...e,...t,features:t.features??e.features};(e.defaultColDef||t.defaultColDef)&&(n.defaultColDef={...e.defaultColDef,...t.defaultColDef}),(e.locale||t.locale)&&(n.locale={...e.locale,...t.locale});let o=ge(e,t);o&&(n.components=o);let a=be(e,t);return a&&(n.columnTypes=a),(e.aggFuncs||t.aggFuncs)&&(n.aggFuncs={...e.aggFuncs,...t.aggFuncs}),n.pagination=A(e.pagination,t.pagination),n.statusBar=A(e.statusBar,t.statusBar),n.watermark=A(e.watermark,t.watermark),ye(n,e,t),n}function w(...e){return e.reduce(he,{})}function Te(e){return e?(Array.isArray(e)?e:[e]).filter(t=>typeof t=="string"&&t.trim().length>0):[]}var ke=new Set(["rowData","columnDefs","datasource","loading","error","initialState","persistence","components","columnTypes","stateKey","stateStore","stateSaveDebounceMs","columnStateKey","columnStateStore"]);function ee(e,t,n){if(!t||typeof t!="object"||Array.isArray(t))return{};let o={};for(let[a,u]of Object.entries(t)){if(!ke.has(a)){o[a]=u;continue}let r={code:n==="defaults"?"INVALID_DEFAULT_OPTION":"INVALID_PRESET_OPTION",option:a,layer:n,message:`[MachTable] "${a}" is instance-only and cannot be declared in config ${n}.`};if(e.onConfigWarning?.(r),e.strict!==!1)throw new TypeError(r.message)}return o}function L(e={}){let t=ee(e,e.defaults,"defaults");return{defaults:w({columnTypes:e.columnTypes,components:e.components},t),presets:Object.fromEntries(Object.entries(e.presets??{}).map(([n,o])=>[n,w(ee(e,o,`preset:${n}`))])),defaultPreset:e.defaultPreset??!1,strict:e.strict!==!1,...e.onConfigWarning?{onConfigWarning:e.onConfigWarning}:{}}}function te(e,t){let n=L({...t,strict:t.strict??e.strict,onConfigWarning:t.onConfigWarning??e.onConfigWarning}),o={...e.presets};for(let[a,u]of Object.entries(n.presets))o[a]=w(e.presets[a]??{},u);return{defaults:w(e.defaults,n.defaults),presets:o,defaultPreset:t.defaultPreset===void 0?e.defaultPreset:t.defaultPreset,strict:t.strict??e.strict,...t.onConfigWarning??e.onConfigWarning?{onConfigWarning:t.onConfigWarning??e.onConfigWarning}:{}}}function ne(e,t,n,o){let a=t===void 0?e.defaultPreset:t,u=[{name:"application defaults",options:e.defaults}];for(let s of Te(a)){let m=e.presets[s];if(!m){let d={code:"UNKNOWN_PRESET",preset:s,message:`[MachTable] Unknown preset "${s}". Register it in mach-table.config.ts or remove the preset.`};o?o(d):e.onConfigWarning?e.onConfigWarning(d):console.warn(d.message);continue}u.push({name:`preset:${s}`,options:m})}u.push({name:"table props",options:n});let r=w(...u.map(s=>s.options));return{options:r,explain(s){let m=u.filter(g=>Object.prototype.hasOwnProperty.call(g.options,s)).map(g=>({name:g.name,value:g.options[s]})),d=m[m.length-1];return{key:s,value:r[s],source:d?.name??"MachTable built-in",layers:m}}}}0&&(module.exports={GRID_OPTION_KEYS,GRID_OPTION_META,canReplaceGridData,createSelectControl,mergeMachTableConfig,normalizeMachTableConfig,readGridCell,resolveMachTableGridOptions,resumeGrid,suspendGrid,writeGridInput});
|
|
1
|
+
"use strict";var P=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ue(t))!pe.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=de(t,r))||o.enumerable});return e};var ge=e=>me(P({},"__esModule",{value:!0}),e);var Ee={};fe(Ee,{GRID_OPTION_KEYS:()=>re,GRID_OPTION_META:()=>oe,beginGridInput:()=>te,canReplaceGridData:()=>ee,createSelectControl:()=>Y,equivalentConfigValue:()=>O,equivalentGridOption:()=>F,mergeMachTableConfig:()=>ie,normalizeMachTableConfig:()=>S,readGridCell:()=>Q,resolveMachTableGridOptions:()=>se,resumeGrid:()=>Z,suspendGrid:()=>J,writeGridInput:()=>X});module.exports=ge(Ee);function O(e,t,n=2){if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length||e.length>100?!1:e.every((r,d)=>O(r,t[d],n-1));if(!K(e)||!K(t))return!1;let o=Object.keys(e);return o.length!==Object.keys(t).length||o.length>100?!1:o.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&O(e[r],t[r],n-1))}function K(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var be=new Set(["defaultColDef","locale","components","columnTypes","aggFuncs","pagination","statusBar","watermark"]);function F(e,t,n){return Object.is(t,n)||be.has(e)&&O(t,n,3)}function h(e,t,n){let o=document.createElement(e);if(t&&(o.className=t),n)for(let r of Object.keys(n))o.setAttribute(r,n[r]);return o}function W(e,t){if(e.classList.add("mach-portal"),!t)return;let n=window.getComputedStyle(t);for(let o=0;o<n.length;o++){let r=n.item(o);if(!r.startsWith("--mach-"))continue;let d=n.getPropertyValue(r).trim();d&&e.style.setProperty(r,d)}e.style.colorScheme=n.colorScheme}function V(e,t,n){return e<t?t:e>n?n:e}var _=0;function B(e="rg"){return _++,`${e}-${_}`}var p=null;function z(e){p?.owner&&(e===p.owner||e.contains(p.owner))&&p.close()}function U(e){let t=e.target;p?.contains(t)||p?.close()}function E(){p?.reposition()}function q(e){e.key!=="Escape"||!p||(e.preventDefault(),e.stopImmediatePropagation(),p.close(!0))}function ye(e){p?.close!==e.close&&p?.close(),!p&&(p=e,document.addEventListener("mousedown",U,!0),document.addEventListener("keydown",q,!0),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0))}function he(e){p?.close===e&&(p=null,document.removeEventListener("mousedown",U,!0),document.removeEventListener("keydown",q,!0),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0))}function w(e,t){return t?`${e} ${t}`:e}function R(e){let t=[];return e.forEach((n,o)=>{n.disabled||t.push(o)}),t}function $(e,t,n){let o=R(e);if(o.length===0)return-1;let r=o.indexOf(t);return r<0?n>0?o[0]:o[o.length-1]:o[Math.max(0,Math.min(o.length-1,r+n))]}function G(e,t){return e.findIndex(n=>n.value===t&&!n.disabled)}function Y(e){let t=h("div",w("mach-select-control",e.classNames?.root)),n=h("select",w("mach-select-native",e.classNames?.native));n.hidden=!0,n.tabIndex=-1,n.setAttribute("aria-hidden","true");let o=h("button",w("mach-select-trigger",e.classNames?.trigger));o.type="button",o.setAttribute("role","combobox"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-label",e.ariaLabel);let r=h("span",w("mach-select-value",e.classNames?.value)),d=h("span",w("mach-select-caret",e.classNames?.caret));d.setAttribute("aria-hidden","true"),o.append(r,d);let i=h("div",w("mach-select-listbox",e.classNames?.listbox));i.id=B("mach-select-listbox"),i.setAttribute("role","listbox"),i.setAttribute("aria-hidden","true"),o.setAttribute("aria-controls",i.id),t.append(n,o);let s=[...e.options],m=[],c=-1,g=!1,I=()=>e.themeSource??t.closest(".mach-root")??t,v=()=>{let a=s.find(l=>l.value===n.value);r.textContent=a?.label??n.value,m.forEach((l,b)=>{let u=s[b]?.value===n.value;l.setAttribute("aria-selected",u?"true":"false"),l.classList.toggle("mach-select-option--selected",u),l.classList.toggle("mach-select-option--active",b===c)}),o.setAttribute("aria-activedescendant",c>=0?m[c]?.id??"":"")},k=()=>{let a=o.getBoundingClientRect(),l=i.getBoundingClientRect(),b=Math.max(a.width,l.width),u=V(a.left,8,Math.max(8,window.innerWidth-b-8)),C=window.innerHeight-a.bottom-8,T=C<Math.min(l.height,240)&&a.top>C,f=T?Math.max(8,a.top-l.height-5):Math.min(window.innerHeight-l.height-8,a.bottom+5);i.style.minWidth=`${a.width}px`,i.style.left=`${u}px`,i.style.top=`${Math.max(8,f)}px`,i.classList.toggle("mach-select-listbox--above",T)},y=(a=!1)=>i.classList.contains("mach-select-listbox--open")?(i.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),i.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-activedescendant"),i.remove(),he(y),a&&!g&&o.focus({preventScroll:!0}),!0):!1,le=(a,l=!0)=>{!s[a]||s[a].disabled||(c=a,v(),l&&m[a]?.scrollIntoView?.({block:"nearest"}))},M=()=>{g||o.disabled||i.classList.contains("mach-select-listbox--open")||(ye({owner:I(),close:y,contains:a=>t.contains(a)||i.contains(a),reposition:k}),c=G(s,n.value),c<0&&(c=R(s)[0]??-1),W(i,I()),document.body.appendChild(i),i.classList.add("mach-select-listbox--open"),i.setAttribute("aria-hidden","false"),o.setAttribute("aria-expanded","true"),k(),v(),m[c]?.scrollIntoView?.({block:"nearest"}))},L=a=>{let l=s[a];!l||l.disabled||(n.value=l.value,c=a,v(),y(!0),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})))},N=(a,l)=>{s=[...a],n.replaceChildren(),i.replaceChildren(),m=s.map((u,C)=>{let T=document.createElement("option");T.value=u.value,T.textContent=u.label,T.disabled=u.disabled===!0,n.appendChild(T);let f=h("button",w("mach-select-option",e.classNames?.option));return f.id=`${i.id}-option-${C}`,f.type="button",f.tabIndex=-1,f.dataset.value=u.value,f.disabled=u.disabled===!0,f.setAttribute("role","option"),f.textContent=u.label,f.addEventListener("mousedown",ce=>ce.preventDefault()),f.addEventListener("click",()=>L(C)),i.appendChild(f),f});let b=s.find(u=>!u.disabled)?.value??"";n.value=l!=null&&s.some(u=>u.value===l)?l:b,c=G(s,n.value),v()},j=a=>{if(a.key==="Tab"){y();return}if(a.key==="Escape"){if(!y(!0))return;a.preventDefault(),a.stopPropagation();return}if(a.key==="Enter"||a.key===" "){a.preventDefault(),a.stopPropagation(),i.classList.contains("mach-select-listbox--open")?L(c):M();return}let l=c;if(a.key==="ArrowDown")l=$(s,c,1);else if(a.key==="ArrowUp")l=$(s,c,-1);else if(a.key==="Home")l=R(s)[0]??-1;else if(a.key==="End"){let b=R(s);l=b[b.length-1]??-1}else return;a.preventDefault(),a.stopPropagation(),i.classList.contains("mach-select-listbox--open")||M(),le(l)},H=()=>{c=G(s,n.value),v(),e.onChange?.(n.value)};return o.addEventListener("click",()=>{y()||M()}),o.addEventListener("keydown",j),n.addEventListener("change",H),N(s,e.value),{el:t,native:n,trigger:o,listbox:i,contains:a=>t.contains(a)||i.contains(a),isOpen:()=>i.classList.contains("mach-select-listbox--open"),open:M,close:y,focus:()=>o.focus({preventScroll:!0}),getValue:()=>n.value,setValue:a=>{n.value=a,c=G(s,a),v()},setOptions:N,destroy:()=>{g||(g=!0,y(),o.removeEventListener("keydown",j),n.removeEventListener("change",H),t.remove())}}}var x=Symbol.for("mach-table.adapter.lifecycle.v1");function J(e){if(e.isDestroyed())return;let t=e.view.getRoot();t&&z(t),e[x]?.suspend()}function Z(e){e.isDestroyed()||e[x]?.resume()}function Q(e,t,n){return e.isDestroyed()?"":e[x]?.readCell(t,n)??""}function X(e,t){e.isDestroyed()||e[x]?.writeInput(t)}function ee(e){return!e.isDestroyed()&&(e[x]?.canReplaceData()??!1)}var Te=Symbol.for("mach-table.import.v1");function we(e){let t=e[Te];if(!t)throw new TypeError("Import plans require a MachTable GridApi");return t}function te(e){return e.isDestroyed()?()=>!1:we(e).begin()}var ne={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};function ve(){return Object.fromEntries(Object.entries(ne).map(([e,t])=>[e,{kind:t,update:e==="columnDefs"||e==="rowData"?e:e==="quickFilterText"?"quickFilter":"options"}]))}var oe=ve(),re=Object.freeze(Object.keys(ne));function A(e,t){return t===void 0?e:typeof t!="object"||t===null||typeof e!="object"||e===null?t:{...e,...t}}function De(e,t){return typeof e!="function"?t:typeof t!="function"?e:(...n)=>{let o;try{e(...n)}catch(r){o=r}try{t(...n)}catch(r){o??(o=r)}if(o!==void 0)throw o}}function Ce(e,t){if(!(!e.components&&!t.components))return{cellRenderers:{...e.components?.cellRenderers,...t.components?.cellRenderers},cellEditors:{...e.components?.cellEditors,...t.components?.cellEditors}}}function Oe(e,t){if(!e.columnTypes&&!t.columnTypes)return;let n={},o=new Set([...Object.keys(e.columnTypes??{}),...Object.keys(t.columnTypes??{})]);for(let r of o)n[r]={...e.columnTypes?.[r],...t.columnTypes?.[r]};return n}function xe(e,t,n){for(let o of new Set([...Object.keys(t),...Object.keys(n)])){if(!/^on[A-Z]/.test(o))continue;let r=t[o],d=n[o];typeof r!="function"||typeof d!="function"||(e[o]=De(r,d))}}function Me(e,t){let n={...e,...t,features:t.features??e.features};(e.defaultColDef||t.defaultColDef)&&(n.defaultColDef={...e.defaultColDef,...t.defaultColDef}),(e.locale||t.locale)&&(n.locale={...e.locale,...t.locale});let o=Ce(e,t);o&&(n.components=o);let r=Oe(e,t);return r&&(n.columnTypes=r),(e.aggFuncs||t.aggFuncs)&&(n.aggFuncs={...e.aggFuncs,...t.aggFuncs}),n.pagination=A(e.pagination,t.pagination),n.statusBar=A(e.statusBar,t.statusBar),n.watermark=A(e.watermark,t.watermark),xe(n,e,t),n}function D(...e){return e.reduce(Me,{})}function Ge(e){return e?(Array.isArray(e)?e:[e]).filter(t=>typeof t=="string"&&t.trim().length>0):[]}var Re=new Set(["rowData","columnDefs","datasource","loading","error","initialState","persistence","components","columnTypes","stateKey","stateStore","stateSaveDebounceMs","columnStateKey","columnStateStore"]);function ae(e,t,n){if(!t||typeof t!="object"||Array.isArray(t))return{};let o={};for(let[r,d]of Object.entries(t)){if(!Re.has(r)&&(r!=="dataProcessor"||d==null||typeof d=="function")){o[r]=d;continue}let i={code:n==="defaults"?"INVALID_DEFAULT_OPTION":"INVALID_PRESET_OPTION",option:r,layer:n,message:r==="dataProcessor"?`[MachTable] "dataProcessor" in config ${n} must be a factory returning a fresh per-grid instance.`:`[MachTable] "${r}" is instance-only and cannot be declared in config ${n}.`};if(e.onConfigWarning?.(i),e.strict!==!1)throw new TypeError(i.message)}return o}function S(e={}){let t=ae(e,e.defaults,"defaults");return{defaults:D({columnTypes:e.columnTypes,components:e.components},t),presets:Object.fromEntries(Object.entries(e.presets??{}).map(([n,o])=>[n,D(ae(e,o,`preset:${n}`))])),defaultPreset:e.defaultPreset??!1,strict:e.strict!==!1,...e.onConfigWarning?{onConfigWarning:e.onConfigWarning}:{}}}function ie(e,t){let n=S({...t,strict:t.strict??e.strict,onConfigWarning:t.onConfigWarning??e.onConfigWarning}),o={...e.presets};for(let[r,d]of Object.entries(n.presets))o[r]=D(e.presets[r]??{},d);return{defaults:D(e.defaults,n.defaults),presets:o,defaultPreset:t.defaultPreset===void 0?e.defaultPreset:t.defaultPreset,strict:t.strict??e.strict,...t.onConfigWarning??e.onConfigWarning?{onConfigWarning:t.onConfigWarning??e.onConfigWarning}:{}}}function se(e,t,n,o){let r=t===void 0?e.defaultPreset:t,d=[{name:"application defaults",options:e.defaults}];for(let s of Ge(r)){let m=e.presets[s];if(!m){let c={code:"UNKNOWN_PRESET",preset:s,message:`[MachTable] Unknown preset "${s}". Register it in mach-table.config.ts or remove the preset.`};o?o(c):e.onConfigWarning?e.onConfigWarning(c):console.warn(c.message);continue}d.push({name:`preset:${s}`,options:m})}d.push({name:"table props",options:n});let i=D(...d.map(s=>s.options));return{options:i,explain(s){let m=d.filter(g=>Object.prototype.hasOwnProperty.call(g.options,s)).map(g=>({name:g.name,value:g.options[s]})),c=m[m.length-1];return{key:s,value:i[s],source:c?.name??"MachTable built-in",layers:m}}}}0&&(module.exports={GRID_OPTION_KEYS,GRID_OPTION_META,beginGridInput,canReplaceGridData,createSelectControl,equivalentConfigValue,equivalentGridOption,mergeMachTableConfig,normalizeMachTableConfig,readGridCell,resolveMachTableGridOptions,resumeGrid,suspendGrid,writeGridInput});
|
package/dist/adapter.d.cts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { b as GridApi, c as GridOptions,
|
|
2
|
-
export { M as MachTableOptionExplanation, R as ResolvedMachTableConfig, a as ResolvedMachTableGridOptions, m as mergeMachTableConfig, n as normalizeMachTableConfig, r as resolveMachTableGridOptions } from './configuration-
|
|
1
|
+
import { b as GridApi, c as GridOptions, j as GridEventType } from './api-CfZinb9Q.cjs';
|
|
2
|
+
export { M as MachTableOptionExplanation, R as ResolvedMachTableConfig, a as ResolvedMachTableGridOptions, m as mergeMachTableConfig, n as normalizeMachTableConfig, r as resolveMachTableGridOptions } from './configuration-D2lEYcli.cjs';
|
|
3
|
+
|
|
4
|
+
/** Bounded structural comparison for small immutable config values, never row data. */
|
|
5
|
+
declare function equivalentConfigValue(left: unknown, right: unknown, depth?: number): boolean;
|
|
6
|
+
/** Merged layers allocate fresh objects; preserve updates for genuine instance replacements. */
|
|
7
|
+
declare function equivalentGridOption(key: string, left: unknown, right: unknown): boolean;
|
|
3
8
|
|
|
4
9
|
interface GridInputCell {
|
|
5
10
|
rowId: string;
|
|
@@ -14,15 +19,28 @@ declare function readGridCell(api: GridApi<any>, rowId: string, colId: string):
|
|
|
14
19
|
declare function writeGridInput(api: GridApi<any>, cells: readonly GridInputCell[]): void;
|
|
15
20
|
declare function canReplaceGridData(api: GridApi<any>): boolean;
|
|
16
21
|
|
|
22
|
+
/** Internal adapter boundary shared with lazy typed-file IO. */
|
|
23
|
+
declare function beginGridInput(api: GridApi): () => boolean;
|
|
24
|
+
|
|
17
25
|
type EventOptionKey = `on${Capitalize<GridEventType>}`;
|
|
18
26
|
type GridOptionKey = Exclude<keyof GridOptions<any>, EventOptionKey>;
|
|
19
|
-
/**
|
|
20
|
-
* Runtime single source of truth for every non-event GridOptions property.
|
|
21
|
-
*
|
|
22
|
-
* The mapped `satisfies` type intentionally makes adding a GridOptions field a
|
|
23
|
-
* compile error until its adapter/update behavior is declared here.
|
|
24
|
-
*/
|
|
25
27
|
declare const GRID_OPTION_META: {
|
|
28
|
+
readonly blockSize: {
|
|
29
|
+
readonly kind: "number";
|
|
30
|
+
readonly update: "options";
|
|
31
|
+
};
|
|
32
|
+
readonly pagination: {
|
|
33
|
+
readonly kind: "boolean-object";
|
|
34
|
+
readonly update: "options";
|
|
35
|
+
};
|
|
36
|
+
readonly loading: {
|
|
37
|
+
readonly kind: "boolean";
|
|
38
|
+
readonly update: "options";
|
|
39
|
+
};
|
|
40
|
+
readonly error: {
|
|
41
|
+
readonly kind: "unknown";
|
|
42
|
+
readonly update: "options";
|
|
43
|
+
};
|
|
26
44
|
readonly columnDefs: {
|
|
27
45
|
readonly kind: "array";
|
|
28
46
|
readonly update: "columnDefs";
|
|
@@ -243,10 +261,6 @@ declare const GRID_OPTION_META: {
|
|
|
243
261
|
readonly kind: "array";
|
|
244
262
|
readonly update: "options";
|
|
245
263
|
};
|
|
246
|
-
readonly pagination: {
|
|
247
|
-
readonly kind: "boolean-object";
|
|
248
|
-
readonly update: "options";
|
|
249
|
-
};
|
|
250
264
|
readonly watermark: {
|
|
251
265
|
readonly kind: "boolean-object";
|
|
252
266
|
readonly update: "options";
|
|
@@ -299,10 +313,6 @@ declare const GRID_OPTION_META: {
|
|
|
299
313
|
readonly kind: "string";
|
|
300
314
|
readonly update: "options";
|
|
301
315
|
};
|
|
302
|
-
readonly blockSize: {
|
|
303
|
-
readonly kind: "number";
|
|
304
|
-
readonly update: "options";
|
|
305
|
-
};
|
|
306
316
|
readonly infiniteBufferRows: {
|
|
307
317
|
readonly kind: "number";
|
|
308
318
|
readonly update: "options";
|
|
@@ -324,7 +334,7 @@ declare const GRID_OPTION_META: {
|
|
|
324
334
|
readonly update: "options";
|
|
325
335
|
};
|
|
326
336
|
readonly dataProcessor: {
|
|
327
|
-
readonly kind: "object";
|
|
337
|
+
readonly kind: "object-function";
|
|
328
338
|
readonly update: "options";
|
|
329
339
|
};
|
|
330
340
|
readonly dataProcessorMinRows: {
|
|
@@ -371,14 +381,6 @@ declare const GRID_OPTION_META: {
|
|
|
371
381
|
readonly kind: "string";
|
|
372
382
|
readonly update: "options";
|
|
373
383
|
};
|
|
374
|
-
readonly loading: {
|
|
375
|
-
readonly kind: "boolean";
|
|
376
|
-
readonly update: "options";
|
|
377
|
-
};
|
|
378
|
-
readonly error: {
|
|
379
|
-
readonly kind: "unknown";
|
|
380
|
-
readonly update: "options";
|
|
381
|
-
};
|
|
382
384
|
readonly overlayNoRowsTemplate: {
|
|
383
385
|
readonly kind: "unknown";
|
|
384
386
|
readonly update: "options";
|
|
@@ -441,4 +443,4 @@ interface SelectControl {
|
|
|
441
443
|
}
|
|
442
444
|
declare function createSelectControl(config: SelectControlOptions): SelectControl;
|
|
443
445
|
|
|
444
|
-
export { GRID_OPTION_KEYS, GRID_OPTION_META, type GridInputCell, type SelectControl, type SelectControlClassNames, type SelectControlOption, type SelectControlOptions, canReplaceGridData, createSelectControl, readGridCell, resumeGrid, suspendGrid, writeGridInput };
|
|
446
|
+
export { GRID_OPTION_KEYS, GRID_OPTION_META, type GridInputCell, type SelectControl, type SelectControlClassNames, type SelectControlOption, type SelectControlOptions, beginGridInput, canReplaceGridData, createSelectControl, equivalentConfigValue, equivalentGridOption, readGridCell, resumeGrid, suspendGrid, writeGridInput };
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { b as GridApi, c as GridOptions,
|
|
2
|
-
export { M as MachTableOptionExplanation, R as ResolvedMachTableConfig, a as ResolvedMachTableGridOptions, m as mergeMachTableConfig, n as normalizeMachTableConfig, r as resolveMachTableGridOptions } from './configuration-
|
|
1
|
+
import { b as GridApi, c as GridOptions, j as GridEventType } from './api-CfZinb9Q.js';
|
|
2
|
+
export { M as MachTableOptionExplanation, R as ResolvedMachTableConfig, a as ResolvedMachTableGridOptions, m as mergeMachTableConfig, n as normalizeMachTableConfig, r as resolveMachTableGridOptions } from './configuration-WTbQcWck.js';
|
|
3
|
+
|
|
4
|
+
/** Bounded structural comparison for small immutable config values, never row data. */
|
|
5
|
+
declare function equivalentConfigValue(left: unknown, right: unknown, depth?: number): boolean;
|
|
6
|
+
/** Merged layers allocate fresh objects; preserve updates for genuine instance replacements. */
|
|
7
|
+
declare function equivalentGridOption(key: string, left: unknown, right: unknown): boolean;
|
|
3
8
|
|
|
4
9
|
interface GridInputCell {
|
|
5
10
|
rowId: string;
|
|
@@ -14,15 +19,28 @@ declare function readGridCell(api: GridApi<any>, rowId: string, colId: string):
|
|
|
14
19
|
declare function writeGridInput(api: GridApi<any>, cells: readonly GridInputCell[]): void;
|
|
15
20
|
declare function canReplaceGridData(api: GridApi<any>): boolean;
|
|
16
21
|
|
|
22
|
+
/** Internal adapter boundary shared with lazy typed-file IO. */
|
|
23
|
+
declare function beginGridInput(api: GridApi): () => boolean;
|
|
24
|
+
|
|
17
25
|
type EventOptionKey = `on${Capitalize<GridEventType>}`;
|
|
18
26
|
type GridOptionKey = Exclude<keyof GridOptions<any>, EventOptionKey>;
|
|
19
|
-
/**
|
|
20
|
-
* Runtime single source of truth for every non-event GridOptions property.
|
|
21
|
-
*
|
|
22
|
-
* The mapped `satisfies` type intentionally makes adding a GridOptions field a
|
|
23
|
-
* compile error until its adapter/update behavior is declared here.
|
|
24
|
-
*/
|
|
25
27
|
declare const GRID_OPTION_META: {
|
|
28
|
+
readonly blockSize: {
|
|
29
|
+
readonly kind: "number";
|
|
30
|
+
readonly update: "options";
|
|
31
|
+
};
|
|
32
|
+
readonly pagination: {
|
|
33
|
+
readonly kind: "boolean-object";
|
|
34
|
+
readonly update: "options";
|
|
35
|
+
};
|
|
36
|
+
readonly loading: {
|
|
37
|
+
readonly kind: "boolean";
|
|
38
|
+
readonly update: "options";
|
|
39
|
+
};
|
|
40
|
+
readonly error: {
|
|
41
|
+
readonly kind: "unknown";
|
|
42
|
+
readonly update: "options";
|
|
43
|
+
};
|
|
26
44
|
readonly columnDefs: {
|
|
27
45
|
readonly kind: "array";
|
|
28
46
|
readonly update: "columnDefs";
|
|
@@ -243,10 +261,6 @@ declare const GRID_OPTION_META: {
|
|
|
243
261
|
readonly kind: "array";
|
|
244
262
|
readonly update: "options";
|
|
245
263
|
};
|
|
246
|
-
readonly pagination: {
|
|
247
|
-
readonly kind: "boolean-object";
|
|
248
|
-
readonly update: "options";
|
|
249
|
-
};
|
|
250
264
|
readonly watermark: {
|
|
251
265
|
readonly kind: "boolean-object";
|
|
252
266
|
readonly update: "options";
|
|
@@ -299,10 +313,6 @@ declare const GRID_OPTION_META: {
|
|
|
299
313
|
readonly kind: "string";
|
|
300
314
|
readonly update: "options";
|
|
301
315
|
};
|
|
302
|
-
readonly blockSize: {
|
|
303
|
-
readonly kind: "number";
|
|
304
|
-
readonly update: "options";
|
|
305
|
-
};
|
|
306
316
|
readonly infiniteBufferRows: {
|
|
307
317
|
readonly kind: "number";
|
|
308
318
|
readonly update: "options";
|
|
@@ -324,7 +334,7 @@ declare const GRID_OPTION_META: {
|
|
|
324
334
|
readonly update: "options";
|
|
325
335
|
};
|
|
326
336
|
readonly dataProcessor: {
|
|
327
|
-
readonly kind: "object";
|
|
337
|
+
readonly kind: "object-function";
|
|
328
338
|
readonly update: "options";
|
|
329
339
|
};
|
|
330
340
|
readonly dataProcessorMinRows: {
|
|
@@ -371,14 +381,6 @@ declare const GRID_OPTION_META: {
|
|
|
371
381
|
readonly kind: "string";
|
|
372
382
|
readonly update: "options";
|
|
373
383
|
};
|
|
374
|
-
readonly loading: {
|
|
375
|
-
readonly kind: "boolean";
|
|
376
|
-
readonly update: "options";
|
|
377
|
-
};
|
|
378
|
-
readonly error: {
|
|
379
|
-
readonly kind: "unknown";
|
|
380
|
-
readonly update: "options";
|
|
381
|
-
};
|
|
382
384
|
readonly overlayNoRowsTemplate: {
|
|
383
385
|
readonly kind: "unknown";
|
|
384
386
|
readonly update: "options";
|
|
@@ -441,4 +443,4 @@ interface SelectControl {
|
|
|
441
443
|
}
|
|
442
444
|
declare function createSelectControl(config: SelectControlOptions): SelectControl;
|
|
443
445
|
|
|
444
|
-
export { GRID_OPTION_KEYS, GRID_OPTION_META, type GridInputCell, type SelectControl, type SelectControlClassNames, type SelectControlOption, type SelectControlOptions, canReplaceGridData, createSelectControl, readGridCell, resumeGrid, suspendGrid, writeGridInput };
|
|
446
|
+
export { GRID_OPTION_KEYS, GRID_OPTION_META, type GridInputCell, type SelectControl, type SelectControlClassNames, type SelectControlOption, type SelectControlOptions, beginGridInput, canReplaceGridData, createSelectControl, equivalentConfigValue, equivalentGridOption, readGridCell, resumeGrid, suspendGrid, writeGridInput };
|
package/dist/adapter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function h(e,t,n){let o=document.createElement(e);if(t&&(o.className=t),n)for(let a of Object.keys(n))o.setAttribute(a,n[a]);return o}var J=["--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 H(e,t){if(e.classList.add("mach-portal"),!t)return;let n=window.getComputedStyle(t);for(let o of J){let a=n.getPropertyValue(o).trim();a&&e.style.setProperty(o,a)}e.style.colorScheme=n.colorScheme}function _(e,t,n){return e<t?t:e>n?n:e}var j=0;function F(e="rg"){return j++,`${e}-${j}`}var p=null;function B(e){p?.owner&&(e===p.owner||e.contains(p.owner))&&p.close()}function K(e){let t=e.target;p?.contains(t)||p?.close()}function R(){p?.reposition()}function z(e){e.key!=="Escape"||!p||(e.preventDefault(),e.stopImmediatePropagation(),p.close(!0))}function Z(e){p?.close!==e.close&&p?.close(),!p&&(p=e,document.addEventListener("mousedown",K,!0),document.addEventListener("keydown",z,!0),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0))}function Q(e){p?.close===e&&(p=null,document.removeEventListener("mousedown",K,!0),document.removeEventListener("keydown",z,!0),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0))}function k(e,t){return t?`${e} ${t}`:e}function x(e){let t=[];return e.forEach((n,o)=>{n.disabled||t.push(o)}),t}function W(e,t,n){let o=x(e);if(o.length===0)return-1;let a=o.indexOf(t);return a<0?n>0?o[0]:o[o.length-1]:o[Math.max(0,Math.min(o.length-1,a+n))]}function M(e,t){return e.findIndex(n=>n.value===t&&!n.disabled)}function X(e){let t=h("div",k("mach-select-control",e.classNames?.root)),n=h("select",k("mach-select-native",e.classNames?.native));n.hidden=!0,n.tabIndex=-1,n.setAttribute("aria-hidden","true");let o=h("button",k("mach-select-trigger",e.classNames?.trigger));o.type="button",o.setAttribute("role","combobox"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-label",e.ariaLabel);let a=h("span",k("mach-select-value",e.classNames?.value)),u=h("span",k("mach-select-caret",e.classNames?.caret));u.setAttribute("aria-hidden","true"),o.append(a,u);let r=h("div",k("mach-select-listbox",e.classNames?.listbox));r.id=F("mach-select-listbox"),r.setAttribute("role","listbox"),r.setAttribute("aria-hidden","true"),o.setAttribute("aria-controls",r.id),t.append(n,o);let s=[...e.options],m=[],d=-1,g=!1,G=()=>e.themeSource??t.closest(".mach-root")??t,v=()=>{let i=s.find(l=>l.value===n.value);a.textContent=i?.label??n.value,m.forEach((l,b)=>{let c=s[b]?.value===n.value;l.setAttribute("aria-selected",c?"true":"false"),l.classList.toggle("mach-select-option--selected",c),l.classList.toggle("mach-select-option--active",b===d)}),o.setAttribute("aria-activedescendant",d>=0?m[d]?.id??"":"")},A=()=>{let i=o.getBoundingClientRect(),l=r.getBoundingClientRect(),b=Math.max(i.width,l.width),c=_(i.left,8,Math.max(8,window.innerWidth-b-8)),D=window.innerHeight-i.bottom-8,T=D<Math.min(l.height,240)&&i.top>D,f=T?Math.max(8,i.top-l.height-5):Math.min(window.innerHeight-l.height-8,i.bottom+5);r.style.minWidth=`${i.width}px`,r.style.left=`${c}px`,r.style.top=`${Math.max(8,f)}px`,r.classList.toggle("mach-select-listbox--above",T)},y=(i=!1)=>r.classList.contains("mach-select-listbox--open")?(r.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),r.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-activedescendant"),r.remove(),Q(y),i&&!g&&o.focus({preventScroll:!0}),!0):!1,Y=(i,l=!0)=>{!s[i]||s[i].disabled||(d=i,v(),l&&m[i]?.scrollIntoView?.({block:"nearest"}))},O=()=>{g||o.disabled||r.classList.contains("mach-select-listbox--open")||(Z({owner:G(),close:y,contains:i=>t.contains(i)||r.contains(i),reposition:A}),d=M(s,n.value),d<0&&(d=x(s)[0]??-1),H(r,G()),document.body.appendChild(r),r.classList.add("mach-select-listbox--open"),r.setAttribute("aria-hidden","false"),o.setAttribute("aria-expanded","true"),A(),v(),m[d]?.scrollIntoView?.({block:"nearest"}))},L=i=>{let l=s[i];!l||l.disabled||(n.value=l.value,d=i,v(),y(!0),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})))},P=(i,l)=>{s=[...i],n.replaceChildren(),r.replaceChildren(),m=s.map((c,D)=>{let T=document.createElement("option");T.value=c.value,T.textContent=c.label,T.disabled=c.disabled===!0,n.appendChild(T);let f=h("button",k("mach-select-option",e.classNames?.option));return f.id=`${r.id}-option-${D}`,f.type="button",f.tabIndex=-1,f.dataset.value=c.value,f.disabled=c.disabled===!0,f.setAttribute("role","option"),f.textContent=c.label,f.addEventListener("mousedown",q=>q.preventDefault()),f.addEventListener("click",()=>L(D)),r.appendChild(f),f});let b=s.find(c=>!c.disabled)?.value??"";n.value=l!=null&&s.some(c=>c.value===l)?l:b,d=M(s,n.value),v()},I=i=>{if(i.key==="Tab"){y();return}if(i.key==="Escape"){if(!y(!0))return;i.preventDefault(),i.stopPropagation();return}if(i.key==="Enter"||i.key===" "){i.preventDefault(),i.stopPropagation(),r.classList.contains("mach-select-listbox--open")?L(d):O();return}let l=d;if(i.key==="ArrowDown")l=W(s,d,1);else if(i.key==="ArrowUp")l=W(s,d,-1);else if(i.key==="Home")l=x(s)[0]??-1;else if(i.key==="End"){let b=x(s);l=b[b.length-1]??-1}else return;i.preventDefault(),i.stopPropagation(),r.classList.contains("mach-select-listbox--open")||O(),Y(l)},N=()=>{d=M(s,n.value),v(),e.onChange?.(n.value)};return o.addEventListener("click",()=>{y()||O()}),o.addEventListener("keydown",I),n.addEventListener("change",N),P(s,e.value),{el:t,native:n,trigger:o,listbox:r,contains:i=>t.contains(i)||r.contains(i),isOpen:()=>r.classList.contains("mach-select-listbox--open"),open:O,close:y,focus:()=>o.focus({preventScroll:!0}),getValue:()=>n.value,setValue:i=>{n.value=i,d=M(s,i),v()},setOptions:P,destroy:()=>{g||(g=!0,y(),o.removeEventListener("keydown",I),n.removeEventListener("change",N),t.remove())}}}var C=Symbol.for("mach-table.adapter.lifecycle.v1");function ee(e){if(e.isDestroyed())return;let t=e.view.getRoot();t&&B(t),e[C]?.suspend()}function te(e){e.isDestroyed()||e[C]?.resume()}function ne(e,t,n){return e.isDestroyed()?"":e[C]?.readCell(t,n)??""}function oe(e,t){e.isDestroyed()||e[C]?.writeInput(t)}function ie(e){return!e.isDestroyed()&&(e[C]?.canReplaceData()??!1)}var E={columnDefs:{kind:"array",update:"columnDefs"},rowData:{kind:"array",update:"rowData"},defaultColDef:{kind:"object",update:"options"},columnTypes:{kind:"object",update:"options"},rowKey:{kind:"unknown",update:"options"},rowHeight:{kind:"number",update:"options"},headerHeight:{kind:"number",update:"options"},rowBuffer:{kind:"number",update:"options"},columnLayout:{kind:"string",update:"options"},enableColumnResize:{kind:"boolean",update:"options"},domLayout:{kind:"string",update:"options"},rowSelection:{kind:"string",update:"options"},multiSort:{kind:"boolean",update:"options"},size:{kind:"string",update:"options"},stripedRows:{kind:"boolean",update:"options"},rowStyleRules:{kind:"array",update:"options"},showCellBorders:{kind:"boolean",update:"options"},theme:{kind:"string",update:"options"},quickFilterText:{kind:"string",update:"quickFilter"},advancedFilterModel:{kind:"object",update:"options"},masterDetail:{kind:"boolean",update:"options"},detailRowHeight:{kind:"number",update:"options"},detailRowRenderer:{kind:"function",update:"options"},isRowExpandable:{kind:"function",update:"options"},detailToggleColumn:{kind:"boolean",update:"options"},columnMenu:{kind:"boolean",update:"options"},aggFuncs:{kind:"object",update:"options"},components:{kind:"object",update:"options"},actionPolicy:{kind:"object",update:"options"},features:{kind:"array",update:"options"},initialState:{kind:"object",update:"options"},persistence:{kind:"boolean-object",update:"options"},locale:{kind:"object",update:"options"},editType:{kind:"string",update:"options"},editableIndicator:{kind:"string",update:"options"},rowEditValidator:{kind:"function",update:"options"},singleClickEdit:{kind:"boolean",update:"options"},manualSorting:{kind:"boolean",update:"options"},manualFiltering:{kind:"boolean",update:"options"},showSummary:{kind:"boolean",update:"options"},summaryMethod:{kind:"function",update:"options"},treeData:{kind:"boolean",update:"options"},childrenKey:{kind:"string",update:"options"},isTreeRowExpandable:{kind:"function",update:"options"},loadTreeChildren:{kind:"function",update:"options"},autoCheckedChildren:{kind:"boolean",update:"options"},defaultExpandAll:{kind:"boolean",update:"options"},indexOffset:{kind:"number",update:"options"},applyRowDrag:{kind:"boolean",update:"options"},rowDragPolicy:{kind:"object",update:"options"},undoStackSize:{kind:"number",update:"options"},asyncTransactionWaitMillis:{kind:"number",update:"options"},getRowHeight:{kind:"function",update:"options"},pinnedTopRowData:{kind:"array",update:"options"},pinnedBottomRowData:{kind:"array",update:"options"},pagination:{kind:"boolean-object",update:"options"},watermark:{kind:"boolean-object",update:"options"},suppressWarnings:{kind:"boolean",update:"options"},enableRangeSelection:{kind:"boolean",update:"options"},suppressClipboard:{kind:"boolean",update:"options"},contextMenu:{kind:"boolean",update:"options"},getContextMenuItems:{kind:"function",update:"options"},tooltipComponent:{kind:"function",update:"options"},tooltipShowDelay:{kind:"number",update:"options"},flashCells:{kind:"boolean",update:"options"},fillHandle:{kind:"boolean",update:"options"},statusBar:{kind:"boolean-object",update:"options"},datasource:{kind:"object",update:"options"},datasourceMode:{kind:"string",update:"options"},blockSize:{kind:"number",update:"options"},infiniteBufferRows:{kind:"number",update:"options"},maxBlocksInCache:{kind:"number",update:"options"},datasourceMaxConcurrentRequests:{kind:"number",update:"options"},blockPrefetch:{kind:"number",update:"options"},datasourceRowCount:{kind:"number",update:"options"},dataProcessor:{kind:"object",update:"options"},dataProcessorMinRows:{kind:"number",update:"options"},datasourceRetryCount:{kind:"number",update:"options"},datasourceRetryDelay:{kind:"number",update:"options"},datasourceRetryJitter:{kind:"number",update:"options"},suppressCellFocus:{kind:"boolean",update:"options"},suppressRowHoverHighlight:{kind:"boolean",update:"options"},suppressNoRowsOverlay:{kind:"boolean",update:"options"},suppressHeaderFocus:{kind:"boolean",update:"options"},ariaLabel:{kind:"string",update:"options"},ariaLabelledBy:{kind:"string",update:"options"},ariaDescribedBy:{kind:"string",update:"options"},loading:{kind:"boolean",update:"options"},error:{kind:"unknown",update:"options"},overlayNoRowsTemplate:{kind:"unknown",update:"options"},overlayLoadingTemplate:{kind:"unknown",update:"options"},overlayErrorTemplate:{kind:"unknown",update:"options"},allowUnsafeOverlayHtml:{kind:"boolean",update:"options"},className:{kind:"string",update:"options"}},V=Object.freeze(Object.keys(E)),Te=Object.freeze(V.filter(e=>E[e].update==="options"));function S(e,t){return t===void 0?e:typeof t!="object"||t===null||typeof e!="object"||e===null?t:{...e,...t}}function ae(e,t){return typeof e!="function"?t:typeof t!="function"?e:(...n)=>{let o;try{e(...n)}catch(a){o=a}try{t(...n)}catch(a){o??(o=a)}if(o!==void 0)throw o}}function re(e,t){if(!(!e.components&&!t.components))return{cellRenderers:{...e.components?.cellRenderers,...t.components?.cellRenderers},cellEditors:{...e.components?.cellEditors,...t.components?.cellEditors}}}function se(e,t){if(!e.columnTypes&&!t.columnTypes)return;let n={},o=new Set([...Object.keys(e.columnTypes??{}),...Object.keys(t.columnTypes??{})]);for(let a of o)n[a]={...e.columnTypes?.[a],...t.columnTypes?.[a]};return n}function le(e,t,n){for(let o of new Set([...Object.keys(t),...Object.keys(n)])){if(!/^on[A-Z]/.test(o))continue;let a=t[o],u=n[o];typeof a!="function"||typeof u!="function"||(e[o]=ae(a,u))}}function de(e,t){let n={...e,...t,features:t.features??e.features};(e.defaultColDef||t.defaultColDef)&&(n.defaultColDef={...e.defaultColDef,...t.defaultColDef}),(e.locale||t.locale)&&(n.locale={...e.locale,...t.locale});let o=re(e,t);o&&(n.components=o);let a=se(e,t);return a&&(n.columnTypes=a),(e.aggFuncs||t.aggFuncs)&&(n.aggFuncs={...e.aggFuncs,...t.aggFuncs}),n.pagination=S(e.pagination,t.pagination),n.statusBar=S(e.statusBar,t.statusBar),n.watermark=S(e.watermark,t.watermark),le(n,e,t),n}function w(...e){return e.reduce(de,{})}function ce(e){return e?(Array.isArray(e)?e:[e]).filter(t=>typeof t=="string"&&t.trim().length>0):[]}var pe=new Set(["rowData","columnDefs","datasource","loading","error","initialState","persistence","components","columnTypes","stateKey","stateStore","stateSaveDebounceMs","columnStateKey","columnStateStore"]);function $(e,t,n){if(!t||typeof t!="object"||Array.isArray(t))return{};let o={};for(let[a,u]of Object.entries(t)){if(!pe.has(a)){o[a]=u;continue}let r={code:n==="defaults"?"INVALID_DEFAULT_OPTION":"INVALID_PRESET_OPTION",option:a,layer:n,message:`[MachTable] "${a}" is instance-only and cannot be declared in config ${n}.`};if(e.onConfigWarning?.(r),e.strict!==!1)throw new TypeError(r.message)}return o}function U(e={}){let t=$(e,e.defaults,"defaults");return{defaults:w({columnTypes:e.columnTypes,components:e.components},t),presets:Object.fromEntries(Object.entries(e.presets??{}).map(([n,o])=>[n,w($(e,o,`preset:${n}`))])),defaultPreset:e.defaultPreset??!1,strict:e.strict!==!1,...e.onConfigWarning?{onConfigWarning:e.onConfigWarning}:{}}}function ue(e,t){let n=U({...t,strict:t.strict??e.strict,onConfigWarning:t.onConfigWarning??e.onConfigWarning}),o={...e.presets};for(let[a,u]of Object.entries(n.presets))o[a]=w(e.presets[a]??{},u);return{defaults:w(e.defaults,n.defaults),presets:o,defaultPreset:t.defaultPreset===void 0?e.defaultPreset:t.defaultPreset,strict:t.strict??e.strict,...t.onConfigWarning??e.onConfigWarning?{onConfigWarning:t.onConfigWarning??e.onConfigWarning}:{}}}function fe(e,t,n,o){let a=t===void 0?e.defaultPreset:t,u=[{name:"application defaults",options:e.defaults}];for(let s of ce(a)){let m=e.presets[s];if(!m){let d={code:"UNKNOWN_PRESET",preset:s,message:`[MachTable] Unknown preset "${s}". Register it in mach-table.config.ts or remove the preset.`};o?o(d):e.onConfigWarning?e.onConfigWarning(d):console.warn(d.message);continue}u.push({name:`preset:${s}`,options:m})}u.push({name:"table props",options:n});let r=w(...u.map(s=>s.options));return{options:r,explain(s){let m=u.filter(g=>Object.prototype.hasOwnProperty.call(g.options,s)).map(g=>({name:g.name,value:g.options[s]})),d=m[m.length-1];return{key:s,value:r[s],source:d?.name??"MachTable built-in",layers:m}}}}export{V as GRID_OPTION_KEYS,E as GRID_OPTION_META,ie as canReplaceGridData,X as createSelectControl,ue as mergeMachTableConfig,U as normalizeMachTableConfig,ne as readGridCell,fe as resolveMachTableGridOptions,te as resumeGrid,ee as suspendGrid,oe as writeGridInput};
|
|
1
|
+
function M(e,t,n=2){if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length||e.length>100?!1:e.every((a,d)=>M(a,t[d],n-1));if(!j(e)||!j(t))return!1;let o=Object.keys(e);return o.length!==Object.keys(t).length||o.length>100?!1:o.every(a=>Object.prototype.hasOwnProperty.call(t,a)&&M(e[a],t[a],n-1))}function j(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var Z=new Set(["defaultColDef","locale","components","columnTypes","aggFuncs","pagination","statusBar","watermark"]);function Q(e,t,n){return Object.is(t,n)||Z.has(e)&&M(t,n,3)}function h(e,t,n){let o=document.createElement(e);if(t&&(o.className=t),n)for(let a of Object.keys(n))o.setAttribute(a,n[a]);return o}function K(e,t){if(e.classList.add("mach-portal"),!t)return;let n=window.getComputedStyle(t);for(let o=0;o<n.length;o++){let a=n.item(o);if(!a.startsWith("--mach-"))continue;let d=n.getPropertyValue(a).trim();d&&e.style.setProperty(a,d)}e.style.colorScheme=n.colorScheme}function F(e,t,n){return e<t?t:e>n?n:e}var H=0;function _(e="rg"){return H++,`${e}-${H}`}var p=null;function V(e){p?.owner&&(e===p.owner||e.contains(p.owner))&&p.close()}function B(e){let t=e.target;p?.contains(t)||p?.close()}function E(){p?.reposition()}function $(e){e.key!=="Escape"||!p||(e.preventDefault(),e.stopImmediatePropagation(),p.close(!0))}function X(e){p?.close!==e.close&&p?.close(),!p&&(p=e,document.addEventListener("mousedown",B,!0),document.addEventListener("keydown",$,!0),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0))}function ee(e){p?.close===e&&(p=null,document.removeEventListener("mousedown",B,!0),document.removeEventListener("keydown",$,!0),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0))}function w(e,t){return t?`${e} ${t}`:e}function R(e){let t=[];return e.forEach((n,o)=>{n.disabled||t.push(o)}),t}function W(e,t,n){let o=R(e);if(o.length===0)return-1;let a=o.indexOf(t);return a<0?n>0?o[0]:o[o.length-1]:o[Math.max(0,Math.min(o.length-1,a+n))]}function G(e,t){return e.findIndex(n=>n.value===t&&!n.disabled)}function te(e){let t=h("div",w("mach-select-control",e.classNames?.root)),n=h("select",w("mach-select-native",e.classNames?.native));n.hidden=!0,n.tabIndex=-1,n.setAttribute("aria-hidden","true");let o=h("button",w("mach-select-trigger",e.classNames?.trigger));o.type="button",o.setAttribute("role","combobox"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-label",e.ariaLabel);let a=h("span",w("mach-select-value",e.classNames?.value)),d=h("span",w("mach-select-caret",e.classNames?.caret));d.setAttribute("aria-hidden","true"),o.append(a,d);let i=h("div",w("mach-select-listbox",e.classNames?.listbox));i.id=_("mach-select-listbox"),i.setAttribute("role","listbox"),i.setAttribute("aria-hidden","true"),o.setAttribute("aria-controls",i.id),t.append(n,o);let s=[...e.options],m=[],c=-1,g=!1,A=()=>e.themeSource??t.closest(".mach-root")??t,v=()=>{let r=s.find(l=>l.value===n.value);a.textContent=r?.label??n.value,m.forEach((l,b)=>{let u=s[b]?.value===n.value;l.setAttribute("aria-selected",u?"true":"false"),l.classList.toggle("mach-select-option--selected",u),l.classList.toggle("mach-select-option--active",b===c)}),o.setAttribute("aria-activedescendant",c>=0?m[c]?.id??"":"")},S=()=>{let r=o.getBoundingClientRect(),l=i.getBoundingClientRect(),b=Math.max(r.width,l.width),u=F(r.left,8,Math.max(8,window.innerWidth-b-8)),C=window.innerHeight-r.bottom-8,T=C<Math.min(l.height,240)&&r.top>C,f=T?Math.max(8,r.top-l.height-5):Math.min(window.innerHeight-l.height-8,r.bottom+5);i.style.minWidth=`${r.width}px`,i.style.left=`${u}px`,i.style.top=`${Math.max(8,f)}px`,i.classList.toggle("mach-select-listbox--above",T)},y=(r=!1)=>i.classList.contains("mach-select-listbox--open")?(i.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),i.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false"),o.removeAttribute("aria-activedescendant"),i.remove(),ee(y),r&&!g&&o.focus({preventScroll:!0}),!0):!1,Y=(r,l=!0)=>{!s[r]||s[r].disabled||(c=r,v(),l&&m[r]?.scrollIntoView?.({block:"nearest"}))},x=()=>{g||o.disabled||i.classList.contains("mach-select-listbox--open")||(X({owner:A(),close:y,contains:r=>t.contains(r)||i.contains(r),reposition:S}),c=G(s,n.value),c<0&&(c=R(s)[0]??-1),K(i,A()),document.body.appendChild(i),i.classList.add("mach-select-listbox--open"),i.setAttribute("aria-hidden","false"),o.setAttribute("aria-expanded","true"),S(),v(),m[c]?.scrollIntoView?.({block:"nearest"}))},I=r=>{let l=s[r];!l||l.disabled||(n.value=l.value,c=r,v(),y(!0),n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})))},k=(r,l)=>{s=[...r],n.replaceChildren(),i.replaceChildren(),m=s.map((u,C)=>{let T=document.createElement("option");T.value=u.value,T.textContent=u.label,T.disabled=u.disabled===!0,n.appendChild(T);let f=h("button",w("mach-select-option",e.classNames?.option));return f.id=`${i.id}-option-${C}`,f.type="button",f.tabIndex=-1,f.dataset.value=u.value,f.disabled=u.disabled===!0,f.setAttribute("role","option"),f.textContent=u.label,f.addEventListener("mousedown",J=>J.preventDefault()),f.addEventListener("click",()=>I(C)),i.appendChild(f),f});let b=s.find(u=>!u.disabled)?.value??"";n.value=l!=null&&s.some(u=>u.value===l)?l:b,c=G(s,n.value),v()},L=r=>{if(r.key==="Tab"){y();return}if(r.key==="Escape"){if(!y(!0))return;r.preventDefault(),r.stopPropagation();return}if(r.key==="Enter"||r.key===" "){r.preventDefault(),r.stopPropagation(),i.classList.contains("mach-select-listbox--open")?I(c):x();return}let l=c;if(r.key==="ArrowDown")l=W(s,c,1);else if(r.key==="ArrowUp")l=W(s,c,-1);else if(r.key==="Home")l=R(s)[0]??-1;else if(r.key==="End"){let b=R(s);l=b[b.length-1]??-1}else return;r.preventDefault(),r.stopPropagation(),i.classList.contains("mach-select-listbox--open")||x(),Y(l)},N=()=>{c=G(s,n.value),v(),e.onChange?.(n.value)};return o.addEventListener("click",()=>{y()||x()}),o.addEventListener("keydown",L),n.addEventListener("change",N),k(s,e.value),{el:t,native:n,trigger:o,listbox:i,contains:r=>t.contains(r)||i.contains(r),isOpen:()=>i.classList.contains("mach-select-listbox--open"),open:x,close:y,focus:()=>o.focus({preventScroll:!0}),getValue:()=>n.value,setValue:r=>{n.value=r,c=G(s,r),v()},setOptions:k,destroy:()=>{g||(g=!0,y(),o.removeEventListener("keydown",L),n.removeEventListener("change",N),t.remove())}}}var O=Symbol.for("mach-table.adapter.lifecycle.v1");function ne(e){if(e.isDestroyed())return;let t=e.view.getRoot();t&&V(t),e[O]?.suspend()}function oe(e){e.isDestroyed()||e[O]?.resume()}function re(e,t,n){return e.isDestroyed()?"":e[O]?.readCell(t,n)??""}function ae(e,t){e.isDestroyed()||e[O]?.writeInput(t)}function ie(e){return!e.isDestroyed()&&(e[O]?.canReplaceData()??!1)}var se=Symbol.for("mach-table.import.v1");function le(e){let t=e[se];if(!t)throw new TypeError("Import plans require a MachTable GridApi");return t}function ce(e){return e.isDestroyed()?()=>!1:le(e).begin()}var z={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};function de(){return Object.fromEntries(Object.entries(z).map(([e,t])=>[e,{kind:t,update:e==="columnDefs"||e==="rowData"?e:e==="quickFilterText"?"quickFilter":"options"}]))}var ue=de(),pe=Object.freeze(Object.keys(z));function P(e,t){return t===void 0?e:typeof t!="object"||t===null||typeof e!="object"||e===null?t:{...e,...t}}function fe(e,t){return typeof e!="function"?t:typeof t!="function"?e:(...n)=>{let o;try{e(...n)}catch(a){o=a}try{t(...n)}catch(a){o??(o=a)}if(o!==void 0)throw o}}function me(e,t){if(!(!e.components&&!t.components))return{cellRenderers:{...e.components?.cellRenderers,...t.components?.cellRenderers},cellEditors:{...e.components?.cellEditors,...t.components?.cellEditors}}}function ge(e,t){if(!e.columnTypes&&!t.columnTypes)return;let n={},o=new Set([...Object.keys(e.columnTypes??{}),...Object.keys(t.columnTypes??{})]);for(let a of o)n[a]={...e.columnTypes?.[a],...t.columnTypes?.[a]};return n}function be(e,t,n){for(let o of new Set([...Object.keys(t),...Object.keys(n)])){if(!/^on[A-Z]/.test(o))continue;let a=t[o],d=n[o];typeof a!="function"||typeof d!="function"||(e[o]=fe(a,d))}}function ye(e,t){let n={...e,...t,features:t.features??e.features};(e.defaultColDef||t.defaultColDef)&&(n.defaultColDef={...e.defaultColDef,...t.defaultColDef}),(e.locale||t.locale)&&(n.locale={...e.locale,...t.locale});let o=me(e,t);o&&(n.components=o);let a=ge(e,t);return a&&(n.columnTypes=a),(e.aggFuncs||t.aggFuncs)&&(n.aggFuncs={...e.aggFuncs,...t.aggFuncs}),n.pagination=P(e.pagination,t.pagination),n.statusBar=P(e.statusBar,t.statusBar),n.watermark=P(e.watermark,t.watermark),be(n,e,t),n}function D(...e){return e.reduce(ye,{})}function he(e){return e?(Array.isArray(e)?e:[e]).filter(t=>typeof t=="string"&&t.trim().length>0):[]}var Te=new Set(["rowData","columnDefs","datasource","loading","error","initialState","persistence","components","columnTypes","stateKey","stateStore","stateSaveDebounceMs","columnStateKey","columnStateStore"]);function U(e,t,n){if(!t||typeof t!="object"||Array.isArray(t))return{};let o={};for(let[a,d]of Object.entries(t)){if(!Te.has(a)&&(a!=="dataProcessor"||d==null||typeof d=="function")){o[a]=d;continue}let i={code:n==="defaults"?"INVALID_DEFAULT_OPTION":"INVALID_PRESET_OPTION",option:a,layer:n,message:a==="dataProcessor"?`[MachTable] "dataProcessor" in config ${n} must be a factory returning a fresh per-grid instance.`:`[MachTable] "${a}" is instance-only and cannot be declared in config ${n}.`};if(e.onConfigWarning?.(i),e.strict!==!1)throw new TypeError(i.message)}return o}function q(e={}){let t=U(e,e.defaults,"defaults");return{defaults:D({columnTypes:e.columnTypes,components:e.components},t),presets:Object.fromEntries(Object.entries(e.presets??{}).map(([n,o])=>[n,D(U(e,o,`preset:${n}`))])),defaultPreset:e.defaultPreset??!1,strict:e.strict!==!1,...e.onConfigWarning?{onConfigWarning:e.onConfigWarning}:{}}}function we(e,t){let n=q({...t,strict:t.strict??e.strict,onConfigWarning:t.onConfigWarning??e.onConfigWarning}),o={...e.presets};for(let[a,d]of Object.entries(n.presets))o[a]=D(e.presets[a]??{},d);return{defaults:D(e.defaults,n.defaults),presets:o,defaultPreset:t.defaultPreset===void 0?e.defaultPreset:t.defaultPreset,strict:t.strict??e.strict,...t.onConfigWarning??e.onConfigWarning?{onConfigWarning:t.onConfigWarning??e.onConfigWarning}:{}}}function ve(e,t,n,o){let a=t===void 0?e.defaultPreset:t,d=[{name:"application defaults",options:e.defaults}];for(let s of he(a)){let m=e.presets[s];if(!m){let c={code:"UNKNOWN_PRESET",preset:s,message:`[MachTable] Unknown preset "${s}". Register it in mach-table.config.ts or remove the preset.`};o?o(c):e.onConfigWarning?e.onConfigWarning(c):console.warn(c.message);continue}d.push({name:`preset:${s}`,options:m})}d.push({name:"table props",options:n});let i=D(...d.map(s=>s.options));return{options:i,explain(s){let m=d.filter(g=>Object.prototype.hasOwnProperty.call(g.options,s)).map(g=>({name:g.name,value:g.options[s]})),c=m[m.length-1];return{key:s,value:i[s],source:c?.name??"MachTable built-in",layers:m}}}}export{pe as GRID_OPTION_KEYS,ue as GRID_OPTION_META,ce as beginGridInput,ie as canReplaceGridData,te as createSelectControl,M as equivalentConfigValue,Q as equivalentGridOption,we as mergeMachTableConfig,q as normalizeMachTableConfig,re as readGridCell,ve as resolveMachTableGridOptions,oe as resumeGrid,ne as suspendGrid,ae as writeGridInput};
|
package/dist/analysis.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},re=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ee(e))!te.call(n,i)&&i!==t&&R(n,i,{get:()=>e[i],enumerable:!(r=Q(e,i))||r.enumerable});return n};var ie=n=>re(R({},"__esModule",{value:!0}),n);var we={};ne(we,{createPivot:()=>C,evaluateFormulas:()=>N,mountAnalysis:()=>Z});module.exports=ie(we);var oe=new Set(["__proto__","prototype","constructor"]);function E(n){return typeof n!="string"||n.length===0?!1:n.split(".").every(t=>t.length>0&&!oe.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 se=new Set(["sum","count","avg","min","max"]);function z(n){return JSON.stringify(n.map(e=>[e===null?"null":typeof e,e]))}function j(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 ae(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){le(i);let o=JSON.stringify([i.field??null,i.aggregate]);if(r.has(o))throw new TypeError("Duplicate pivot measure");r.add(o)}}function le(n){if(!se.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 G(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 ue(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 ce(n,e){return JSON.stringify([n===null?"total":z(n),e.field??null,e.aggregate])}function C(n,e){ae(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=>j(x(s,p))),m=z(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=>j(x(s,p)));for(let p of e.values){let g=p.field?x(s,p.field):void 0;U(d,r,i,h,p,g),o.length&&U(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)W(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:V(a,u.cells)}));return{columns:a,rows:l,totals:V(a,i),inputCount:n.length}}function W(n,e,t){let r=ce(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 U(n,e,t,r,i,o){let a=W(e,r,i);G(n.cells,a,o),G(t,a,o)}function V(n,e){let t=Object.create(null);for(let r of n)t[r.id]=ue(e.get(r.id),r.measure.aggregate);return t}var f=class extends Error{constructor(t,r){super(r);this.code=t}},B={"+":1,"-":1,"*":2,"/":2,"%":2,"^":3},de=new Set(["SUM","MIN","MAX","AVG"]);function fe(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=me(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 me(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 X(n){let e=fe(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(B,d)?B[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(!de.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 pe(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(pe(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 N(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,X(l))}catch(s){r.set(a,Y(s))}}let i=[];return{rows:n.map((a,l)=>{let s={...a},u=ge(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 Y(n){return n instanceof f?n:new f("SYNTAX",n instanceof Error?n.message:String(n))}function he(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 ge(n,e){let t=new Map,r=new Set,i=o=>{if(!e.has(o))return he(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=Y(l);throw t.set(o,s),s}finally{r.delete(o)}};for(let o of e.keys())try{i(o)}catch{}return t}var ve=["--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 K(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let r of ve){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 q(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",K(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 J(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=[],O=()=>{M.length&&l.append(w("polyline",{points:M.join(" "),fill:"none",stroke:"currentColor","stroke-width":2})),M=[]};return o.forEach((b,L)=>{let S=b.values[e];if(S==null){O();return}let F=55+v*(L+.5),A=p(S),I=b.dimensions.map(H=>H==null?"\u7A7A\u503C":String(H)).join(" / ")||"\u5168\u90E8",$=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"});$.append(w("title",{},`${I}: ${S}`)),l.append($),t==="line"&&M.push(`${F},${A}`),(o.length<=10||L%Math.ceil(o.length/10)===0)&&l.append(w("text",{x:F,y:238,"text-anchor":"middle","font-size":10},I.slice(0,12)))}),O(),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 be={sum:"\u6C42\u548C",count:"\u8BB0\u5F55\u6570",avg:"\u5E73\u5747\u503C",min:"\u6700\u5C0F\u503C",max:"\u6700\u5927\u503C"};function Z(n,e){return new D(n,e)}var D=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=q(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(be).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=N(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
|
+
"use strict";var D=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},le=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ie(e))!se.call(t,o)&&o!==n&&D(t,o,{get:()=>e[o],enumerable:!(r=oe(e,o))||r.enumerable});return t};var ue=t=>le(D({},"__esModule",{value:!0}),t);var ke={};ae(ke,{createPivot:()=>C,evaluateFormulas:()=>S,mountAnalysis:()=>re});module.exports=ue(ke);var ce=new Set(["__proto__","prototype","constructor"]),M=new Map;function G(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&&!ce.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 G(t)!==null}function x(t,e){if(t==null)return;let n=G(e);if(!n)return;let r=t;for(let o of n){if(r==null)return;r=r[o]}return r}function U(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function V(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 B(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 de=new Set(["sum","count","avg","min","max"]);function Y(t){return JSON.stringify(t.map(e=>[e===null?"null":typeof e,e]))}function W(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 me(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){fe(o);let i=JSON.stringify([o.field??null,o.aggregate]);if(r.has(i))throw new TypeError("Duplicate pivot measure");r.add(i)}}function fe(t){if(!de.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 z(t,e,n){let r=t.get(e);r||(r=U(),t.set(e,r)),V(r,n)}function pe(t,e){return JSON.stringify([t===null?"total":Y(t),e.field??null,e.aggregate])}function C(t,e){me(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=>W(x(s,p))),f=Y(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=>W(x(s,p)));for(let p of e.values){let g=p.field?x(s,p.field):void 0;K(d,r,o,h,p,g),i.length&&K(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)q(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:X(a,u.cells)}));return{columns:a,rows:l,totals:X(a,o),inputCount:t.length}}function q(t,e,n){let r=pe(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 K(t,e,n,r,o,i){let a=q(e,r,o);z(t.cells,a,i),z(n,a,i)}function X(t,e){let n=Object.create(null);for(let r of t)n[r.id]=B(e.get(r.id),r.measure.aggregate);return n}var m=class extends Error{constructor(n,r){super(r);this.code=n}},J={"+":1,"-":1,"*":2,"/":2,"%":2,"^":3},he=new Set(["SUM","MIN","MAX","AVG"]);function ge(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=ve(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 ve(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 Z(t){let e=ge(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(J,d)?J[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(!he.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 be(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(be(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 S(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,Z(l))}catch(s){r.set(a,Q(s))}}let o=[];return{rows:t.map((a,l)=>{let s={...a},u=we(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 Q(t){return t instanceof m?t:new m("SYNTAX",t instanceof Error?t.message:String(t))}function ye(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 we(t,e){let n=new Map,r=new Set,o=i=>{if(!e.has(i))return ye(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=Q(l);throw n.set(i,s),s}finally{r.delete(i)}};for(let i of e.keys())try{o(i)}catch{}return n}function ee(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 te(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",ee(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 ne(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=[],O=()=>{P.length&&l.append(y("polyline",{points:P.join(" "),fill:"none",stroke:"currentColor","stroke-width":2})),P=[]};return i.forEach((b,I)=>{let R=b.values[e];if(R==null){O();return}let N=55+v*(I+.5),F=p(R),$=b.dimensions.map(j=>j==null?"\u7A7A\u503C":String(j)).join(" / ")||"\u5168\u90E8",H=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"});H.append(y("title",{},`${$}: ${R}`)),l.append(H),n==="line"&&P.push(`${N},${F}`),(i.length<=10||I%Math.ceil(i.length/10)===0)&&l.append(y("text",{x:N,y:238,"text-anchor":"middle","font-size":10},$.slice(0,12)))}),O(),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 xe={sum:"\u6C42\u548C",count:"\u8BB0\u5F55\u6570",avg:"\u5E73\u5747\u503C",min:"\u6700\u5C0F\u503C",max:"\u6700\u5927\u503C"};function re(t,e){return new L(t,e)}var L=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=te(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(xe).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=S(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=C(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,ne(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}};0&&(module.exports={createPivot,evaluateFormulas,mountAnalysis});
|
package/dist/analysis.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WorkbenchOptions, a as WorkbenchHandle } from './shared-
|
|
2
|
-
import './api-
|
|
1
|
+
import { W as WorkbenchOptions, a as WorkbenchHandle } from './shared-D-DnodkE.cjs';
|
|
2
|
+
import './api-CfZinb9Q.cjs';
|
|
3
3
|
|
|
4
4
|
type PivotAggregate = "sum" | "count" | "avg" | "min" | "max";
|
|
5
5
|
type PivotDimension = string | number | boolean | null;
|
package/dist/analysis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WorkbenchOptions, a as WorkbenchHandle } from './shared-
|
|
2
|
-
import './api-
|
|
1
|
+
import { W as WorkbenchOptions, a as WorkbenchHandle } from './shared-buw2Rj4E.js';
|
|
2
|
+
import './api-CfZinb9Q.js';
|
|
3
3
|
|
|
4
4
|
type PivotAggregate = "sum" | "count" | "avg" | "min" | "max";
|
|
5
5
|
type PivotDimension = string | number | boolean | null;
|