@koeroesi86/canvas-grid 26.11.3 → 26.11.4
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/text/index.d.ts +12 -4
- package/build/types/utils/column-store.d.ts +2 -0
- package/build/types/utils/data-store.d.ts +3 -0
- package/build/types/utils/fit-text.d.ts +6 -0
- package/build/web-component.js +1 -1
- package/build/web-component.js.map +1 -1
- package/build/web-component.mjs +125 -160
- package/build/web-component.mjs.map +1 -1
- package/package.json +2 -5
- package/build/types/character/index.d.ts +0 -21
package/build/web-component.mjs
CHANGED
|
@@ -194,6 +194,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
194
194
|
}
|
|
195
195
|
}, m = class {
|
|
196
196
|
values;
|
|
197
|
+
version = 0;
|
|
197
198
|
updatedAt = void 0;
|
|
198
199
|
constructor(e = 0) {
|
|
199
200
|
this.values = Array(e).fill(void 0);
|
|
@@ -205,19 +206,19 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
205
206
|
return this.updatedAt?.[e] || void 0;
|
|
206
207
|
}
|
|
207
208
|
set(e, t, n) {
|
|
208
|
-
for (
|
|
209
|
+
for (this.version++; this.values.length < e;) this.values.push(void 0);
|
|
209
210
|
if (this.values[e] = t, n !== void 0 || this.updatedAt !== void 0) {
|
|
210
211
|
for (this.updatedAt ??= Array(this.values.length).fill(0); this.updatedAt.length < this.values.length;) this.updatedAt.push(0);
|
|
211
212
|
this.updatedAt[e] = n ?? 0;
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
clearSlots(e) {
|
|
215
|
-
e.forEach((e) => {
|
|
216
|
+
this.version++, e.forEach((e) => {
|
|
216
217
|
e < this.values.length && (this.values[e] = void 0), this.updatedAt && e < this.updatedAt.length && (this.updatedAt[e] = 0);
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
compact(e) {
|
|
220
|
-
this.values = Array.from(e, (e) => this.values[e]);
|
|
221
|
+
this.version++, this.values = Array.from(e, (e) => this.values[e]);
|
|
221
222
|
let { updatedAt: t } = this;
|
|
222
223
|
t && (this.updatedAt = Array.from(e, (e) => t[e] ?? 0));
|
|
223
224
|
}
|
|
@@ -349,16 +350,23 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
349
350
|
let n = x(e) - x(t);
|
|
350
351
|
return n === 0 ? x(e) === 3 ? 0 : x(e) === 0 ? Number(e) - Number(t) : y.compare(String(e), String(t)) : n;
|
|
351
352
|
}, C = (e) => {
|
|
352
|
-
let t = new Uint8Array(e.length), n = new Float64Array(e.length), r = /* @__PURE__ */ new Map();
|
|
353
|
-
e.
|
|
354
|
-
|
|
353
|
+
let t = new Uint8Array(e.length), n = new Float64Array(e.length), r = new Int32Array(e.length), i = /* @__PURE__ */ new Map();
|
|
354
|
+
for (let a = 0; a < e.length; a++) {
|
|
355
|
+
let o = e[a], s = x(o);
|
|
356
|
+
if (t[a] = s, s === 0) {
|
|
357
|
+
n[a] = Number(o);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (s !== 1 && s !== 2) continue;
|
|
361
|
+
let c = String(o), l = i.get(c);
|
|
362
|
+
l === void 0 && (l = i.size, i.set(c, l)), r[a] = l;
|
|
363
|
+
}
|
|
364
|
+
let a = new Float64Array(i.size), o = Array.from(i.keys()).sort(y.compare), s = 0;
|
|
365
|
+
o.forEach((e, t) => {
|
|
366
|
+
t > 0 && y.compare(o[t - 1], e) !== 0 && s++, a[i.get(e) ?? 0] = s;
|
|
355
367
|
});
|
|
356
|
-
let i = 0
|
|
357
|
-
return
|
|
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
|
-
}), {
|
|
368
|
+
for (let i = 0; i < e.length; i++) (t[i] === 1 || t[i] === 2) && (n[i] = a[r[i]]);
|
|
369
|
+
return {
|
|
362
370
|
ranks: t,
|
|
363
371
|
keys: n
|
|
364
372
|
};
|
|
@@ -369,6 +377,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
369
377
|
sortModel = [];
|
|
370
378
|
sortDirty = !1;
|
|
371
379
|
sortChanged = /* @__PURE__ */ new Set();
|
|
380
|
+
defaultKeys = /* @__PURE__ */ new WeakMap();
|
|
372
381
|
environment;
|
|
373
382
|
constructor(e) {
|
|
374
383
|
this.environment = e;
|
|
@@ -448,33 +457,50 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
448
457
|
markSortDirty(e, t) {
|
|
449
458
|
this.sortModel.some(({ columnId: e }) => t.includes(String(e))) && (this.sortDirty = !0, this.sortChanged.add(String(e)));
|
|
450
459
|
}
|
|
460
|
+
defaultKeyOf(e) {
|
|
461
|
+
let t = this.defaultKeys.get(e);
|
|
462
|
+
if (t && t.version === e.version) return t.key;
|
|
463
|
+
let n = C(e.values);
|
|
464
|
+
return this.defaultKeys.set(e, {
|
|
465
|
+
version: e.version,
|
|
466
|
+
key: n
|
|
467
|
+
}), n;
|
|
468
|
+
}
|
|
451
469
|
createComparator(e) {
|
|
452
|
-
let t = this.sortModel
|
|
453
|
-
|
|
454
|
-
|
|
470
|
+
let [t, ...n] = this.sortModel, r = t && !t.compare && e && n.length === 0 ? this.columns.get(String(t.columnId)) : void 0;
|
|
471
|
+
if (r) {
|
|
472
|
+
let { ranks: e, keys: n } = this.defaultKeyOf(r), i = t.direction === "desc" ? -1 : 1;
|
|
473
|
+
return (t, r) => {
|
|
474
|
+
let a = e[t.slot] - e[r.slot] || n[t.slot] - n[r.slot] || 0;
|
|
475
|
+
return a === 0 ? t.slot - r.slot : a * i;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
let i = this.sortModel.map(({ columnId: t, direction: n = "asc", compare: r }) => {
|
|
479
|
+
let i = this.columns.get(String(t)), a = i?.values, o = n === "desc" ? -1 : 1;
|
|
480
|
+
if (!i || !a) return {
|
|
455
481
|
order: () => 0,
|
|
456
|
-
sign:
|
|
482
|
+
sign: o
|
|
457
483
|
};
|
|
458
484
|
if (r) return {
|
|
459
|
-
order: (e, t) => r(
|
|
460
|
-
sign:
|
|
485
|
+
order: (e, t) => r(a[e.slot], a[t.slot]),
|
|
486
|
+
sign: o
|
|
461
487
|
};
|
|
462
488
|
if (!e) return {
|
|
463
|
-
order: (e, t) => S(
|
|
464
|
-
sign:
|
|
489
|
+
order: (e, t) => S(a[e.slot], a[t.slot]),
|
|
490
|
+
sign: o
|
|
465
491
|
};
|
|
466
|
-
let { ranks:
|
|
492
|
+
let { ranks: s, keys: c } = this.defaultKeyOf(i);
|
|
467
493
|
return {
|
|
468
|
-
order: (e, t) =>
|
|
469
|
-
sign:
|
|
494
|
+
order: (e, t) => s[e.slot] - s[t.slot] || c[e.slot] - c[t.slot] || 0,
|
|
495
|
+
sign: o
|
|
470
496
|
};
|
|
471
497
|
});
|
|
472
|
-
return (e,
|
|
473
|
-
for (let { order:
|
|
474
|
-
let
|
|
475
|
-
if (
|
|
498
|
+
return (e, t) => {
|
|
499
|
+
for (let { order: n, sign: r } of i) {
|
|
500
|
+
let i = n(e, t);
|
|
501
|
+
if (i !== 0) return i * r;
|
|
476
502
|
}
|
|
477
|
-
return e.slot -
|
|
503
|
+
return e.slot - t.slot;
|
|
478
504
|
};
|
|
479
505
|
}
|
|
480
506
|
sort() {
|
|
@@ -518,29 +544,11 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
518
544
|
}
|
|
519
545
|
optionsUpdated(e) {}
|
|
520
546
|
clearCache() {}
|
|
521
|
-
}, M =
|
|
522
|
-
bitmaps = new T(4096);
|
|
523
|
-
cacheKey(e) {}
|
|
524
|
-
pixelRatio = 1;
|
|
525
|
-
clearCache() {
|
|
526
|
-
this.bitmaps.clear();
|
|
527
|
-
}
|
|
528
|
-
paint(e, t, n, r) {
|
|
529
|
-
let i = this.cacheKey(t), a = (i === void 0 ? void 0 : this.bitmaps.get(i)) ?? this.renderBitmap(t, i);
|
|
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);
|
|
531
|
-
}
|
|
532
|
-
element = O((e, t, n, r) => this.paint(e, t, n, r));
|
|
533
|
-
renderBitmap(e, t) {
|
|
534
|
-
let n = this.render(e);
|
|
535
|
-
if (t === void 0 || n.width <= 0 || n.height <= 0) return n;
|
|
536
|
-
let r = document.createElement("canvas");
|
|
537
|
-
return r.width = n.width, r.height = n.height, r.getContext("2d")?.drawImage(n, 0, 0), this.bitmaps.set(t, r), r;
|
|
538
|
-
}
|
|
539
|
-
}, N = (e, t) => {
|
|
547
|
+
}, M = (e, t) => {
|
|
540
548
|
let n = e.getContext("2d", t);
|
|
541
549
|
if (!n) throw Error("2D canvas context is not available");
|
|
542
550
|
return n;
|
|
543
|
-
},
|
|
551
|
+
}, N = class extends j {
|
|
544
552
|
ctx;
|
|
545
553
|
offCanvas = document.createElement("canvas");
|
|
546
554
|
offCtx;
|
|
@@ -548,7 +556,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
548
556
|
speed = 6;
|
|
549
557
|
count = 75;
|
|
550
558
|
constructor(e) {
|
|
551
|
-
super(e), this.ctx = this.options.ctx, this.offCanvas.width = 250, this.offCanvas.height = 250, this.offCtx =
|
|
559
|
+
super(e), this.ctx = this.options.ctx, this.offCanvas.width = 250, this.offCanvas.height = 250, this.offCtx = M(this.offCanvas), this.offCtx.lineWidth = .5, this.offCtx.strokeStyle = "rgba(255, 255, 255, 0.75)";
|
|
552
560
|
}
|
|
553
561
|
updateLoader() {
|
|
554
562
|
this.rotation += this.speed / 100;
|
|
@@ -564,12 +572,12 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
564
572
|
let e = Math.round((this.ctx.canvas.width - this.offCanvas.width) / 2), t = Math.round((this.ctx.canvas.height - this.offCanvas.height) / 2);
|
|
565
573
|
return this.ctx.clearRect(e, t, 250, 250), this.ctx.drawImage(this.offCanvas, e, t), this.offCanvas;
|
|
566
574
|
}
|
|
567
|
-
},
|
|
575
|
+
}, P = class {
|
|
568
576
|
name;
|
|
569
577
|
canvas = document.createElement("canvas");
|
|
570
578
|
ctx;
|
|
571
579
|
constructor(e, { alpha: t = !0, desynchronized: n = !1 } = {}) {
|
|
572
|
-
this.name = e, this.canvas.className = `drawingLayer ${e}`, this.ctx =
|
|
580
|
+
this.name = e, this.canvas.className = `drawingLayer ${e}`, this.ctx = M(this.canvas, {
|
|
573
581
|
alpha: t,
|
|
574
582
|
desynchronized: n
|
|
575
583
|
});
|
|
@@ -583,7 +591,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
583
591
|
clear() {
|
|
584
592
|
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
585
593
|
}
|
|
586
|
-
},
|
|
594
|
+
}, F = class {
|
|
587
595
|
renderers = /* @__PURE__ */ new Map();
|
|
588
596
|
warned = /* @__PURE__ */ new Set();
|
|
589
597
|
register(e, t) {
|
|
@@ -603,10 +611,10 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
603
611
|
clearCaches() {
|
|
604
612
|
this.renderers.forEach((e) => e.clearCache?.());
|
|
605
613
|
}
|
|
606
|
-
},
|
|
614
|
+
}, I = O((e, { x: t = 0, y: n = 0, width: r, height: i, color: a, alpha: o = 1 }, s, c) => {
|
|
607
615
|
let l = Math.trunc(r), u = Math.trunc(i);
|
|
608
616
|
!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));
|
|
609
|
-
}),
|
|
617
|
+
}), L = class e extends j {
|
|
610
618
|
static defaultOptions = {
|
|
611
619
|
layer: "background",
|
|
612
620
|
enableFlashing: !0,
|
|
@@ -638,67 +646,39 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
638
646
|
}
|
|
639
647
|
draw({ ctx: e, x: t, y: n, width: r, height: i, age: a }) {
|
|
640
648
|
let { background: o, flashRGB: s, borderRightWidth: c, borderRightColor: l, borderBottomWidth: u, borderBottomColor: d } = this.options, f = this.getFlashAlpha(a);
|
|
641
|
-
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(
|
|
649
|
+
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(I, {
|
|
642
650
|
width: r,
|
|
643
651
|
height: i,
|
|
644
652
|
color: o
|
|
645
|
-
}), f > 0 && /* @__PURE__ */ A.createElement(
|
|
653
|
+
}), f > 0 && /* @__PURE__ */ A.createElement(I, {
|
|
646
654
|
width: r,
|
|
647
655
|
height: i,
|
|
648
656
|
color: `rgb(${s})`,
|
|
649
657
|
alpha: f
|
|
650
|
-
}), c > 0 && /* @__PURE__ */ A.createElement(
|
|
658
|
+
}), c > 0 && /* @__PURE__ */ A.createElement(I, {
|
|
651
659
|
x: r - c,
|
|
652
660
|
width: c,
|
|
653
661
|
height: i,
|
|
654
662
|
color: l
|
|
655
|
-
}), u > 0 && /* @__PURE__ */ A.createElement(
|
|
663
|
+
}), u > 0 && /* @__PURE__ */ A.createElement(I, {
|
|
656
664
|
y: i - u,
|
|
657
665
|
width: r,
|
|
658
666
|
height: u,
|
|
659
667
|
color: d
|
|
660
668
|
}))).draw(e, t, n);
|
|
661
669
|
}
|
|
662
|
-
},
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
...e.defaultOptions,
|
|
675
|
-
...t
|
|
676
|
-
}), this.ctx = N(this.canvas, { alpha: this.options.alpha }), this.ctx.textAlign = "left", this.ctx.textBaseline = "top";
|
|
677
|
-
}
|
|
678
|
-
set font(e) {
|
|
679
|
-
this.options.font !== e && (this.options.font = e);
|
|
680
|
-
}
|
|
681
|
-
set color(e) {
|
|
682
|
-
this.options.color = e;
|
|
683
|
-
}
|
|
684
|
-
clearCache() {
|
|
685
|
-
super.clearCache(), this.charWidthCache.clear();
|
|
686
|
-
}
|
|
687
|
-
cacheKey({ value: e = "", height: t = 0 }) {
|
|
688
|
-
return `${this.options.font}|${this.options.color}|${this.pixelRatio}|${t}|${e}`;
|
|
689
|
-
}
|
|
690
|
-
getCharacterWidth(e = "") {
|
|
691
|
-
let t = this.charWidthCache.get(e);
|
|
692
|
-
if (t) return t;
|
|
693
|
-
this.ctx.font !== this.options.font && (this.ctx.font = this.options.font, this.ctx.textAlign = "left", this.ctx.textBaseline = "top");
|
|
694
|
-
let n = Math.ceil(this.ctx.measureText(e).width);
|
|
695
|
-
return this.charWidthCache.set(e, n), n;
|
|
696
|
-
}
|
|
697
|
-
render({ value: e = "", height: t = 0 }) {
|
|
698
|
-
let { pixelRatio: n } = this;
|
|
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;
|
|
700
|
-
}
|
|
701
|
-
}, B = class e extends j {
|
|
670
|
+
}, R = (e, t, n, r) => {
|
|
671
|
+
let i = 0, a = 0;
|
|
672
|
+
for (; a < e.length;) {
|
|
673
|
+
let n = r(e.charAt(a));
|
|
674
|
+
if (i + n > t) break;
|
|
675
|
+
i += n, a++;
|
|
676
|
+
}
|
|
677
|
+
if (a === e.length) return e;
|
|
678
|
+
let o = r(n);
|
|
679
|
+
for (; a > 0 && i + o > t;) a--, i -= r(e.charAt(a));
|
|
680
|
+
return i + o > t ? "" : e.slice(0, a) + n;
|
|
681
|
+
}, z = class e extends j {
|
|
702
682
|
static defaultOptions = {
|
|
703
683
|
ellipsis: "…",
|
|
704
684
|
cellPadding: {
|
|
@@ -711,64 +691,49 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
711
691
|
color: "#fff",
|
|
712
692
|
isEllipsisRight: !0
|
|
713
693
|
};
|
|
714
|
-
|
|
694
|
+
characterWidths = /* @__PURE__ */ new Map();
|
|
695
|
+
measureContext = M(document.createElement("canvas"));
|
|
696
|
+
measuredFont = "";
|
|
715
697
|
constructor(t = {}) {
|
|
716
698
|
super({
|
|
717
699
|
...e.defaultOptions,
|
|
718
700
|
...t
|
|
719
|
-
}), this.characterRenderer = new z({
|
|
720
|
-
font: this.options.font,
|
|
721
|
-
color: this.options.color
|
|
722
701
|
});
|
|
723
702
|
}
|
|
724
703
|
set font(e) {
|
|
725
|
-
this.options.font !== e && (this.options.font = e, this.
|
|
704
|
+
this.options.font !== e && (this.options.font = e, this.clearCache());
|
|
726
705
|
}
|
|
727
706
|
get font() {
|
|
728
707
|
return this.options.font;
|
|
729
708
|
}
|
|
730
709
|
set color(e) {
|
|
731
|
-
this.options.color = e
|
|
710
|
+
this.options.color = e;
|
|
732
711
|
}
|
|
733
712
|
get color() {
|
|
734
713
|
return this.options.color;
|
|
735
714
|
}
|
|
736
|
-
|
|
737
|
-
this.characterRenderer.pixelRatio = e;
|
|
738
|
-
}
|
|
739
|
-
get pixelRatio() {
|
|
740
|
-
return this.characterRenderer.pixelRatio;
|
|
741
|
-
}
|
|
715
|
+
pixelRatio = 1;
|
|
742
716
|
clearCache() {
|
|
743
|
-
this.
|
|
717
|
+
this.characterWidths.clear(), this.measuredFont = "";
|
|
718
|
+
}
|
|
719
|
+
measureCharacter(e) {
|
|
720
|
+
let t = this.characterWidths.get(e);
|
|
721
|
+
if (t !== void 0) return t;
|
|
722
|
+
this.measuredFont !== this.options.font && (this.measureContext.font = this.options.font, this.measuredFont = this.options.font);
|
|
723
|
+
let n = this.measureContext.measureText(e).width;
|
|
724
|
+
return this.characterWidths.set(e, n), n;
|
|
744
725
|
}
|
|
745
726
|
getTextWidth(e) {
|
|
746
727
|
let t = 0;
|
|
747
|
-
for (let n = 0; n < e.length; n++)
|
|
748
|
-
let r = e.charAt(n);
|
|
749
|
-
t += this.characterRenderer.getCharacterWidth(r);
|
|
750
|
-
}
|
|
728
|
+
for (let n = 0; n < e.length; n++) t += this.measureCharacter(e.charAt(n));
|
|
751
729
|
return t;
|
|
752
730
|
}
|
|
753
731
|
paint(e, { value: t = "", x: n = 0, y: r = 0, width: i = 0, height: a = 0 }, o, s) {
|
|
754
|
-
let c = this.
|
|
755
|
-
|
|
756
|
-
let r = t.charAt(n), i = Math.round(this.characterRenderer.getCharacterWidth(r));
|
|
757
|
-
if (Math.ceil(h + i) >= u) {
|
|
758
|
-
this.characterRenderer.paint(e, {
|
|
759
|
-
value: this.options.ellipsis,
|
|
760
|
-
height: p
|
|
761
|
-
}, d + m, f);
|
|
762
|
-
break;
|
|
763
|
-
}
|
|
764
|
-
this.characterRenderer.paint(e, {
|
|
765
|
-
value: r,
|
|
766
|
-
height: p
|
|
767
|
-
}, d + m, f), h += i, m += i;
|
|
768
|
-
}
|
|
732
|
+
let { cellPadding: c } = this.options, l = R(t, i - c.left - c.right, this.options.ellipsis, (e) => this.measureCharacter(e));
|
|
733
|
+
l === "" || a - c.top - c.bottom <= 0 || (e.font = this.options.font, e.fillStyle = this.options.color, e.textAlign = "left", e.textBaseline = "top", e.fillText(l, o + n + c.left, s + r + c.top));
|
|
769
734
|
}
|
|
770
735
|
element = O((e, t, n, r) => this.paint(e, t, n, r));
|
|
771
|
-
},
|
|
736
|
+
}, B = class e extends j {
|
|
772
737
|
static defaultOptions = {
|
|
773
738
|
layer: "header",
|
|
774
739
|
background: "#333",
|
|
@@ -784,7 +749,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
784
749
|
super({
|
|
785
750
|
...e.defaultOptions,
|
|
786
751
|
...t
|
|
787
|
-
}), this.textRenderer = new
|
|
752
|
+
}), this.textRenderer = new z({
|
|
788
753
|
font: this.options.font,
|
|
789
754
|
color: this.options.color
|
|
790
755
|
});
|
|
@@ -810,16 +775,16 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
810
775
|
draw({ ctx: e, x: t, y: n, width: r, height: i, formatted: a }) {
|
|
811
776
|
if (r === 0 || i === 0) return;
|
|
812
777
|
let { background: o, borderRightWidth: s, borderRightColor: c, borderBottomWidth: l, borderBottomColor: u } = this.options;
|
|
813
|
-
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(
|
|
778
|
+
(/* @__PURE__ */ A.createElement(k, null, /* @__PURE__ */ A.createElement(I, {
|
|
814
779
|
width: r,
|
|
815
780
|
height: i,
|
|
816
781
|
color: o
|
|
817
|
-
}), s > 0 && /* @__PURE__ */ A.createElement(
|
|
782
|
+
}), s > 0 && /* @__PURE__ */ A.createElement(I, {
|
|
818
783
|
x: r - s,
|
|
819
784
|
width: s,
|
|
820
785
|
height: i,
|
|
821
786
|
color: c
|
|
822
|
-
}), l > 0 && /* @__PURE__ */ A.createElement(
|
|
787
|
+
}), l > 0 && /* @__PURE__ */ A.createElement(I, {
|
|
823
788
|
y: i - l,
|
|
824
789
|
width: r,
|
|
825
790
|
height: l,
|
|
@@ -830,7 +795,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
830
795
|
height: i
|
|
831
796
|
}))).draw(e, t, n);
|
|
832
797
|
}
|
|
833
|
-
},
|
|
798
|
+
}, V = class e extends j {
|
|
834
799
|
static defaultOptions = {
|
|
835
800
|
layer: "content",
|
|
836
801
|
font: "12px monospace",
|
|
@@ -841,7 +806,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
841
806
|
super({
|
|
842
807
|
...e.defaultOptions,
|
|
843
808
|
...t
|
|
844
|
-
}), this.renderer = new
|
|
809
|
+
}), this.renderer = new z({
|
|
845
810
|
font: this.options.font,
|
|
846
811
|
color: this.options.color
|
|
847
812
|
});
|
|
@@ -877,18 +842,18 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
877
842
|
height: i
|
|
878
843
|
})).draw(e, t, n));
|
|
879
844
|
}
|
|
880
|
-
},
|
|
845
|
+
}, H = { scrollArea: "scrollArea" }, U = {
|
|
881
846
|
background: "background",
|
|
882
847
|
content: "content",
|
|
883
848
|
header: "header",
|
|
884
849
|
backgroundRenderer: "background",
|
|
885
850
|
valueRenderer: "value",
|
|
886
851
|
headerRenderer: "header"
|
|
887
|
-
},
|
|
888
|
-
if (document.getElementById(
|
|
852
|
+
}, W = "canvas-grid-styles", G = () => {
|
|
853
|
+
if (document.getElementById(W)) return;
|
|
889
854
|
let e = document.createElement("style");
|
|
890
|
-
e.id =
|
|
891
|
-
},
|
|
855
|
+
e.id = W, e.textContent = E, document.head.appendChild(e);
|
|
856
|
+
}, K = class extends HTMLElement {
|
|
892
857
|
fps = 30;
|
|
893
858
|
_font = "12px monospace";
|
|
894
859
|
_headerFont = "13px monospace";
|
|
@@ -928,10 +893,10 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
928
893
|
layers = [];
|
|
929
894
|
layersByName = /* @__PURE__ */ new Map();
|
|
930
895
|
warnedLayers = /* @__PURE__ */ new Set();
|
|
931
|
-
renderers = new
|
|
932
|
-
cellRenderers = [
|
|
933
|
-
cellBackgroundRenderer = new
|
|
934
|
-
layer:
|
|
896
|
+
renderers = new F();
|
|
897
|
+
cellRenderers = [U.backgroundRenderer, U.valueRenderer];
|
|
898
|
+
cellBackgroundRenderer = new L({
|
|
899
|
+
layer: U.background,
|
|
935
900
|
background: this._backgroundColor,
|
|
936
901
|
enableFlashing: !0,
|
|
937
902
|
flashInDuration: 200,
|
|
@@ -942,13 +907,13 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
942
907
|
borderBottomWidth: 1,
|
|
943
908
|
borderBottomColor: "#3f3f3f"
|
|
944
909
|
});
|
|
945
|
-
cellValueRenderer = new
|
|
946
|
-
layer:
|
|
910
|
+
cellValueRenderer = new V({
|
|
911
|
+
layer: U.content,
|
|
947
912
|
font: this._font,
|
|
948
913
|
color: this.textColor
|
|
949
914
|
});
|
|
950
|
-
headerCellRenderer = new
|
|
951
|
-
layer:
|
|
915
|
+
headerCellRenderer = new B({
|
|
916
|
+
layer: U.header,
|
|
952
917
|
font: this._headerFont,
|
|
953
918
|
color: this.textColor,
|
|
954
919
|
background: "#222",
|
|
@@ -966,8 +931,8 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
966
931
|
}, 50);
|
|
967
932
|
agApi;
|
|
968
933
|
constructor() {
|
|
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(
|
|
970
|
-
ctx: this.requireLayer(
|
|
934
|
+
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(U.background, { alpha: !1 }), this.addLayer(U.content), this.addLayer(U.header), this.registerRenderer(U.backgroundRenderer, this.cellBackgroundRenderer), this.registerRenderer(U.valueRenderer, this.cellValueRenderer), this.registerRenderer(U.headerRenderer, this.headerCellRenderer), this.loadingIndicator = new N({ ctx: this.requireLayer(U.header).ctx }), this.cell = {
|
|
935
|
+
ctx: this.requireLayer(U.content).ctx,
|
|
971
936
|
x: 0,
|
|
972
937
|
y: 0,
|
|
973
938
|
width: 0,
|
|
@@ -999,7 +964,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
999
964
|
};
|
|
1000
965
|
}
|
|
1001
966
|
get canvas() {
|
|
1002
|
-
return this.requireLayer(
|
|
967
|
+
return this.requireLayer(U.content).canvas;
|
|
1003
968
|
}
|
|
1004
969
|
get flashInDuration() {
|
|
1005
970
|
return this.cellBackgroundRenderer.options.flashInDuration;
|
|
@@ -1023,7 +988,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1023
988
|
}
|
|
1024
989
|
addLayer(e, { alpha: t = !0, desynchronized: n = !1, before: r } = {}) {
|
|
1025
990
|
if (this.getLayer(e)) throw Error(`canvas-grid: layer "${e}" already exists`);
|
|
1026
|
-
let i = new
|
|
991
|
+
let i = new P(e, {
|
|
1027
992
|
alpha: t,
|
|
1028
993
|
desynchronized: n
|
|
1029
994
|
}), a = r === void 0 ? void 0 : this.requireLayer(r);
|
|
@@ -1041,7 +1006,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1041
1006
|
}
|
|
1042
1007
|
createScrollArea() {
|
|
1043
1008
|
let e = document.createElement("div");
|
|
1044
|
-
return e.className =
|
|
1009
|
+
return e.className = H.scrollArea, e.appendChild(this.scrollHelper), e;
|
|
1045
1010
|
}
|
|
1046
1011
|
set font(e) {
|
|
1047
1012
|
this._font !== e && (this._font = e, this.cellValueRenderer.font = e);
|
|
@@ -1186,7 +1151,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1186
1151
|
index: e.index
|
|
1187
1152
|
},
|
|
1188
1153
|
formatted: `${e.index + 1}`
|
|
1189
|
-
}), this.paint(
|
|
1154
|
+
}), this.paint(U.headerRenderer));
|
|
1190
1155
|
}
|
|
1191
1156
|
forceDraw() {
|
|
1192
1157
|
this.layers.forEach((e) => e.clear()), this.draw(!0);
|
|
@@ -1230,7 +1195,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1230
1195
|
return this.dataStore.getSortModel();
|
|
1231
1196
|
}
|
|
1232
1197
|
renderBrick() {
|
|
1233
|
-
this.showHeaders && this.showRowNumbers && this._headerBackgroundColor && (this.describe(0, 0, this.rowNumbersWidth, this.headerHeight, {}), this.paint(
|
|
1198
|
+
this.showHeaders && this.showRowNumbers && this._headerBackgroundColor && (this.describe(0, 0, this.rowNumbersWidth, this.headerHeight, {}), this.paint(U.headerRenderer));
|
|
1234
1199
|
}
|
|
1235
1200
|
renderHeaders() {
|
|
1236
1201
|
let e = (this.showRowNumbers ? this.rowNumbersWidth : 0) - this.scrollXOffset;
|
|
@@ -1279,7 +1244,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1279
1244
|
let t = {
|
|
1280
1245
|
width: 100,
|
|
1281
1246
|
valueFormatter: (e) => String(e),
|
|
1282
|
-
headerRenderer:
|
|
1247
|
+
headerRenderer: U.headerRenderer
|
|
1283
1248
|
};
|
|
1284
1249
|
e.forEach((e, n) => {
|
|
1285
1250
|
if (typeof e == "string" || typeof e == "number") {
|
|
@@ -1303,7 +1268,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
1303
1268
|
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);
|
|
1304
1269
|
}
|
|
1305
1270
|
};
|
|
1306
|
-
window && window.customElements && (
|
|
1307
|
-
export {
|
|
1271
|
+
window && window.customElements && (G(), customElements.define("canvas-grid", K));
|
|
1272
|
+
export { K as default };
|
|
1308
1273
|
|
|
1309
1274
|
//# sourceMappingURL=web-component.mjs.map
|