@omnigrid/core 0.1.24 → 0.1.25
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/dist/grid.d.ts +99 -2
- package/dist/grid.js +336 -10
- package/dist/groupingPipeline.d.ts +49 -0
- package/dist/groupingPipeline.js +211 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -0
- package/dist/pipeline.d.ts +68 -0
- package/dist/pipeline.js +62 -0
- package/dist/types.d.ts +240 -38
- package/package.json +41 -41
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import type { OverlayOptions, OverlayState, OverlayType } from "./overlays";
|
|
2
2
|
import type { SlotManager } from "./slots";
|
|
3
3
|
import type { IconRegistry } from "./icons";
|
|
4
|
-
import type { FilterCondition, FilterModel
|
|
4
|
+
import type { FilterCondition, FilterModel } from "./filtering";
|
|
5
5
|
import type { UIPopupAnchor, UIPopupDescriptor } from "./ui";
|
|
6
|
+
import type { StateUpdater } from "./store";
|
|
7
|
+
import type { DataPipeline } from "./pipeline";
|
|
8
|
+
export type { PipelineProcessor, PipelineStage } from "./pipeline";
|
|
6
9
|
export type RowId = string | number;
|
|
7
10
|
export type SortDirection = "asc" | "desc";
|
|
8
11
|
export type CellAlign = "left" | "center" | "right";
|
|
9
12
|
export type DataProcessor<T> = (data: T[]) => T[];
|
|
13
|
+
/** Scope used when resolving leaf descendants of a composite row. @api */
|
|
14
|
+
export type RowHierarchyScope = "all" | "filtered";
|
|
15
|
+
/**
|
|
16
|
+
* Generic hierarchy capability provided by a row-model plugin.
|
|
17
|
+
* Returns leaf row IDs for composite rows, or `undefined` when the ID is a leaf.
|
|
18
|
+
*
|
|
19
|
+
* @api
|
|
20
|
+
*/
|
|
21
|
+
export interface RowHierarchy<T> {
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the leaf rows represented by a row ID.
|
|
24
|
+
* @param rowId - Row or composite-row identifier.
|
|
25
|
+
* @param scope - Whether filtered-out descendants are included.
|
|
26
|
+
* @returns Leaf row IDs, an empty array for an empty composite row, or `undefined` for a leaf.
|
|
27
|
+
* @api
|
|
28
|
+
*/
|
|
29
|
+
getLeafRowIds(rowId: RowId, scope: RowHierarchyScope): readonly RowId[] | undefined;
|
|
30
|
+
}
|
|
10
31
|
/**
|
|
11
32
|
* Nature of the values stored in a column.
|
|
12
33
|
*
|
|
@@ -45,6 +66,95 @@ export interface RowNode<T> {
|
|
|
45
66
|
/** Raw row data object. */
|
|
46
67
|
data: T;
|
|
47
68
|
}
|
|
69
|
+
/** Aggregation function applied to column values within a group. */
|
|
70
|
+
export type AggregationFunc<T = unknown> = (values: unknown[]) => unknown;
|
|
71
|
+
/**
|
|
72
|
+
* A group (aggregated) row produced by the Row Grouping engine.
|
|
73
|
+
*
|
|
74
|
+
* `id` is a stable path such as `"Region:Europe/Country:France"`. `key` is the
|
|
75
|
+
* group value at this level (e.g. `"Europe"`), `level` is the nesting depth
|
|
76
|
+
* (0 = outermost), and `expanded` reflects whether its children are visible in
|
|
77
|
+
* the flattened output. `aggregations` holds pre-computed per-column
|
|
78
|
+
* aggregates (sum, avg, min, max, count, ...).
|
|
79
|
+
*
|
|
80
|
+
* @api
|
|
81
|
+
*/
|
|
82
|
+
export interface GroupRowNode<T> {
|
|
83
|
+
type: 'group';
|
|
84
|
+
/** Stable path identifying the group, e.g. "Region:Europe/Country:France". */
|
|
85
|
+
id: string;
|
|
86
|
+
/** Column field this group levels on. */
|
|
87
|
+
field: string;
|
|
88
|
+
/** Group value at this level, e.g. "Europe". */
|
|
89
|
+
key: string;
|
|
90
|
+
/** Nesting depth (0 = outermost group level). */
|
|
91
|
+
level: number;
|
|
92
|
+
/** Whether the group's children are currently visible in the flat output. */
|
|
93
|
+
expanded: boolean;
|
|
94
|
+
/** Total number of descendant leaf rows in this group. */
|
|
95
|
+
childrenCount: number;
|
|
96
|
+
/** Pre-computed per-column aggregates, keyed by column id. */
|
|
97
|
+
aggregations: Record<string, unknown>;
|
|
98
|
+
/** Child nodes (sub-groups and leaf rows). */
|
|
99
|
+
children: TreeRowNode<T>[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Context passed to a custom group row renderer (`groupRowRenderer`).
|
|
103
|
+
*
|
|
104
|
+
* @api
|
|
105
|
+
*/
|
|
106
|
+
export interface GroupRowRenderParams<T> {
|
|
107
|
+
/** The group node being rendered. */
|
|
108
|
+
node: GroupRowNode<T>;
|
|
109
|
+
/** The column the group cell belongs to. */
|
|
110
|
+
column: ColumnLeafDef<T>;
|
|
111
|
+
/** Stable row id of the group. */
|
|
112
|
+
id: RowId;
|
|
113
|
+
/** Zero-based index in the processed dataset. */
|
|
114
|
+
index: number;
|
|
115
|
+
/** The grid API instance. */
|
|
116
|
+
api: GridApi<T>;
|
|
117
|
+
/** Current grid state. */
|
|
118
|
+
state: GridState<T>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Custom renderer for group rows. May return any headless content accepted by
|
|
122
|
+
* the active UI adapter (string, number, ReactNode, slot node, ...).
|
|
123
|
+
*
|
|
124
|
+
* @api
|
|
125
|
+
*/
|
|
126
|
+
export type GroupRowRenderer<T> = (params: GroupRowRenderParams<T>) => unknown;
|
|
127
|
+
/**
|
|
128
|
+
* A leaf (data) row produced by the Row Grouping engine.
|
|
129
|
+
*
|
|
130
|
+
* Wraps a single raw data row together with the group it belongs to and its
|
|
131
|
+
* depth in the group hierarchy.
|
|
132
|
+
*
|
|
133
|
+
* @api
|
|
134
|
+
*/
|
|
135
|
+
export interface DataRowNode<T> {
|
|
136
|
+
type: 'leaf';
|
|
137
|
+
/** Stable row identifier (from `getRowId`). */
|
|
138
|
+
id: RowId;
|
|
139
|
+
/** Raw row data object. */
|
|
140
|
+
data: T;
|
|
141
|
+
/** Nesting depth (equals the number of group levels). */
|
|
142
|
+
level: number;
|
|
143
|
+
/** The group this row belongs to. */
|
|
144
|
+
parent: GroupRowNode<T>;
|
|
145
|
+
/**
|
|
146
|
+
* Set when this leaf row is displayed as a collapsed single-child group
|
|
147
|
+
* (`collapseSingleChildGroups: true`). Contains the grouping field, value,
|
|
148
|
+
* and hierarchy level to display instead of the row's own field value.
|
|
149
|
+
*/
|
|
150
|
+
collapsedGroup?: {
|
|
151
|
+
field: string;
|
|
152
|
+
key: string;
|
|
153
|
+
level: number;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** A row in the flattened grouped output — either a group or a data row. */
|
|
157
|
+
export type TreeRowNode<T> = GroupRowNode<T> | DataRowNode<T>;
|
|
48
158
|
/**
|
|
49
159
|
* Context passed to the `colSpan` resolver of a column.
|
|
50
160
|
*
|
|
@@ -274,43 +384,19 @@ export interface ColumnLeafDef<T> extends BaseColumnDef<T> {
|
|
|
274
384
|
maxWidth?: number;
|
|
275
385
|
/** Whether this column can be sorted. */
|
|
276
386
|
sortable?: boolean;
|
|
277
|
-
/**
|
|
278
|
-
* Nature of the values in this column. When omitted, the filtering plugin
|
|
279
|
-
* infers it by sampling the data.
|
|
280
|
-
*/
|
|
281
|
-
dataType?: ColumnDataType;
|
|
282
|
-
/**
|
|
283
|
-
* Kind of filter UI rendered for this column. When omitted, it is derived
|
|
284
|
-
* from `dataType` (and, failing that, from the sampled data).
|
|
285
|
-
*/
|
|
286
|
-
filterType?: ColumnFilterType;
|
|
287
|
-
/**
|
|
288
|
-
* Identifier of a custom filter registered with the filtering plugin.
|
|
289
|
-
* Required when `filterType` is `"custom"`.
|
|
290
|
-
*/
|
|
291
|
-
filterTypeId?: string;
|
|
292
|
-
/**
|
|
293
|
-
* Whether this column offers a filter menu. Set to `false` to opt the column out of
|
|
294
|
-
* filtering UI (the header filter icon is hidden).
|
|
295
|
-
* @default true
|
|
296
|
-
*/
|
|
297
|
-
filterable?: boolean;
|
|
298
|
-
/**
|
|
299
|
-
* Custom subset of operators allowed for this column's filter menu.
|
|
300
|
-
*/
|
|
301
|
-
allowedOperators?: FilterOperator[];
|
|
302
|
-
/**
|
|
303
|
-
* Fixed option list used by the `"set"` filter. When provided, the column
|
|
304
|
-
* defaults to `filterType: "set"` unless `filterType` is set explicitly.
|
|
305
|
-
*/
|
|
306
|
-
filterOptions?: Array<{
|
|
307
|
-
label: string;
|
|
308
|
-
value: any;
|
|
309
|
-
}>;
|
|
310
387
|
/** Horizontal alignment of cell content. */
|
|
311
388
|
align?: CellAlign;
|
|
312
389
|
/** Enables automatic text wrapping instead of ellipsis truncation. @default false @api */
|
|
313
390
|
wrapText?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Controls whether the cell keeps the theme's internal padding or removes it
|
|
393
|
+
* so custom content can fill the cell.
|
|
394
|
+
* - `"normal"` (default): preserves the theme padding.
|
|
395
|
+
* - `"flush"`: removes the cell padding.
|
|
396
|
+
* @default "normal"
|
|
397
|
+
* @api
|
|
398
|
+
*/
|
|
399
|
+
cellLayout?: "normal" | "flush";
|
|
314
400
|
/** Initial sort direction used by SortingPlugin. */
|
|
315
401
|
sortState?: SortDirection;
|
|
316
402
|
/** 1-based sort priority, set only while multiple columns are sorted. */
|
|
@@ -553,9 +639,19 @@ export interface ColumnGroupViewport<T> {
|
|
|
553
639
|
export interface ViewportData<T> {
|
|
554
640
|
rows: Array<{
|
|
555
641
|
id: RowId;
|
|
556
|
-
data
|
|
642
|
+
/** Raw row data for leaf rows; `undefined` for group rows. */
|
|
643
|
+
data: T | undefined;
|
|
644
|
+
/** Zero-based index of the row in the flattened output. */
|
|
557
645
|
index: number;
|
|
646
|
+
/** Nesting depth (0 = outermost group, equal to groupBy length for leaves). */
|
|
647
|
+
level: number;
|
|
648
|
+
/** `'group'` for a group row, `'leaf'` for a data row. */
|
|
649
|
+
type: 'group' | 'leaf';
|
|
650
|
+
/** The group node when `type === 'group'`, otherwise `undefined`. */
|
|
651
|
+
group: GroupRowNode<T> | undefined;
|
|
652
|
+
/** Absolute vertical offset (px) of the row top. */
|
|
558
653
|
offset: number;
|
|
654
|
+
/** Row height in pixels. */
|
|
559
655
|
height?: number;
|
|
560
656
|
}>;
|
|
561
657
|
/** Scrollable (virtualized) leaf columns of the current horizontal window. */
|
|
@@ -648,7 +744,13 @@ export interface ViewportData<T> {
|
|
|
648
744
|
totalWidth: number;
|
|
649
745
|
totalHeight: number;
|
|
650
746
|
}
|
|
651
|
-
|
|
747
|
+
/**
|
|
748
|
+
* Fundamental state owned directly by the Grid Core engine.
|
|
749
|
+
* Contains only rendering, geometry, viewport, and core overlay state.
|
|
750
|
+
*
|
|
751
|
+
* @api
|
|
752
|
+
*/
|
|
753
|
+
export interface CoreGridState<T> {
|
|
652
754
|
data: T[];
|
|
653
755
|
columns: ColumnDef<T>[];
|
|
654
756
|
viewport: ViewportState;
|
|
@@ -659,10 +761,51 @@ export interface GridState<T> {
|
|
|
659
761
|
flashedCells: Map<string, number>;
|
|
660
762
|
/** Active overlay state — updated automatically by the grid's overlay manager. */
|
|
661
763
|
overlay: OverlayState;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Open interface for plugin-contributed state slices.
|
|
767
|
+
* Plugins augment this interface via TypeScript module augmentation.
|
|
768
|
+
*
|
|
769
|
+
* @api
|
|
770
|
+
*/
|
|
771
|
+
export interface PluginStateExtensions<T> {
|
|
772
|
+
/** Fields the rows are currently grouped by (empty = no grouping). */
|
|
773
|
+
groupBy?: string[];
|
|
774
|
+
/** Expanded state of groups, keyed by group id. */
|
|
775
|
+
expandedGroups?: Record<string, boolean>;
|
|
776
|
+
/** Group column render mode: `'single'` (one Group column) or `'perLevel'` (one column per group level). */
|
|
777
|
+
groupColumnMode?: "single" | "perLevel";
|
|
778
|
+
/** Header text for the Group column in `'single'` mode. */
|
|
779
|
+
groupColumnHeader?: string;
|
|
780
|
+
/** Whether group rows display the number of child rows. */
|
|
781
|
+
showChildCount?: boolean;
|
|
782
|
+
/** Custom renderer for group rows. */
|
|
783
|
+
groupRowRenderer?: GroupRowRenderer<T>;
|
|
662
784
|
/**
|
|
663
785
|
* Global quick filter query string. Applied across every column whose
|
|
664
786
|
* `searchable` property is not `false`. Empty string means no quick filter.
|
|
665
787
|
*/
|
|
788
|
+
quickFilter?: string;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Unified grid state combining core state and modular plugin slices.
|
|
792
|
+
*
|
|
793
|
+
* @api
|
|
794
|
+
*/
|
|
795
|
+
export interface GridState<T> extends CoreGridState<T>, PluginStateExtensions<T> {
|
|
796
|
+
/** Fields the rows are currently grouped by (empty = no grouping). */
|
|
797
|
+
groupBy: string[];
|
|
798
|
+
/** Expanded state of groups, keyed by group id. */
|
|
799
|
+
expandedGroups: Record<string, boolean>;
|
|
800
|
+
/** Group column render mode: `'single'` (one Group column) or `'perLevel'` (one column per group level). */
|
|
801
|
+
groupColumnMode: "single" | "perLevel";
|
|
802
|
+
/** Header text for the Group column in `'single'` mode. */
|
|
803
|
+
groupColumnHeader: string;
|
|
804
|
+
/** Whether group rows display the number of child rows. */
|
|
805
|
+
showChildCount: boolean;
|
|
806
|
+
/** Custom renderer for group rows. */
|
|
807
|
+
groupRowRenderer?: GroupRowRenderer<T>;
|
|
808
|
+
/** Global quick filter query string. */
|
|
666
809
|
quickFilter: string;
|
|
667
810
|
}
|
|
668
811
|
export interface GridEvents<T> {
|
|
@@ -956,8 +1099,39 @@ export interface SlotMount<T> {
|
|
|
956
1099
|
position: SlotPosition;
|
|
957
1100
|
unmount(): void;
|
|
958
1101
|
}
|
|
959
|
-
|
|
1102
|
+
/**
|
|
1103
|
+
* Open interface for plugin-contributed API methods.
|
|
1104
|
+
* Plugins augment this interface via TypeScript module augmentation.
|
|
1105
|
+
*
|
|
1106
|
+
* @api
|
|
1107
|
+
*/
|
|
1108
|
+
export interface PluginApiExtensions<T> {
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Base grid API surface provided by the core engine.
|
|
1112
|
+
*
|
|
1113
|
+
* @api
|
|
1114
|
+
*/
|
|
1115
|
+
export interface CoreGridApi<T> {
|
|
960
1116
|
getState(): GridState<T>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Updates the grid state via partial patch or reducer.
|
|
1119
|
+
* @param updater - State slice patch or updater function.
|
|
1120
|
+
* @api
|
|
1121
|
+
*/
|
|
1122
|
+
setState(updater: StateUpdater<GridState<T>>): void;
|
|
1123
|
+
/**
|
|
1124
|
+
* Registers methods dynamically contributed by plugins.
|
|
1125
|
+
* These methods are attached both to `api.methods` and directly to `api`.
|
|
1126
|
+
* @param methods - Methods to register.
|
|
1127
|
+
* @returns Cleanup callback to unregister the methods.
|
|
1128
|
+
* @api
|
|
1129
|
+
*/
|
|
1130
|
+
registerMethods(methods: Record<string, unknown>): () => void;
|
|
1131
|
+
/** Extensible multi-stage data transformation pipeline. */
|
|
1132
|
+
readonly pipeline: DataPipeline<T>;
|
|
1133
|
+
/** Namespace for plugin-contributed methods. */
|
|
1134
|
+
readonly methods: Record<string, unknown>;
|
|
961
1135
|
getScrollPosition(): ScrollPosition;
|
|
962
1136
|
/**
|
|
963
1137
|
* Requests a native scroll position update from the active adapter.
|
|
@@ -968,6 +1142,28 @@ export interface GridApi<T> {
|
|
|
968
1142
|
getViewportData(): ViewportData<T>;
|
|
969
1143
|
getColumnWidth(columnId: string): number | undefined;
|
|
970
1144
|
getProcessedData(): T[];
|
|
1145
|
+
/**
|
|
1146
|
+
* Returns the active dataset consumed by the virtualizer and DOM pool.
|
|
1147
|
+
* When grouping or a custom row model is active, returns the transformed rows;
|
|
1148
|
+
* otherwise returns the processed data rows.
|
|
1149
|
+
* @api
|
|
1150
|
+
*/
|
|
1151
|
+
getRows(): unknown[];
|
|
1152
|
+
/**
|
|
1153
|
+
* Returns the rows after core filtering but before plugin processors.
|
|
1154
|
+
* @api
|
|
1155
|
+
*/
|
|
1156
|
+
getFilteredData(): T[];
|
|
1157
|
+
/** Returns the registered generic row hierarchy capability, if any. @api */
|
|
1158
|
+
getRowHierarchy(): RowHierarchy<T> | undefined;
|
|
1159
|
+
/**
|
|
1160
|
+
* Registers a generic row hierarchy capability.
|
|
1161
|
+
* Only one active hierarchy provider is supported per grid instance.
|
|
1162
|
+
* @param hierarchy - The active row hierarchy implementation.
|
|
1163
|
+
* @returns Cleanup callback to unregister the provider.
|
|
1164
|
+
* @api
|
|
1165
|
+
*/
|
|
1166
|
+
registerRowHierarchy(hierarchy: RowHierarchy<T>): () => void;
|
|
971
1167
|
getRowId(row: T, index: number): RowId;
|
|
972
1168
|
/**
|
|
973
1169
|
* Resolves the normalized horizontal span of a single body cell.
|
|
@@ -1193,4 +1389,10 @@ export interface GridApi<T> {
|
|
|
1193
1389
|
destroy(): void;
|
|
1194
1390
|
isDestroyed(): boolean;
|
|
1195
1391
|
}
|
|
1196
|
-
|
|
1392
|
+
/**
|
|
1393
|
+
* Complete grid API surface combining core methods and modular plugin extensions.
|
|
1394
|
+
*
|
|
1395
|
+
* @api
|
|
1396
|
+
*/
|
|
1397
|
+
export interface GridApi<T> extends CoreGridApi<T>, PluginApiExtensions<T> {
|
|
1398
|
+
}
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@omnigrid/core",
|
|
3
|
+
"version": "0.1.25",
|
|
4
|
+
"description": "Framework-agnostic core engine for OmniGrid",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"omnigrid",
|
|
7
|
+
"grid",
|
|
8
|
+
"table",
|
|
9
|
+
"datatable",
|
|
10
|
+
"core",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/KRZK-Apps/omnigrid.git",
|
|
16
|
+
"directory": "core"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/KRZK-Apps/omnigrid/tree/main/core#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/KRZK-Apps/omnigrid/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "npx tsc -p tsconfig.json",
|
|
37
|
+
"lint": "npx tsc --noEmit -p tsconfig.json",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"vitest": "^5.0.2"
|
|
30
43
|
}
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"dist"
|
|
34
|
-
],
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "npx tsc -p tsconfig.json",
|
|
37
|
-
"lint": "npx tsc --noEmit -p tsconfig.json",
|
|
38
|
-
"test": "vitest run",
|
|
39
|
-
"prepublishOnly": "npm run build"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"vitest": "^5.0.2"
|
|
43
|
-
}
|
|
44
44
|
}
|