@svgrid/grid 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FlexRender.svelte +96 -96
- package/dist/GridMenus.svelte +205 -127
- package/dist/SvGrid.controller.svelte.d.ts +44 -1
- package/dist/SvGrid.controller.svelte.js +240 -44
- package/dist/SvGrid.css +325 -22
- package/dist/SvGrid.helpers.test.d.ts +1 -0
- package/dist/SvGrid.helpers.test.js +298 -0
- package/dist/SvGrid.svelte +729 -203
- package/dist/SvGrid.types.d.ts +91 -4
- package/dist/aligned-grids.d.ts +6 -0
- package/dist/aligned-grids.js +84 -0
- package/dist/aligned-grids.test.d.ts +1 -0
- package/dist/aligned-grids.test.js +75 -0
- package/dist/build-api.coverage.test.d.ts +20 -0
- package/dist/build-api.coverage.test.js +505 -0
- package/dist/build-api.js +61 -31
- package/dist/cell-render.test.d.ts +1 -0
- package/dist/cell-render.test.js +338 -0
- package/dist/cell-values.d.ts +1 -1
- package/dist/cell-values.js +7 -7
- package/dist/chart-export.test.d.ts +1 -0
- package/dist/chart-export.test.js +302 -0
- package/dist/chart.coverage.test.d.ts +1 -0
- package/dist/chart.coverage.test.js +748 -0
- package/dist/clipboard.js +88 -24
- package/dist/clipboard.test.d.ts +1 -0
- package/dist/clipboard.test.js +700 -0
- package/dist/collaboration.coverage.test.d.ts +1 -0
- package/dist/collaboration.coverage.test.js +200 -0
- package/dist/column-groups.d.ts +19 -0
- package/dist/column-groups.js +62 -0
- package/dist/column-groups.test.d.ts +1 -0
- package/dist/column-groups.test.js +56 -0
- package/dist/column-types.d.ts +10 -0
- package/dist/column-types.js +63 -0
- package/dist/column-types.test.d.ts +1 -0
- package/dist/column-types.test.js +62 -0
- package/dist/columns.test.d.ts +1 -0
- package/dist/columns.test.js +625 -0
- package/dist/core.d.ts +86 -1
- package/dist/core.js +2 -2
- package/dist/editing.d.ts +7 -0
- package/dist/editing.js +191 -5
- package/dist/editing.test.d.ts +1 -0
- package/dist/editing.test.js +732 -0
- package/dist/editors/cell-editors.coverage.test.d.ts +1 -0
- package/dist/editors/cell-editors.coverage.test.js +139 -0
- package/dist/facet-buckets.test.d.ts +1 -0
- package/dist/facet-buckets.test.js +296 -0
- package/dist/filter-operators.test.d.ts +1 -0
- package/dist/filter-operators.test.js +135 -0
- package/dist/hyperformula-adapter.test.d.ts +1 -0
- package/dist/hyperformula-adapter.test.js +205 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/keyboard-handlers.coverage.test.d.ts +1 -0
- package/dist/keyboard-handlers.coverage.test.js +495 -0
- package/dist/keyboard-handlers.js +7 -2
- package/dist/menus.js +1 -0
- package/dist/menus.test.d.ts +1 -0
- package/dist/menus.test.js +560 -0
- package/dist/named-views.coverage.test.d.ts +1 -0
- package/dist/named-views.coverage.test.js +180 -0
- package/dist/row-drag.d.ts +49 -0
- package/dist/row-drag.js +221 -0
- package/dist/row-drag.test.d.ts +1 -0
- package/dist/row-drag.test.js +142 -0
- package/dist/row-resize.test.d.ts +1 -0
- package/dist/row-resize.test.js +329 -0
- package/dist/scroll-sync.js +3 -0
- package/dist/scroll-sync.test.d.ts +1 -0
- package/dist/scroll-sync.test.js +290 -0
- package/dist/selection.d.ts +7 -1
- package/dist/selection.js +76 -36
- package/dist/selection.multi-range.test.d.ts +1 -0
- package/dist/selection.multi-range.test.js +55 -0
- package/dist/selection.test.d.ts +1 -0
- package/dist/selection.test.js +647 -0
- package/dist/server-data-source.coverage.test.d.ts +1 -0
- package/dist/server-data-source.coverage.test.js +154 -0
- package/dist/spreadsheet.d.ts +30 -0
- package/dist/spreadsheet.js +48 -0
- package/dist/spreadsheet.test.d.ts +1 -0
- package/dist/spreadsheet.test.js +446 -0
- package/dist/summaries.js +4 -4
- package/dist/sv-grid-scrollbar.js +13 -1
- package/dist/svgrid-wrapper.types.d.ts +19 -0
- package/dist/svgrid.behavior.test.js +20 -0
- package/dist/svgrid.interaction.test.js +31 -0
- package/dist/svgrid.new-features.wrapper.test.js +34 -2
- package/dist/test-setup.js +9 -3
- package/dist/virtualization/scroll-scaling.d.ts +17 -0
- package/dist/virtualization/scroll-scaling.js +35 -0
- package/dist/virtualization/scroll-scaling.test.js +42 -1
- package/package.json +2 -1
- package/src/FlexRender.svelte +96 -96
- package/src/GridMenus.svelte +205 -127
- package/src/SvGrid.controller.svelte.ts +204 -36
- package/src/SvGrid.css +277 -12
- package/src/SvGrid.svelte +727 -205
- package/src/SvGrid.types.ts +85 -4
- package/src/a11y.contract.test.ts +49 -49
- package/src/a11y.test.ts +59 -59
- package/src/a11y.ts +59 -59
- package/src/aligned-grids.test.ts +80 -0
- package/src/aligned-grids.ts +87 -0
- package/src/build-api.ts +43 -23
- package/src/cell-formatting.ts +169 -169
- package/src/cell-values.ts +4 -4
- package/src/clipboard.test.ts +49 -0
- package/src/clipboard.ts +51 -23
- package/src/column-groups.test.ts +59 -0
- package/src/column-groups.ts +80 -0
- package/src/column-types.test.ts +68 -0
- package/src/column-types.ts +82 -0
- package/src/core.performance.test.ts +30 -30
- package/src/core.ts +1077 -999
- package/src/createGrid.svelte.ts +42 -42
- package/src/createGrid.test.ts +10 -10
- package/src/createGridState.svelte.ts +17 -17
- package/src/editing.ts +161 -5
- package/src/flex-render.ts +3 -3
- package/src/index.ts +208 -196
- package/src/keyboard.test.ts +59 -59
- package/src/keyboard.ts +97 -97
- package/src/menus.ts +1 -0
- package/src/merge-objects.ts +48 -48
- package/src/render-component.ts +28 -28
- package/src/row-drag.test.ts +168 -0
- package/src/row-drag.ts +255 -0
- package/src/scroll-sync.ts +2 -0
- package/src/selection.multi-range.test.ts +61 -0
- package/src/selection.ts +71 -37
- package/src/spreadsheet.test.ts +46 -2
- package/src/spreadsheet.ts +58 -0
- package/src/static-functions.ts +11 -11
- package/src/subscribe.ts +38 -38
- package/src/summaries.ts +4 -4
- package/src/svgrid-wrapper.types.ts +412 -393
- package/src/svgrid.features.test.ts +157 -157
- package/src/svgrid.new-features.wrapper.test.ts +2 -2
- package/src/svgrid.wrapper.test.ts +40 -40
- package/src/virtualization/column-virtualizer.test.ts +27 -27
- package/src/virtualization/column-virtualizer.ts +30 -30
- package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
- package/src/virtualization/types.ts +30 -30
- package/src/virtualization/virtualizer.test.ts +47 -47
- package/src/virtualization/virtualizer.ts +296 -296
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { rowResize } from './row-resize';
|
|
3
|
+
const STRIP_CLASS = 'sv-grid-row-resize-handle';
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Helpers
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/** Build a host `<table>` with `rows` body rows. Each row carries the
|
|
8
|
+
* `tr.sv-grid-row` class + a `.sv-row-gutter` cell holding a
|
|
9
|
+
* `data-svgrid-row` marker, matching what SvGrid renders. Extra classes
|
|
10
|
+
* let individual tests opt rows out (header / spacer / no-gutter). */
|
|
11
|
+
function buildGrid(specs) {
|
|
12
|
+
const host = document.createElement('div');
|
|
13
|
+
const table = document.createElement('table');
|
|
14
|
+
const tbody = document.createElement('tbody');
|
|
15
|
+
const rows = [];
|
|
16
|
+
specs.forEach((spec, i) => {
|
|
17
|
+
const tr = document.createElement('tr');
|
|
18
|
+
tr.className = ['sv-grid-row', ...(spec.rowClasses ?? [])].join(' ');
|
|
19
|
+
const cell = document.createElement('td');
|
|
20
|
+
cell.className = 'sv-grid-cell';
|
|
21
|
+
if (spec.gutter !== false)
|
|
22
|
+
cell.classList.add('sv-row-gutter');
|
|
23
|
+
const marker = document.createElement('span');
|
|
24
|
+
marker.setAttribute('data-svgrid-row', String(spec.rowIndex ?? i));
|
|
25
|
+
cell.appendChild(marker);
|
|
26
|
+
tr.appendChild(cell);
|
|
27
|
+
tbody.appendChild(tr);
|
|
28
|
+
rows.push(tr);
|
|
29
|
+
});
|
|
30
|
+
table.appendChild(tbody);
|
|
31
|
+
host.appendChild(table);
|
|
32
|
+
document.body.appendChild(host);
|
|
33
|
+
return { host, rows };
|
|
34
|
+
}
|
|
35
|
+
function gutterOf(tr) {
|
|
36
|
+
return tr.querySelector('.sv-row-gutter');
|
|
37
|
+
}
|
|
38
|
+
function stripOf(tr) {
|
|
39
|
+
return tr.querySelector(`.${STRIP_CLASS}`);
|
|
40
|
+
}
|
|
41
|
+
/** Mock getBoundingClientRect so a TR reports a real height in jsdom
|
|
42
|
+
* (which otherwise returns all-zero rects). */
|
|
43
|
+
function mockRowHeight(tr, height) {
|
|
44
|
+
tr.getBoundingClientRect = () => ({ height, width: 100, top: 0, left: 0, right: 100, bottom: height, x: 0, y: 0, toJSON() { } });
|
|
45
|
+
}
|
|
46
|
+
function pointer(type, init = {}) {
|
|
47
|
+
return new PointerEvent(type, { bubbles: true, cancelable: true, pointerId: 1, ...init });
|
|
48
|
+
}
|
|
49
|
+
const hosts = [];
|
|
50
|
+
function track(host) {
|
|
51
|
+
hosts.push(host);
|
|
52
|
+
return host;
|
|
53
|
+
}
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
// jsdom lacks pointer-capture methods on elements; stub them so the action's
|
|
56
|
+
// try/catch wrapped calls have something to invoke.
|
|
57
|
+
if (!HTMLElement.prototype.setPointerCapture) {
|
|
58
|
+
HTMLElement.prototype.setPointerCapture = function () { };
|
|
59
|
+
}
|
|
60
|
+
if (!HTMLElement.prototype.releasePointerCapture) {
|
|
61
|
+
HTMLElement.prototype.releasePointerCapture = function () { };
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
while (hosts.length)
|
|
66
|
+
hosts.pop().remove();
|
|
67
|
+
document.body.innerHTML = '';
|
|
68
|
+
document.body.style.cursor = '';
|
|
69
|
+
});
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// decorate()
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
describe('rowResize - strip injection', () => {
|
|
74
|
+
it('injects a resize strip into every gutter cell', () => {
|
|
75
|
+
const { host, rows } = buildGrid([{}, {}, {}]);
|
|
76
|
+
track(host);
|
|
77
|
+
const action = rowResize(host, { onResize: vi.fn() });
|
|
78
|
+
for (const tr of rows) {
|
|
79
|
+
const strip = stripOf(tr);
|
|
80
|
+
expect(strip).not.toBeNull();
|
|
81
|
+
expect(strip.getAttribute('role')).toBe('separator');
|
|
82
|
+
expect(strip.getAttribute('aria-orientation')).toBe('horizontal');
|
|
83
|
+
expect(strip.getAttribute('aria-label')).toBe('Resize row');
|
|
84
|
+
expect(strip.style.cursor).toBe('row-resize');
|
|
85
|
+
}
|
|
86
|
+
// Gutter cells become a positioning context with visible overflow.
|
|
87
|
+
expect(gutterOf(rows[0]).style.position).toBe('relative');
|
|
88
|
+
expect(gutterOf(rows[0]).style.overflow).toBe('visible');
|
|
89
|
+
action.destroy();
|
|
90
|
+
});
|
|
91
|
+
it('does not double-inject a strip on re-decorate', async () => {
|
|
92
|
+
const { host, rows } = buildGrid([{}]);
|
|
93
|
+
track(host);
|
|
94
|
+
const action = rowResize(host, { onResize: vi.fn() });
|
|
95
|
+
expect(rows[0].querySelectorAll(`.${STRIP_CLASS}`).length).toBe(1);
|
|
96
|
+
// Trigger the MutationObserver by appending an unrelated node.
|
|
97
|
+
gutterOf(rows[0]).appendChild(document.createElement('span'));
|
|
98
|
+
await Promise.resolve();
|
|
99
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
100
|
+
expect(rows[0].querySelectorAll(`.${STRIP_CLASS}`).length).toBe(1);
|
|
101
|
+
action.destroy();
|
|
102
|
+
});
|
|
103
|
+
it('skips header rows, spacer rows, and rows without a gutter cell', () => {
|
|
104
|
+
const { host, rows } = buildGrid([
|
|
105
|
+
{ rowClasses: ['sv-grid-header-row'] },
|
|
106
|
+
{ rowClasses: ['sv-grid-row-spacer'] },
|
|
107
|
+
{ gutter: false },
|
|
108
|
+
{}, // normal row gets a strip
|
|
109
|
+
]);
|
|
110
|
+
track(host);
|
|
111
|
+
const action = rowResize(host, { onResize: vi.fn() });
|
|
112
|
+
expect(stripOf(rows[0])).toBeNull();
|
|
113
|
+
expect(stripOf(rows[1])).toBeNull();
|
|
114
|
+
expect(stripOf(rows[2])).toBeNull();
|
|
115
|
+
expect(stripOf(rows[3])).not.toBeNull();
|
|
116
|
+
action.destroy();
|
|
117
|
+
});
|
|
118
|
+
it('does not override an already-positioned gutter cell', () => {
|
|
119
|
+
const { host, rows } = buildGrid([{}]);
|
|
120
|
+
track(host);
|
|
121
|
+
gutterOf(rows[0]).style.position = 'sticky';
|
|
122
|
+
const action = rowResize(host, { onResize: vi.fn() });
|
|
123
|
+
expect(gutterOf(rows[0]).style.position).toBe('sticky');
|
|
124
|
+
action.destroy();
|
|
125
|
+
});
|
|
126
|
+
it('injects no strips when created disabled', () => {
|
|
127
|
+
const { host, rows } = buildGrid([{}, {}]);
|
|
128
|
+
track(host);
|
|
129
|
+
const action = rowResize(host, { onResize: vi.fn(), disabled: true });
|
|
130
|
+
expect(stripOf(rows[0])).toBeNull();
|
|
131
|
+
expect(stripOf(rows[1])).toBeNull();
|
|
132
|
+
action.destroy();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
// Drag lifecycle
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
describe('rowResize - drag', () => {
|
|
139
|
+
it('reports the new height on pointerup and fires move callbacks', () => {
|
|
140
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
141
|
+
track(host);
|
|
142
|
+
mockRowHeight(rows[0], 32);
|
|
143
|
+
const onResize = vi.fn();
|
|
144
|
+
const onResizeMove = vi.fn();
|
|
145
|
+
const action = rowResize(host, { onResize, onResizeMove });
|
|
146
|
+
const strip = stripOf(rows[0]);
|
|
147
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 100 }));
|
|
148
|
+
expect(strip.classList.contains('is-resizing')).toBe(true);
|
|
149
|
+
expect(document.body.style.cursor).toBe('row-resize');
|
|
150
|
+
// Drag down 20px -> 52.
|
|
151
|
+
window.dispatchEvent(pointer('pointermove', { clientY: 120 }));
|
|
152
|
+
expect(onResizeMove).toHaveBeenLastCalledWith(0, 52);
|
|
153
|
+
expect(rows[0].style.height).toBe('52px');
|
|
154
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 120 }));
|
|
155
|
+
expect(onResize).toHaveBeenCalledWith(0, 52);
|
|
156
|
+
expect(strip.classList.contains('is-resizing')).toBe(false);
|
|
157
|
+
expect(document.body.style.cursor).toBe('');
|
|
158
|
+
action.destroy();
|
|
159
|
+
});
|
|
160
|
+
it('clamps the height to the min bound', () => {
|
|
161
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
162
|
+
track(host);
|
|
163
|
+
mockRowHeight(rows[0], 32);
|
|
164
|
+
const onResize = vi.fn();
|
|
165
|
+
const action = rowResize(host, { onResize, min: 24 });
|
|
166
|
+
const strip = stripOf(rows[0]);
|
|
167
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 100 }));
|
|
168
|
+
// Drag far up -> would be negative, clamps to 24.
|
|
169
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 0 }));
|
|
170
|
+
expect(onResize).toHaveBeenCalledWith(0, 24);
|
|
171
|
+
action.destroy();
|
|
172
|
+
});
|
|
173
|
+
it('clamps the height to the max bound', () => {
|
|
174
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
175
|
+
track(host);
|
|
176
|
+
mockRowHeight(rows[0], 32);
|
|
177
|
+
const onResize = vi.fn();
|
|
178
|
+
const action = rowResize(host, { onResize, max: 50 });
|
|
179
|
+
const strip = stripOf(rows[0]);
|
|
180
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 100 }));
|
|
181
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 1000 }));
|
|
182
|
+
expect(onResize).toHaveBeenCalledWith(0, 50);
|
|
183
|
+
action.destroy();
|
|
184
|
+
});
|
|
185
|
+
it('works without an onResizeMove callback (optional)', () => {
|
|
186
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
187
|
+
track(host);
|
|
188
|
+
mockRowHeight(rows[0], 30);
|
|
189
|
+
const onResize = vi.fn();
|
|
190
|
+
const action = rowResize(host, { onResize });
|
|
191
|
+
const strip = stripOf(rows[0]);
|
|
192
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 50 }));
|
|
193
|
+
expect(() => window.dispatchEvent(pointer('pointermove', { clientY: 60 }))).not.toThrow();
|
|
194
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 60 }));
|
|
195
|
+
expect(onResize).toHaveBeenCalledWith(0, 40);
|
|
196
|
+
action.destroy();
|
|
197
|
+
});
|
|
198
|
+
it('ignores pointermove / pointerup when no drag is active', () => {
|
|
199
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
200
|
+
track(host);
|
|
201
|
+
const onResize = vi.fn();
|
|
202
|
+
const onResizeMove = vi.fn();
|
|
203
|
+
const action = rowResize(host, { onResize, onResizeMove });
|
|
204
|
+
// No pointerdown first - listeners were only attached on down, so these
|
|
205
|
+
// shouldn't do anything even if dispatched.
|
|
206
|
+
window.dispatchEvent(pointer('pointermove', { clientY: 10 }));
|
|
207
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 10 }));
|
|
208
|
+
expect(onResize).not.toHaveBeenCalled();
|
|
209
|
+
expect(onResizeMove).not.toHaveBeenCalled();
|
|
210
|
+
action.destroy();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
// pointerdown guards
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
describe('rowResize - pointerdown guards', () => {
|
|
217
|
+
it('ignores pointerdown when disabled', () => {
|
|
218
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
219
|
+
track(host);
|
|
220
|
+
mockRowHeight(rows[0], 32);
|
|
221
|
+
const onResize = vi.fn();
|
|
222
|
+
// Start enabled so a strip exists, then disable via update.
|
|
223
|
+
const action = rowResize(host, { onResize });
|
|
224
|
+
const strip = stripOf(rows[0]);
|
|
225
|
+
action.update({ onResize, disabled: true });
|
|
226
|
+
// update removes strips, but dispatch on the (now-detached) strip anyway:
|
|
227
|
+
// even if it were still in the DOM, current.disabled short-circuits.
|
|
228
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 10 }));
|
|
229
|
+
window.dispatchEvent(pointer('pointerup', { clientY: 50 }));
|
|
230
|
+
expect(onResize).not.toHaveBeenCalled();
|
|
231
|
+
action.destroy();
|
|
232
|
+
});
|
|
233
|
+
it('ignores pointerdown on a non-strip target', () => {
|
|
234
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
235
|
+
track(host);
|
|
236
|
+
const onResize = vi.fn();
|
|
237
|
+
const action = rowResize(host, { onResize });
|
|
238
|
+
gutterOf(rows[0]).dispatchEvent(pointer('pointerdown', { clientY: 10 }));
|
|
239
|
+
expect(document.body.style.cursor).toBe('');
|
|
240
|
+
action.destroy();
|
|
241
|
+
});
|
|
242
|
+
it('ignores a strip whose row has a non-finite row index', () => {
|
|
243
|
+
const { host, rows } = buildGrid([{}]);
|
|
244
|
+
track(host);
|
|
245
|
+
// Remove the data-svgrid-row marker so rowIndexOf returns NaN.
|
|
246
|
+
rows[0].querySelector('[data-svgrid-row]').removeAttribute('data-svgrid-row');
|
|
247
|
+
const onResize = vi.fn();
|
|
248
|
+
const action = rowResize(host, { onResize });
|
|
249
|
+
const strip = stripOf(rows[0]);
|
|
250
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 10 }));
|
|
251
|
+
expect(document.body.style.cursor).toBe('');
|
|
252
|
+
expect(strip.classList.contains('is-resizing')).toBe(false);
|
|
253
|
+
action.destroy();
|
|
254
|
+
});
|
|
255
|
+
it('ignores a strip not inside a tr.sv-grid-row', () => {
|
|
256
|
+
const host = track(document.createElement('div'));
|
|
257
|
+
document.body.appendChild(host);
|
|
258
|
+
// A loose strip with no matching ancestor row.
|
|
259
|
+
const strip = document.createElement('div');
|
|
260
|
+
strip.className = STRIP_CLASS;
|
|
261
|
+
host.appendChild(strip);
|
|
262
|
+
const onResize = vi.fn();
|
|
263
|
+
const action = rowResize(host, { onResize });
|
|
264
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 10 }));
|
|
265
|
+
expect(document.body.style.cursor).toBe('');
|
|
266
|
+
action.destroy();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// update() + destroy()
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
describe('rowResize - update + destroy', () => {
|
|
273
|
+
it('removes strips when toggled to disabled and restores when re-enabled', () => {
|
|
274
|
+
const { host, rows } = buildGrid([{}, {}]);
|
|
275
|
+
track(host);
|
|
276
|
+
const onResize = vi.fn();
|
|
277
|
+
const action = rowResize(host, { onResize, disabled: false });
|
|
278
|
+
expect(stripOf(rows[0])).not.toBeNull();
|
|
279
|
+
action.update({ onResize, disabled: true });
|
|
280
|
+
expect(stripOf(rows[0])).toBeNull();
|
|
281
|
+
expect(stripOf(rows[1])).toBeNull();
|
|
282
|
+
action.update({ onResize, disabled: false });
|
|
283
|
+
expect(stripOf(rows[0])).not.toBeNull();
|
|
284
|
+
action.destroy();
|
|
285
|
+
});
|
|
286
|
+
it('does not repaint when disabled flag is unchanged on update', () => {
|
|
287
|
+
const { host, rows } = buildGrid([{}]);
|
|
288
|
+
track(host);
|
|
289
|
+
const action = rowResize(host, { onResize: vi.fn() });
|
|
290
|
+
const firstStrip = stripOf(rows[0]);
|
|
291
|
+
// Same disabled value -> decorate is NOT called, strip stays the same node.
|
|
292
|
+
action.update({ onResize: vi.fn() });
|
|
293
|
+
expect(stripOf(rows[0])).toBe(firstStrip);
|
|
294
|
+
action.destroy();
|
|
295
|
+
});
|
|
296
|
+
it('destroy removes all strips and detaches listeners', () => {
|
|
297
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
298
|
+
track(host);
|
|
299
|
+
mockRowHeight(rows[0], 32);
|
|
300
|
+
const onResize = vi.fn();
|
|
301
|
+
const action = rowResize(host, { onResize });
|
|
302
|
+
expect(stripOf(rows[0])).not.toBeNull();
|
|
303
|
+
action.destroy();
|
|
304
|
+
expect(stripOf(rows[0])).toBeNull();
|
|
305
|
+
// After destroy the pointerdown listener is gone; re-create a strip
|
|
306
|
+
// manually and confirm no drag starts.
|
|
307
|
+
const strip = document.createElement('div');
|
|
308
|
+
strip.className = STRIP_CLASS;
|
|
309
|
+
gutterOf(rows[0]).appendChild(strip);
|
|
310
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 10 }));
|
|
311
|
+
expect(document.body.style.cursor).toBe('');
|
|
312
|
+
});
|
|
313
|
+
it('uses default min=20 / max=320 when bounds are omitted', () => {
|
|
314
|
+
const { host, rows } = buildGrid([{ rowIndex: 0 }]);
|
|
315
|
+
track(host);
|
|
316
|
+
mockRowHeight(rows[0], 100);
|
|
317
|
+
const onResize = vi.fn();
|
|
318
|
+
const action = rowResize(host, { onResize });
|
|
319
|
+
const strip = stripOf(rows[0]);
|
|
320
|
+
strip.dispatchEvent(pointer('pointerdown', { clientY: 0 }));
|
|
321
|
+
// Drag way past max -> clamps to 320.
|
|
322
|
+
window.dispatchEvent(pointer('pointermove', { clientY: 10000 }));
|
|
323
|
+
expect(rows[0].style.height).toBe('320px');
|
|
324
|
+
// Drag way below min -> clamps to 20.
|
|
325
|
+
window.dispatchEvent(pointer('pointerup', { clientY: -10000 }));
|
|
326
|
+
expect(onResize).toHaveBeenCalledWith(0, 20);
|
|
327
|
+
action.destroy();
|
|
328
|
+
});
|
|
329
|
+
});
|
package/dist/scroll-sync.js
CHANGED
|
@@ -64,6 +64,9 @@ export function createScrollSync(ctx) {
|
|
|
64
64
|
if (ctx.columnMenuFor || ctx.operatorMenuFor)
|
|
65
65
|
ctx.closeMenus();
|
|
66
66
|
scheduleScrollSync(container.scrollTop, container.scrollLeft);
|
|
67
|
+
// Mirror horizontal scroll to any aligned grids in the same group.
|
|
68
|
+
if (ctx.props.alignedGridGroup != null)
|
|
69
|
+
ctx.broadcastAlignedScroll(container.scrollLeft);
|
|
67
70
|
if (ctx.props.onScrollBottomReached) {
|
|
68
71
|
const { scrollTop, scrollHeight, clientHeight } = container;
|
|
69
72
|
const atBottom = scrollTop + clientHeight >= scrollHeight - 32;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { createScrollSync } from './scroll-sync';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Fake controller `ctx` for the scroll-sync handlers. As with the other
|
|
5
|
+
// controller-slice tests, the handlers read/write everything through `ctx`,
|
|
6
|
+
// so a hand-rolled stub drives every branch. Where the handler reads real DOM
|
|
7
|
+
// geometry (tooltip placement, scroll offsets) we build genuine elements and
|
|
8
|
+
// stub getBoundingClientRect / scroll metrics.
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
function makeCtx(overrides = {}) {
|
|
11
|
+
const ctx = {
|
|
12
|
+
tooltip: null,
|
|
13
|
+
tooltipTimer: null,
|
|
14
|
+
scrollSyncRaf: null,
|
|
15
|
+
scrollVersion: 0,
|
|
16
|
+
pendingScrollTop: 0,
|
|
17
|
+
pendingScrollLeft: 0,
|
|
18
|
+
rowVirtualizationEnabled: false,
|
|
19
|
+
columnVirtualizationEnabled: false,
|
|
20
|
+
scrollBottomArmed: true,
|
|
21
|
+
columnMenuFor: null,
|
|
22
|
+
operatorMenuFor: null,
|
|
23
|
+
closeMenus: vi.fn(),
|
|
24
|
+
domToLogicalRowOffset: (n) => n,
|
|
25
|
+
virtualizer: { setScrollOffset: vi.fn() },
|
|
26
|
+
columnVirtualizer: { setHorizontalOffset: vi.fn() },
|
|
27
|
+
props: {},
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
return ctx;
|
|
31
|
+
}
|
|
32
|
+
const syncFor = (overrides) => {
|
|
33
|
+
const ctx = makeCtx(overrides);
|
|
34
|
+
return { ctx, ss: createScrollSync(ctx) };
|
|
35
|
+
};
|
|
36
|
+
describe('showTooltipFor / hideTooltip', () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
vi.useFakeTimers();
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
vi.useRealTimers();
|
|
42
|
+
});
|
|
43
|
+
function anchorEl(rect) {
|
|
44
|
+
const el = document.createElement('div');
|
|
45
|
+
el.getBoundingClientRect = () => ({ left: 0, right: 0, top: 0, bottom: 0, width: 0, height: 0, x: 0, y: 0, ...rect });
|
|
46
|
+
return el;
|
|
47
|
+
}
|
|
48
|
+
it('does nothing when there is no text', () => {
|
|
49
|
+
const { ctx, ss } = syncFor();
|
|
50
|
+
ss.showTooltipFor(anchorEl({}), '');
|
|
51
|
+
expect(ctx.tooltipTimer).toBeNull();
|
|
52
|
+
vi.runAllTimers();
|
|
53
|
+
expect(ctx.tooltip).toBeNull();
|
|
54
|
+
});
|
|
55
|
+
it('schedules a tooltip after the debounce, positioned below the anchor', () => {
|
|
56
|
+
const { ctx, ss } = syncFor();
|
|
57
|
+
// Anchor near the top of a tall viewport -> tooltip appears below.
|
|
58
|
+
vi.stubGlobal('innerWidth', 1000);
|
|
59
|
+
vi.stubGlobal('innerHeight', 800);
|
|
60
|
+
const el = anchorEl({ left: 100, right: 140, top: 50, bottom: 70 });
|
|
61
|
+
ss.showTooltipFor(el, 'hello');
|
|
62
|
+
expect(ctx.tooltipTimer).not.toBeNull();
|
|
63
|
+
expect(ctx.tooltip).toBeNull(); // not yet flushed
|
|
64
|
+
vi.advanceTimersByTime(250);
|
|
65
|
+
expect(ctx.tooltip).toEqual({
|
|
66
|
+
text: 'hello',
|
|
67
|
+
x: 106, // left + 6, within clamp range
|
|
68
|
+
y: 76, // bottom + 6 since "below"
|
|
69
|
+
below: true,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
it('flips above the anchor when there is no room below', () => {
|
|
73
|
+
const { ctx, ss } = syncFor();
|
|
74
|
+
vi.stubGlobal('innerWidth', 1000);
|
|
75
|
+
vi.stubGlobal('innerHeight', 200);
|
|
76
|
+
// bottom + 64 is NOT < 200, so the tooltip renders above.
|
|
77
|
+
const el = anchorEl({ left: 100, right: 140, top: 150, bottom: 170 });
|
|
78
|
+
ss.showTooltipFor(el, 'world');
|
|
79
|
+
vi.advanceTimersByTime(250);
|
|
80
|
+
expect(ctx.tooltip.below).toBe(false);
|
|
81
|
+
expect(ctx.tooltip.y).toBe(144); // top - 6
|
|
82
|
+
});
|
|
83
|
+
it('clamps x so a wide tooltip stays inside the viewport', () => {
|
|
84
|
+
const { ctx, ss } = syncFor();
|
|
85
|
+
vi.stubGlobal('innerWidth', 300);
|
|
86
|
+
vi.stubGlobal('innerHeight', 800);
|
|
87
|
+
const el = anchorEl({ left: 280, right: 300, top: 10, bottom: 30 });
|
|
88
|
+
ss.showTooltipFor(el, 'edge');
|
|
89
|
+
vi.advanceTimersByTime(250);
|
|
90
|
+
// x clamped to vw - 290 = 10.
|
|
91
|
+
expect(ctx.tooltip.x).toBe(10);
|
|
92
|
+
});
|
|
93
|
+
it('clears a pending timer before scheduling a new tooltip', () => {
|
|
94
|
+
const { ctx, ss } = syncFor();
|
|
95
|
+
const clearSpy = vi.spyOn(window, 'clearTimeout');
|
|
96
|
+
const el = anchorEl({ left: 10, right: 30, top: 10, bottom: 30 });
|
|
97
|
+
ss.showTooltipFor(el, 'first');
|
|
98
|
+
ss.showTooltipFor(el, 'second');
|
|
99
|
+
expect(clearSpy).toHaveBeenCalled();
|
|
100
|
+
clearSpy.mockRestore();
|
|
101
|
+
});
|
|
102
|
+
it('hideTooltip clears the pending timer and the tooltip', () => {
|
|
103
|
+
const { ctx, ss } = syncFor();
|
|
104
|
+
const el = anchorEl({ left: 10, right: 30, top: 10, bottom: 30 });
|
|
105
|
+
ss.showTooltipFor(el, 'gone');
|
|
106
|
+
ctx.tooltip = { text: 'x', x: 0, y: 0, below: true };
|
|
107
|
+
ss.hideTooltip();
|
|
108
|
+
expect(ctx.tooltipTimer).toBeNull();
|
|
109
|
+
expect(ctx.tooltip).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
it('hideTooltip is safe when no timer is pending', () => {
|
|
112
|
+
const { ctx, ss } = syncFor();
|
|
113
|
+
ctx.tooltip = { text: 'x', x: 0, y: 0, below: true };
|
|
114
|
+
ss.hideTooltip();
|
|
115
|
+
expect(ctx.tooltip).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('scheduleScrollSync / flushScheduledScrollSync', () => {
|
|
119
|
+
let rafCb = null;
|
|
120
|
+
let rafCalls = 0;
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
rafCb = null;
|
|
123
|
+
rafCalls = 0;
|
|
124
|
+
vi.stubGlobal('requestAnimationFrame', (cb) => {
|
|
125
|
+
rafCb = cb;
|
|
126
|
+
rafCalls += 1;
|
|
127
|
+
return 42;
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
afterEach(() => {
|
|
131
|
+
vi.unstubAllGlobals();
|
|
132
|
+
});
|
|
133
|
+
it('records the pending offsets and schedules a single rAF', () => {
|
|
134
|
+
const { ctx, ss } = syncFor();
|
|
135
|
+
ss.scheduleScrollSync(120, 45);
|
|
136
|
+
expect(ctx.pendingScrollTop).toBe(120);
|
|
137
|
+
expect(ctx.pendingScrollLeft).toBe(45);
|
|
138
|
+
expect(ctx.scrollSyncRaf).toBe(42);
|
|
139
|
+
expect(rafCalls).toBe(1);
|
|
140
|
+
});
|
|
141
|
+
it('coalesces back-to-back calls into one frame (latest position wins)', () => {
|
|
142
|
+
const { ctx, ss } = syncFor();
|
|
143
|
+
ss.scheduleScrollSync(10, 0);
|
|
144
|
+
ss.scheduleScrollSync(200, 5); // raf already pending, must not re-schedule
|
|
145
|
+
expect(rafCalls).toBe(1);
|
|
146
|
+
expect(ctx.pendingScrollTop).toBe(200);
|
|
147
|
+
expect(ctx.pendingScrollLeft).toBe(5);
|
|
148
|
+
});
|
|
149
|
+
it('flush bumps scrollVersion and clears the raf handle', () => {
|
|
150
|
+
const { ctx, ss } = syncFor();
|
|
151
|
+
ss.scheduleScrollSync(50, 50);
|
|
152
|
+
rafCb?.(0);
|
|
153
|
+
expect(ctx.scrollVersion).toBe(1);
|
|
154
|
+
expect(ctx.scrollSyncRaf).toBeNull();
|
|
155
|
+
});
|
|
156
|
+
it('flush pushes the row offset through domToLogicalRowOffset when row virtualization is on', () => {
|
|
157
|
+
const setScrollOffset = vi.fn();
|
|
158
|
+
const { ss } = syncFor({
|
|
159
|
+
rowVirtualizationEnabled: true,
|
|
160
|
+
domToLogicalRowOffset: (n) => n * 2,
|
|
161
|
+
virtualizer: { setScrollOffset },
|
|
162
|
+
});
|
|
163
|
+
ss.scheduleScrollSync(30, 0);
|
|
164
|
+
rafCb?.(0);
|
|
165
|
+
expect(setScrollOffset).toHaveBeenCalledWith(60);
|
|
166
|
+
});
|
|
167
|
+
it('flush pushes the horizontal offset when column virtualization is on', () => {
|
|
168
|
+
const setHorizontalOffset = vi.fn();
|
|
169
|
+
const { ss } = syncFor({
|
|
170
|
+
columnVirtualizationEnabled: true,
|
|
171
|
+
columnVirtualizer: { setHorizontalOffset },
|
|
172
|
+
});
|
|
173
|
+
ss.scheduleScrollSync(0, 88);
|
|
174
|
+
rafCb?.(0);
|
|
175
|
+
expect(setHorizontalOffset).toHaveBeenCalledWith(88);
|
|
176
|
+
});
|
|
177
|
+
it('flush skips both virtualizers when neither is enabled', () => {
|
|
178
|
+
const { ctx, ss } = syncFor();
|
|
179
|
+
ss.scheduleScrollSync(5, 5);
|
|
180
|
+
rafCb?.(0);
|
|
181
|
+
expect(ctx.virtualizer.setScrollOffset).not.toHaveBeenCalled();
|
|
182
|
+
expect(ctx.columnVirtualizer.setHorizontalOffset).not.toHaveBeenCalled();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
describe('onBodyScroll', () => {
|
|
186
|
+
let rafCb = null;
|
|
187
|
+
beforeEach(() => {
|
|
188
|
+
rafCb = null;
|
|
189
|
+
vi.stubGlobal('requestAnimationFrame', (cb) => {
|
|
190
|
+
rafCb = cb;
|
|
191
|
+
return 7;
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
afterEach(() => {
|
|
195
|
+
vi.unstubAllGlobals();
|
|
196
|
+
});
|
|
197
|
+
function scrollEvent(container) {
|
|
198
|
+
return { currentTarget: container };
|
|
199
|
+
}
|
|
200
|
+
function scroller(props) {
|
|
201
|
+
const el = document.createElement('div');
|
|
202
|
+
Object.defineProperty(el, 'scrollTop', { value: props.scrollTop ?? 0, configurable: true });
|
|
203
|
+
Object.defineProperty(el, 'scrollLeft', { value: props.scrollLeft ?? 0, configurable: true });
|
|
204
|
+
Object.defineProperty(el, 'scrollHeight', { value: props.scrollHeight ?? 0, configurable: true });
|
|
205
|
+
Object.defineProperty(el, 'clientHeight', { value: props.clientHeight ?? 0, configurable: true });
|
|
206
|
+
return el;
|
|
207
|
+
}
|
|
208
|
+
it('does nothing when there is no current target', () => {
|
|
209
|
+
const { ctx, ss } = syncFor();
|
|
210
|
+
ss.onBodyScroll(scrollEvent(null));
|
|
211
|
+
expect(ctx.pendingScrollTop).toBe(0);
|
|
212
|
+
});
|
|
213
|
+
it('records the container scroll offsets via scheduleScrollSync', () => {
|
|
214
|
+
const { ctx, ss } = syncFor();
|
|
215
|
+
const el = scroller({ scrollTop: 90, scrollLeft: 12 });
|
|
216
|
+
ss.onBodyScroll(scrollEvent(el));
|
|
217
|
+
expect(ctx.pendingScrollTop).toBe(90);
|
|
218
|
+
expect(ctx.pendingScrollLeft).toBe(12);
|
|
219
|
+
expect(ctx.scrollSyncRaf).toBe(7);
|
|
220
|
+
});
|
|
221
|
+
it('closes open column/operator menus on scroll', () => {
|
|
222
|
+
const closeMenus = vi.fn();
|
|
223
|
+
const { ss } = syncFor({ columnMenuFor: 'x', closeMenus });
|
|
224
|
+
ss.onBodyScroll(scrollEvent(scroller({})));
|
|
225
|
+
expect(closeMenus).toHaveBeenCalled();
|
|
226
|
+
});
|
|
227
|
+
it('closes menus when an operator menu is open', () => {
|
|
228
|
+
const closeMenus = vi.fn();
|
|
229
|
+
const { ss } = syncFor({ operatorMenuFor: 'op', closeMenus });
|
|
230
|
+
ss.onBodyScroll(scrollEvent(scroller({})));
|
|
231
|
+
expect(closeMenus).toHaveBeenCalled();
|
|
232
|
+
});
|
|
233
|
+
it('does not close menus when none are open', () => {
|
|
234
|
+
const closeMenus = vi.fn();
|
|
235
|
+
const { ss } = syncFor({ closeMenus });
|
|
236
|
+
ss.onBodyScroll(scrollEvent(scroller({})));
|
|
237
|
+
expect(closeMenus).not.toHaveBeenCalled();
|
|
238
|
+
});
|
|
239
|
+
it('fires onScrollBottomReached once when the scroll reaches the bottom', () => {
|
|
240
|
+
const onScrollBottomReached = vi.fn();
|
|
241
|
+
const { ctx, ss } = syncFor({
|
|
242
|
+
props: { onScrollBottomReached },
|
|
243
|
+
scrollBottomArmed: true,
|
|
244
|
+
});
|
|
245
|
+
// scrollTop + clientHeight >= scrollHeight - 32 -> at bottom.
|
|
246
|
+
const el = scroller({ scrollTop: 600, clientHeight: 400, scrollHeight: 1000 });
|
|
247
|
+
ss.onBodyScroll(scrollEvent(el));
|
|
248
|
+
expect(onScrollBottomReached).toHaveBeenCalledWith({
|
|
249
|
+
scrollTop: 600,
|
|
250
|
+
scrollHeight: 1000,
|
|
251
|
+
clientHeight: 400,
|
|
252
|
+
});
|
|
253
|
+
expect(ctx.scrollBottomArmed).toBe(false); // disarmed so it won't refire
|
|
254
|
+
});
|
|
255
|
+
it('does not refire onScrollBottomReached while still at the bottom (disarmed)', () => {
|
|
256
|
+
const onScrollBottomReached = vi.fn();
|
|
257
|
+
const { ss } = syncFor({
|
|
258
|
+
props: { onScrollBottomReached },
|
|
259
|
+
scrollBottomArmed: false,
|
|
260
|
+
});
|
|
261
|
+
const el = scroller({ scrollTop: 600, clientHeight: 400, scrollHeight: 1000 });
|
|
262
|
+
ss.onBodyScroll(scrollEvent(el));
|
|
263
|
+
expect(onScrollBottomReached).not.toHaveBeenCalled();
|
|
264
|
+
});
|
|
265
|
+
it('re-arms the trigger after scrolling away from the bottom', () => {
|
|
266
|
+
const onScrollBottomReached = vi.fn();
|
|
267
|
+
const { ctx, ss } = syncFor({
|
|
268
|
+
props: { onScrollBottomReached },
|
|
269
|
+
scrollBottomArmed: false,
|
|
270
|
+
});
|
|
271
|
+
// Not at bottom: scrollTop + clientHeight < scrollHeight - 32.
|
|
272
|
+
const el = scroller({ scrollTop: 100, clientHeight: 400, scrollHeight: 1000 });
|
|
273
|
+
ss.onBodyScroll(scrollEvent(el));
|
|
274
|
+
expect(ctx.scrollBottomArmed).toBe(true);
|
|
275
|
+
expect(onScrollBottomReached).not.toHaveBeenCalled();
|
|
276
|
+
});
|
|
277
|
+
it('skips the bottom-reached logic entirely when no callback is registered', () => {
|
|
278
|
+
const { ctx, ss } = syncFor({ scrollBottomArmed: true });
|
|
279
|
+
const el = scroller({ scrollTop: 600, clientHeight: 400, scrollHeight: 1000 });
|
|
280
|
+
ss.onBodyScroll(scrollEvent(el));
|
|
281
|
+
// Armed flag is untouched when there is no callback.
|
|
282
|
+
expect(ctx.scrollBottomArmed).toBe(true);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
describe('createScrollSync wiring', () => {
|
|
286
|
+
it('exposes the documented handler surface', () => {
|
|
287
|
+
const { ss } = syncFor();
|
|
288
|
+
expect(Object.keys(ss).sort()).toEqual(['flushScheduledScrollSync', 'hideTooltip', 'onBodyScroll', 'scheduleScrollSync', 'showTooltipFor']);
|
|
289
|
+
});
|
|
290
|
+
});
|
package/dist/selection.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function createSelection<TFeatures extends TableFeatures = TableF
|
|
|
6
6
|
toggleSelectAllRows: () => void;
|
|
7
7
|
setActiveCell: (rowIndex: number, colIndex: number) => void;
|
|
8
8
|
scrollActiveCellIntoView: (rowIndex: number, colIndex: number) => void;
|
|
9
|
-
setSelection: (rowIndex: number, colIndex: number) => void;
|
|
9
|
+
setSelection: (rowIndex: number, colIndex: number, additive?: boolean) => void;
|
|
10
10
|
extendSelection: (rowIndex: number, colIndex: number) => void;
|
|
11
11
|
isCellInSelectedRange: (rowIndex: number, colIndex: number) => boolean;
|
|
12
12
|
getCellRangeEdges: (rowIndex: number, colIndex: number) => {
|
|
@@ -15,6 +15,12 @@ export declare function createSelection<TFeatures extends TableFeatures = TableF
|
|
|
15
15
|
left: boolean;
|
|
16
16
|
right: boolean;
|
|
17
17
|
} | null;
|
|
18
|
+
getSelectionRects: () => {
|
|
19
|
+
minRow: number;
|
|
20
|
+
maxRow: number;
|
|
21
|
+
minCol: number;
|
|
22
|
+
maxCol: number;
|
|
23
|
+
}[];
|
|
18
24
|
isInFillPreview: (rowIndex: number, colIndex: number) => boolean;
|
|
19
25
|
findColumnById: (columnId: string) => any;
|
|
20
26
|
onCellPointerDown: (rowIndex: number, colIndex: number, event: PointerEvent) => void;
|