@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,53 @@
|
|
|
1
|
+
import type { ColumnDefaults, ColumnNode, DetailOptions, DetailRenderer, DetailRowContext } from '../types';
|
|
2
|
+
/** Default width of the toggle column `ig:detail`. */
|
|
3
|
+
export declare const DETAIL_TOGGLE_WIDTH = 28;
|
|
4
|
+
/** `GridOptions.detail` after defaults. */
|
|
5
|
+
export interface ResolvedDetail {
|
|
6
|
+
/** Null: every loaded data row. */
|
|
7
|
+
master: ((ctx: DetailRowContext) => boolean) | null;
|
|
8
|
+
openByDefault: boolean | ((ctx: DetailRowContext) => boolean);
|
|
9
|
+
toggle: 'column' | 'cells';
|
|
10
|
+
toggleWidth: number;
|
|
11
|
+
grid: DetailOptions['grid'] | null;
|
|
12
|
+
renderer: DetailRenderer | null;
|
|
13
|
+
height: number | 'auto' | ((ctx: DetailRowContext) => number);
|
|
14
|
+
minHeight: number;
|
|
15
|
+
/** Null: 400 for the built-in grid, none for custom content (`termOf`); Infinity: none for either. */
|
|
16
|
+
maxHeight: number | null;
|
|
17
|
+
keep: number;
|
|
18
|
+
refresh: 'rows' | 'all' | 'none';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the option: `undefined` → null (off). `toggleColumns`: some column sets `ColumnDef.detailToggle` (the default
|
|
22
|
+
* toggle is then `'cells'`). A size that is not a finite number of at least 0 takes its default (a fixed `height`:
|
|
23
|
+
* `'auto'`) — except `maxHeight` and `keep`, where `Infinity` means no cap and every detail kept; a negative `keep` is
|
|
24
|
+
* 0, a `maxHeight` below `minHeight` is raised to it. Contradictions give one hint each through `warn(key, message)`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveDetail(option: DetailOptions | undefined, ctx: {
|
|
27
|
+
toggleColumns: boolean;
|
|
28
|
+
}, warn: (key: string, message: string) => void): ResolvedDetail | null;
|
|
29
|
+
/**
|
|
30
|
+
* What a new value changes now: the heights are re-placed, `keep` evicts, `master` and `toggle` ask and rebind
|
|
31
|
+
* the drawn rows' chevrons, a new `openByDefault` applies from the next ask. `content` (`grid`, `renderer`, `refresh`)
|
|
32
|
+
* applies only from the next build or refresh. `on` / `off`: detail turned on or off (no other flag then).
|
|
33
|
+
*/
|
|
34
|
+
export interface DetailDiff {
|
|
35
|
+
on: boolean;
|
|
36
|
+
off: boolean;
|
|
37
|
+
heights: boolean;
|
|
38
|
+
keep: boolean;
|
|
39
|
+
masters: boolean;
|
|
40
|
+
toggle: boolean;
|
|
41
|
+
openByDefault: boolean;
|
|
42
|
+
content: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compares two resolved values field by field: functions by identity, `grid` and `renderer` by value with their
|
|
46
|
+
* functions by identity — so an inline object re-created on every render with the same functions changes nothing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function diffDetail(a: ResolvedDetail | null, b: ResolvedDetail | null): DetailDiff;
|
|
49
|
+
/**
|
|
50
|
+
* Some column sets `ColumnDef.detailToggle`: a leaf of `nodes` or `defaults` (which reaches every data column).
|
|
51
|
+
* The group column cannot: its options have no such field.
|
|
52
|
+
*/
|
|
53
|
+
export declare function hasToggleColumns(nodes: readonly ColumnNode[], defaults?: ColumnDefaults): boolean;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type ViewportSource } from '../source';
|
|
2
|
+
import type { DetailIndex } from '../viewport/heightView';
|
|
3
|
+
import type { ResolvedDetail } from './options';
|
|
4
|
+
/**
|
|
5
|
+
* A master's identity: a client row's id, else its row object; a server row's id, else an index key — a
|
|
6
|
+
* frozen object per display index, dropped on a reset.
|
|
7
|
+
*/
|
|
8
|
+
export type RowKey = unknown;
|
|
9
|
+
/** Answer bits per key: `master` was asked; it said yes; a function `openByDefault` said open. */
|
|
10
|
+
export declare const ASKED = 1;
|
|
11
|
+
export declare const MASTER = 2;
|
|
12
|
+
export declare const OPEN = 4;
|
|
13
|
+
/**
|
|
14
|
+
* The open state: a default — false, true, or `'ask'` (a function's answer, kept per master as `OPEN`) —
|
|
15
|
+
* plus exceptions by key, and the per-key answer cache of `master`, a function `openByDefault` and a function
|
|
16
|
+
* `height` (asked once per row and data change, forgotten with the key's other answers). Only a master (an answer
|
|
17
|
+
* with `MASTER`) is ever open.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DetailState {
|
|
20
|
+
/** The current default: the option's, or `setAll`'s since. */
|
|
21
|
+
private def;
|
|
22
|
+
/** The option's default (the constructor's, else the last `setDefault`): what `clear` goes back to. */
|
|
23
|
+
private base;
|
|
24
|
+
private readonly answers;
|
|
25
|
+
/** Every key's answer while there is no function to ask (`setAsking`): none is kept then. */
|
|
26
|
+
private always;
|
|
27
|
+
/** A function `height`'s answers (−1: invalid, the `'auto'` height); a key's entry goes with its answer. */
|
|
28
|
+
private readonly sizes;
|
|
29
|
+
private readonly except;
|
|
30
|
+
private ver;
|
|
31
|
+
constructor(openByDefault: boolean | 'ask');
|
|
32
|
+
/**
|
|
33
|
+
* Moves on every change of the default or an exception. Answers do not move it: a first answer arrives before its
|
|
34
|
+
* row is bound; a row asked again whose chevron or open state turned moves the controller's version.
|
|
35
|
+
*/
|
|
36
|
+
get version(): number;
|
|
37
|
+
/** The key's answer bits; 0: not asked. */
|
|
38
|
+
answer(key: RowKey): number;
|
|
39
|
+
/** Whether the key has a kept answer, also one `askAgain` stripped of `ASKED` (a non-master's is 0 then). */
|
|
40
|
+
kept(key: RowKey): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether `master` or `openByDefault` is a function to ask. Without one every key's answer is a master's,
|
|
43
|
+
* known without keeping it, so the cache does not grow with every row drawn.
|
|
44
|
+
*/
|
|
45
|
+
setAsking(asking: boolean): void;
|
|
46
|
+
/** A new answer: the key's row was asked (again), so its `height` is asked again too. */
|
|
47
|
+
remember(key: RowKey, bits: number): void;
|
|
48
|
+
forget(key: RowKey): void;
|
|
49
|
+
/**
|
|
50
|
+
* The key's row is to be asked again (`refreshDetails`, a master's data change): its `height` goes, and its
|
|
51
|
+
* answer stays without `ASKED` until the new one, so the asker can tell whether the row's chevron turned.
|
|
52
|
+
*/
|
|
53
|
+
askAgain(key: RowKey): void;
|
|
54
|
+
forgetAll(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Forgets the answers of the keys `gone` names (keys that left the data), so the cache keeps no row object
|
|
57
|
+
* the app dropped; their exceptions stay (`drop`).
|
|
58
|
+
*/
|
|
59
|
+
forgetIf(gone: (key: RowKey) => boolean): void;
|
|
60
|
+
/** A function `height`'s kept answer for the key (−1: invalid); undefined: not asked since the key's row was. */
|
|
61
|
+
height(key: RowKey): number | undefined;
|
|
62
|
+
rememberHeight(key: RowKey, h: number): void;
|
|
63
|
+
/** A new `height` (re-placed at once): every function answer is asked again. */
|
|
64
|
+
forgetHeights(): void;
|
|
65
|
+
/** A master (asked) and its exception, else the default; `bits`: an answer not kept (an export's). */
|
|
66
|
+
isOpen(key: RowKey, bits?: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Records an exception; true when the key's open state changed. A key asked and found no master takes none (false).
|
|
69
|
+
*/
|
|
70
|
+
setOpen(key: RowKey, open: boolean): boolean;
|
|
71
|
+
/** `setAllDetailsOpen`: the default becomes `open`, the exceptions go. */
|
|
72
|
+
setAll(open: boolean): void;
|
|
73
|
+
/** A new `openByDefault`: the exceptions stay; a function's kept answers apply until asked again. */
|
|
74
|
+
setDefault(def: boolean | 'ask'): void;
|
|
75
|
+
exceptions(): IterableIterator<[RowKey, boolean]>;
|
|
76
|
+
drop(key: RowKey): void;
|
|
77
|
+
/**
|
|
78
|
+
* The open state goes (`setRows`): answers, exceptions and a `setAll` default — the default is the
|
|
79
|
+
* option's again (the constructor's, else the last `setDefault`).
|
|
80
|
+
*/
|
|
81
|
+
clear(): void;
|
|
82
|
+
/** The exception, else the default (a function's: its kept answer). */
|
|
83
|
+
private wanted;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The details kept alive while hidden: at most `limit`, least recently hidden first out; the pinned one —
|
|
87
|
+
* the detail holding the focus — counts but is never evicted.
|
|
88
|
+
*/
|
|
89
|
+
export declare class KeepList<K> {
|
|
90
|
+
private limit;
|
|
91
|
+
/** Insertion order is hiding order: oldest first. */
|
|
92
|
+
private readonly order;
|
|
93
|
+
private pinned;
|
|
94
|
+
constructor(limit: number);
|
|
95
|
+
/** `key` was hidden now (it becomes the most recent); returns the evicted keys, oldest first. */
|
|
96
|
+
hidden(key: K): K[];
|
|
97
|
+
/** Drawn again: no longer kept. */
|
|
98
|
+
shown(key: K): void;
|
|
99
|
+
/** Destroyed elsewhere. */
|
|
100
|
+
delete(key: K): void;
|
|
101
|
+
pin(key: K | null): void;
|
|
102
|
+
setLimit(n: number): K[];
|
|
103
|
+
/** Oldest first. */
|
|
104
|
+
keys(): K[];
|
|
105
|
+
/** Every kept key, oldest first (`setRows`, `destroy`); the list is empty afterwards. */
|
|
106
|
+
clear(): K[];
|
|
107
|
+
private evict;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The detail term: a fixed height; a function's answer (`answer`, already checked — invalid is null: the
|
|
111
|
+
* caller takes 'auto' and reports); or 'auto' — the measured height (`measured` null → `minHeight`) up to `maxHeight`,
|
|
112
|
+
* which is 400 for the built-in grid (`custom` false) and none for custom content when unset. `minHeight` wins over
|
|
113
|
+
* `maxHeight`, as in CSS.
|
|
114
|
+
*/
|
|
115
|
+
export declare function termOf(o: ResolvedDetail, answer: number | null, measured: number | null, custom: boolean): number;
|
|
116
|
+
/**
|
|
117
|
+
* Eager placement: every exception's term written at its key's row — `term(row, key)` for an open
|
|
118
|
+
* one, 0 for a closed one and for a key asked and found no master (a row that stops being a master closes);
|
|
119
|
+
* a key not asked yet is placed, `term` asks it. Keys not displayed (`rowOf` −1) are skipped. True when a term
|
|
120
|
+
* changed.
|
|
121
|
+
*/
|
|
122
|
+
export declare function placeExplicit(state: DetailState, rowOf: (key: RowKey) => number, term: (row: number, key: RowKey) => number, index: DetailIndex): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* A row's key: client — `keyOfNode(nodeOf(row))`, null for group rows, fillers and total rows
|
|
125
|
+
* (`nodeOf` is −1); any other source — the row's id, else its index key from `indexKeys` (created on first use), null
|
|
126
|
+
* while the row is not loaded and for a group or total row. Null: the row cannot be a master.
|
|
127
|
+
*/
|
|
128
|
+
export declare function rowKeyOf(source: ViewportSource, row: number, indexKeys: Map<number, object>): RowKey | null;
|
|
129
|
+
/**
|
|
130
|
+
* The display row of `key`: client — `rowOfNode(nodeOfKey(key))`; a server source — its loaded rows by id
|
|
131
|
+
* (`forEachLoaded`); an index key — its index while `indexKeys` holds it (a scan: rows without ids are the rare case).
|
|
132
|
+
* −1 when not displayed (filtered out, in a closed group, not loaded, gone with a reset).
|
|
133
|
+
*/
|
|
134
|
+
export declare function rowOfKey(source: ViewportSource, key: RowKey, indexKeys: Map<number, object>): number;
|
|
135
|
+
/**
|
|
136
|
+
* `rowOfKey` for many keys in one go (eager placement after a batch): on a server source the first lookup by
|
|
137
|
+
* id walks the loaded rows once into an id → row map, the first by index key turns `indexKeys` around, instead of a
|
|
138
|
+
* walk per key. Valid until the source or `indexKeys` change: one placement long.
|
|
139
|
+
*/
|
|
140
|
+
export declare function keyRows(source: ViewportSource, indexKeys: Map<number, object>): (key: RowKey) => number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CellRange } from '../types';
|
|
2
|
+
import type { EditTarget } from './types';
|
|
3
|
+
/** Rows `first`..`last` of one section (the body, or a pinned one), each covering the columns `ids`, in display order. */
|
|
4
|
+
export interface Band {
|
|
5
|
+
first: number;
|
|
6
|
+
last: number;
|
|
7
|
+
ids: readonly string[];
|
|
8
|
+
pinned?: 'top' | 'bottom';
|
|
9
|
+
}
|
|
10
|
+
/** Delete, or Backspace where it clears: either with no modifier at all. */
|
|
11
|
+
export declare function isClearKey(e: KeyboardEvent, backspaceClears: boolean): boolean;
|
|
12
|
+
/** Mod+D with no Shift and no Alt. */
|
|
13
|
+
export declare function isCopyDownKey(e: KeyboardEvent): boolean;
|
|
14
|
+
/** Calls `fn` for every cell of the bands: bands in order, rows ascending, columns in display order. */
|
|
15
|
+
export declare function eachCell(bands: readonly Band[], fn: (cell: EditTarget) => void): void;
|
|
16
|
+
/**
|
|
17
|
+
* The range as one band, for copy-down (the range made first); null while it names no rows, or runs from one
|
|
18
|
+
* section into another (a copy-down down through a pinned edge has no one top row to copy).
|
|
19
|
+
*/
|
|
20
|
+
export declare function bandOf(range: CellRange | undefined, ids: readonly string[], rowCount: number): Band | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditingOptions } from '../types';
|
|
2
|
+
import type { EditHost, Editing, ResolvedEditing } from './types';
|
|
3
|
+
export declare function resolveEditing(option: EditingOptions | null | undefined): ResolvedEditing;
|
|
4
|
+
export declare function createEditing(host: EditHost): Editing;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CellEditor, ColumnDef, EditableContext, EditorName } from '../../types';
|
|
2
|
+
import type { DataType } from '../values';
|
|
3
|
+
/** The built-in editors by name. */
|
|
4
|
+
export declare const EDITORS: Partial<Record<EditorName, CellEditor>>;
|
|
5
|
+
/** A cell's editor, its `params` and whether it opens as a popup. */
|
|
6
|
+
export interface ChosenEditor {
|
|
7
|
+
editor: CellEditor;
|
|
8
|
+
params: object;
|
|
9
|
+
popup: ColumnDef['editorPopup'];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A cell's editor: the one the column names or gives, or a function's choice for the row (a falsy answer, or
|
|
13
|
+
* one without `editor`: the data type's); else the data type's. A name not registered is the text editor. Params:
|
|
14
|
+
* the choice's, else `editorParams` (an object, or a function of the row); popup: the choice's, else `editorPopup`. Null:
|
|
15
|
+
* the app's `editor` or `editorParams` function threw (reported once per function), and nothing opens, as when a `create`
|
|
16
|
+
* throws.
|
|
17
|
+
*/
|
|
18
|
+
export declare function chooseEditor(def: ColumnDef, type: DataType | undefined, ctx: EditableContext): ChosenEditor | null;
|
|
19
|
+
/**
|
|
20
|
+
* Where a chosen editor opens: in a popup over its cell (`true`, `'over'`), under it (`'under'`), or
|
|
21
|
+
* (null) in the cell. Large text is always a popup, a textarea of ten rows having no room in a cell.
|
|
22
|
+
*/
|
|
23
|
+
export declare function popupPlace(chosen: ChosenEditor): 'over' | 'under' | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GridTexts } from '../../i18n/texts';
|
|
2
|
+
import type { CellEditorContext } from '../../types';
|
|
3
|
+
import type { CloseReason, PopupHandle } from '../../ui/popup';
|
|
4
|
+
import type { DataType } from '../values';
|
|
5
|
+
export interface EditorInternals {
|
|
6
|
+
/** Read per use: the locale can change live. */
|
|
7
|
+
texts(): GridTexts;
|
|
8
|
+
/** The mark the grid's number inputs write (`Locale.decimal`). */
|
|
9
|
+
decimal(): '.' | ',';
|
|
10
|
+
/** A number as the number filter's inputs write it (the style's input format). */
|
|
11
|
+
numberText(value: number): string;
|
|
12
|
+
/** The column's data type, as the grid resolves it; date editors turn on the time for the `*Time` ones. */
|
|
13
|
+
dataType(): DataType | undefined;
|
|
14
|
+
/** The edited row back in view, before the editor handles a key itself; nothing for a popup editor. */
|
|
15
|
+
reveal(): void;
|
|
16
|
+
/**
|
|
17
|
+
* A list below `field` on the grid's popup layer, as the session's (the select editor's, `popupHost.ts`): it takes
|
|
18
|
+
* no focus, closes on a press outside it and `field`, a scroll of the body, another popup opening (`closed` says
|
|
19
|
+
* how) and the edit's end; one at a time. Null before the editor is placed (in `create`) and once the edit ended.
|
|
20
|
+
*/
|
|
21
|
+
list(content: HTMLElement, field: HTMLElement, closed?: (how: CloseReason) => void): PopupHandle | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function registerInternals(ctx: CellEditorContext, internals: EditorInternals): void;
|
|
24
|
+
/** The internals of a context the editing module made; a built-in editor is only ever given one of those. */
|
|
25
|
+
export declare function internalsOf(ctx: CellEditorContext): EditorInternals;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CellEditor } from '../../types';
|
|
2
|
+
/** `n` cut (not rounded) to `precision` digits after the point, by its shortest text, so `1.15` never becomes `1.14`. */
|
|
3
|
+
export declare function truncateTo(n: number, precision: number): number;
|
|
4
|
+
export declare const numberEditor: CellEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CellEditor, CellEditorContext, CellEditorInstance } from '../../types';
|
|
2
|
+
/** `editorParams` of the text editor and large text. */
|
|
3
|
+
export interface TextParams {
|
|
4
|
+
/** A hard stop in typing, not a red state; a longer start value is an error. */
|
|
5
|
+
maxLength?: number;
|
|
6
|
+
/** Seed from the column's `format` instead of `String`. */
|
|
7
|
+
useFormat?: boolean;
|
|
8
|
+
placeholder?: string | ((ctx: CellEditorContext) => string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A text control's editor: the text editor's input, large text's textarea. Seeded as the trigger says; a
|
|
12
|
+
* `maxLength` is a hard stop in typing; validated on every change; untouched, it hands back the start value itself.
|
|
13
|
+
*/
|
|
14
|
+
export declare function textInstance(host: HTMLElement, control: HTMLInputElement | HTMLTextAreaElement, ctx: CellEditorContext): CellEditorInstance;
|
|
15
|
+
export declare const textEditor: CellEditor;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CellRange, ColumnDef, ColumnInfo, EditOperation, FillValueContext } from '../types';
|
|
2
|
+
import type { EditHost, EditTarget } from './types';
|
|
3
|
+
import type { UndoAction } from './undo';
|
|
4
|
+
/** What a fill asks of the grid. */
|
|
5
|
+
export interface FillWriteHost extends Pick<EditHost, 'contextOf' | 'dataType' | 'decimal' | 'writeBatch'> {
|
|
6
|
+
/** The gate, per cell. */
|
|
7
|
+
canEdit(cell: EditTarget): boolean;
|
|
8
|
+
/** A column's definition; undefined: not defined. */
|
|
9
|
+
def(column: string): ColumnDef | undefined;
|
|
10
|
+
/** A column as `getColumns` reports it (for `fill.value`'s context); null: not defined. */
|
|
11
|
+
info(column: string): ColumnInfo | null;
|
|
12
|
+
/** A source cell's value; a group or total row's counts as empty: `null`. */
|
|
13
|
+
sourceValue(cell: EditTarget): unknown;
|
|
14
|
+
/** The operation's one undo step (`Operations.push`). */
|
|
15
|
+
push(action: UndoAction): void;
|
|
16
|
+
}
|
|
17
|
+
/** Where a fill writes: rows of the range's columns (a vertical fill), or columns of its rows (a horizontal one). */
|
|
18
|
+
export type FillTargets = {
|
|
19
|
+
axis: 'y';
|
|
20
|
+
rows: readonly number[];
|
|
21
|
+
} | {
|
|
22
|
+
axis: 'x';
|
|
23
|
+
columns: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export interface FillJob {
|
|
26
|
+
/** The range's body rows and its columns in display order: the source cells. */
|
|
27
|
+
rows: {
|
|
28
|
+
first: number;
|
|
29
|
+
last: number;
|
|
30
|
+
};
|
|
31
|
+
columns: readonly string[];
|
|
32
|
+
/** `'grow'`: the targets are filled from the sources; `'shrink'`: they are given up and cleared. */
|
|
33
|
+
kind: 'grow' | 'shrink';
|
|
34
|
+
/** In fill order, nearest the sources first. */
|
|
35
|
+
targets: FillTargets;
|
|
36
|
+
/** Up or left: the values run away from the sources (`fillValues`). */
|
|
37
|
+
backwards: boolean;
|
|
38
|
+
alt: boolean;
|
|
39
|
+
value: ((ctx: FillValueContext) => unknown) | undefined;
|
|
40
|
+
initial: CellRange;
|
|
41
|
+
final: CellRange;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Runs a fill as one operation: `source: 'fill'` writes, one `onEditOperation` with both ranges, one undo
|
|
45
|
+
* step that lands on its first change. Null: nothing written (or, in request mode, asked for).
|
|
46
|
+
*/
|
|
47
|
+
export declare function runFill(host: FillWriteHost, job: FillJob): EditOperation | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ResolvedCellSelection } from '../selection/options';
|
|
2
|
+
import type { RangeColumns, RangeModel } from '../selection/ranges';
|
|
3
|
+
import type { CellAddress, CellRange, CellSelectionOptions, FillValueContext } from '../types';
|
|
4
|
+
import { type FillWriteHost } from './fill';
|
|
5
|
+
import type { EditTarget } from './types';
|
|
6
|
+
/** The handle's class: `body.ts` recognises a press on it. */
|
|
7
|
+
export declare const FILL_HANDLE_CLASS = "ig-fill-handle";
|
|
8
|
+
/** The range handle's class: the same element in `'range'` mode. */
|
|
9
|
+
export declare const RANGE_HANDLE_CLASS = "ig-range-handle";
|
|
10
|
+
/** `cellSelection.fill` with its defaults. */
|
|
11
|
+
export interface ResolvedFill {
|
|
12
|
+
direction: 'xy' | 'x' | 'y';
|
|
13
|
+
clearOnShrink: boolean;
|
|
14
|
+
value: ((ctx: FillValueContext) => unknown) | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** `true` is `{}`; false and unset: no fill handle. */
|
|
17
|
+
export declare function resolveFill(option: CellSelectionOptions['fill']): ResolvedFill | null;
|
|
18
|
+
/** What the handle asks of the grid. */
|
|
19
|
+
export interface FillHandleHost extends FillWriteHost {
|
|
20
|
+
/** The resolved cell selection; null while it is off. */
|
|
21
|
+
selection(): ResolvedCellSelection | null;
|
|
22
|
+
/** The range model; null while cell selection is off. */
|
|
23
|
+
model(): RangeModel | null;
|
|
24
|
+
/** The range columns of the applied layout, display order. */
|
|
25
|
+
rangeColumns(): RangeColumns;
|
|
26
|
+
/** The body's display rows, as the range model counts them. */
|
|
27
|
+
rowCount(): number;
|
|
28
|
+
/** The pinned sections' rows, both together. */
|
|
29
|
+
pinnedRows(): number;
|
|
30
|
+
/** An edit is open or a range press runs: no handle then. */
|
|
31
|
+
blocked(): boolean;
|
|
32
|
+
/** The drawn body cell; null: none. */
|
|
33
|
+
cellElement(cell: EditTarget): HTMLElement | null;
|
|
34
|
+
/** The preview's reader for the cell bits (the range wiring's), drawn at once; null while no fill drag runs. */
|
|
35
|
+
setPreview(read: ((row: number, displayIndex: number, pinned?: 'top' | 'bottom') => number) | null): void;
|
|
36
|
+
/** The one range becomes `range`: a pointer step, with its range event. */
|
|
37
|
+
setRange(range: CellRange): void;
|
|
38
|
+
/** Runs `run` with its events held until its state changes are done. */
|
|
39
|
+
step<T>(run: () => T): T;
|
|
40
|
+
}
|
|
41
|
+
export interface FillHandle {
|
|
42
|
+
/** `'fill'`: the fill handle; `'range'`: the range handle, whose drag only resizes the range. */
|
|
43
|
+
readonly mode: 'fill' | 'range';
|
|
44
|
+
/**
|
|
45
|
+
* The range the handle shows on, as a range drag from its top-left cell (`from`) to its bottom-right one (`to`, the
|
|
46
|
+
* handle's cell); null: no handle shows.
|
|
47
|
+
*/
|
|
48
|
+
corners(): {
|
|
49
|
+
from: CellAddress;
|
|
50
|
+
to: CellAddress;
|
|
51
|
+
} | null;
|
|
52
|
+
/** After each pass, O(1): the handle in the corner cell when one shows and is drawn, else detached. */
|
|
53
|
+
afterPass(): void;
|
|
54
|
+
/** A press on the handle: a fill drag starts from the range as it is; false: none (no handle shows). */
|
|
55
|
+
begin(): boolean;
|
|
56
|
+
/** A drag step: the body cell under the pointer, and the pointer's way from the press in px, scrolling included. */
|
|
57
|
+
to(cell: CellAddress, dx: number, dy: number): void;
|
|
58
|
+
/** The release: the fill runs; `alt`: Alt was held. */
|
|
59
|
+
release(alt: boolean): void;
|
|
60
|
+
/** Escape, a lost release, a change from elsewhere: the preview goes and nothing is written. */
|
|
61
|
+
cancel(): void;
|
|
62
|
+
/** A double-click on the handle: down (right under `'x'`) to the last displayed row (column). */
|
|
63
|
+
toEnd(alt: boolean): void;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
}
|
|
66
|
+
export declare function createFillHandle(host: FillHandleHost, mode?: 'fill' | 'range'): FillHandle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fill-handle values: what the cells after a drag get, from the source cells.
|
|
3
|
+
* Pure; the caller writes or skips each cell, and a skipped cell still uses up its step.
|
|
4
|
+
*/
|
|
5
|
+
export interface FillOptions {
|
|
6
|
+
/** Alt held: a single number counts +1 per cell, several numbers repeat. */
|
|
7
|
+
alt: boolean;
|
|
8
|
+
/** Dragging up or left: the targets run away from the sources, so the order is mirrored. */
|
|
9
|
+
backwards: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The values for `count` target cells, one per cell in fill order (with `backwards`, away from the sources).
|
|
13
|
+
* Only all-number sources can make a series; anything else (text, dates, mixed) repeats in order, whatever Alt says.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fillValues(sources: readonly unknown[], count: number, opts: FillOptions): unknown[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ResolvedClipboard } from '../clipboard/options';
|
|
2
|
+
import type { CellRange } from '../types';
|
|
3
|
+
import { type Band } from './clear';
|
|
4
|
+
import type { EditHost, EditOperations, EditSession, EditTarget } from './types';
|
|
5
|
+
import { type UndoAction } from './undo';
|
|
6
|
+
/** What the operations ask of the grid (it adds the range wiring to the editing host's methods). */
|
|
7
|
+
export interface OperationsHost extends Pick<EditHost, 'options' | 'contextOf' | 'rowKey' | 'writeBatch' | 'step' | 'reveal' | 'focusPosition' | 'focusCell' | 'hint' | 'value' | 'dataType' | 'decimal' | 'columnInfo'> {
|
|
8
|
+
/** The open edit, if any. */
|
|
9
|
+
session(): EditSession | null;
|
|
10
|
+
/** The cell ranges as the app sees them. */
|
|
11
|
+
ranges(): CellRange[];
|
|
12
|
+
/** Replaces the cell ranges; nothing while cell selection is off. */
|
|
13
|
+
setRanges(ranges: readonly CellRange[]): void;
|
|
14
|
+
/** The gate for one cell: editable, and a data cell of a source that writes. */
|
|
15
|
+
canEdit(cell: EditTarget): boolean;
|
|
16
|
+
/** The union of the ranges as bands, in display order; null while cell selection is off. */
|
|
17
|
+
bands(): Band[] | null;
|
|
18
|
+
/** The range columns' ids in display order, and the body's row count: what `'all'` stands for. */
|
|
19
|
+
columnIds(): readonly string[];
|
|
20
|
+
rowCount(): number;
|
|
21
|
+
/** Some displayed column may be edited: Mod+D acts only on such a grid. */
|
|
22
|
+
anyEditable(): boolean;
|
|
23
|
+
/** The cells flash as a copy does: body rows only, `rows` ascending runs [first, last]. */
|
|
24
|
+
flash(rows: readonly {
|
|
25
|
+
first: number;
|
|
26
|
+
last: number;
|
|
27
|
+
}[], column: string): void;
|
|
28
|
+
/** The clipboard options; null while the clipboard is off. */
|
|
29
|
+
clipboard(): ResolvedClipboard | null;
|
|
30
|
+
/** A `paste` event belongs to this grid as a copy's does: its own focus, no editable element or renderer content. */
|
|
31
|
+
owns(e: Event): boolean;
|
|
32
|
+
/** The focused cell (a pinned one with its section); null without one (a header, nothing, `cellFocus: false`). */
|
|
33
|
+
focused(): EditTarget | null;
|
|
34
|
+
/** A pinned section's row count. */
|
|
35
|
+
pinnedRows(side: 'top' | 'bottom'): number;
|
|
36
|
+
/** A group or total row: a paste skips it and doesn't count it. */
|
|
37
|
+
skipsRow(row: number, pinned?: 'top' | 'bottom'): boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The operations module as the grid holds it: the contract's methods plus the grid's API and what other operations
|
|
41
|
+
* use.
|
|
42
|
+
*/
|
|
43
|
+
export interface Operations extends EditOperations {
|
|
44
|
+
/** A finished operation's step: a clear, paste, cut, fill, copy-down or bulk. A new action clears redo. */
|
|
45
|
+
push(action: UndoAction): void;
|
|
46
|
+
/** `Grid.undo` / `Grid.redo`: false when undo is off, in request mode, or there is nothing to step over. */
|
|
47
|
+
undo(source: 'key' | 'api'): boolean;
|
|
48
|
+
redo(source: 'key' | 'api'): boolean;
|
|
49
|
+
sizes(): {
|
|
50
|
+
undo: number;
|
|
51
|
+
redo: number;
|
|
52
|
+
};
|
|
53
|
+
/** True while a write should be recorded (undo on, not request mode): so a write allocates nothing otherwise. */
|
|
54
|
+
wants(): boolean;
|
|
55
|
+
/** `Grid.copyDown`: the first range's top row down. False when nothing was written. */
|
|
56
|
+
copyDown(source: 'key' | 'api'): boolean;
|
|
57
|
+
/** `editing` was set anew: a changed `undo` (off, on or another limit) clears both stacks. */
|
|
58
|
+
optionsChanged(): void;
|
|
59
|
+
/** `Grid.paste(text)`: false when nothing was written (or asked for). */
|
|
60
|
+
paste(text: string, source: 'key' | 'menu' | 'api'): boolean;
|
|
61
|
+
/** `Grid.paste()` and the menu's Paste: the text through `clipboard.read`, else `readText`. */
|
|
62
|
+
pasteRead(source: 'menu' | 'api'): Promise<boolean>;
|
|
63
|
+
/** A cut's text is written: its editable cells cleared, one operation `'cut'` keeping the ranges. */
|
|
64
|
+
cut(cells: readonly Band[], source: 'key' | 'menu' | 'api'): void;
|
|
65
|
+
/** The edit module is dropped or the grid destroyed: the `paste` listener goes. */
|
|
66
|
+
dispose(): void;
|
|
67
|
+
}
|
|
68
|
+
export declare function createOperations(host: OperationsHost): Operations;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EditOperation } from '../types';
|
|
2
|
+
import type { OperationsHost } from './operations';
|
|
3
|
+
import type { EditChange } from './types';
|
|
4
|
+
import type { UndoAction } from './undo';
|
|
5
|
+
/** What a paste asks of the grid: the operations' host, of which it reads these. */
|
|
6
|
+
export type PasteHost = Pick<OperationsHost, 'options' | 'contextOf' | 'writeBatch' | 'step' | 'hint' | 'value' | 'dataType' | 'decimal' | 'columnInfo' | 'focusPosition' | 'focusCell' | 'session' | 'ranges' | 'setRanges' | 'canEdit' | 'columnIds' | 'rowCount' | 'clipboard' | 'owns' | 'focused' | 'pinnedRows' | 'skipsRow'>;
|
|
7
|
+
/** The paste as the operations hold it. */
|
|
8
|
+
export interface Paste {
|
|
9
|
+
/** Mod+V on a cell: unless a `paste` event follows within the task, the text comes through `clipboard.read`. */
|
|
10
|
+
press(): void;
|
|
11
|
+
/** `text` pasted as one operation from `source`; false when nothing was written (or asked for). */
|
|
12
|
+
paste(text: string, source: EditOperation['source']): boolean;
|
|
13
|
+
/** `Grid.paste()` and the menu's Paste: the text read through `clipboard.read`, else `navigator.clipboard.readText`. */
|
|
14
|
+
read(source: EditOperation['source']): Promise<boolean>;
|
|
15
|
+
/** The edit module is dropped: the listener goes. */
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
18
|
+
/** What a finished paste hands back to the operations: its undo step and its flash. */
|
|
19
|
+
export interface PasteDone {
|
|
20
|
+
push(action: UndoAction): void;
|
|
21
|
+
flash(changes: readonly EditChange[]): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createPaste(host: PasteHost, done: PasteDone): Paste;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PastePlan {
|
|
2
|
+
/** The target range's size after the paste: the rectangle written, or the target's own size when it stays. */
|
|
3
|
+
rows: number;
|
|
4
|
+
columns: number;
|
|
5
|
+
/** The block repeats down / across: the target's size on that axis is a whole multiple of the block's. */
|
|
6
|
+
repeatRows: boolean;
|
|
7
|
+
repeatColumns: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* How `block` lands on a range of `target` size (`null`: no range, the focused cell). An axis repeats the block when the
|
|
11
|
+
* range's size on it is a whole multiple of the block's, else the block is placed once there, and may run past the
|
|
12
|
+
* range. The range afterwards is the rectangle written; a single-cell range stays single.
|
|
13
|
+
*/
|
|
14
|
+
export declare function planPaste(block: readonly (readonly string[])[], target: {
|
|
15
|
+
rows: number;
|
|
16
|
+
columns: number;
|
|
17
|
+
} | null): PastePlan;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CloseReason, PopupHandle, PopupLayer } from '../ui/popup';
|
|
2
|
+
/** What the popup host asks of the grid. */
|
|
3
|
+
export interface EditorPopupDeps {
|
|
4
|
+
/** The grid's popup layer (made on first use). */
|
|
5
|
+
layer(): PopupLayer;
|
|
6
|
+
/** The grid's root: a box stays inside it, and presses on the grid are heard there. */
|
|
7
|
+
root: HTMLElement;
|
|
8
|
+
/**
|
|
9
|
+
* A key inside the box goes to the app's `onCellKeyDown` for the edited cell, `editing: true`, as an in-cell editor's
|
|
10
|
+
* does. True: a listener prevented it, and the grid stays out.
|
|
11
|
+
*/
|
|
12
|
+
cellKey(e: KeyboardEvent): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* A press on `target` commits a popup editor: the grid's own empty space or a header cell — not a cell
|
|
15
|
+
* (`body.ts` takes those, block mode's refusal included), a floating filter, a header's buttons (their popup replaces
|
|
16
|
+
* the box), a scrollbar, a bar or panel, a detail's content.
|
|
17
|
+
*/
|
|
18
|
+
around(target: Element): boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface EditorBoxOptions {
|
|
21
|
+
/** The edited column (`PopupChange.column`). */
|
|
22
|
+
column: string;
|
|
23
|
+
/** The dialog's accessible name. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** `'over'`: its top-left on the cell's; `'under'`: below the cell, above it when below doesn't fit. */
|
|
26
|
+
place: 'over' | 'under';
|
|
27
|
+
/** The edited cell's box now; null while none is drawn. Read at every placement. */
|
|
28
|
+
cell(): DOMRectReadOnly | null;
|
|
29
|
+
/** Enter, Escape or Tab inside the box (Mod+Enter too): the session's answer; `'done'` prevents the key. */
|
|
30
|
+
key(e: KeyboardEvent): 'done' | 'pass';
|
|
31
|
+
/** A press on the grid's empty space or a header (a touch: at its tap). `'swallow'`: block mode refused it. */
|
|
32
|
+
press(e: MouseEvent): 'pass' | 'swallow';
|
|
33
|
+
/**
|
|
34
|
+
* The layer closed the box, not the edit: another popup replaced it, the API, an Escape in a dialog around the grid;
|
|
35
|
+
* `'api'` also when the layer couldn't open it (it is being destroyed).
|
|
36
|
+
*/
|
|
37
|
+
closed(how: CloseReason): void;
|
|
38
|
+
}
|
|
39
|
+
/** A popup editor's box. */
|
|
40
|
+
export interface EditorBox {
|
|
41
|
+
readonly el: HTMLElement;
|
|
42
|
+
readonly handle: PopupHandle;
|
|
43
|
+
/** The edit ended: the box closes, and `closed` isn't called. */
|
|
44
|
+
close(): void;
|
|
45
|
+
}
|
|
46
|
+
export interface EditorListOptions {
|
|
47
|
+
column: string;
|
|
48
|
+
label: string;
|
|
49
|
+
/** The box of a popup editor the list belongs to: it nests there, so it doesn't replace it. */
|
|
50
|
+
parent: EditorBox | null;
|
|
51
|
+
/** It closed, by whatever: a press outside it, a scroll, another popup, the edit's end. */
|
|
52
|
+
closed?: (how: CloseReason) => void;
|
|
53
|
+
}
|
|
54
|
+
export interface EditorPopups {
|
|
55
|
+
/** Opens `content` (the editor's host) in a box at its cell; focus is left to the session. */
|
|
56
|
+
open(content: HTMLElement, options: EditorBoxOptions): EditorBox;
|
|
57
|
+
/**
|
|
58
|
+
* An editor's list below `field` (the select editor's): on the layer as the session's, so it isn't "outside";
|
|
59
|
+
* it takes no focus, closes when the body scrolls, on a press outside it and field, and when another popup replaces it.
|
|
60
|
+
*/
|
|
61
|
+
list(content: HTMLElement, field: HTMLElement, options: EditorListOptions): PopupHandle;
|
|
62
|
+
}
|
|
63
|
+
export declare function createEditorPopups(deps: EditorPopupDeps): EditorPopups;
|