@olvnck/ingrid 0.0.0-stage → 0.15.21
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 +13 -0
- package/LICENSE +21 -0
- package/README.md +5535 -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,52 @@
|
|
|
1
|
+
import type { EffectScope } from 'vue';
|
|
2
|
+
import type { CellEditor, CellEditorContext, ColumnInfo } from '../types';
|
|
3
|
+
import type { PopupHandle } from '../ui/popup';
|
|
4
|
+
import type { EditorBox } from './popupHost';
|
|
5
|
+
import type { EditSession, EditTrigger } from './types';
|
|
6
|
+
/** The last `ctx.setValue`, `getValue`'s stand-in. */
|
|
7
|
+
export interface LastSet {
|
|
8
|
+
set: boolean;
|
|
9
|
+
value: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** `EditSession` with what only the editing module reads. */
|
|
12
|
+
export interface OpenSession extends EditSession {
|
|
13
|
+
readonly editor: CellEditor;
|
|
14
|
+
/** The context the editor got; its `row` and `rowIndex` are the event's. */
|
|
15
|
+
readonly ctx: CellEditorContext;
|
|
16
|
+
/** The column as it was at the start: a stop event's when the column went meanwhile. */
|
|
17
|
+
readonly info: ColumnInfo;
|
|
18
|
+
readonly last: LastSet;
|
|
19
|
+
/** The cell and row element carrying the editing classes; null: none yet. */
|
|
20
|
+
cell: HTMLElement | null;
|
|
21
|
+
row: HTMLElement | null;
|
|
22
|
+
/** The listeners on `host`, stopped with the editor. */
|
|
23
|
+
scope: EffectScope | null;
|
|
24
|
+
/** A popup editor's box on the popup layer, holding `host`; null: the editor is in its cell. */
|
|
25
|
+
popup: EditorBox | null;
|
|
26
|
+
/** The editor's open list (the select editor's, `EditorInternals.list`); null: none. */
|
|
27
|
+
list: PopupHandle | null;
|
|
28
|
+
}
|
|
29
|
+
/** `readValue`'s answer for a `getValue` that threw: the edit cancels. */
|
|
30
|
+
export declare const READ_THREW: unique symbol;
|
|
31
|
+
/** The trigger `startEditing`'s `key` stands for: a character, Backspace, Enter, F2, or the API's own. */
|
|
32
|
+
export declare function triggerOfKey(key: string | undefined): EditTrigger;
|
|
33
|
+
/** `CellEditorContext.key` of a trigger. */
|
|
34
|
+
export declare function keyOfTrigger(trigger: EditTrigger): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* The editor's host and its `create`, synchronous so it can take focus in the key's own task. Null: a
|
|
37
|
+
* veto, or a throw (reported once); nothing is left behind.
|
|
38
|
+
*/
|
|
39
|
+
export declare function openSession(fields: Pick<EditSession, 'target' | 'key' | 'column' | 'startValue' | 'trigger'> & {
|
|
40
|
+
editor: CellEditor;
|
|
41
|
+
ctx: CellEditorContext;
|
|
42
|
+
info: ColumnInfo;
|
|
43
|
+
last: LastSet;
|
|
44
|
+
}): OpenSession | null;
|
|
45
|
+
/** The editor's value: `getValue`, else the last `ctx.setValue`, else the start value. */
|
|
46
|
+
export declare function readValue(s: OpenSession): unknown;
|
|
47
|
+
/** The editor says nothing is to be written (`cancelled`). A throw counts as yes. */
|
|
48
|
+
export declare function readCancelled(s: OpenSession): boolean;
|
|
49
|
+
/** Focus into the editor: its `focus`, else the first tabbable element in the host. */
|
|
50
|
+
export declare function focusEditor(s: OpenSession, first: () => HTMLElement | undefined): void;
|
|
51
|
+
/** The editor's end: `destroy`, its host out of the cell; its list and a popup editor's box close. */
|
|
52
|
+
export declare function endEditor(s: OpenSession): void;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import type { GridTexts } from '../i18n/texts';
|
|
2
|
+
import type { SourceChange } from '../source';
|
|
3
|
+
import type { CellEditEvent, CellEditorInstance, CellEditStopEvent, CellRange, CellValueChange, ColumnDef, ColumnInfo, EditableContext, EditOperation } from '../types';
|
|
4
|
+
import type { TooltipLayer } from '../ui/tooltip';
|
|
5
|
+
import type { EditorPopups } from './popupHost';
|
|
6
|
+
import type { DataType } from './values';
|
|
7
|
+
/** A cell by what identifies it across passes: display row (a pinned row: its index in its section), column id. */
|
|
8
|
+
export interface EditTarget {
|
|
9
|
+
row: number;
|
|
10
|
+
column: string;
|
|
11
|
+
pinned?: 'top' | 'bottom';
|
|
12
|
+
}
|
|
13
|
+
/** What opened an editor. */
|
|
14
|
+
export type EditTrigger = {
|
|
15
|
+
kind: 'enter' | 'f2' | 'pointer' | 'tab' | 'api';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'char';
|
|
18
|
+
char: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'backspace';
|
|
21
|
+
};
|
|
22
|
+
/** What ends an edit with a commit. */
|
|
23
|
+
export type StopHow = 'enter' | 'tab' | 'press' | 'view' | 'focus' | 'api' | 'editor' | 'popup';
|
|
24
|
+
/** What ends an edit without one. */
|
|
25
|
+
export type CancelWhy = 'escape' | 'api' | 'editor' | 'gone' | 'column' | 'source';
|
|
26
|
+
/** The one open edit: at most one per grid. */
|
|
27
|
+
export interface EditSession {
|
|
28
|
+
/** Where it is now. The object stays; `keep()` hands it out, so its readers read no source per draw. */
|
|
29
|
+
readonly target: EditTarget;
|
|
30
|
+
/** The row's key (`rowKey`; a pinned row's `sectionKey`), so a moved row is found again. */
|
|
31
|
+
readonly key: unknown;
|
|
32
|
+
readonly column: ColumnDef;
|
|
33
|
+
/** The value the cell held when the editor opened, raw. */
|
|
34
|
+
readonly startValue: unknown;
|
|
35
|
+
/** The editor's instance and its host element (`div.ig-cell-editor`, in its cell or a popup editor's box). */
|
|
36
|
+
readonly instance: CellEditorInstance;
|
|
37
|
+
readonly host: HTMLElement;
|
|
38
|
+
readonly trigger: EditTrigger;
|
|
39
|
+
errors: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
export interface Editing {
|
|
42
|
+
/** The gate. */
|
|
43
|
+
canEdit(cell: EditTarget): boolean;
|
|
44
|
+
/** `GridOptions.editing` with its defaults. */
|
|
45
|
+
options(): ResolvedEditing;
|
|
46
|
+
start(cell: EditTarget, trigger: EditTrigger, event?: Event): boolean;
|
|
47
|
+
/** False: refused (block mode, invalid value). */
|
|
48
|
+
commit(how: StopHow, event?: Event): boolean;
|
|
49
|
+
cancel(why: CancelWhy): void;
|
|
50
|
+
session(): EditSession | null;
|
|
51
|
+
/** For `FocusDraw.keep` and `keptSlot`. */
|
|
52
|
+
keep(): EditTarget | null;
|
|
53
|
+
onCellKey(e: KeyboardEvent, from: EditTarget, ctx: {
|
|
54
|
+
external: boolean;
|
|
55
|
+
}): 'done' | 'pass';
|
|
56
|
+
onEditorKey(e: KeyboardEvent): 'done' | 'pass';
|
|
57
|
+
/**
|
|
58
|
+
* A press on a cell. `'swallow'`: the press does nothing else: block mode's refusal, or a touch press on
|
|
59
|
+
* another cell, which commits at its tap (`commit('press')`), so a scroll commits nothing.
|
|
60
|
+
*/
|
|
61
|
+
pressOnCell(target: EditTarget, e: PointerEvent): 'pass' | 'swallow';
|
|
62
|
+
/** A click or double-click on a cell's own area: the start the column's or the grid's option asks for. */
|
|
63
|
+
clickOnCell(target: EditTarget, kind: 'single' | 'double', e: MouseEvent): boolean;
|
|
64
|
+
/** DOM focus into the open editor; false: none is open. */
|
|
65
|
+
takeFocus(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tab's walk found the editable `cell`, focus on its way there: its editor opens. A live box opens none, as
|
|
68
|
+
* it's its own editor: the walk waits there, for `walkOn`. Under `tab: 'focus'`: nothing more.
|
|
69
|
+
*/
|
|
70
|
+
arriveByTab(cell: EditTarget, e: KeyboardEvent): void;
|
|
71
|
+
/** Tab on `from`: the walk waiting on this box goes on (`'pass'`: the key is the browser's); null: no walk waits here. */
|
|
72
|
+
walkOn(from: EditTarget, e: KeyboardEvent): 'done' | 'pass' | null;
|
|
73
|
+
/**
|
|
74
|
+
* The focused position is going to `to` (null: no cell, a header or a detail stop), whatever moved it: another
|
|
75
|
+
* cell commits an open edit. False: block mode refuses, and the move mustn't happen. Any other place ends a waiting walk.
|
|
76
|
+
*/
|
|
77
|
+
beforeFocusMove(to: EditTarget | null): boolean;
|
|
78
|
+
/** The operations module. */
|
|
79
|
+
setOperations(operations: EditOperations | null): void;
|
|
80
|
+
/** The funnel. */
|
|
81
|
+
beforeViewChange(): void;
|
|
82
|
+
/**
|
|
83
|
+
* A change of the body's source, before the grid applies it: a structural one marks the session's row for
|
|
84
|
+
* a look-up by its key once the batch is applied (`settled`); `rows` changes leave it alone.
|
|
85
|
+
*/
|
|
86
|
+
sourceChanged(change: SourceChange): void;
|
|
87
|
+
/** A pinned section's rows are about to be set (by `sectionKey`); `settled` follows once they are. */
|
|
88
|
+
sectionChanged(side: 'top' | 'bottom'): void;
|
|
89
|
+
/**
|
|
90
|
+
* A batch of source changes is applied (the grid's `settle`), or (`side`) a section's rows set: the session's row is
|
|
91
|
+
* looked up by its key — with `side`, only an edit of that section's. Still shown: the position follows it and its
|
|
92
|
+
* view is re-keyed; gone: the edit cancels.
|
|
93
|
+
*/
|
|
94
|
+
settled(side?: 'top' | 'bottom'): void;
|
|
95
|
+
/** A layout was applied: an edit whose column is hidden or removed cancels. */
|
|
96
|
+
columnsChanged(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Just before the row pools render: a session whose row moved re-keys its view, so no DOM move; a change
|
|
99
|
+
* the batch's end hasn't resolved yet (a pass inside the batch's task) is resolved first.
|
|
100
|
+
*/
|
|
101
|
+
beforeRender(): void;
|
|
102
|
+
/** At a pass's start, while an edit is open: what holds focus in the editor (`blur` isn't reliable). */
|
|
103
|
+
beforePass(): void;
|
|
104
|
+
/** Placing, O(1); the fill handle's too. After the render and before the refocus rule. */
|
|
105
|
+
afterPass(): void;
|
|
106
|
+
dispose(): void;
|
|
107
|
+
}
|
|
108
|
+
/** The operations module, registered on `Editing`. */
|
|
109
|
+
export interface EditOperations {
|
|
110
|
+
onCellKey(e: KeyboardEvent, from: EditTarget, ctx: {
|
|
111
|
+
external: boolean;
|
|
112
|
+
}): 'done' | 'pass';
|
|
113
|
+
/** Mod+Enter. */
|
|
114
|
+
bulk(value: unknown, origin: EditTarget): boolean;
|
|
115
|
+
/** A commit's or a box's undo entry. */
|
|
116
|
+
record(change: EditChange, source: CellValueChange['source']): void;
|
|
117
|
+
/** Clears the undo stacks. */
|
|
118
|
+
viewChanged(): void;
|
|
119
|
+
/** A pinned section's rows were replaced: only the steps holding a change there go (body positions stay). */
|
|
120
|
+
pinnedChanged(side: 'top' | 'bottom'): void;
|
|
121
|
+
}
|
|
122
|
+
/** One cell of an operation (public). */
|
|
123
|
+
export type EditChange = EditOperation['changes'][number];
|
|
124
|
+
export interface BatchWriter {
|
|
125
|
+
write(cell: EditTarget, value: unknown): boolean;
|
|
126
|
+
readonly changes: readonly EditChange[];
|
|
127
|
+
}
|
|
128
|
+
/** `EditingOptions` with its defaults (`undo`: null while off). */
|
|
129
|
+
export interface ResolvedEditing {
|
|
130
|
+
click: 'double' | 'single' | 'none';
|
|
131
|
+
enterMoves: false | 'afterEdit' | 'always';
|
|
132
|
+
tab: 'edit' | 'focus';
|
|
133
|
+
backspaceEdits: boolean;
|
|
134
|
+
stopOnFocusLoss: boolean;
|
|
135
|
+
invalid: 'revert' | 'block';
|
|
136
|
+
request: boolean;
|
|
137
|
+
undo: {
|
|
138
|
+
limit: number;
|
|
139
|
+
} | null;
|
|
140
|
+
}
|
|
141
|
+
/** What `createEditing` asks of the grid. */
|
|
142
|
+
export interface EditHost {
|
|
143
|
+
options(): ResolvedEditing;
|
|
144
|
+
/**
|
|
145
|
+
* Gate step 1: the cell as a data cell of a source that can write, with its row object; null for a group,
|
|
146
|
+
* filler or total row, a row not loaded, a grid-owned column, a computed field without `setValue`, a source that
|
|
147
|
+
* cannot write.
|
|
148
|
+
*/
|
|
149
|
+
contextOf(cell: EditTarget): EditableContext | null;
|
|
150
|
+
/** `GridOptions.cellFocus`: only `true` lets an editor open. */
|
|
151
|
+
cellFocus(): boolean | 'row';
|
|
152
|
+
/** The data type of a column that may be edited: given, else inferred from the first value. */
|
|
153
|
+
dataType(column: string): DataType | undefined;
|
|
154
|
+
/** One console hint per key. */
|
|
155
|
+
hint(key: string, message: string): void;
|
|
156
|
+
/** Writes N cells as one operation. Null: nothing written. */
|
|
157
|
+
writeBatch(kind: EditOperation['kind'], source: EditOperation['source'], run: (writer: BatchWriter) => void, ranges?: {
|
|
158
|
+
initial?: CellRange;
|
|
159
|
+
final?: CellRange;
|
|
160
|
+
}): EditOperation | null;
|
|
161
|
+
/** A checkbox column: it passes the gate and opens no editor. */
|
|
162
|
+
checkbox(column: string): boolean;
|
|
163
|
+
/** Enter's move: focus to the cell below (`up`: above). It opens nothing, and asks no `navigate`. */
|
|
164
|
+
enterMove(from: EditTarget, up: boolean): void;
|
|
165
|
+
/**
|
|
166
|
+
* Tab goes on from the committed cell, or a live box the walk waited on: focus to the next editable cell,
|
|
167
|
+
* and `arriveByTab`; with none, what Tab does without editing. `'pass'`: the key is the browser's, out of the grid.
|
|
168
|
+
*/
|
|
169
|
+
tabOn(from: EditTarget, event: KeyboardEvent): 'done' | 'pass';
|
|
170
|
+
/** Focus on `el` hasn't left the grid: its header or rows, one of its popups or their owner elements. */
|
|
171
|
+
keepsFocus(el: Element): boolean;
|
|
172
|
+
/** A cell's raw value (`undefined` while its row loads). */
|
|
173
|
+
value(cell: EditTarget): unknown;
|
|
174
|
+
/** The row's key (`rowKey`; a pinned row's `sectionKey`). */
|
|
175
|
+
rowKey(cell: EditTarget): unknown;
|
|
176
|
+
/**
|
|
177
|
+
* The display row now holding `key` (a pinned row: its index in section `pinned`, by `sectionKey`); −1 when it isn't
|
|
178
|
+
* shown (gone, filtered out, in a closed group) or the source can't look keys up (a server or custom source).
|
|
179
|
+
*/
|
|
180
|
+
rowOf(key: unknown, pinned?: 'top' | 'bottom'): number;
|
|
181
|
+
/** The focused position is `cell`. */
|
|
182
|
+
focusedOn(cell: EditTarget): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* The position follows its row to `cell`: one `FocusChange` with source `'data'`, DOM focus left where it
|
|
185
|
+
* is, and no commit, as the session's target is already there.
|
|
186
|
+
*/
|
|
187
|
+
placeMoved(cell: EditTarget): void;
|
|
188
|
+
/** The row view holding `el` (the editor's host) now stands for `cell`'s row, with no DOM move. */
|
|
189
|
+
rekey(el: HTMLElement, cell: EditTarget): void;
|
|
190
|
+
/**
|
|
191
|
+
* The pass gave an editor focus back or moved its cell (a pin change): for about three frames a scroll the browser
|
|
192
|
+
* makes (a reveal) is written back, before it counts as the user's.
|
|
193
|
+
*/
|
|
194
|
+
guardScroll(): void;
|
|
195
|
+
/** The column is defined and displayed. */
|
|
196
|
+
shown(column: string): boolean;
|
|
197
|
+
/** A column as `getColumns` reports it; null: not defined. */
|
|
198
|
+
columnInfo(column: string): ColumnInfo | null;
|
|
199
|
+
/** The editor's accessible name (`texts.editorLabel`). */
|
|
200
|
+
label(column: string): string;
|
|
201
|
+
/** The mark the grid's number inputs write (`Locale.decimal`). */
|
|
202
|
+
decimal(): '.' | ',';
|
|
203
|
+
/** The live texts (the built-in editors' validation messages). */
|
|
204
|
+
texts(): GridTexts;
|
|
205
|
+
/** A number as the number filter's inputs write it (the style's input format). */
|
|
206
|
+
numberText(value: number): string;
|
|
207
|
+
/** A value as the cell shows it (the column's `format`, isolated). */
|
|
208
|
+
format(cell: EditTarget, value: unknown): string;
|
|
209
|
+
/** An editor's write (`writeValue`, source `'edit'`). True: written, or in request mode asked for. */
|
|
210
|
+
write(cell: EditTarget, value: unknown): boolean;
|
|
211
|
+
/** Runs a step with its events held: they go out, in order, once its state changes are done. */
|
|
212
|
+
step<T>(run: () => T): T;
|
|
213
|
+
/** The cell scrolled into view and drawn, now (`scrollCellIntoView` + `flushPass`). */
|
|
214
|
+
reveal(cell: EditTarget): void;
|
|
215
|
+
/** The drawn cell; null: none. */
|
|
216
|
+
cellElement(cell: EditTarget): HTMLElement | null;
|
|
217
|
+
/** The logical focus on the cell, DOM focus left alone. */
|
|
218
|
+
focusPosition(cell: EditTarget): void;
|
|
219
|
+
/** DOM focus back on `cell`, the logical position with it; null: on the focused position, wherever it went. */
|
|
220
|
+
focusCell(cell: EditTarget | null): void;
|
|
221
|
+
hideTooltip(): void;
|
|
222
|
+
/** The grid's polite live region says `text`; '' replaces what it said with nothing. */
|
|
223
|
+
announce(text: string): void;
|
|
224
|
+
/** The live region exists now, so a screen reader has it before its text changes. */
|
|
225
|
+
liveRegion(): void;
|
|
226
|
+
/** The styled tooltip's layer (made on first use); null: the browser's own tooltips are on. */
|
|
227
|
+
tooltip(): TooltipLayer | null;
|
|
228
|
+
emitStart(event: CellEditEvent): void;
|
|
229
|
+
emitStop(event: CellEditStopEvent): void;
|
|
230
|
+
/** An edit ended: the module may not be needed any more (`syncEdit`). */
|
|
231
|
+
closed(): void;
|
|
232
|
+
/** A popup editor's box and an editor's list on the grid's popup layer (`popupHost.ts`); made on first use. */
|
|
233
|
+
popups(): EditorPopups;
|
|
234
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CellRange, CellValueChange } from '../types';
|
|
2
|
+
import type { EditChange } from './types';
|
|
3
|
+
/** One step. */
|
|
4
|
+
export interface UndoAction {
|
|
5
|
+
/** What made it: an editor's commit (`'edit'`), a live box (`'checkbox'`), or an operation's kind. */
|
|
6
|
+
kind: CellValueChange['source'];
|
|
7
|
+
/** Every cell the action wrote, in write order. Cells are by display row, a pinned row by its section. */
|
|
8
|
+
changes: readonly EditChange[];
|
|
9
|
+
/** The ranges at the time: a clear or cut gives them back (`keepRanges`). */
|
|
10
|
+
ranges?: readonly CellRange[];
|
|
11
|
+
/** True: undo and redo restore `ranges` (a clear, a cut); false: one cell range on the first change. */
|
|
12
|
+
keepRanges: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UndoStack {
|
|
15
|
+
/** A new action clears redo; one with no changes does neither, and with `limit <= 0` nothing is kept. */
|
|
16
|
+
push(action: UndoAction): void;
|
|
17
|
+
/** The action to apply backwards; it moves to redo whatever came of it. Null: nothing to undo. */
|
|
18
|
+
undo(): UndoAction | null;
|
|
19
|
+
/** The action to apply again; it moves back to undo. Null: nothing to redo. */
|
|
20
|
+
redo(): UndoAction | null;
|
|
21
|
+
clear(): void;
|
|
22
|
+
/** Drops the steps holding a change in pinned section `side` (replacing the section's rows); the others stay. */
|
|
23
|
+
dropPinned(side: 'top' | 'bottom'): void;
|
|
24
|
+
sizes(): {
|
|
25
|
+
undo: number;
|
|
26
|
+
redo: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The most recent `limit` steps are kept; the oldest is dropped (`<= 0`: off). */
|
|
30
|
+
export declare function createUndoStack(limit: number): UndoStack;
|
|
31
|
+
/**
|
|
32
|
+
* The writes that apply `action` in one direction: undo writes the old values, last change first (so a cell written twice
|
|
33
|
+
* ends on its first old value); redo the new ones, in write order.
|
|
34
|
+
*/
|
|
35
|
+
export declare function writesOf(action: UndoAction, direction: 'undo' | 'redo'): {
|
|
36
|
+
change: EditChange;
|
|
37
|
+
value: unknown;
|
|
38
|
+
}[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type OpenSession } from './session';
|
|
2
|
+
/**
|
|
3
|
+
* The errors of the editor's value now. `value` is what the editor holds (read here when not given: `getValue` may run
|
|
4
|
+
* more than once). A column's `validate` replaces the editor's errors and gets them; a throw is reported once and counts
|
|
5
|
+
* as valid. A value the editor cannot read (a refused text, a `getValue` that threw) is not judged by `validate`: the
|
|
6
|
+
* editor's own errors stand.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validate(s: OpenSession, ...given: [] | [unknown]): readonly string[];
|
|
9
|
+
/** Whether two error lists say the same. */
|
|
10
|
+
export declare function sameErrors(a: readonly string[], b: readonly string[]): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ViewportSource } from '../source';
|
|
2
|
+
import type { ColumnDef, EditableContext } from '../types';
|
|
3
|
+
/** A column's data type (`ColumnDef.dataType`, without `false`). */
|
|
4
|
+
export type DataType = Exclude<NonNullable<ColumnDef['dataType']>, false>;
|
|
5
|
+
/** A parser's answer for a text it cannot read: the cell stays as it was. */
|
|
6
|
+
export declare const REFUSED: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* The data type a value shows (the checkbox columns' inference, widened): a number, a boolean, a `Date`, an ISO date or
|
|
9
|
+
* date-time string, else text for any other string; `undefined` for `null`, `undefined` and other objects.
|
|
10
|
+
*/
|
|
11
|
+
export declare function inferDataType(value: unknown): DataType | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The parser of a data type, for a column without `parse`: `decimal` is the mark the grid's number inputs
|
|
14
|
+
* write (`Locale.decimal`; `','` also reads `.` as a mark and a grouped `1.234,50`). Nothing trims a text.
|
|
15
|
+
*/
|
|
16
|
+
export declare function defaultParser(type: DataType | undefined, decimal: '.' | ','): (text: string) => unknown | typeof REFUSED;
|
|
17
|
+
/**
|
|
18
|
+
* What a column reads `text` as: its `parse`, isolated (a throw is reported once and refuses), else its data
|
|
19
|
+
* type's default parser. The one place an editor's commit, a clear, a paste, a Mod+Enter and a fill across columns read
|
|
20
|
+
* a text, an empty one included. `ctx` null: no context to give `parse` (the cell has none), so the default parser reads.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readText(text: string, ctx: EditableContext | null, type: DataType | undefined, decimal: '.' | ','): unknown;
|
|
23
|
+
/** A value as the text another column's `parse` reads: empty for null, undefined and an invalid date. */
|
|
24
|
+
export declare function textOf(value: unknown): string;
|
|
25
|
+
/**
|
|
26
|
+
* The row object behind a cell as an `EditableContext`, read without writing: the source's `writeCell` hands the object
|
|
27
|
+
* out and the probe declines, so nothing is kept or announced. Null where the source does not write the cell (a group or
|
|
28
|
+
* filler row, an aggregate, a row not loaded, a computed field without a column `setValue`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function editableContextOf(source: ViewportSource, def: ColumnDef, field: string, row: number, pinned?: 'top' | 'bottom'): EditableContext | null;
|
|
31
|
+
/**
|
|
32
|
+
* Whether `def.editable` lets the cell be edited: `true`, or the function's answer. `ctx` is made
|
|
33
|
+
* only for the function form (a lazy `() => EditableContext | null` keeps the common `true` free of work; null: the cell
|
|
34
|
+
* has no row object, so no). A throw is reported once per function and counts as no.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isEditableColumn(def: Pick<ColumnDef, 'editable'>, ctx: EditableContext | null | (() => EditableContext | null)): boolean;
|
|
37
|
+
/** Whether a column may be editable at all (`editable` set and not `false`). */
|
|
38
|
+
export declare function mayBeEditable(def: Pick<ColumnDef, 'editable'>): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TableColumn } from '../table/cells';
|
|
2
|
+
import type { TableHost } from '../table/host';
|
|
3
|
+
import type { ExportColumn } from '../types';
|
|
4
|
+
import type { ResolvedExport } from './options';
|
|
5
|
+
export interface ExportCol extends TableColumn {
|
|
6
|
+
mode: 'auto' | 'text' | 'value';
|
|
7
|
+
/** XLSX: how strings are written. */
|
|
8
|
+
type: ExportColumn['type'];
|
|
9
|
+
numberFormat: string | undefined;
|
|
10
|
+
/** px: `export.width` ?? the grid's width (a hidden column: the width the grid keeps for it). */
|
|
11
|
+
width: number;
|
|
12
|
+
/** Left-pinned or the row-number column (`freeze: 'headerAndPinned'`). */
|
|
13
|
+
leading: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The columns an export writes, with their header texts when it writes them: the `header` hook over each
|
|
17
|
+
* column's `headerName` and each group's name, isolated (a throw is reported once, the default used).
|
|
18
|
+
*/
|
|
19
|
+
export declare function exportColumns(host: TableHost, o: ResolvedExport): ExportCol[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ExportFile, ExportFormat, ExportSink } from '../types';
|
|
2
|
+
import type { ResolvedExport } from './options';
|
|
3
|
+
import { type ChunkQueue } from './writer';
|
|
4
|
+
/** How long a download's object URL lives: Safari may cancel a download whose URL is revoked at once. */
|
|
5
|
+
export declare const REVOKE_MS = 60000;
|
|
6
|
+
/** Each format's media type and extension. */
|
|
7
|
+
export declare const FILE_TYPES: Readonly<Record<ExportFormat, {
|
|
8
|
+
type: string;
|
|
9
|
+
extension: string;
|
|
10
|
+
}>>;
|
|
11
|
+
/**
|
|
12
|
+
* The file's name: `fileName` (a string or a function of the format, isolated: a throw is reported once), else
|
|
13
|
+
* `'export'` — also for a function that returns no non-empty string — with the format's extension unless the
|
|
14
|
+
* name ends with it (any case).
|
|
15
|
+
*/
|
|
16
|
+
export declare function fileNameOf(o: Pick<ResolvedExport, 'fileName' | 'format'>): string;
|
|
17
|
+
/** The chunks kept for one Blob (the default and `write` deliveries). */
|
|
18
|
+
export interface BlobQueue extends ChunkQueue {
|
|
19
|
+
blob(type: string): Blob;
|
|
20
|
+
}
|
|
21
|
+
export declare function blobQueue(): BlobQueue;
|
|
22
|
+
/**
|
|
23
|
+
* A sink's `abort(reason)`, when it has one (a throw or a rejection is reported once under `hook` and ignored);
|
|
24
|
+
* never rejects, also for something that is no sink (a `stream` hook's late answer).
|
|
25
|
+
*/
|
|
26
|
+
export declare function abortSink(sink: unknown, hook: object, reason: unknown): Promise<void>;
|
|
27
|
+
/** A `stream` sink's queue: each chunk written in order and awaited; `held` counts the unwritten bytes. */
|
|
28
|
+
export interface StreamQueue extends ChunkQueue {
|
|
29
|
+
/** Settles once the unwritten chunks hold less than half of `PAUSE_BYTES`, or writing stopped. */
|
|
30
|
+
drained(): Promise<void>;
|
|
31
|
+
/** Every chunk written, then `close()`; rejects with the first failure. */
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
/** Stops writing and calls the sink's `abort(reason)` once (isolated: a throw is reported and ignored). */
|
|
34
|
+
abort(reason: unknown): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The queue over `sink`. A rejected (or throwing) `write` or `close` is reported once (owner `hook`) and handed to
|
|
38
|
+
* `failed`, which ends the export; writing stops there.
|
|
39
|
+
*/
|
|
40
|
+
export declare function streamQueue(sink: ExportSink, hook: object, failed: (error: unknown) => void): StreamQueue;
|
|
41
|
+
/**
|
|
42
|
+
* The default delivery: an `<a download>` with the `hidden` attribute (no inline style: strict CSP) over an
|
|
43
|
+
* object URL of the file, appended to `.ig-root`, clicked, removed. The URL is revoked `REVOKE_MS` later by a timer in
|
|
44
|
+
* a detached effect scope — not the grid's, so `destroy()` does not stop it (a stopped timer would leak the URL;
|
|
45
|
+
* revoking at destroy can cancel Safari's download).
|
|
46
|
+
*/
|
|
47
|
+
export declare function download(root: HTMLElement, file: ExportFile): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ClientInternals, ExpandedOrder } from '../data/client/clientSource';
|
|
2
|
+
import type { ServerInternals } from '../data/server/serverSource';
|
|
3
|
+
import type { TableColumn } from '../table/cells';
|
|
4
|
+
import type { TableHost } from '../table/host';
|
|
5
|
+
import { type WalkSections } from '../table/rows';
|
|
6
|
+
import type { Take } from '../table/takes';
|
|
7
|
+
/** A range resolved against the display rows and the export's columns (takeRanges' rule). */
|
|
8
|
+
export interface RangeRect {
|
|
9
|
+
first: number;
|
|
10
|
+
last: number;
|
|
11
|
+
ids: ReadonlySet<string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The cell ranges clipped to the view: each range's rows `first … last` (a range without rows left out) and the range
|
|
15
|
+
* columns it names, in its order (the export's ranges, columns and `'selection'` choice read them alike). Body rows
|
|
16
|
+
* only — `getRangeRows` / `readRangeRows` — unless `sections` names the pinned sections taken: then a
|
|
17
|
+
* range's rows in display order, its pinned rows at their place around its body rows (`rangeSpan`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function clippedRanges(host: TableHost, sections?: WalkSections | null): {
|
|
20
|
+
first: number;
|
|
21
|
+
last: number;
|
|
22
|
+
ids: string[];
|
|
23
|
+
}[];
|
|
24
|
+
/**
|
|
25
|
+
* The cell ranges as rects over the columns `column` accepts (`takeRanges`' rule); a range without one left out. With
|
|
26
|
+
* `sections`, rows in display order (`clippedRanges`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function rangeRects(host: TableHost, column: (id: string) => TableColumn | null, sections?: WalkSections | null): RangeRect[];
|
|
29
|
+
/** Display row `row` with every column of `columns`: `rows: 'selection'`'s one row. */
|
|
30
|
+
export declare function rowRect(host: TableHost, row: number, columns: readonly TableColumn[]): RangeRect[];
|
|
31
|
+
/**
|
|
32
|
+
* `rows: 'all'` of a client's grouped or tree view: every row of the expanded order, taken when the walk is built
|
|
33
|
+
* (rows appended while `confirm` is open belong to the file).
|
|
34
|
+
*/
|
|
35
|
+
export declare function expandedView(host: TableHost, columns: readonly TableColumn[], client: ClientInternals, x: ExpandedOrder): Take;
|
|
36
|
+
/**
|
|
37
|
+
* `rows: 'selected'` of a client's grouped or tree view: every selected data row, displayed or inside a closed
|
|
38
|
+
* group; under the descendants modes a group row (or tree parent) that is selected as its checkbox shows it — displayed
|
|
39
|
+
* or not (`groupSelected`) — brings every row below it, open or closed, its total row included (a total
|
|
40
|
+
* row never comes by itself, the grand total never). `'self'` keeps each row to itself. Null without a selection, a
|
|
41
|
+
* selected row or columns.
|
|
42
|
+
*/
|
|
43
|
+
export declare function expandedSelected(host: TableHost, columns: readonly TableColumn[], client: ClientInternals, x: ExpandedOrder): Take | null;
|
|
44
|
+
/**
|
|
45
|
+
* The merged position intervals the ranges `rects` take of the expanded order (each row once, in order), as
|
|
46
|
+
* `expandedRects` takes them (`rangeRows` reads the data rows in them).
|
|
47
|
+
*/
|
|
48
|
+
export declare function expandedSpans(rects: readonly {
|
|
49
|
+
first: number;
|
|
50
|
+
last: number;
|
|
51
|
+
}[], x: ExpandedOrder): [number, number][];
|
|
52
|
+
/**
|
|
53
|
+
* Rects of display rows over a client's grouped or tree view (`rows: 'ranges'`, `'selection'`'s one row): each
|
|
54
|
+
* from its first row to the end of the outermost group row it holds whose group reaches past its last row — a closed
|
|
55
|
+
* group's rows follow its row, an open one's rows below the rect come with it, and so does its total row (a
|
|
56
|
+
* group's `end` includes its bottom total, its top total is its first child). One 'grid' block over the positions,
|
|
57
|
+
* cells outside every rect empty. Null when no rect is left. With `sections` the rects are in display order
|
|
58
|
+
* (`rangeRects`): their pinned rows before and after the order's positions.
|
|
59
|
+
*/
|
|
60
|
+
export declare function expandedRects(host: TableHost, rects: readonly RangeRect[], columns: readonly TableColumn[], x: ExpandedOrder, sections?: WalkSections | null): Take | null;
|
|
61
|
+
/**
|
|
62
|
+
* Rects of display rows over a server's grouped or tree view: each read from its first row to the end of the
|
|
63
|
+
* outermost open group it holds that reaches past its last row (`subtreeEnd`), with the levels of the closed groups it
|
|
64
|
+
* lists (`readRows` with `all`), one read per merged interval; the rects over the reads' rows in their order, one
|
|
65
|
+
* 'grid' block. The size before `confirm` counts the display rows only (closed groups' rows are not known before the
|
|
66
|
+
* read: a lower bound); `result` takes the rows read. With `sections` the rects are in display order (`rangeRects`):
|
|
67
|
+
* their pinned rows are not read but walked before and after the reads' rows.
|
|
68
|
+
*/
|
|
69
|
+
export declare function serverRects(host: TableHost, rects: readonly RangeRect[], columns: readonly TableColumn[], reader: ServerInternals, sections?: WalkSections | null): Take | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TableHost } from '../table/host';
|
|
2
|
+
import { type Slicer } from '../table/slicer';
|
|
3
|
+
import type { ExportFile, ExportFormat, ExportInfo, ExportRequest, ExportResult, GridOptions } from '../types';
|
|
4
|
+
import { type WriterFactory } from './writer';
|
|
5
|
+
/** The grid as the export reads it: the table host, plus the root a download goes into and the live region. */
|
|
6
|
+
export interface ExportHost extends TableHost {
|
|
7
|
+
/** null in Node tests: no download. */
|
|
8
|
+
readonly root: HTMLElement | null;
|
|
9
|
+
announce(text: string): void;
|
|
10
|
+
formatCount(count: number): string;
|
|
11
|
+
/** The focused body cell's display row (`rows: 'selection'`'s last fallback); −1 without one. */
|
|
12
|
+
focusedRow(): number;
|
|
13
|
+
}
|
|
14
|
+
export interface Exporter {
|
|
15
|
+
export(request: ExportRequest, source: ExportInfo['source']): Promise<ExportResult>;
|
|
16
|
+
exportBlob(request: ExportRequest): Promise<ExportFile>;
|
|
17
|
+
/** `false`: cancels a running `export()`, not an `exportBlob()`. */
|
|
18
|
+
setOptions(option: GridOptions['export']): void;
|
|
19
|
+
/** The menus' check: exporting is on. */
|
|
20
|
+
enabled(): boolean;
|
|
21
|
+
/** Every splice (`at`) or reset (`at` 0) the grid applies: an export built from live rows that reach `at` ends. */
|
|
22
|
+
moved(at: number): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function createExporter(host: ExportHost, slicer: Slicer, writers?: Partial<Record<ExportFormat, WriterFactory>>): Exporter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExportCol } from './columns';
|
|
2
|
+
import type { ResolvedExport } from './options';
|
|
3
|
+
export interface HeaderRows {
|
|
4
|
+
/** Group rows first, then the header row; null = no cell. */
|
|
5
|
+
rows: (string | null)[][];
|
|
6
|
+
groupRows: number;
|
|
7
|
+
/** Group cells spanning more than one column (XLSX merges them). */
|
|
8
|
+
merges: {
|
|
9
|
+
row: number;
|
|
10
|
+
first: number;
|
|
11
|
+
last: number;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
/** The header rows of `cols` under `o.headers`; none without columns (an empty file). */
|
|
15
|
+
export declare function headerRows(cols: readonly ExportCol[], o: ResolvedExport): HeaderRows;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ExportFormat, ExportHeaders, ExportOptions, ExportRequest, GridOptions } from '../types';
|
|
2
|
+
/** An export's options with their defaults; the hooks, the sheet and the file name stay optional. */
|
|
3
|
+
export interface ResolvedExport extends Required<Pick<ExportOptions, 'columns' | 'rowNumbers' | 'groupRows' | 'pinnedRows' | 'groupSeparator' | 'delimiter' | 'quote' | 'lineEnding' | 'bom' | 'escapeFormulas' | 'freeze' | 'table'>>, Pick<ExportOptions, 'sheetName' | 'fileName' | 'value' | 'detail' | 'header' | 'confirm' | 'progress' | 'write' | 'stream'> {
|
|
4
|
+
/** `'row'`: `rows: 'selection'` resolved to its one row, `row` (`resolveSelection`). */
|
|
5
|
+
rows: NonNullable<ExportOptions['rows']> | 'row';
|
|
6
|
+
/** The row `rows: 'selection'` falls back to: the request's `row`, else (−1) the focused cell's. */
|
|
7
|
+
row: number;
|
|
8
|
+
/** `headers` for this export's format: a function's answer. */
|
|
9
|
+
headers: ExportHeaders;
|
|
10
|
+
format: ExportFormat;
|
|
11
|
+
signal: AbortSignal | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** The grid's export defaults: `true` and `undefined` are none, `false` turns exporting off (null). */
|
|
14
|
+
export declare function gridExportOptions(option: GridOptions['export']): ExportOptions | null;
|
|
15
|
+
/**
|
|
16
|
+
* The request's fields over the grid's, field by field, then the defaults. The delimiter of a `'tsv'` export is a
|
|
17
|
+
* tab unless the request itself names one: the grid's `delimiter` is for CSV.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveExport(defaults: ExportOptions, request: ExportRequest): ResolvedExport;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TableHost } from '../table/host';
|
|
2
|
+
import type { TableJob } from '../table/job';
|
|
3
|
+
import { type TableWalk, type Take } from '../table/takes';
|
|
4
|
+
import type { ExportSize } from '../types';
|
|
5
|
+
import type { ExportCol } from './columns';
|
|
6
|
+
import type { ResolvedExport } from './options';
|
|
7
|
+
/** Console hint (developer-facing, English). */
|
|
8
|
+
export declare const MOVED_HINT = "InGrid: the rows changed while an export read or built them; the export was cancelled.";
|
|
9
|
+
export interface ExportPlan {
|
|
10
|
+
size: ExportSize;
|
|
11
|
+
take: Take;
|
|
12
|
+
/** Rows written beside the take's: `rows: 'all'`'s pinned rows; 0 without them. */
|
|
13
|
+
sectionRows: number;
|
|
14
|
+
/** A tree view (the group column shows a label field). */
|
|
15
|
+
tree: boolean;
|
|
16
|
+
/** The grouped fields of a grouped view; 0 for flat views and trees. */
|
|
17
|
+
groupLevels: number;
|
|
18
|
+
/** The walks, in order; ends early when the job is cancelled. Sets `job.liveUpTo` while live rows are walked. */
|
|
19
|
+
segments(job: TableJob): AsyncGenerator<ExportSegment, void>;
|
|
20
|
+
}
|
|
21
|
+
/** One walk of an export's rows. */
|
|
22
|
+
export interface ExportSegment extends TableWalk {
|
|
23
|
+
/** Another segment follows: a flat server view's windows but the last (the progress after each). */
|
|
24
|
+
more?: true;
|
|
25
|
+
/**
|
|
26
|
+
* Row numbers from the display row where the row has one (`rows: 'selected'`, `'ranges'`, `'selection'`: the numbers
|
|
27
|
+
* the grid draws), the walk position for a row inside a closed group; without it, the walk position.
|
|
28
|
+
*/
|
|
29
|
+
displayNumbers?: true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `rows: 'selection'` resolved: the ranges when they cover more than one cell, else the selected rows when the
|
|
33
|
+
* filters keep any, else one row — the request's `row`, else the focused cell's (`'row'`, −1: none, nothing is
|
|
34
|
+
* exported). Other modes as they are.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveSelection(host: TableHost & {
|
|
37
|
+
focusedRow(): number;
|
|
38
|
+
}, o: ResolvedExport): ResolvedExport;
|
|
39
|
+
/**
|
|
40
|
+
* The plan of an export over `cols` (the row-number column first when exported); null when there is nothing to walk —
|
|
41
|
+
* no exported column, nothing selected, no range: the file gets its header rows only.
|
|
42
|
+
*/
|
|
43
|
+
export declare function planExport(host: TableHost, o: ResolvedExport, cols: readonly ExportCol[], fileName: string): ExportPlan | null;
|