@affino/datagrid-pivot 0.1.1
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/contracts.d.ts +32 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +1 -0
- package/dist/coreTypes.d.ts +163 -0
- package/dist/coreTypes.d.ts.map +1 -0
- package/dist/coreTypes.js +1 -0
- package/dist/drilldownContracts.d.ts +18 -0
- package/dist/drilldownContracts.d.ts.map +1 -0
- package/dist/drilldownContracts.js +1 -0
- package/dist/drilldownRuntime.d.ts +17 -0
- package/dist/drilldownRuntime.d.ts.map +1 -0
- package/dist/drilldownRuntime.js +103 -0
- package/dist/fieldRuntime.d.ts +8 -0
- package/dist/fieldRuntime.d.ts.map +1 -0
- package/dist/fieldRuntime.js +52 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +161 -0
- package/dist/incrementalHelpers.d.ts +23 -0
- package/dist/incrementalHelpers.d.ts.map +1 -0
- package/dist/incrementalHelpers.js +107 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/layoutContracts.d.ts +28 -0
- package/dist/layoutContracts.d.ts.map +1 -0
- package/dist/layoutContracts.js +1 -0
- package/dist/layoutRuntime.d.ts +9 -0
- package/dist/layoutRuntime.d.ts.map +1 -0
- package/dist/layoutRuntime.js +160 -0
- package/dist/runtimeContracts.d.ts +30 -0
- package/dist/runtimeContracts.d.ts.map +1 -0
- package/dist/runtimeContracts.js +1 -0
- package/dist/runtimeHelpers.d.ts +34 -0
- package/dist/runtimeHelpers.d.ts.map +1 -0
- package/dist/runtimeHelpers.js +105 -0
- package/package.json +41 -0
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
function isPivotAggOp(value) {
|
|
2
|
+
return (value === "sum"
|
|
3
|
+
|| value === "avg"
|
|
4
|
+
|| value === "min"
|
|
5
|
+
|| value === "max"
|
|
6
|
+
|| value === "count"
|
|
7
|
+
|| value === "countNonNull"
|
|
8
|
+
|| value === "first"
|
|
9
|
+
|| value === "last"
|
|
10
|
+
|| value === "custom");
|
|
11
|
+
}
|
|
12
|
+
function normalizePivotFieldList(input) {
|
|
13
|
+
if (!Array.isArray(input)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const unique = new Set();
|
|
17
|
+
for (const rawField of input) {
|
|
18
|
+
if (typeof rawField !== "string") {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const field = rawField.trim();
|
|
22
|
+
if (field.length === 0 || unique.has(field)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
unique.add(field);
|
|
26
|
+
}
|
|
27
|
+
return Array.from(unique);
|
|
28
|
+
}
|
|
29
|
+
export function normalizePivotSpec(pivotSpec) {
|
|
30
|
+
if (!pivotSpec) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const normalizedRows = normalizePivotFieldList(pivotSpec.rows);
|
|
34
|
+
const normalizedColumns = normalizePivotFieldList(pivotSpec.columns);
|
|
35
|
+
const normalizedValues = [];
|
|
36
|
+
const seenValues = new Set();
|
|
37
|
+
if (Array.isArray(pivotSpec.values)) {
|
|
38
|
+
for (const valueSpec of pivotSpec.values) {
|
|
39
|
+
const field = typeof (valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.field) === "string"
|
|
40
|
+
? valueSpec.field.trim()
|
|
41
|
+
: "";
|
|
42
|
+
const agg = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.agg;
|
|
43
|
+
if (field.length === 0 || !isPivotAggOp(agg)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const dedupeKey = `${field}::${agg}`;
|
|
47
|
+
if (seenValues.has(dedupeKey)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
seenValues.add(dedupeKey);
|
|
51
|
+
normalizedValues.push({
|
|
52
|
+
field,
|
|
53
|
+
agg,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (normalizedValues.length === 0) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const rowSubtotals = pivotSpec.rowSubtotals === true;
|
|
61
|
+
const columnSubtotals = pivotSpec.columnSubtotals === true;
|
|
62
|
+
const columnGrandTotal = pivotSpec.columnGrandTotal === true;
|
|
63
|
+
const columnSubtotalPosition = pivotSpec.columnSubtotalPosition === "before"
|
|
64
|
+
? "before"
|
|
65
|
+
: undefined;
|
|
66
|
+
const columnGrandTotalPosition = pivotSpec.columnGrandTotalPosition === "first"
|
|
67
|
+
? "first"
|
|
68
|
+
: undefined;
|
|
69
|
+
const grandTotal = pivotSpec.grandTotal === true;
|
|
70
|
+
return {
|
|
71
|
+
rows: normalizedRows,
|
|
72
|
+
columns: normalizedColumns,
|
|
73
|
+
values: normalizedValues,
|
|
74
|
+
...(rowSubtotals ? { rowSubtotals: true } : {}),
|
|
75
|
+
...(columnSubtotals ? { columnSubtotals: true } : {}),
|
|
76
|
+
...(columnGrandTotal ? { columnGrandTotal: true } : {}),
|
|
77
|
+
...(columnSubtotalPosition ? { columnSubtotalPosition } : {}),
|
|
78
|
+
...(columnGrandTotalPosition ? { columnGrandTotalPosition } : {}),
|
|
79
|
+
...(grandTotal ? { grandTotal: true } : {}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export function clonePivotSpec(pivotSpec) {
|
|
83
|
+
const normalized = normalizePivotSpec(pivotSpec);
|
|
84
|
+
if (!normalized) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
rows: [...normalized.rows],
|
|
89
|
+
columns: [...normalized.columns],
|
|
90
|
+
values: normalized.values.map(value => ({ ...value })),
|
|
91
|
+
...(normalized.rowSubtotals ? { rowSubtotals: true } : {}),
|
|
92
|
+
...(normalized.columnSubtotals ? { columnSubtotals: true } : {}),
|
|
93
|
+
...(normalized.columnGrandTotal ? { columnGrandTotal: true } : {}),
|
|
94
|
+
...(normalized.columnSubtotalPosition
|
|
95
|
+
? { columnSubtotalPosition: normalized.columnSubtotalPosition }
|
|
96
|
+
: {}),
|
|
97
|
+
...(normalized.columnGrandTotalPosition
|
|
98
|
+
? { columnGrandTotalPosition: normalized.columnGrandTotalPosition }
|
|
99
|
+
: {}),
|
|
100
|
+
...(normalized.grandTotal ? { grandTotal: true } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function isSamePivotSpec(left, right) {
|
|
104
|
+
var _a, _b, _c, _d;
|
|
105
|
+
const normalizedLeft = normalizePivotSpec(left);
|
|
106
|
+
const normalizedRight = normalizePivotSpec(right);
|
|
107
|
+
if (!normalizedLeft && !normalizedRight) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
if (!normalizedLeft || !normalizedRight) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (normalizedLeft.rows.length !== normalizedRight.rows.length) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (normalizedLeft.columns.length !== normalizedRight.columns.length) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (normalizedLeft.values.length !== normalizedRight.values.length) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (Boolean(normalizedLeft.rowSubtotals) !== Boolean(normalizedRight.rowSubtotals)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
if (Boolean(normalizedLeft.columnSubtotals) !== Boolean(normalizedRight.columnSubtotals)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (Boolean(normalizedLeft.columnGrandTotal) !== Boolean(normalizedRight.columnGrandTotal)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (((_a = normalizedLeft.columnSubtotalPosition) !== null && _a !== void 0 ? _a : "after") !== ((_b = normalizedRight.columnSubtotalPosition) !== null && _b !== void 0 ? _b : "after")) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (((_c = normalizedLeft.columnGrandTotalPosition) !== null && _c !== void 0 ? _c : "last") !== ((_d = normalizedRight.columnGrandTotalPosition) !== null && _d !== void 0 ? _d : "last")) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (Boolean(normalizedLeft.grandTotal) !== Boolean(normalizedRight.grandTotal)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
for (let index = 0; index < normalizedLeft.rows.length; index += 1) {
|
|
141
|
+
if (normalizedLeft.rows[index] !== normalizedRight.rows[index]) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
for (let index = 0; index < normalizedLeft.columns.length; index += 1) {
|
|
146
|
+
if (normalizedLeft.columns[index] !== normalizedRight.columns[index]) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
for (let index = 0; index < normalizedLeft.values.length; index += 1) {
|
|
151
|
+
const leftValue = normalizedLeft.values[index];
|
|
152
|
+
const rightValue = normalizedRight.values[index];
|
|
153
|
+
if (!leftValue || !rightValue) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (leftValue.field !== rightValue.field || leftValue.agg !== rightValue.agg) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DataGridIncrementalAggregationLeafContribution } from "./coreTypes.js";
|
|
2
|
+
import type { DataGridRowNode } from "./coreTypes.js";
|
|
3
|
+
import type { DataGridPivotFieldResolver } from "./fieldRuntime.js";
|
|
4
|
+
export interface DataGridPivotIncrementalTouchedKeys {
|
|
5
|
+
rowEntryKeys: readonly string[];
|
|
6
|
+
columnKeys: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export interface DataGridPivotIncrementalTouchedKeysState<T> {
|
|
9
|
+
rowEntries: ReadonlyMap<string, unknown>;
|
|
10
|
+
runtimeColumnsByColumnKey: ReadonlyMap<string, readonly unknown[]>;
|
|
11
|
+
rowFieldResolvers: readonly DataGridPivotFieldResolver<T>[];
|
|
12
|
+
columnFieldResolvers: readonly DataGridPivotFieldResolver<T>[];
|
|
13
|
+
normalizeFieldValue: (value: unknown) => string;
|
|
14
|
+
includeRowSubtotals: boolean;
|
|
15
|
+
includeColumnSubtotals: boolean;
|
|
16
|
+
includeGrandTotal: boolean;
|
|
17
|
+
includeColumnGrandTotal: boolean;
|
|
18
|
+
columnGrandTotalKey: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function isSameLeafContribution(left: DataGridIncrementalAggregationLeafContribution, right: DataGridIncrementalAggregationLeafContribution): boolean;
|
|
21
|
+
export declare function buildPivotIncrementalTouchedKeys<T>(row: DataGridRowNode<T>, state: DataGridPivotIncrementalTouchedKeysState<T>): DataGridPivotIncrementalTouchedKeys | null;
|
|
22
|
+
export declare function isSamePivotTouchedKeys(left: DataGridPivotIncrementalTouchedKeys, right: DataGridPivotIncrementalTouchedKeys): boolean;
|
|
23
|
+
//# sourceMappingURL=incrementalHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incrementalHelpers.d.ts","sourceRoot":"","sources":["../src/incrementalHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8CAA8C,EAC/C,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACV,0BAA0B,EAC3B,MAAM,mBAAmB,CAAA;AAM1B,MAAM,WAAW,mCAAmC;IAClD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,wCAAwC,CAAC,CAAC;IACzD,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC,yBAAyB,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAA;IAClE,iBAAiB,EAAE,SAAS,0BAA0B,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,oBAAoB,EAAE,SAAS,0BAA0B,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9D,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAA;IAC/C,mBAAmB,EAAE,OAAO,CAAA;IAC5B,sBAAsB,EAAE,OAAO,CAAA;IAC/B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,uBAAuB,EAAE,OAAO,CAAA;IAChC,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,8CAA8C,EACpD,KAAK,EAAE,8CAA8C,GACpD,OAAO,CAkCT;AAED,wBAAgB,gCAAgC,CAAC,CAAC,EAChD,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,EACvB,KAAK,EAAE,wCAAwC,CAAC,CAAC,CAAC,GACjD,mCAAmC,GAAG,IAAI,CA2D5C;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,mCAAmC,EACzC,KAAK,EAAE,mCAAmC,GACzC,OAAO,CAeT"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createPivotAxisKey, normalizePivotAxisValue, } from "./runtimeHelpers.js";
|
|
2
|
+
export function isSameLeafContribution(left, right) {
|
|
3
|
+
const leftKeys = Object.keys(left);
|
|
4
|
+
const rightKeys = Object.keys(right);
|
|
5
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
for (const key of leftKeys) {
|
|
9
|
+
const leftValue = left[key];
|
|
10
|
+
const rightValue = right[key];
|
|
11
|
+
if (typeof leftValue === "object" &&
|
|
12
|
+
leftValue !== null &&
|
|
13
|
+
typeof rightValue === "object" &&
|
|
14
|
+
rightValue !== null) {
|
|
15
|
+
const leftRecord = leftValue;
|
|
16
|
+
const rightRecord = rightValue;
|
|
17
|
+
const leftRecordKeys = Object.keys(leftRecord);
|
|
18
|
+
const rightRecordKeys = Object.keys(rightRecord);
|
|
19
|
+
if (leftRecordKeys.length !== rightRecordKeys.length) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
for (const nestedKey of leftRecordKeys) {
|
|
23
|
+
if (leftRecord[nestedKey] !== rightRecord[nestedKey]) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (leftValue !== rightValue) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
export function buildPivotIncrementalTouchedKeys(row, state) {
|
|
36
|
+
if (row.kind !== "leaf") {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const rowPath = state.rowFieldResolvers.map(resolver => ({
|
|
40
|
+
field: resolver.field,
|
|
41
|
+
value: normalizePivotAxisValue(resolver.read(row), state.normalizeFieldValue),
|
|
42
|
+
}));
|
|
43
|
+
const columnPath = state.columnFieldResolvers.map(resolver => ({
|
|
44
|
+
field: resolver.field,
|
|
45
|
+
value: normalizePivotAxisValue(resolver.read(row), state.normalizeFieldValue),
|
|
46
|
+
}));
|
|
47
|
+
const rowKey = createPivotAxisKey("pivot:row:", rowPath);
|
|
48
|
+
const rowEntryKeys = [];
|
|
49
|
+
if (state.rowEntries.has(rowKey)) {
|
|
50
|
+
rowEntryKeys.push(rowKey);
|
|
51
|
+
}
|
|
52
|
+
if (rowPath.length > 1) {
|
|
53
|
+
for (let depth = 1; depth < rowPath.length; depth += 1) {
|
|
54
|
+
const groupPath = rowPath.slice(0, depth);
|
|
55
|
+
const groupKey = createPivotAxisKey("pivot:group:", groupPath);
|
|
56
|
+
if (state.rowEntries.has(groupKey)) {
|
|
57
|
+
rowEntryKeys.push(groupKey);
|
|
58
|
+
}
|
|
59
|
+
if (state.includeRowSubtotals) {
|
|
60
|
+
const subtotalKey = `${createPivotAxisKey("pivot:subtotal:", groupPath)}depth:${depth}`;
|
|
61
|
+
if (state.rowEntries.has(subtotalKey)) {
|
|
62
|
+
rowEntryKeys.push(subtotalKey);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (state.includeGrandTotal && state.rowEntries.has("pivot:grand-total")) {
|
|
68
|
+
rowEntryKeys.push("pivot:grand-total");
|
|
69
|
+
}
|
|
70
|
+
const columnKey = createPivotAxisKey("pivot:column:", columnPath);
|
|
71
|
+
const columnKeys = [];
|
|
72
|
+
if (state.runtimeColumnsByColumnKey.has(columnKey)) {
|
|
73
|
+
columnKeys.push(columnKey);
|
|
74
|
+
}
|
|
75
|
+
if (state.includeColumnGrandTotal && state.runtimeColumnsByColumnKey.has(state.columnGrandTotalKey)) {
|
|
76
|
+
columnKeys.push(state.columnGrandTotalKey);
|
|
77
|
+
}
|
|
78
|
+
if (state.includeColumnSubtotals) {
|
|
79
|
+
for (let depth = 1; depth < columnPath.length; depth += 1) {
|
|
80
|
+
const subtotalColumnPath = columnPath.slice(0, depth);
|
|
81
|
+
const subtotalColumnKey = `${createPivotAxisKey("pivot:column-subtotal:", subtotalColumnPath)}depth:${depth}`;
|
|
82
|
+
if (state.runtimeColumnsByColumnKey.has(subtotalColumnKey)) {
|
|
83
|
+
columnKeys.push(subtotalColumnKey);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
rowEntryKeys,
|
|
89
|
+
columnKeys,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function isSamePivotTouchedKeys(left, right) {
|
|
93
|
+
if (left.rowEntryKeys.length !== right.rowEntryKeys.length || left.columnKeys.length !== right.columnKeys.length) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
for (let index = 0; index < left.rowEntryKeys.length; index += 1) {
|
|
97
|
+
if (left.rowEntryKeys[index] !== right.rowEntryKeys[index]) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (let index = 0; index < left.columnKeys.length; index += 1) {
|
|
102
|
+
if (left.columnKeys[index] !== right.columnKeys[index]) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { DataGridAggOp, DataGridPivotSpec, DataGridPivotValueSpec, DataGridPivotColumn, DataGridPivotColumnPathSegment, DataGridPivotColumnSubtotalPosition, DataGridPivotColumnGrandTotalPosition, } from "./contracts.js";
|
|
2
|
+
export type { DataGridAdvancedFilter, DataGridAdvancedFilterCondition, DataGridAdvancedFilterConditionType, DataGridAdvancedFilterExpression, DataGridAdvancedFilterGroup, DataGridAdvancedFilterNot, DataGridAggregationModel, DataGridAggregationColumnSpec, DataGridAggregationColumnSpecAnyState, DataGridAggregationFieldReader, DataGridColumnFilter, DataGridColumnFilterSnapshotEntry, DataGridColumnPredicateFilter, DataGridColumnPredicateOperator, DataGridColumnValueSetFilter, DataGridColumnPin, DataGridFilterClause, DataGridFilterSnapshot, DataGridGroupBySpec, DataGridGroupExpansionSnapshot, DataGridPivotLayoutColumnModel, DataGridPivotLayoutColumnModelColumnSnapshot, DataGridPivotLayoutColumnModelSnapshot, DataGridPivotLayoutRowModel, DataGridPivotLayoutRowModelSnapshot, DataGridRowId, DataGridRowNode, DataGridSortDirection, DataGridSortState, DataGridSortAndFilterModelInput, } from "./coreTypes.js";
|
|
3
|
+
export type { DataGridPivotCellDrilldownInput, DataGridPivotCellDrilldown, } from "./drilldownContracts.js";
|
|
4
|
+
export type { ResolvePivotCellDrilldownInput, } from "./drilldownRuntime.js";
|
|
5
|
+
export type { DataGridPivotLayoutColumnState, DataGridPivotLayoutSnapshot, DataGridPivotLayoutImportOptions, DataGridPivotInteropSnapshot, } from "./layoutContracts.js";
|
|
6
|
+
export type { DataGridPivotRuntimeOptions, DataGridPivotProjectionResult, DataGridPivotProjectRowsInput, DataGridPivotIncrementalPatchRow, DataGridPivotApplyValuePatchInput, DataGridPivotRuntime, } from "./runtimeContracts.js";
|
|
7
|
+
export type { DataGridPivotRuntimeValueSpec, } from "./runtimeHelpers.js";
|
|
8
|
+
export type { DataGridPivotFieldResolver, } from "./fieldRuntime.js";
|
|
9
|
+
export type { DataGridPivotIncrementalTouchedKeys, DataGridPivotIncrementalTouchedKeysState, } from "./incrementalHelpers.js";
|
|
10
|
+
export { normalizePivotSpec, clonePivotSpec, isSamePivotSpec, } from "./helpers.js";
|
|
11
|
+
export { createPivotAxisKey, createPivotAggregateKey, createPivotColumnId, createPivotColumnLabel, normalizePivotAxisValue, comparePivotPathSegments, isPivotPathPrefixOrEqual, normalizePivotColumns, serializePivotModelForIncrementalState, } from "./runtimeHelpers.js";
|
|
12
|
+
export { readPivotValueByPathSegments, createPivotFieldResolver, } from "./fieldRuntime.js";
|
|
13
|
+
export { isSameLeafContribution, buildPivotIncrementalTouchedKeys, isSamePivotTouchedKeys, } from "./incrementalHelpers.js";
|
|
14
|
+
export { resolvePivotCellDrilldown, } from "./drilldownRuntime.js";
|
|
15
|
+
export type { DataGridPivotLayoutSortFilterBatchCapability, } from "./layoutRuntime.js";
|
|
16
|
+
export { exportPivotLayoutSnapshot, exportPivotInteropSnapshot, importPivotLayoutSnapshot, } from "./layoutRuntime.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,8BAA8B,E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EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sCAAsC,GACvC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EACL,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EACV,4CAA4C,GAC7C,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { normalizePivotSpec, clonePivotSpec, isSamePivotSpec, } from "./helpers.js";
|
|
2
|
+
export { createPivotAxisKey, createPivotAggregateKey, createPivotColumnId, createPivotColumnLabel, normalizePivotAxisValue, comparePivotPathSegments, isPivotPathPrefixOrEqual, normalizePivotColumns, serializePivotModelForIncrementalState, } from "./runtimeHelpers.js";
|
|
3
|
+
export { readPivotValueByPathSegments, createPivotFieldResolver, } from "./fieldRuntime.js";
|
|
4
|
+
export { isSameLeafContribution, buildPivotIncrementalTouchedKeys, isSamePivotTouchedKeys, } from "./incrementalHelpers.js";
|
|
5
|
+
export { resolvePivotCellDrilldown, } from "./drilldownRuntime.js";
|
|
6
|
+
export { exportPivotLayoutSnapshot, exportPivotInteropSnapshot, importPivotLayoutSnapshot, } from "./layoutRuntime.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DataGridPivotColumn, DataGridPivotSpec } from "./contracts.js";
|
|
2
|
+
import type { DataGridAggregationModel, DataGridColumnPin, DataGridFilterSnapshot, DataGridGroupBySpec, DataGridGroupExpansionSnapshot, DataGridRowNode, DataGridSortState } from "./coreTypes.js";
|
|
3
|
+
export interface DataGridPivotLayoutColumnState {
|
|
4
|
+
order: readonly string[];
|
|
5
|
+
visibility: Readonly<Record<string, boolean>>;
|
|
6
|
+
widths: Readonly<Record<string, number | null>>;
|
|
7
|
+
pins: Readonly<Record<string, DataGridColumnPin>>;
|
|
8
|
+
}
|
|
9
|
+
export interface DataGridPivotLayoutSnapshot<TRow = unknown> {
|
|
10
|
+
version: 1;
|
|
11
|
+
sortModel: readonly DataGridSortState[];
|
|
12
|
+
filterModel: DataGridFilterSnapshot | null;
|
|
13
|
+
groupBy: DataGridGroupBySpec | null;
|
|
14
|
+
pivotModel: DataGridPivotSpec | null;
|
|
15
|
+
aggregationModel: DataGridAggregationModel<TRow> | null;
|
|
16
|
+
groupExpansion: DataGridGroupExpansionSnapshot | null;
|
|
17
|
+
columnState: DataGridPivotLayoutColumnState;
|
|
18
|
+
}
|
|
19
|
+
export interface DataGridPivotLayoutImportOptions {
|
|
20
|
+
applyColumnState?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DataGridPivotInteropSnapshot<TRow = unknown> {
|
|
23
|
+
version: 1;
|
|
24
|
+
layout: DataGridPivotLayoutSnapshot<TRow>;
|
|
25
|
+
pivotColumns: readonly DataGridPivotColumn[];
|
|
26
|
+
rows: readonly DataGridRowNode<TRow>[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=layoutContracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutContracts.d.ts","sourceRoot":"","sources":["../src/layoutContracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,8BAA8B,EAC9B,eAAe,EACf,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAA;IAC/C,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAA;CAClD;AAED,MAAM,WAAW,2BAA2B,CAAC,IAAI,GAAG,OAAO;IACzD,OAAO,EAAE,CAAC,CAAA;IACV,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACvC,WAAW,EAAE,sBAAsB,GAAG,IAAI,CAAA;IAC1C,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACnC,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAA;IACpC,gBAAgB,EAAE,wBAAwB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACvD,cAAc,EAAE,8BAA8B,GAAG,IAAI,CAAA;IACrD,WAAW,EAAE,8BAA8B,CAAA;CAC5C;AAED,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,MAAM,WAAW,4BAA4B,CAAC,IAAI,GAAG,OAAO;IAC1D,OAAO,EAAE,CAAC,CAAA;IACV,MAAM,EAAE,2BAA2B,CAAC,IAAI,CAAC,CAAA;IACzC,YAAY,EAAE,SAAS,mBAAmB,EAAE,CAAA;IAC5C,IAAI,EAAE,SAAS,eAAe,CAAC,IAAI,CAAC,EAAE,CAAA;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DataGridPivotInteropSnapshot, DataGridPivotLayoutImportOptions, DataGridPivotLayoutSnapshot } from "./layoutContracts.js";
|
|
2
|
+
import type { DataGridPivotLayoutColumnModel, DataGridPivotLayoutRowModel, DataGridSortAndFilterModelInput } from "./coreTypes.js";
|
|
3
|
+
export interface DataGridPivotLayoutSortFilterBatchCapability {
|
|
4
|
+
setSortAndFilterModel: (input: DataGridSortAndFilterModelInput) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function exportPivotLayoutSnapshot<TRow = unknown>(rowModel: DataGridPivotLayoutRowModel<TRow>, columnModel: DataGridPivotLayoutColumnModel): DataGridPivotLayoutSnapshot<TRow>;
|
|
7
|
+
export declare function exportPivotInteropSnapshot<TRow = unknown>(rowModel: DataGridPivotLayoutRowModel<TRow>, columnModel: DataGridPivotLayoutColumnModel): DataGridPivotInteropSnapshot<TRow> | null;
|
|
8
|
+
export declare function importPivotLayoutSnapshot<TRow = unknown>(rowModel: DataGridPivotLayoutRowModel<TRow>, columnModel: DataGridPivotLayoutColumnModel, batchSortFilterCapability: DataGridPivotLayoutSortFilterBatchCapability | null, layout: DataGridPivotLayoutSnapshot<TRow>, options?: DataGridPivotLayoutImportOptions): void;
|
|
9
|
+
//# sourceMappingURL=layoutRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutRuntime.d.ts","sourceRoot":"","sources":["../src/layoutRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC5B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAEV,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,4CAA4C;IAC3D,qBAAqB,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAA;CACxE;AA0DD,wBAAgB,yBAAyB,CAAC,IAAI,GAAG,OAAO,EACtD,QAAQ,EAAE,2BAA2B,CAAC,IAAI,CAAC,EAC3C,WAAW,EAAE,8BAA8B,GAC1C,2BAA2B,CAAC,IAAI,CAAC,CA0BnC;AAED,wBAAgB,0BAA0B,CAAC,IAAI,GAAG,OAAO,EACvD,QAAQ,EAAE,2BAA2B,CAAC,IAAI,CAAC,EAC3C,WAAW,EAAE,8BAA8B,GAC1C,4BAA4B,CAAC,IAAI,CAAC,GAAG,IAAI,CAiB3C;AAED,wBAAgB,yBAAyB,CAAC,IAAI,GAAG,OAAO,EACtD,QAAQ,EAAE,2BAA2B,CAAC,IAAI,CAAC,EAC3C,WAAW,EAAE,8BAA8B,EAC3C,yBAAyB,EAAE,4CAA4C,GAAG,IAAI,EAC9E,MAAM,EAAE,2BAA2B,CAAC,IAAI,CAAC,EACzC,OAAO,GAAE,gCAAqC,GAC7C,IAAI,CA4DN"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
function cloneSerializable(value) {
|
|
2
|
+
const structuredCloneRef = globalThis.structuredClone;
|
|
3
|
+
if (typeof structuredCloneRef === "function") {
|
|
4
|
+
try {
|
|
5
|
+
return structuredCloneRef(value);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
// Fall through to JSON fallback.
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(JSON.stringify(value));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function areSerializableValuesEqual(left, right) {
|
|
19
|
+
if (Object.is(left, right)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function normalizePivotLayoutOrder(input) {
|
|
30
|
+
if (!Array.isArray(input)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const normalized = [];
|
|
35
|
+
for (const rawKey of input) {
|
|
36
|
+
if (typeof rawKey !== "string") {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const key = rawKey.trim();
|
|
40
|
+
if (key.length === 0 || seen.has(key)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
seen.add(key);
|
|
44
|
+
normalized.push(key);
|
|
45
|
+
}
|
|
46
|
+
return normalized;
|
|
47
|
+
}
|
|
48
|
+
function normalizePivotLayoutPin(pin) {
|
|
49
|
+
if (pin === "left" || pin === "right" || pin === "none") {
|
|
50
|
+
return pin;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
export function exportPivotLayoutSnapshot(rowModel, columnModel) {
|
|
55
|
+
const rowSnapshot = rowModel.getSnapshot();
|
|
56
|
+
const columnSnapshot = columnModel.getSnapshot();
|
|
57
|
+
const visibility = {};
|
|
58
|
+
const widths = {};
|
|
59
|
+
const pins = {};
|
|
60
|
+
for (const column of columnSnapshot.columns) {
|
|
61
|
+
visibility[column.key] = column.visible;
|
|
62
|
+
widths[column.key] = column.width;
|
|
63
|
+
pins[column.key] = column.pin;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
version: 1,
|
|
67
|
+
sortModel: cloneSerializable(rowSnapshot.sortModel),
|
|
68
|
+
filterModel: cloneSerializable(rowSnapshot.filterModel),
|
|
69
|
+
groupBy: cloneSerializable(rowSnapshot.groupBy),
|
|
70
|
+
pivotModel: cloneSerializable(rowModel.getPivotModel()),
|
|
71
|
+
aggregationModel: cloneSerializable(rowModel.getAggregationModel()),
|
|
72
|
+
groupExpansion: cloneSerializable(rowSnapshot.groupExpansion),
|
|
73
|
+
columnState: {
|
|
74
|
+
order: cloneSerializable(columnSnapshot.order),
|
|
75
|
+
visibility,
|
|
76
|
+
widths,
|
|
77
|
+
pins,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function exportPivotInteropSnapshot(rowModel, columnModel) {
|
|
82
|
+
var _a;
|
|
83
|
+
const pivotModel = rowModel.getPivotModel();
|
|
84
|
+
if (!pivotModel) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const rowSnapshot = rowModel.getSnapshot();
|
|
88
|
+
const rowCount = Math.max(0, Math.trunc(rowSnapshot.rowCount));
|
|
89
|
+
const rows = rowCount > 0
|
|
90
|
+
? rowModel.getRowsInRange({ start: 0, end: rowCount - 1 })
|
|
91
|
+
: [];
|
|
92
|
+
const layout = exportPivotLayoutSnapshot(rowModel, columnModel);
|
|
93
|
+
return {
|
|
94
|
+
version: 1,
|
|
95
|
+
layout,
|
|
96
|
+
pivotColumns: cloneSerializable((_a = rowSnapshot.pivotColumns) !== null && _a !== void 0 ? _a : []),
|
|
97
|
+
rows: cloneSerializable(rows),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function importPivotLayoutSnapshot(rowModel, columnModel, batchSortFilterCapability, layout, options = {}) {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
if (!layout || typeof layout !== "object") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const currentLayout = exportPivotLayoutSnapshot(rowModel, columnModel);
|
|
106
|
+
if (areSerializableValuesEqual(currentLayout, layout)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (options.applyColumnState !== false) {
|
|
110
|
+
const applyColumnState = () => {
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
112
|
+
const order = normalizePivotLayoutOrder((_a = layout.columnState) === null || _a === void 0 ? void 0 : _a.order);
|
|
113
|
+
if (order.length > 0) {
|
|
114
|
+
columnModel.setColumnOrder(order);
|
|
115
|
+
}
|
|
116
|
+
const visibility = (_c = (_b = layout.columnState) === null || _b === void 0 ? void 0 : _b.visibility) !== null && _c !== void 0 ? _c : {};
|
|
117
|
+
for (const [key, value] of Object.entries(visibility)) {
|
|
118
|
+
columnModel.setColumnVisibility(key, Boolean(value));
|
|
119
|
+
}
|
|
120
|
+
const widths = (_e = (_d = layout.columnState) === null || _d === void 0 ? void 0 : _d.widths) !== null && _e !== void 0 ? _e : {};
|
|
121
|
+
for (const [key, value] of Object.entries(widths)) {
|
|
122
|
+
const normalizedWidth = Number.isFinite(value)
|
|
123
|
+
? Math.max(0, Math.trunc(value))
|
|
124
|
+
: null;
|
|
125
|
+
columnModel.setColumnWidth(key, normalizedWidth);
|
|
126
|
+
}
|
|
127
|
+
const pins = (_g = (_f = layout.columnState) === null || _f === void 0 ? void 0 : _f.pins) !== null && _g !== void 0 ? _g : {};
|
|
128
|
+
for (const [key, value] of Object.entries(pins)) {
|
|
129
|
+
const normalizedPin = normalizePivotLayoutPin(value);
|
|
130
|
+
if (!normalizedPin) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
columnModel.setColumnPin(key, normalizedPin);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
if (typeof columnModel.batch === "function") {
|
|
137
|
+
columnModel.batch(applyColumnState);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
applyColumnState();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const sortModel = Array.isArray(layout.sortModel)
|
|
144
|
+
? layout.sortModel
|
|
145
|
+
: [];
|
|
146
|
+
const filterModel = layout.filterModel == null
|
|
147
|
+
? null
|
|
148
|
+
: layout.filterModel;
|
|
149
|
+
if (batchSortFilterCapability) {
|
|
150
|
+
batchSortFilterCapability.setSortAndFilterModel({ sortModel, filterModel });
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
rowModel.setFilterModel(filterModel);
|
|
154
|
+
rowModel.setSortModel(sortModel);
|
|
155
|
+
}
|
|
156
|
+
rowModel.setGroupBy((_a = layout.groupBy) !== null && _a !== void 0 ? _a : null);
|
|
157
|
+
rowModel.setPivotModel((_b = layout.pivotModel) !== null && _b !== void 0 ? _b : null);
|
|
158
|
+
rowModel.setAggregationModel((_c = layout.aggregationModel) !== null && _c !== void 0 ? _c : null);
|
|
159
|
+
rowModel.setGroupExpansion((_d = layout.groupExpansion) !== null && _d !== void 0 ? _d : null);
|
|
160
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataGridPivotColumn, DataGridPivotSpec } from "./contracts.js";
|
|
2
|
+
import type { DataGridAggregationFieldReader, DataGridGroupExpansionSnapshot, DataGridRowNode } from "./coreTypes.js";
|
|
3
|
+
export interface DataGridPivotRuntimeOptions<T> {
|
|
4
|
+
readRowField?: DataGridAggregationFieldReader<T>;
|
|
5
|
+
}
|
|
6
|
+
export interface DataGridPivotProjectionResult<T> {
|
|
7
|
+
rows: DataGridRowNode<T>[];
|
|
8
|
+
columns: DataGridPivotColumn[];
|
|
9
|
+
}
|
|
10
|
+
export interface DataGridPivotProjectRowsInput<T> {
|
|
11
|
+
inputRows: readonly DataGridRowNode<T>[];
|
|
12
|
+
pivotModel: DataGridPivotSpec;
|
|
13
|
+
normalizeFieldValue: (value: unknown) => string;
|
|
14
|
+
expansionSnapshot?: DataGridGroupExpansionSnapshot | null;
|
|
15
|
+
}
|
|
16
|
+
export interface DataGridPivotIncrementalPatchRow<T> {
|
|
17
|
+
previousRow: DataGridRowNode<T>;
|
|
18
|
+
nextRow: DataGridRowNode<T>;
|
|
19
|
+
}
|
|
20
|
+
export interface DataGridPivotApplyValuePatchInput<T> {
|
|
21
|
+
projectedRows: readonly DataGridRowNode<T>[];
|
|
22
|
+
pivotModel: DataGridPivotSpec;
|
|
23
|
+
changedRows: readonly DataGridPivotIncrementalPatchRow<T>[];
|
|
24
|
+
}
|
|
25
|
+
export interface DataGridPivotRuntime<T> {
|
|
26
|
+
projectRows: (input: DataGridPivotProjectRowsInput<T>) => DataGridPivotProjectionResult<T>;
|
|
27
|
+
applyValueOnlyPatch: (input: DataGridPivotApplyValuePatchInput<T>) => DataGridPivotProjectionResult<T> | null;
|
|
28
|
+
normalizeColumns: (columns: readonly DataGridPivotColumn[]) => DataGridPivotColumn[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=runtimeContracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeContracts.d.ts","sourceRoot":"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CAAC,CAAC,KAAK,6BAA6B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC7G,gBAAgB,EAAE,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,CAAA;CACrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DataGridAggOp, DataGridPivotColumn, DataGridPivotColumnPathSegment, DataGridPivotSpec } from "./contracts.js";
|
|
2
|
+
export interface DataGridPivotRuntimeValueSpec {
|
|
3
|
+
field: string;
|
|
4
|
+
agg: DataGridAggOp;
|
|
5
|
+
aggregateKey: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createPivotAxisKey(prefix: "pivot:row:" | "pivot:column:" | "pivot:column-subtotal:" | "pivot:subtotal:" | "pivot:group:", segments: readonly {
|
|
8
|
+
field: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}[]): string;
|
|
11
|
+
export declare function createPivotAggregateKey(spec: DataGridPivotRuntimeValueSpec): string;
|
|
12
|
+
export declare function createPivotColumnId(columnKey: string, valueSpec: DataGridPivotRuntimeValueSpec): string;
|
|
13
|
+
export declare function createPivotColumnLabel(columnPath: readonly DataGridPivotColumnPathSegment[], valueSpec: DataGridPivotRuntimeValueSpec, options?: {
|
|
14
|
+
subtotal?: boolean;
|
|
15
|
+
grandTotal?: boolean;
|
|
16
|
+
}): string;
|
|
17
|
+
export declare function normalizePivotAxisValue(value: unknown, normalizeFieldValue: (value: unknown) => string): string;
|
|
18
|
+
export declare function comparePivotPathSegments(left: readonly {
|
|
19
|
+
field: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[], right: readonly {
|
|
22
|
+
field: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[]): number;
|
|
25
|
+
export declare function isPivotPathPrefixOrEqual(prefix: readonly {
|
|
26
|
+
field: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}[], candidate: readonly {
|
|
29
|
+
field: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}[]): boolean;
|
|
32
|
+
export declare function normalizePivotColumns(columns: readonly DataGridPivotColumn[]): DataGridPivotColumn[];
|
|
33
|
+
export declare function serializePivotModelForIncrementalState(pivotModel: DataGridPivotSpec): string;
|
|
34
|
+
//# sourceMappingURL=runtimeHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeHelpers.d.ts","sourceRoot":"","sources":["../src/runtimeHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,aAAa,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB;AAOD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,wBAAwB,GAAG,iBAAiB,GAAG,cAAc,EACtG,QAAQ,EAAE,SAAS;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,GACpD,MAAM,CAMR;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,6BAA6B,GAAG,MAAM,CAEnF;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,6BAA6B,GACvC,MAAM,CAER;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,8BAA8B,EAAE,EACrD,SAAS,EAAE,6BAA6B,EACxC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACzD,MAAM,CAQR;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAC9C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