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