@koeroesi86/canvas-grid 26.11.2 → 26.11.3
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/build/types/utils/column-store.d.ts +4 -2
- package/build/types/utils/data-store.d.ts +6 -0
- package/build/types/utils/row-store.d.ts +28 -6
- package/build/web-component.js +1 -1
- package/build/web-component.js.map +1 -1
- package/build/web-component.mjs +209 -126
- package/build/web-component.mjs.map +1 -1
- package/package.json +1 -1
package/build/web-component.mjs
CHANGED
|
@@ -211,32 +211,36 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
211
211
|
this.updatedAt[e] = n ?? 0;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
clearSlots(e) {
|
|
215
|
+
e.forEach((e) => {
|
|
216
|
+
e < this.values.length && (this.values[e] = void 0), this.updatedAt && e < this.updatedAt.length && (this.updatedAt[e] = 0);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
compact(e) {
|
|
220
|
+
this.values = Array.from(e, (e) => this.values[e]);
|
|
221
|
+
let { updatedAt: t } = this;
|
|
222
|
+
t && (this.updatedAt = Array.from(e, (e) => t[e] ?? 0));
|
|
222
223
|
}
|
|
223
|
-
}, h = class {
|
|
224
|
+
}, h = 1024, g = class {
|
|
224
225
|
items = [];
|
|
225
|
-
|
|
226
|
+
byId = /* @__PURE__ */ new Map();
|
|
226
227
|
tops = [];
|
|
227
228
|
end = 0;
|
|
229
|
+
nextSlot = 0;
|
|
228
230
|
get length() {
|
|
229
231
|
return this.items.length;
|
|
230
232
|
}
|
|
231
233
|
get totalHeight() {
|
|
232
234
|
return this.end;
|
|
233
235
|
}
|
|
236
|
+
get slotCount() {
|
|
237
|
+
return this.nextSlot;
|
|
238
|
+
}
|
|
234
239
|
get keys() {
|
|
235
240
|
return this.items.map((e) => e.id);
|
|
236
241
|
}
|
|
237
242
|
get(e) {
|
|
238
|
-
|
|
239
|
-
return t === void 0 ? void 0 : this.items[t];
|
|
243
|
+
return this.byId.get(String(e));
|
|
240
244
|
}
|
|
241
245
|
at(e) {
|
|
242
246
|
return this.items[e];
|
|
@@ -255,21 +259,23 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
255
259
|
return t;
|
|
256
260
|
}
|
|
257
261
|
set(e) {
|
|
258
|
-
let t =
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
let t = String(e.id), n = this.byId.get(t);
|
|
263
|
+
if (n) {
|
|
264
|
+
let r = {
|
|
265
|
+
id: e.id,
|
|
266
|
+
height: e.height,
|
|
267
|
+
index: n.index,
|
|
268
|
+
slot: n.slot
|
|
269
|
+
};
|
|
270
|
+
return this.items[n.index] = r, this.byId.set(t, r), this.reindexFrom(n.index), r;
|
|
266
271
|
}
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
index:
|
|
271
|
-
slot:
|
|
272
|
-
}
|
|
272
|
+
let r = this.items.length, i = {
|
|
273
|
+
id: e.id,
|
|
274
|
+
height: e.height,
|
|
275
|
+
index: r,
|
|
276
|
+
slot: this.nextSlot++
|
|
277
|
+
};
|
|
278
|
+
return this.items.push(i), this.byId.set(t, i), this.tops.push(this.end), this.end += Math.round(e.height), i;
|
|
273
279
|
}
|
|
274
280
|
removeMany(e) {
|
|
275
281
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -277,38 +283,92 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
277
283
|
let n = this.get(e);
|
|
278
284
|
n && t.add(n);
|
|
279
285
|
}), t.size === 0) return [];
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
t.forEach((e) => this.byId.delete(String(e.id)));
|
|
287
|
+
let n = Array.from(t, (e) => e.index).sort((e, t) => e - t);
|
|
288
|
+
return this.closeGaps(n), this.reindexFrom(n[0]), Array.from(t, (e) => e.slot).sort((e, t) => e - t);
|
|
289
|
+
}
|
|
290
|
+
compactSlots() {
|
|
291
|
+
let e = this.nextSlot - this.items.length;
|
|
292
|
+
if (e < h || e <= this.items.length) return;
|
|
293
|
+
let t = Int32Array.from(this.items, (e) => e.slot).sort(), n = new Int32Array(this.nextSlot);
|
|
294
|
+
return t.forEach((e, t) => {
|
|
295
|
+
n[e] = t;
|
|
296
|
+
}), this.items.forEach((e) => {
|
|
297
|
+
e.slot = n[e.slot];
|
|
298
|
+
}), this.nextSlot = this.items.length, t;
|
|
287
299
|
}
|
|
288
300
|
sort(e) {
|
|
289
301
|
this.items.sort(e), this.reindexFrom(0);
|
|
290
302
|
}
|
|
303
|
+
resort(e, t) {
|
|
304
|
+
let n = /* @__PURE__ */ new Set();
|
|
305
|
+
for (let t of e) {
|
|
306
|
+
let e = this.get(t);
|
|
307
|
+
e && n.add(e);
|
|
308
|
+
}
|
|
309
|
+
if (n.size === 0) return;
|
|
310
|
+
let r = Array.from(n, (e) => e.index).sort((e, t) => e - t);
|
|
311
|
+
this.closeGaps(r);
|
|
312
|
+
let i = Array.from(n).sort(t), a = i.map((e) => this.lowerBound(this.items, e, t)), o = this.items.length;
|
|
313
|
+
i.forEach((e) => this.items.push(e));
|
|
314
|
+
let { items: s } = this, c = o;
|
|
315
|
+
for (let e = i.length - 1; e >= 0; e--) {
|
|
316
|
+
for (let t = c - 1; t >= a[e]; t--) s[t + e + 1] = s[t];
|
|
317
|
+
s[a[e] + e] = i[e], c = a[e];
|
|
318
|
+
}
|
|
319
|
+
this.reindexFrom(Math.min(r[0], a[0]));
|
|
320
|
+
}
|
|
291
321
|
clear() {
|
|
292
|
-
this.items = [], this.
|
|
322
|
+
this.items = [], this.byId.clear(), this.tops = [], this.end = 0, this.nextSlot = 0;
|
|
323
|
+
}
|
|
324
|
+
closeGaps(e) {
|
|
325
|
+
let { items: t } = this, n = e[0];
|
|
326
|
+
e.forEach((r, i) => {
|
|
327
|
+
let a = e[i + 1] ?? t.length;
|
|
328
|
+
for (let e = r + 1; e < a; e++) t[n++] = t[e];
|
|
329
|
+
}), t.length = n;
|
|
330
|
+
}
|
|
331
|
+
lowerBound(e, t, n) {
|
|
332
|
+
let r = 0, i = e.length;
|
|
333
|
+
for (; r < i;) {
|
|
334
|
+
let a = r + i >>> 1;
|
|
335
|
+
n(e[a], t) < 0 ? r = a + 1 : i = a;
|
|
336
|
+
}
|
|
337
|
+
return r;
|
|
293
338
|
}
|
|
294
339
|
reindexFrom(e) {
|
|
295
340
|
this.tops.length = this.items.length;
|
|
296
341
|
let t = e === 0 ? 0 : this.tops[e - 1] + Math.round(this.items[e - 1].height);
|
|
297
342
|
for (let n = e; n < this.items.length; n++) {
|
|
298
343
|
let e = this.items[n];
|
|
299
|
-
e.index = n, this.
|
|
344
|
+
e.index = n, this.tops[n] = t, t += Math.round(e.height);
|
|
300
345
|
}
|
|
301
346
|
this.end = t;
|
|
302
347
|
}
|
|
303
|
-
},
|
|
304
|
-
let n =
|
|
305
|
-
return n === 0 ?
|
|
306
|
-
},
|
|
307
|
-
|
|
348
|
+
}, _ = () => (/* @__PURE__ */ new Date()).valueOf(), v = (e, t) => e.id, y = new Intl.Collator(), b = 8, x = (e) => e == null ? 3 : typeof e == "number" || typeof e == "bigint" ? 0 : typeof e == "string" ? 1 : 2, S = (e, t) => {
|
|
349
|
+
let n = x(e) - x(t);
|
|
350
|
+
return n === 0 ? x(e) === 3 ? 0 : x(e) === 0 ? Number(e) - Number(t) : y.compare(String(e), String(t)) : n;
|
|
351
|
+
}, C = (e) => {
|
|
352
|
+
let t = new Uint8Array(e.length), n = new Float64Array(e.length), r = /* @__PURE__ */ new Map();
|
|
353
|
+
e.forEach((e, i) => {
|
|
354
|
+
t[i] = x(e), t[i] === 0 && (n[i] = Number(e)), (t[i] === 1 || t[i] === 2) && r.set(String(e), 0);
|
|
355
|
+
});
|
|
356
|
+
let i = 0, a = Array.from(r.keys()).sort(y.compare);
|
|
357
|
+
return a.forEach((e, t) => {
|
|
358
|
+
t > 0 && y.compare(a[t - 1], e) !== 0 && i++, r.set(e, i);
|
|
359
|
+
}), e.forEach((e, i) => {
|
|
360
|
+
(t[i] === 1 || t[i] === 2) && (n[i] = r.get(String(e)) ?? 0);
|
|
361
|
+
}), {
|
|
362
|
+
ranks: t,
|
|
363
|
+
keys: n
|
|
364
|
+
};
|
|
365
|
+
}, w = class {
|
|
366
|
+
rows = new g();
|
|
308
367
|
columns = /* @__PURE__ */ new Map();
|
|
309
368
|
pending = [];
|
|
310
369
|
sortModel = [];
|
|
311
370
|
sortDirty = !1;
|
|
371
|
+
sortChanged = /* @__PURE__ */ new Set();
|
|
312
372
|
environment;
|
|
313
373
|
constructor(e) {
|
|
314
374
|
this.environment = e;
|
|
@@ -346,9 +406,9 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
346
406
|
this.rows.clear(), this.columns.clear();
|
|
347
407
|
}
|
|
348
408
|
setRows(e) {
|
|
349
|
-
this.pending = [], this.clear(), e.forEach((e, t) => this.addRow(this.environment.getRowId(e, t), e, void 0)), this.sort();
|
|
409
|
+
this.pending = [], this.clear(), this.sortChanged.clear(), Object.keys(e[0] ?? {}).forEach((t) => this.columns.set(t, new m(e.length))), e.forEach((e, t) => this.addRow(this.environment.getRowId(e, t), e, void 0)), this.sortModel.length > 0 && this.sort();
|
|
350
410
|
}
|
|
351
|
-
flush(e =
|
|
411
|
+
flush(e = _()) {
|
|
352
412
|
let t = this.pending;
|
|
353
413
|
this.pending = [];
|
|
354
414
|
let n = [], r = !1, i = () => {
|
|
@@ -356,52 +416,75 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
356
416
|
};
|
|
357
417
|
return t.forEach(({ type: t, row: r }) => {
|
|
358
418
|
t === "remove" ? n.push(this.environment.getRowId(r)) : (i(), this.applyUpdate(r, e));
|
|
359
|
-
}), i(), this.sortDirty ? (this.
|
|
419
|
+
}), i(), this.sortDirty ? (this.sortChanges(), !0) : r;
|
|
360
420
|
}
|
|
361
421
|
column(e) {
|
|
362
422
|
let t = this.columns.get(e);
|
|
363
|
-
return t || (t = new m(this.rows.
|
|
423
|
+
return t || (t = new m(this.rows.slotCount), this.columns.set(e, t)), t;
|
|
364
424
|
}
|
|
365
425
|
addRow(e, t, n) {
|
|
366
|
-
this.rows.set({
|
|
426
|
+
let { slot: r } = this.rows.set({
|
|
367
427
|
id: e,
|
|
368
428
|
height: this.environment.getCellHeight()
|
|
369
|
-
});
|
|
370
|
-
let
|
|
371
|
-
|
|
429
|
+
}), i = Object.keys(t);
|
|
430
|
+
for (let e of i) this.column(e).set(r, t[e], n);
|
|
431
|
+
this.markSortDirty(e, i);
|
|
372
432
|
}
|
|
373
433
|
removeRows(e) {
|
|
374
434
|
if (e.length === 0) return !1;
|
|
375
435
|
let t = this.rows.removeMany(e);
|
|
376
|
-
|
|
436
|
+
this.columns.forEach((e) => e.clearSlots(t));
|
|
437
|
+
let n = this.rows.compactSlots();
|
|
438
|
+
return n && this.columns.forEach((e) => e.compact(n)), t.length > 0;
|
|
377
439
|
}
|
|
378
440
|
applyUpdate(e, t) {
|
|
379
441
|
let n = this.environment.getRowId(e), r = this.rows.get(n);
|
|
380
|
-
r ? Object.keys(e).forEach((n) => this.applyValue(r.slot, n, e[n], t)) : this.addRow(n, e, t);
|
|
442
|
+
r ? Object.keys(e).forEach((n) => this.applyValue(r.id, r.slot, n, e[n], t)) : this.addRow(n, e, t);
|
|
381
443
|
}
|
|
382
|
-
applyValue(e, t, n, r) {
|
|
383
|
-
let
|
|
384
|
-
|
|
444
|
+
applyValue(e, t, n, r, i) {
|
|
445
|
+
let a = this.column(n), o = a.get(t);
|
|
446
|
+
o !== r && (a.set(t, r, o === void 0 ? void 0 : i), this.markSortDirty(e, [n]));
|
|
385
447
|
}
|
|
386
|
-
markSortDirty(e) {
|
|
387
|
-
this.sortModel.some(({ columnId:
|
|
448
|
+
markSortDirty(e, t) {
|
|
449
|
+
this.sortModel.some(({ columnId: e }) => t.includes(String(e))) && (this.sortDirty = !0, this.sortChanged.add(String(e)));
|
|
388
450
|
}
|
|
389
|
-
|
|
390
|
-
this.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
451
|
+
createComparator(e) {
|
|
452
|
+
let t = this.sortModel.map(({ columnId: t, direction: n = "asc", compare: r }) => {
|
|
453
|
+
let i = this.columns.get(String(t))?.values, a = n === "desc" ? -1 : 1;
|
|
454
|
+
if (!i) return {
|
|
455
|
+
order: () => 0,
|
|
456
|
+
sign: a
|
|
457
|
+
};
|
|
458
|
+
if (r) return {
|
|
459
|
+
order: (e, t) => r(i[e.slot], i[t.slot]),
|
|
460
|
+
sign: a
|
|
461
|
+
};
|
|
462
|
+
if (!e) return {
|
|
463
|
+
order: (e, t) => S(i[e.slot], i[t.slot]),
|
|
464
|
+
sign: a
|
|
465
|
+
};
|
|
466
|
+
let { ranks: o, keys: s } = C(i);
|
|
467
|
+
return {
|
|
468
|
+
order: (e, t) => o[e.slot] - o[t.slot] || (o[e.slot] === 3 ? 0 : s[e.slot] - s[t.slot]) || 0,
|
|
469
|
+
sign: a
|
|
470
|
+
};
|
|
402
471
|
});
|
|
472
|
+
return (e, n) => {
|
|
473
|
+
for (let { order: r, sign: i } of t) {
|
|
474
|
+
let t = r(e, n);
|
|
475
|
+
if (t !== 0) return t * i;
|
|
476
|
+
}
|
|
477
|
+
return e.slot - n.slot;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
sort() {
|
|
481
|
+
this.sortDirty = !1, this.sortChanged.clear(), this.rows.sort(this.createComparator(!0));
|
|
482
|
+
}
|
|
483
|
+
sortChanges() {
|
|
484
|
+
let e = this.sortChanged;
|
|
485
|
+
e.size * b >= this.rows.length ? this.sort() : (this.sortDirty = !1, this.sortChanged = /* @__PURE__ */ new Set(), this.rows.resort(e, this.createComparator(!1)));
|
|
403
486
|
}
|
|
404
|
-
},
|
|
487
|
+
}, T = class {
|
|
405
488
|
entries = /* @__PURE__ */ new Map();
|
|
406
489
|
limit;
|
|
407
490
|
constructor(e) {
|
|
@@ -422,9 +505,9 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
422
505
|
get size() {
|
|
423
506
|
return this.entries.size;
|
|
424
507
|
}
|
|
425
|
-
},
|
|
508
|
+
}, E = "canvas-grid{isolation:isolate;display:block;position:relative}canvas-grid,canvas-grid *{box-sizing:border-box;margin:0;padding:0}canvas-grid .drawingLayer{contain:strict;width:100%;height:100%;position:absolute;top:0;left:0}canvas-grid .scrollArea{z-index:10;backface-visibility:hidden;will-change:transform;width:100%;height:100%;position:absolute;top:0;left:0;overflow:auto}canvas-grid .scrollArea>div{will-change:scroll-position, transform}", D = (e) => !!e, O = (e) => (t) => ({ draw: (n, r, i) => e(n, t, r, i) }), k = ({ x: e = 0, y: t = 0, children: n }) => ({ draw: (r, i, a) => [n].flat(2).filter(D).forEach((n) => n.draw(r, i + e, a + t)) }), A = { createElement(e, t, ...n) {
|
|
426
509
|
return e(Object.assign({}, t, { children: n }));
|
|
427
|
-
} },
|
|
510
|
+
} }, j = class {
|
|
428
511
|
options;
|
|
429
512
|
constructor(e) {
|
|
430
513
|
this.options = { ...e };
|
|
@@ -435,8 +518,8 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
435
518
|
}
|
|
436
519
|
optionsUpdated(e) {}
|
|
437
520
|
clearCache() {}
|
|
438
|
-
},
|
|
439
|
-
bitmaps = new
|
|
521
|
+
}, M = class extends j {
|
|
522
|
+
bitmaps = new T(4096);
|
|
440
523
|
cacheKey(e) {}
|
|
441
524
|
pixelRatio = 1;
|
|
442
525
|
clearCache() {
|
|
@@ -446,18 +529,18 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
446
529
|
let i = this.cacheKey(t), a = (i === void 0 ? void 0 : this.bitmaps.get(i)) ?? this.renderBitmap(t, i);
|
|
447
530
|
a.width <= 0 || a.height <= 0 || e.drawImage(a, n + (t.x ?? 0), r + (t.y ?? 0), a.width / this.pixelRatio, a.height / this.pixelRatio);
|
|
448
531
|
}
|
|
449
|
-
element =
|
|
532
|
+
element = O((e, t, n, r) => this.paint(e, t, n, r));
|
|
450
533
|
renderBitmap(e, t) {
|
|
451
534
|
let n = this.render(e);
|
|
452
535
|
if (t === void 0 || n.width <= 0 || n.height <= 0) return n;
|
|
453
536
|
let r = document.createElement("canvas");
|
|
454
537
|
return r.width = n.width, r.height = n.height, r.getContext("2d")?.drawImage(n, 0, 0), this.bitmaps.set(t, r), r;
|
|
455
538
|
}
|
|
456
|
-
},
|
|
539
|
+
}, N = (e, t) => {
|
|
457
540
|
let n = e.getContext("2d", t);
|
|
458
541
|
if (!n) throw Error("2D canvas context is not available");
|
|
459
542
|
return n;
|
|
460
|
-
},
|
|
543
|
+
}, P = class extends j {
|
|
461
544
|
ctx;
|
|
462
545
|
offCanvas = document.createElement("canvas");
|
|
463
546
|
offCtx;
|
|
@@ -465,7 +548,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
465
548
|
speed = 6;
|
|
466
549
|
count = 75;
|
|
467
550
|
constructor(e) {
|
|
468
|
-
super(e), this.ctx = this.options.ctx, this.offCanvas.width = 250, this.offCanvas.height = 250, this.offCtx =
|
|
551
|
+
super(e), this.ctx = this.options.ctx, this.offCanvas.width = 250, this.offCanvas.height = 250, this.offCtx = N(this.offCanvas), this.offCtx.lineWidth = .5, this.offCtx.strokeStyle = "rgba(255, 255, 255, 0.75)";
|
|
469
552
|
}
|
|
470
553
|
updateLoader() {
|
|
471
554
|
this.rotation += this.speed / 100;
|
|
@@ -481,12 +564,12 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
481
564
|
let e = Math.round((this.ctx.canvas.width - this.offCanvas.width) / 2), t = Math.round((this.ctx.canvas.height - this.offCanvas.height) / 2);
|
|
482
565
|
return this.ctx.clearRect(e, t, 250, 250), this.ctx.drawImage(this.offCanvas, e, t), this.offCanvas;
|
|
483
566
|
}
|
|
484
|
-
},
|
|
567
|
+
}, F = class {
|
|
485
568
|
name;
|
|
486
569
|
canvas = document.createElement("canvas");
|
|
487
570
|
ctx;
|
|
488
571
|
constructor(e, { alpha: t = !0, desynchronized: n = !1 } = {}) {
|
|
489
|
-
this.name = e, this.canvas.className = `drawingLayer ${e}`, this.ctx =
|
|
572
|
+
this.name = e, this.canvas.className = `drawingLayer ${e}`, this.ctx = N(this.canvas, {
|
|
490
573
|
alpha: t,
|
|
491
574
|
desynchronized: n
|
|
492
575
|
});
|
|
@@ -500,7 +583,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
500
583
|
clear() {
|
|
501
584
|
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
502
585
|
}
|
|
503
|
-
},
|
|
586
|
+
}, I = class {
|
|
504
587
|
renderers = /* @__PURE__ */ new Map();
|
|
505
588
|
warned = /* @__PURE__ */ new Set();
|
|
506
589
|
register(e, t) {
|
|
@@ -520,10 +603,10 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
520
603
|
clearCaches() {
|
|
521
604
|
this.renderers.forEach((e) => e.clearCache?.());
|
|
522
605
|
}
|
|
523
|
-
},
|
|
606
|
+
}, L = O((e, { x: t = 0, y: n = 0, width: r, height: i, color: a, alpha: o = 1 }, s, c) => {
|
|
524
607
|
let l = Math.trunc(r), u = Math.trunc(i);
|
|
525
608
|
!a || l <= 0 || u <= 0 || o <= 0 || (e.fillStyle = a, o >= 1 ? e.fillRect(s + t, c + n, l, u) : (e.globalAlpha = o, e.fillRect(s + t, c + n, l, u), e.globalAlpha = 1));
|
|
526
|
-
}),
|
|
609
|
+
}), R = class e extends j {
|
|
527
610
|
static defaultOptions = {
|
|
528
611
|
layer: "background",
|
|
529
612
|
enableFlashing: !0,
|
|
@@ -555,28 +638,28 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
555
638
|
}
|
|
556
639
|
draw({ ctx: e, x: t, y: n, width: r, height: i, age: a }) {
|
|
557
640
|
let { background: o, flashRGB: s, borderRightWidth: c, borderRightColor: l, borderBottomWidth: u, borderBottomColor: d } = this.options, f = this.getFlashAlpha(a);
|
|
558
|
-
(/* @__PURE__ */
|
|
641
|
+
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(L, {
|
|
559
642
|
width: r,
|
|
560
643
|
height: i,
|
|
561
644
|
color: o
|
|
562
|
-
}), f > 0 && /* @__PURE__ */
|
|
645
|
+
}), f > 0 && /* @__PURE__ */ A.createElement(L, {
|
|
563
646
|
width: r,
|
|
564
647
|
height: i,
|
|
565
648
|
color: `rgb(${s})`,
|
|
566
649
|
alpha: f
|
|
567
|
-
}), c > 0 && /* @__PURE__ */
|
|
650
|
+
}), c > 0 && /* @__PURE__ */ A.createElement(L, {
|
|
568
651
|
x: r - c,
|
|
569
652
|
width: c,
|
|
570
653
|
height: i,
|
|
571
654
|
color: l
|
|
572
|
-
}), u > 0 && /* @__PURE__ */
|
|
655
|
+
}), u > 0 && /* @__PURE__ */ A.createElement(L, {
|
|
573
656
|
y: i - u,
|
|
574
657
|
width: r,
|
|
575
658
|
height: u,
|
|
576
659
|
color: d
|
|
577
660
|
}))).draw(e, t, n);
|
|
578
661
|
}
|
|
579
|
-
},
|
|
662
|
+
}, z = class e extends M {
|
|
580
663
|
static defaultOptions = {
|
|
581
664
|
font: "12px monospace",
|
|
582
665
|
color: "#fff",
|
|
@@ -590,7 +673,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
590
673
|
super({
|
|
591
674
|
...e.defaultOptions,
|
|
592
675
|
...t
|
|
593
|
-
}), this.ctx =
|
|
676
|
+
}), this.ctx = N(this.canvas, { alpha: this.options.alpha }), this.ctx.textAlign = "left", this.ctx.textBaseline = "top";
|
|
594
677
|
}
|
|
595
678
|
set font(e) {
|
|
596
679
|
this.options.font !== e && (this.options.font = e);
|
|
@@ -615,7 +698,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
615
698
|
let { pixelRatio: n } = this;
|
|
616
699
|
return this.canvas.width = Math.round(this.getCharacterWidth(e) * n), this.canvas.height = Math.round(t * n), this.ctx.setTransform(n, 0, 0, n, 0, 0), this.ctx.font = this.options.font, this.ctx.textAlign = "left", this.ctx.textBaseline = "top", this.ctx.fillStyle !== this.options.color && (this.ctx.fillStyle = this.options.color), this.ctx.fillText(e, 0, 0), this.canvas;
|
|
617
700
|
}
|
|
618
|
-
},
|
|
701
|
+
}, B = class e extends j {
|
|
619
702
|
static defaultOptions = {
|
|
620
703
|
ellipsis: "…",
|
|
621
704
|
cellPadding: {
|
|
@@ -633,7 +716,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
633
716
|
super({
|
|
634
717
|
...e.defaultOptions,
|
|
635
718
|
...t
|
|
636
|
-
}), this.characterRenderer = new
|
|
719
|
+
}), this.characterRenderer = new z({
|
|
637
720
|
font: this.options.font,
|
|
638
721
|
color: this.options.color
|
|
639
722
|
});
|
|
@@ -684,8 +767,8 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
684
767
|
}, d + m, f), h += i, m += i;
|
|
685
768
|
}
|
|
686
769
|
}
|
|
687
|
-
element =
|
|
688
|
-
},
|
|
770
|
+
element = O((e, t, n, r) => this.paint(e, t, n, r));
|
|
771
|
+
}, V = class e extends j {
|
|
689
772
|
static defaultOptions = {
|
|
690
773
|
layer: "header",
|
|
691
774
|
background: "#333",
|
|
@@ -701,7 +784,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
701
784
|
super({
|
|
702
785
|
...e.defaultOptions,
|
|
703
786
|
...t
|
|
704
|
-
}), this.textRenderer = new
|
|
787
|
+
}), this.textRenderer = new B({
|
|
705
788
|
font: this.options.font,
|
|
706
789
|
color: this.options.color
|
|
707
790
|
});
|
|
@@ -727,27 +810,27 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
727
810
|
draw({ ctx: e, x: t, y: n, width: r, height: i, formatted: a }) {
|
|
728
811
|
if (r === 0 || i === 0) return;
|
|
729
812
|
let { background: o, borderRightWidth: s, borderRightColor: c, borderBottomWidth: l, borderBottomColor: u } = this.options;
|
|
730
|
-
(/* @__PURE__ */
|
|
813
|
+
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(L, {
|
|
731
814
|
width: r,
|
|
732
815
|
height: i,
|
|
733
816
|
color: o
|
|
734
|
-
}), s > 0 && /* @__PURE__ */
|
|
817
|
+
}), s > 0 && /* @__PURE__ */ A.createElement(L, {
|
|
735
818
|
x: r - s,
|
|
736
819
|
width: s,
|
|
737
820
|
height: i,
|
|
738
821
|
color: c
|
|
739
|
-
}), l > 0 && /* @__PURE__ */
|
|
822
|
+
}), l > 0 && /* @__PURE__ */ A.createElement(L, {
|
|
740
823
|
y: i - l,
|
|
741
824
|
width: r,
|
|
742
825
|
height: l,
|
|
743
826
|
color: u
|
|
744
|
-
}), /* @__PURE__ */
|
|
827
|
+
}), /* @__PURE__ */ A.createElement(this.textRenderer.element, {
|
|
745
828
|
value: a,
|
|
746
829
|
width: r,
|
|
747
830
|
height: i
|
|
748
831
|
}))).draw(e, t, n);
|
|
749
832
|
}
|
|
750
|
-
},
|
|
833
|
+
}, H = class e extends j {
|
|
751
834
|
static defaultOptions = {
|
|
752
835
|
layer: "content",
|
|
753
836
|
font: "12px monospace",
|
|
@@ -758,7 +841,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
758
841
|
super({
|
|
759
842
|
...e.defaultOptions,
|
|
760
843
|
...t
|
|
761
|
-
}), this.renderer = new
|
|
844
|
+
}), this.renderer = new B({
|
|
762
845
|
font: this.options.font,
|
|
763
846
|
color: this.options.color
|
|
764
847
|
});
|
|
@@ -788,24 +871,24 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
788
871
|
this.renderer.clearCache();
|
|
789
872
|
}
|
|
790
873
|
draw({ ctx: e, x: t, y: n, width: r, height: i, formatted: a, valueChanged: o, forced: s }) {
|
|
791
|
-
(o || s) && (e.clearRect(t, n, r, i), (/* @__PURE__ */
|
|
874
|
+
(o || s) && (e.clearRect(t, n, r, i), (/* @__PURE__ */ A.createElement(this.renderer.element, {
|
|
792
875
|
value: a,
|
|
793
876
|
width: r,
|
|
794
877
|
height: i
|
|
795
878
|
})).draw(e, t, n));
|
|
796
879
|
}
|
|
797
|
-
},
|
|
880
|
+
}, U = { scrollArea: "scrollArea" }, W = {
|
|
798
881
|
background: "background",
|
|
799
882
|
content: "content",
|
|
800
883
|
header: "header",
|
|
801
884
|
backgroundRenderer: "background",
|
|
802
885
|
valueRenderer: "value",
|
|
803
886
|
headerRenderer: "header"
|
|
804
|
-
},
|
|
805
|
-
if (document.getElementById(
|
|
887
|
+
}, G = "canvas-grid-styles", K = () => {
|
|
888
|
+
if (document.getElementById(G)) return;
|
|
806
889
|
let e = document.createElement("style");
|
|
807
|
-
e.id =
|
|
808
|
-
},
|
|
890
|
+
e.id = G, e.textContent = E, document.head.appendChild(e);
|
|
891
|
+
}, q = class extends HTMLElement {
|
|
809
892
|
fps = 30;
|
|
810
893
|
_font = "12px monospace";
|
|
811
894
|
_headerFont = "13px monospace";
|
|
@@ -824,13 +907,13 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
824
907
|
_backgroundColor = "#333";
|
|
825
908
|
_headerBackgroundColor = "#222";
|
|
826
909
|
textColor = "#efefef";
|
|
827
|
-
dataStore = new
|
|
910
|
+
dataStore = new w({
|
|
828
911
|
getRowId: (e, t) => this.getRowId(e, t),
|
|
829
912
|
getCellHeight: () => this.cellHeight
|
|
830
913
|
});
|
|
831
914
|
_dataCollection = this.dataStore.rows;
|
|
832
|
-
cellEntries = new
|
|
833
|
-
getRowId =
|
|
915
|
+
cellEntries = new T(2048);
|
|
916
|
+
getRowId = v;
|
|
834
917
|
headers = new p();
|
|
835
918
|
animationFrame = void 0;
|
|
836
919
|
scrollYOffset = 0;
|
|
@@ -845,10 +928,10 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
845
928
|
layers = [];
|
|
846
929
|
layersByName = /* @__PURE__ */ new Map();
|
|
847
930
|
warnedLayers = /* @__PURE__ */ new Set();
|
|
848
|
-
renderers = new
|
|
849
|
-
cellRenderers = [
|
|
850
|
-
cellBackgroundRenderer = new
|
|
851
|
-
layer:
|
|
931
|
+
renderers = new I();
|
|
932
|
+
cellRenderers = [W.backgroundRenderer, W.valueRenderer];
|
|
933
|
+
cellBackgroundRenderer = new R({
|
|
934
|
+
layer: W.background,
|
|
852
935
|
background: this._backgroundColor,
|
|
853
936
|
enableFlashing: !0,
|
|
854
937
|
flashInDuration: 200,
|
|
@@ -859,13 +942,13 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
859
942
|
borderBottomWidth: 1,
|
|
860
943
|
borderBottomColor: "#3f3f3f"
|
|
861
944
|
});
|
|
862
|
-
cellValueRenderer = new
|
|
863
|
-
layer:
|
|
945
|
+
cellValueRenderer = new H({
|
|
946
|
+
layer: W.content,
|
|
864
947
|
font: this._font,
|
|
865
948
|
color: this.textColor
|
|
866
949
|
});
|
|
867
|
-
headerCellRenderer = new
|
|
868
|
-
layer:
|
|
950
|
+
headerCellRenderer = new V({
|
|
951
|
+
layer: W.header,
|
|
869
952
|
font: this._headerFont,
|
|
870
953
|
color: this.textColor,
|
|
871
954
|
background: "#222",
|
|
@@ -883,8 +966,8 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
883
966
|
}, 50);
|
|
884
967
|
agApi;
|
|
885
968
|
constructor() {
|
|
886
|
-
super(), this.resize = this.resize.bind(this), this.setValues = this.setValues.bind(this), this.setColumns = this.setColumns.bind(this), this.clearValues = this.clearValues.bind(this), this.updateLastRender = this.updateLastRender.bind(this), this.transaction = this.transaction.bind(this), this.queueUpdate = this.queueUpdate.bind(this), this.addLayer(
|
|
887
|
-
ctx: this.requireLayer(
|
|
969
|
+
super(), this.resize = this.resize.bind(this), this.setValues = this.setValues.bind(this), this.setColumns = this.setColumns.bind(this), this.clearValues = this.clearValues.bind(this), this.updateLastRender = this.updateLastRender.bind(this), this.transaction = this.transaction.bind(this), this.queueUpdate = this.queueUpdate.bind(this), this.addLayer(W.background, { alpha: !1 }), this.addLayer(W.content), this.addLayer(W.header), this.registerRenderer(W.backgroundRenderer, this.cellBackgroundRenderer), this.registerRenderer(W.valueRenderer, this.cellValueRenderer), this.registerRenderer(W.headerRenderer, this.headerCellRenderer), this.loadingIndicator = new P({ ctx: this.requireLayer(W.header).ctx }), this.cell = {
|
|
970
|
+
ctx: this.requireLayer(W.content).ctx,
|
|
888
971
|
x: 0,
|
|
889
972
|
y: 0,
|
|
890
973
|
width: 0,
|
|
@@ -916,7 +999,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
916
999
|
};
|
|
917
1000
|
}
|
|
918
1001
|
get canvas() {
|
|
919
|
-
return this.requireLayer(
|
|
1002
|
+
return this.requireLayer(W.content).canvas;
|
|
920
1003
|
}
|
|
921
1004
|
get flashInDuration() {
|
|
922
1005
|
return this.cellBackgroundRenderer.options.flashInDuration;
|
|
@@ -940,7 +1023,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
940
1023
|
}
|
|
941
1024
|
addLayer(e, { alpha: t = !0, desynchronized: n = !1, before: r } = {}) {
|
|
942
1025
|
if (this.getLayer(e)) throw Error(`canvas-grid: layer "${e}" already exists`);
|
|
943
|
-
let i = new
|
|
1026
|
+
let i = new F(e, {
|
|
944
1027
|
alpha: t,
|
|
945
1028
|
desynchronized: n
|
|
946
1029
|
}), a = r === void 0 ? void 0 : this.requireLayer(r);
|
|
@@ -958,7 +1041,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
958
1041
|
}
|
|
959
1042
|
createScrollArea() {
|
|
960
1043
|
let e = document.createElement("div");
|
|
961
|
-
return e.className =
|
|
1044
|
+
return e.className = U.scrollArea, e.appendChild(this.scrollHelper), e;
|
|
962
1045
|
}
|
|
963
1046
|
set font(e) {
|
|
964
1047
|
this._font !== e && (this._font = e, this.cellValueRenderer.font = e);
|
|
@@ -1103,7 +1186,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1103
1186
|
index: e.index
|
|
1104
1187
|
},
|
|
1105
1188
|
formatted: `${e.index + 1}`
|
|
1106
|
-
}), this.paint(
|
|
1189
|
+
}), this.paint(W.headerRenderer));
|
|
1107
1190
|
}
|
|
1108
1191
|
forceDraw() {
|
|
1109
1192
|
this.layers.forEach((e) => e.clear()), this.draw(!0);
|
|
@@ -1147,7 +1230,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1147
1230
|
return this.dataStore.getSortModel();
|
|
1148
1231
|
}
|
|
1149
1232
|
renderBrick() {
|
|
1150
|
-
this.showHeaders && this.showRowNumbers && this._headerBackgroundColor && (this.describe(0, 0, this.rowNumbersWidth, this.headerHeight, {}), this.paint(
|
|
1233
|
+
this.showHeaders && this.showRowNumbers && this._headerBackgroundColor && (this.describe(0, 0, this.rowNumbersWidth, this.headerHeight, {}), this.paint(W.headerRenderer));
|
|
1151
1234
|
}
|
|
1152
1235
|
renderHeaders() {
|
|
1153
1236
|
let e = (this.showRowNumbers ? this.rowNumbersWidth : 0) - this.scrollXOffset;
|
|
@@ -1196,7 +1279,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1196
1279
|
let t = {
|
|
1197
1280
|
width: 100,
|
|
1198
1281
|
valueFormatter: (e) => String(e),
|
|
1199
|
-
headerRenderer:
|
|
1282
|
+
headerRenderer: W.headerRenderer
|
|
1200
1283
|
};
|
|
1201
1284
|
e.forEach((e, n) => {
|
|
1202
1285
|
if (typeof e == "string" || typeof e == "number") {
|
|
@@ -1220,7 +1303,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1220
1303
|
this.cancelRender(), document.removeEventListener("visibilitychange", this.onVisibilityChange), this.resizeObserver?.disconnect(), this.pixelRatioQuery?.removeEventListener("change", this.watchPixelRatio), document.fonts?.removeEventListener("loadingdone", this.onFontsLoaded), clearTimeout(this.fontsTimeout);
|
|
1221
1304
|
}
|
|
1222
1305
|
};
|
|
1223
|
-
window && window.customElements && (
|
|
1224
|
-
export {
|
|
1306
|
+
window && window.customElements && (K(), customElements.define("canvas-grid", q));
|
|
1307
|
+
export { q as default };
|
|
1225
1308
|
|
|
1226
1309
|
//# sourceMappingURL=web-component.mjs.map
|