@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,34 @@
|
|
|
1
|
+
import type { ColumnDefaults, ColumnNode, GridOptions, GroupColumnOptions, RowDragOptions, RowDropPositions } from '../types';
|
|
2
|
+
/** Default width of the handle column `ig:row-drag`. */
|
|
3
|
+
export declare const HANDLE_WIDTH = 28;
|
|
4
|
+
/** `GridOptions.rowDrag` after defaults. */
|
|
5
|
+
export interface ResolvedRowDrag {
|
|
6
|
+
handle: 'column' | 'cells' | 'row';
|
|
7
|
+
handleWidth: number;
|
|
8
|
+
multiple: boolean;
|
|
9
|
+
reorder: boolean;
|
|
10
|
+
/** Drops on the grid's own rows; `reorder` makes it `'between'`. */
|
|
11
|
+
drop: RowDropPositions | false;
|
|
12
|
+
draggable: RowDragOptions['draggable'];
|
|
13
|
+
label: RowDragOptions['label'];
|
|
14
|
+
canDrop: RowDragOptions['canDrop'];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the option: `false` / `undefined` → null (off), `true` → `{}`. `dragColumns`: some column sets
|
|
18
|
+
* `ColumnDef.rowDrag` (the default handle is then `'cells'`); `server`: the source is a server source (no managed
|
|
19
|
+
* reorder). Contradictions give one hint each through `warn(key, message)` and resolve as the hint says.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveRowDrag(option: GridOptions['rowDrag'], ctx: {
|
|
22
|
+
dragColumns: boolean;
|
|
23
|
+
server: boolean;
|
|
24
|
+
}, warn: (key: string, message: string) => void): ResolvedRowDrag | null;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a change needs a running drag cancelled: the handle, the drop positions, `reorder` or `multiple`. New
|
|
27
|
+
* `label` / `draggable` / `canDrop` functions or a new width apply from their next call.
|
|
28
|
+
*/
|
|
29
|
+
export declare function structuralChange(a: ResolvedRowDrag | null, b: ResolvedRowDrag | null): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Some column (or the defaults, or the group column's options) sets `rowDrag`: the default handle
|
|
32
|
+
* becomes `'cells'`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function hasDragColumns(nodes: readonly ColumnNode[], defaults?: ColumnDefaults, group?: GroupColumnOptions): boolean;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { GridTexts } from '../i18n/texts';
|
|
2
|
+
import type { RowSelectionModel } from '../selection/rows';
|
|
3
|
+
import { type SourceChange, type ViewportSource } from '../source';
|
|
4
|
+
import type { DraggedRows, RowDragOptions, RowDragOver, RowId } from '../types';
|
|
5
|
+
/** The source and selection a drag reads. */
|
|
6
|
+
export interface DragSourceView {
|
|
7
|
+
source: ViewportSource;
|
|
8
|
+
selection: RowSelectionModel | null;
|
|
9
|
+
/** `groupSelects !== 'self'`: only leaves are taken, as a copy of the selection takes them. */
|
|
10
|
+
leavesOnly: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The row can be dragged (the controller's `gripState` 'on': loaded, a data row, `draggable`): selected rows it
|
|
13
|
+
* refuses stay behind. Left out: every loaded data row.
|
|
14
|
+
*/
|
|
15
|
+
draggable?: (row: number) => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A loaded data row: not loading or failed, not a client group row or a tree filler, not a total row.
|
|
19
|
+
*/
|
|
20
|
+
export declare function canDragRow(source: ViewportSource, row: number): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* What a total row is to a drag — `'grand'` for the grand total (the first or last display row: the far
|
|
23
|
+
* side of it is no gap between rows), `'group'` for a group's total row, null for any other row (or out of range). No
|
|
24
|
+
* grip, never an `on` target.
|
|
25
|
+
*/
|
|
26
|
+
export declare function totalOf(source: ViewportSource, row: number): 'grand' | 'group' | null;
|
|
27
|
+
/**
|
|
28
|
+
* The displayed selected rows in display order (under `groupSelects: 'descendants'` the displayed leaves), as a copy
|
|
29
|
+
* takes them; only loaded data rows that `view.draggable` allows. A client source is read
|
|
30
|
+
* through the model's keys (the selected rows, not every row), a server source over its loaded rows, any other source
|
|
31
|
+
* by a scan.
|
|
32
|
+
*/
|
|
33
|
+
export declare function selectedDisplayRows(view: DragSourceView): number[];
|
|
34
|
+
/**
|
|
35
|
+
* What a press on `pressed` drags: that row, or with `multiple` and the pressed row selected the displayed
|
|
36
|
+
* selected rows that can be dragged — `draggable` refusing a selected row leaves it behind; the pressed row is always
|
|
37
|
+
* dragged, as no press starts on a row that cannot be — (`selection` then the model's state at the press;
|
|
38
|
+
* `count` the model's own for a server select-all). A drag never changes the selection.
|
|
39
|
+
*/
|
|
40
|
+
export declare function draggedRowsOf(view: DragSourceView, pressed: number, multiple: boolean): DraggedRows;
|
|
41
|
+
/**
|
|
42
|
+
* The ghost's text: `label(rows, over)` when given (`over`: the drag's target now); else `text(row)` for one row, the
|
|
43
|
+
* texts' "3 rows" for several, "Selected rows" for a select-all of unknown size. A `label` that throws (or returns no
|
|
44
|
+
* string) is passed to `report` and the default is used.
|
|
45
|
+
*/
|
|
46
|
+
export declare function dragLabel(rows: DraggedRows, label: RowDragOptions['label'], text: (row: number) => string, texts: GridTexts, formatCount: (n: number) => string, report: (error: unknown) => void, over?: RowDragOver | null): string;
|
|
47
|
+
/**
|
|
48
|
+
* Where dragged (or pressed) rows are after a change of their source: `rows` ascending display
|
|
49
|
+
* indexes with their `ids`. A splice moves them as `model.ts`'s `remapRows` does (a client source announces its identity
|
|
50
|
+
* diff as splices, so this follows client rows by object); a count change drops rows past the end; a `rows` change moves
|
|
51
|
+
* nothing; a reset loses them all. On a server source rows are followed by id: a loaded row whose id is no longer the
|
|
52
|
+
* dragged one has left. A server row without an id cannot be followed, so a change that may have moved it — a splice, a
|
|
53
|
+
* count change, a block reloaded over it — loses the drag. Returns each row's new index (−1: it left), or null: cancel.
|
|
54
|
+
*/
|
|
55
|
+
export declare function followRows(source: ViewportSource, rows: readonly number[], ids: readonly (RowId | null)[], change: SourceChange): number[] | null;
|
|
56
|
+
/**
|
|
57
|
+
* The dragged rows after a source change: the same object when nothing moved, a new one with the rows that are
|
|
58
|
+
* left (`row` the pressed row's new index, else the first row left; `count` less the rows that left), or null when the
|
|
59
|
+
* drag cannot follow or no row is left — the drag is cancelled.
|
|
60
|
+
*/
|
|
61
|
+
export declare function followDragged(source: ViewportSource, dragged: DraggedRows, change: SourceChange): DraggedRows | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { InteractHost } from '../interact/host';
|
|
2
|
+
import type { DraggedRows, Grid, RowDragOptions, RowDragOver, RowDrop, RowDropPositions, RowDropZone } from '../types';
|
|
3
|
+
import type { RowDragEvents } from './events';
|
|
4
|
+
/** A running drag as a drop side sees it. */
|
|
5
|
+
export interface DragInfo {
|
|
6
|
+
rows: DraggedRows;
|
|
7
|
+
from: Grid;
|
|
8
|
+
/** The rows are this side's grid's own: the no-op rule applies. */
|
|
9
|
+
own: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface DropSide {
|
|
12
|
+
readonly grid: Grid;
|
|
13
|
+
/** `el` (the hit element) is in the grid's header, body or status bar; not its side bar or group panel. */
|
|
14
|
+
covers(el: Element): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Aims at the client point (x, y) — the zone `zone` (null: the source's own rows) — and marks the target. Returns the
|
|
17
|
+
* same object while grid, zone, row, position and allowed stay (no object per call), a new one when one changed.
|
|
18
|
+
* `canDrop` is asked once per target, its answer cached. Reads the rows area once; `scroll` reuses it.
|
|
19
|
+
*/
|
|
20
|
+
aim(x: number, y: number, drag: DragInfo, zone: RowDropZone | null): RowDragOver;
|
|
21
|
+
/** One auto-scroll frame (the edge band; past it over the header and status bar), after `aim` in the same frame. */
|
|
22
|
+
scroll(x: number, y: number): void;
|
|
23
|
+
/** The drag left the grid, ended or was cancelled: the mark goes. */
|
|
24
|
+
leave(): void;
|
|
25
|
+
/**
|
|
26
|
+
* The grid draws a pending pass now (`InteractHost.flushPass`): called by the drag's frame callback after its aim, so
|
|
27
|
+
* a changed mark shows in the frame that aimed it, not one frame behind the ghost. Nothing when none is pending.
|
|
28
|
+
*/
|
|
29
|
+
flush(): void;
|
|
30
|
+
/**
|
|
31
|
+
* An accepted drop — a release, or the keyboard twin's step — and `onRowDrop` on this grid. Its own rows
|
|
32
|
+
* with `reorder` in array order move first: focus follows a moved focused row by key, and the event has
|
|
33
|
+
* `moved` and `order`; its own rows dropped between rows and not moved leave it to the app, and focus follows the
|
|
34
|
+
* focused row once the app's change shows it where the drop put it. True when the rows moved (the caller says
|
|
35
|
+
* "Moved", else "Dropped").
|
|
36
|
+
*/
|
|
37
|
+
drop(drag: DragInfo, over: RowDragOver, source: RowDrop['source']): boolean;
|
|
38
|
+
/** The grid's source changed: the `canDrop` answers go, and the same place may hold another row. */
|
|
39
|
+
sourceChanged(): void;
|
|
40
|
+
/**
|
|
41
|
+
* The grid's `settle` after a batch of source changes, before the batch's focus 'data' change: a pending follow
|
|
42
|
+
* puts the focus on its row when the app's change shows that row where the drop put it, else is dropped.
|
|
43
|
+
*/
|
|
44
|
+
settled(): void;
|
|
45
|
+
/** A `FocusChange` other than 'data' went out (the user or the app moved focus): a pending follow is dropped. */
|
|
46
|
+
focusMoved(): void;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What a drop side takes drops by: the grid's own `rowDrag.drop` / `canDrop` (zone null or left out), or the options of
|
|
51
|
+
* the grid zone aimed through.
|
|
52
|
+
*/
|
|
53
|
+
export interface DropSideOptions {
|
|
54
|
+
positions: RowDropPositions | false;
|
|
55
|
+
canDrop: RowDragOptions['canDrop'];
|
|
56
|
+
/** The grid's own `rowDrag.reorder`: a drop of its own rows moves them while the view is in array order. */
|
|
57
|
+
reorder?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare function createDropSide(host: InteractHost, options: (zone?: RowDropZone | null) => DropSideOptions, events: RowDragEvents): DropSide;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ElementDropZone, Grid, GridDropZoneOptions, RowDragOver, RowDropPositions, RowDropZone, ZoneDragEvent } from '../types';
|
|
2
|
+
import type { DropSide } from './target';
|
|
3
|
+
/** One entry of a source grid's zone list. */
|
|
4
|
+
export interface SourceZone {
|
|
5
|
+
/** The element the lookup finds it by: a grid's root, an element zone's element. */
|
|
6
|
+
anchor: Element;
|
|
7
|
+
/**
|
|
8
|
+
* The hit element `top` (inside `anchor`) is over the zone: a grid's header, body or status bar — not its side bar
|
|
9
|
+
* or group panel; an element zone covers all of its element.
|
|
10
|
+
*/
|
|
11
|
+
covers(top: Element): boolean;
|
|
12
|
+
/** Null: the source grid's own rows (`rowDrag.drop`). */
|
|
13
|
+
zone: RowDropZone | ElementDropZone | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The innermost zone over `top`, the topmost element at the pointer: the first ancestor-or-self that anchors a
|
|
17
|
+
* zone covering `top`. A grid whose root is found but whose header, body or status bar `top` is not in (its side bar,
|
|
18
|
+
* say) does not match, and the walk goes on to the zones around it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findZone(top: Element | null, zones: ReadonlyMap<Element, SourceZone>): SourceZone | null;
|
|
21
|
+
/**
|
|
22
|
+
* A target grid as its zones share it (one per grid, made by its controller with its first `rowDropZone`): its drop
|
|
23
|
+
* side, its root (the zones' anchor), and the sources whose lists hold one of its zones — told when the grid is
|
|
24
|
+
* destroyed, so each drops the zone at once and its lock follows.
|
|
25
|
+
*/
|
|
26
|
+
export interface ZoneTarget {
|
|
27
|
+
readonly side: DropSide;
|
|
28
|
+
readonly anchor: Element;
|
|
29
|
+
gone: boolean;
|
|
30
|
+
readonly sources: Set<() => void>;
|
|
31
|
+
}
|
|
32
|
+
/** A grid zone as the registry holds it: its target and its resolved options (what the target's side aims by). */
|
|
33
|
+
export interface GridZone {
|
|
34
|
+
readonly target: ZoneTarget;
|
|
35
|
+
readonly side: DropSide;
|
|
36
|
+
readonly positions: RowDropPositions;
|
|
37
|
+
readonly canDrop: GridDropZoneOptions['canDrop'];
|
|
38
|
+
}
|
|
39
|
+
/** A target grid's new zone (`Grid.rowDropZone`): a frozen `{ grid }`, registered with its target and options. */
|
|
40
|
+
export declare function makeGridZone(target: ZoneTarget, options?: GridDropZoneOptions): RowDropZone;
|
|
41
|
+
/** A destroyed grid's zone: frozen, dead on arrival (no source takes it, no hint either). */
|
|
42
|
+
export declare function deadGridZone(grid: Grid): RowDropZone;
|
|
43
|
+
/** A zone some `rowDropZone` made (also a destroyed grid's): anything else is a hand-built object or another copy's. */
|
|
44
|
+
export declare function isKnownZone(zone: RowDropZone): boolean;
|
|
45
|
+
/** A target grid was destroyed: its zones go dead, and every source holding one drops it. */
|
|
46
|
+
export declare function targetGone(target: ZoneTarget): void;
|
|
47
|
+
/**
|
|
48
|
+
* The drop side a grid zone aims through, with the zone's positions and `canDrop`; null for an element zone, an
|
|
49
|
+
* object no `rowDropZone` made, and a zone whose grid is destroyed. The registry's own entry: no object per call.
|
|
50
|
+
*/
|
|
51
|
+
export declare function dropSideOf(zone: RowDropZone | ElementDropZone): GridZone | null;
|
|
52
|
+
/** An element zone: an object with an `element`, as against the opaque `{ grid }` a `rowDropZone` made. */
|
|
53
|
+
export declare function isElementZone(zone: RowDropZone | ElementDropZone | null): zone is ElementDropZone;
|
|
54
|
+
/**
|
|
55
|
+
* What one drag hears of the element zones, kept by the gesture: the zone the pointer is in, whether it takes
|
|
56
|
+
* the drag (`canDrop`, asked once per enter and kept while the pointer stays), the `RowDragOver` it reports (one object
|
|
57
|
+
* per enter, so a still pointer reports no change) and whether the pointer moved since the last `onMove`. A zone that
|
|
58
|
+
* refuses hears nothing at all.
|
|
59
|
+
*/
|
|
60
|
+
export interface ElementHearing {
|
|
61
|
+
zone: ElementDropZone | null;
|
|
62
|
+
heard: boolean;
|
|
63
|
+
over: RowDragOver | null;
|
|
64
|
+
moved: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare function elementHearing(): ElementHearing;
|
|
67
|
+
/**
|
|
68
|
+
* One aim at an element zone (or none: `zone` null): the pointer left the zone it was in (`onLeave`), entered this one
|
|
69
|
+
* (`canDrop`, then `onEnter`), moved in it (`onMove`, at most once per frame: the gesture aims once per frame; not at
|
|
70
|
+
* the release's aim, which is no step). Returns what `onRowDragMove` reports: the zone's over, null for none.
|
|
71
|
+
*/
|
|
72
|
+
export declare function aimElement(h: ElementHearing, zone: ElementDropZone | null, e: ZoneDragEvent, final: boolean): RowDragOver | null;
|
|
73
|
+
/** The pointer leaves the zone it was in, or the drag ends elsewhere: `onLeave` when the zone took the drag. */
|
|
74
|
+
export declare function leaveElement(h: ElementHearing, e: ZoneDragEvent | null): void;
|
|
75
|
+
/** The accepted release: the zone to call `onDrop` on (after the ghost goes), the hearing cleared; null: none. */
|
|
76
|
+
export declare function takeElement(h: ElementHearing): ElementDropZone | null;
|
|
77
|
+
export declare function dropElement(zone: ElementDropZone, e: ZoneDragEvent): void;
|
|
78
|
+
/** Forgets the zone with no callback (a destroyed grid delivers nothing). */
|
|
79
|
+
export declare function forget(h: ElementHearing): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Passes `catchUp()` may add between a frame's pass and its paint; a longer cascade goes on in the next frame. */
|
|
2
|
+
export declare const MAX_LATE_PASSES = 4;
|
|
3
|
+
export interface FrameScheduler {
|
|
4
|
+
/** Ensures `pass` runs once in the next animation frame. */
|
|
5
|
+
request(): void;
|
|
6
|
+
/**
|
|
7
|
+
* For changes that arrived after a pass whose frame is not painted yet (a source answering within microtasks):
|
|
8
|
+
* runs `pass` again at once, so that paint shows them, at most MAX_LATE_PASSES times per frame. Otherwise (no pass
|
|
9
|
+
* since the last paint, inside a pass, or past the limit) the same as `request()`.
|
|
10
|
+
*/
|
|
11
|
+
catchUp(): void;
|
|
12
|
+
/** Runs `pass` synchronously if a frame is pending (for synchronous APIs such as scrollToRow). */
|
|
13
|
+
flush(): void;
|
|
14
|
+
/** Queues work that runs after the pass within the frame budget (at least one task per frame). */
|
|
15
|
+
defer(task: () => void): void;
|
|
16
|
+
readonly pending: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One render pass per animation frame plus a budgeted queue for deferred work.
|
|
20
|
+
* Must be created inside an effect scope: disposing the scope stops the scheduler for good.
|
|
21
|
+
*
|
|
22
|
+
* `paintTargets` (two elements the caller owns) tell `catchUp()` when a drawn frame is about to be painted: the
|
|
23
|
+
* second is observed again after every pass, so its ResizeObserver notification arrives in that frame's ResizeObserver
|
|
24
|
+
* step, after layout and before paint; the first stays observed, so the observer keeps its place among the document's
|
|
25
|
+
* observers (WebKit drops an observer without observations from its list and appends it again on the next observe).
|
|
26
|
+
* Without them, or when no rendering step follows (a `flush()` between frames), a message posted after the pass ends
|
|
27
|
+
* the window: a later task (in WebKit it may come after timers that are already due).
|
|
28
|
+
*/
|
|
29
|
+
export declare function createFrameScheduler(pass: () => void, budgetMs?: number, paintTargets?: readonly [Element, Element]): FrameScheduler;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UnionBand } from './ranges';
|
|
2
|
+
export interface AggregateResult {
|
|
3
|
+
count: number;
|
|
4
|
+
numbers: number;
|
|
5
|
+
sum: number | bigint;
|
|
6
|
+
min: number | bigint | null;
|
|
7
|
+
max: number | bigint | null;
|
|
8
|
+
avg: number | bigint | null;
|
|
9
|
+
/** Cells of rows that were not loaded were left out (a server source: the numbers are of loaded rows). */
|
|
10
|
+
partial: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Which rows of the union have values. `rows: null`: every row is asked (`isLoaded`); otherwise only the listed rows,
|
|
14
|
+
* ascending — a server source's block cache (only loaded rows count) —, each asked again, since a block may have
|
|
15
|
+
* been evicted after the list was made. The rows of a band not listed are counted as skipped in one step.
|
|
16
|
+
*/
|
|
17
|
+
export interface LoadedRows {
|
|
18
|
+
rows: ArrayLike<number> | null;
|
|
19
|
+
isLoaded(row: number): boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The numbers over the union's cells (`RangeModel.unionBands`, each cell once): `count` is every cell of a loaded row;
|
|
23
|
+
* `numbers` the cells that are numbers or bigints (with `'text'` also plain decimal strings). `value(row, id)` reads a
|
|
24
|
+
* cell, `ids` maps display indexes to column ids. Rows `loaded` says have no values are skipped — the listed form costs
|
|
25
|
+
* nothing per unloaded row — and make the result `partial`. A pinned section's band is read with its
|
|
26
|
+
* `pinned` and always has values (the app's objects): `loaded` speaks of body rows. Plain loops, a yield after about
|
|
27
|
+
* every 4,096 cells, loaded or not (a 5M-row server union over a cache of a few thousand rows would otherwise be one
|
|
28
|
+
* slice).
|
|
29
|
+
*/
|
|
30
|
+
export declare function aggregateUnion(bands: readonly UnionBand[], ids: readonly string[], value: (row: number, id: string, pinned?: 'top' | 'bottom') => unknown, loaded: LoadedRows, numbers: 'values' | 'text'): Generator<void, AggregateResult>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CellSelectionOptions } from '../types';
|
|
2
|
+
export type ResolvedCellSelection = Required<CellSelectionOptions>;
|
|
3
|
+
/**
|
|
4
|
+
* `cellSelection: true` is `{}`; false, null and undefined switch cell selection off (null). `rowFocus` (`cellFocus:
|
|
5
|
+
* 'row'`): cell selection works as `unit: 'row'` whatever the option says.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCellSelection(option: boolean | CellSelectionOptions | null | undefined, rowFocus?: boolean): ResolvedCellSelection | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ViewportSource } from '../source';
|
|
2
|
+
import type { TableHost } from '../table/host';
|
|
3
|
+
/**
|
|
4
|
+
* The data rows of the ranges' union (every range column, whatever the export's column filter): a grouped or tree view
|
|
5
|
+
* its expanded order's spans, a flat client view the display rows; `[]` for a server or custom source, without ranges
|
|
6
|
+
* or while cell selection is off. A one-cell range counts. Group rows and total rows are no data rows: no
|
|
7
|
+
* data node, no row object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rangeRows(host: TableHost, source: ViewportSource): unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* `rangeRows` on every source. A server source's rows are read by the same rule: each range from its first
|
|
12
|
+
* row to the end of the outermost open group it holds (`subtreeEnd`), closed groups' rows through the datasource
|
|
13
|
+
* (`readRows` with `all`, as the ranges export reads them); each data row once in display order, a plain object of
|
|
14
|
+
* the columns' fields (`rowFields`). Group rows are not rows; a tree parent is. A client source gives `rangeRows`, a
|
|
15
|
+
* custom source `[]`. Rejects with an `AbortError` when `signal` aborts or a read was cancelled (a new generation, rows
|
|
16
|
+
* spliced above it) or its rows moved while it ran (an opened level let through: the ranges' rows can't be found
|
|
17
|
+
* again, as the export's); with the datasource's error when a request fails.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readRangeRows(host: TableHost, signal: AbortSignal): Promise<unknown[]>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { CellAddress, CellRange } from '../types';
|
|
2
|
+
type Side = 'top' | 'bottom';
|
|
3
|
+
/** The range columns in display order (no row-number / selection column). */
|
|
4
|
+
export interface RangeColumns {
|
|
5
|
+
ids: readonly string[];
|
|
6
|
+
indexOf(id: string): number;
|
|
7
|
+
}
|
|
8
|
+
export interface RangeModel {
|
|
9
|
+
readonly version: number;
|
|
10
|
+
ranges(): CellRange[];
|
|
11
|
+
active(): CellRange | null;
|
|
12
|
+
set(ranges: readonly CellRange[]): boolean;
|
|
13
|
+
add(range: CellRange): boolean;
|
|
14
|
+
clear(): boolean;
|
|
15
|
+
/** Replace everything with one range from `anchor` to `end` (a click, a plain move, a drag step). */
|
|
16
|
+
only(anchor: CellAddress, end: CellAddress, unit: 'cell' | 'row'): boolean;
|
|
17
|
+
/** Move the active range's far corner (Shift); fixes 'all' extents first. */
|
|
18
|
+
extendTo(end: CellAddress, unit: 'cell' | 'row'): boolean;
|
|
19
|
+
/** Take a rectangle out of every range (Mod-drag inside a range), splitting rectangles. */
|
|
20
|
+
subtract(rect: CellRange): boolean;
|
|
21
|
+
selectAll(anchor: CellAddress): boolean;
|
|
22
|
+
toRowUnit(): boolean;
|
|
23
|
+
/** A cell is in a range; `pinned`: a row of that pinned section. */
|
|
24
|
+
contains(row: number, column: string, pinned?: Side): boolean;
|
|
25
|
+
/** Body rows only: a corner in a pinned section stays where it is. */
|
|
26
|
+
splice(at: number, removed: number, inserted: number): boolean;
|
|
27
|
+
reset(rowCount: number): boolean;
|
|
28
|
+
columnsChanged(columns: RangeColumns): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The pinned sections' row counts (0 and 0 at creation): `'all'` ranges and drawing cover them. In a
|
|
31
|
+
* section whose count changed, a corner or anchor past its rows clamps: to the section's
|
|
32
|
+
* last row; when it emptied, to the body edge next to it (the last body row for the bottom section, the first for
|
|
33
|
+
* the top one; with the body empty too, the nearest row of the other section); the corners are ordered again, and a
|
|
34
|
+
* range left without rows goes. True when that moved or dropped a corner or anchor: the ranges changed.
|
|
35
|
+
*/
|
|
36
|
+
sectionsChanged(top: number, bottom: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The top section's rows moved by `delta` at its head — the pinned grand total came (+1) or went (−1)
|
|
39
|
+
* as its first row: every corner and anchor in the top section follows its row, as `splice` moves body corners; one
|
|
40
|
+
* on the leaving row stays at row 0, the first app row now. Called before `sectionsChanged` takes the new count,
|
|
41
|
+
* which clamps them as for any set (into the body edge when the section emptied). True when the ranges changed.
|
|
42
|
+
*/
|
|
43
|
+
shiftTop(delta: 1 | -1): boolean;
|
|
44
|
+
/** The union's extent over the body's `rowCount` rows and the pinned sections' rows: distinct rows, columns, cells. */
|
|
45
|
+
summary(rowCount: number): {
|
|
46
|
+
rows: number;
|
|
47
|
+
columns: number;
|
|
48
|
+
cells: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* cellBits for a drawn cell: level, edges, aria-selected; computed from prepared per-range data. `pinned`: a
|
|
52
|
+
* row of that pinned section; a range's top edge is on its first covered row, its bottom edge on its last.
|
|
53
|
+
*/
|
|
54
|
+
cellBits(row: number, displayIndex: number, pinned?: Side): number;
|
|
55
|
+
/** Rows covered by any range, for the row-number highlight; `pinned`: a row of that section. */
|
|
56
|
+
rowHit(row: number, pinned?: Side): boolean;
|
|
57
|
+
columnHit(id: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The union of the ranges as row bands, in display order — the top section's, the body's, the bottom section's
|
|
60
|
+
* —, ascending and disjoint within each (no range starts or ends inside one), each with the display
|
|
61
|
+
* indexes it covers, ascending; resolved now against `rowCount` body rows, so a later change does not mix into a
|
|
62
|
+
* walk in progress. A caller walks the cells with plain loops and can skip whole rows (the aggregation over a
|
|
63
|
+
* server's loaded rows).
|
|
64
|
+
*/
|
|
65
|
+
unionBands(rowCount: number): UnionBand[];
|
|
66
|
+
}
|
|
67
|
+
/** One band of `RangeModel.unionBands`: rows [first, last], each covering the cells at `columns` (display indexes). */
|
|
68
|
+
export interface UnionBand {
|
|
69
|
+
first: number;
|
|
70
|
+
last: number;
|
|
71
|
+
columns: number[];
|
|
72
|
+
/** A pinned section's band: its rows are indexes in that section. Absent for the body's. */
|
|
73
|
+
pinned?: Side;
|
|
74
|
+
}
|
|
75
|
+
export declare const CELL_LEVEL = 7;
|
|
76
|
+
export declare const CELL_TOP = 8;
|
|
77
|
+
export declare const CELL_RIGHT = 16;
|
|
78
|
+
export declare const CELL_BOTTOM = 32;
|
|
79
|
+
export declare const CELL_LEFT = 64;
|
|
80
|
+
/** The logically focused cell: drawn by the row pool from the focus model, never set by this model. */
|
|
81
|
+
export declare const CELL_FOCUS = 128;
|
|
82
|
+
export declare const CELL_SELECTED = 256;
|
|
83
|
+
/** `RangeColumns` over a list of ids in display order. */
|
|
84
|
+
export declare function rangeColumnsOf(ids: readonly string[]): RangeColumns;
|
|
85
|
+
/**
|
|
86
|
+
* The body rows of a range's `rows` among `n` body rows: [first, last], first > last when it has none; a
|
|
87
|
+
* corner in a pinned section stands for the body's edge on its side. For the readers that take body rows only.
|
|
88
|
+
*/
|
|
89
|
+
export declare function bodyRows(rows: CellRange['rows'], n: number): {
|
|
90
|
+
first: number;
|
|
91
|
+
last: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A range's rows in display order among `t` top, `n` body and `u` bottom rows, in one index space: top row
|
|
95
|
+
* `i` is `i − t`, body row `r` is `r`, bottom row `j` is `n + j`. [first, last], first > last when it has none. A
|
|
96
|
+
* section counted 0 is not taken (empty, or left out): a corner in it stands for the next row in display order, so
|
|
97
|
+
* with `t = u = 0` these are the body rows `bodyRows` gives. Copy and export walk a range's rows so (`table/takes.ts`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function rangeSpan(rows: CellRange['rows'], n: number, t: number, u: number): {
|
|
100
|
+
first: number;
|
|
101
|
+
last: number;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Creates the model. `rowCount()` is read once, here: afterwards the model follows the display rows through every
|
|
105
|
+
* `splice` and `reset`, as the grid's own heights do — in a batch of splices the source's count is already final at
|
|
106
|
+
* the first one, so the model never asks it mid-batch. The grid therefore reports every splice and reset,
|
|
107
|
+
* with or without ranges. 'all' extents are fixed and drawn up to that count. Ranges are kept as given apart
|
|
108
|
+
* from normalising (rows truncated and ordered, columns in display order); `set` / `add` do not clamp rows, `reset`
|
|
109
|
+
* does, and drawing clamps them to the rows. `extendTo` without a range changes nothing (the caller starts
|
|
110
|
+
* one with `only`). A corner is a (section, row) pair, the sections ordered top < body < bottom; the
|
|
111
|
+
* pinned sections' counts come from `sectionsChanged`.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createRangeModel(columns: RangeColumns, rowCount: () => number): RangeModel;
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import type { RowId, RowSelectContext, RowSelectionOptions, RowSelectionState } from '../types';
|
|
2
|
+
/** A selection state of one row: null = indeterminate (a row with children, some of its leaves selected). */
|
|
3
|
+
export type Tri = boolean | null;
|
|
4
|
+
/** What the model needs from a source (client or server). */
|
|
5
|
+
export interface SelectionSourceView {
|
|
6
|
+
readonly kind: 'client' | 'server';
|
|
7
|
+
rowCount(): number;
|
|
8
|
+
/** Null: a group row, a filler, a row not loaded yet, or a row without an id. */
|
|
9
|
+
idOf(row: number): RowId | null;
|
|
10
|
+
/** Group rows and fillers (and server group rows); a client source's total rows too (no id of their own). */
|
|
11
|
+
isGroup(row: number): boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A server source's view. */
|
|
14
|
+
export interface ServerSelectionView extends SelectionSourceView {
|
|
15
|
+
readonly kind: 'server';
|
|
16
|
+
/** The data rows of the query (`SourceStatus.total`); null when unknown — a grouped or tree query. */
|
|
17
|
+
total(): number | null;
|
|
18
|
+
/**
|
|
19
|
+
* Calls `visit` with every display row that may be loaded (a superset is fine: rows not loaded answer `idOf` null),
|
|
20
|
+
* each once: what a `selectable` change re-checks, so its cost follows the block cache, not the row count.
|
|
21
|
+
*/
|
|
22
|
+
forEachLoaded(visit: (row: number) => void): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The client source's selection internals, from `clientInternals(source)`. A data node is a row with data,
|
|
26
|
+
* displayed or not; its index is stable within one data generation.
|
|
27
|
+
*/
|
|
28
|
+
export interface ClientSelectionView extends SelectionSourceView {
|
|
29
|
+
readonly kind: 'client';
|
|
30
|
+
/** Moves on `setData` / `refresh`, not on filter, sort or expansion changes. */
|
|
31
|
+
dataGeneration(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Moves on filter changes and data generations, not on sort or expansion changes: `selectable` results, the scope
|
|
34
|
+
* counts and the header state are cached per data and filter version.
|
|
35
|
+
*/
|
|
36
|
+
filterVersion(): number;
|
|
37
|
+
nodeCount(): number;
|
|
38
|
+
/** −1 for group rows and fillers. */
|
|
39
|
+
nodeOf(row: number): number;
|
|
40
|
+
/** −1 when the node is not displayed (filtered out, collapsed). */
|
|
41
|
+
rowOfNode(node: number): number;
|
|
42
|
+
/** The id, else the row object. */
|
|
43
|
+
keyOfNode(node: number): unknown;
|
|
44
|
+
/** −1 when no node holds the key. */
|
|
45
|
+
nodeOfKey(key: unknown): number;
|
|
46
|
+
dataOfNode(node: number): unknown;
|
|
47
|
+
/**
|
|
48
|
+
* The data nodes in `'all'` (source order) or `'filtered'` order (the passing nodes, display order). The model reads
|
|
49
|
+
* a scope once per data and filter version (and on select-all), so a fresh array per call is fine.
|
|
50
|
+
*/
|
|
51
|
+
scopeNodes(scope: 'all' | 'filtered'): Int32Array;
|
|
52
|
+
/** Descendants with data, filtered-out ones included; never the row itself (empty for a leaf). */
|
|
53
|
+
leafNodes(row: number): Int32Array;
|
|
54
|
+
/** `leafNodes` of node `node`, displayed or not (an export of the selected rows inside closed groups). */
|
|
55
|
+
leafNodesOfNode(node: number): Int32Array;
|
|
56
|
+
/** Descendants with data that pass the filters; never the row itself. */
|
|
57
|
+
visibleLeafNodes(row: number): Int32Array;
|
|
58
|
+
/** Group rows, tree fillers and tree parents with descendants; never a total row. */
|
|
59
|
+
hasChildren(row: number): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The row a total row stands for — a group total's group row (displayed: its total shows while it is
|
|
62
|
+
* open), −1 for the grand total (none); null for every other row. A total row has no node and no leaves of its own.
|
|
63
|
+
* Absent: the view has no total rows.
|
|
64
|
+
*/
|
|
65
|
+
totalFor?(row: number): number | null;
|
|
66
|
+
/**
|
|
67
|
+
* A data node with descendants (a tree parent): under the descendants modes it is derived and never stored, also
|
|
68
|
+
* while it is not displayed (select-all, `leafNodes` of its ancestors). Independent of filter and expansion; stable
|
|
69
|
+
* within a data generation.
|
|
70
|
+
*/
|
|
71
|
+
nodeHasChildren(node: number): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The source's map of the last generation step: new node → old node (−1 = a new row object); null when that step
|
|
74
|
+
* was not a `setData` with a new array. The model carries a node through it only when the node's key is the old
|
|
75
|
+
* one's. The map exists only during the change announcement unless it was built: call `dataChanged()` synchronously
|
|
76
|
+
* inside the source's change listener (afterwards an unbuilt map is gone, and rows are found again by key).
|
|
77
|
+
*/
|
|
78
|
+
lastRemap(): Int32Array | null;
|
|
79
|
+
}
|
|
80
|
+
export interface RowSelectionModel {
|
|
81
|
+
/** Moves on every change. */
|
|
82
|
+
readonly version: number;
|
|
83
|
+
/** Rows with children under the descendants modes: derived. */
|
|
84
|
+
isSelected(row: number): Tri;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the row with id `id` at display row `row` is selected, for rows a server read returned without loading
|
|
87
|
+
* them: the `{ all, ids }` rule, and under `all` a row `selectable` rejects is not, as
|
|
88
|
+
* `isSelected` reads a loaded row. Client: whether the data node holding `id` is selected.
|
|
89
|
+
*/
|
|
90
|
+
idSelected(row: number, id: RowId): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Client: whether data node `node` is selected, displayed or not (an export of the selected rows inside closed
|
|
93
|
+
* groups). Server: false (its rows have no nodes).
|
|
94
|
+
*/
|
|
95
|
+
nodeSelected(node: number): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Client, the descendants modes: whether node `node` with children — a group, a filler or a tree parent, displayed
|
|
98
|
+
* or not — is selected, as its checkbox shows it once displayed (every selectable leaf selected, one at least).
|
|
99
|
+
* False under `'self'` and on a server.
|
|
100
|
+
*/
|
|
101
|
+
groupSelected(node: number): boolean;
|
|
102
|
+
/** Selected rows the filters keep (client: data nodes in the `'filtered'` scope); a server's `count()`. */
|
|
103
|
+
filteredCount(): number | null;
|
|
104
|
+
/** Whether a gesture or call may select the row (deselecting is always allowed). */
|
|
105
|
+
canSelect(row: number): boolean;
|
|
106
|
+
/** Null: unknown (a server's `all` over a grouped or tree query). */
|
|
107
|
+
count(): number | null;
|
|
108
|
+
/** Selected rows that are displayed. */
|
|
109
|
+
displayedCount(): number;
|
|
110
|
+
/** The header checkbox: tri-state over the selectable rows of the scope; disabled when none is. */
|
|
111
|
+
headerState(scope: 'all' | 'filtered'): {
|
|
112
|
+
state: Tri;
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
};
|
|
115
|
+
/** One gesture or call; returns true when the selection changed. */
|
|
116
|
+
apply(op: SelectionOp): boolean;
|
|
117
|
+
getState(): RowSelectionState;
|
|
118
|
+
setState(state: RowSelectionState | null): boolean;
|
|
119
|
+
/** Client: row objects (display order, then hidden ones in source order); server: none. */
|
|
120
|
+
selectedRows(displayedOnly: boolean): unknown[];
|
|
121
|
+
/** Display index of the anchor, −1 = none. */
|
|
122
|
+
anchor(): number;
|
|
123
|
+
/** Prunes rows that left the data (client: on a new data generation); true when the selection changed. */
|
|
124
|
+
dataChanged(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The config's `selectable` was replaced: its cached results go, and selected rows it now rejects are deselected
|
|
127
|
+
* (the rule for data changes). Client: every selected node; server: explicit ids
|
|
128
|
+
* of loaded rows (under `all` such rows already read as not selected). True when the selection changed.
|
|
129
|
+
*/
|
|
130
|
+
selectableChanged(): boolean;
|
|
131
|
+
/** A source reset (server: the anchor is kept only while its row is loaded at its index). */
|
|
132
|
+
reset(): void;
|
|
133
|
+
/** Anchor index remap only (server: a pending Shift range is cancelled when the splice reaches it). */
|
|
134
|
+
splice(at: number, removed: number, inserted: number): void;
|
|
135
|
+
/** Aborts pending reads; a result arriving later is ignored. */
|
|
136
|
+
destroy(): void;
|
|
137
|
+
}
|
|
138
|
+
export type SelectionOp = {
|
|
139
|
+
kind: 'click';
|
|
140
|
+
row: number;
|
|
141
|
+
mod: boolean;
|
|
142
|
+
shift: boolean;
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'toggle';
|
|
145
|
+
row: number;
|
|
146
|
+
mod: boolean;
|
|
147
|
+
shift: boolean;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'extend';
|
|
150
|
+
row: number;
|
|
151
|
+
} | {
|
|
152
|
+
kind: 'only';
|
|
153
|
+
row: number;
|
|
154
|
+
} | {
|
|
155
|
+
kind: 'rows';
|
|
156
|
+
rows: readonly number[];
|
|
157
|
+
selected: boolean;
|
|
158
|
+
clear: boolean;
|
|
159
|
+
} | {
|
|
160
|
+
kind: 'all';
|
|
161
|
+
scope: 'all' | 'filtered';
|
|
162
|
+
selected: boolean;
|
|
163
|
+
};
|
|
164
|
+
/** Resolved options. */
|
|
165
|
+
export interface RowSelectionConfig {
|
|
166
|
+
mode: 'single' | 'multiple';
|
|
167
|
+
click: {
|
|
168
|
+
select: boolean;
|
|
169
|
+
deselect: boolean;
|
|
170
|
+
};
|
|
171
|
+
clickToggles: boolean;
|
|
172
|
+
groupSelects: 'self' | 'descendants' | 'filteredDescendants';
|
|
173
|
+
/** Already isolated by the grid. */
|
|
174
|
+
selectable: (ctx: RowSelectContext) => boolean;
|
|
175
|
+
}
|
|
176
|
+
export interface ResolvedRowSelectionUi {
|
|
177
|
+
checkboxes: boolean | ((ctx: RowSelectContext) => boolean);
|
|
178
|
+
checkboxLocation: 'column' | 'group';
|
|
179
|
+
/** Default: row boxes in the selection column ('multiple'). */
|
|
180
|
+
headerCheckbox: boolean;
|
|
181
|
+
hideDisabledCheckboxes: boolean;
|
|
182
|
+
/** Default 'filtered'. */
|
|
183
|
+
selectAll: 'all' | 'filtered';
|
|
184
|
+
followFocus: boolean;
|
|
185
|
+
/** Default 40. */
|
|
186
|
+
columnWidth: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The default `selectable`: every data row. The models recognise it and skip building a `RowSelectContext` (scroll hot
|
|
190
|
+
* path: rows bound for the first time while nothing is selected allocate nothing).
|
|
191
|
+
*/
|
|
192
|
+
export declare const SELECT_ALL_ROWS: () => boolean;
|
|
193
|
+
/**
|
|
194
|
+
* The defaults: checkboxes on, the header checkbox while row boxes are in the selection column ('multiple' only),
|
|
195
|
+
* click selection off, `selectAll: 'filtered'`, `groupSelects: 'self'` (always under 'single': selecting a group selects
|
|
196
|
+
* several rows), a 40 px selection column. Null: row selection off.
|
|
197
|
+
*/
|
|
198
|
+
export declare function resolveRowSelection(option: 'single' | 'multiple' | RowSelectionOptions | null | undefined): (RowSelectionConfig & ResolvedRowSelectionUi) | null;
|
|
199
|
+
/** A client source's selection: a byte per data node, carried through `setData` by the source's remap and by key. */
|
|
200
|
+
export declare function createClientSelection(view: ClientSelectionView, config: RowSelectionConfig): RowSelectionModel;
|
|
201
|
+
/**
|
|
202
|
+
* A server source's selection: `{ all, ids }`; group rows are never selectable and `groupSelects` acts as
|
|
203
|
+
* 'self'. `readIds` gives the ids of display rows `first … last` (null for group rows and rows without one) for a Shift
|
|
204
|
+
* range over rows not loaded yet; `onDeferredChange` is called when such a range applied later (the grid emits its
|
|
205
|
+
* `SelectionChange` then, the `apply` that started it having returned false), never after `destroy()`.
|
|
206
|
+
*/
|
|
207
|
+
export declare function createServerSelection(view: ServerSelectionView, config: RowSelectionConfig, readIds: (first: number, last: number, signal: AbortSignal) => Promise<(RowId | null)[]>, onDeferredChange?: () => void): RowSelectionModel;
|