@agile-team/mach-table 0.33.0 → 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 +27 -3
- package/dist/adapter.d.cts +2 -2
- package/dist/adapter.d.ts +2 -2
- package/dist/analysis.d.cts +2 -2
- package/dist/analysis.d.ts +2 -2
- package/dist/{api-CZkd8tYy.d.cts → api-CfZinb9Q.d.cts} +1 -1
- package/dist/{api-CZkd8tYy.d.ts → api-CfZinb9Q.d.ts} +1 -1
- 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-XdxYEMiS.d.cts → configuration-D2lEYcli.d.cts} +1 -1
- package/dist/{configuration-D10N9PqG.d.ts → configuration-WTbQcWck.d.ts} +1 -1
- package/dist/import.d.cts +1 -1
- package/dist/import.d.ts +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +6 -27
- package/dist/index.d.ts +6 -27
- package/dist/index.js +5 -5
- package/dist/multi-range.d.cts +1 -1
- package/dist/multi-range.d.ts +1 -1
- package/dist/ordering.d.cts +1 -1
- package/dist/ordering.d.ts +1 -1
- package/dist/preferences.d.cts +1 -1
- package/dist/preferences.d.ts +1 -1
- package/dist/server-side.d.cts +1 -1
- package/dist/server-side.d.ts +1 -1
- package/dist/{shared-BS_wes40.d.cts → shared-D-DnodkE.d.cts} +1 -1
- package/dist/{shared-ujm7RteA.d.ts → shared-buw2Rj4E.d.ts} +1 -1
- package/dist/workbench.d.cts +3 -3
- package/dist/workbench.d.ts +3 -3
- package/dist/worker.d.cts +2 -2
- package/dist/worker.d.ts +2 -2
- package/package.json +12 -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
|
|
|
@@ -94,6 +94,7 @@ const options: GridOptions<Plan> = {
|
|
|
94
94
|
| `/server-side` | 服务端分组/聚合、route 分页、缓存/刷新/事务及层级选择 |
|
|
95
95
|
| `/multi-range` | Ctrl/Cmd 追加范围、格式化复制、校验清空及撤销 |
|
|
96
96
|
| `/import` | 有界数据预览、共享同步/异步校验、结构化错误与过期保护 |
|
|
97
|
+
| `/business` | 显式字典显示/解析/输出策略、范围与币种/单位分组的本地语义合计 |
|
|
97
98
|
| `/analysis` | Pivot、安全公式、柱/折线图和数据表回退 |
|
|
98
99
|
|
|
99
100
|
```ts
|
|
@@ -111,7 +112,30 @@ filters.destroy();
|
|
|
111
112
|
|
|
112
113
|
Source-available © ChenyCHENYU (Agile Team). 任何使用均须事先取得书面授权。详见 [LICENSE](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSE) 与[授权流程](https://github.com/ChenyCHENYU/MachTable/blob/main/LICENSING.md)。
|
|
113
114
|
|
|
114
|
-
## 0.
|
|
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)
|
|
115
139
|
|
|
116
140
|
`ColDef.valueParser` 统一编辑、粘贴和导入的规范值;`valueSerializer` 按 clipboard/csv/xlsx 定义输出,沿用已有 `columnTypes` 优先级。排序/过滤读取规范值,可信事务与撤销不重复解析。`api.io.importMatrix()` / `exportMatrix()` 直传类型,完整导入预览从当前包的 `/import` 导入 `createImportPlan()`,不加载到默认入口。
|
|
117
141
|
|
package/dist/adapter.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as GridApi, c as GridOptions, j as GridEventType } from './api-
|
|
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
3
|
|
|
4
4
|
/** Bounded structural comparison for small immutable config values, never row data. */
|
|
5
5
|
declare function equivalentConfigValue(left: unknown, right: unknown, depth?: number): boolean;
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as GridApi, c as GridOptions, j as GridEventType } from './api-
|
|
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
3
|
|
|
4
4
|
/** Bounded structural comparison for small immutable config values, never row data. */
|
|
5
5
|
declare function equivalentConfigValue(left: unknown, right: unknown, depth?: number): boolean;
|
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;
|
|
@@ -1423,4 +1423,4 @@ interface GridApi<TData = any> {
|
|
|
1423
1423
|
isDestroyed(): boolean;
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
|
-
export { type
|
|
1426
|
+
export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ValueOutputTarget as V, type ColumnLayoutMode as W, type ColumnMovedEvent as X, type ColumnResizedEvent as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueParserParams as bI, type ValueSerializerParams as bJ, type ValueSetterParams as bK, type WatermarkConfig as bL, formatText as bM, formatTwo as bN, isColDefGroup as bO, matchLocaleKey as bP, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type GridEventType as j, type SaveChangesHandler as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
|
|
@@ -1423,4 +1423,4 @@ interface GridApi<TData = any> {
|
|
|
1423
1423
|
isDestroyed(): boolean;
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
|
-
export { type
|
|
1426
|
+
export { type ContextMenuItem as $, type AdvancedFilterModel as A, type ApplyGridStateOptions as B, type ColDef as C, type CellAlign as D, type CellClassParams as E, type FilterType as F, type GridFeature as G, type CellClassRule as H, type ImportMatrixOptions as I, type CellClickEvent as J, type CellContextMenuEvent as K, type CellDoubleClickEvent as L, type CellEditingStartedEvent as M, type CellEditingStoppedEvent as N, type CellEditorFactory as O, type CellEditorParams as P, type CellRendererOutput as Q, type CellStyleRule as R, type SortModel as S, type CellValueChangedEvent as T, type ColDefOrGroup as U, type ValueOutputTarget as V, type ColumnLayoutMode as W, type ColumnMovedEvent as X, type ColumnResizedEvent as Y, type ColumnVisibilityChangedEvent as Z, type ColumnWorkbenchItem as _, type GridCellRange as a, type PaginationChangedEvent as a$, type ContextMenuParams as a0, type CsvExportParams as a1, DEFAULT_LOCALE as a2, type DatasourceMode as a3, type DateFilterCondition as a4, type DateFilterMatch as a5, type DetailRowRendererParams as a6, type DetailToggledEvent as a7, type DirtyStateChangedEvent as a8, type DomLayoutMode as a9, type GridHierarchyApi as aA, type GridIoApi as aB, type GridPaginationApi as aC, type GridPerformanceSnapshot as aD, type GridPersistenceOptions as aE, type GridReadyEvent as aF, type GridRowsApi as aG, type GridSelectionApi as aH, type GridSortingApi as aI, type GridStateApi as aJ, type GridStateSection as aK, type GridUpdateSchedulerSnapshot as aL, type GridViewApi as aM, type HeaderComponentParams as aN, type ICellEditor as aO, type ICellRendererResult as aP, type ImportCsvOptions as aQ, type InfiniteGetRowsParams as aR, LOCALE_EN as aS, type MachTableLocale as aT, type MachTableLocaleKey as aU, type MatrixExportParams as aV, type ModelUpdatedEvent as aW, type NumberFilterCondition as aX, type NumberFilterMatch as aY, type OverlayContent as aZ, type OverlayTemplate as a_, EVENT_TYPES as aa, type EditableIndicator as ab, type EditableParams as ac, type EventHandlers as ad, type FilterChangedEvent as ae, type GetRowHeightParams as af, type GridAsyncOptions as ag, type GridBatchSaveResult as ah, type GridCellChange as ai, type GridColumnsApi as aj, type GridDataProcessorColumn as ak, type GridDataProcessorRequest as al, type GridDataProcessorResult as am, type GridDataProcessorRow as an, type GridDatasource as ao, type GridDiagnosticError as ap, type GridDiagnostics as aq, type GridDiagnosticsApi as ar, type GridEditType as as, type GridEditingApi as at, type GridErrorCode as au, type GridErrorEvent as av, type GridEventBase as aw, type GridEventMap as ax, type GridFeatureContext as ay, type GridFilteringApi as az, type GridApi as b, type PaginationConfig as b0, type PinnedDirection as b1, type PrintOptions as b2, type RangeSelectionChangedEvent as b3, type RefreshCellsParams as b4, type RemoteBlockCacheSnapshot as b5, type ResolvedGridOptions as b6, type RowClickEvent as b7, type RowDragEndEvent as b8, type RowDragIntent as b9, type ThemeMode as bA, type TooltipParams as bB, type TreeChildrenLoadFailedEvent as bC, type TreeChildrenLoadedEvent as bD, type TreeDataLoadParams as bE, type ValueFormatterParams as bF, type ValueGetterParams as bG, type ValueInputSource as bH, type ValueParserParams as bI, type ValueSerializerParams as bJ, type ValueSetterParams as bK, type WatermarkConfig as bL, formatText as bM, formatTwo as bN, isColDefGroup as bO, matchLocaleKey as bP, type RowDragPolicy as ba, type RowEditChange as bb, type RowEditValidationParams as bc, type RowEditValidationResult as bd, type RowEditingStartedEvent as be, type RowEditingStoppedEvent as bf, type RowNode as bg, type RowSelectionMode as bh, type RowStyleParams as bi, type RowStyleRule as bj, type RowTone as bk, type RowTransaction as bl, type SaveChangeIssue as bm, type SaveChangesResult as bn, type SelectEditorOption as bo, type SelectEditorParams as bp, type SelectionChangedEvent as bq, type SetFilterCondition as br, type SetFilterParams as bs, type SortChangedEvent as bt, type SortDirection as bu, type SortModelItem as bv, type StatusBarConfig as bw, type StatusBarPanel as bx, type TextFilterCondition as by, type TextFilterMatch as bz, type GridOptions as c, type GridDataProcessor as d, type GridComponents as e, type GridState as f, type GridStateStore as g, type FilterModel as h, type FieldPath as i, type GridEventType as j, type SaveChangesHandler as k, type ColumnFilter as l, type AdvancedFilterCondition as m, type AdvancedFilterNode as n, type AdvancedFilterGroup as o, type ColDefGroup as p, type GridStateInput as q, type GridSize as r, type CellRendererParams as s, type GridChange as t, type CellRendererFn as u, type FieldPathValue as v, type SaveChangeConflict as w, type ColumnState as x, type ActionPolicy as y, type ActionPolicyContext as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var o in e)T(t,o,{get:e[o],enumerable:!0})},R=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!E.call(t,r)&&r!==o&&T(t,r,{get:()=>e[r],enumerable:!(a=C(e,r))||a.enumerable});return t};var O=t=>R(T({},"__esModule",{value:!0}),t);var A={};N(A,{createDictionaryColumn:()=>V,summarizeRows:()=>k});module.exports=O(A);var f=Symbol("ambiguous dictionary input");function p(t,e,o){let a=t.get(e);t.set(e,a!==void 0&&a!==o?f:o)}function z(t,e){return t===void 0?e:e===void 0||e===t?t:f}function V(t,e={}){let o=[],a=o,r=new Map,i=new Map,u=new Map,s=new Map,g=()=>{let n=typeof e.options=="function"?e.options():e.options??o;if(n===a)return;let y=new Map(n.map(m=>[m.value,m])),c=new Map,l=new Map,K=new Map;for(let[m,w]of y)p(c,String(m),m),p(l,w.label,m),p(K,`${String(m)} \xB7 ${w.label}`,m);a=n,r=y,i=c,u=l,s=K},b=n=>typeof n=="string"||typeof n=="number",h=n=>(g(),t.get(n)??r.get(n)?.label),D=(n,y)=>{if(n==null||n==="")return"";if(!b(n))return typeof n=="boolean"?String(n):"";let c=String(n);if(y==="code")return c;let l=h(n);return l===void 0?c:y==="label"?l:`${c} \xB7 ${l}`},x=n=>{if(!b(n)||n===""||(g(),r.has(n)||t.get(n)!==void 0||typeof n!="string"))return n;let y=i.get(n)??z(u.get(n),s.get(n));if(y===f)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${n}`);return y??n};return{valueFormatter:({value:n})=>D(n,e.display??"label"),valueParser:({value:n})=>x(n),valueSerializer:({value:n,target:y})=>{let c=e.output?.[y]??"code";return c==="code"?n:D(n,c)}}}function S(t){if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>Number.MAX_SAFE_INTEGER)throw new TypeError("[MachTable] Summary arithmetic requires finite numbers within the safe range; provide numeric for decimal strings or exact arithmetic.");return t}function d(t){if(t!=null&&typeof t.then=="function")throw Promise.resolve(t).catch(()=>{}),new TypeError("[MachTable] Summary numeric callbacks must return synchronous values.");return t}var G={zero:()=>0,add:(t,e)=>S(t+S(e)),divide:(t,e)=>e===0?null:S(t/e)};function M(t,e){let o=new Map;for(let a of t)(a.kind==="sum"||a.kind==="ratio")&&o.set(a.id,{value:d(e.zero()),denominator:d(e.zero())});return{rowCount:0,totals:o}}function $(t,e,o,a){e.rowCount++;for(let r of o){if(r.kind==="count"||r.kind==="none")continue;let i=e.totals.get(r.id),u=r.kind==="sum"?r.value(t):r.numerator(t);if(u!=null&&u!==""&&(i.value=d(a.add(i.value,u))),r.kind==="ratio"){let s=r.denominator(t);s!=null&&s!==""&&(i.denominator=d(a.add(i.denominator,s)))}}}function v(t,e,o){let a=Object.create(null);for(let r of e)if(r.kind!=="none")if(r.kind==="count")a[r.id]=t.rowCount;else{let i=t.totals.get(r.id);a[r.id]=r.kind==="sum"?i.value:d(o.divide(i.value,i.denominator))}return a}function k(t,e){let o=new Set;for(let i of e.metrics){if(!i.id||o.has(i.id))throw new TypeError("[MachTable] Summary metric IDs must be non-empty and unique.");o.add(i.id)}let a=e.numeric??G,r=new Map;e.groupBy||r.set(void 0,M(e.metrics,a));for(let i of t){let u=e.groupBy?.(i);if(e.groupBy&&typeof u!="string"&&(typeof u!="number"||!Number.isFinite(u)))throw new TypeError("[MachTable] Summary group keys must be strings or finite numbers.");let s=r.get(u);s||(s=M(e.metrics,a),r.set(u,s)),$(i,s,e.metrics,a)}return{scope:e.scope,groups:[...r].map(([i,u])=>({key:i,rowCount:u.rowCount,values:v(u,e.metrics,a)}))}}0&&(module.exports={createDictionaryColumn,summarizeRows});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { V as ValueOutputTarget, C as ColDef } from './api-CfZinb9Q.cjs';
|
|
2
|
+
import { D as DictionaryKey, a as DictionaryEntry } from './cachedDictionary-HXvqrDI0.cjs';
|
|
3
|
+
|
|
4
|
+
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
+
interface DictionaryColumnSource<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
get(key: TKey): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface DictionaryColumnOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
10
|
+
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
+
options?: readonly DictionaryEntry<TKey>[] | (() => readonly DictionaryEntry<TKey>[]);
|
|
12
|
+
display?: DictionaryDisplay;
|
|
13
|
+
/** Omitted targets preserve the original code and its type. */
|
|
14
|
+
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
|
+
}
|
|
16
|
+
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
+
declare function createDictionaryColumn<TData = any, TKey extends DictionaryKey = DictionaryKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
|
+
|
|
19
|
+
type SummaryScope = "page" | "selected" | "query";
|
|
20
|
+
type SemanticSummaryMetric<TData> = {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: "sum";
|
|
23
|
+
value(row: TData): unknown;
|
|
24
|
+
} | {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: "count";
|
|
27
|
+
} | {
|
|
28
|
+
id: string;
|
|
29
|
+
kind: "ratio";
|
|
30
|
+
numerator(row: TData): unknown;
|
|
31
|
+
denominator(row: TData): unknown;
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: "none";
|
|
35
|
+
};
|
|
36
|
+
/** Inject existing decimal arithmetic here; validation and divide-by-zero policy belong to the adapter. */
|
|
37
|
+
interface SummaryNumericStrategy<TValue> {
|
|
38
|
+
zero(): TValue;
|
|
39
|
+
add(total: TValue, value: unknown): TValue;
|
|
40
|
+
divide(numerator: TValue, denominator: TValue): TValue | null;
|
|
41
|
+
}
|
|
42
|
+
interface SemanticSummaryOptions<TData, TValue = number> {
|
|
43
|
+
/** Describes rows supplied by the caller; "query" never fetches more rows. */
|
|
44
|
+
scope: SummaryScope;
|
|
45
|
+
metrics: readonly SemanticSummaryMetric<TData>[];
|
|
46
|
+
/** Stable currency/unit composition is an application decision; typed keys stay distinct. */
|
|
47
|
+
groupBy?: (row: TData) => string | number;
|
|
48
|
+
numeric?: SummaryNumericStrategy<TValue>;
|
|
49
|
+
}
|
|
50
|
+
interface SemanticSummaryResult<TValue = number> {
|
|
51
|
+
scope: SummaryScope;
|
|
52
|
+
groups: Array<{
|
|
53
|
+
key: string | number | undefined;
|
|
54
|
+
rowCount: number;
|
|
55
|
+
values: Record<string, TValue | number | null>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** O(rows × metrics) local aggregation, with explicit scope and no implicit currency/unit mixing. */
|
|
59
|
+
declare function summarizeRows<TData, TValue = number>(rows: readonly TData[], options: SemanticSummaryOptions<TData, TValue>): SemanticSummaryResult<TValue>;
|
|
60
|
+
|
|
61
|
+
export { type DictionaryColumnOptions, type DictionaryColumnSource, type DictionaryDisplay, type SemanticSummaryMetric, type SemanticSummaryOptions, type SemanticSummaryResult, type SummaryNumericStrategy, type SummaryScope, createDictionaryColumn, summarizeRows };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { V as ValueOutputTarget, C as ColDef } from './api-CfZinb9Q.js';
|
|
2
|
+
import { D as DictionaryKey, a as DictionaryEntry } from './cachedDictionary-HXvqrDI0.js';
|
|
3
|
+
|
|
4
|
+
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
+
interface DictionaryColumnSource<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
get(key: TKey): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface DictionaryColumnOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
10
|
+
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
+
options?: readonly DictionaryEntry<TKey>[] | (() => readonly DictionaryEntry<TKey>[]);
|
|
12
|
+
display?: DictionaryDisplay;
|
|
13
|
+
/** Omitted targets preserve the original code and its type. */
|
|
14
|
+
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
|
+
}
|
|
16
|
+
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
+
declare function createDictionaryColumn<TData = any, TKey extends DictionaryKey = DictionaryKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
|
+
|
|
19
|
+
type SummaryScope = "page" | "selected" | "query";
|
|
20
|
+
type SemanticSummaryMetric<TData> = {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: "sum";
|
|
23
|
+
value(row: TData): unknown;
|
|
24
|
+
} | {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: "count";
|
|
27
|
+
} | {
|
|
28
|
+
id: string;
|
|
29
|
+
kind: "ratio";
|
|
30
|
+
numerator(row: TData): unknown;
|
|
31
|
+
denominator(row: TData): unknown;
|
|
32
|
+
} | {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: "none";
|
|
35
|
+
};
|
|
36
|
+
/** Inject existing decimal arithmetic here; validation and divide-by-zero policy belong to the adapter. */
|
|
37
|
+
interface SummaryNumericStrategy<TValue> {
|
|
38
|
+
zero(): TValue;
|
|
39
|
+
add(total: TValue, value: unknown): TValue;
|
|
40
|
+
divide(numerator: TValue, denominator: TValue): TValue | null;
|
|
41
|
+
}
|
|
42
|
+
interface SemanticSummaryOptions<TData, TValue = number> {
|
|
43
|
+
/** Describes rows supplied by the caller; "query" never fetches more rows. */
|
|
44
|
+
scope: SummaryScope;
|
|
45
|
+
metrics: readonly SemanticSummaryMetric<TData>[];
|
|
46
|
+
/** Stable currency/unit composition is an application decision; typed keys stay distinct. */
|
|
47
|
+
groupBy?: (row: TData) => string | number;
|
|
48
|
+
numeric?: SummaryNumericStrategy<TValue>;
|
|
49
|
+
}
|
|
50
|
+
interface SemanticSummaryResult<TValue = number> {
|
|
51
|
+
scope: SummaryScope;
|
|
52
|
+
groups: Array<{
|
|
53
|
+
key: string | number | undefined;
|
|
54
|
+
rowCount: number;
|
|
55
|
+
values: Record<string, TValue | number | null>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** O(rows × metrics) local aggregation, with explicit scope and no implicit currency/unit mixing. */
|
|
59
|
+
declare function summarizeRows<TData, TValue = number>(rows: readonly TData[], options: SemanticSummaryOptions<TData, TValue>): SemanticSummaryResult<TValue>;
|
|
60
|
+
|
|
61
|
+
export { type DictionaryColumnOptions, type DictionaryColumnSource, type DictionaryDisplay, type SemanticSummaryMetric, type SemanticSummaryOptions, type SemanticSummaryResult, type SummaryNumericStrategy, type SummaryScope, createDictionaryColumn, summarizeRows };
|
package/dist/business.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Symbol("ambiguous dictionary input");function T(n,t,i){let a=n.get(t);n.set(t,a!==void 0&&a!==i?p:i)}function k(n,t){return n===void 0?t:t===void 0||t===n?n:p}function h(n,t={}){let i=[],a=i,r=new Map,o=new Map,u=new Map,s=new Map,S=()=>{let e=typeof t.options=="function"?t.options():t.options??i;if(e===a)return;let y=new Map(e.map(m=>[m.value,m])),c=new Map,l=new Map,D=new Map;for(let[m,K]of y)T(c,String(m),m),T(l,K.label,m),T(D,`${String(m)} \xB7 ${K.label}`,m);a=e,r=y,o=c,u=l,s=D},g=e=>typeof e=="string"||typeof e=="number",V=e=>(S(),n.get(e)??r.get(e)?.label),b=(e,y)=>{if(e==null||e==="")return"";if(!g(e))return typeof e=="boolean"?String(e):"";let c=String(e);if(y==="code")return c;let l=V(e);return l===void 0?c:y==="label"?l:`${c} \xB7 ${l}`},M=e=>{if(!g(e)||e===""||(S(),r.has(e)||n.get(e)!==void 0||typeof e!="string"))return e;let y=o.get(e)??k(u.get(e),s.get(e));if(y===p)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${e}`);return y??e};return{valueFormatter:({value:e})=>b(e,t.display??"label"),valueParser:({value:e})=>M(e),valueSerializer:({value:e,target:y})=>{let c=t.output?.[y]??"code";return c==="code"?e:b(e,c)}}}function f(n){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>Number.MAX_SAFE_INTEGER)throw new TypeError("[MachTable] Summary arithmetic requires finite numbers within the safe range; provide numeric for decimal strings or exact arithmetic.");return n}function d(n){if(n!=null&&typeof n.then=="function")throw Promise.resolve(n).catch(()=>{}),new TypeError("[MachTable] Summary numeric callbacks must return synchronous values.");return n}var x={zero:()=>0,add:(n,t)=>f(n+f(t)),divide:(n,t)=>t===0?null:f(n/t)};function w(n,t){let i=new Map;for(let a of n)(a.kind==="sum"||a.kind==="ratio")&&i.set(a.id,{value:d(t.zero()),denominator:d(t.zero())});return{rowCount:0,totals:i}}function C(n,t,i,a){t.rowCount++;for(let r of i){if(r.kind==="count"||r.kind==="none")continue;let o=t.totals.get(r.id),u=r.kind==="sum"?r.value(n):r.numerator(n);if(u!=null&&u!==""&&(o.value=d(a.add(o.value,u))),r.kind==="ratio"){let s=r.denominator(n);s!=null&&s!==""&&(o.denominator=d(a.add(o.denominator,s)))}}}function P(n,t,i){let a=Object.create(null);for(let r of t)if(r.kind!=="none")if(r.kind==="count")a[r.id]=n.rowCount;else{let o=n.totals.get(r.id);a[r.id]=r.kind==="sum"?o.value:d(i.divide(o.value,o.denominator))}return a}function E(n,t){let i=new Set;for(let o of t.metrics){if(!o.id||i.has(o.id))throw new TypeError("[MachTable] Summary metric IDs must be non-empty and unique.");i.add(o.id)}let a=t.numeric??x,r=new Map;t.groupBy||r.set(void 0,w(t.metrics,a));for(let o of n){let u=t.groupBy?.(o);if(t.groupBy&&typeof u!="string"&&(typeof u!="number"||!Number.isFinite(u)))throw new TypeError("[MachTable] Summary group keys must be strings or finite numbers.");let s=r.get(u);s||(s=w(t.metrics,a),r.set(u,s)),C(o,s,t.metrics,a)}return{scope:t.scope,groups:[...r].map(([o,u])=>({key:o,rowCount:u.rowCount,values:P(u,t.metrics,a)}))}}export{h as createDictionaryColumn,E as summarizeRows};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type DictionaryKey = string | number;
|
|
2
|
+
interface DictionaryEntry<TKey extends DictionaryKey = DictionaryKey> {
|
|
3
|
+
value: TKey;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
interface CachedDictionaryOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
load(keys: readonly TKey[], signal: AbortSignal): Promise<readonly DictionaryEntry<TKey>[]>;
|
|
8
|
+
/** Positive values expire labels and missing keys; 0 caches until invalidation. */
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
/** LRU capacity shared by resolved labels and missing keys. */
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
batchDelayMs?: number;
|
|
13
|
+
onError?(error: unknown, keys: readonly TKey[]): void;
|
|
14
|
+
}
|
|
15
|
+
interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
16
|
+
get(key: TKey): string | undefined;
|
|
17
|
+
resolve(key: TKey): Promise<string | undefined>;
|
|
18
|
+
resolveMany(keys: readonly TKey[]): Promise<ReadonlyMap<TKey, string>>;
|
|
19
|
+
/** Explicit entries supersede queued/in-flight work for the same keys. */
|
|
20
|
+
prime(entries: readonly DictionaryEntry<TKey>[]): void;
|
|
21
|
+
/** Evicts keys and settles their pending lookups with undefined; later resolves load anew. */
|
|
22
|
+
invalidate(keys?: readonly TKey[]): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
/** Cached labels and missing keys, bounded by maxSize. */
|
|
25
|
+
readonly size: number;
|
|
26
|
+
}
|
|
27
|
+
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
|
+
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
|
+
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type DictionaryEntry as a, type CachedDictionaryOptions as b, createCachedDictionary as c };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type DictionaryKey = string | number;
|
|
2
|
+
interface DictionaryEntry<TKey extends DictionaryKey = DictionaryKey> {
|
|
3
|
+
value: TKey;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
interface CachedDictionaryOptions<TKey extends DictionaryKey = DictionaryKey> {
|
|
7
|
+
load(keys: readonly TKey[], signal: AbortSignal): Promise<readonly DictionaryEntry<TKey>[]>;
|
|
8
|
+
/** Positive values expire labels and missing keys; 0 caches until invalidation. */
|
|
9
|
+
ttlMs?: number;
|
|
10
|
+
/** LRU capacity shared by resolved labels and missing keys. */
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
batchDelayMs?: number;
|
|
13
|
+
onError?(error: unknown, keys: readonly TKey[]): void;
|
|
14
|
+
}
|
|
15
|
+
interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
16
|
+
get(key: TKey): string | undefined;
|
|
17
|
+
resolve(key: TKey): Promise<string | undefined>;
|
|
18
|
+
resolveMany(keys: readonly TKey[]): Promise<ReadonlyMap<TKey, string>>;
|
|
19
|
+
/** Explicit entries supersede queued/in-flight work for the same keys. */
|
|
20
|
+
prime(entries: readonly DictionaryEntry<TKey>[]): void;
|
|
21
|
+
/** Evicts keys and settles their pending lookups with undefined; later resolves load anew. */
|
|
22
|
+
invalidate(keys?: readonly TKey[]): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
/** Cached labels and missing keys, bounded by maxSize. */
|
|
25
|
+
readonly size: number;
|
|
26
|
+
}
|
|
27
|
+
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
|
+
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
|
+
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type DictionaryEntry as a, type CachedDictionaryOptions as b, createCachedDictionary as c };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-
|
|
1
|
+
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-CfZinb9Q.cjs';
|
|
2
2
|
|
|
3
3
|
type MachTablePresetSelection = string | readonly string[] | false;
|
|
4
4
|
type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-
|
|
1
|
+
import { c as GridOptions, d as GridDataProcessor, C as ColDef, e as GridComponents } from './api-CfZinb9Q.js';
|
|
2
2
|
|
|
3
3
|
type MachTablePresetSelection = string | readonly string[] | false;
|
|
4
4
|
type MachTableInstanceOptionKey = "rowData" | "columnDefs" | "datasource" | "loading" | "error" | "initialState" | "persistence" | "components" | "columnTypes";
|
package/dist/import.d.cts
CHANGED
package/dist/import.d.ts
CHANGED