@genexus/genexus-ide-ui 0.0.10 → 0.0.12
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/README.md +18 -256
- package/dist/cjs/ch-grid-row-actions.cjs.entry.js +30 -1
- package/dist/cjs/ch-grid-rowset-legend.cjs.entry.js +16 -3
- package/dist/cjs/ch-grid_9.cjs.entry.js +292 -247
- package/dist/cjs/ch-suggest.cjs.entry.js +9 -8
- package/dist/cjs/ch-tree-item.cjs.entry.js +1 -1
- package/dist/cjs/genexus-ide-ui.cjs.js +1 -1
- package/dist/cjs/gx-ide-new-kb.cjs.entry.js +7 -7
- package/dist/cjs/gx-ide-test.cjs.entry.js +3 -2
- package/dist/cjs/gxg-combo-box_8.cjs.entry.js +69 -54
- package/dist/cjs/gxg-form-text.cjs.entry.js +23 -13
- package/dist/cjs/gxg-form-textarea.cjs.entry.js +1 -1
- package/dist/cjs/gxg-list-box-item.cjs.entry.js +5 -2
- package/dist/cjs/gxg-list-box.cjs.entry.js +1 -1
- package/dist/cjs/gxg-test.cjs.entry.js +5 -3
- package/dist/cjs/gxg-tree-item.cjs.entry.js +1 -1
- package/dist/cjs/gxg-tree.cjs.entry.js +2 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/common/render-tree.js +2 -1
- package/dist/collection/components/_test/test.js +1 -1
- package/dist/collection/components/new-kb/new-kb.js +10 -10
- package/dist/components/ch-grid-row-actions.js +52 -4
- package/dist/components/ch-grid-rowset-legend.js +32 -1
- package/dist/components/ch-grid2.js +295 -249
- package/dist/components/ch-suggest.js +10 -9
- package/dist/components/ch-tree-item.js +1 -1
- package/dist/components/combo-box-item.js +18 -18
- package/dist/components/combo-box.js +51 -36
- package/dist/components/form-text.js +25 -13
- package/dist/components/gx-ide-new-kb.js +9 -9
- package/dist/components/gx-ide-test.js +3 -2
- package/dist/components/gxg-form-textarea.js +1 -1
- package/dist/components/gxg-list-box-item.js +5 -2
- package/dist/components/gxg-list-box.js +1 -1
- package/dist/components/gxg-test.js +5 -3
- package/dist/components/gxg-tree-item2.js +1 -2
- package/dist/components/gxg-tree2.js +2 -1
- package/dist/esm/ch-grid-row-actions.entry.js +31 -2
- package/dist/esm/ch-grid-rowset-legend.entry.js +19 -2
- package/dist/esm/ch-grid_9.entry.js +292 -247
- package/dist/esm/ch-suggest.entry.js +9 -8
- package/dist/esm/ch-tree-item.entry.js +1 -1
- package/dist/esm/genexus-ide-ui.js +1 -1
- package/dist/esm/gx-ide-new-kb.entry.js +7 -7
- package/dist/esm/gx-ide-test.entry.js +3 -2
- package/dist/esm/gxg-combo-box_8.entry.js +69 -54
- package/dist/esm/gxg-form-text.entry.js +23 -13
- package/dist/esm/gxg-form-textarea.entry.js +1 -1
- package/dist/esm/gxg-list-box-item.entry.js +5 -2
- package/dist/esm/gxg-list-box.entry.js +1 -1
- package/dist/esm/gxg-test.entry.js +5 -3
- package/dist/esm/gxg-tree-item.entry.js +1 -1
- package/dist/esm/gxg-tree.entry.js +2 -1
- package/dist/esm/loader.js +1 -1
- package/dist/genexus-ide-ui/genexus-ide-ui.css +2 -2
- package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
- package/dist/genexus-ide-ui/p-01795e05.entry.js +1 -0
- package/dist/genexus-ide-ui/p-1367be09.entry.js +1 -0
- package/dist/genexus-ide-ui/p-18c86754.entry.js +1 -0
- package/dist/genexus-ide-ui/p-26b1d9c2.entry.js +1 -0
- package/dist/genexus-ide-ui/p-3c6099ff.entry.js +1 -0
- package/dist/genexus-ide-ui/p-4144fe18.entry.js +1 -0
- package/dist/genexus-ide-ui/p-421bd2fb.entry.js +1 -0
- package/dist/genexus-ide-ui/p-5faaf0e5.entry.js +1 -0
- package/dist/genexus-ide-ui/{p-45bf6aaf.entry.js → p-7b79281c.entry.js} +1 -1
- package/dist/genexus-ide-ui/p-7dead490.entry.js +1 -0
- package/dist/genexus-ide-ui/p-8f89e354.entry.js +1 -0
- package/dist/genexus-ide-ui/{p-bb9e6db0.entry.js → p-a04ce551.entry.js} +1 -1
- package/dist/genexus-ide-ui/p-b31a9621.entry.js +1 -0
- package/dist/genexus-ide-ui/{p-3546b5f7.entry.js → p-c0360787.entry.js} +1 -1
- package/dist/genexus-ide-ui/{p-4c6b4be3.entry.js → p-f23610f0.entry.js} +1 -1
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/grid/ch-grid.css +0 -9
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/grid/grid-row-actions/ch-grid-row-actions.css +3 -0
- package/dist/node_modules/@genexus/gemini/dist/collection/components/combo-box-item/combo-box-item.css +14 -14
- package/dist/node_modules/@genexus/gemini/dist/collection/components/form-text/form-text.css +1 -1
- package/dist/node_modules/@genexus/gemini/dist/collection/components/form-textarea/form-textarea.css +1 -1
- package/dist/node_modules/@genexus/gemini/dist/collection/components/list-box/list-box.css +1 -1
- package/dist/node_modules/@genexus/gemini/dist/collection/components/list-box-item/list-box-item.css +12 -9
- package/dist/types/common/render-tree.d.ts +1 -1
- package/dist/types/components/new-kb/new-kb.d.ts +2 -2
- package/dist/types/components.d.ts +20 -16
- package/package.json +2 -2
- package/dist/cjs/ch-grid-rowset-legend-d29e1c7d.js +0 -22
- package/dist/components/ch-grid-rowset-legend2.js +0 -35
- package/dist/esm/ch-grid-rowset-legend-d6a0dd68.js +0 -20
- package/dist/genexus-ide-ui/p-17827fd8.js +0 -1
- package/dist/genexus-ide-ui/p-4298cd04.entry.js +0 -1
- package/dist/genexus-ide-ui/p-5aa4d5cc.entry.js +0 -1
- package/dist/genexus-ide-ui/p-715bf2d4.entry.js +0 -1
- package/dist/genexus-ide-ui/p-761e8fa3.entry.js +0 -1
- package/dist/genexus-ide-ui/p-93f9f73b.entry.js +0 -1
- package/dist/genexus-ide-ui/p-b218be5e.entry.js +0 -1
- package/dist/genexus-ide-ui/p-c0a96223.entry.js +0 -1
- package/dist/genexus-ide-ui/p-c132ce73.entry.js +0 -1
- package/dist/genexus-ide-ui/p-d3e6590c.entry.js +0 -1
- package/dist/genexus-ide-ui/p-d57c8f13.entry.js +0 -1
- package/dist/genexus-ide-ui/p-d5cf33f2.entry.js +0 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-93a6a7e0.js');
|
|
6
|
-
const chGridRowsetLegend = require('./ch-grid-rowset-legend-d29e1c7d.js');
|
|
7
6
|
const helpers = require('./helpers-00cb4402.js');
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -205,7 +204,6 @@ class HTMLChGridRowElement extends HTMLElement {
|
|
|
205
204
|
return this.parentGrid;
|
|
206
205
|
}
|
|
207
206
|
}
|
|
208
|
-
HTMLChGridRowElement.TAG_NAME = "CH-GRID-ROW";
|
|
209
207
|
if (!customElements.get("ch-grid-row")) {
|
|
210
208
|
customElements.define("ch-grid-row", HTMLChGridRowElement);
|
|
211
209
|
}
|
|
@@ -289,19 +287,18 @@ class HTMLChGridRowsetElement extends HTMLElement {
|
|
|
289
287
|
}
|
|
290
288
|
hasLegend() {
|
|
291
289
|
var _a;
|
|
292
|
-
return ((_a = this.firstElementChild) === null || _a === void 0 ? void 0 : _a.tagName) ===
|
|
290
|
+
return ((_a = this.firstElementChild) === null || _a === void 0 ? void 0 : _a.tagName) === "ch-grid-rowset-legend";
|
|
293
291
|
}
|
|
294
292
|
isNestedRow() {
|
|
295
|
-
return this.parentElement.tagName ===
|
|
293
|
+
return this.parentElement.tagName === "CH-GRID-ROW";
|
|
296
294
|
}
|
|
297
295
|
getParentRowset() {
|
|
298
296
|
const node = this.parentElement.closest("ch-grid-rowset, ch-grid");
|
|
299
|
-
if (node.tagName ===
|
|
297
|
+
if (node.tagName === "CH-GRID-ROWSET") {
|
|
300
298
|
return node;
|
|
301
299
|
}
|
|
302
300
|
}
|
|
303
301
|
}
|
|
304
|
-
HTMLChGridRowsetElement.TAG_NAME = "CH-GRID-ROWSET";
|
|
305
302
|
if (!customElements.get("ch-grid-rowset")) {
|
|
306
303
|
customElements.define("ch-grid-rowset", HTMLChGridRowsetElement);
|
|
307
304
|
}
|
|
@@ -447,7 +444,10 @@ class HTMLChGridCellElement extends HTMLElement {
|
|
|
447
444
|
}));
|
|
448
445
|
}
|
|
449
446
|
actionClickHandler() {
|
|
450
|
-
|
|
447
|
+
this.dispatchEvent(new CustomEvent("cellRowActionClicked", {
|
|
448
|
+
bubbles: true,
|
|
449
|
+
composed: true
|
|
450
|
+
}));
|
|
451
451
|
}
|
|
452
452
|
definePlain() {
|
|
453
453
|
this.cellType = ChGridCellType.Plain;
|
|
@@ -488,10 +488,11 @@ class HTMLChGridCellElement extends HTMLElement {
|
|
|
488
488
|
this.action.addEventListener("click", this.actionClickHandler.bind(this));
|
|
489
489
|
}
|
|
490
490
|
if (this.rowSelector) {
|
|
491
|
-
this.addEventListener("mousedown", (eventInfo) => eventInfo.stopPropagation());
|
|
492
491
|
this.selector = this.shadowRoot.querySelector("[part='selector']");
|
|
492
|
+
this.selector.addEventListener("mousedown", (eventInfo) => eventInfo.stopPropagation());
|
|
493
493
|
this.selector.addEventListener("click", this.selectorClickHandler.bind(this));
|
|
494
494
|
this.selectorLabel = this.shadowRoot.querySelector("[part='selector-label']");
|
|
495
|
+
this.selectorLabel.addEventListener("mousedown", (eventInfo) => eventInfo.stopPropagation());
|
|
495
496
|
this.selectorLabel.addEventListener("click", this.selectorLabelClickHandler.bind(this));
|
|
496
497
|
}
|
|
497
498
|
}
|
|
@@ -513,80 +514,90 @@ class HTMLChGridCellElement extends HTMLElement {
|
|
|
513
514
|
}
|
|
514
515
|
}
|
|
515
516
|
}
|
|
516
|
-
HTMLChGridCellElement.TAG_NAME = "CH-GRID-CELL";
|
|
517
517
|
if (!customElements.get("ch-grid-cell")) {
|
|
518
518
|
customElements.define("ch-grid-cell", HTMLChGridCellElement);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
class ChGridManagerColumnDrag {
|
|
522
|
-
constructor(columnId, columns) {
|
|
522
|
+
constructor(columnId, columns, isRTL) {
|
|
523
523
|
this.lastTargetOrder = 0;
|
|
524
|
+
this.isRTL = isRTL;
|
|
524
525
|
this.columns = columns.map(column => ({
|
|
525
|
-
column,
|
|
526
|
+
element: column,
|
|
526
527
|
rect: column.getBoundingClientRect(),
|
|
527
528
|
translateX: 0,
|
|
528
529
|
order: column.order
|
|
529
530
|
}));
|
|
530
|
-
this.column = this.columns.find(item => item.
|
|
531
|
+
this.column = this.columns.find(item => item.element.columnId === columnId);
|
|
531
532
|
this.columns.forEach(this.setColumnHiddenRect.bind(this));
|
|
532
533
|
}
|
|
533
534
|
dragging(position) {
|
|
534
535
|
/**
|
|
535
536
|
* Indica el orden inicial de la columna que se está arrastrando
|
|
536
537
|
*/
|
|
537
|
-
const sourceOrder = this.column.
|
|
538
|
+
const sourceOrder = this.column.element.order;
|
|
538
539
|
/**
|
|
539
540
|
* Indica a qué grupo de fijación pertenece la columna que se está arrastrando
|
|
540
541
|
*/
|
|
541
|
-
const sourceFreeze = this.column.
|
|
542
|
+
const sourceFreeze = this.column.element.freeze;
|
|
542
543
|
let targetOrder = 0;
|
|
543
544
|
let targetOrderChanged = false;
|
|
544
545
|
this.column.translateX = 0;
|
|
545
546
|
this.columns
|
|
546
|
-
.filter(
|
|
547
|
-
.forEach(
|
|
547
|
+
.filter(column => column.element.freeze === sourceFreeze)
|
|
548
|
+
.forEach(column => {
|
|
548
549
|
/**
|
|
549
550
|
* Indica el orden de la columna actual
|
|
550
551
|
*/
|
|
551
|
-
const columnOrder =
|
|
552
|
+
const columnOrder = column.element.order;
|
|
552
553
|
/**
|
|
553
554
|
* Indica si la columna que se está arrastrando estaba a la derecha o
|
|
554
555
|
* a la izquierda de la actual cuando se inició el arrastre para
|
|
555
|
-
*
|
|
556
|
+
* incrementar el orden según corresponda.
|
|
556
557
|
*/
|
|
557
|
-
const dragDirection = sourceOrder > columnOrder ?
|
|
558
|
+
const dragDirection = sourceOrder > columnOrder ? 1 : -1;
|
|
558
559
|
/**
|
|
559
560
|
* Indica si la columna actual hay que desplazarla a la derecha o
|
|
560
561
|
* a la izquierda cuando se cruce con la columna arrastrada.
|
|
561
562
|
*/
|
|
562
|
-
const shiftDirection = sourceOrder > columnOrder ? 1 : -1;
|
|
563
|
-
if (
|
|
564
|
-
position <
|
|
563
|
+
const shiftDirection = (sourceOrder > columnOrder ? 1 : -1) * (this.isRTL ? -1 : 1);
|
|
564
|
+
if (column.rect.left < position &&
|
|
565
|
+
position < column.rect.right &&
|
|
565
566
|
columnOrder !== sourceOrder) {
|
|
566
567
|
/*
|
|
567
568
|
La posicion actual del mouse está dentro de la columna actual y
|
|
568
569
|
no es la columna que se está arrastrando
|
|
569
570
|
*/
|
|
570
|
-
this.swapColumnPosition(
|
|
571
|
+
this.swapColumnPosition(column, shiftDirection);
|
|
572
|
+
// actualizo el orden de la columna actual
|
|
573
|
+
column.order = column.element.order + dragDirection;
|
|
571
574
|
targetOrder = columnOrder;
|
|
572
575
|
}
|
|
573
|
-
else if (position <
|
|
576
|
+
else if (position < column.rect.left &&
|
|
577
|
+
(this.isRTL ? columnOrder > sourceOrder : columnOrder < sourceOrder)) {
|
|
574
578
|
/*
|
|
575
579
|
La posicion actual del mouse está a la izquierda de la columna actual
|
|
576
580
|
haciendo que la columna arrastrada cruce la actual.
|
|
577
581
|
*/
|
|
578
|
-
this.swapColumnPosition(
|
|
579
|
-
|
|
582
|
+
this.swapColumnPosition(column, shiftDirection);
|
|
583
|
+
// actualizo el orden de la columna actual
|
|
584
|
+
column.order = column.element.order + dragDirection;
|
|
585
|
+
if (!targetOrder ||
|
|
586
|
+
(this.isRTL ? columnOrder > targetOrder : columnOrder < targetOrder)) {
|
|
580
587
|
targetOrder = columnOrder;
|
|
581
588
|
}
|
|
582
589
|
}
|
|
583
|
-
else if (position >
|
|
590
|
+
else if (position > column.rect.right &&
|
|
591
|
+
(this.isRTL ? columnOrder < sourceOrder : columnOrder > sourceOrder)) {
|
|
584
592
|
/*
|
|
585
593
|
La posicion actual del mouse está a la derecha de la columna actual
|
|
586
594
|
haciendo que la columna arrastrada cruce la actual.
|
|
587
595
|
*/
|
|
588
|
-
this.swapColumnPosition(
|
|
589
|
-
|
|
596
|
+
this.swapColumnPosition(column, shiftDirection);
|
|
597
|
+
// actualizo el orden de la columna actual
|
|
598
|
+
column.order = column.element.order + dragDirection;
|
|
599
|
+
if (!targetOrder ||
|
|
600
|
+
(this.isRTL ? columnOrder < targetOrder : columnOrder > targetOrder)) {
|
|
590
601
|
targetOrder = columnOrder;
|
|
591
602
|
}
|
|
592
603
|
}
|
|
@@ -595,84 +606,84 @@ class ChGridManagerColumnDrag {
|
|
|
595
606
|
La posicion actual del mouse NO está dentro de la columna actual ni
|
|
596
607
|
la cruza.
|
|
597
608
|
*/
|
|
598
|
-
this.resetColumnPosition(
|
|
609
|
+
this.resetColumnPosition(column);
|
|
599
610
|
}
|
|
600
611
|
});
|
|
601
|
-
this.column.order = targetOrder ? targetOrder : this.column.
|
|
612
|
+
this.column.order = targetOrder ? targetOrder : this.column.element.order;
|
|
602
613
|
targetOrderChanged = targetOrder !== this.lastTargetOrder;
|
|
603
614
|
this.lastTargetOrder = targetOrder;
|
|
604
615
|
return targetOrderChanged;
|
|
605
616
|
}
|
|
606
617
|
dragEnd() {
|
|
607
|
-
this.columns.forEach(
|
|
608
|
-
|
|
609
|
-
|
|
618
|
+
this.columns.forEach(column => {
|
|
619
|
+
column.element.order = column.order;
|
|
620
|
+
column.translateX = 0;
|
|
610
621
|
});
|
|
611
622
|
}
|
|
612
623
|
getColumnStyle(column) {
|
|
613
624
|
return {
|
|
614
|
-
[`--ch-grid-column-${column.physicalOrder}-transform`]: `translateX(${this.columns
|
|
625
|
+
[`--ch-grid-column-${column.physicalOrder}-transform`]: `translateX(${this.columns.find(columnItem => columnItem.element === column)
|
|
626
|
+
.translateX}px)`
|
|
615
627
|
};
|
|
616
628
|
}
|
|
617
629
|
getColumnsFirstLast() {
|
|
618
630
|
let itemFirst;
|
|
619
631
|
let itemLast;
|
|
620
632
|
this.columns.forEach(item => {
|
|
621
|
-
if (!item.
|
|
633
|
+
if (!item.element.hidden &&
|
|
634
|
+
(!itemFirst || item.order < itemFirst.order)) {
|
|
622
635
|
itemFirst = item;
|
|
623
636
|
}
|
|
624
|
-
if (!item.
|
|
637
|
+
if (!item.element.hidden && (!itemLast || item.order > itemLast.order)) {
|
|
625
638
|
itemLast = item;
|
|
626
639
|
}
|
|
627
640
|
});
|
|
628
641
|
return {
|
|
629
|
-
columnFirst: itemFirst.
|
|
630
|
-
columnLast: itemLast.
|
|
642
|
+
columnFirst: itemFirst.element,
|
|
643
|
+
columnLast: itemLast.element
|
|
631
644
|
};
|
|
632
645
|
}
|
|
633
|
-
swapColumnPosition(column,
|
|
646
|
+
swapColumnPosition(column, shiftDirection) {
|
|
634
647
|
// desplazo la columna actual para ocupar el espacio que dejó
|
|
635
648
|
// la columna arrastrada
|
|
636
649
|
column.translateX = this.column.rect.width * shiftDirection;
|
|
637
|
-
// actualizo el orden de la columna actual
|
|
638
|
-
column.order = column.column.order + shiftDirection;
|
|
639
650
|
// desplazo la columna que se está arrastrando para que ocupe el
|
|
640
651
|
// espacio que dejó la columna actual
|
|
641
|
-
this.column.translateX += column.rect.width *
|
|
652
|
+
this.column.translateX += column.rect.width * (shiftDirection * -1);
|
|
642
653
|
}
|
|
643
654
|
resetColumnPosition(column) {
|
|
644
655
|
// no desplazo la columna actual
|
|
645
656
|
column.translateX = 0;
|
|
646
657
|
// asigno su posición original
|
|
647
|
-
column.order = column.
|
|
658
|
+
column.order = column.element.order;
|
|
648
659
|
}
|
|
649
|
-
setColumnHiddenRect(
|
|
650
|
-
if (
|
|
651
|
-
const columnSibling = this.getPreviousSiblingVisible(
|
|
652
|
-
this.getNextSiblingVisible(
|
|
653
|
-
|
|
660
|
+
setColumnHiddenRect(column) {
|
|
661
|
+
if (column.element.hidden) {
|
|
662
|
+
const columnSibling = this.getPreviousSiblingVisible(column) ||
|
|
663
|
+
this.getNextSiblingVisible(column);
|
|
664
|
+
column.rect = new DOMRect(column.element.order < columnSibling.element.order
|
|
654
665
|
? columnSibling.rect.left
|
|
655
666
|
: columnSibling.rect.right, columnSibling.rect.y, 0, columnSibling.rect.height);
|
|
656
667
|
}
|
|
657
668
|
}
|
|
658
669
|
getPreviousSiblingVisible(hidden) {
|
|
659
670
|
let previous;
|
|
660
|
-
this.columns.forEach(
|
|
661
|
-
if (!
|
|
662
|
-
|
|
663
|
-
(!previous ||
|
|
664
|
-
previous =
|
|
671
|
+
this.columns.forEach(column => {
|
|
672
|
+
if (!column.element.hidden &&
|
|
673
|
+
column.element.order < hidden.element.order &&
|
|
674
|
+
(!previous || column.element.order > previous.element.order)) {
|
|
675
|
+
previous = column;
|
|
665
676
|
}
|
|
666
677
|
});
|
|
667
678
|
return previous;
|
|
668
679
|
}
|
|
669
680
|
getNextSiblingVisible(hidden) {
|
|
670
681
|
let next;
|
|
671
|
-
this.columns.forEach(
|
|
672
|
-
if (!
|
|
673
|
-
|
|
674
|
-
(!next ||
|
|
675
|
-
next =
|
|
682
|
+
this.columns.forEach(column => {
|
|
683
|
+
if (!column.element.hidden &&
|
|
684
|
+
column.element.order > hidden.element.order &&
|
|
685
|
+
(!next || column.element.order < next.element.order)) {
|
|
686
|
+
next = column;
|
|
676
687
|
}
|
|
677
688
|
});
|
|
678
689
|
return next;
|
|
@@ -680,12 +691,13 @@ class ChGridManagerColumnDrag {
|
|
|
680
691
|
}
|
|
681
692
|
|
|
682
693
|
class ChGridManagerColumns {
|
|
683
|
-
constructor(
|
|
694
|
+
constructor(manager) {
|
|
684
695
|
this.columnsetObserver = new MutationObserver(this.reloadColumns.bind(this));
|
|
685
696
|
this.columnResizeObserver = new ResizeObserver(this.resizeColumnHandler.bind(this));
|
|
686
697
|
this.columnsDisplay = [];
|
|
687
|
-
this.
|
|
688
|
-
this.
|
|
698
|
+
this.columnsWidth = [];
|
|
699
|
+
this.manager = manager;
|
|
700
|
+
this.columns = Array.from(this.manager.grid.querySelectorAll("ch-grid-column"));
|
|
689
701
|
this.observeColumnset();
|
|
690
702
|
this.defineColumns(this.columns);
|
|
691
703
|
this.defineColumnsVariables();
|
|
@@ -773,7 +785,7 @@ class ChGridManagerColumns {
|
|
|
773
785
|
this.columnsDisplay[i].setAttribute("slot", "column-display");
|
|
774
786
|
this.columnsDisplay[i].setAttribute("class", column.displayObserverClass);
|
|
775
787
|
this.columnsDisplay[i].column = column;
|
|
776
|
-
this.grid.
|
|
788
|
+
this.manager.grid.appendChild(this.columnsDisplay[i]);
|
|
777
789
|
}
|
|
778
790
|
}
|
|
779
791
|
defineColumnResizeObserver(column) {
|
|
@@ -782,14 +794,14 @@ class ChGridManagerColumns {
|
|
|
782
794
|
defineColumnType(column) {
|
|
783
795
|
switch (column.columnType) {
|
|
784
796
|
case "tree":
|
|
785
|
-
this.grid
|
|
797
|
+
this.manager.grid
|
|
786
798
|
.querySelectorAll(`ch-grid-cell:nth-child(${column.physicalOrder})`)
|
|
787
799
|
.forEach((cell) => {
|
|
788
800
|
cell.type = ChGridCellType.TreeNode;
|
|
789
801
|
});
|
|
790
802
|
break;
|
|
791
803
|
case "rich":
|
|
792
|
-
this.grid
|
|
804
|
+
this.manager.grid
|
|
793
805
|
.querySelectorAll(`ch-grid-cell:nth-child(${column.physicalOrder})`)
|
|
794
806
|
.forEach((cell) => {
|
|
795
807
|
cell.rowDrag = column.richRowDrag;
|
|
@@ -853,10 +865,10 @@ class ChGridManagerColumns {
|
|
|
853
865
|
});
|
|
854
866
|
}
|
|
855
867
|
observeColumnset() {
|
|
856
|
-
this.columnsetObserver.observe(this.grid.
|
|
868
|
+
this.columnsetObserver.observe(this.manager.grid.querySelector("ch-grid-columnset"), { childList: true });
|
|
857
869
|
}
|
|
858
870
|
reloadColumns() {
|
|
859
|
-
const columns = Array.from(this.grid.
|
|
871
|
+
const columns = Array.from(this.manager.grid.querySelectorAll("ch-grid-column"));
|
|
860
872
|
const columnsAdded = columns.filter(column => !this.columns.includes(column));
|
|
861
873
|
const columnsRemoved = this.columns.filter(column => !columns.includes(column));
|
|
862
874
|
if (columnsAdded.length || columnsRemoved.length) {
|
|
@@ -871,8 +883,9 @@ class ChGridManagerColumns {
|
|
|
871
883
|
resizeColumnHandler(entries) {
|
|
872
884
|
for (const entry of entries) {
|
|
873
885
|
const column = entry.target;
|
|
874
|
-
this.
|
|
886
|
+
this.columnsWidth[column.physicalOrder - 1] = entry.contentRect.width;
|
|
875
887
|
}
|
|
888
|
+
this.manager.setColumnWidthVariables(this.columnsWidth);
|
|
876
889
|
}
|
|
877
890
|
getColumnUniqueId() {
|
|
878
891
|
const uniqueId = Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
@@ -887,7 +900,7 @@ class ChGridManagerColumns {
|
|
|
887
900
|
});
|
|
888
901
|
}
|
|
889
902
|
adjustBaseLayer() {
|
|
890
|
-
this.
|
|
903
|
+
this.manager.setBaseLayer(this.columns.length);
|
|
891
904
|
}
|
|
892
905
|
fnSortByOrder(columnA, columnB) {
|
|
893
906
|
if (columnA.order < columnB.order) {
|
|
@@ -901,20 +914,20 @@ class ChGridManagerColumns {
|
|
|
901
914
|
}
|
|
902
915
|
|
|
903
916
|
class ChGridManagerSelection {
|
|
904
|
-
constructor(
|
|
917
|
+
constructor(manager) {
|
|
905
918
|
this.selectionStateNone = {
|
|
906
919
|
rowFocused: null,
|
|
907
920
|
rowsSelected: [],
|
|
908
921
|
cellSelected: null
|
|
909
922
|
};
|
|
910
|
-
this.
|
|
923
|
+
this.manager = manager;
|
|
911
924
|
}
|
|
912
925
|
select(state, row, cell, append, range) {
|
|
913
926
|
var _a;
|
|
914
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
927
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
915
928
|
return this.selectionStateNone;
|
|
916
929
|
}
|
|
917
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
930
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
918
931
|
append = false;
|
|
919
932
|
range = false;
|
|
920
933
|
}
|
|
@@ -923,7 +936,7 @@ class ChGridManagerSelection {
|
|
|
923
936
|
let cellSelected = state.cellSelected;
|
|
924
937
|
rowFocused = row;
|
|
925
938
|
if (range) {
|
|
926
|
-
const rangeRows = this.
|
|
939
|
+
const rangeRows = this.manager.getRowsRange((_a = this.rangeStart) !== null && _a !== void 0 ? _a : row, row);
|
|
927
940
|
if (this.rangeValue) {
|
|
928
941
|
if (append) {
|
|
929
942
|
rowsSelected = Array.from(new Set(rowsSelected.concat(rangeRows)));
|
|
@@ -934,7 +947,7 @@ class ChGridManagerSelection {
|
|
|
934
947
|
}
|
|
935
948
|
cellSelected =
|
|
936
949
|
cell ||
|
|
937
|
-
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.
|
|
950
|
+
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.manager.getFirstColumn());
|
|
938
951
|
}
|
|
939
952
|
else {
|
|
940
953
|
rowsSelected = rowsSelected.filter(rowSelected => !rangeRows.includes(rowSelected));
|
|
@@ -952,7 +965,7 @@ class ChGridManagerSelection {
|
|
|
952
965
|
rowsSelected = [...rowsSelected, row];
|
|
953
966
|
cellSelected =
|
|
954
967
|
cell ||
|
|
955
|
-
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.
|
|
968
|
+
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.manager.getFirstColumn());
|
|
956
969
|
}
|
|
957
970
|
}
|
|
958
971
|
else {
|
|
@@ -964,26 +977,26 @@ class ChGridManagerSelection {
|
|
|
964
977
|
: [row];
|
|
965
978
|
cellSelected =
|
|
966
979
|
cell ||
|
|
967
|
-
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.
|
|
980
|
+
row.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.manager.getFirstColumn());
|
|
968
981
|
}
|
|
969
982
|
return { rowFocused, rowsSelected, cellSelected };
|
|
970
983
|
}
|
|
971
984
|
selectAll(state, value = true) {
|
|
972
985
|
var _a;
|
|
973
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
986
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
974
987
|
return this.selectionStateNone;
|
|
975
988
|
}
|
|
976
|
-
const rows = this.
|
|
989
|
+
const rows = this.manager.getRows();
|
|
977
990
|
let rowFocused = state.rowFocused;
|
|
978
991
|
let rowsSelected = state.rowsSelected;
|
|
979
992
|
let cellSelected = state.cellSelected;
|
|
980
993
|
if (value) {
|
|
981
|
-
rowFocused = rowFocused !== null && rowFocused !== void 0 ? rowFocused : this.
|
|
994
|
+
rowFocused = rowFocused !== null && rowFocused !== void 0 ? rowFocused : this.manager.getFirstRow();
|
|
982
995
|
rowsSelected = rows;
|
|
983
|
-
cellSelected = rowFocused.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.
|
|
996
|
+
cellSelected = rowFocused.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.manager.getFirstColumn());
|
|
984
997
|
}
|
|
985
998
|
else {
|
|
986
|
-
rowFocused = rowFocused !== null && rowFocused !== void 0 ? rowFocused : this.
|
|
999
|
+
rowFocused = rowFocused !== null && rowFocused !== void 0 ? rowFocused : this.manager.getFirstRow();
|
|
987
1000
|
rowsSelected = [];
|
|
988
1001
|
cellSelected = null;
|
|
989
1002
|
}
|
|
@@ -1010,37 +1023,37 @@ class ChGridManagerSelection {
|
|
|
1010
1023
|
}
|
|
1011
1024
|
selectFirstRow(state, append) {
|
|
1012
1025
|
var _a;
|
|
1013
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1026
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1014
1027
|
return this.selectionStateNone;
|
|
1015
1028
|
}
|
|
1016
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1029
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1017
1030
|
append = false;
|
|
1018
1031
|
}
|
|
1019
|
-
const firstRow = this.
|
|
1032
|
+
const firstRow = this.manager.getFirstRow();
|
|
1020
1033
|
let rowFocused = state.rowFocused;
|
|
1021
1034
|
let rowsSelected = state.rowsSelected;
|
|
1022
1035
|
let cellSelected = state.cellSelected;
|
|
1023
1036
|
if (firstRow) {
|
|
1024
1037
|
if (append) {
|
|
1025
|
-
const rangeRows = this.
|
|
1038
|
+
const rangeRows = this.manager.getRowsRange(rowFocused !== null && rowFocused !== void 0 ? rowFocused : firstRow, firstRow);
|
|
1026
1039
|
rowsSelected = Array.from(new Set(rowsSelected.concat(rangeRows)));
|
|
1027
1040
|
}
|
|
1028
1041
|
else {
|
|
1029
1042
|
rowsSelected = [firstRow];
|
|
1030
1043
|
}
|
|
1031
1044
|
rowFocused = firstRow;
|
|
1032
|
-
cellSelected = firstRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.
|
|
1045
|
+
cellSelected = firstRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.manager.getFirstColumn());
|
|
1033
1046
|
}
|
|
1034
1047
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1035
1048
|
}
|
|
1036
1049
|
selectPreviousRow(state, append) {
|
|
1037
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1050
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1038
1051
|
return this.selectionStateNone;
|
|
1039
1052
|
}
|
|
1040
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1053
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1041
1054
|
append = false;
|
|
1042
1055
|
}
|
|
1043
|
-
const previousRow = this.
|
|
1056
|
+
const previousRow = this.manager.getPreviousRow(state.rowFocused);
|
|
1044
1057
|
let rowFocused = state.rowFocused;
|
|
1045
1058
|
let rowsSelected = state.rowsSelected;
|
|
1046
1059
|
let cellSelected = state.cellSelected;
|
|
@@ -1063,18 +1076,18 @@ class ChGridManagerSelection {
|
|
|
1063
1076
|
rowsSelected = [previousRow];
|
|
1064
1077
|
}
|
|
1065
1078
|
rowFocused = previousRow;
|
|
1066
|
-
cellSelected = previousRow.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.
|
|
1079
|
+
cellSelected = previousRow.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.manager.getFirstColumn());
|
|
1067
1080
|
}
|
|
1068
1081
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1069
1082
|
}
|
|
1070
1083
|
selectNextRow(state, append) {
|
|
1071
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1084
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1072
1085
|
return this.selectionStateNone;
|
|
1073
1086
|
}
|
|
1074
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1087
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1075
1088
|
append = false;
|
|
1076
1089
|
}
|
|
1077
|
-
const nextRow = this.
|
|
1090
|
+
const nextRow = this.manager.getNextRow(state.rowFocused);
|
|
1078
1091
|
let rowFocused = state.rowFocused;
|
|
1079
1092
|
let rowsSelected = state.rowsSelected;
|
|
1080
1093
|
let cellSelected = state.cellSelected;
|
|
@@ -1098,52 +1111,52 @@ class ChGridManagerSelection {
|
|
|
1098
1111
|
rowsSelected = [nextRow];
|
|
1099
1112
|
}
|
|
1100
1113
|
rowFocused = nextRow;
|
|
1101
|
-
cellSelected = nextRow.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.
|
|
1114
|
+
cellSelected = nextRow.getCell((cellSelected === null || cellSelected === void 0 ? void 0 : cellSelected.column) || this.manager.getFirstColumn());
|
|
1102
1115
|
}
|
|
1103
1116
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1104
1117
|
}
|
|
1105
1118
|
selectLastRow(state, append) {
|
|
1106
1119
|
var _a;
|
|
1107
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1120
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1108
1121
|
return this.selectionStateNone;
|
|
1109
1122
|
}
|
|
1110
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1123
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1111
1124
|
append = false;
|
|
1112
1125
|
}
|
|
1113
|
-
const firstRow = this.
|
|
1126
|
+
const firstRow = this.manager.getLastRow();
|
|
1114
1127
|
let rowFocused = state.rowFocused;
|
|
1115
1128
|
let rowsSelected = state.rowsSelected;
|
|
1116
1129
|
let cellSelected = state.cellSelected;
|
|
1117
1130
|
if (firstRow) {
|
|
1118
1131
|
if (append) {
|
|
1119
|
-
const rangeRows = this.
|
|
1132
|
+
const rangeRows = this.manager.getRowsRange(rowFocused !== null && rowFocused !== void 0 ? rowFocused : firstRow, firstRow);
|
|
1120
1133
|
rowsSelected = Array.from(new Set(rowsSelected.concat(rangeRows)));
|
|
1121
1134
|
}
|
|
1122
1135
|
else {
|
|
1123
1136
|
rowsSelected = [firstRow];
|
|
1124
1137
|
}
|
|
1125
1138
|
rowFocused = firstRow;
|
|
1126
|
-
cellSelected = firstRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.
|
|
1139
|
+
cellSelected = firstRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.manager.getFirstColumn());
|
|
1127
1140
|
}
|
|
1128
1141
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1129
1142
|
}
|
|
1130
1143
|
selectPreviousPageRow(state, append) {
|
|
1131
1144
|
var _a;
|
|
1132
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1145
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1133
1146
|
return this.selectionStateNone;
|
|
1134
1147
|
}
|
|
1135
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1148
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1136
1149
|
append = false;
|
|
1137
1150
|
}
|
|
1138
|
-
const rows = this.
|
|
1139
|
-
const rowsPerPage = this.
|
|
1151
|
+
const rows = this.manager.getRows();
|
|
1152
|
+
const rowsPerPage = this.manager.getRowsPerPage();
|
|
1140
1153
|
let rowFocused = state.rowFocused;
|
|
1141
1154
|
let rowsSelected = state.rowsSelected;
|
|
1142
1155
|
let cellSelected = state.cellSelected;
|
|
1143
1156
|
const previousPageRow = rows[Math.max(rows.indexOf(rowFocused) - rowsPerPage, 0)];
|
|
1144
1157
|
if (previousPageRow) {
|
|
1145
1158
|
if (append) {
|
|
1146
|
-
const rangeRows = this.
|
|
1159
|
+
const rangeRows = this.manager.getRowsRange(rowFocused !== null && rowFocused !== void 0 ? rowFocused : previousPageRow, previousPageRow);
|
|
1147
1160
|
rowsSelected = Array.from(new Set(rowsSelected.concat(rangeRows)));
|
|
1148
1161
|
}
|
|
1149
1162
|
else {
|
|
@@ -1153,27 +1166,27 @@ class ChGridManagerSelection {
|
|
|
1153
1166
|
: [previousPageRow];
|
|
1154
1167
|
}
|
|
1155
1168
|
rowFocused = previousPageRow;
|
|
1156
|
-
cellSelected = previousPageRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.
|
|
1169
|
+
cellSelected = previousPageRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.manager.getFirstColumn());
|
|
1157
1170
|
}
|
|
1158
1171
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1159
1172
|
}
|
|
1160
1173
|
selectNextPageRow(state, append) {
|
|
1161
1174
|
var _a;
|
|
1162
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1175
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1163
1176
|
return this.selectionStateNone;
|
|
1164
1177
|
}
|
|
1165
|
-
else if (this.grid.rowSelectionMode !== "multiple") {
|
|
1178
|
+
else if (this.manager.grid.rowSelectionMode !== "multiple") {
|
|
1166
1179
|
append = false;
|
|
1167
1180
|
}
|
|
1168
|
-
const rows = this.
|
|
1169
|
-
const rowsPerPage = this.
|
|
1181
|
+
const rows = this.manager.getRows();
|
|
1182
|
+
const rowsPerPage = this.manager.getRowsPerPage();
|
|
1170
1183
|
let rowFocused = state.rowFocused;
|
|
1171
1184
|
let rowsSelected = state.rowsSelected;
|
|
1172
1185
|
let cellSelected = state.cellSelected;
|
|
1173
1186
|
const nextPageRow = rows[Math.min(rows.indexOf(rowFocused) + rowsPerPage, rows.length - 1)];
|
|
1174
1187
|
if (nextPageRow) {
|
|
1175
1188
|
if (append) {
|
|
1176
|
-
const rangeRows = this.
|
|
1189
|
+
const rangeRows = this.manager.getRowsRange(rowFocused !== null && rowFocused !== void 0 ? rowFocused : nextPageRow, nextPageRow);
|
|
1177
1190
|
rowsSelected = Array.from(new Set(rowsSelected.concat(rangeRows)));
|
|
1178
1191
|
}
|
|
1179
1192
|
else {
|
|
@@ -1183,19 +1196,19 @@ class ChGridManagerSelection {
|
|
|
1183
1196
|
: [nextPageRow];
|
|
1184
1197
|
}
|
|
1185
1198
|
rowFocused = nextPageRow;
|
|
1186
|
-
cellSelected = nextPageRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.
|
|
1199
|
+
cellSelected = nextPageRow.getCell(((_a = state.cellSelected) === null || _a === void 0 ? void 0 : _a.column) || this.manager.getFirstColumn());
|
|
1187
1200
|
}
|
|
1188
1201
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1189
1202
|
}
|
|
1190
1203
|
selectPreviousCell(state) {
|
|
1191
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1204
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1192
1205
|
return this.selectionStateNone;
|
|
1193
1206
|
}
|
|
1194
1207
|
const rowFocused = state.rowFocused;
|
|
1195
1208
|
let rowsSelected = state.rowsSelected;
|
|
1196
1209
|
let cellSelected = state.cellSelected;
|
|
1197
1210
|
if (cellSelected) {
|
|
1198
|
-
const nextCell = this.
|
|
1211
|
+
const nextCell = this.manager.getPreviousCell(cellSelected);
|
|
1199
1212
|
if (nextCell) {
|
|
1200
1213
|
cellSelected = nextCell;
|
|
1201
1214
|
}
|
|
@@ -1205,20 +1218,20 @@ class ChGridManagerSelection {
|
|
|
1205
1218
|
rowsSelected = [...rowsSelected, rowFocused];
|
|
1206
1219
|
}
|
|
1207
1220
|
if (!cellSelected) {
|
|
1208
|
-
cellSelected = rowFocused.getCell(this.
|
|
1221
|
+
cellSelected = rowFocused.getCell(this.manager.getFirstColumn());
|
|
1209
1222
|
}
|
|
1210
1223
|
}
|
|
1211
1224
|
return { rowFocused, rowsSelected, cellSelected };
|
|
1212
1225
|
}
|
|
1213
1226
|
selectNextCell(state) {
|
|
1214
|
-
if (this.grid.rowSelectionMode === "none") {
|
|
1227
|
+
if (this.manager.grid.rowSelectionMode === "none") {
|
|
1215
1228
|
return this.selectionStateNone;
|
|
1216
1229
|
}
|
|
1217
1230
|
const rowFocused = state.rowFocused;
|
|
1218
1231
|
let rowsSelected = state.rowsSelected;
|
|
1219
1232
|
let cellSelected = state.cellSelected;
|
|
1220
1233
|
if (cellSelected) {
|
|
1221
|
-
const nextCell = this.
|
|
1234
|
+
const nextCell = this.manager.getNextCell(cellSelected);
|
|
1222
1235
|
if (nextCell) {
|
|
1223
1236
|
cellSelected = nextCell;
|
|
1224
1237
|
}
|
|
@@ -1228,7 +1241,7 @@ class ChGridManagerSelection {
|
|
|
1228
1241
|
rowsSelected = [...rowsSelected, rowFocused];
|
|
1229
1242
|
}
|
|
1230
1243
|
if (!cellSelected) {
|
|
1231
|
-
cellSelected = rowFocused.getCell(this.
|
|
1244
|
+
cellSelected = rowFocused.getCell(this.manager.getFirstColumn());
|
|
1232
1245
|
}
|
|
1233
1246
|
}
|
|
1234
1247
|
return { rowFocused, rowsSelected, cellSelected };
|
|
@@ -1238,7 +1251,7 @@ class ChGridManagerSelection {
|
|
|
1238
1251
|
if (row) {
|
|
1239
1252
|
if (range) {
|
|
1240
1253
|
const value = !row.marked;
|
|
1241
|
-
const rows = this.
|
|
1254
|
+
const rows = this.manager.getRowsRange((_a = this.lastRowMarked) !== null && _a !== void 0 ? _a : row, row);
|
|
1242
1255
|
this.lastRowMarked = row;
|
|
1243
1256
|
if (value) {
|
|
1244
1257
|
return currentRowsMarked.concat(rows.filter(row => !currentRowsMarked.includes(row)));
|
|
@@ -1261,14 +1274,14 @@ class ChGridManagerSelection {
|
|
|
1261
1274
|
}
|
|
1262
1275
|
markAllRows(value = true) {
|
|
1263
1276
|
if (value) {
|
|
1264
|
-
return this.
|
|
1277
|
+
return this.manager.getRows();
|
|
1265
1278
|
}
|
|
1266
1279
|
else {
|
|
1267
1280
|
return [];
|
|
1268
1281
|
}
|
|
1269
1282
|
}
|
|
1270
1283
|
syncRowSelector(rows, previous = [], selectorMode) {
|
|
1271
|
-
const columnSelector = this.
|
|
1284
|
+
const columnSelector = this.manager.columns.getColumnSelector();
|
|
1272
1285
|
if ((columnSelector === null || columnSelector === void 0 ? void 0 : columnSelector.richRowSelectorMode) === selectorMode) {
|
|
1273
1286
|
const indexColumnSelector = columnSelector.physicalOrder - 1;
|
|
1274
1287
|
previous === null || previous === void 0 ? void 0 : previous.filter(x => !rows.includes(x)).forEach(row => {
|
|
@@ -1284,7 +1297,7 @@ class ChGridManagerSelection {
|
|
|
1284
1297
|
if (rows.length === 0) {
|
|
1285
1298
|
columnSelector.richRowSelectorState = "";
|
|
1286
1299
|
}
|
|
1287
|
-
else if (rows.length === this.
|
|
1300
|
+
else if (rows.length === this.manager.getRows().length) {
|
|
1288
1301
|
columnSelector.richRowSelectorState = "checked";
|
|
1289
1302
|
}
|
|
1290
1303
|
else {
|
|
@@ -1293,7 +1306,7 @@ class ChGridManagerSelection {
|
|
|
1293
1306
|
}
|
|
1294
1307
|
}
|
|
1295
1308
|
sortRowsSelected(rowsSelected) {
|
|
1296
|
-
const rows = Array.from(this.grid.
|
|
1309
|
+
const rows = Array.from(this.manager.grid.querySelectorAll("ch-grid-row"));
|
|
1297
1310
|
return rowsSelected.sort((rowA, rowB) => {
|
|
1298
1311
|
const rowAIndex = rows.indexOf(rowA);
|
|
1299
1312
|
const rowBIndex = rows.indexOf(rowB);
|
|
@@ -1307,7 +1320,7 @@ class ChGridManagerSelection {
|
|
|
1307
1320
|
});
|
|
1308
1321
|
}
|
|
1309
1322
|
isContiguousSelection(sortedRowsSelected) {
|
|
1310
|
-
const rows = Array.from(this.grid.
|
|
1323
|
+
const rows = Array.from(this.manager.grid.querySelectorAll("ch-grid-row")).filter(row => row.isVisible());
|
|
1311
1324
|
if (sortedRowsSelected.length === 0) {
|
|
1312
1325
|
return false;
|
|
1313
1326
|
}
|
|
@@ -1323,13 +1336,13 @@ class ChGridManagerSelection {
|
|
|
1323
1336
|
}
|
|
1324
1337
|
|
|
1325
1338
|
class ChGridManagerRowDrag {
|
|
1326
|
-
constructor(
|
|
1339
|
+
constructor(manager) {
|
|
1327
1340
|
this.dragMouseMoveFn = this.dragMouseMoveHandler.bind(this);
|
|
1328
|
-
this.
|
|
1341
|
+
this.manager = manager;
|
|
1329
1342
|
}
|
|
1330
1343
|
dragStart(row) {
|
|
1331
1344
|
this.row = row;
|
|
1332
|
-
this.rowIndex = this.
|
|
1345
|
+
this.rowIndex = this.manager.getGridRowIndex(row);
|
|
1333
1346
|
this.defineListeners();
|
|
1334
1347
|
this.createRowShadow();
|
|
1335
1348
|
this.floatRow();
|
|
@@ -1337,11 +1350,11 @@ class ChGridManagerRowDrag {
|
|
|
1337
1350
|
}
|
|
1338
1351
|
dragMouseMoveHandler(eventInfo) {
|
|
1339
1352
|
const target = eventInfo.target;
|
|
1340
|
-
const rowHover = target.closest(
|
|
1353
|
+
const rowHover = target.closest("ch-grid-row");
|
|
1341
1354
|
if (rowHover &&
|
|
1342
1355
|
rowHover.parentElement === this.row.parentElement &&
|
|
1343
|
-
rowHover.grid === this.grid
|
|
1344
|
-
const rowHoverIndex = this.
|
|
1356
|
+
rowHover.grid === this.manager.grid) {
|
|
1357
|
+
const rowHoverIndex = this.manager.getGridRowIndex(rowHover);
|
|
1345
1358
|
const rowHoverGridPosition = rowHoverIndex + 2; // +1 RowHeaderColumn, +1 array start at 1
|
|
1346
1359
|
const offsetPosition = this.rowIndex < rowHoverIndex ? -1 : 1;
|
|
1347
1360
|
if (this.rowShadow.style.getPropertyValue("--row-shadow-row-start") !==
|
|
@@ -1357,7 +1370,7 @@ class ChGridManagerRowDrag {
|
|
|
1357
1370
|
dragMouseUpHandler() {
|
|
1358
1371
|
document.removeEventListener("mousemove", this.dragMouseMoveFn);
|
|
1359
1372
|
const dropPosition = parseInt(this.rowShadow.style.getPropertyValue("--row-shadow-row-start"));
|
|
1360
|
-
const rowDrop = this.grid
|
|
1373
|
+
const rowDrop = this.manager.grid
|
|
1361
1374
|
.querySelectorAll("ch-grid-row")
|
|
1362
1375
|
.item(dropPosition - 2);
|
|
1363
1376
|
if (dropPosition < this.rowIndex + 2) {
|
|
@@ -1380,10 +1393,10 @@ class ChGridManagerRowDrag {
|
|
|
1380
1393
|
});
|
|
1381
1394
|
}
|
|
1382
1395
|
createRowShadow() {
|
|
1383
|
-
const rowHeight = this.
|
|
1396
|
+
const rowHeight = this.manager.getRowHeight(this.row);
|
|
1384
1397
|
this.rowShadow = document.createElement("div");
|
|
1385
1398
|
this.rowShadow.style.display = "contents";
|
|
1386
|
-
this.
|
|
1399
|
+
this.manager.getColumnsWidth().forEach(width => {
|
|
1387
1400
|
const column = document.createElement("div");
|
|
1388
1401
|
column.style.opacity = "0";
|
|
1389
1402
|
column.style.minWidth = width;
|
|
@@ -1393,15 +1406,15 @@ class ChGridManagerRowDrag {
|
|
|
1393
1406
|
});
|
|
1394
1407
|
}
|
|
1395
1408
|
floatRow() {
|
|
1396
|
-
const columnsWidth = this.
|
|
1397
|
-
const rowWidth = this.
|
|
1409
|
+
const columnsWidth = this.manager.getColumnsWidth();
|
|
1410
|
+
const rowWidth = this.manager.gridLayout.clientWidth;
|
|
1398
1411
|
this.row.before(this.rowShadow);
|
|
1399
1412
|
this.row.setAttribute("dragging", "");
|
|
1400
1413
|
this.row.style.width = `${rowWidth}px`;
|
|
1401
1414
|
this.row
|
|
1402
1415
|
.querySelectorAll(":scope > ch-grid-cell")
|
|
1403
1416
|
.forEach((cell, i) => {
|
|
1404
|
-
const columnPosition = parseInt(this.
|
|
1417
|
+
const columnPosition = parseInt(this.manager.gridLayout.style.getPropertyValue(`--ch-grid-column-${i + 1}-position`));
|
|
1405
1418
|
if (!cell.hidden) {
|
|
1406
1419
|
cell.style.width = columnsWidth[columnPosition - 1];
|
|
1407
1420
|
cell.style.order = `${columnPosition}`;
|
|
@@ -1425,55 +1438,75 @@ class ChGridManagerRowDrag {
|
|
|
1425
1438
|
}
|
|
1426
1439
|
}
|
|
1427
1440
|
|
|
1441
|
+
class ChGridManagerRowActions {
|
|
1442
|
+
constructor(manager) {
|
|
1443
|
+
var _a;
|
|
1444
|
+
this.manager = manager;
|
|
1445
|
+
(_a = this.manager.grid
|
|
1446
|
+
.querySelectorAll("ch-grid-row-actions")) === null || _a === void 0 ? void 0 : _a.forEach(rowActions => {
|
|
1447
|
+
if (rowActions.showOnRowHover) {
|
|
1448
|
+
this.showOnRowHover = rowActions;
|
|
1449
|
+
}
|
|
1450
|
+
if (rowActions.showOnRowActions) {
|
|
1451
|
+
this.showOnRowActions = rowActions;
|
|
1452
|
+
}
|
|
1453
|
+
if (rowActions.showOnRowContext) {
|
|
1454
|
+
this.showOnRowContext = rowActions;
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
var StyleRule;
|
|
1461
|
+
(function (StyleRule) {
|
|
1462
|
+
StyleRule[StyleRule["BASE_LAYER"] = 0] = "BASE_LAYER";
|
|
1463
|
+
StyleRule[StyleRule["COLUMNS_WIDTH"] = 1] = "COLUMNS_WIDTH";
|
|
1464
|
+
})(StyleRule || (StyleRule = {}));
|
|
1428
1465
|
class ChGridManager {
|
|
1429
1466
|
constructor(grid) {
|
|
1467
|
+
this.styleSheet = new CSSStyleSheet();
|
|
1430
1468
|
this.grid = grid;
|
|
1431
|
-
this.
|
|
1432
|
-
this.
|
|
1469
|
+
this.styleSheet.insertRule(`:host {}`, StyleRule.BASE_LAYER);
|
|
1470
|
+
this.styleSheet.insertRule(".main {}", StyleRule.COLUMNS_WIDTH);
|
|
1471
|
+
this.grid.shadowRoot.adoptedStyleSheets.push(this.styleSheet);
|
|
1472
|
+
this.columns = new ChGridManagerColumns(this);
|
|
1473
|
+
this.selection = new ChGridManagerSelection(this);
|
|
1474
|
+
this.rowActions = new ChGridManagerRowActions(this);
|
|
1433
1475
|
}
|
|
1434
|
-
get
|
|
1435
|
-
return this.
|
|
1476
|
+
get gridLayout() {
|
|
1477
|
+
return this.gridLayoutElement;
|
|
1436
1478
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
gridDidLoad() {
|
|
1441
|
-
if (this.isRowActionsEnabled()) {
|
|
1442
|
-
this.observeMainScroll();
|
|
1443
|
-
}
|
|
1479
|
+
componentDidLoad(gridLayout) {
|
|
1480
|
+
this.gridLayoutElement = gridLayout;
|
|
1444
1481
|
}
|
|
1445
1482
|
getColumns() {
|
|
1446
|
-
return this.
|
|
1483
|
+
return this.columns.getColumns();
|
|
1447
1484
|
}
|
|
1448
1485
|
getColumnsWidth() {
|
|
1449
|
-
return getComputedStyle(this.
|
|
1486
|
+
return getComputedStyle(this.gridLayout).gridTemplateColumns.split(" ");
|
|
1450
1487
|
}
|
|
1451
1488
|
getColumnsetHeight() {
|
|
1452
|
-
const gridColumnsHeight = getComputedStyle(this.
|
|
1489
|
+
const gridColumnsHeight = getComputedStyle(this.gridLayout).gridTemplateRows.split(" ");
|
|
1453
1490
|
return parseInt(gridColumnsHeight[0]) || 0;
|
|
1454
1491
|
}
|
|
1455
1492
|
getFirstColumn() {
|
|
1456
|
-
return this.
|
|
1493
|
+
return this.columns.getColumnsFirstLast().columnFirst;
|
|
1457
1494
|
}
|
|
1458
1495
|
getFirstRow() {
|
|
1459
|
-
return this.grid.
|
|
1496
|
+
return this.grid.querySelector("ch-grid-row");
|
|
1460
1497
|
}
|
|
1461
1498
|
getScrollOffsetTop() {
|
|
1462
|
-
return this.
|
|
1499
|
+
return this.gridLayout.offsetTop + this.getColumnsetHeight();
|
|
1463
1500
|
}
|
|
1464
1501
|
getScrollOffsetLeft() {
|
|
1465
|
-
return this.
|
|
1466
|
-
.getColumns(true)
|
|
1467
|
-
.reduce((offsetRight, column) => {
|
|
1502
|
+
return this.columns.getColumns(true).reduce((offsetRight, column) => {
|
|
1468
1503
|
return column.freeze === "start" && !column.hidden
|
|
1469
1504
|
? offsetRight + column.offsetWidth
|
|
1470
1505
|
: offsetRight;
|
|
1471
1506
|
}, 0);
|
|
1472
1507
|
}
|
|
1473
1508
|
getScrollOffsetRight() {
|
|
1474
|
-
return this.
|
|
1475
|
-
.getColumns(true)
|
|
1476
|
-
.reduce((offsetRight, column) => {
|
|
1509
|
+
return this.columns.getColumns(true).reduce((offsetRight, column) => {
|
|
1477
1510
|
return column.freeze === "end" && !column.hidden
|
|
1478
1511
|
? offsetRight + column.offsetWidth
|
|
1479
1512
|
: offsetRight;
|
|
@@ -1498,7 +1531,7 @@ class ChGridManager {
|
|
|
1498
1531
|
}
|
|
1499
1532
|
getPreviousCell(current) {
|
|
1500
1533
|
const columnOrder = current.column.order;
|
|
1501
|
-
const previousColumn = this.
|
|
1534
|
+
const previousColumn = this.columns
|
|
1502
1535
|
.getColumns()
|
|
1503
1536
|
.reduce((previous, column) => {
|
|
1504
1537
|
return column.order < columnOrder &&
|
|
@@ -1513,9 +1546,7 @@ class ChGridManager {
|
|
|
1513
1546
|
}
|
|
1514
1547
|
getNextCell(current) {
|
|
1515
1548
|
const columnOrder = current.column.order;
|
|
1516
|
-
const nextColumn = this.
|
|
1517
|
-
.getColumns()
|
|
1518
|
-
.reduce((previous, column) => {
|
|
1549
|
+
const nextColumn = this.columns.getColumns().reduce((previous, column) => {
|
|
1519
1550
|
return column.order > columnOrder &&
|
|
1520
1551
|
!column.hidden &&
|
|
1521
1552
|
(!previous || column.order < previous.order)
|
|
@@ -1527,27 +1558,27 @@ class ChGridManager {
|
|
|
1527
1558
|
}
|
|
1528
1559
|
}
|
|
1529
1560
|
getGridRowIndex(row) {
|
|
1530
|
-
return Array.prototype.indexOf.call(this.grid.
|
|
1561
|
+
return Array.prototype.indexOf.call(this.grid.querySelectorAll("ch-grid-row, ch-grid-rowset-legend"), row);
|
|
1531
1562
|
}
|
|
1532
1563
|
getRowsetRowIndex(row) {
|
|
1533
1564
|
return Array.prototype.indexOf.call(row.parentElement.children, row);
|
|
1534
1565
|
}
|
|
1535
1566
|
getRowHeight(row) {
|
|
1536
|
-
const gridRowsHeight = getComputedStyle(this.
|
|
1567
|
+
const gridRowsHeight = getComputedStyle(this.gridLayout).gridTemplateRows.split(" ");
|
|
1537
1568
|
const rowIndex = this.getGridRowIndex(row) + 1;
|
|
1538
1569
|
return parseInt(gridRowsHeight[rowIndex]) || 0;
|
|
1539
1570
|
}
|
|
1540
1571
|
getRowsPerPage() {
|
|
1541
|
-
const gridHeight = this.
|
|
1572
|
+
const gridHeight = this.gridLayout.clientHeight;
|
|
1542
1573
|
const columnsHeight = this.getColumnsetHeight();
|
|
1543
1574
|
const rowHeight = this.getRowHeight(this.getFirstRow());
|
|
1544
1575
|
return Math.floor((gridHeight - columnsHeight) / rowHeight);
|
|
1545
1576
|
}
|
|
1546
1577
|
getRow(rowId) {
|
|
1547
|
-
return this.grid.
|
|
1578
|
+
return this.grid.querySelector(`ch-grid-row[rowid="${rowId}"]`);
|
|
1548
1579
|
}
|
|
1549
1580
|
getRows(state = "all") {
|
|
1550
|
-
const rows = Array.from(this.grid.
|
|
1581
|
+
const rows = Array.from(this.grid.querySelectorAll(`ch-grid-row`));
|
|
1551
1582
|
if (state === "visible") {
|
|
1552
1583
|
return rows.filter(row => row.isVisible());
|
|
1553
1584
|
}
|
|
@@ -1556,7 +1587,7 @@ class ChGridManager {
|
|
|
1556
1587
|
}
|
|
1557
1588
|
}
|
|
1558
1589
|
getRowsSelected() {
|
|
1559
|
-
return Array.from(this.grid.
|
|
1590
|
+
return Array.from(this.grid.querySelectorAll(`ch-grid-row[selected]`));
|
|
1560
1591
|
}
|
|
1561
1592
|
getRowsRange(start, end) {
|
|
1562
1593
|
const rows = this.getRows();
|
|
@@ -1574,11 +1605,11 @@ class ChGridManager {
|
|
|
1574
1605
|
isRowActionsEventTarget(eventInfo) {
|
|
1575
1606
|
return (eventInfo
|
|
1576
1607
|
.composedPath()
|
|
1577
|
-
.find((target) =>
|
|
1608
|
+
.find((target) => target.tagName === "CH-GRID-ROW-ACTIONS") != null);
|
|
1578
1609
|
}
|
|
1579
1610
|
getCell(cellId, rowId, columnId) {
|
|
1580
1611
|
if (cellId) {
|
|
1581
|
-
return this.grid.
|
|
1612
|
+
return this.grid.querySelector(`ch-grid-cell[cellid="${cellId}"]`);
|
|
1582
1613
|
}
|
|
1583
1614
|
else if (rowId && columnId) {
|
|
1584
1615
|
const row = this.getRow(rowId);
|
|
@@ -1594,7 +1625,7 @@ class ChGridManager {
|
|
|
1594
1625
|
.find((target) => target.tagName === "CH-GRID-CELL");
|
|
1595
1626
|
}
|
|
1596
1627
|
columnDragStart(columnId) {
|
|
1597
|
-
this.columnDragManager = new ChGridManagerColumnDrag(columnId, this.
|
|
1628
|
+
this.columnDragManager = new ChGridManagerColumnDrag(columnId, this.columns.getColumns(), this.isRTLDirection());
|
|
1598
1629
|
}
|
|
1599
1630
|
columnDragging(position) {
|
|
1600
1631
|
return this.columnDragManager.dragging(position);
|
|
@@ -1604,43 +1635,38 @@ class ChGridManager {
|
|
|
1604
1635
|
this.columnDragManager = null;
|
|
1605
1636
|
}
|
|
1606
1637
|
rowDragStart(row) {
|
|
1607
|
-
this.rowDragManager = new ChGridManagerRowDrag(this
|
|
1638
|
+
this.rowDragManager = new ChGridManagerRowDrag(this);
|
|
1608
1639
|
this.rowDragManager.dragStart(row);
|
|
1609
1640
|
}
|
|
1610
1641
|
getGridStyle() {
|
|
1611
1642
|
return Object.assign(Object.assign(Object.assign(Object.assign({ display: "grid" }, this.getGridTemplateColumns()), this.getRowBoxSimulationStyle()), this.getDragTransitionStyle()), this.getColumnsStyle());
|
|
1612
1643
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
return slot.assignedElements().length > 0;
|
|
1644
|
+
setBaseLayer(value) {
|
|
1645
|
+
this.styleSheet.deleteRule(StyleRule.BASE_LAYER);
|
|
1646
|
+
this.styleSheet.insertRule(`:host { --ch-grid-base-layer: ${value}; }`, StyleRule.BASE_LAYER);
|
|
1617
1647
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
else {
|
|
1624
|
-
this.grid.gridRowActionsEl.removeAttribute("show");
|
|
1625
|
-
this.grid.gridRowActionsEl.style.removeProperty("--ch-grid-row-highlighted-top");
|
|
1626
|
-
}
|
|
1648
|
+
setColumnWidthVariables(columnsWidth) {
|
|
1649
|
+
this.styleSheet.deleteRule(StyleRule.COLUMNS_WIDTH);
|
|
1650
|
+
this.styleSheet.insertRule(`.main { ${columnsWidth
|
|
1651
|
+
.map((columnWidth, columnIndex) => `--ch-grid-column-${columnIndex + 1}-width:${columnWidth}px;`)
|
|
1652
|
+
.join("\n")} }`, StyleRule.COLUMNS_WIDTH);
|
|
1627
1653
|
}
|
|
1628
1654
|
ensureRowVisible(row) {
|
|
1629
|
-
let node = row.parentElement.closest(
|
|
1630
|
-
const { columnFirst } = this.
|
|
1655
|
+
let node = row.parentElement.closest("ch-grid-row, ch-grid-rowset");
|
|
1656
|
+
const { columnFirst } = this.columns.getColumnsFirstLast();
|
|
1631
1657
|
while (node) {
|
|
1632
1658
|
node.collapsed = false;
|
|
1633
|
-
node = node.parentElement.closest(
|
|
1659
|
+
node = node.parentElement.closest("ch-grid-row, ch-grid-rowset");
|
|
1634
1660
|
}
|
|
1635
1661
|
if (row.children[columnFirst.physicalOrder]) {
|
|
1636
1662
|
this.ensureVisible(row.children[columnFirst.physicalOrder]);
|
|
1637
1663
|
}
|
|
1638
1664
|
}
|
|
1639
1665
|
ensureCellVisible(cell) {
|
|
1640
|
-
let node = cell.closest(
|
|
1666
|
+
let node = cell.closest("ch-grid-row, ch-grid-rowset");
|
|
1641
1667
|
while (!cell.isVisible() && node) {
|
|
1642
1668
|
node.collapsed = false;
|
|
1643
|
-
node = node.parentElement.closest(
|
|
1669
|
+
node = node.parentElement.closest("ch-grid-row, ch-grid-rowset");
|
|
1644
1670
|
}
|
|
1645
1671
|
if (!cell.isVisible()) {
|
|
1646
1672
|
cell.column.hidden = false;
|
|
@@ -1649,7 +1675,7 @@ class ChGridManager {
|
|
|
1649
1675
|
}
|
|
1650
1676
|
ensureVisible(cell) {
|
|
1651
1677
|
const isColumnFreeze = ["start", "end"].includes(cell.column.freeze);
|
|
1652
|
-
const scroll = this.
|
|
1678
|
+
const scroll = this.gridLayout;
|
|
1653
1679
|
const scrollOffsetTop = this.getScrollOffsetTop();
|
|
1654
1680
|
const scrollOffsetLeft = this.getScrollOffsetLeft();
|
|
1655
1681
|
const scrollOffsetRight = this.getScrollOffsetRight();
|
|
@@ -1684,7 +1710,7 @@ class ChGridManager {
|
|
|
1684
1710
|
}
|
|
1685
1711
|
getGridTemplateColumns() {
|
|
1686
1712
|
return {
|
|
1687
|
-
"grid-template-columns": this.
|
|
1713
|
+
"grid-template-columns": this.columns
|
|
1688
1714
|
.getColumns()
|
|
1689
1715
|
.map(column => `var(--ch-grid-column-${column.physicalOrder}-size)`)
|
|
1690
1716
|
.join(" ")
|
|
@@ -1693,7 +1719,7 @@ class ChGridManager {
|
|
|
1693
1719
|
getRowBoxSimulationStyle() {
|
|
1694
1720
|
const { columnFirst, columnLast } = this.columnDragManager
|
|
1695
1721
|
? this.columnDragManager.getColumnsFirstLast()
|
|
1696
|
-
: this.
|
|
1722
|
+
: this.columns.getColumnsFirstLast();
|
|
1697
1723
|
if (!columnFirst || !columnLast) {
|
|
1698
1724
|
return null;
|
|
1699
1725
|
}
|
|
@@ -1706,17 +1732,13 @@ class ChGridManager {
|
|
|
1706
1732
|
[`--ch-grid-column-${columnLast.physicalOrder}-padding-end`]: "var(--ch-grid-fallback, inherit)"
|
|
1707
1733
|
};
|
|
1708
1734
|
}
|
|
1709
|
-
getRowTop(row) {
|
|
1710
|
-
const cell = row.firstElementChild;
|
|
1711
|
-
return cell.offsetTop;
|
|
1712
|
-
}
|
|
1713
1735
|
getDragTransitionStyle() {
|
|
1714
1736
|
return {
|
|
1715
1737
|
"--column-drag-transition-duration": this.columnDragManager ? ".2s" : "0s"
|
|
1716
1738
|
};
|
|
1717
1739
|
}
|
|
1718
1740
|
getColumnsStyle() {
|
|
1719
|
-
return this.
|
|
1741
|
+
return this.columns.getColumns().reduce((style, column) => {
|
|
1720
1742
|
return Object.assign(Object.assign({}, style), this.getColumnStyle(column));
|
|
1721
1743
|
}, {});
|
|
1722
1744
|
}
|
|
@@ -1755,7 +1777,7 @@ class ChGridManager {
|
|
|
1755
1777
|
}
|
|
1756
1778
|
getColumnFreezeEndStyle(column) {
|
|
1757
1779
|
const calcItems = ["0px"];
|
|
1758
|
-
for (let i = this.
|
|
1780
|
+
for (let i = this.columns.getColumns().length; i > column.order; i--) {
|
|
1759
1781
|
calcItems.push(`var(--ch-grid-column-${i}-width)`);
|
|
1760
1782
|
}
|
|
1761
1783
|
return {
|
|
@@ -1780,12 +1802,12 @@ class ChGridManager {
|
|
|
1780
1802
|
[`--ch-grid-column-${column.physicalOrder}-content`]: column.order === 1 ? "''" : "none"
|
|
1781
1803
|
};
|
|
1782
1804
|
}
|
|
1783
|
-
|
|
1784
|
-
this.grid.
|
|
1805
|
+
isRTLDirection() {
|
|
1806
|
+
return getComputedStyle(this.grid).direction === "rtl";
|
|
1785
1807
|
}
|
|
1786
1808
|
}
|
|
1787
1809
|
|
|
1788
|
-
const chGridCss = ":host{display:flex;position:relative;flex-direction:column;--ch-grid-cell-active-layer:calc(var(--ch-grid-base-layer) * 1);--ch-grid-column-header-layer:calc(var(--ch-grid-base-layer) * 2);--ch-grid-column-freeze-layer:calc(var(--ch-grid-base-layer) * 4);--ch-grid-column-active-layer:calc(var(--ch-grid-base-layer) * 8);--ch-grid-settings-layer:calc(var(--ch-grid-base-layer) * 16)}.main{display:none;grid-auto-flow:dense;overflow-x:auto;user-select:none}
|
|
1810
|
+
const chGridCss = ":host{display:flex;position:relative;flex-direction:column;--ch-grid-cell-active-layer:calc(var(--ch-grid-base-layer) * 1);--ch-grid-column-header-layer:calc(var(--ch-grid-base-layer) * 2);--ch-grid-column-freeze-layer:calc(var(--ch-grid-base-layer) * 4);--ch-grid-column-active-layer:calc(var(--ch-grid-base-layer) * 8);--ch-grid-settings-layer:calc(var(--ch-grid-base-layer) * 16)}.main{display:none;grid-auto-flow:dense;overflow-x:auto;user-select:none}";
|
|
1789
1811
|
|
|
1790
1812
|
const ChGrid = class {
|
|
1791
1813
|
constructor(hostRef) {
|
|
@@ -1814,49 +1836,36 @@ const ChGrid = class {
|
|
|
1814
1836
|
* A boolean indicating whether the user can drag column headers to reorder columns.
|
|
1815
1837
|
*/
|
|
1816
1838
|
this.allowColumnReorder = true;
|
|
1817
|
-
this.styleSheet = new CSSStyleSheet();
|
|
1818
|
-
}
|
|
1819
|
-
baseLayerHandler(value) {
|
|
1820
|
-
this.styleSheet.replace(`:host { --ch-grid-base-layer: ${value} ;}`);
|
|
1821
|
-
}
|
|
1822
|
-
componentWillLoad() {
|
|
1823
|
-
this.manager = new ChGridManager(this);
|
|
1824
|
-
this.gridStyle = this.manager.getGridStyle();
|
|
1825
|
-
this.rowsSelected = this.manager.getRowsSelected();
|
|
1826
|
-
this.el.shadowRoot.adoptedStyleSheets.push(this.styleSheet);
|
|
1827
|
-
}
|
|
1828
|
-
componentDidLoad() {
|
|
1829
|
-
this.manager.gridDidLoad();
|
|
1830
|
-
this.gridRowActionsEnabled = this.manager.isRowActionsEnabled();
|
|
1831
1839
|
}
|
|
1832
|
-
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
return false;
|
|
1840
|
+
rowFocusedHandler(row, previous) {
|
|
1841
|
+
if (row) {
|
|
1842
|
+
row.focused = true;
|
|
1843
|
+
}
|
|
1844
|
+
if (previous) {
|
|
1845
|
+
previous.focused = false;
|
|
1839
1846
|
}
|
|
1840
1847
|
}
|
|
1841
1848
|
rowHighlightedHandler(row, previous) {
|
|
1849
|
+
var _a, _b;
|
|
1850
|
+
// highlight
|
|
1842
1851
|
if (row) {
|
|
1843
1852
|
row.highlighted = true;
|
|
1844
1853
|
}
|
|
1845
1854
|
if (previous) {
|
|
1846
1855
|
previous.highlighted = false;
|
|
1847
1856
|
}
|
|
1848
|
-
|
|
1849
|
-
this.manager.setRowActionsPosition(row);
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
rowFocusedHandler(row, previous) {
|
|
1857
|
+
// actions
|
|
1853
1858
|
if (row) {
|
|
1854
|
-
|
|
1859
|
+
(_a = this.manager.rowActions.showOnRowHover) === null || _a === void 0 ? void 0 : _a.openRowHover(row);
|
|
1855
1860
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1861
|
+
else {
|
|
1862
|
+
(_b = this.manager.rowActions.showOnRowHover) === null || _b === void 0 ? void 0 : _b.close();
|
|
1858
1863
|
}
|
|
1859
1864
|
}
|
|
1865
|
+
rowsMarkedHandler(rows, previous) {
|
|
1866
|
+
this.manager.selection.syncRowSelector(rows, previous, "mark");
|
|
1867
|
+
this.rowMarkingChanged.emit({ rowsId: rows.map(row => row.rowId) });
|
|
1868
|
+
}
|
|
1860
1869
|
rowsSelectedHandler(rows, previous) {
|
|
1861
1870
|
if (previous) {
|
|
1862
1871
|
previous
|
|
@@ -1869,10 +1878,6 @@ const ChGrid = class {
|
|
|
1869
1878
|
this.manager.selection.syncRowSelector(rows, previous, "select");
|
|
1870
1879
|
this.selectionChanged.emit({ rowsId: rows.map(row => row.rowId) });
|
|
1871
1880
|
}
|
|
1872
|
-
rowsMarkedHandler(rows, previous) {
|
|
1873
|
-
this.manager.selection.syncRowSelector(rows, previous, "mark");
|
|
1874
|
-
this.rowMarkingChanged.emit({ rowsId: rows.map(row => row.rowId) });
|
|
1875
|
-
}
|
|
1876
1881
|
cellSelectedHandler(cell, previous) {
|
|
1877
1882
|
if (cell) {
|
|
1878
1883
|
cell.selected = true;
|
|
@@ -1886,6 +1891,23 @@ const ChGrid = class {
|
|
|
1886
1891
|
columnId: this.cellSelected ? this.cellSelected.column.columnId : null
|
|
1887
1892
|
});
|
|
1888
1893
|
}
|
|
1894
|
+
componentWillLoad() {
|
|
1895
|
+
this.manager = new ChGridManager(this.el);
|
|
1896
|
+
this.gridStyle = this.manager.getGridStyle();
|
|
1897
|
+
this.rowsSelected = this.manager.getRowsSelected();
|
|
1898
|
+
}
|
|
1899
|
+
componentDidLoad() {
|
|
1900
|
+
this.manager.componentDidLoad(this.gridLayoutElement);
|
|
1901
|
+
}
|
|
1902
|
+
componentShouldUpdate(_newValue, _oldValue, name) {
|
|
1903
|
+
if (name === "rowFocused" ||
|
|
1904
|
+
name === "rowHighlighted" ||
|
|
1905
|
+
name === "rowSelected" ||
|
|
1906
|
+
name === "rowsMarked" ||
|
|
1907
|
+
name === "cellSelected") {
|
|
1908
|
+
return false;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1889
1911
|
focusHandler() {
|
|
1890
1912
|
if (this.rowSelectionMode !== "none") {
|
|
1891
1913
|
this.rowFocused = this.rowsSelected[0] || this.manager.getFirstRow();
|
|
@@ -2028,6 +2050,11 @@ const ChGrid = class {
|
|
|
2028
2050
|
this.rowsMarked = this.manager.selection.markRow(this.manager.getRowEventTarget(eventInfo), eventInfo.detail.checked, eventInfo.detail.range, this.rowsMarked);
|
|
2029
2051
|
}
|
|
2030
2052
|
}
|
|
2053
|
+
cellRowActionClickedHandler(eventInfo) {
|
|
2054
|
+
var _a;
|
|
2055
|
+
const cell = eventInfo.target;
|
|
2056
|
+
(_a = this.manager.rowActions.showOnRowActions) === null || _a === void 0 ? void 0 : _a.openRowActions(cell);
|
|
2057
|
+
}
|
|
2031
2058
|
columnStyleChangedHandler() {
|
|
2032
2059
|
if (this.manager) {
|
|
2033
2060
|
this.gridStyle = this.manager.getGridStyle();
|
|
@@ -2058,10 +2085,10 @@ const ChGrid = class {
|
|
|
2058
2085
|
this.manager.ensureCellVisible(eventInfo.target);
|
|
2059
2086
|
}
|
|
2060
2087
|
settingsShowClickedHandler() {
|
|
2061
|
-
this.
|
|
2088
|
+
this.settingsUI.show = true;
|
|
2062
2089
|
}
|
|
2063
2090
|
settingsCloseClickedHandler() {
|
|
2064
|
-
this.
|
|
2091
|
+
this.settingsUI.show = false;
|
|
2065
2092
|
}
|
|
2066
2093
|
/**
|
|
2067
2094
|
* Retrieves the rowId of the currently focused row.
|
|
@@ -2148,6 +2175,28 @@ const ChGrid = class {
|
|
|
2148
2175
|
rowFocused === null || rowFocused === void 0 ? void 0 : rowFocused.ensureVisible();
|
|
2149
2176
|
}
|
|
2150
2177
|
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Mark or unmark a row.
|
|
2180
|
+
* @param rowId - The rowId of the row to select or deselect.
|
|
2181
|
+
* @param marked - A boolean indicating whether to mark or unmark the row.
|
|
2182
|
+
*/
|
|
2183
|
+
async markRow(rowId, marked = true) {
|
|
2184
|
+
const columnSelector = this.manager.columns.getColumnSelector();
|
|
2185
|
+
const row = this.manager.getRow(rowId);
|
|
2186
|
+
if (row && (columnSelector === null || columnSelector === void 0 ? void 0 : columnSelector.richRowSelectorMode) === "mark") {
|
|
2187
|
+
this.rowsMarked = this.manager.selection.markRow(row, marked, false, this.rowsMarked);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Mark or unmark all rows.
|
|
2192
|
+
* @param marked - A boolean indicating whether to mark or unmark all rows.
|
|
2193
|
+
*/
|
|
2194
|
+
async markAllRows(marked = true) {
|
|
2195
|
+
const columnSelector = this.manager.columns.getColumnSelector();
|
|
2196
|
+
if ((columnSelector === null || columnSelector === void 0 ? void 0 : columnSelector.richRowSelectorMode) === "mark") {
|
|
2197
|
+
this.rowsMarked = this.manager.selection.markAllRows(marked);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2151
2200
|
/**
|
|
2152
2201
|
* Expands a row, showing its children.
|
|
2153
2202
|
* @param rowId - The rowId of the row to expand.
|
|
@@ -2305,22 +2354,18 @@ const ChGrid = class {
|
|
|
2305
2354
|
row.collapsed = false;
|
|
2306
2355
|
}
|
|
2307
2356
|
}
|
|
2308
|
-
render() {
|
|
2309
|
-
return (index.h(index.Host, { tabindex: this.rowSelectionMode !== "none" ? "0" : false }, index.h("header", { part: "header" }, index.h("slot", { name: "header" })), index.h("section", { class: "main", style: this.gridStyle, part: "main", ref: el => (this.gridMainEl = el) }, index.h("slot", null)), index.h("aside", null, this.renderSettings(), index.h("slot", { name: "column-display" }), this.renderRowActions()), index.h("footer", { part: "footer" }, index.h("slot", { name: "footer" }))));
|
|
2310
|
-
}
|
|
2311
2357
|
renderSettings() {
|
|
2312
|
-
return (index.h("ch-grid-settings", { grid: this.el, ref: el => (this.
|
|
2358
|
+
return (index.h("ch-grid-settings", { grid: this.el, ref: el => (this.settingsUI = el), exportparts: "\n mask:settings-mask,\n window:settings-window,\n header:settings-header,\n caption:settings-caption,\n close:settings-close,\n main:settings-main,\n footer:settings-footer\n " }, index.h("slot", { name: "settings" }, index.h("ch-grid-settings-columns", { part: "settings-columns", columns: [...this.manager.getColumns()], exportparts: "\n column:settings-columns-item,\n column-label:settings-columns-label,\n column-visible:settings-columns-visible,\n column-visible-checked:settings-columns-visible-checked\n " }))));
|
|
2313
2359
|
}
|
|
2314
|
-
|
|
2315
|
-
return (index.h("section", { class: "
|
|
2360
|
+
render() {
|
|
2361
|
+
return (index.h(index.Host, { tabindex: this.rowSelectionMode !== "none" ? "0" : false }, index.h("header", { part: "header" }, index.h("slot", { name: "header" })), index.h("section", { class: "main", style: this.gridStyle, part: "main", ref: el => (this.gridLayoutElement = el) }, index.h("slot", null)), index.h("aside", null, this.renderSettings(), index.h("slot", { name: "column-display" }), index.h("slot", { name: "row-actions" })), index.h("footer", { part: "footer" }, index.h("slot", { name: "footer" }))));
|
|
2316
2362
|
}
|
|
2317
2363
|
get el() { return index.getElement(this); }
|
|
2318
2364
|
static get watchers() { return {
|
|
2319
|
-
"baseLayer": ["baseLayerHandler"],
|
|
2320
|
-
"rowHighlighted": ["rowHighlightedHandler"],
|
|
2321
2365
|
"rowFocused": ["rowFocusedHandler"],
|
|
2322
|
-
"
|
|
2366
|
+
"rowHighlighted": ["rowHighlightedHandler"],
|
|
2323
2367
|
"rowsMarked": ["rowsMarkedHandler"],
|
|
2368
|
+
"rowsSelected": ["rowsSelectedHandler"],
|
|
2324
2369
|
"cellSelected": ["cellSelectedHandler"]
|
|
2325
2370
|
}; }
|
|
2326
2371
|
};
|