@agile-team/mach-table 0.35.2 → 0.36.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 +3 -1
- package/dist/business.cjs +1 -1
- package/dist/business.d.cts +12 -5
- package/dist/business.d.ts +12 -5
- package/dist/business.js +1 -1
- package/dist/{cachedDictionary-HXvqrDI0.d.cts → cachedDictionary-C26hMT22.d.cts} +1 -1
- package/dist/{cachedDictionary-HXvqrDI0.d.ts → cachedDictionary-C26hMT22.d.ts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/mach-table.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
# @agile-team/mach-table
|
|
6
6
|
|
|
7
|
-
MachTable 0.
|
|
7
|
+
MachTable 0.36.0 的框架无关 TypeScript Core:零运行时依赖,提供行列双虚拟化、领域化 API、单元格/整行编辑、树与分组、随机访问远程数据、区段隔离状态持久化和可诊断扩展系统。本版统一完整表头宽度下限,覆盖初始布局、fit、状态恢复及交互缩列,内置插画空态与亮暗主题继续保留;可选 `/business` 的字典列策略、本地语义合计及字典缓存隔离继续兼容;普通根入口 API 和既有默认行为保持兼容。
|
|
8
|
+
|
|
9
|
+
小型本地明细可使用 `domLayout: "autoHeight"` 随当前页内容收起;本版为该模式的空态、加载态和错误态预留必要展示空间,恢复数据后释放最小高度。可通过 `--mach-overlay-min-height` 局部调整。大数据表继续使用有明确高度的默认虚拟布局。
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @agile-team/mach-table
|
package/dist/business.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var N=(n,e)=>{for(var o in e)f(n,o,{get:e[o],enumerable:!0})},R=(n,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!E.call(n,r)&&r!==o&&f(n,r,{get:()=>e[r],enumerable:!(a=x(e,r))||a.enumerable});return n};var O=n=>R(f({},"__esModule",{value:!0}),n);var B={};N(B,{createDictionaryColumn:()=>C,summarizeRows:()=>k});module.exports=O(B);var g=Symbol("ambiguous dictionary input");function S(n,e,o){let a=n.get(e);n.set(e,a!==void 0&&a!==o?g:o)}function A(n,e){return n===void 0?e:e===void 0||e===n?n:g}function C(n,e={}){let o=[],a=o,r=new Map,i=new Map,u=new Map,m=new Map,K=()=>{let t=typeof e.options=="function"?e.options():e.options??o;if(t===a)return;let s=new Map(t.map(c=>[c.value,c])),y=new Map,l=new Map,T=new Map;for(let[c,V]of s)S(y,String(c),c),S(l,V.label,c),S(T,`${String(c)} \xB7 ${V.label}`,c);a=t,r=s,i=y,u=l,m=T},w=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean",h=t=>(K(),n.get(t)??r.get(t)?.label),p=(t,s)=>{if(Array.isArray(t))return t.map(T=>p(T,s)).join(e.separator??"\u3001");if(t==null||!w(t))return"";let y=String(t);if(s==="code")return y;let l=h(t);return l===void 0?y:s==="label"?l:`${y} \xB7 ${l}`},D=t=>{if(Array.isArray(t))return t.map(D);if(!w(t)||t===""||(K(),r.has(t)||n.get(t)!==void 0||typeof t!="string"))return t;let s=i.get(t)??A(u.get(t),m.get(t));if(s===g)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${t}`);return s??t};return{valueFormatter:({value:t})=>p(t,e.display??"label"),valueParser:({value:t})=>D(t),valueSerializer:({value:t,target:s})=>{let y=e.output?.[s]??"code";return y==="code"?t:p(t,y)}}}function b(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 z={zero:()=>0,add:(n,e)=>b(n+b(e)),divide:(n,e)=>e===0?null:b(n/e)};function M(n,e){let o=new Map;for(let a of n)(a.kind==="sum"||a.kind==="ratio")&&o.set(a.id,{value:d(e.zero()),denominator:d(e.zero())});return{rowCount:0,totals:o}}function G(n,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(n):r.numerator(n);if(u!=null&&u!==""&&(i.value=d(a.add(i.value,u))),r.kind==="ratio"){let m=r.denominator(n);m!=null&&m!==""&&(i.denominator=d(a.add(i.denominator,m)))}}}function $(n,e,o){let a=Object.create(null);for(let r of e)if(r.kind!=="none")if(r.kind==="count")a[r.id]=n.rowCount;else{let i=n.totals.get(r.id);a[r.id]=r.kind==="sum"?i.value:d(o.divide(i.value,i.denominator))}return a}function k(n,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??z,r=new Map;e.groupBy||r.set(void 0,M(e.metrics,a));for(let i of n){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 m=r.get(u);m||(m=M(e.metrics,a),r.set(u,m)),G(i,m,e.metrics,a)}return{scope:e.scope,groups:[...r].map(([i,u])=>({key:i,rowCount:u.rowCount,values:$(u,e.metrics,a)}))}}0&&(module.exports={createDictionaryColumn,summarizeRows});
|
package/dist/business.d.cts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { V as ValueOutputTarget, C as ColDef } from './api-Di5SQHAP.cjs';
|
|
2
|
-
import { D as DictionaryKey
|
|
2
|
+
import { D as DictionaryKey } from './cachedDictionary-C26hMT22.cjs';
|
|
3
3
|
|
|
4
4
|
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
type ColumnKey = DictionaryKey | boolean;
|
|
6
|
+
interface ColumnEntry<TKey extends ColumnKey> {
|
|
7
|
+
value: TKey;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
5
10
|
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
-
interface DictionaryColumnSource<TKey extends
|
|
11
|
+
interface DictionaryColumnSource<TKey extends ColumnKey = ColumnKey> {
|
|
7
12
|
get(key: TKey): string | undefined;
|
|
8
13
|
}
|
|
9
|
-
interface DictionaryColumnOptions<TKey extends
|
|
14
|
+
interface DictionaryColumnOptions<TKey extends ColumnKey = ColumnKey> {
|
|
10
15
|
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
-
options?: readonly
|
|
16
|
+
options?: readonly ColumnEntry<TKey>[] | (() => readonly ColumnEntry<TKey>[]);
|
|
12
17
|
display?: DictionaryDisplay;
|
|
18
|
+
/** Array display/output only; input strings are never split implicitly. */
|
|
19
|
+
separator?: string;
|
|
13
20
|
/** Omitted targets preserve the original code and its type. */
|
|
14
21
|
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
22
|
}
|
|
16
23
|
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
-
declare function createDictionaryColumn<TData = any, TKey extends
|
|
24
|
+
declare function createDictionaryColumn<TData = any, TKey extends ColumnKey = ColumnKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
25
|
|
|
19
26
|
type SummaryScope = "page" | "selected" | "query";
|
|
20
27
|
type SemanticSummaryMetric<TData> = {
|
package/dist/business.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { V as ValueOutputTarget, C as ColDef } from './api-Di5SQHAP.js';
|
|
2
|
-
import { D as DictionaryKey
|
|
2
|
+
import { D as DictionaryKey } from './cachedDictionary-C26hMT22.js';
|
|
3
3
|
|
|
4
4
|
type DictionaryDisplay = "code" | "label" | "code-label";
|
|
5
|
+
type ColumnKey = DictionaryKey | boolean;
|
|
6
|
+
interface ColumnEntry<TKey extends ColumnKey> {
|
|
7
|
+
value: TKey;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
5
10
|
/** Structural adapter for an existing provider; this helper never loads or caches remote data. */
|
|
6
|
-
interface DictionaryColumnSource<TKey extends
|
|
11
|
+
interface DictionaryColumnSource<TKey extends ColumnKey = ColumnKey> {
|
|
7
12
|
get(key: TKey): string | undefined;
|
|
8
13
|
}
|
|
9
|
-
interface DictionaryColumnOptions<TKey extends
|
|
14
|
+
interface DictionaryColumnOptions<TKey extends ColumnKey = ColumnKey> {
|
|
10
15
|
/** Immutable snapshot for reverse parsing. Replace its identity when options change. */
|
|
11
|
-
options?: readonly
|
|
16
|
+
options?: readonly ColumnEntry<TKey>[] | (() => readonly ColumnEntry<TKey>[]);
|
|
12
17
|
display?: DictionaryDisplay;
|
|
18
|
+
/** Array display/output only; input strings are never split implicitly. */
|
|
19
|
+
separator?: string;
|
|
13
20
|
/** Omitted targets preserve the original code and its type. */
|
|
14
21
|
output?: Partial<Record<ValueOutputTarget, DictionaryDisplay>>;
|
|
15
22
|
}
|
|
16
23
|
/** Explicit, synchronous dictionary presentation and typed IO; no existing defaults are changed. */
|
|
17
|
-
declare function createDictionaryColumn<TData = any, TKey extends
|
|
24
|
+
declare function createDictionaryColumn<TData = any, TKey extends ColumnKey = ColumnKey>(source: DictionaryColumnSource<TKey>, config?: DictionaryColumnOptions<TKey>): Partial<ColDef<TData>>;
|
|
18
25
|
|
|
19
26
|
type SummaryScope = "page" | "selected" | "query";
|
|
20
27
|
type SemanticSummaryMetric<TData> = {
|
package/dist/business.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Symbol("ambiguous dictionary input");function f(t,n,i){let a=t.get(n);t.set(n,a!==void 0&&a!==i?S:i)}function M(t,n){return t===void 0?n:n===void 0||n===t?t:S}function k(t,n={}){let i=[],a=i,r=new Map,o=new Map,u=new Map,m=new Map,b=()=>{let e=typeof n.options=="function"?n.options():n.options??i;if(e===a)return;let s=new Map(e.map(c=>[c.value,c])),y=new Map,l=new Map,T=new Map;for(let[c,D]of s)f(y,String(c),c),f(l,D.label,c),f(T,`${String(c)} \xB7 ${D.label}`,c);a=e,r=s,o=y,u=l,m=T},K=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean",C=e=>(b(),t.get(e)??r.get(e)?.label),p=(e,s)=>{if(Array.isArray(e))return e.map(T=>p(T,s)).join(n.separator??"\u3001");if(e==null||!K(e))return"";let y=String(e);if(s==="code")return y;let l=C(e);return l===void 0?y:s==="label"?l:`${y} \xB7 ${l}`},w=e=>{if(Array.isArray(e))return e.map(w);if(!K(e)||e===""||(b(),r.has(e)||t.get(e)!==void 0||typeof e!="string"))return e;let s=o.get(e)??M(u.get(e),m.get(e));if(s===S)throw new TypeError(`[MachTable] Ambiguous dictionary value: ${e}`);return s??e};return{valueFormatter:({value:e})=>p(e,n.display??"label"),valueParser:({value:e})=>w(e),valueSerializer:({value:e,target:s})=>{let y=n.output?.[s]??"code";return y==="code"?e:p(e,y)}}}function g(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 h={zero:()=>0,add:(t,n)=>g(t+g(n)),divide:(t,n)=>n===0?null:g(t/n)};function V(t,n){let i=new Map;for(let a of t)(a.kind==="sum"||a.kind==="ratio")&&i.set(a.id,{value:d(n.zero()),denominator:d(n.zero())});return{rowCount:0,totals:i}}function x(t,n,i,a){n.rowCount++;for(let r of i){if(r.kind==="count"||r.kind==="none")continue;let o=n.totals.get(r.id),u=r.kind==="sum"?r.value(t):r.numerator(t);if(u!=null&&u!==""&&(o.value=d(a.add(o.value,u))),r.kind==="ratio"){let m=r.denominator(t);m!=null&&m!==""&&(o.denominator=d(a.add(o.denominator,m)))}}}function P(t,n,i){let a=Object.create(null);for(let r of n)if(r.kind!=="none")if(r.kind==="count")a[r.id]=t.rowCount;else{let o=t.totals.get(r.id);a[r.id]=r.kind==="sum"?o.value:d(i.divide(o.value,o.denominator))}return a}function E(t,n){let i=new Set;for(let o of n.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=n.numeric??h,r=new Map;n.groupBy||r.set(void 0,V(n.metrics,a));for(let o of t){let u=n.groupBy?.(o);if(n.groupBy&&typeof u!="string"&&(typeof u!="number"||!Number.isFinite(u)))throw new TypeError("[MachTable] Summary group keys must be strings or finite numbers.");let m=r.get(u);m||(m=V(n.metrics,a),r.set(u,m)),x(o,m,n.metrics,a)}return{scope:n.scope,groups:[...r].map(([o,u])=>({key:o,rowCount:u.rowCount,values:P(u,n.metrics,a)}))}}export{k as createDictionaryColumn,E as summarizeRows};
|
|
@@ -27,4 +27,4 @@ interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
|
27
27
|
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
28
|
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
29
|
|
|
30
|
-
export { type CachedDictionary as C, type DictionaryKey as D, type
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type CachedDictionaryOptions as a, type DictionaryEntry as b, createCachedDictionary as c };
|
|
@@ -27,4 +27,4 @@ interface CachedDictionary<TKey extends DictionaryKey = DictionaryKey> {
|
|
|
27
27
|
/** Bounded TTL/LRU resolver; pending entry identity isolates invalidated generations. */
|
|
28
28
|
declare function createCachedDictionary<TKey extends DictionaryKey = DictionaryKey>(options: CachedDictionaryOptions<TKey>): CachedDictionary<TKey>;
|
|
29
29
|
|
|
30
|
-
export { type CachedDictionary as C, type DictionaryKey as D, type
|
|
30
|
+
export { type CachedDictionary as C, type DictionaryKey as D, type CachedDictionaryOptions as a, type DictionaryEntry as b, createCachedDictionary as c };
|