@olvnck/ingrid 0.0.0-stage → 0.15.20
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +5533 -2
- package/THIRD_PARTY_NOTICES.md +10 -0
- package/dist/engine/clipboard/copy.d.ts +40 -0
- package/dist/engine/clipboard/options.d.ts +16 -0
- package/dist/engine/clipboard/text.d.ts +32 -0
- package/dist/engine/columns/autosize.d.ts +43 -0
- package/dist/engine/columns/dataType.d.ts +30 -0
- package/dist/engine/columns/fold.d.ts +48 -0
- package/dist/engine/columns/layout.d.ts +150 -0
- package/dist/engine/columns/model.d.ts +369 -0
- package/dist/engine/columns/query.d.ts +16 -0
- package/dist/engine/columns/tooltips.d.ts +27 -0
- package/dist/engine/data/client/clientSource.d.ts +151 -0
- package/dist/engine/data/client/columnFilters.d.ts +106 -0
- package/dist/engine/data/client/descendants.d.ts +35 -0
- package/dist/engine/data/client/diff.d.ts +23 -0
- package/dist/engine/data/client/fields.d.ts +70 -0
- package/dist/engine/data/client/filter.d.ts +95 -0
- package/dist/engine/data/client/flatten.d.ts +141 -0
- package/dist/engine/data/client/groupSize.d.ts +14 -0
- package/dist/engine/data/client/hierarchy.d.ts +85 -0
- package/dist/engine/data/client/order.d.ts +32 -0
- package/dist/engine/data/client/pipeline.d.ts +277 -0
- package/dist/engine/data/client/remap.d.ts +33 -0
- package/dist/engine/data/client/trees.d.ts +41 -0
- package/dist/engine/data/client/types.d.ts +173 -0
- package/dist/engine/data/memory/generate.d.ts +36 -0
- package/dist/engine/data/memory/memoryDatasource.d.ts +46 -0
- package/dist/engine/data/rowKey.d.ts +15 -0
- package/dist/engine/data/server/contract.d.ts +64 -0
- package/dist/engine/data/server/expansion.d.ts +35 -0
- package/dist/engine/data/server/levelStore.d.ts +99 -0
- package/dist/engine/data/server/loader.d.ts +128 -0
- package/dist/engine/data/server/reader.d.ts +88 -0
- package/dist/engine/data/server/response.d.ts +31 -0
- package/dist/engine/data/server/serverSource.d.ts +130 -0
- package/dist/engine/data/shared/aggregate.d.ts +12 -0
- package/dist/engine/data/shared/columnFilter.d.ts +19 -0
- package/dist/engine/data/shared/compare.d.ts +12 -0
- package/dist/engine/data/shared/dateParts.d.ts +19 -0
- package/dist/engine/data/shared/distinct.d.ts +30 -0
- package/dist/engine/data/shared/filterRecord.d.ts +7 -0
- package/dist/engine/data/shared/keys.d.ts +17 -0
- package/dist/engine/data/shared/quickFilter.d.ts +17 -0
- package/dist/engine/data/shared/sourceUtils.d.ts +11 -0
- package/dist/engine/data/shared/splice.d.ts +9 -0
- package/dist/engine/detail/builds.d.ts +26 -0
- package/dist/engine/detail/content.d.ts +24 -0
- package/dist/engine/detail/controller.d.ts +176 -0
- package/dist/engine/detail/events.d.ts +11 -0
- package/dist/engine/detail/follow.d.ts +56 -0
- package/dist/engine/detail/layer.d.ts +119 -0
- package/dist/engine/detail/live.d.ts +96 -0
- package/dist/engine/detail/options.d.ts +53 -0
- package/dist/engine/detail/state.d.ts +140 -0
- package/dist/engine/edit/clear.d.ts +20 -0
- package/dist/engine/edit/editing.d.ts +4 -0
- package/dist/engine/edit/editors/date.d.ts +3 -0
- package/dist/engine/edit/editors/index.d.ts +23 -0
- package/dist/engine/edit/editors/internals.d.ts +25 -0
- package/dist/engine/edit/editors/largeText.d.ts +2 -0
- package/dist/engine/edit/editors/number.d.ts +4 -0
- package/dist/engine/edit/editors/select.d.ts +2 -0
- package/dist/engine/edit/editors/text.d.ts +15 -0
- package/dist/engine/edit/fill.d.ts +47 -0
- package/dist/engine/edit/fillHandle.d.ts +66 -0
- package/dist/engine/edit/fillValues.d.ts +15 -0
- package/dist/engine/edit/operations.d.ts +68 -0
- package/dist/engine/edit/paste.d.ts +23 -0
- package/dist/engine/edit/pastePlan.d.ts +17 -0
- package/dist/engine/edit/popupHost.d.ts +63 -0
- package/dist/engine/edit/session.d.ts +52 -0
- package/dist/engine/edit/types.d.ts +234 -0
- package/dist/engine/edit/undo.d.ts +38 -0
- package/dist/engine/edit/validation.d.ts +10 -0
- package/dist/engine/edit/values.d.ts +38 -0
- package/dist/engine/export/columns.d.ts +19 -0
- package/dist/engine/export/deliver.d.ts +47 -0
- package/dist/engine/export/dsv.d.ts +2 -0
- package/dist/engine/export/expanded.d.ts +69 -0
- package/dist/engine/export/export.d.ts +25 -0
- package/dist/engine/export/headers.d.ts +15 -0
- package/dist/engine/export/options.d.ts +19 -0
- package/dist/engine/export/plan.d.ts +43 -0
- package/dist/engine/export/values.d.ts +33 -0
- package/dist/engine/export/walk.d.ts +31 -0
- package/dist/engine/export/writer.d.ts +62 -0
- package/dist/engine/export/xlsx/cells.d.ts +31 -0
- package/dist/engine/export/xlsx/index.d.ts +12 -0
- package/dist/engine/export/xlsx/parts.d.ts +36 -0
- package/dist/engine/export/xlsx/sheet.d.ts +30 -0
- package/dist/engine/export/xlsx/styles.d.ts +15 -0
- package/dist/engine/export/xlsx/table.d.ts +8 -0
- package/dist/engine/export/xlsx/zip.d.ts +24 -0
- package/dist/engine/filter/groupFilter.d.ts +28 -0
- package/dist/engine/filter/model.d.ts +235 -0
- package/dist/engine/filter/shorthand.d.ts +36 -0
- package/dist/engine/filter/state.d.ts +76 -0
- package/dist/engine/filter/summary.d.ts +16 -0
- package/dist/engine/filter/values.d.ts +40 -0
- package/dist/engine/find/index.d.ts +94 -0
- package/dist/engine/find/match.d.ts +38 -0
- package/dist/engine/find/model.d.ts +115 -0
- package/dist/engine/grid.d.ts +42 -0
- package/dist/engine/i18n/numbers.d.ts +34 -0
- package/dist/engine/i18n/texts.d.ts +306 -0
- package/dist/engine/interact/autoScroll.d.ts +11 -0
- package/dist/engine/interact/body.d.ts +41 -0
- package/dist/engine/interact/focus.d.ts +158 -0
- package/dist/engine/interact/header.d.ts +216 -0
- package/dist/engine/interact/host.d.ts +400 -0
- package/dist/engine/interact/keyboard.d.ts +20 -0
- package/dist/engine/interact/menuKey.d.ts +7 -0
- package/dist/engine/interact/own.d.ts +2 -0
- package/dist/engine/interact/ranges.d.ts +68 -0
- package/dist/engine/interact/rowSelection.d.ts +53 -0
- package/dist/engine/interact/shortcut.d.ts +21 -0
- package/dist/engine/interact/tooltips.d.ts +63 -0
- package/dist/engine/measure.d.ts +30 -0
- package/dist/engine/render/cells.d.ts +322 -0
- package/dist/engine/render/columns.d.ts +28 -0
- package/dist/engine/render/dom.d.ts +24 -0
- package/dist/engine/render/flash.d.ts +74 -0
- package/dist/engine/render/groupCell.d.ts +50 -0
- package/dist/engine/render/groupPanel.d.ts +21 -0
- package/dist/engine/render/header.d.ts +162 -0
- package/dist/engine/render/overlay.d.ts +15 -0
- package/dist/engine/render/pinnedRows.d.ts +106 -0
- package/dist/engine/render/rowPool.d.ts +3 -0
- package/dist/engine/render/scrollbars.d.ts +77 -0
- package/dist/engine/render/strategy.d.ts +397 -0
- package/dist/engine/reportError.d.ts +7 -0
- package/dist/engine/rowdrag/controller.d.ts +80 -0
- package/dist/engine/rowdrag/events.d.ts +17 -0
- package/dist/engine/rowdrag/gesture.d.ts +33 -0
- package/dist/engine/rowdrag/keys.d.ts +21 -0
- package/dist/engine/rowdrag/model.d.ts +67 -0
- package/dist/engine/rowdrag/options.d.ts +34 -0
- package/dist/engine/rowdrag/rows.d.ts +61 -0
- package/dist/engine/rowdrag/target.d.ts +59 -0
- package/dist/engine/rowdrag/zones.d.ts +79 -0
- package/dist/engine/schedule.d.ts +29 -0
- package/dist/engine/selection/aggregate.d.ts +30 -0
- package/dist/engine/selection/options.d.ts +7 -0
- package/dist/engine/selection/rangeRows.d.ts +19 -0
- package/dist/engine/selection/ranges.d.ts +114 -0
- package/dist/engine/selection/rows.d.ts +207 -0
- package/dist/engine/source.d.ts +225 -0
- package/dist/engine/synthetic.d.ts +28 -0
- package/dist/engine/table/cells.d.ts +52 -0
- package/dist/engine/table/headers.d.ts +20 -0
- package/dist/engine/table/host.d.ts +65 -0
- package/dist/engine/table/job.d.ts +21 -0
- package/dist/engine/table/rows.d.ts +99 -0
- package/dist/engine/table/slicer.d.ts +54 -0
- package/dist/engine/table/takes.d.ts +145 -0
- package/dist/engine/types.d.ts +2950 -0
- package/dist/engine/ui/announce.d.ts +7 -0
- package/dist/engine/ui/chooser.d.ts +19 -0
- package/dist/engine/ui/columnList.d.ts +41 -0
- package/dist/engine/ui/columnMenu.d.ts +96 -0
- package/dist/engine/ui/columnsPanel.d.ts +16 -0
- package/dist/engine/ui/contextMenu.d.ts +48 -0
- package/dist/engine/ui/controller.d.ts +295 -0
- package/dist/engine/ui/filters/apply.d.ts +53 -0
- package/dist/engine/ui/filters/custom.d.ts +3 -0
- package/dist/engine/ui/filters/date.d.ts +12 -0
- package/dist/engine/ui/filters/host.d.ts +102 -0
- package/dist/engine/ui/filters/multi.d.ts +6 -0
- package/dist/engine/ui/filters/number.d.ts +15 -0
- package/dist/engine/ui/filters/numberMask.d.ts +15 -0
- package/dist/engine/ui/filters/set.d.ts +3 -0
- package/dist/engine/ui/filters/simple.d.ts +52 -0
- package/dist/engine/ui/filters/text.d.ts +5 -0
- package/dist/engine/ui/filtersPanel.d.ts +18 -0
- package/dist/engine/ui/floating.d.ts +66 -0
- package/dist/engine/ui/floatingShorthand.d.ts +20 -0
- package/dist/engine/ui/floatingTypes.d.ts +82 -0
- package/dist/engine/ui/icons.d.ts +25 -0
- package/dist/engine/ui/menu.d.ts +45 -0
- package/dist/engine/ui/overlayHost.d.ts +7 -0
- package/dist/engine/ui/place.d.ts +37 -0
- package/dist/engine/ui/popup.d.ts +97 -0
- package/dist/engine/ui/sideBar.d.ts +26 -0
- package/dist/engine/ui/statusBar.d.ts +29 -0
- package/dist/engine/ui/toolbar/buttons.d.ts +21 -0
- package/dist/engine/ui/toolbar/chipState.d.ts +52 -0
- package/dist/engine/ui/toolbar/chips.d.ts +23 -0
- package/dist/engine/ui/toolbar/findBox.d.ts +10 -0
- package/dist/engine/ui/toolbar/quickFilterBox.d.ts +12 -0
- package/dist/engine/ui/toolbar/registry.d.ts +5 -0
- package/dist/engine/ui/toolbar/toolbar.d.ts +31 -0
- package/dist/engine/ui/toolbar/types.d.ts +23 -0
- package/dist/engine/ui/tooltip.d.ts +34 -0
- package/dist/engine/ui/virtualList.d.ts +35 -0
- package/dist/engine/viewport/heightView.d.ts +62 -0
- package/dist/engine/viewport/heights.d.ts +39 -0
- package/dist/engine/viewport/intervals.d.ts +19 -0
- package/dist/engine/viewport/range.d.ts +51 -0
- package/dist/engine/viewport/scroll.d.ts +45 -0
- package/dist/engine/viewport/stack.d.ts +160 -0
- package/dist/grid-C34VEap6.js +32310 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1273 -0
- package/dist/ingrid.css +1 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.js +1 -0
- package/dist/locale/de.d.ts +4 -0
- package/dist/locale/de.js +222 -0
- package/dist/themes/primevue.css +63 -0
- package/dist/themes/tailwind.css +68 -0
- package/dist/vue/InGrid.vue.d.ts +263 -0
- package/dist/vue/stableOptions.d.ts +8 -0
- package/dist/vue/useClientSource.d.ts +28 -0
- package/dist/vue/useServerSource.d.ts +8 -0
- package/dist/vue/vueRenderer.d.ts +164 -0
- package/dist/xlsx-59umS_n_.js +325 -0
- package/package.json +78 -5
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { type FilterValues, type RowQuery, type ValuesRequest } from '../../source';
|
|
2
|
+
import type { Fields } from './fields';
|
|
3
|
+
import { type TotalPlace } from './flatten';
|
|
4
|
+
import { type AggregateValues, type Hierarchy } from './hierarchy';
|
|
5
|
+
import { type TreeShape } from './trees';
|
|
6
|
+
import type { ClientSourceOptions, Reporter, TreeOptions } from './types';
|
|
7
|
+
export interface PipelineOptions<T> {
|
|
8
|
+
fields: Fields<T>;
|
|
9
|
+
/** Tree data; null = flat rows, which may be grouped. */
|
|
10
|
+
tree: TreeOptions<T> | null;
|
|
11
|
+
/** The `id` option as a function: parent-id and nested trees key their nodes by it. */
|
|
12
|
+
idOf: ((row: T) => string | number) | null;
|
|
13
|
+
/** `ClientSourceOptions.aggregates`: custom aggregate functions (a built-in name wins). */
|
|
14
|
+
aggregates: Readonly<Record<string, (values: readonly unknown[]) => unknown>>;
|
|
15
|
+
/** `ClientSourceOptions.filterTypes`: the tests of custom filter kinds. */
|
|
16
|
+
filterTypes?: ClientSourceOptions<T>['filterTypes'];
|
|
17
|
+
report: Reporter;
|
|
18
|
+
/** A tree adapter's problem, with the error of a throwing tree getter. */
|
|
19
|
+
reportTree: (problem: string, error?: unknown) => void;
|
|
20
|
+
}
|
|
21
|
+
/** How often each stage ran (a stage runs again only when one of its inputs changed). */
|
|
22
|
+
export interface PipelineStats {
|
|
23
|
+
tree: number;
|
|
24
|
+
sort: number;
|
|
25
|
+
quickFilter: number;
|
|
26
|
+
/** The column filters' mask. */
|
|
27
|
+
columnFilter: number;
|
|
28
|
+
predicate: number;
|
|
29
|
+
hierarchy: number;
|
|
30
|
+
/** The group-size filter's pass over grouped rows: its test and the grouping built again. */
|
|
31
|
+
groupSize: number;
|
|
32
|
+
aggregates: number;
|
|
33
|
+
order: number;
|
|
34
|
+
/** Appended rows taken in by `append`, without running the stages again. */
|
|
35
|
+
append: number;
|
|
36
|
+
}
|
|
37
|
+
/** What one run hands the source. */
|
|
38
|
+
export interface PipelineOutput<T> {
|
|
39
|
+
/** Data nodes 0 … dataCount − 1: the input array, or (nested trees) the depth-first array of its rows. */
|
|
40
|
+
readonly nodes: readonly T[];
|
|
41
|
+
readonly dataCount: number;
|
|
42
|
+
readonly hierarchy: Hierarchy;
|
|
43
|
+
/** The hierarchy's children in display order (laid out like `hierarchy.children`). */
|
|
44
|
+
readonly ordered: Int32Array;
|
|
45
|
+
/**
|
|
46
|
+
* Per data node: its position in the sort permutation (ties by input position). A new array exactly when the
|
|
47
|
+
* permutation changed: flat rows shown under two outputs with the same `rank` and `nodes` are both in its order.
|
|
48
|
+
*/
|
|
49
|
+
readonly rank: Int32Array;
|
|
50
|
+
/** Replaced by `Pipeline.refreshAggregates` on the output the source shows; nothing else moves. */
|
|
51
|
+
aggregates: AggregateValues;
|
|
52
|
+
/** Data rows passing the filters; trees: visible data nodes. */
|
|
53
|
+
readonly count: number;
|
|
54
|
+
/** All data rows; trees: the data nodes the tree kept (dropped rows count in neither). */
|
|
55
|
+
readonly total: number;
|
|
56
|
+
/**
|
|
57
|
+
* Every node of the hierarchy depth-first, as if everything were expanded; built on first use. With `place`: each
|
|
58
|
+
* node's total row at its place too (`flatten.ts` `depthFirst`), built once for the place last
|
|
59
|
+
* given — the client source gives one per run.
|
|
60
|
+
*/
|
|
61
|
+
depthFirst(place?: ((node: number) => TotalPlace) | null): Int32Array;
|
|
62
|
+
/**
|
|
63
|
+
* Per node: its position in `depthFirst(place)`, −1 outside the hierarchy (runSplices' order); built on first use.
|
|
64
|
+
* With `place` it also covers total rows' numbers (`2 · nodeCount + 1` entries; −1 for the top node, which is no
|
|
65
|
+
* row of the order, and for totals that are none).
|
|
66
|
+
*/
|
|
67
|
+
dfsRank(place?: ((node: number) => TotalPlace) | null): Int32Array;
|
|
68
|
+
/** A tree's structure (every node, filtered-out ones included; −2 = dropped); null for flat or grouped rows. */
|
|
69
|
+
readonly shape: TreeShape<T> | null;
|
|
70
|
+
/**
|
|
71
|
+
* Grouped rows: per level, the grouped field's values of every data node, filtered-out ones included (what the
|
|
72
|
+
* groups were built from); null otherwise.
|
|
73
|
+
*/
|
|
74
|
+
readonly groupValues: readonly (readonly unknown[])[] | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The client pipeline: sort permutation → filter mask (quick filter, predicate and column filters) → hierarchy
|
|
78
|
+
* (grouped rows under a group-size filter: grouped again) → aggregates → order, each stage cached with its inputs and
|
|
79
|
+
* run again only when one of them changed. A new array keeps the per-row caches of the row objects it holds again;
|
|
80
|
+
* the set filter's values come from the same caches (`filterValues`). Plain TypeScript over typed arrays — no
|
|
81
|
+
* listeners, no DOM, no Vue (worker-safe). `clientSource` flattens the result and announces it.
|
|
82
|
+
*/
|
|
83
|
+
export declare class Pipeline<T extends object> {
|
|
84
|
+
readonly stats: PipelineStats;
|
|
85
|
+
private readonly options;
|
|
86
|
+
private readonly quick;
|
|
87
|
+
private readonly columnMasks;
|
|
88
|
+
private readonly keepDescendants;
|
|
89
|
+
private rows;
|
|
90
|
+
/** Moves with every setData (a refresh too): every stage depends on it. */
|
|
91
|
+
private data;
|
|
92
|
+
private predicate;
|
|
93
|
+
private predicateVersion;
|
|
94
|
+
/** Field values of the current data version: each field is read once per data change. */
|
|
95
|
+
private columns;
|
|
96
|
+
/**
|
|
97
|
+
* The data nodes the current data version's per-row caches were read from, taken when a run first holds a
|
|
98
|
+
* cache: a copy when they are the app's array, which the app may change in place before its next `setData`
|
|
99
|
+
* (a nested tree's nodes are the pipeline's own). Null: no cache held.
|
|
100
|
+
*/
|
|
101
|
+
private idents;
|
|
102
|
+
/** The last data version's caches, carried into the next run once its nodes are known. */
|
|
103
|
+
private pending;
|
|
104
|
+
/** The carry's map of the current data version (new node → old node, −1 = new row); null when none ran. */
|
|
105
|
+
private remap;
|
|
106
|
+
/** Set-filter values: per field, the last request's key and answer. */
|
|
107
|
+
private valuesCache;
|
|
108
|
+
/** Each stage's inputs at its last run, compared by identity. */
|
|
109
|
+
private readonly inputs;
|
|
110
|
+
private sort;
|
|
111
|
+
private groupBy;
|
|
112
|
+
private aggregateQuery;
|
|
113
|
+
private quickFilter;
|
|
114
|
+
private filter;
|
|
115
|
+
/**
|
|
116
|
+
* `filter` without the group column's entries: what the row mask tests. Kept by value, so a change of the
|
|
117
|
+
* group-size filter alone keeps the column mask and the base grouping; only the group-size pass runs again.
|
|
118
|
+
*/
|
|
119
|
+
private rowFilter;
|
|
120
|
+
private shape;
|
|
121
|
+
private perm;
|
|
122
|
+
private rank;
|
|
123
|
+
private quickMask;
|
|
124
|
+
private predMask;
|
|
125
|
+
private columnMask;
|
|
126
|
+
private mask;
|
|
127
|
+
/** The hierarchy shown: the grouping of the passing rows, or with a group-size filter the `sized` one. */
|
|
128
|
+
private hierarchy;
|
|
129
|
+
/** Grouped rows: the grouping of the rows the mask passes (null otherwise); the group-size pass reads it. */
|
|
130
|
+
private groups;
|
|
131
|
+
/** The grouping again, of the rows in groups the group-size filter keeps (null without one). */
|
|
132
|
+
private sized;
|
|
133
|
+
private count;
|
|
134
|
+
private aggregateValues;
|
|
135
|
+
/** The aggregates include the virtual top node's — the grand total's — while the source shows one. */
|
|
136
|
+
private top;
|
|
137
|
+
private ordered;
|
|
138
|
+
/** `failing`'s own filter caches, over the rows it is asked about; built on first use. */
|
|
139
|
+
private probe;
|
|
140
|
+
constructor(options: PipelineOptions<T>);
|
|
141
|
+
/**
|
|
142
|
+
* New rows, or the same array after in-place changes (refresh): every stage runs again. The same array drops every
|
|
143
|
+
* per-row cache — field columns, filter values and texts, haystacks — since any row may have changed in place.
|
|
144
|
+
* A new array keeps them for the row objects the last data version held: the next run
|
|
145
|
+
* carries them by identity once its data nodes are known (a tree's, after `buildTree`) and reads only new rows.
|
|
146
|
+
* Masks, the permutation and the hierarchy are computed again either way.
|
|
147
|
+
*/
|
|
148
|
+
setData(rows: readonly T[]): void;
|
|
149
|
+
/**
|
|
150
|
+
* The remap of the current data version, when its first run carried the last version's caches (a `setData` with a
|
|
151
|
+
* new array while a cache was held): new data node → old data node of the same row object, −1 for a new one. Null
|
|
152
|
+
* otherwise (the client source then builds the map itself).
|
|
153
|
+
*/
|
|
154
|
+
lastRemap(): Int32Array | null;
|
|
155
|
+
/**
|
|
156
|
+
* Data node `node`'s row object was changed in place (a value write): its entries in the
|
|
157
|
+
* per-row caches are read again — the field columns (sort keys, group keys, aggregated values), the column filters'
|
|
158
|
+
* values and texts, its quick-filter text — and the stages whose results that may change run again at the next
|
|
159
|
+
* `run`: the sort, grouping or aggregates when a cached value of their fields changed, the quick filter when the
|
|
160
|
+
* text did, column filters and an app predicate always (a test may read any part of the row). Nothing runs now and
|
|
161
|
+
* the other rows' caches stay: no data change. A row's id and a tree's structure are read by `setData` only.
|
|
162
|
+
*/
|
|
163
|
+
rowChanged(node: number): void;
|
|
164
|
+
/**
|
|
165
|
+
* A held update: `rows` takes the place of the rows held — the same count, and node for node the same
|
|
166
|
+
* row (the caller checked the ids) as other objects. Every node whose object differs — every node when `rows` is
|
|
167
|
+
* the array held, its rows changed in place — counts as written (`rowChanged`): its cached keys are read from the new object, and the stages those feed run again at the next
|
|
168
|
+
* `run`; no stage runs now, so every row keeps its place and its visibility. The filter caches describe the old
|
|
169
|
+
* array and go, with the filter stages' memos: the next run tests every row's fresh values. Returns the nodes
|
|
170
|
+
* whose object differs; null — nothing changed — for a tree (its structure is built from the rows), another count,
|
|
171
|
+
* or a data version that has not run yet.
|
|
172
|
+
*/
|
|
173
|
+
hold(rows: readonly T[]): number[] | null;
|
|
174
|
+
/**
|
|
175
|
+
* Of the data nodes `nodes` (flat or grouped rows), those whose values as they are now fail the last run's quick
|
|
176
|
+
* filter, column filters (the group column's excepted) or app predicate: rows that stay shown after a
|
|
177
|
+
* write or a held update although they no longer match. Tested apart from the stages' caches, which keep
|
|
178
|
+
* describing the last run. None without a filter, and none in a tree (a row shows there for its descendants too).
|
|
179
|
+
*/
|
|
180
|
+
failing(nodes: readonly number[]): number[];
|
|
181
|
+
/**
|
|
182
|
+
* After a write, the aggregates stage alone — `computeAggregates` over the current hierarchy,
|
|
183
|
+
* when `rowChanged` dropped its memo (an aggregated field changed). No sort, grouping or order runs, so no row moves;
|
|
184
|
+
* those stages' dropped inputs stay dropped, so the next `run` still sorts and groups by the written values. The
|
|
185
|
+
* stage's inputs are recorded as a run would, and the order stage's too when it was current for the old values: a
|
|
186
|
+
* run that changes nothing else does not re-order groups by their new sums. True when the stage ran.
|
|
187
|
+
*/
|
|
188
|
+
refreshAggregates(): boolean;
|
|
189
|
+
/** The aggregates the next `run` hands out (after `refreshAggregates`, the refreshed ones). */
|
|
190
|
+
currentAggregates(): AggregateValues;
|
|
191
|
+
/**
|
|
192
|
+
* Whether runs aggregate the virtual top node too (`AggregateValues.top`, every visible leaf: the grand
|
|
193
|
+
* total's values) — only while a grand total is asked. A change runs the aggregates stage again at the next `run`.
|
|
194
|
+
*/
|
|
195
|
+
setTopAggregates(on: boolean): void;
|
|
196
|
+
/** The app's filter; a call with any function runs the predicate again, even the same one. */
|
|
197
|
+
setPredicate(predicate: ((row: T) => boolean) | null): void;
|
|
198
|
+
run(query: RowQuery): PipelineOutput<T>;
|
|
199
|
+
/**
|
|
200
|
+
* The set filter's values: the distinct filter values of `request.field` over the data nodes
|
|
201
|
+
* passing `request`'s filters and the predicate (`valuesMask`), blanks first, then by the field's comparator, with
|
|
202
|
+
* counts when asked. `search` and `limit` are ignored (the UI searches the labels). Cached one entry per field by
|
|
203
|
+
* the data version, the predicate version, `filter`, `quickFilter` and `counts`: an equal request returns
|
|
204
|
+
* the same object, which callers must not change.
|
|
205
|
+
*/
|
|
206
|
+
filterValues(request: ValuesRequest): FilterValues;
|
|
207
|
+
/**
|
|
208
|
+
* The data nodes passing a values request's filters (`filter`, the other columns' entries; `quickFilter`) and the
|
|
209
|
+
* app predicate: a tree's data nodes by their own pass, not the visibility (no ancestor or descendant
|
|
210
|
+
* kept around a match, no dropped row); grouped rows' leaves. Null: every data node passes. `field`, the field
|
|
211
|
+
* listed, has its filter values read and held beside the query's before the nodes' identities are
|
|
212
|
+
* recorded, so a new array carries them even when the query holds no cache.
|
|
213
|
+
*/
|
|
214
|
+
valuesMask(request: Pick<ValuesRequest, 'field' | 'filter' | 'quickFilter'>): Uint8Array | null;
|
|
215
|
+
/**
|
|
216
|
+
* After a throw: `due` recorded the inputs of the stage that threw, so every stage's are forgotten (the next run
|
|
217
|
+
* starts over), with the filter caches and a pending carry.
|
|
218
|
+
*/
|
|
219
|
+
private forget;
|
|
220
|
+
/**
|
|
221
|
+
* The rows from `from` on were pushed onto the array the pipeline holds, and the rows before them did not change
|
|
222
|
+
* (`refresh({ appended })`): a new data version computed from the last run's, which must have covered
|
|
223
|
+
* exactly rows 0 … from − 1 under `query`. Flat rows only (no tree, no grouping): the cached columns (the column
|
|
224
|
+
* filters' too) are extended, the new rows inserted into the permutation (`insertSorted`) and tested against the
|
|
225
|
+
* filters alone, then the flat hierarchy is built again (O(rows), typed arrays) and every stage's inputs recorded,
|
|
226
|
+
* so a `run` with the same query redoes nothing. Returns the output, or null when the incremental path does not
|
|
227
|
+
* apply (nothing changed then: the caller runs `setData` and `run`). A throw forgets every stage's inputs and the
|
|
228
|
+
* columns, like `run`.
|
|
229
|
+
*/
|
|
230
|
+
append(from: number, query: RowQuery): PipelineOutput<T> | null;
|
|
231
|
+
private appendRows;
|
|
232
|
+
private stages;
|
|
233
|
+
/**
|
|
234
|
+
* Grouped rows: the grouping of the rows `mask` passes. With a group-size filter (rule
|
|
235
|
+
* B) its innermost groups are tested by their row count — the rows the other filters passed — and the grouping is
|
|
236
|
+
* built again from the rows of the groups that pass, so outer groups, counts, aggregates and order follow (an outer
|
|
237
|
+
* group without a passing group is gone). Each pass runs again only when one of its inputs changed (a new grouping,
|
|
238
|
+
* or another entry); without the filter nothing more runs, and when no group fails the base
|
|
239
|
+
* grouping is kept.
|
|
240
|
+
*/
|
|
241
|
+
private grouping;
|
|
242
|
+
/** Lets the group-size pass's grouping go: without the filter it is not held, and it runs again when it returns. */
|
|
243
|
+
private dropSized;
|
|
244
|
+
/**
|
|
245
|
+
* The data nodes of the current data version: a tree's structure is built once per data change.
|
|
246
|
+
* After a `setData` with a new array, the last version's caches are carried to them first.
|
|
247
|
+
*/
|
|
248
|
+
private prepare;
|
|
249
|
+
/**
|
|
250
|
+
* The last data version's caches carried to `nodes[0 … count − 1]` through one remap by row identity (first
|
|
251
|
+
* occurrence wins); only new nodes' rows are read, each field once for every cache. The haystacks are carried
|
|
252
|
+
* while the query searches (else they are built again when it does, as before). Nothing held: the filter
|
|
253
|
+
* caches are reset and no remap is built.
|
|
254
|
+
*/
|
|
255
|
+
private carry;
|
|
256
|
+
/**
|
|
257
|
+
* Records the data nodes the current version's caches describe, once a cache is held; extended by appended
|
|
258
|
+
* rows. The app's own array is copied: an in-place change before the next `setData` must not make another
|
|
259
|
+
* object take a cached value.
|
|
260
|
+
*/
|
|
261
|
+
private keepIdentities;
|
|
262
|
+
/**
|
|
263
|
+
* True, and counted, when an input of `stage` differs (by identity) from its last run; records the inputs before
|
|
264
|
+
* the stage runs. Stages are built not to throw (app callbacks are isolated). Should one throw anyway (an
|
|
265
|
+
* internal bug, or a row property whose getter throws), its old result would stay marked current, so `run`
|
|
266
|
+
* then forgets every recorded input and the next run computes each stage again.
|
|
267
|
+
*/
|
|
268
|
+
private due;
|
|
269
|
+
private column;
|
|
270
|
+
/**
|
|
271
|
+
* Each node's own filter result: data nodes from the mask; a filler (it has no row) by its key under the
|
|
272
|
+
* quick filter (its text) and the column filters (only entries on the tree field, with the key as the value),
|
|
273
|
+
* and never while an app predicate is set — it cannot be asked.
|
|
274
|
+
*/
|
|
275
|
+
private ownPass;
|
|
276
|
+
private output;
|
|
277
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Fields } from './fields';
|
|
2
|
+
/**
|
|
3
|
+
* Per new data node (`nodes[0 … count − 1]`): the old data node (`old[0 … oldCount − 1]`) holding the same row object,
|
|
4
|
+
* its first occurrence when the old nodes list it more than once; −1 for a row object the old nodes do not hold.
|
|
5
|
+
* One transient `Map` from row object to old node — the one per-row map allowed — dropped on return.
|
|
6
|
+
*/
|
|
7
|
+
export declare function remapNodes<T>(old: readonly T[], oldCount: number, nodes: readonly T[], count: number): Int32Array;
|
|
8
|
+
/**
|
|
9
|
+
* A new data version matched to the last one by row identity: every per-row cache — the
|
|
10
|
+
* pipeline's field columns, the column filters' value and text columns, the quick filter's haystacks — is carried
|
|
11
|
+
* through `remap`, and only the rows of new nodes (`fresh`) are read. A field the caches share is read once for them
|
|
12
|
+
* all (`values`): a new row is read once however many caches hold its field. Worker-safe: no Vue, no DOM.
|
|
13
|
+
*/
|
|
14
|
+
export declare class NodeRemap<T> {
|
|
15
|
+
/** Per new data node: the old data node of the same row object (its first occurrence), −1 = a new row. */
|
|
16
|
+
readonly remap: Int32Array;
|
|
17
|
+
/** The new data nodes, `nodes[0 … count − 1]`. */
|
|
18
|
+
readonly nodes: readonly T[];
|
|
19
|
+
readonly count: number;
|
|
20
|
+
/** The rows of the new nodes whose `remap` is −1, in node order: the only rows a carry reads. */
|
|
21
|
+
readonly fresh: readonly T[];
|
|
22
|
+
private readonly fields;
|
|
23
|
+
/** Per field: its values of the fresh rows, read on first use. */
|
|
24
|
+
private readonly read;
|
|
25
|
+
constructor(fields: Fields<T>, old: readonly T[], oldCount: number, nodes: readonly T[], count: number);
|
|
26
|
+
/** `field`'s values of the fresh rows (`Fields.column`: a throwing read is reported once, undefined), read once. */
|
|
27
|
+
values(field: string): readonly unknown[];
|
|
28
|
+
/**
|
|
29
|
+
* `old` (one entry per old node) carried to the new nodes: a kept node takes its old node's entry, a new node the
|
|
30
|
+
* next entry of `fresh` (one per fresh row, in node order).
|
|
31
|
+
*/
|
|
32
|
+
carry<V>(old: readonly V[], fresh: readonly V[]): V[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GroupKey } from '../server/contract';
|
|
2
|
+
import type { TreeOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A tree's structure, built once per data change by one of the three adapters: a parent per
|
|
5
|
+
* node, the data nodes first, then the path fillers. Filtering, order and expansion run on it unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export interface TreeShape<T> {
|
|
8
|
+
/** The input array, or (nested) the depth-first array of references. */
|
|
9
|
+
nodes: readonly T[];
|
|
10
|
+
dataCount: number;
|
|
11
|
+
/** Data nodes + fillers. */
|
|
12
|
+
nodeCount: number;
|
|
13
|
+
/** −1 top level, −2 dropped (a duplicate or empty path: in neither `count` nor `total`). */
|
|
14
|
+
parent: Int32Array;
|
|
15
|
+
/**
|
|
16
|
+
* Per node: parent-id and nested trees — `keyOf` of the row's id (nested without `id`: its position among its
|
|
17
|
+
* siblings); paths — `keyOf` of the last path element; fillers — their path element.
|
|
18
|
+
*/
|
|
19
|
+
keys: readonly GroupKey[];
|
|
20
|
+
/** Per node: data nodes themselves; a filler its smallest data descendant (its place without a sort). */
|
|
21
|
+
firstData: Int32Array;
|
|
22
|
+
/** Data nodes with parent −2. */
|
|
23
|
+
dropped: number;
|
|
24
|
+
}
|
|
25
|
+
/** What `buildTree` reports, each at most once per build (`clientSource` turns them into errors reported once). */
|
|
26
|
+
export declare const TREE_PROBLEMS: {
|
|
27
|
+
readonly noId: "a parentId tree needs the id option: every row is shown at the top level";
|
|
28
|
+
readonly missingId: "a row of a parentId tree has no id: no row can name it as its parent";
|
|
29
|
+
readonly unknownParent: "a parent id names no row: the row is shown at the top level";
|
|
30
|
+
readonly cycle: "parent ids form a cycle: it is broken at the first row that repeats, which is shown at the top level";
|
|
31
|
+
readonly duplicateId: "several rows have the same id: the first one wins, the others are shown at the top level";
|
|
32
|
+
readonly duplicatePath: "several rows have the same path: the first one wins, the others are left out";
|
|
33
|
+
readonly emptyPath: "a row has an empty path: it is left out";
|
|
34
|
+
readonly nestedCycle: "a row is listed among its own descendants: the repetition is left out";
|
|
35
|
+
readonly getter: "a tree getter threw: the row is treated as having no id, parent, path or children";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Builds the tree of `rows`. `idOf` is the source's `id` option (null without one); `report` gets each
|
|
39
|
+
* problem of `TREE_PROBLEMS` at most once per call, a throwing getter's error as the second argument.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildTree<T>(rows: readonly T[], tree: TreeOptions<T>, idOf: ((row: T) => string | number) | null, report: (problem: string, error?: unknown) => void): TreeShape<T>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ExpansionChange, FilterValues, RowInfo, RowQuery, SourceStatus, TotalRows, ValuesRequest, ViewportSource } from '../../source';
|
|
2
|
+
import type { ExpansionState, GroupKey } from '../server/contract';
|
|
3
|
+
/**
|
|
4
|
+
* Per-field data logic of a client source. A field without an entry reads `row[field]` with the
|
|
5
|
+
* defaults below. Columns name fields (`ColumnDef.field`, default the column id) and stay presentation; a computed
|
|
6
|
+
* column is a field with a `value` getter plus a column naming it.
|
|
7
|
+
*/
|
|
8
|
+
export interface FieldDef<T> {
|
|
9
|
+
/** Getter; default `row[field]`. */
|
|
10
|
+
value?: (row: T) => unknown;
|
|
11
|
+
/** Ascending order; default `compareValues` (blanks first, numbers by value, the rest by their string form). */
|
|
12
|
+
compare?: (a: unknown, b: unknown) => number;
|
|
13
|
+
/** The value's quick-filter text; default `textOf(value)`. */
|
|
14
|
+
text?: (value: unknown, row: T) => string;
|
|
15
|
+
/** Whether the quick filter searches this field (default true). */
|
|
16
|
+
quickFilter?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The value column filters and the set filter see: `filterValue(value, row)`, where `value`
|
|
19
|
+
* is the getter's value or `row[field]`; default the value itself. Never the formatted text. A throw is reported
|
|
20
|
+
* once and reads as undefined.
|
|
21
|
+
*/
|
|
22
|
+
filterValue?: (value: unknown, row: T) => unknown;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Tree data in one of three input shapes: `parentId` (a field or getter; needs the `id` option; a
|
|
26
|
+
* blank parent is a top-level row), `path` (the last element is the node's key, a missing prefix becomes a filler
|
|
27
|
+
* row) or `children` (a field or getter; the given array is the top level). `keepDescendants` (default true): a
|
|
28
|
+
* filter match keeps its whole subtree.
|
|
29
|
+
*/
|
|
30
|
+
export type TreeOptions<T> = ({
|
|
31
|
+
parentId: string | ((row: T) => unknown);
|
|
32
|
+
} | {
|
|
33
|
+
path: (row: T) => readonly unknown[];
|
|
34
|
+
} | {
|
|
35
|
+
children: string | ((row: T) => readonly T[] | null | undefined);
|
|
36
|
+
}) & {
|
|
37
|
+
keepDescendants?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Read once: a different `id`, `fields`, `aggregates`, `tree` or `filterTypes` needs a new source. */
|
|
40
|
+
export interface ClientSourceOptions<T> {
|
|
41
|
+
/** Row id: a field name or a function. Default: the row object itself (identity). */
|
|
42
|
+
id?: string | ((row: T) => string | number);
|
|
43
|
+
/** Per-field data logic; a field without an entry reads `row[field]`. */
|
|
44
|
+
fields?: Record<string, FieldDef<T>>;
|
|
45
|
+
/** Aggregate functions beside the built-in 'sum' | 'avg' | 'min' | 'max' | 'count' (a built-in name wins). */
|
|
46
|
+
aggregates?: Record<string, (values: readonly unknown[]) => unknown>;
|
|
47
|
+
/** Tree data; absent = flat rows, which can be grouped. */
|
|
48
|
+
tree?: TreeOptions<T>;
|
|
49
|
+
/**
|
|
50
|
+
* The tests of custom filter kinds: `RowQuery.filter` entries whose `kind` names one are tested with
|
|
51
|
+
* `test(entry.model, filterValue, row)`; a throwing test is reported once and lets the row pass; a kind missing
|
|
52
|
+
* here is reported once and lets every row pass. A tree's path filler has no row: it is tested (only by a filter
|
|
53
|
+
* on the tree field) with its key as the value and `row` undefined.
|
|
54
|
+
*/
|
|
55
|
+
filterTypes?: Record<string, (model: unknown, value: unknown, row: T) => boolean>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A synchronous source over the row objects an app holds. Every row is loaded: `isLoaded` is always
|
|
59
|
+
* true and `ensureLoaded(first, last, anchor?)` does nothing.
|
|
60
|
+
*/
|
|
61
|
+
export interface ClientSource<T> extends ViewportSource {
|
|
62
|
+
rowInfo(row: number, into?: RowInfo): RowInfo;
|
|
63
|
+
parentRow(row: number): number;
|
|
64
|
+
groupEnd(row: number): number;
|
|
65
|
+
setQuery(query: RowQuery): void;
|
|
66
|
+
/**
|
|
67
|
+
* The total rows to show; the grid calls it (`groupTotalRow`, `grandTotalRow`). The grand total is the
|
|
68
|
+
* first or last displayed row with the aggregates over every passing row (none while no row passes); `'pinned'`
|
|
69
|
+
* keeps it out of the display order.
|
|
70
|
+
*/
|
|
71
|
+
setTotalRows(totals: TotalRows | null): void;
|
|
72
|
+
setExpanded(row: number, expanded: boolean, options?: {
|
|
73
|
+
all?: boolean;
|
|
74
|
+
source?: 'ui' | 'api';
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* Replaces the rows; the displayed order is diffed by id into splices. A row object passed again
|
|
78
|
+
* counts as unchanged: its sort keys, group and aggregate values, filter values and
|
|
79
|
+
* quick-filter text are reused, only new row objects are read. A row changed in place needs `refresh()`.
|
|
80
|
+
*
|
|
81
|
+
* `{ hold: true }` — a held update, for new values of the rows shown (an edit's answer from a backend),
|
|
82
|
+
* not for a load: `rows` are the rows the source holds, the same ids in the same order, as new objects (or the same
|
|
83
|
+
* array, its rows changed in place). Each row keeps its place and stays shown whatever its new values say, as after
|
|
84
|
+
* a write (`writeCell`): nothing is sorted, filtered or grouped again until the next query change, `setFilter`,
|
|
85
|
+
* `setData` or `refresh()`; cells, classes and computed row heights follow the new objects, the group aggregates
|
|
86
|
+
* and the grand total too, the selection, the focus and the expansion stay. A shown row that no longer passes the
|
|
87
|
+
* filters is marked (`RowInfo.unmatched`) and counted (`unmatched`); `refresh()` re-applies. Needs the `id` option
|
|
88
|
+
* and rows that are no tree (one hint otherwise); with another row count or an id that differs the rows are set as
|
|
89
|
+
* without `hold`.
|
|
90
|
+
*/
|
|
91
|
+
setData(rows: readonly T[], options?: {
|
|
92
|
+
hold?: boolean;
|
|
93
|
+
}): void;
|
|
94
|
+
/**
|
|
95
|
+
* After rows were changed in place: `setData` with the same array. `{ appended: n }`: the app
|
|
96
|
+
* only pushed `n` new rows onto the end of that array; no other row changed (not its values, not its place). Flat
|
|
97
|
+
* rows (sorted, filtered, quick filter) then take an incremental path: only the new rows are read, sorted in and
|
|
98
|
+
* tested, and they are announced as insertions. Grouped rows and trees refresh fully. A count that does not
|
|
99
|
+
* match the rows added is reported once and refreshes fully; a changed old row is the app's error (it is not
|
|
100
|
+
* read again).
|
|
101
|
+
*/
|
|
102
|
+
refresh(options?: {
|
|
103
|
+
appended?: number;
|
|
104
|
+
}): void;
|
|
105
|
+
/** The app's own filter, ANDed with the quick filter; null removes it. */
|
|
106
|
+
setFilter(predicate: ((row: T) => boolean) | null): void;
|
|
107
|
+
/**
|
|
108
|
+
* Value writes: `write` gets the row object of a displayed data row (not a group row, a
|
|
109
|
+
* filler or a tree parent's aggregated field); a `plain` write into a field with a `FieldDef.value` getter is
|
|
110
|
+
* refused. A write that happened drops the row's cached keys (sort, filters, quick-filter text, group key);
|
|
111
|
+
* the rows are sorted, filtered and grouped again only by the next query change, `setFilter`, `setData` or
|
|
112
|
+
* `refresh` — nothing runs, nothing is announced now.
|
|
113
|
+
*/
|
|
114
|
+
writeCell(row: number, field: string, write: (data: object) => boolean, plain: boolean): boolean;
|
|
115
|
+
/** The row object of a displayed row; undefined for group rows and fillers. */
|
|
116
|
+
data(row: number): T | undefined;
|
|
117
|
+
/** The `id` option's value of a displayed row; null for group rows, fillers, or without `id`. */
|
|
118
|
+
idOf(row: number): string | number | null;
|
|
119
|
+
/**
|
|
120
|
+
* A displayed row's index in the rows array the source last read (creation, `setData`, `refresh`), whatever the
|
|
121
|
+
* sort, filters and grouping; −1 for group rows, fillers and rows out of range. A nested tree counts its
|
|
122
|
+
* rows depth-first, as `total` does. New data, appended rows and a managed row drag re-index.
|
|
123
|
+
*/
|
|
124
|
+
sourceIndexOf(row: number): number;
|
|
125
|
+
/** Displayed index of a row (by id, or by the row object); −1 when unknown, filtered out or inside a collapsed parent. */
|
|
126
|
+
rowOf(key: string | number | T): number;
|
|
127
|
+
/** Expands the row's ancestors, then `rowOf(key)`. */
|
|
128
|
+
reveal(key: string | number | T): number;
|
|
129
|
+
/** Every passing data row, sorted, as if everything were expanded. */
|
|
130
|
+
filteredRows(): T[];
|
|
131
|
+
/** Data rows passing the filters (= `filteredRows().length`). */
|
|
132
|
+
readonly count: number;
|
|
133
|
+
/** All data rows (tree: every data node; rows a tree drops count in neither). */
|
|
134
|
+
readonly total: number;
|
|
135
|
+
/**
|
|
136
|
+
* Data rows of the view (`count` holds them) whose values no longer pass the quick filter, the column filters or
|
|
137
|
+
* the `setFilter` predicate: they stay where they are after a held update (`setData(rows, { hold: true
|
|
138
|
+
* })`) or a write until the filters run again — the next query change, `setFilter`, `setData` or `refresh()`.
|
|
139
|
+
* `RowInfo.unmatched` marks each; `onChange` tells a change (after writes once per task). Always 0 in a tree.
|
|
140
|
+
*/
|
|
141
|
+
readonly unmatched: number;
|
|
142
|
+
expand(path: readonly GroupKey[]): void;
|
|
143
|
+
collapse(path: readonly GroupKey[]): void;
|
|
144
|
+
isExpanded(path: readonly GroupKey[]): boolean;
|
|
145
|
+
expandAll(): void;
|
|
146
|
+
collapseAll(): void;
|
|
147
|
+
/** Keys of the row's ancestors, plus its own key when it has one (group rows, tree rows). */
|
|
148
|
+
pathOf(row: number): GroupKey[];
|
|
149
|
+
getExpansion(): ExpansionState;
|
|
150
|
+
setExpansion(state: ExpansionState): void;
|
|
151
|
+
onExpansionChange(listener: (change: ExpansionChange) => void): () => void;
|
|
152
|
+
/**
|
|
153
|
+
* After data, filters or the query changed the rows or the counts: once per run, after the grid's changes; also
|
|
154
|
+
* after writes that changed `unmatched` (once per task).
|
|
155
|
+
*/
|
|
156
|
+
onChange(listener: () => void): () => void;
|
|
157
|
+
/**
|
|
158
|
+
* A set filter's values, synchronously: the distinct filter values of `request.field` over
|
|
159
|
+
* the data rows passing `request.filter`, `request.quickFilter` and the app predicate (a tree's rows by their own
|
|
160
|
+
* pass; grouped rows' leaves), blanks first, then by `FieldDef.compare` (else `compareValues`), case variants
|
|
161
|
+
* apart, with counts when asked. `search` and `limit` are ignored: the list is complete and the UI searches its
|
|
162
|
+
* labels. Cached per field until the data, the predicate or the request changes; do not change the result.
|
|
163
|
+
*/
|
|
164
|
+
filterValues(request: ValuesRequest): FilterValues;
|
|
165
|
+
/** Not remote; grouping offered unless the source holds a tree; `total` and `count`. */
|
|
166
|
+
status(): SourceStatus;
|
|
167
|
+
destroy(): void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* How the pipeline reports an app callback that threw or a data problem: `clientSource` binds it to
|
|
171
|
+
* `reportErrorOnce(source, key, error)`. Pipeline functions call it at most once per key and call.
|
|
172
|
+
*/
|
|
173
|
+
export type Reporter = (key: string, error: unknown) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MemoryTable } from './memoryDatasource';
|
|
2
|
+
/** A demo table (playground, tests): id, country, city, category, name, amount, quantity, date; deterministic per seed. */
|
|
3
|
+
export declare function generateTable(rows: number, options?: {
|
|
4
|
+
seed?: number;
|
|
5
|
+
}): MemoryTable;
|
|
6
|
+
/** Benchmark data: `groups` × `subgroups` groups of `rowsPerSubgroup` leaves, ordered by g1, then g2. */
|
|
7
|
+
export declare function generateGroupedTable(groups: number, subgroups: number, rowsPerSubgroup: number): MemoryTable;
|
|
8
|
+
/** A tree (playground "Tree" page): `fanout` children per folder, `depth` levels; files are the last level. */
|
|
9
|
+
export declare function generateTree(options?: {
|
|
10
|
+
depth?: number;
|
|
11
|
+
fanout?: number;
|
|
12
|
+
seed?: number;
|
|
13
|
+
}): MemoryTable;
|
|
14
|
+
/**
|
|
15
|
+
* Demo row objects (playground, benchmarks, tests): typical business records, deterministic per seed. The 20 fields
|
|
16
|
+
* mix the value types client data meets: `id` (1…n), `code` ('P-004711'), `name`, `country` and `city` (a matching
|
|
17
|
+
* pair), `category`, `status`, `amount`, `quantity`, `weight` (a number stored as text, '12.50'), `ref` (digits with
|
|
18
|
+
* leading zeros), `created` (an ISO date), `updated` (epoch ms), `flags` (bits: 1 = error, 2 = warning, 8 = locked;
|
|
19
|
+
* 4 is left to the app), `active`, `priority` (1–5), `owner`, `unit`, `note` (free text, sometimes '') and `score`
|
|
20
|
+
* (sometimes null). `fields` below 20 keeps the first fields (at least `id`); above 20 adds numbers x20, x21, ….
|
|
21
|
+
* A row costs its object and two strings (`code`, `ref`); the other strings are shared.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateRecords(rows: number, options?: {
|
|
24
|
+
seed?: number;
|
|
25
|
+
fields?: number;
|
|
26
|
+
}): Record<string, unknown>[];
|
|
27
|
+
/**
|
|
28
|
+
* `generateTree`'s tree as row objects `{ id, parent, name, kind, size }` (for `clientSource(rows, { id: 'id', tree:
|
|
29
|
+
* { parentId: 'parent' } })`), in the same depth-first order: every parent comes before its children, so any prefix
|
|
30
|
+
* of the array is a well-formed tree.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateRecordTree(options?: {
|
|
33
|
+
depth?: number;
|
|
34
|
+
fanout?: number;
|
|
35
|
+
seed?: number;
|
|
36
|
+
}): Record<string, unknown>[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type FilterValues, type ValuesRequest } from '../../source';
|
|
2
|
+
import type { RowsRequest, ServerDatasource } from '../server/contract';
|
|
3
|
+
/** Columnar in-memory data: field → values, all of the same length. */
|
|
4
|
+
export interface MemoryTable {
|
|
5
|
+
columns: Record<string, ArrayLike<unknown>>;
|
|
6
|
+
}
|
|
7
|
+
export interface MemoryDatasourceOptions {
|
|
8
|
+
/** Delay per request (ms). */
|
|
9
|
+
latencyMs?: number;
|
|
10
|
+
/** Extra random delay up to this many ms (seeded). */
|
|
11
|
+
jitterMs?: number;
|
|
12
|
+
/** Share of requests that fail (seeded), 0…1. */
|
|
13
|
+
failRate?: number;
|
|
14
|
+
seed?: number;
|
|
15
|
+
/** Leaf rows carry `ids` from this field (e.g. the original file row). */
|
|
16
|
+
idField?: string;
|
|
17
|
+
/** Tree mode: rows linked by id and parent id; a blank parent is a top-level row. */
|
|
18
|
+
tree?: {
|
|
19
|
+
idField: string;
|
|
20
|
+
parentField: string;
|
|
21
|
+
};
|
|
22
|
+
/** Custom filter kinds' tests, as `ClientSourceOptions.filterTypes`; `row` is the table row index. */
|
|
23
|
+
filterTypes?: Record<string, (model: unknown, value: unknown, row: number) => boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Applies an `ig:group` entry to the groups of every level: a group that fails is left out of its level, while its
|
|
26
|
+
* parent's child count and aggregates stay as computed, as an SQL `HAVING` on the child query behaves.
|
|
27
|
+
*/
|
|
28
|
+
groupFilter?: (model: unknown, group: {
|
|
29
|
+
level: number;
|
|
30
|
+
childCount: number;
|
|
31
|
+
}) => boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface MemoryDatasource extends ServerDatasource {
|
|
34
|
+
/** Every request received, without its signal (tests, the playground's request log); `quickFilter` and `filter` only when sent. */
|
|
35
|
+
readonly log: readonly Omit<RowsRequest, 'signal'>[];
|
|
36
|
+
/** Distinct values of a field among the rows passing the request's filters. */
|
|
37
|
+
getValues(request: ValuesRequest): Promise<FilterValues>;
|
|
38
|
+
clearLog(): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The reference implementation of the server contract over in-memory data: grouping with exact totals
|
|
42
|
+
* and child counts, typed sorting incl. the group order, aggregation, the quick filter on flat and grouped data,
|
|
43
|
+
* trees from id / parent fields; optional latency, jitter and failures. Each level of a query is
|
|
44
|
+
* computed once and cached until the query changes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function memoryDatasource(table: MemoryTable, options?: MemoryDatasourceOptions): MemoryDatasource;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RowInfo, type ViewportSource } from '../source';
|
|
2
|
+
/**
|
|
3
|
+
* The row's `rowInfo().id` (a server group row's prefixed with U+0000), else the client source's identity (a leaf's
|
|
4
|
+
* row object or id, a group row's or filler's path key; a group's total row its group's path key marked as
|
|
5
|
+
* a total, the grand total a constant — total rows have no id), else null: out of range, a server row not loaded or
|
|
6
|
+
* without an id, a custom source without ids. `info`: the row's info when the caller has read it (`null` = the source
|
|
7
|
+
* has none).
|
|
8
|
+
*/
|
|
9
|
+
export declare function rowKey(source: ViewportSource, row: number, info?: RowInfo | null): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* The key `rowKey` gives a client source's row, by its node (`ClientInternals.identityOfNode`; a total row's too):
|
|
12
|
+
* also while the row is inside a closed group, so find's active match keeps it while the app opens and closes
|
|
13
|
+
* groups. Null for any other source or a node out of range.
|
|
14
|
+
*/
|
|
15
|
+
export declare function nodeKey(source: ViewportSource, node: number): unknown;
|