@svgrid/grid 1.1.0 → 1.1.1
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/GridMenus.svelte +205 -127
- package/dist/SvGrid.controller.svelte.d.ts +44 -1
- package/dist/SvGrid.controller.svelte.js +223 -38
- package/dist/SvGrid.css +2012 -1709
- package/dist/SvGrid.helpers.test.d.ts +1 -0
- package/dist/SvGrid.helpers.test.js +298 -0
- package/dist/SvGrid.svelte +2346 -2043
- 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 +59 -29
- package/dist/cell-render.test.d.ts +1 -0
- package/dist/cell-render.test.js +338 -0
- 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 +85 -0
- 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/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/GridMenus.svelte +205 -127
- package/src/SvGrid.controller.svelte.ts +2352 -2195
- package/src/SvGrid.css +2012 -1747
- package/src/SvGrid.svelte +2346 -2047
- package/src/SvGrid.types.ts +537 -456
- package/src/aligned-grids.test.ts +80 -0
- package/src/aligned-grids.ts +87 -0
- package/src/build-api.ts +683 -663
- 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.ts +78 -0
- package/src/editing.ts +669 -513
- package/src/index.ts +12 -0
- package/src/menus.ts +1 -0
- 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 +489 -445
- package/src/spreadsheet.ts +304 -246
- package/src/svgrid-wrapper.types.ts +19 -0
- package/src/svgrid.new-features.wrapper.test.ts +2 -2
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { spreadsheetLayout, spansToMerges } from './spreadsheet';
|
|
3
|
+
// jsdom does not implement the global `CSS` object, which `findCell` uses via
|
|
4
|
+
// `CSS.escape`. Provide a minimal polyfill so the action's selector queries
|
|
5
|
+
// run. (A real browser ships CSS.escape; this is purely an env gap.)
|
|
6
|
+
if (typeof globalThis.CSS === 'undefined') {
|
|
7
|
+
// @ts-expect-error - minimal shim for the test environment
|
|
8
|
+
globalThis.CSS = { escape: (s) => s.replace(/["\\]/g, '\\$&') };
|
|
9
|
+
}
|
|
10
|
+
else if (typeof globalThis.CSS.escape !== 'function') {
|
|
11
|
+
// @ts-expect-error - augment partial CSS object
|
|
12
|
+
globalThis.CSS.escape = (s) => s.replace(/["\\]/g, '\\$&');
|
|
13
|
+
}
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Helpers
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/** Flush a queued requestAnimationFrame callback. The action batches its
|
|
18
|
+
* work into one rAF, so tests must advance a frame to observe the effect. */
|
|
19
|
+
function flushFrame() {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
// Two rAFs: the first lets any already-queued callback run, the second
|
|
22
|
+
// guarantees we resolve AFTER that callback has executed.
|
|
23
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Build a `<table>` with a header-less body of `rows` x `cols`. Each TD is
|
|
27
|
+
* tagged with `data-svgrid-row` (display index) + `data-col-id` exactly the
|
|
28
|
+
* way SvGrid emits them, which is what the layout helper queries on. */
|
|
29
|
+
function buildGrid(rows, columnOrder) {
|
|
30
|
+
const host = document.createElement('div');
|
|
31
|
+
const table = document.createElement('table');
|
|
32
|
+
const tbody = document.createElement('tbody');
|
|
33
|
+
for (let r = 0; r < rows; r += 1) {
|
|
34
|
+
const tr = document.createElement('tr');
|
|
35
|
+
for (const colId of columnOrder) {
|
|
36
|
+
const td = document.createElement('td');
|
|
37
|
+
td.setAttribute('data-svgrid-row', String(r));
|
|
38
|
+
td.setAttribute('data-col-id', colId);
|
|
39
|
+
td.textContent = `${colId}-${r}`;
|
|
40
|
+
tr.appendChild(td);
|
|
41
|
+
}
|
|
42
|
+
tbody.appendChild(tr);
|
|
43
|
+
}
|
|
44
|
+
table.appendChild(tbody);
|
|
45
|
+
host.appendChild(table);
|
|
46
|
+
document.body.appendChild(host);
|
|
47
|
+
const cellAt = (r, colId) => {
|
|
48
|
+
const el = host.querySelector(`td[data-svgrid-row="${r}"][data-col-id="${colId}"]`);
|
|
49
|
+
if (!el)
|
|
50
|
+
throw new Error(`no cell at row=${r} col=${colId}`);
|
|
51
|
+
return el;
|
|
52
|
+
};
|
|
53
|
+
return { host, cellAt };
|
|
54
|
+
}
|
|
55
|
+
let hosts = [];
|
|
56
|
+
function track(host) {
|
|
57
|
+
hosts.push(host);
|
|
58
|
+
return host;
|
|
59
|
+
}
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
hosts = [];
|
|
62
|
+
});
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
for (const h of hosts)
|
|
65
|
+
h.remove();
|
|
66
|
+
document.body.innerHTML = '';
|
|
67
|
+
});
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Merges
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
describe('spreadsheetLayout - merges', () => {
|
|
72
|
+
it('applies colspan + hides covered cells horizontally', async () => {
|
|
73
|
+
const cols = ['a', 'b', 'c'];
|
|
74
|
+
const { host, cellAt } = buildGrid(2, cols);
|
|
75
|
+
track(host);
|
|
76
|
+
const action = spreadsheetLayout(host, {
|
|
77
|
+
columnOrder: cols,
|
|
78
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2 }],
|
|
79
|
+
});
|
|
80
|
+
await flushFrame();
|
|
81
|
+
const origin = cellAt(0, 'a');
|
|
82
|
+
expect(origin.getAttribute('colspan')).toBe('2');
|
|
83
|
+
expect(origin.hasAttribute('rowspan')).toBe(false);
|
|
84
|
+
expect(origin.getAttribute('data-svgrid-sheet')).toBe('');
|
|
85
|
+
// Covered neighbour to the right is hidden + marked.
|
|
86
|
+
expect(cellAt(0, 'b').style.display).toBe('none');
|
|
87
|
+
expect(cellAt(0, 'b').getAttribute('data-svgrid-sheet')).toBe('');
|
|
88
|
+
// Untouched cells stay visible.
|
|
89
|
+
expect(cellAt(0, 'c').style.display).toBe('');
|
|
90
|
+
expect(cellAt(1, 'a').style.display).toBe('');
|
|
91
|
+
action.destroy();
|
|
92
|
+
});
|
|
93
|
+
it('applies rowspan + hides covered cells vertically', async () => {
|
|
94
|
+
const cols = ['a', 'b'];
|
|
95
|
+
const { host, cellAt } = buildGrid(3, cols);
|
|
96
|
+
track(host);
|
|
97
|
+
const action = spreadsheetLayout(host, {
|
|
98
|
+
columnOrder: cols,
|
|
99
|
+
merges: [{ rowIndex: 0, columnId: 'a', rowspan: 2 }],
|
|
100
|
+
});
|
|
101
|
+
await flushFrame();
|
|
102
|
+
const origin = cellAt(0, 'a');
|
|
103
|
+
expect(origin.getAttribute('rowspan')).toBe('2');
|
|
104
|
+
expect(origin.hasAttribute('colspan')).toBe(false);
|
|
105
|
+
expect(cellAt(1, 'a').style.display).toBe('none');
|
|
106
|
+
expect(cellAt(2, 'a').style.display).toBe(''); // outside the span
|
|
107
|
+
action.destroy();
|
|
108
|
+
});
|
|
109
|
+
it('handles a rectangular colspan + rowspan block', async () => {
|
|
110
|
+
const cols = ['a', 'b', 'c'];
|
|
111
|
+
const { host, cellAt } = buildGrid(3, cols);
|
|
112
|
+
track(host);
|
|
113
|
+
const action = spreadsheetLayout(host, {
|
|
114
|
+
columnOrder: cols,
|
|
115
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2, rowspan: 2 }],
|
|
116
|
+
});
|
|
117
|
+
await flushFrame();
|
|
118
|
+
expect(cellAt(0, 'a').getAttribute('colspan')).toBe('2');
|
|
119
|
+
expect(cellAt(0, 'a').getAttribute('rowspan')).toBe('2');
|
|
120
|
+
// All covered cells except the origin are hidden.
|
|
121
|
+
expect(cellAt(0, 'b').style.display).toBe('none');
|
|
122
|
+
expect(cellAt(1, 'a').style.display).toBe('none');
|
|
123
|
+
expect(cellAt(1, 'b').style.display).toBe('none');
|
|
124
|
+
// c column + row 2 untouched.
|
|
125
|
+
expect(cellAt(0, 'c').style.display).toBe('');
|
|
126
|
+
expect(cellAt(2, 'a').style.display).toBe('');
|
|
127
|
+
action.destroy();
|
|
128
|
+
});
|
|
129
|
+
it('clamps zero/negative span to a minimum of 1 (no colspan/rowspan attr)', async () => {
|
|
130
|
+
const cols = ['a', 'b'];
|
|
131
|
+
const { host, cellAt } = buildGrid(2, cols);
|
|
132
|
+
track(host);
|
|
133
|
+
const action = spreadsheetLayout(host, {
|
|
134
|
+
columnOrder: cols,
|
|
135
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 0, rowspan: -5 }],
|
|
136
|
+
});
|
|
137
|
+
await flushFrame();
|
|
138
|
+
const origin = cellAt(0, 'a');
|
|
139
|
+
// Clamped to 1, so no span attributes are written, but it is still marked.
|
|
140
|
+
expect(origin.hasAttribute('colspan')).toBe(false);
|
|
141
|
+
expect(origin.hasAttribute('rowspan')).toBe(false);
|
|
142
|
+
expect(origin.getAttribute('data-svgrid-sheet')).toBe('');
|
|
143
|
+
expect(cellAt(0, 'b').style.display).toBe(''); // nothing covered
|
|
144
|
+
action.destroy();
|
|
145
|
+
});
|
|
146
|
+
it('skips a merge whose columnId is not in columnOrder', async () => {
|
|
147
|
+
const cols = ['a', 'b'];
|
|
148
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
149
|
+
track(host);
|
|
150
|
+
const action = spreadsheetLayout(host, {
|
|
151
|
+
columnOrder: cols,
|
|
152
|
+
merges: [{ rowIndex: 0, columnId: 'ghost', colspan: 2 }],
|
|
153
|
+
});
|
|
154
|
+
await flushFrame();
|
|
155
|
+
expect(cellAt(0, 'a').hasAttribute('data-svgrid-sheet')).toBe(false);
|
|
156
|
+
expect(cellAt(0, 'b').style.display).toBe('');
|
|
157
|
+
action.destroy();
|
|
158
|
+
});
|
|
159
|
+
it('skips a merge whose origin cell is not rendered', async () => {
|
|
160
|
+
const cols = ['a', 'b'];
|
|
161
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
162
|
+
track(host);
|
|
163
|
+
const action = spreadsheetLayout(host, {
|
|
164
|
+
columnOrder: cols,
|
|
165
|
+
merges: [{ rowIndex: 99, columnId: 'a', colspan: 2 }],
|
|
166
|
+
});
|
|
167
|
+
await flushFrame();
|
|
168
|
+
// Nothing marked anywhere.
|
|
169
|
+
expect(host.querySelectorAll('[data-svgrid-sheet]').length).toBe(0);
|
|
170
|
+
expect(cellAt(0, 'a').style.display).toBe('');
|
|
171
|
+
action.destroy();
|
|
172
|
+
});
|
|
173
|
+
it('ignores covered cells that fall outside the columnOrder or render window', async () => {
|
|
174
|
+
const cols = ['a', 'b'];
|
|
175
|
+
// Only 1 row rendered, but ask for a colspan that runs off the column
|
|
176
|
+
// list AND a rowspan that runs off the rendered rows.
|
|
177
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
178
|
+
track(host);
|
|
179
|
+
const action = spreadsheetLayout(host, {
|
|
180
|
+
columnOrder: cols,
|
|
181
|
+
merges: [{ rowIndex: 0, columnId: 'b', colspan: 3, rowspan: 3 }],
|
|
182
|
+
});
|
|
183
|
+
await flushFrame();
|
|
184
|
+
const origin = cellAt(0, 'b');
|
|
185
|
+
expect(origin.getAttribute('colspan')).toBe('3');
|
|
186
|
+
expect(origin.getAttribute('rowspan')).toBe('3');
|
|
187
|
+
// No sibling to the right of b, and rows 1/2 don't exist - so the only
|
|
188
|
+
// marked cell is the origin itself.
|
|
189
|
+
expect(host.querySelectorAll('[data-svgrid-sheet]').length).toBe(1);
|
|
190
|
+
action.destroy();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
// Selection-edge inheritance
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
describe('spreadsheetLayout - selection edge inheritance', () => {
|
|
197
|
+
it('mirrors range-right / range-bottom / selected-range flags onto the origin', async () => {
|
|
198
|
+
const cols = ['a', 'b'];
|
|
199
|
+
const { host, cellAt } = buildGrid(2, cols);
|
|
200
|
+
track(host);
|
|
201
|
+
// Mark the far covered cell with range edge flags BEFORE applying.
|
|
202
|
+
cellAt(1, 'b').setAttribute('data-range-right', 'true');
|
|
203
|
+
cellAt(1, 'b').setAttribute('data-range-bottom', 'true');
|
|
204
|
+
cellAt(0, 'b').setAttribute('data-selected-range', 'true');
|
|
205
|
+
const action = spreadsheetLayout(host, {
|
|
206
|
+
columnOrder: cols,
|
|
207
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2, rowspan: 2 }],
|
|
208
|
+
});
|
|
209
|
+
await flushFrame();
|
|
210
|
+
const origin = cellAt(0, 'a');
|
|
211
|
+
expect(origin.classList.contains('sv-merge-edge-right')).toBe(true);
|
|
212
|
+
expect(origin.classList.contains('sv-merge-edge-bottom')).toBe(true);
|
|
213
|
+
expect(origin.classList.contains('sv-merge-in-range')).toBe(true);
|
|
214
|
+
action.destroy();
|
|
215
|
+
});
|
|
216
|
+
it('leaves edge classes off when no range flags are present', async () => {
|
|
217
|
+
const cols = ['a', 'b'];
|
|
218
|
+
const { host, cellAt } = buildGrid(2, cols);
|
|
219
|
+
track(host);
|
|
220
|
+
const action = spreadsheetLayout(host, {
|
|
221
|
+
columnOrder: cols,
|
|
222
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2, rowspan: 2 }],
|
|
223
|
+
});
|
|
224
|
+
await flushFrame();
|
|
225
|
+
const origin = cellAt(0, 'a');
|
|
226
|
+
expect(origin.classList.contains('sv-merge-edge-right')).toBe(false);
|
|
227
|
+
expect(origin.classList.contains('sv-merge-edge-bottom')).toBe(false);
|
|
228
|
+
expect(origin.classList.contains('sv-merge-in-range')).toBe(false);
|
|
229
|
+
action.destroy();
|
|
230
|
+
});
|
|
231
|
+
it('treats the origin own selected-range flag as in-range', async () => {
|
|
232
|
+
const cols = ['a'];
|
|
233
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
234
|
+
track(host);
|
|
235
|
+
cellAt(0, 'a').setAttribute('data-selected-range', 'true');
|
|
236
|
+
const action = spreadsheetLayout(host, {
|
|
237
|
+
columnOrder: cols,
|
|
238
|
+
merges: [{ rowIndex: 0, columnId: 'a' }],
|
|
239
|
+
});
|
|
240
|
+
await flushFrame();
|
|
241
|
+
expect(cellAt(0, 'a').classList.contains('sv-merge-in-range')).toBe(true);
|
|
242
|
+
action.destroy();
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// Borders
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
describe('spreadsheetLayout - borders', () => {
|
|
249
|
+
it('injects an overlay with the requested edge styles', async () => {
|
|
250
|
+
const cols = ['a'];
|
|
251
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
252
|
+
track(host);
|
|
253
|
+
const action = spreadsheetLayout(host, {
|
|
254
|
+
columnOrder: cols,
|
|
255
|
+
borders: [
|
|
256
|
+
{
|
|
257
|
+
rowIndex: 0,
|
|
258
|
+
columnId: 'a',
|
|
259
|
+
top: { width: 3, style: 'dashed', color: 'red' },
|
|
260
|
+
bottom: {}, // defaults: 2px solid currentColor
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
});
|
|
264
|
+
await flushFrame();
|
|
265
|
+
const td = cellAt(0, 'a');
|
|
266
|
+
const overlay = td.querySelector('.sv-cell-border-overlay');
|
|
267
|
+
expect(overlay).not.toBeNull();
|
|
268
|
+
expect(overlay.style.borderTop).toBe('3px dashed red');
|
|
269
|
+
// jsdom's CSSOM drops the `currentColor` keyword from the border
|
|
270
|
+
// shorthand, but the width + style survive, confirming the default
|
|
271
|
+
// (2px solid) edge was emitted.
|
|
272
|
+
expect(overlay.style.borderBottom).toContain('2px solid');
|
|
273
|
+
// No left/right set.
|
|
274
|
+
expect(overlay.style.borderLeft).toBe('');
|
|
275
|
+
expect(td.getAttribute('data-svgrid-sheet')).toBe('');
|
|
276
|
+
// The TD becomes a positioning context.
|
|
277
|
+
expect(td.style.position).toBe('relative');
|
|
278
|
+
action.destroy();
|
|
279
|
+
});
|
|
280
|
+
it('skips a border spec with no edges set (no overlay injected)', async () => {
|
|
281
|
+
const cols = ['a'];
|
|
282
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
283
|
+
track(host);
|
|
284
|
+
const action = spreadsheetLayout(host, {
|
|
285
|
+
columnOrder: cols,
|
|
286
|
+
borders: [{ rowIndex: 0, columnId: 'a' }],
|
|
287
|
+
});
|
|
288
|
+
await flushFrame();
|
|
289
|
+
expect(cellAt(0, 'a').querySelector('.sv-cell-border-overlay')).toBeNull();
|
|
290
|
+
expect(cellAt(0, 'a').hasAttribute('data-svgrid-sheet')).toBe(false);
|
|
291
|
+
action.destroy();
|
|
292
|
+
});
|
|
293
|
+
it('skips a border spec whose target cell is absent', async () => {
|
|
294
|
+
const cols = ['a'];
|
|
295
|
+
const { host } = buildGrid(1, cols);
|
|
296
|
+
track(host);
|
|
297
|
+
const action = spreadsheetLayout(host, {
|
|
298
|
+
columnOrder: cols,
|
|
299
|
+
borders: [{ rowIndex: 5, columnId: 'a', top: { width: 1 } }],
|
|
300
|
+
});
|
|
301
|
+
await flushFrame();
|
|
302
|
+
expect(host.querySelectorAll('.sv-cell-border-overlay').length).toBe(0);
|
|
303
|
+
action.destroy();
|
|
304
|
+
});
|
|
305
|
+
it('does not override an already-positioned TD', async () => {
|
|
306
|
+
const cols = ['a'];
|
|
307
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
308
|
+
track(host);
|
|
309
|
+
cellAt(0, 'a').style.position = 'absolute';
|
|
310
|
+
const action = spreadsheetLayout(host, {
|
|
311
|
+
columnOrder: cols,
|
|
312
|
+
borders: [{ rowIndex: 0, columnId: 'a', left: { color: 'blue' } }],
|
|
313
|
+
});
|
|
314
|
+
await flushFrame();
|
|
315
|
+
expect(cellAt(0, 'a').style.position).toBe('absolute');
|
|
316
|
+
action.destroy();
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
// Cleanup + update + destroy
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
describe('spreadsheetLayout - update + cleanup', () => {
|
|
323
|
+
it('clears prior decorations on the next apply (update path)', async () => {
|
|
324
|
+
const cols = ['a', 'b'];
|
|
325
|
+
const { host, cellAt } = buildGrid(2, cols);
|
|
326
|
+
track(host);
|
|
327
|
+
const action = spreadsheetLayout(host, {
|
|
328
|
+
columnOrder: cols,
|
|
329
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2 }],
|
|
330
|
+
borders: [{ rowIndex: 1, columnId: 'a', top: { width: 1 } }],
|
|
331
|
+
});
|
|
332
|
+
await flushFrame();
|
|
333
|
+
expect(cellAt(0, 'a').getAttribute('colspan')).toBe('2');
|
|
334
|
+
expect(cellAt(1, 'a').querySelector('.sv-cell-border-overlay')).not.toBeNull();
|
|
335
|
+
// Update to an empty spec - everything from the previous run is removed.
|
|
336
|
+
action.update({ columnOrder: cols, merges: [], borders: [] });
|
|
337
|
+
await flushFrame();
|
|
338
|
+
expect(cellAt(0, 'a').hasAttribute('colspan')).toBe(false);
|
|
339
|
+
expect(cellAt(0, 'b').style.display).toBe('');
|
|
340
|
+
expect(cellAt(0, 'a').hasAttribute('data-svgrid-sheet')).toBe(false);
|
|
341
|
+
expect(cellAt(1, 'a').querySelector('.sv-cell-border-overlay')).toBeNull();
|
|
342
|
+
action.destroy();
|
|
343
|
+
});
|
|
344
|
+
it('re-applies decorations when the grid body mutates (MutationObserver)', async () => {
|
|
345
|
+
const cols = ['a', 'b'];
|
|
346
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
347
|
+
track(host);
|
|
348
|
+
const action = spreadsheetLayout(host, {
|
|
349
|
+
columnOrder: cols,
|
|
350
|
+
merges: [{ rowIndex: 1, columnId: 'a', colspan: 2 }],
|
|
351
|
+
});
|
|
352
|
+
await flushFrame();
|
|
353
|
+
// Row 1 does not exist yet - nothing applied.
|
|
354
|
+
expect(host.querySelectorAll('[data-svgrid-sheet]').length).toBe(0);
|
|
355
|
+
// Simulate the grid rendering a new row -> observer schedules apply.
|
|
356
|
+
const tbody = host.querySelector('tbody');
|
|
357
|
+
const tr = document.createElement('tr');
|
|
358
|
+
for (const colId of cols) {
|
|
359
|
+
const td = document.createElement('td');
|
|
360
|
+
td.setAttribute('data-svgrid-row', '1');
|
|
361
|
+
td.setAttribute('data-col-id', colId);
|
|
362
|
+
tr.appendChild(td);
|
|
363
|
+
}
|
|
364
|
+
tbody.appendChild(tr);
|
|
365
|
+
await flushFrame();
|
|
366
|
+
await flushFrame();
|
|
367
|
+
expect(cellAt(1, 'a').getAttribute('colspan')).toBe('2');
|
|
368
|
+
action.destroy();
|
|
369
|
+
});
|
|
370
|
+
it('destroy disconnects the observer and cancels a pending frame', async () => {
|
|
371
|
+
const cols = ['a', 'b'];
|
|
372
|
+
const { host, cellAt } = buildGrid(1, cols);
|
|
373
|
+
track(host);
|
|
374
|
+
// Destroy immediately - the first scheduled frame is pending.
|
|
375
|
+
const action = spreadsheetLayout(host, {
|
|
376
|
+
columnOrder: cols,
|
|
377
|
+
merges: [{ rowIndex: 0, columnId: 'a', colspan: 2 }],
|
|
378
|
+
});
|
|
379
|
+
action.destroy();
|
|
380
|
+
await flushFrame();
|
|
381
|
+
await flushFrame();
|
|
382
|
+
// Frame was cancelled before apply ran.
|
|
383
|
+
expect(cellAt(0, 'a').hasAttribute('colspan')).toBe(false);
|
|
384
|
+
// After destroy, mutations no longer trigger apply.
|
|
385
|
+
const tbody = host.querySelector('tbody');
|
|
386
|
+
tbody.appendChild(document.createElement('tr'));
|
|
387
|
+
await flushFrame();
|
|
388
|
+
await flushFrame();
|
|
389
|
+
expect(cellAt(0, 'a').hasAttribute('colspan')).toBe(false);
|
|
390
|
+
});
|
|
391
|
+
it('treats null merges / borders as empty (no throw)', async () => {
|
|
392
|
+
const cols = ['a'];
|
|
393
|
+
const { host } = buildGrid(1, cols);
|
|
394
|
+
track(host);
|
|
395
|
+
const opts = {
|
|
396
|
+
columnOrder: cols,
|
|
397
|
+
merges: null,
|
|
398
|
+
borders: null,
|
|
399
|
+
};
|
|
400
|
+
const action = spreadsheetLayout(host, opts);
|
|
401
|
+
await flushFrame();
|
|
402
|
+
expect(host.querySelectorAll('[data-svgrid-sheet]').length).toBe(0);
|
|
403
|
+
action.destroy();
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
describe('spansToMerges - declarative colSpan/rowSpan -> MergeSpec[]', () => {
|
|
407
|
+
const rows = [
|
|
408
|
+
{ region: 'AMER', q: 'Q1', amt: 1 },
|
|
409
|
+
{ region: 'AMER', q: 'Q2', amt: 2 },
|
|
410
|
+
{ region: 'AMER', q: 'Q3', amt: 3 },
|
|
411
|
+
{ region: 'EMEA', q: 'Q1', amt: 4 },
|
|
412
|
+
{ region: 'EMEA', q: 'Q2', amt: 5 },
|
|
413
|
+
];
|
|
414
|
+
// Merge each run of equal `region` values downward.
|
|
415
|
+
function regionRowSpan() {
|
|
416
|
+
return ({ data, rowIndex }) => {
|
|
417
|
+
if (rowIndex > 0 && rows[rowIndex - 1].region === data.region)
|
|
418
|
+
return 1; // covered
|
|
419
|
+
let n = 1;
|
|
420
|
+
while (rows[rowIndex + n]?.region === data.region)
|
|
421
|
+
n += 1;
|
|
422
|
+
return n;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
it('emits a rowspan merge at each run origin and skips covered rows', () => {
|
|
426
|
+
const columns = [{ id: 'region', field: 'region', rowSpan: regionRowSpan() }];
|
|
427
|
+
const merges = spansToMerges(rows, columns);
|
|
428
|
+
// AMER spans rows 0..2 (rowspan 3), EMEA spans rows 3..4 (rowspan 2).
|
|
429
|
+
expect(merges).toEqual([
|
|
430
|
+
{ rowIndex: 0, columnId: 'region', colspan: undefined, rowspan: 3 },
|
|
431
|
+
{ rowIndex: 3, columnId: 'region', colspan: undefined, rowspan: 2 },
|
|
432
|
+
]);
|
|
433
|
+
});
|
|
434
|
+
it('supports colSpan and marks covered columns', () => {
|
|
435
|
+
const columns = [
|
|
436
|
+
{ id: 'a', field: 'region', colSpan: ({ rowIndex }) => (rowIndex === 0 ? 2 : 1) },
|
|
437
|
+
{ id: 'b', field: 'q' },
|
|
438
|
+
{ id: 'c', field: 'amt' },
|
|
439
|
+
];
|
|
440
|
+
const merges = spansToMerges(rows.slice(0, 1), columns);
|
|
441
|
+
expect(merges).toEqual([{ rowIndex: 0, columnId: 'a', colspan: 2, rowspan: undefined }]);
|
|
442
|
+
});
|
|
443
|
+
it('returns no merges when no column defines spans', () => {
|
|
444
|
+
expect(spansToMerges(rows, [{ id: 'region', field: 'region' }])).toEqual([]);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
@@ -30,7 +30,11 @@ const STYLE_TEMPLATE = `
|
|
|
30
30
|
display: flex;
|
|
31
31
|
user-select: none;
|
|
32
32
|
background: var(--sg-scrollbar-bg, #eef2f8);
|
|
33
|
-
|
|
33
|
+
/* The 1px separator is drawn on the INNER edge only (the edge facing
|
|
34
|
+
the grid body) via the orientation rules below. A full inset box
|
|
35
|
+
here doubled up with the grid's own frame border on the outer edge,
|
|
36
|
+
reading as a 2px border - most visible in dense-gridline themes
|
|
37
|
+
like Excel, which should show a single 1px line. */
|
|
34
38
|
/* Start hidden + non-interactive - viewport/content sizes are 0 until
|
|
35
39
|
after the first layout pass, so without this default the scrollbar
|
|
36
40
|
paints visible for one frame and then JS hides it on mount. That
|
|
@@ -44,10 +48,18 @@ const STYLE_TEMPLATE = `
|
|
|
44
48
|
:host([orientation="vertical"]) {
|
|
45
49
|
flex-direction: column;
|
|
46
50
|
width: ${ARROW_SIZE}px;
|
|
51
|
+
/* LTR: vertical scrollbar sits at the right, inner edge is the left. */
|
|
52
|
+
box-shadow: inset 1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
53
|
+
}
|
|
54
|
+
:host([orientation="vertical"]:dir(rtl)) {
|
|
55
|
+
/* RTL flips the scrollbar to the left, so the inner edge is the right. */
|
|
56
|
+
box-shadow: inset -1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
47
57
|
}
|
|
48
58
|
:host([orientation="horizontal"]) {
|
|
49
59
|
flex-direction: row;
|
|
50
60
|
height: ${ARROW_SIZE}px;
|
|
61
|
+
/* Horizontal scrollbar sits at the bottom, inner edge is the top. */
|
|
62
|
+
box-shadow: inset 0 1px 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
51
63
|
}
|
|
52
64
|
.arrow {
|
|
53
65
|
flex: none;
|
|
@@ -58,6 +58,16 @@ export type SvGridApi<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
58
58
|
getCellValue(rowIndex: number, columnId: string): unknown;
|
|
59
59
|
/** Write a cell value through the column's field. */
|
|
60
60
|
setCellValue(rowIndex: number, columnId: string, value: unknown): void;
|
|
61
|
+
/**
|
|
62
|
+
* Programmatically begin editing a cell (as a double-click would). Returns
|
|
63
|
+
* `true` if editing started (cell exists, editable, editing enabled).
|
|
64
|
+
*/
|
|
65
|
+
startEditing(rowIndex: number, columnId: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Commit (default) or, with `cancel: true`, discard the active edit.
|
|
68
|
+
* Returns `true` if there was an edit in progress.
|
|
69
|
+
*/
|
|
70
|
+
stopEditing(cancel?: boolean): boolean;
|
|
61
71
|
/**
|
|
62
72
|
* Programmatically select one or more rectangular cell ranges. Each
|
|
63
73
|
* range is `[rowStart, colStart, rowEnd, colEnd]` in 0-indexed grid
|
|
@@ -105,6 +115,15 @@ export type SvGridApi<TFeatures extends TableFeatures, TData extends RowData> =
|
|
|
105
115
|
value?: string;
|
|
106
116
|
/** Upper bound for the `between` operator. Required when `operator === 'between'`. */
|
|
107
117
|
valueTo?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Optional SECOND condition on the same column, joined by `join`
|
|
120
|
+
* (multi-condition filtering, e.g. "> 100 AND < 500").
|
|
121
|
+
*/
|
|
122
|
+
operator2?: SvGridFilterOperator;
|
|
123
|
+
value2?: string;
|
|
124
|
+
valueTo2?: string;
|
|
125
|
+
/** How to combine the two conditions. Defaults to `'AND'`. */
|
|
126
|
+
join?: 'AND' | 'OR';
|
|
108
127
|
} | null): void;
|
|
109
128
|
/**
|
|
110
129
|
* Set the facet (set-list, Excel-style multi-select) filter for a column.
|
|
@@ -389,6 +389,26 @@ describe('SvGrid - column add / remove / visibility', () => {
|
|
|
389
389
|
destroy();
|
|
390
390
|
}
|
|
391
391
|
});
|
|
392
|
+
it('columns marked `visible: false` start hidden but stay listed', async () => {
|
|
393
|
+
const columns = personColumns.map((c) => (c.field === 'team' ? { ...c, visible: false } : c));
|
|
394
|
+
const { api, destroy } = await mountGrid({ columns });
|
|
395
|
+
try {
|
|
396
|
+
// Starts hidden...
|
|
397
|
+
expect(api.isColumnVisible('team')).toBe(false);
|
|
398
|
+
// ...but is still listed in getColumns() (so a Choose Columns UI
|
|
399
|
+
// can offer it), just with visible=false.
|
|
400
|
+
const team = api.getColumns().find((c) => c.id === 'team');
|
|
401
|
+
expect(team).toBeDefined();
|
|
402
|
+
expect(team?.visible).toBe(false);
|
|
403
|
+
// A later user toggle wins over the initial flag.
|
|
404
|
+
api.setColumnVisible('team', true);
|
|
405
|
+
await tick();
|
|
406
|
+
expect(api.isColumnVisible('team')).toBe(true);
|
|
407
|
+
}
|
|
408
|
+
finally {
|
|
409
|
+
destroy();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
392
412
|
});
|
|
393
413
|
describe('SvGrid - row add / remove', () => {
|
|
394
414
|
it('addRow at top / bottom / specific index', async () => {
|
|
@@ -272,6 +272,37 @@ describe('SvGrid interactions - cell pointer events', () => {
|
|
|
272
272
|
destroy();
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
|
+
// issue #23: a mouse drag extends the cell range, but a touch drag must NOT -
|
|
276
|
+
// it should leave the single tapped cell selected so the finger-drag scrolls.
|
|
277
|
+
async function dragSelectCount(pointerType) {
|
|
278
|
+
const { target, destroy } = await mountInteractive();
|
|
279
|
+
try {
|
|
280
|
+
const a = target.querySelector('[data-svgrid-row="0"][data-svgrid-col="0"]');
|
|
281
|
+
const c = target.querySelector('[data-svgrid-row="0"][data-svgrid-col="2"]');
|
|
282
|
+
if (!a || !c)
|
|
283
|
+
return -1; // jsdom didn't lay the cells out; caller skips
|
|
284
|
+
a.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, pointerId: 1, button: 0, pointerType }));
|
|
285
|
+
await tick();
|
|
286
|
+
c.dispatchEvent(new PointerEvent('pointerenter', { bubbles: true, pointerId: 1, pointerType }));
|
|
287
|
+
await tick();
|
|
288
|
+
return target.querySelectorAll('[data-selected-range="true"]').length;
|
|
289
|
+
}
|
|
290
|
+
finally {
|
|
291
|
+
destroy();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
it('mouse drag extends the selection across cells', async () => {
|
|
295
|
+
const n = await dragSelectCount('mouse');
|
|
296
|
+
if (n < 0)
|
|
297
|
+
return;
|
|
298
|
+
expect(n).toBeGreaterThan(1); // (0,0) -> (0,2) selects the row's 3 cells
|
|
299
|
+
});
|
|
300
|
+
it('touch drag does not start a range selection (issue #23)', async () => {
|
|
301
|
+
const n = await dragSelectCount('touch');
|
|
302
|
+
if (n < 0)
|
|
303
|
+
return;
|
|
304
|
+
expect(n).toBeLessThanOrEqual(1); // only the tapped cell; finger-drag scrolls
|
|
305
|
+
});
|
|
275
306
|
});
|
|
276
307
|
describe('SvGrid interactions - copy', () => {
|
|
277
308
|
it('Ctrl+C with a cell range does not throw', async () => {
|
|
@@ -64,7 +64,7 @@ describe('SvGrid wrapper - cellClass + rowClass', () => {
|
|
|
64
64
|
it('computes the row-level class once per render row and threads it onto the <tr>', () => {
|
|
65
65
|
expect(source).toMatch(/function computeRowClass/);
|
|
66
66
|
expect(source).toMatch(/userRowClass = computeRowClass\(row, rowIndex\)/);
|
|
67
|
-
expect(source).toMatch(/class=\{`sv-grid-row \$\{userRowClass\}
|
|
67
|
+
expect(source).toMatch(/class=\{`sv-grid-row \$\{userRowClass\}/);
|
|
68
68
|
});
|
|
69
69
|
it('computes the cell-level class per column and threads it onto the <td>', () => {
|
|
70
70
|
expect(source).toMatch(/function computeCellClass/);
|
|
@@ -120,7 +120,7 @@ describe('SvGrid wrapper - between filter operator', () => {
|
|
|
120
120
|
expect(source).toMatch(/if \(f\.operator === "between"\) \{[^}]*f\.value\.trim\(\)\.length > 0[^}]*f\.valueTo[^}]*\.trim\(\)\.length > 0/);
|
|
121
121
|
});
|
|
122
122
|
it('forwards valueTo through applyExcelFilter', () => {
|
|
123
|
-
expect(source).toMatch(/valueTo
|
|
123
|
+
expect(source).toMatch(/valueTo:\s*(filter\.operator|op) === "between" \? (filter\.valueTo|valueTo) : undefined/);
|
|
124
124
|
});
|
|
125
125
|
it('publishes valueTo in the onFiltersChange payload only for between clauses', () => {
|
|
126
126
|
expect(source).toMatch(/f\.operator === "between" && f\.valueTo\s*\?\s*\{ valueTo: f\.valueTo \}/);
|
|
@@ -159,4 +159,36 @@ describe('SvGrid wrapper - multi-cell paste + cut + delete', () => {
|
|
|
159
159
|
expect(source).toMatch(/event\.key === "Delete" \|\| event\.key === "Backspace"/);
|
|
160
160
|
expect(source).toMatch(/if \((?:ctx\.)?clearSelectedCells\(\)\)\s*\{/);
|
|
161
161
|
});
|
|
162
|
+
// Regression: the controller's ctx is an object literal of getters, and the
|
|
163
|
+
// copy/cut/paste handlers in keyboard-handlers + menus reach the functions
|
|
164
|
+
// via `ctx.<name>()`. A refactor once shipped the `ctx.cutSelectionToClipboard`
|
|
165
|
+
// / `ctx.pasteFromClipboard` CALLS but dropped their getters, so those threw
|
|
166
|
+
// "is not a function" at runtime - copy worked, cut + paste were dead. Assert
|
|
167
|
+
// every clipboard function called through ctx has a matching getter.
|
|
168
|
+
it('exposes a ctx getter for every clipboard command it calls through ctx', () => {
|
|
169
|
+
for (const fn of [
|
|
170
|
+
'copySelectionToClipboard',
|
|
171
|
+
'cutSelectionToClipboard',
|
|
172
|
+
'pasteFromClipboard',
|
|
173
|
+
'onGridPaste',
|
|
174
|
+
'clearSelectedCells',
|
|
175
|
+
]) {
|
|
176
|
+
expect(source).toMatch(new RegExp(`get ${fn}\\(\\)\\s*\\{\\s*return ${fn};?\\s*\\}`));
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
it('copy/cut fall back to execCommand when navigator.clipboard is absent (insecure context)', () => {
|
|
180
|
+
expect(source).toMatch(/function writeClipboardText\(/);
|
|
181
|
+
expect(source).toMatch(/document\.execCommand\("copy"\)/);
|
|
182
|
+
});
|
|
183
|
+
it('paste falls back to a native paste event when the async API is unavailable', () => {
|
|
184
|
+
// keydown only preventDefaults (and uses the async API) in a secure context;
|
|
185
|
+
// otherwise it lets the browser deliver a native paste event to onGridPaste.
|
|
186
|
+
// Accept either the positive branch or the inverted early-return guard
|
|
187
|
+
// (`if (!navigator.clipboard?.readText) return`) - both gate on the async API.
|
|
188
|
+
expect(source).toMatch(/if \(!?navigator\.clipboard\?\.readText\)/);
|
|
189
|
+
expect(source).toMatch(/function onGridPaste\(event: ClipboardEvent\)/);
|
|
190
|
+
expect(source).toMatch(/clipboardData\?\.getData\("text\/plain"\)/);
|
|
191
|
+
// The grid root wires the handler.
|
|
192
|
+
expect(source).toMatch(/onpaste=\{onGridPaste\}/);
|
|
193
|
+
});
|
|
162
194
|
});
|
package/dist/test-setup.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// Vitest setup. jsdom doesn't ship ResizeObserver, IntersectionObserver,
|
|
2
2
|
// or the layout APIs SvGrid touches inside its mount effects. Provide
|
|
3
3
|
// minimal no-op stubs so component mounting completes without crashing.
|
|
4
|
+
//
|
|
5
|
+
// These assign to globals/prototypes the jsdom env doesn't fully type, so
|
|
6
|
+
// the targets are cast to `any`. We deliberately avoid expect-error
|
|
7
|
+
// suppression directives: when a stub happens to line up with the lib types,
|
|
8
|
+
// such a directive becomes "unused" and svelte-check fails the build (an
|
|
9
|
+
// unused expect-error directive is itself an error).
|
|
4
10
|
if (typeof globalThis.ResizeObserver === 'undefined') {
|
|
5
|
-
|
|
11
|
+
;
|
|
6
12
|
globalThis.ResizeObserver = class {
|
|
7
13
|
observe() { }
|
|
8
14
|
unobserve() { }
|
|
@@ -10,7 +16,7 @@ if (typeof globalThis.ResizeObserver === 'undefined') {
|
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
if (typeof globalThis.IntersectionObserver === 'undefined') {
|
|
13
|
-
|
|
19
|
+
;
|
|
14
20
|
globalThis.IntersectionObserver = class {
|
|
15
21
|
observe() { }
|
|
16
22
|
unobserve() { }
|
|
@@ -23,7 +29,7 @@ if (typeof globalThis.IntersectionObserver === 'undefined') {
|
|
|
23
29
|
// jsdom's HTMLElement.scrollIntoView is a no-op; some grid code calls it
|
|
24
30
|
// during the first effect. Make sure the method exists on every element.
|
|
25
31
|
if (typeof Element !== 'undefined' && !Element.prototype.scrollIntoView) {
|
|
26
|
-
|
|
32
|
+
;
|
|
27
33
|
Element.prototype.scrollIntoView = function () { };
|
|
28
34
|
}
|
|
29
35
|
export {};
|