@univerjs-pro/engine-pivot 0.4.2 → 0.5.0-alpha.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.
@@ -1,187 +0,0 @@
1
- import { PivotDataFieldDataTypeEnum, PivotDataFieldSortOperatorEnum, PivotFilterTypeEnum, PivotShowAsTypeEnum, PivotSubtotalTypeEnum, ST_PivotFilterOperatorEnum } from './enum';
2
- export interface IDateValue {
3
- /**
4
- * @description the date value, it stores the number of seconds since January 1, 1970, 00:00:00 UTC, it is same to excel date value
5
- */
6
- v: number;
7
- /**
8
- * @description only date type has this property, we can use it to format the date
9
- */
10
- f: string;
11
- }
12
- type IBlankValue = null | undefined;
13
- /**
14
- * Represents the value of a data field in a pivot table data field
15
- */
16
- export type IDataFieldValue = string | number | boolean | IDateValue | IBlankValue;
17
- export interface IDataFieldInfo {
18
- id: string;
19
- name: string;
20
- fieldDataType: PivotDataFieldDataTypeEnum;
21
- format: string;
22
- maxNumber: number;
23
- minNumber: number;
24
- maxDate: number;
25
- minDate: number;
26
- records: IDataFieldValue[];
27
- rangeKey: string;
28
- }
29
- export interface IPivotField {
30
- id: string;
31
- displayName: string;
32
- subtotalType: PivotSubtotalTypeEnum;
33
- }
34
- /**
35
- * @description using Wefloder to store the pivot table data
36
- * @typedef Tuple
37
- * @property {number} sum - The sum of the values in the tuple.
38
- * @property {number} count - The count of the values in the tuple.
39
- * @property {number} countN - The count of the number values in the tuple.
40
- * @property {number} product - The product of the values in the tuple.
41
- * @property {number} min - The minimum value in the tuple.
42
- * @property {number} max - The maximum value in the tuple.
43
- * @property {number} squareSum - The sum of the squares of the values in the tuple.
44
- */
45
- export interface IPivotTuple {
46
- sum: number;
47
- count: number;
48
- countN: number;
49
- product: number;
50
- min: number;
51
- max: number;
52
- squareSum: number;
53
- }
54
- export type IPivotTableFilterInfo = IPivotTableManualFilter | IPivotTableCustomFilter | IPivotTableValueFilter;
55
- export type IPivotTableSortInfo = IPivotTableLabelSortInfo | IPivotTableValueSortInfo;
56
- export interface IPivotTableLabelSortInfo {
57
- type: PivotDataFieldSortOperatorEnum;
58
- }
59
- export interface IPivotTableValueSortInfo {
60
- /**
61
- * @property {PivotDataFieldSortOperatorEnum} - The sort operator of the field items.
62
- */
63
- type: PivotDataFieldSortOperatorEnum;
64
- /**
65
- * @property {string} - The base field id of the field items to sort.
66
- */
67
- baseFieldId: string;
68
- /**
69
- * @property {string[]} - The path list of field items to sort.
70
- */
71
- sortItems: string[];
72
- }
73
- /**
74
- * Represents the Pivot Table Manual Filter info
75
- */
76
- export interface IPivotTableManualFilter {
77
- /**
78
- * @property {PivotFilterTypeEnum} - The filter type.
79
- */
80
- type: PivotFilterTypeEnum.ManualFilter;
81
- /**
82
- * @property {string[]} - The list of selected items.
83
- */
84
- list: string[];
85
- isAll?: boolean;
86
- }
87
- export interface IPivotTableCustomFilter {
88
- type: PivotFilterTypeEnum.CustomFilter;
89
- operator: ST_PivotFilterOperatorEnum;
90
- expected: any;
91
- }
92
- export interface IPivotTableValueFilter {
93
- type: PivotFilterTypeEnum.ValueFilter;
94
- operator: ST_PivotFilterOperatorEnum;
95
- expected: any;
96
- }
97
- export interface IPivotTableShowDataAsInfo {
98
- type: PivotShowAsTypeEnum;
99
- baseFieldId: string;
100
- baseItem: string;
101
- }
102
- /**
103
- * Represents the query data for a label field in a pivot table.
104
- */
105
- export interface IPivotTableLabelFieldQueryData {
106
- /**
107
- * The unique identifier of the label field.
108
- */
109
- id: string;
110
- /**
111
- * The unique identifier of the data field associated with the label field.
112
- */
113
- dataFieldId: string;
114
- /**
115
- * The display name of the label field.
116
- */
117
- displayName: string;
118
- /**
119
- * Information about the filter applied to the label field.
120
- */
121
- filterInfo?: IPivotTableFilterInfo;
122
- /**
123
- * Information about the sort applied to the label field.
124
- */
125
- sortInfo: IPivotTableSortInfo;
126
- }
127
- /**
128
- * Represents the data structure for a pivot table query.
129
- */
130
- export interface IPivotTableQueryData {
131
- /**
132
- * The query info of row fields in the pivot table.
133
- */
134
- rowQueryInfo: IPivotTableLabelFieldQueryData[];
135
- /**
136
- * The query info of column fields in the pivot table.
137
- */
138
- colQueryInfo: IPivotTableLabelFieldQueryData[];
139
- /**
140
- * The query info of filter fields in the pivot table.
141
- */
142
- filterQueryInfo: IPivotTableLabelFieldQueryData[];
143
- /**
144
- * The query info of value fields in the pivot table.
145
- */
146
- valueQueryInfo: IPivotTableValueFieldQueryData[];
147
- /**
148
- * The collapse state of the fields.
149
- * @property {Record<string, boolean|Record<string, boolean>>} - The collapse state of the pivot table.
150
- */
151
- collapseInfo: Record<string, boolean | Record<string, boolean>>;
152
- }
153
- /**
154
- * Represents the query data for a value field in a pivot table.
155
- */
156
- export interface IPivotTableValueFieldQueryData {
157
- /**
158
- * The unique identifier of the value field.
159
- */
160
- id: string;
161
- /**
162
- * The unique identifier of the data field associated with the value field.
163
- */
164
- dataFieldId: string;
165
- /**
166
- * The display name of the value field.
167
- */
168
- displayName: string;
169
- /**
170
- * The type of subtotal to be displayed for this value field.
171
- */
172
- subtotal: PivotSubtotalTypeEnum;
173
- /**
174
- * Information about how to show the data for this value field.
175
- */
176
- showDataAs: IPivotTableShowDataAsInfo;
177
- }
178
- /**
179
- * Represents the query data for a measure field in a pivot table.
180
- */
181
- export interface IPivotTableMeasureData {
182
- /**
183
- * @property {IPivotTableLabelFieldQueryData[]} - The query data for the value fields.
184
- */
185
- values: IPivotTableValueFieldQueryData[];
186
- }
187
- export {};
@@ -1,184 +0,0 @@
1
- import { PivotLayoutTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from './enum';
2
- import { IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSortInfo } from './interface';
3
- import { IPivotTableOptions } from './layout-type';
4
- export interface IPivotTableValueFieldJSON {
5
- dataFieldId: string;
6
- id: string;
7
- sourceName: string;
8
- displayName: string;
9
- format: string | undefined;
10
- subtotal: PivotSubtotalTypeEnum;
11
- showDataAs: IPivotTableShowDataAsInfo;
12
- }
13
- export interface IPivotTableLabelFieldJSON {
14
- dataFieldId: string;
15
- id: string;
16
- sourceName: string;
17
- displayName: string;
18
- format: string | undefined;
19
- sortInfo?: IPivotTableSortInfo;
20
- filterInfo?: IPivotTableFilterInfo;
21
- }
22
- /**
23
- * Represents a snapshot of a pivot table.
24
- */
25
- export interface IPivotTableSnapshot {
26
- /**
27
- * Represents the label fields in the pivot table.
28
- */
29
- dimension: Record<string, IPivotTableLabelFieldJSON>;
30
- /**
31
- * Represents the value fields in the pivot table.
32
- */
33
- measure: Record<string, IPivotTableValueFieldJSON>;
34
- /**
35
- * Represents the fields id used for grouping value in the pivot table.
36
- */
37
- valueFields: string[];
38
- /**
39
- * Represents the fields id used for filtering in the pivot table.
40
- */
41
- filterFields: string[];
42
- /**
43
- * Represents the fields id used for grouping rows in the pivot table.
44
- */
45
- rowFields: string[];
46
- /**
47
- * Represents the fields id used for grouping columns in the pivot table.
48
- */
49
- columnFields: string[];
50
- /**
51
- * Represents the fields id that are hidden in the pivot table.
52
- */
53
- hiddenFields: string[];
54
- /**
55
- * Represents the special ΣValue fields order index in the dimension fields.
56
- */
57
- valueIndex: number;
58
- /**
59
- * Represents the special ΣValue fields position in row or column area.
60
- */
61
- valuePosition: PivotTableValuePositionEnum;
62
- /**
63
- * Represents the layout of the pivot table.
64
- */
65
- layout: PivotLayoutTypeEnum;
66
- /**
67
- * Represents the collapse information of the pivot table.
68
- */
69
- collapseInfo: Record<string, any>;
70
- options: IPivotTableOptions;
71
- }
72
- export interface IFieldsCollectionJSON {
73
- fieldIds: string[];
74
- customFields: IDataFieldJSON[];
75
- displayNameRecord: Record<string, string>;
76
- dataRecordCount: number;
77
- range: unknown;
78
- fields: Record<string, IDataFieldJSON>;
79
- }
80
- /**
81
- * Represents the data field serialized to JSON data structure.
82
- */
83
- export interface IDataFieldJSON {
84
- id: string;
85
- name: string;
86
- hexCode: string;
87
- rangeKey: string;
88
- }
89
- export interface IDataFieldManagerBaseJSON {
90
- collections: Record<string, IFieldsCollectionJSON>;
91
- dataFields: Record<string, IDataFieldJSON>;
92
- }
93
- export declare enum PivotTableChangeTypeEnum {
94
- AddField = 0,
95
- SetSubtotalType = 1,
96
- RemoveField = 2,
97
- RenameField = 3,
98
- SetFilterInfo = 4,
99
- SetSortInfo = 5,
100
- UpdateFieldPosition = 6,
101
- UpdateValuePosition = 7,
102
- SetOptions = 8,
103
- SetFieldFormat = 9,
104
- SetCollapse = 10,
105
- UpdateSource = 11
106
- }
107
- export interface IPivotTableAddFieldChange {
108
- type: PivotTableChangeTypeEnum.AddField;
109
- fieldJson: IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON;
110
- area: PivotTableFiledAreaEnum;
111
- index: number;
112
- }
113
- export interface IPivotUpdateSourceChange {
114
- type: PivotTableChangeTypeEnum.UpdateSource;
115
- tableFieldId: string;
116
- oldSourceName: string;
117
- newSourceName: string;
118
- oldDataFieldId: string;
119
- newDataFieldId: string;
120
- }
121
- export interface IPivotTableSetSubtotalTypeChange {
122
- type: PivotTableChangeTypeEnum.SetSubtotalType;
123
- fieldId: string;
124
- newSubtotalType: PivotSubtotalTypeEnum;
125
- oldSubtotalType: PivotSubtotalTypeEnum;
126
- }
127
- export interface IPivotTableRemoveFieldChange {
128
- type: PivotTableChangeTypeEnum.RemoveField;
129
- fieldId: string;
130
- area: PivotTableFiledAreaEnum;
131
- index: number;
132
- fieldJson: IPivotTableValueFieldJSON | IPivotTableLabelFieldJSON;
133
- }
134
- export interface IPivotTableRenameFieldChange {
135
- type: PivotTableChangeTypeEnum.RenameField;
136
- fieldId: string;
137
- oldName: string;
138
- newName: string;
139
- }
140
- export interface IPivotTableUpdatePositionChange {
141
- type: PivotTableChangeTypeEnum.UpdateFieldPosition;
142
- fieldId: string;
143
- oldArea: PivotTableFiledAreaEnum;
144
- newArea: PivotTableFiledAreaEnum;
145
- oldIndex: number;
146
- newIndex: number;
147
- }
148
- export interface IPivotTableSetOptionsChange {
149
- type: PivotTableChangeTypeEnum.SetOptions;
150
- oldOptions: IPivotTableOptions;
151
- newOptions: IPivotTableOptions;
152
- }
153
- export interface IPivotTableUpdateValuePositionChange {
154
- type: PivotTableChangeTypeEnum.UpdateValuePosition;
155
- oldValuePosition: PivotTableValuePositionEnum;
156
- newValuePosition: PivotTableValuePositionEnum;
157
- oldIndex: number;
158
- newIndex: number;
159
- }
160
- export interface IPivotTableSetFilterInfoChange {
161
- type: PivotTableChangeTypeEnum.SetFilterInfo;
162
- fieldId: string;
163
- oldFilterInfo: IPivotTableFilterInfo;
164
- newFilterInfo: IPivotTableFilterInfo;
165
- }
166
- export interface IPivotTableSetSortInfoChange {
167
- type: PivotTableChangeTypeEnum.SetSortInfo;
168
- fieldId: string;
169
- oldSortInfo: IPivotTableSortInfo | undefined;
170
- newSortInfo: IPivotTableSortInfo | undefined;
171
- }
172
- export interface IPivotTableSetFormatChange {
173
- type: PivotTableChangeTypeEnum.SetFieldFormat;
174
- fieldId: string;
175
- oldFormat: string | undefined;
176
- newFormat: string | undefined;
177
- }
178
- export interface IPivotTableSetCollapseChange {
179
- type: PivotTableChangeTypeEnum.SetCollapse;
180
- fieldId: string;
181
- collapse: boolean;
182
- item?: string;
183
- }
184
- export type IPivotTableChangeSet = IPivotTableAddFieldChange | IPivotTableSetSubtotalTypeChange | IPivotTableRemoveFieldChange | IPivotTableRenameFieldChange | IPivotTableSetFilterInfoChange | IPivotTableSetSortInfoChange | IPivotTableUpdatePositionChange | IPivotTableUpdateValuePositionChange | IPivotTableSetOptionsChange | IPivotTableSetFormatChange | IPivotTableSetCollapseChange | IPivotUpdateSourceChange;
@@ -1,237 +0,0 @@
1
- import { PivotView } from '../layout/pivot-view';
2
- import { NodeTree } from '../summary/node-tree';
3
- import { SummaryManager } from '../summary/summary-manager';
4
- import { PivotErrorTypeEnum } from './enum';
5
- import { IPivotTableQueryData, IPivotTableValueFieldQueryData } from './interface';
6
- export interface IPivotViewItemData {
7
- [row: number]: IPivotViewColData;
8
- }
9
- export interface IPivotViewPrefixValue {
10
- prefix: string;
11
- value: string;
12
- }
13
- export interface IPivotViewErrorValue {
14
- errorType: PivotErrorTypeEnum;
15
- }
16
- export type IPivotViewValueType = number | string | undefined | IPivotViewErrorValue | IPivotViewPrefixValue;
17
- interface IPivotViewColData {
18
- [col: number]: IPivotViewCellData;
19
- }
20
- export interface IPivotViewCellData {
21
- v?: IPivotViewValueType;
22
- s?: PivotCellStyleTypeEnum;
23
- /**
24
- * @description only for the pivot table page filter cell, the value is the page filter index
25
- */
26
- i?: number;
27
- /**
28
- * means the cell is blank, the only value is 1
29
- */
30
- t?: PivotViewCellValueTypeEnum;
31
- }
32
- export declare enum PivotViewCellValueTypeEnum {
33
- blank = 2,
34
- date = 4
35
- }
36
- /**
37
- * Represents the pivot view info data structure, which is used to store row /col path and value index
38
- */
39
- export interface IPivotViewInfo {
40
- /**
41
- * The pivot table field id
42
- */
43
- tableFieldId: string;
44
- /**
45
- * The paths of the row/col
46
- */
47
- paths: string[];
48
- /**
49
- * The value index of the row/col
50
- */
51
- valueIndex: number;
52
- /**
53
- * is this row/col is bottom total, in excel, maybe has top total in outline layout
54
- */
55
- isBottomTotal?: boolean;
56
- /**
57
- * the node level of row or col
58
- */
59
- level: number;
60
- /**
61
- * only for col view, to match some node does not save in node tree
62
- */
63
- colPathMap?: Record<string, number>;
64
- /**
65
- * the info is ΣValue
66
- */
67
- isValue?: boolean;
68
- /**
69
- * the data field id
70
- */
71
- dataFieldId?: string;
72
- }
73
- /**
74
- * Represents the pivot cell style type enum
75
- */
76
- export declare enum PivotCellStyleTypeEnum {
77
- /**
78
- * the pivot table page filter selected all
79
- */
80
- FilterAll = 1,
81
- /**
82
- * the pivot table page filter selected partial
83
- */
84
- FilterPartial = 2,
85
- /**
86
- * the pivot table page filter selected one
87
- */
88
- FilterSingle = 3,
89
- /**
90
- * the pivot table area cell is blank
91
- */
92
- BlankValue = 4,
93
- /**
94
- * the pivot table dimension cell has filter but not sort
95
- */
96
- FilteredSortNone = 5,
97
- /**
98
- * the pivot table dimension cell has filter and sort asc
99
- */
100
- FilteredSortAsc = 6,
101
- /**
102
- * the pivot table dimension cell has filter and sort desc
103
- */
104
- FilteredSortDesc = 7,
105
- /**
106
- * the pivot table dimension cell has no filter and sort
107
- */
108
- FilterNoneSortNone = 8,
109
- /**
110
- * the pivot table dimension cell has no filter and sort asc
111
- */
112
- FilterNoneSortAsc = 9,
113
- /**
114
- * the pivot table dimension cell has no filter and sort desc
115
- */
116
- FilterNoneSortDesc = 10,
117
- /**
118
- * the branch node of tree can be collapse
119
- */
120
- Collapse = 11,
121
- /**
122
- * the branch node of tree can be expand
123
- */
124
- Expand = 12,
125
- /**
126
- * the subtotal cell, the real value should be `${value} Total` or `${value} 汇总`
127
- */
128
- Subtotal = 13,
129
- /**
130
- * the grand total cell, the value template should be `GrandTotal` or `总计`
131
- */
132
- GrandTotal = 14,
133
- /**
134
- * the grandtotal has more than oen value, the real value should be `Total ${value}` or `总计 ${value}`
135
- */
136
- MultipleGrandTotal = 15
137
- }
138
- /**
139
- * Represents the data structure for a pivot table config, which is match CT_pivotTableDefinition
140
- */
141
- export interface IPivotTableOptions {
142
- /**
143
- * The page wrap, it is the wrap of page, the page will wrap to next row when the wrapCursor is equal to pageWrap
144
- */
145
- pageWrap?: number;
146
- /**
147
- * The page over then down, it is the layout of page, if the pageOverThenDown is true, the page will layout over then down, otherwise, the page will layout down then over
148
- */
149
- pageOverThenDown?: boolean;
150
- showColHeaders?: boolean;
151
- showColStripes?: boolean;
152
- showLastColumn?: boolean;
153
- showRowHeaders?: boolean;
154
- showRowStripes?: boolean;
155
- /**
156
- * use span in the pivot table header
157
- */
158
- mergeItems?: boolean;
159
- }
160
- export interface INodeSizeInfo {
161
- /**
162
- * The size of the item
163
- */
164
- itemSize: number;
165
- /**
166
- * The size of the children item top total size
167
- */
168
- topTotalSize: number;
169
- /**
170
- * The size of the children item bottom total size
171
- */
172
- bottomTotalSize: number;
173
- }
174
- export interface IColumnNodeSizeInfo extends INodeSizeInfo {
175
- colPathMap: Record<string, number>;
176
- }
177
- export interface IRowNodeSizeInfo extends INodeSizeInfo {
178
- valueIndex?: number;
179
- }
180
- export interface IPivotLayoutCtx {
181
- view: PivotView;
182
- rowDeep: number;
183
- colDeep: number;
184
- rowNodeTree: NodeTree;
185
- colNodeTree: NodeTree;
186
- measureCount: number;
187
- pageWrap: number;
188
- pageOverThenDown: boolean;
189
- queryData: IPivotTableQueryData;
190
- isColMultiMeasure: boolean;
191
- isRowMultiMeasure: boolean;
192
- valueIndex: number;
193
- valueQueryInfo: IPivotTableValueFieldQueryData[];
194
- measuresMap: Record<string, IPivotTableValueFieldQueryData>;
195
- colMap: Record<string, number>;
196
- summaryManager: SummaryManager;
197
- measureIndexesMap: Record<string, number>;
198
- collapseInfo: Record<string, boolean | Record<string, boolean>>;
199
- }
200
- export interface IPageViewItemRange {
201
- row: number;
202
- col: number;
203
- rowCount: number;
204
- colCount: number;
205
- }
206
- export interface ILabelViewHeaderMapItem {
207
- isValue: boolean;
208
- level: number;
209
- tableFieldId: string;
210
- dataFieldId: string;
211
- }
212
- export interface IPivotViewItemJSON {
213
- data: IPivotViewItemData;
214
- info: IPivotViewInfo[];
215
- rowCount: number;
216
- colCount: number;
217
- lastCol: number;
218
- lastRow: number;
219
- }
220
- export interface IPageViewItemJSON extends IPivotViewItemJSON {
221
- lastRow: number;
222
- lastCol: number;
223
- ranges: IPageViewItemRange[];
224
- }
225
- export interface ILabelViewItemJSON extends IPivotViewItemJSON {
226
- headerMap: ILabelViewHeaderMapItem[];
227
- }
228
- export interface IPivotViewJSON {
229
- pageView: IPageViewItemJSON;
230
- rowView: ILabelViewItemJSON;
231
- colView: ILabelViewItemJSON;
232
- dataView: IPivotViewItemJSON;
233
- cornerView: IPivotViewItemJSON;
234
- version: number;
235
- formatMap: Record<string, string>;
236
- }
237
- export {};
@@ -1,41 +0,0 @@
1
- import { DataField } from '../field/data-field';
2
- import { PivotTuple } from '../summary/pivot-tuple';
3
- import { PivotDataFieldDataTypeEnum, PivotErrorTypeEnum, PivotSubtotalTypeEnum } from './enum';
4
- export interface ITupleItem {
5
- path: string[];
6
- types: PivotDataFieldDataTypeEnum[];
7
- tuple: IMeasureTupleItem;
8
- indexes: number[];
9
- summary?: Record<string, ITupleItemSummary>;
10
- }
11
- export interface ITPivotTupleInfo {
12
- sum: number;
13
- count: number;
14
- countN: number;
15
- product: number;
16
- min: number;
17
- max: number;
18
- squareSum: number;
19
- }
20
- export interface IMeasureTupleItem {
21
- [DataFieldId: string]: PivotTuple;
22
- }
23
- export type ITupleItemSummary = ITPivotTupleInfo & {
24
- [subtotalType in PivotSubtotalTypeEnum]?: number | {
25
- errorType: PivotErrorTypeEnum;
26
- };
27
- };
28
- export interface IMeasuresMapItem {
29
- field: DataField;
30
- subTotal: PivotSubtotalTypeEnum[];
31
- }
32
- export interface IDimensionMapItem {
33
- field: DataField;
34
- }
35
- export interface IPivotSummaryLevelPool {
36
- [level: number]: IPivotSummaryLevelPoolItem[];
37
- }
38
- export interface IPivotSummaryLevelPoolItem {
39
- v: number;
40
- p: number;
41
- }