@genexus/genexus-ide-ui 0.0.57 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ch-checkbox_4.cjs.entry.js → ch-checkbox_3.cjs.entry.js} +54 -43
- package/dist/cjs/ch-suggest_4.cjs.entry.js +2 -2
- package/dist/cjs/ch-test-suggest.cjs.entry.js +84 -0
- package/dist/cjs/ch-test-tree-x.cjs.entry.js +31 -16
- package/dist/cjs/ch-tooltip.cjs.entry.js +85 -0
- package/dist/cjs/genexus-ide-ui.cjs.js +1 -1
- package/dist/cjs/gx-ide-references.cjs.entry.js +76 -116
- package/dist/cjs/gx-ide-test.cjs.entry.js +51 -5
- package/dist/cjs/gxg-label_2.cjs.entry.js +15 -2
- package/dist/cjs/gxg-tree-view.cjs.entry.js +36 -14
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/common/helpers.js +3 -0
- package/dist/collection/components/references/helpers.js +16 -19
- package/dist/collection/components/references/references.css +8 -0
- package/dist/collection/components/references/references.js +60 -98
- package/dist/components/ch-suggest2.js +2 -2
- package/dist/components/ch-test-suggest.js +119 -0
- package/dist/components/ch-test-tree-x.js +38 -28
- package/dist/components/ch-tooltip.js +115 -0
- package/dist/components/gx-ide-references.js +122 -150
- package/dist/components/gx-ide-test.js +48 -2
- package/dist/components/gxg-tree-view.js +1 -434
- package/dist/components/index.js +2 -1
- package/dist/components/tooltip.js +17 -3
- package/dist/components/tree-view.js +453 -0
- package/dist/components/tree-x-list-item.js +35 -23
- package/dist/components/tree-x.js +21 -7
- package/dist/esm/{ch-checkbox_4.entry.js → ch-checkbox_3.entry.js} +55 -43
- package/dist/esm/ch-suggest_4.entry.js +2 -2
- package/dist/esm/ch-test-suggest.entry.js +80 -0
- package/dist/esm/ch-test-tree-x.entry.js +32 -17
- package/dist/esm/ch-tooltip.entry.js +81 -0
- package/dist/esm/genexus-ide-ui.js +1 -1
- package/dist/esm/gx-ide-references.entry.js +76 -116
- package/dist/esm/gx-ide-test.entry.js +48 -2
- package/dist/esm/gxg-label_2.entry.js +15 -2
- package/dist/esm/gxg-tree-view.entry.js +37 -15
- package/dist/esm/loader.js +1 -1
- package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
- package/dist/genexus-ide-ui/p-109209dc.entry.js +1 -0
- package/dist/genexus-ide-ui/p-123b8351.entry.js +1 -0
- package/dist/genexus-ide-ui/p-71c6da54.entry.js +1 -0
- package/dist/genexus-ide-ui/p-86b98a99.entry.js +1 -0
- package/dist/genexus-ide-ui/p-cd00ba19.entry.js +1 -0
- package/dist/genexus-ide-ui/p-ce9fef1a.entry.js +1 -0
- package/dist/genexus-ide-ui/p-d47ed4e3.entry.js +1 -0
- package/dist/genexus-ide-ui/p-d7b452ef.entry.js +1 -0
- package/dist/genexus-ide-ui/p-f62d9b6d.entry.js +1 -0
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/test/test-suggest/test-suggest.css +114 -0
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/tooltip/tooltip.css +120 -0
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/{tree-x → tree-view/tree-x}/tree-x.css +2 -3
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/{tree-x-list-item → tree-view/tree-x-list-item}/tree-x-list-item.css +3 -6
- package/dist/node_modules/@genexus/gemini/dist/collection/components/tooltip/tooltip.css +11 -0
- package/dist/node_modules/@genexus/gemini/dist/collection/components/tree-view/tree-view.css +58 -12
- package/dist/types/common/helpers.d.ts +1 -0
- package/dist/types/components/references/helpers.d.ts +3 -3
- package/dist/types/components/references/references.d.ts +7 -19
- package/package.json +3 -3
- package/dist/cjs/update-tree-model-8b154db1.js +0 -53
- package/dist/components/ch-tree-x-list.js +0 -6
- package/dist/components/tree-x-list.js +0 -31
- package/dist/components/update-tree-model.js +0 -50
- package/dist/esm/update-tree-model-6c612f05.js +0 -50
- package/dist/genexus-ide-ui/p-1f3a81e3.entry.js +0 -1
- package/dist/genexus-ide-ui/p-46d393f5.entry.js +0 -1
- package/dist/genexus-ide-ui/p-5669baf5.entry.js +0 -1
- package/dist/genexus-ide-ui/p-60b2bd2f.entry.js +0 -1
- package/dist/genexus-ide-ui/p-71ecc7fd.js +0 -1
- package/dist/genexus-ide-ui/p-c7425416.entry.js +0 -1
- package/dist/genexus-ide-ui/p-dd2e0590.entry.js +0 -1
- package/dist/genexus-ide-ui/p-ed5cf480.entry.js +0 -1
- package/dist/node_modules/@genexus/chameleon-controls-library/dist/collection/components/tree-x-list/tree-x-list.css +0 -6
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, forceUpdate } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$3 } from './checkbox.js';
|
|
3
|
+
import { d as defineCustomElement$2 } from './tree-x.js';
|
|
4
|
+
import { d as defineCustomElement$1 } from './tree-x-list-item.js';
|
|
5
|
+
|
|
6
|
+
const resolveImgPath = (img) => `/build/icon-assets/${img}.svg`;
|
|
7
|
+
|
|
8
|
+
const treeViewCss = ":root{--ui-animaton-speed:0.2s}.gxg-title-01{font-family:var(--font-family-primary);font-weight:var(--font-weight-bold);font-size:var(--font-size-md);letter-spacing:var(--letter-spacing-md);color:var(--color-on-background);text-align:start;line-height:1.455em}.gxg-title-01--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-bold);font-size:var(--font-size-md);letter-spacing:var(--letter-spacing-md);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-on-primary)}.gxg-title-02{font-family:var(--font-family-primary);font-weight:var(--font-weight-bold);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;text-transform:uppercase;line-height:1.556em}.gxg-title-02--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-bold);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;text-transform:uppercase;line-height:1.556em;color:var(--color-on-primary)}.gxg-title-03{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-xs);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;text-transform:uppercase;line-height:1.556em}.gxg-title-03--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-xs);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;text-transform:uppercase;line-height:1.556em;color:var(--color-on-primary)}.gxg-title-04{font-family:var(--font-family-primary);font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);letter-spacing:var(--letter-spacing-md);color:var(--color-on-background);text-align:start;line-height:1.455em}.gxg-title-04--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);letter-spacing:var(--letter-spacing-md);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-on-primary)}.gxg-title-05{font-family:var(--font-family-primary);font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;line-height:1.556em}.gxg-title-05--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-sm);color:var(--color-on-background);text-align:start;line-height:1.556em;color:var(--color-on-primary)}.gxg-text{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em}.gxg-text--negative{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-on-primary)}.gxg-text--gray{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--gray-05)}.gxg-quote{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;font-style:italic}.gxg-quote--negative{color:var(--color-on-primary)}.gxg-link{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-primary);text-decoration:underline;cursor:pointer;display:inline-block}.gxg-link:hover{color:var(--color-primary-hover)}.gxg-link:active{color:var(--color-primary-active)}.gxg-link-gray{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-primary);text-decoration:underline;cursor:pointer;display:inline-block;color:var(--gray-04)}.gxg-link-gray:hover{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-primary);text-decoration:underline;cursor:pointer;display:inline-block;color:var(--gray-04);color:var(--gray-06)}.gxg-alert-error{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-error-dark);display:inline-block}.gxg-alert-warning{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-warning-dark);display:inline-block}.gxg-alert-success{font-family:var(--font-family-primary);font-weight:var(--font-weight-regular);font-size:var(--font-size-sm);letter-spacing:var(--letter-spacing-xs);color:var(--color-on-background);text-align:start;line-height:1.455em;color:var(--color-success-dark);display:inline-block}.gxg-tab--disabled{color:var(--color-primary-disabled);pointer-events:none}.gxg-tab--disabled[disabled]{color:var(--color-primary-disabled);pointer-events:none}.gxg-label{font-family:var(--font-family-primary) !important;font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm) !important;letter-spacing:var(--letter-spacing-xs);color:var(--color-primary-enabled);text-align:center;line-height:1.455em}.gxg-label:hover{color:var(--color-primary-hover)}.gxg-label:focus{color:var(--color-primary-active)}.gxg-label:active{color:var(--color-primary-active)}.gxg-label[disabled]{color:var(--color-primary-disabled)}.gxg-label--negative{color:var(--color-on-primary)}.gxg-label--negative[disabled]{color:var(--color-on-disabled)}.gxg-button-styles{font-family:var(--font-family-primary) !important;font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm) !important;letter-spacing:var(--letter-spacing-xs);color:var(--color-primary-enabled);text-align:center;line-height:1.455em}.gxg-scrollbar{}.gxg-scrollbar::-webkit-scrollbar{width:6px;height:6px}.gxg-scrollbar::-webkit-scrollbar-track{background-color:var(--gray-02);border-radius:10px}.gxg-scrollbar::-webkit-scrollbar-thumb{background:var(--gray-05);border-radius:10px}.gxg-scrollbar::-webkit-scrollbar-thumb:hover{background:var(--gray-04);cursor:pointer}gxg-tree-view{font-family:var(--font-family-primary);font-size:var(--font-size-lg);font-weight:var(--font-weight-regular);color:var(--color-on-background);display:contents}ch-tree-x{}ch-tree-x::-webkit-scrollbar{width:6px;height:6px}ch-tree-x::-webkit-scrollbar-track{background-color:var(--gray-02);border-radius:10px}ch-tree-x::-webkit-scrollbar-thumb{background:var(--gray-05);border-radius:10px}ch-tree-x::-webkit-scrollbar-thumb:hover{background:var(--gray-04);cursor:pointer}ch-tree-x>div.ch-tree-x-container{position:relative;width:100%}ch-tree-x-list-item{--expandable-button-width:var(--spacing-comp-04)}ch-tree-x-list-item.tree-view-item--folder::part(action)::before,ch-tree-x-list-item.tree-view-item--module::part(action)::before{grid-area:left-img;content:\"\";width:14px;height:14px;margin-inline-end:4px;background-repeat:no-repeat}ch-tree-x-list-item.tree-view-item--folder::part(action)::before{background-image:url(\"/build/icon-assets/objects/folder.svg\")}ch-tree-x-list-item.tree-view-item--folder::part(action expanded)::before{background-image:url(\"/build/icon-assets/objects/folder-open.svg\")}ch-tree-x-list-item.tree-view-item--module::part(action)::before{background-image:url(\"/build/icon-assets/objects/module.svg\")}ch-tree-x-list-item.tree-view-item--module::part(action expanded)::before{background-image:url(\"/build/icon-assets/objects/module-open.svg\")}ch-tree-x-list-item .tree-view-item--pending-commit::part(action)::before{content:\"\";position:relative;z-index:1;grid-area:left-img;width:5px;height:5px;align-self:end;margin-block-end:3px;margin-inline-start:1px;background-color:#2c3b92;border-radius:50%}ch-tree-x-list-item::part(header){padding-inline-end:calc(var(--spacing-comp-02) * 0.65);border:1px solid transparent;height:var(--spacing-comp-05)}ch-tree-x-list-item::part(header):focus{outline-style:solid;outline-color:var(--gxg-border-color--focused);outline-width:var(--border-width-md);outline-offset:-2px}ch-tree-x-list-item[selected]::part(header){background-color:var(--gxg-background-color--selected)}ch-tree-x-list-item[selected]::part(header):hover{background-color:var(--gxg-background-color--selected-hover)}ch-tree-x-list-item::part(expandable-button){background-color:var(--color-hover);margin-inline-start:var(--spacing-comp-01)}ch-tree-x-list-item::part(expandable-button)::before{background-color:var(--gray-04);-webkit-mask-position:center;-webkit-mask-repeat:no-repeat}ch-tree-x-list-item::part(expandable-button):hover{background-color:var(--color-background)}ch-tree-x-list-item::part(expandable-button):focus{outline-style:solid;outline-color:var(--gxg-border-color--focused);outline-width:var(--border-width-md);outline-offset:0}ch-tree-x-list-item::part(action){text-transform:capitalize}ch-tree-x-list-item::part(left-img){width:var(--spacing-comp-04);height:var(--spacing-comp-04)}ch-tree-x-list-item::part(downloading){width:var(--spacing-comp-03);height:var(--spacing-comp-03);border:var(--border-width-md) solid var(--color-primary-enabled);border-inline-start-color:transparent}.ch-tree-x-drag-info{padding-inline:6px;padding-block:2px;background-color:#cfdee6;border:1px solid #0266a0;border-radius:10px;font-size:8px}";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DRAG_DISABLED_VALUE = false;
|
|
11
|
+
const DEFAULT_DROP_DISABLED_VALUE = false;
|
|
12
|
+
const DEFAULT_CLASS_VALUE = "tree-view-item";
|
|
13
|
+
const DEFAULT_EDITABLE_ITEMS_VALUE = true;
|
|
14
|
+
const DEFAULT_EXPANDED_VALUE = false;
|
|
15
|
+
const DEFAULT_INDETERMINATE_VALUE = false;
|
|
16
|
+
const DEFAULT_LAZY_VALUE = false;
|
|
17
|
+
const DEFAULT_ORDER_VALUE = 0;
|
|
18
|
+
const DEFAULT_SELECTED_VALUE = false;
|
|
19
|
+
const GxgTreeView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this.__registerHost();
|
|
23
|
+
this.itemContextmenu = createEvent(this, "itemContextmenu", 7);
|
|
24
|
+
this.itemOpenReference = createEvent(this, "itemOpenReference", 7);
|
|
25
|
+
this.selectedItemsChange = createEvent(this, "selectedItemsChange", 7);
|
|
26
|
+
// UI Models
|
|
27
|
+
this.flattenedTreeModel = new Map();
|
|
28
|
+
this.selectedItems = new Set();
|
|
29
|
+
/**
|
|
30
|
+
* This property lets you specify if the tree is waiting to process the drop
|
|
31
|
+
* of items.
|
|
32
|
+
*/
|
|
33
|
+
this.waitDropProcessing = false;
|
|
34
|
+
/**
|
|
35
|
+
* This attribute lets you specify if the drag operation is disabled in all
|
|
36
|
+
* items by default. If `true`, the items can't be dragged.
|
|
37
|
+
*/
|
|
38
|
+
this.dragDisabled = DEFAULT_DRAG_DISABLED_VALUE;
|
|
39
|
+
/**
|
|
40
|
+
* This attribute lets you specify if the drop operation is disabled in all
|
|
41
|
+
* items by default. If `true`, the items won't accept any drops.
|
|
42
|
+
*/
|
|
43
|
+
this.dropDisabled = DEFAULT_DROP_DISABLED_VALUE;
|
|
44
|
+
/**
|
|
45
|
+
* This property lets you define the model of the ch-tree-x control.
|
|
46
|
+
*/
|
|
47
|
+
this.treeModel = [];
|
|
48
|
+
/**
|
|
49
|
+
* Set this attribute if you want to allow multi selection of the items.
|
|
50
|
+
*/
|
|
51
|
+
this.multiSelection = false;
|
|
52
|
+
/**
|
|
53
|
+
* This attribute lets you specify if the edit operation is enabled in all
|
|
54
|
+
* items by default. If `true`, the items can edit its caption in place.
|
|
55
|
+
*/
|
|
56
|
+
this.editableItems = DEFAULT_EDITABLE_ITEMS_VALUE;
|
|
57
|
+
/**
|
|
58
|
+
* `true` to display the relation between tree items and tree lists using
|
|
59
|
+
* lines.
|
|
60
|
+
*/
|
|
61
|
+
this.showLines = "all";
|
|
62
|
+
this.handleDroppableZoneEnter = (event) => {
|
|
63
|
+
if (!this.checkDroppableZoneCallback) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
// Suppose the request is made immediately by executing the callback
|
|
68
|
+
const requestTimestamp = new Date().getTime();
|
|
69
|
+
const dropInformation = event.detail;
|
|
70
|
+
const promise = this.checkDroppableZoneCallback(dropInformation);
|
|
71
|
+
promise.then((validDrop) => {
|
|
72
|
+
this.updateValidDropZone(requestTimestamp, dropInformation.newContainer.id, dropInformation.draggedItems, validDrop);
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
this.handleSelectedItemsChange = (event) => {
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
const itemsToProcess = new Map(event.detail);
|
|
78
|
+
// Remove no longer selected items
|
|
79
|
+
this.selectedItems.forEach((selectedItemId) => {
|
|
80
|
+
const itemUIModel = this.flattenedTreeModel.get(selectedItemId).item;
|
|
81
|
+
const itemIsStillSelected = itemsToProcess.get(selectedItemId);
|
|
82
|
+
// The item does not need to be added. Remove it from the processed list
|
|
83
|
+
if (itemIsStillSelected) {
|
|
84
|
+
itemUIModel.expanded = itemIsStillSelected.expanded; // Update expanded state
|
|
85
|
+
itemsToProcess.delete(selectedItemId);
|
|
86
|
+
}
|
|
87
|
+
// The item must be un-selected in the UI Model
|
|
88
|
+
else {
|
|
89
|
+
itemUIModel.selected = false;
|
|
90
|
+
this.selectedItems.delete(selectedItemId);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// Add new selected items
|
|
94
|
+
itemsToProcess.forEach((newSelectedItemInfo, itemId) => {
|
|
95
|
+
const newSelectedItem = this.flattenedTreeModel.get(itemId).item;
|
|
96
|
+
newSelectedItem.selected = true;
|
|
97
|
+
newSelectedItem.expanded = newSelectedItemInfo.expanded;
|
|
98
|
+
this.selectedItems.add(itemId);
|
|
99
|
+
});
|
|
100
|
+
this.selectedItemsChange.emit(event.detail);
|
|
101
|
+
};
|
|
102
|
+
this.handleExpandedItemChange = (event) => {
|
|
103
|
+
const detail = event.detail;
|
|
104
|
+
const itemInfo = this.flattenedTreeModel.get(detail.id).item;
|
|
105
|
+
itemInfo.expanded = detail.expanded;
|
|
106
|
+
};
|
|
107
|
+
this.handleItemContextmenu = (event) => {
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
this.itemContextmenu.emit(event.detail);
|
|
110
|
+
};
|
|
111
|
+
this.handleItemsDropped = (event) => {
|
|
112
|
+
if (!this.dropItemsCallback) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
const dataTransferInfo = event.detail;
|
|
117
|
+
const newContainer = dataTransferInfo.newContainer;
|
|
118
|
+
const newParentId = newContainer.id;
|
|
119
|
+
// Check if the parent exists in the UI Model
|
|
120
|
+
if (!this.flattenedTreeModel.get(newParentId)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const draggedItems = dataTransferInfo.draggedItems;
|
|
124
|
+
if (draggedItems.length === 0) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const promise = this.dropItemsCallback(dataTransferInfo);
|
|
128
|
+
this.waitDropProcessing = true;
|
|
129
|
+
promise.then(async (response) => {
|
|
130
|
+
this.waitDropProcessing = false;
|
|
131
|
+
if (!response.acceptDrop) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const newParentUIModel = this.flattenedTreeModel.get(newParentId).item;
|
|
135
|
+
// Only move the items to the new parent, keeping the state
|
|
136
|
+
if (dataTransferInfo.dropInTheSameTree) {
|
|
137
|
+
// Add the UI models to the new container and remove the UI models from
|
|
138
|
+
// the old containers
|
|
139
|
+
draggedItems.forEach(this.moveItemToNewParent(newParentUIModel));
|
|
140
|
+
// When the selected items are moved, the tree must remove its internal
|
|
141
|
+
// state to not have undefined references
|
|
142
|
+
if (dataTransferInfo.draggingSelectedItems) {
|
|
143
|
+
await this.treeRef.clearSelectedItemsInfo();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Add the new items
|
|
147
|
+
else {
|
|
148
|
+
if (response.items == null) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Add new items to the parent
|
|
152
|
+
newParentUIModel.items.push(...response.items);
|
|
153
|
+
// Flatten the new UI models
|
|
154
|
+
response.items.forEach(this.flattenItemUIModel(newParentUIModel));
|
|
155
|
+
}
|
|
156
|
+
this.sortItems(newParentUIModel.items);
|
|
157
|
+
// Open the item to visualize the new subitems
|
|
158
|
+
newParentUIModel.expanded = true;
|
|
159
|
+
// There is no need to force and update, since the waitDropProcessing
|
|
160
|
+
// prop was modified
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
this.moveItemToNewParent = (newParentUIModel) => (dataTransferInfo) => {
|
|
164
|
+
const itemUIModelExtended = this.flattenedTreeModel.get(dataTransferInfo.id);
|
|
165
|
+
const item = itemUIModelExtended.item;
|
|
166
|
+
const oldParentItem = itemUIModelExtended.parentItem;
|
|
167
|
+
// Remove the UI model from the previous parent
|
|
168
|
+
oldParentItem.items.splice(oldParentItem.items.indexOf(item), 1);
|
|
169
|
+
// Add the UI Model to the new parent
|
|
170
|
+
newParentUIModel.items.push(item);
|
|
171
|
+
// Reference the new parent in the item
|
|
172
|
+
itemUIModelExtended.parentItem = newParentUIModel;
|
|
173
|
+
};
|
|
174
|
+
this.renderSubModel = (treeSubModel, lastItem, level) => {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
return (h("ch-tree-x-list-item", { id: treeSubModel.id, caption: treeSubModel.caption, checkbox: treeSubModel.checkbox, checked: treeSubModel.checked, class: treeSubModel.class, disabled: treeSubModel.disabled, downloading: treeSubModel.downloading, dragDisabled: (_a = treeSubModel.dragDisabled) !== null && _a !== void 0 ? _a : this.dragDisabled, dropDisabled: (_b = treeSubModel.dropDisabled) !== null && _b !== void 0 ? _b : this.dropDisabled, editable: (_c = treeSubModel.editable) !== null && _c !== void 0 ? _c : this.editableItems, expanded: treeSubModel.expanded, indeterminate: treeSubModel.indeterminate, lastItem: lastItem, lazyLoad: treeSubModel.lazy, leaf: treeSubModel.leaf, leftImgSrc: treeSubModel.leftImgSrc, level: level, metadata: treeSubModel.metadata, rightImgSrc: treeSubModel.rightImgSrc, selected: treeSubModel.selected, showExpandableButton: treeSubModel.showExpandableButton, showLines: this.showLines, toggleCheckboxes: treeSubModel.toggleCheckboxes }, !treeSubModel.leaf &&
|
|
177
|
+
treeSubModel.items != null &&
|
|
178
|
+
treeSubModel.items.map((subModel, index) => this.renderSubModel(subModel, this.showLines && index === treeSubModel.items.length - 1, level + 1))));
|
|
179
|
+
};
|
|
180
|
+
this.flattenItemUIModel = (parentModel) => (item) => {
|
|
181
|
+
this.flattenedTreeModel.set(item.id, {
|
|
182
|
+
parentItem: parentModel,
|
|
183
|
+
item: item,
|
|
184
|
+
});
|
|
185
|
+
// Make sure the properties are with their default values to avoid issues
|
|
186
|
+
// when reusing DOM nodes
|
|
187
|
+
item.class = item.class == null ? DEFAULT_CLASS_VALUE : item.class;
|
|
188
|
+
item.expanded =
|
|
189
|
+
item.expanded == null ? DEFAULT_EXPANDED_VALUE : item.expanded;
|
|
190
|
+
item.indeterminate =
|
|
191
|
+
item.indeterminate == null
|
|
192
|
+
? DEFAULT_INDETERMINATE_VALUE
|
|
193
|
+
: item.indeterminate;
|
|
194
|
+
item.lazy = item.lazy == null ? DEFAULT_LAZY_VALUE : item.lazy;
|
|
195
|
+
item.order = item.order == null ? DEFAULT_ORDER_VALUE : item.order;
|
|
196
|
+
item.selected =
|
|
197
|
+
item.selected == null ? DEFAULT_SELECTED_VALUE : item.selected;
|
|
198
|
+
if (item.leftImgSrc) {
|
|
199
|
+
item.leftImgSrc = resolveImgPath(item.leftImgSrc);
|
|
200
|
+
}
|
|
201
|
+
if (item.selected) {
|
|
202
|
+
this.selectedItems.add(item.id);
|
|
203
|
+
}
|
|
204
|
+
this.flattenSubModel(item);
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
handleTreeModelChange() {
|
|
208
|
+
this.flattenModel();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Given an item id, an array of items to add, the download status and the
|
|
212
|
+
* lazy state, updates the item's UI Model.
|
|
213
|
+
*/
|
|
214
|
+
async loadLazyContent(itemId, items, downloading = false, lazy = false) {
|
|
215
|
+
const itemToLazyLoadContent = this.flattenedTreeModel.get(itemId).item;
|
|
216
|
+
// Establish that the content was lazy loaded
|
|
217
|
+
itemToLazyLoadContent.downloading = downloading;
|
|
218
|
+
itemToLazyLoadContent.lazy = lazy;
|
|
219
|
+
// Check if there is items to add
|
|
220
|
+
if (items == null) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// @todo What happens in the server when dropping items on a lazy node?
|
|
224
|
+
itemToLazyLoadContent.items = items;
|
|
225
|
+
this.sortItems(itemToLazyLoadContent.items);
|
|
226
|
+
this.flattenSubModel(itemToLazyLoadContent);
|
|
227
|
+
// Force re-render
|
|
228
|
+
forceUpdate(this);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Given an item id, it displays and scrolls into the item view.
|
|
232
|
+
*/
|
|
233
|
+
async scrollIntoVisible(treeItemId) {
|
|
234
|
+
const itemUIModel = this.flattenedTreeModel.get(treeItemId);
|
|
235
|
+
if (!itemUIModel) {
|
|
236
|
+
// @todo Check if the item is on the server?
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
let visitedNode = itemUIModel.parentItem;
|
|
240
|
+
// While the parent is not the root, update the UI Models
|
|
241
|
+
while (visitedNode && visitedNode.id != null) {
|
|
242
|
+
// Expand the item
|
|
243
|
+
visitedNode.expanded = true;
|
|
244
|
+
const visitedNodeUIModel = this.flattenedTreeModel.get(visitedNode.id);
|
|
245
|
+
visitedNode = visitedNodeUIModel.parentItem;
|
|
246
|
+
}
|
|
247
|
+
forceUpdate(this);
|
|
248
|
+
// @todo For some reason, when the model is created using the "big model" option,
|
|
249
|
+
// this implementation does not work when only the UI Model is updated. So, to
|
|
250
|
+
// expand the items, we have to delegate the responsibility to the tree-x
|
|
251
|
+
this.treeRef.scrollIntoVisible(treeItemId);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* This method is used to toggle a tree item by the tree item id/ids.
|
|
255
|
+
*
|
|
256
|
+
* @param treeItemIds An array id the tree items to be toggled.
|
|
257
|
+
* @param expand A boolean indicating that the tree item should be expanded or collapsed. (optional)
|
|
258
|
+
* @returns The modified items after the method was called.
|
|
259
|
+
*/
|
|
260
|
+
async toggleItems(treeItemIds, expand) {
|
|
261
|
+
if (!treeItemIds) {
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
264
|
+
const modifiedTreeItems = [];
|
|
265
|
+
treeItemIds.forEach((treeItemId) => {
|
|
266
|
+
const itemInfo = this.flattenedTreeModel.get(treeItemId).item;
|
|
267
|
+
if (itemInfo) {
|
|
268
|
+
itemInfo.expanded = expand !== null && expand !== void 0 ? expand : !itemInfo.expanded;
|
|
269
|
+
modifiedTreeItems.push({
|
|
270
|
+
id: itemInfo.id,
|
|
271
|
+
expanded: itemInfo.expanded,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
// Force re-render
|
|
276
|
+
forceUpdate(this);
|
|
277
|
+
return modifiedTreeItems;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Given a subset of item's properties, it updates all item UI models.
|
|
281
|
+
*/
|
|
282
|
+
async updateAllItemsProperties(properties) {
|
|
283
|
+
[...this.flattenedTreeModel.values()].forEach((itemUIModel) => {
|
|
284
|
+
if (properties.expanded != null) {
|
|
285
|
+
itemUIModel.item.expanded = properties.expanded;
|
|
286
|
+
}
|
|
287
|
+
if (properties.checked != null) {
|
|
288
|
+
itemUIModel.item.checked = properties.checked;
|
|
289
|
+
itemUIModel.item.indeterminate = false;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
forceUpdate(this);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Given a item list and the properties to update, it updates the properties
|
|
296
|
+
* of the items in the list.
|
|
297
|
+
*/
|
|
298
|
+
async updateItemsProperties(items, properties) {
|
|
299
|
+
items.forEach((item) => {
|
|
300
|
+
const itemUIModel = this.flattenedTreeModel.get(item);
|
|
301
|
+
this.updateItemProperty(itemUIModel, properties);
|
|
302
|
+
});
|
|
303
|
+
forceUpdate(this);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Update the information about the valid droppable zones.
|
|
307
|
+
* @param requestTimestamp Time where the request to the server was made. Useful to avoid having old information.
|
|
308
|
+
* @param newContainerId ID of the container where the drag is trying to be made.
|
|
309
|
+
* @param draggedItems Information about the dragged items.
|
|
310
|
+
* @param validDrop Current state of the droppable zone.
|
|
311
|
+
*/
|
|
312
|
+
async updateValidDropZone(requestTimestamp, newContainerId, draggedItems, validDrop) {
|
|
313
|
+
this.treeRef.updateValidDropZone(requestTimestamp, newContainerId, draggedItems, validDrop);
|
|
314
|
+
}
|
|
315
|
+
updateItemProperty(itemUIModel, properties) {
|
|
316
|
+
if (!itemUIModel) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const itemInfo = itemUIModel.item;
|
|
320
|
+
Object.keys(properties).forEach((propertyName) => {
|
|
321
|
+
itemInfo[propertyName] = properties[propertyName];
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
loadLazyChildrenHandler(event) {
|
|
325
|
+
if (!this.lazyLoadTreeItemsCallback) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
event.stopPropagation();
|
|
329
|
+
const treeItemId = event.detail;
|
|
330
|
+
const promise = this.lazyLoadTreeItemsCallback(treeItemId);
|
|
331
|
+
event.target.downloading = true;
|
|
332
|
+
promise.then((result) => {
|
|
333
|
+
this.loadLazyContent(treeItemId, result);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
handleCaptionModification(event) {
|
|
337
|
+
if (!this.modifyItemCaptionCallback) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
event.stopPropagation();
|
|
341
|
+
const itemRef = event.target;
|
|
342
|
+
const itemId = event.detail.id;
|
|
343
|
+
const itemUIModel = this.flattenedTreeModel.get(itemId);
|
|
344
|
+
const itemInfo = itemUIModel.item;
|
|
345
|
+
const newCaption = event.detail.caption;
|
|
346
|
+
const oldCaption = itemInfo.caption;
|
|
347
|
+
// Optimistic UI: Update the caption in the UI Model before the change is
|
|
348
|
+
// completed in the server
|
|
349
|
+
itemInfo.caption = newCaption;
|
|
350
|
+
// Due to performance reasons, we don't make a shallow copy of the
|
|
351
|
+
// treeModel to force a re-render
|
|
352
|
+
itemRef.caption = newCaption;
|
|
353
|
+
const promise = this.modifyItemCaptionCallback(itemId, newCaption);
|
|
354
|
+
promise.then((status) => {
|
|
355
|
+
if (status.success) {
|
|
356
|
+
this.sortItems(itemUIModel.parentItem.items);
|
|
357
|
+
// Force re-render
|
|
358
|
+
forceUpdate(this);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
itemRef.caption = oldCaption;
|
|
362
|
+
itemInfo.caption = oldCaption;
|
|
363
|
+
// Do something with the error message
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
handleOpenReference(event) {
|
|
368
|
+
event.stopPropagation();
|
|
369
|
+
this.itemOpenReference.emit(event.detail);
|
|
370
|
+
}
|
|
371
|
+
flattenSubModel(model) {
|
|
372
|
+
const items = model.items;
|
|
373
|
+
if (!items) {
|
|
374
|
+
// Make sure that subtrees don't have an undefined array
|
|
375
|
+
if (model.leaf !== true) {
|
|
376
|
+
model.items = [];
|
|
377
|
+
}
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
this.sortItems(items);
|
|
381
|
+
items.forEach(this.flattenItemUIModel(model));
|
|
382
|
+
}
|
|
383
|
+
sortItems(items) {
|
|
384
|
+
// Ensure that items are sorted
|
|
385
|
+
if (this.sortItemsCallback) {
|
|
386
|
+
this.sortItemsCallback(items);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
flattenModel() {
|
|
390
|
+
this.flattenedTreeModel.clear();
|
|
391
|
+
this.flattenSubModel({ id: null, caption: null, items: this.treeModel });
|
|
392
|
+
}
|
|
393
|
+
componentWillLoad() {
|
|
394
|
+
this.flattenModel();
|
|
395
|
+
}
|
|
396
|
+
render() {
|
|
397
|
+
return (h("ch-tree-x", { class: this.cssClass || null, multiSelection: this.multiSelection, waitDropProcessing: this.waitDropProcessing, onDroppableZoneEnter: this.handleDroppableZoneEnter, onExpandedItemChange: this.handleExpandedItemChange, onItemContextmenu: this.handleItemContextmenu, onItemsDropped: this.handleItemsDropped, onSelectedItemsChange: this.handleSelectedItemsChange, ref: (el) => (this.treeRef = el) }, this.treeModel.map((subModel, index) => this.renderSubModel(subModel, this.showLines && index === this.treeModel.length - 1, 0))));
|
|
398
|
+
}
|
|
399
|
+
static get watchers() { return {
|
|
400
|
+
"treeModel": ["handleTreeModelChange"]
|
|
401
|
+
}; }
|
|
402
|
+
static get style() { return treeViewCss; }
|
|
403
|
+
}, [0, "gxg-tree-view", {
|
|
404
|
+
"checkDroppableZoneCallback": [16],
|
|
405
|
+
"cssClass": [1, "css-class"],
|
|
406
|
+
"dragDisabled": [4, "drag-disabled"],
|
|
407
|
+
"dropDisabled": [4, "drop-disabled"],
|
|
408
|
+
"dropItemsCallback": [16],
|
|
409
|
+
"treeModel": [16],
|
|
410
|
+
"lazyLoadTreeItemsCallback": [16],
|
|
411
|
+
"modifyItemCaptionCallback": [16],
|
|
412
|
+
"multiSelection": [4, "multi-selection"],
|
|
413
|
+
"editableItems": [4, "editable-items"],
|
|
414
|
+
"showLines": [1, "show-lines"],
|
|
415
|
+
"sortItemsCallback": [16],
|
|
416
|
+
"waitDropProcessing": [32],
|
|
417
|
+
"loadLazyContent": [64],
|
|
418
|
+
"scrollIntoVisible": [64],
|
|
419
|
+
"toggleItems": [64],
|
|
420
|
+
"updateAllItemsProperties": [64],
|
|
421
|
+
"updateItemsProperties": [64],
|
|
422
|
+
"updateValidDropZone": [64]
|
|
423
|
+
}, [[0, "loadLazyContent", "loadLazyChildrenHandler"], [0, "modifyCaption", "handleCaptionModification"], [2, "openReference", "handleOpenReference"]]]);
|
|
424
|
+
function defineCustomElement() {
|
|
425
|
+
if (typeof customElements === "undefined") {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const components = ["gxg-tree-view", "ch-checkbox", "ch-tree-x", "ch-tree-x-list-item"];
|
|
429
|
+
components.forEach(tagName => { switch (tagName) {
|
|
430
|
+
case "gxg-tree-view":
|
|
431
|
+
if (!customElements.get(tagName)) {
|
|
432
|
+
customElements.define(tagName, GxgTreeView);
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
case "ch-checkbox":
|
|
436
|
+
if (!customElements.get(tagName)) {
|
|
437
|
+
defineCustomElement$3();
|
|
438
|
+
}
|
|
439
|
+
break;
|
|
440
|
+
case "ch-tree-x":
|
|
441
|
+
if (!customElements.get(tagName)) {
|
|
442
|
+
defineCustomElement$2();
|
|
443
|
+
}
|
|
444
|
+
break;
|
|
445
|
+
case "ch-tree-x-list-item":
|
|
446
|
+
if (!customElements.get(tagName)) {
|
|
447
|
+
defineCustomElement$1();
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
} });
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export { GxgTreeView as G, defineCustomElement as d };
|
|
@@ -2,15 +2,15 @@ import { proxyCustomElement, HTMLElement, createEvent, h, writeTask, Host } from
|
|
|
2
2
|
import { m as mouseEventModifierKey } from './helpers.js';
|
|
3
3
|
import { d as defineCustomElement$1 } from './checkbox.js';
|
|
4
4
|
|
|
5
|
-
const treeXListItemCss = ":where(button){all:unset;display:flex;user-select:none;touch-action:manipulation;-webkit-user-drag:element}*,::before,::after{box-sizing:border-box}:host{--checkbox-size:1em;--expandable-button-width:0.75em;--ch-tree-x-list-item-dashed-line--offset:0px;--tab-width:calc(\n var(--checkbox-size) + var(--expandable-button-width) +\n (5px * 2)\n );display:grid;grid-template-rows:min-content;overflow:hidden}.header{--own-offset:0px;display:flex;align-items:center;min-height:calc(1em + 6px);padding-inline-start:var(--padding-inline-start)}.header--disabled{opacity:0.5;pointer-events:none}.header--even{--padding-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width)\n )}.header--even+.expandable{--parent-padding-inline-start--even:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width)\n )}.header--even .dashed-line{--inset-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) +\n var(--parent-checkbox-offset) + var(--parent-expandable-offset)\n )}.header--even-expandable{--padding-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--even-expandable+.expandable{--parent-padding-inline-start--even:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--odd{--padding-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width)\n )}.header--odd+.expandable{--parent-padding-inline-start--odd:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width)\n )}.header--odd .dashed-line{--inset-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) +\n var(--parent-checkbox-offset) + var(--parent-expandable-offset)\n )}.header--odd-expandable{--padding-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--odd-expandable+.expandable{--parent-padding-inline-start--odd:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--level-0{--padding-inline-start:0px}.header--level-0+.expandable{--parent-padding-inline-start--even:0px}.header--expandable-offset{--own-offset:calc(\n var(--expandable-button-width) + 5px\n )}.header--expandable-offset+.expandable{--parent-expandable-offset:calc(var(--expandable-button-width) / 2)}.header--checkbox-offset+.expandable{--parent-checkbox-offset:calc(var(--checkbox-size) / 2);--parent-negative-checkbox-offset:calc(var(--checkbox-size) / 2)}.dashed-line{position:absolute;inset-inline-start:calc( var(--inset-inline-start) + var(--ch-tree-x-list-item-dashed-line--offset) );height:1px;width:calc( var(--tab-width) - var(--parent-checkbox-offset) - var(--parent-expandable-offset) - var(--own-offset) - var(--ch-tree-x-list-item-dashed-line--offset) - 4px );border:0 dashed color-mix(in srgb, currentColor 65%, transparent);border-block-end-width:1px;pointer-events:none;content-visibility:hidden;z-index:1}.last-all-line{inset-block-start:0;height:calc(100% - var(--distance-to-checkbox));border-inline-start-width:1px;border-end-start-radius:2px}.last-line{inset-block-start:0;height:100%;border-inline-start-width:1px;border-style:solid;border-block-end:unset}.expandable-button{display:grid;place-items:center;width:var(--expandable-button-width);height:var(--expandable-button-width);margin-inline-end:5px;z-index:1;cursor:pointer;content-visibility:auto;contain-intrinsic-size:auto var(--expandable-button-width)}.expandable-button::before{content:\"\";width:calc(100% - 2px);height:calc(100% - 2px);background-color:currentColor;-webkit-mask-size:calc(var(--expandable-button-width) - 2px)}.expandable-button--collapsed::before{-webkit-mask-image:url('data:image/svg+xml,<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.15,8.5H8.54v5.61h-1V8.5H1.93v-1H7.54V1.89h1V7.5h5.61Z\"/></svg>')}.expandable-button--expanded::before{-webkit-mask-image:url('data:image/svg+xml,<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.15,8.5H1.93v-1H14.15Z\"/></svg>')}.expandable-button:focus-visible{outline:1px solid #000}.checkbox{margin-inline-end:5px}.checkbox::part(container){width:var(--checkbox-size);height:var(--checkbox-size)}.action{display:grid;grid-template:\"left-img text right-img\"/max-content 1fr max-content;align-items:center;height:100%;flex:1;cursor:pointer}.readonly-mode{padding-block:0.75px}.left-img,.right-img{display:block;width:0.875em;height:0.875em;content-visibility:auto;contain-intrinsic-size:auto 0.875em}.left-img{grid-area:left-img;margin-inline-end:5px}.right-img{grid-area:right-img;margin-inline-start:5px}.edit-name{grid-area:text;width:100%;height:100%;padding:0;margin:0;background-color:unset;color:unset;border:1px solid currentColor;font:unset;outline:unset}.downloading{width:0.75em;height:0.75em;margin-inline-start:8px;border:2px solid currentColor;border-inline-start-color:transparent;border-radius:50%;opacity:0.75;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.expandable{--parent-expandable-offset:0px;--parent-negative-checkbox-offset:0px;--parent-checkbox-offset:0px;display:grid;grid-
|
|
5
|
+
const treeXListItemCss = ":where(button){all:unset;display:flex;user-select:none;touch-action:manipulation;-webkit-user-drag:element}*,::before,::after{box-sizing:border-box}:host{--checkbox-size:1em;--expandable-button-width:0.75em;--ch-tree-x-list-item-dashed-line--offset:0px;--tab-width:calc(\n var(--checkbox-size) + var(--expandable-button-width) +\n (5px * 2)\n );display:grid;grid-template-rows:min-content;overflow:hidden}.header{--own-offset:0px;display:flex;align-items:center;min-height:calc(1em + 6px);padding-inline-start:var(--padding-inline-start)}.header--disabled{opacity:0.5;pointer-events:none}.header--even{--padding-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width)\n )}.header--even+.expandable{--parent-padding-inline-start--even:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width)\n )}.header--even .dashed-line{--inset-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) +\n var(--parent-checkbox-offset) + var(--parent-expandable-offset)\n )}.header--even-expandable{--padding-inline-start:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--even-expandable+.expandable{--parent-padding-inline-start--even:calc(\n var(--parent-padding-inline-start--odd, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--odd{--padding-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width)\n )}.header--odd+.expandable{--parent-padding-inline-start--odd:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width)\n )}.header--odd .dashed-line{--inset-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) +\n var(--parent-checkbox-offset) + var(--parent-expandable-offset)\n )}.header--odd-expandable{--padding-inline-start:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--odd-expandable+.expandable{--parent-padding-inline-start--odd:calc(\n var(--parent-padding-inline-start--even, 0px) + var(--tab-width) - calc(\n var(--expandable-button-width) + 5px\n )\n )}.header--level-0{--padding-inline-start:0px}.header--level-0+.expandable{--parent-padding-inline-start--even:0px}.header--expandable-offset{--own-offset:calc(\n var(--expandable-button-width) + 5px\n )}.header--expandable-offset+.expandable{--parent-expandable-offset:calc(var(--expandable-button-width) / 2)}.header--checkbox-offset+.expandable{--parent-checkbox-offset:calc(var(--checkbox-size) / 2);--parent-negative-checkbox-offset:calc(var(--checkbox-size) / 2)}.dashed-line{position:absolute;inset-inline-start:calc( var(--inset-inline-start) + var(--ch-tree-x-list-item-dashed-line--offset) );height:1px;width:calc( var(--tab-width) - var(--parent-checkbox-offset) - var(--parent-expandable-offset) - var(--own-offset) - var(--ch-tree-x-list-item-dashed-line--offset) - 4px );border:0 dashed color-mix(in srgb, currentColor 65%, transparent);border-block-end-width:1px;pointer-events:none;content-visibility:hidden;z-index:1}.last-all-line{inset-block-start:0;height:calc(100% - var(--distance-to-checkbox));border-inline-start-width:1px;border-end-start-radius:2px}.last-line{inset-block-start:0;height:100%;border-inline-start-width:1px;border-style:solid;border-block-end:unset}.expandable-button{display:grid;place-items:center;width:var(--expandable-button-width);height:var(--expandable-button-width);margin-inline-end:5px;z-index:1;cursor:pointer;content-visibility:auto;contain-intrinsic-size:auto var(--expandable-button-width)}.expandable-button::before{content:\"\";width:calc(100% - 2px);height:calc(100% - 2px);background-color:currentColor;-webkit-mask-size:calc(var(--expandable-button-width) - 2px)}.expandable-button--collapsed::before{-webkit-mask-image:url('data:image/svg+xml,<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.15,8.5H8.54v5.61h-1V8.5H1.93v-1H7.54V1.89h1V7.5h5.61Z\"/></svg>')}.expandable-button--expanded::before{-webkit-mask-image:url('data:image/svg+xml,<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14.15,8.5H1.93v-1H14.15Z\"/></svg>')}.expandable-button:focus-visible{outline:1px solid #000}.checkbox{margin-inline-end:5px}.checkbox::part(container){width:var(--checkbox-size);height:var(--checkbox-size)}.action{display:grid;grid-template:\"left-img text right-img\"/max-content 1fr max-content;align-items:center;height:100%;flex:1;cursor:pointer}.readonly-mode{padding-block:0.75px}.left-img,.right-img{display:block;width:0.875em;height:0.875em;content-visibility:auto;contain-intrinsic-size:auto 0.875em}.left-img{grid-area:left-img;margin-inline-end:5px}.right-img{grid-area:right-img;margin-inline-start:5px}.edit-name{grid-area:text;width:100%;height:100%;padding:0;margin:0;background-color:unset;color:unset;border:1px solid currentColor;font:unset;outline:unset}.downloading{width:0.75em;height:0.75em;margin-inline-start:8px;border:2px solid currentColor;border-inline-start-color:transparent;border-radius:50%;opacity:0.75;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.expandable{--parent-expandable-offset:0px;--parent-negative-checkbox-offset:0px;--parent-checkbox-offset:0px;display:grid;grid-auto-rows:min-content;position:relative;content-visibility:auto;contain-intrinsic-size:auto 100px}.expandable--collapsed{display:none;overflow:hidden;content-visibility:hidden}";
|
|
6
6
|
|
|
7
7
|
const resetDragImage = new Image();
|
|
8
8
|
const INITIAL_LEVEL = 0;
|
|
9
9
|
// Selectors
|
|
10
10
|
const TREE_ITEM_TAG_NAME = "ch-tree-x-list-item";
|
|
11
|
-
const DIRECT_TREE_ITEM_CHILDREN = `:scope
|
|
11
|
+
const DIRECT_TREE_ITEM_CHILDREN = `:scope>${TREE_ITEM_TAG_NAME}`;
|
|
12
12
|
const FIRST_ENABLED_SUB_ITEM = `${TREE_ITEM_TAG_NAME}:not([disabled])`;
|
|
13
|
-
const LAST_SUB_ITEM = `:scope
|
|
13
|
+
const LAST_SUB_ITEM = `:scope>${TREE_ITEM_TAG_NAME}:last-child`;
|
|
14
14
|
// Keys
|
|
15
15
|
const EXPANDABLE_ID = "expandable";
|
|
16
16
|
const ENTER_KEY = "Enter";
|
|
@@ -36,6 +36,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
36
36
|
this.itemDragEnd = createEvent(this, "itemDragEnd", 7);
|
|
37
37
|
this.loadLazyContent = createEvent(this, "loadLazyContent", 7);
|
|
38
38
|
this.modifyCaption = createEvent(this, "modifyCaption", 7);
|
|
39
|
+
this.openReference = createEvent(this, "openReference", 7);
|
|
39
40
|
this.selectedItemChange = createEvent(this, "selectedItemChange", 7);
|
|
40
41
|
this.selectedItemSync = createEvent(this, "selectedItemSync", 7);
|
|
41
42
|
/**
|
|
@@ -182,16 +183,15 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
182
183
|
this.expanded = !this.expanded;
|
|
183
184
|
}
|
|
184
185
|
this.selected = true;
|
|
185
|
-
this.selectedItemChange.emit(this.getSelectedInfo(mouseEventModifierKey(event),
|
|
186
|
+
this.selectedItemChange.emit(this.getSelectedInfo(mouseEventModifierKey(event), true));
|
|
186
187
|
};
|
|
187
|
-
this.getSelectedInfo = (ctrlKeyPressed,
|
|
188
|
+
this.getSelectedInfo = (ctrlKeyPressed, selected) => ({
|
|
188
189
|
ctrlKeyPressed: ctrlKeyPressed,
|
|
189
190
|
expanded: this.expanded,
|
|
190
|
-
goToReference: goToReference,
|
|
191
191
|
id: this.el.id,
|
|
192
192
|
itemRef: this.el,
|
|
193
193
|
metadata: this.metadata,
|
|
194
|
-
parentId: this.el.parentElement.
|
|
194
|
+
parentId: this.el.parentElement.id,
|
|
195
195
|
selected: selected
|
|
196
196
|
});
|
|
197
197
|
this.handleActionDblClick = (event) => {
|
|
@@ -200,8 +200,11 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
200
200
|
this.toggleSelected();
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
|
+
this.emitOpenReference();
|
|
203
204
|
// The Control key is not pressed, so the control can be expanded
|
|
204
|
-
this.
|
|
205
|
+
if (!this.leaf) {
|
|
206
|
+
this.toggleExpand(event);
|
|
207
|
+
}
|
|
205
208
|
};
|
|
206
209
|
/**
|
|
207
210
|
* Event triggered by the following actions on the main button:
|
|
@@ -221,6 +224,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
221
224
|
this.toggleOrSelect(event);
|
|
222
225
|
return;
|
|
223
226
|
}
|
|
227
|
+
this.emitOpenReference();
|
|
224
228
|
// Enter or space
|
|
225
229
|
this.toggleExpand(event);
|
|
226
230
|
};
|
|
@@ -306,7 +310,6 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
306
310
|
}
|
|
307
311
|
handleSelectedChange(newValue) {
|
|
308
312
|
this.selectedItemSync.emit(this.getSelectedInfo(true, // Does not matter in this case
|
|
309
|
-
false, // Does not matter in this case
|
|
310
313
|
newValue));
|
|
311
314
|
}
|
|
312
315
|
handleShowLinesChange(newShowLines) {
|
|
@@ -370,8 +373,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
370
373
|
return;
|
|
371
374
|
}
|
|
372
375
|
// Otherwise, ask the parent to focus the next sibling
|
|
373
|
-
const parentItem = this.el.parentElement
|
|
374
|
-
.parentElement;
|
|
376
|
+
const parentItem = this.el.parentElement;
|
|
375
377
|
parentItem.focusNextSibling(ctrlKeyPressed);
|
|
376
378
|
}
|
|
377
379
|
/**
|
|
@@ -391,8 +393,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
391
393
|
return;
|
|
392
394
|
}
|
|
393
395
|
// Otherwise, set focus in the parent element
|
|
394
|
-
const parentItem = this.el.parentElement
|
|
395
|
-
.parentElement;
|
|
396
|
+
const parentItem = this.el.parentElement;
|
|
396
397
|
// Check if the parent is not disabled
|
|
397
398
|
if (parentItem.disabled) {
|
|
398
399
|
parentItem.focusPreviousItem(ctrlKeyPressed);
|
|
@@ -430,7 +431,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
430
431
|
this.headerRef.focus();
|
|
431
432
|
// Normal navigation auto selects the item.
|
|
432
433
|
if (!ctrlKeyPressed) {
|
|
433
|
-
this.setSelected(
|
|
434
|
+
this.setSelected();
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
getDirectTreeItems() {
|
|
@@ -463,34 +464,41 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
463
464
|
toggleSelected() {
|
|
464
465
|
const selected = !this.selected;
|
|
465
466
|
this.selected = selected;
|
|
466
|
-
this.selectedItemChange.emit(this.getSelectedInfo(true,
|
|
467
|
+
this.selectedItemChange.emit(this.getSelectedInfo(true, selected));
|
|
467
468
|
}
|
|
468
|
-
setSelected(
|
|
469
|
+
setSelected() {
|
|
469
470
|
this.selected = true;
|
|
470
|
-
this.selectedItemChange.emit(this.getSelectedInfo(false,
|
|
471
|
+
this.selectedItemChange.emit(this.getSelectedInfo(false, true));
|
|
471
472
|
}
|
|
472
473
|
toggleOrSelect(event) {
|
|
473
474
|
if (mouseEventModifierKey(event)) {
|
|
474
475
|
this.toggleSelected();
|
|
475
476
|
}
|
|
476
477
|
else {
|
|
477
|
-
this.setSelected(
|
|
478
|
+
this.setSelected();
|
|
478
479
|
}
|
|
479
480
|
}
|
|
481
|
+
emitOpenReference() {
|
|
482
|
+
this.openReference.emit({
|
|
483
|
+
id: this.el.id,
|
|
484
|
+
leaf: this.leaf,
|
|
485
|
+
metadata: this.metadata
|
|
486
|
+
});
|
|
487
|
+
}
|
|
480
488
|
componentWillLoad() {
|
|
481
|
-
const
|
|
489
|
+
const parentElementItem = this.el
|
|
490
|
+
.parentElement;
|
|
482
491
|
// Check if must lazy load
|
|
483
492
|
this.lazyLoadItems(this.expanded);
|
|
484
493
|
// Sync selected state with the main tree
|
|
485
494
|
if (this.selected) {
|
|
486
|
-
this.selectedItemChange.emit(this.getSelectedInfo(true,
|
|
495
|
+
this.selectedItemChange.emit(this.getSelectedInfo(true, true));
|
|
487
496
|
}
|
|
488
497
|
// No need to update more the status
|
|
489
498
|
if (this.level === INITIAL_LEVEL) {
|
|
490
499
|
return;
|
|
491
500
|
}
|
|
492
501
|
// Update checkbox status
|
|
493
|
-
const parentElementItem = parentElement.parentElement;
|
|
494
502
|
if (parentElementItem.checkbox) {
|
|
495
503
|
this.checked = parentElementItem.checked;
|
|
496
504
|
}
|
|
@@ -546,14 +554,17 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
546
554
|
h("div", { class: {
|
|
547
555
|
action: true,
|
|
548
556
|
"readonly-mode": !this.editing
|
|
549
|
-
}, part: `action
|
|
557
|
+
}, part: `action${!this.editing ? " readonly-mode" : ""}${!this.leaf && this.expanded ? " expanded" : ""}`, onDblClick: !this.editing ? this.handleActionDblClick : null }, this.leftImgSrc && this.renderImg("left-img", this.leftImgSrc), this.editable && this.editing ? (h("input", { class: "edit-name", part: "edit-name", disabled: this.disabled, type: "text", value: this.caption, onBlur: this.removeEditMode(false), onKeyDown: this.checkIfShouldRemoveEditMode, ref: el => (this.inputRef = el) })) : (this.caption), this.rightImgSrc &&
|
|
550
558
|
this.renderImg("right-img", this.rightImgSrc)),
|
|
551
559
|
this.showDownloadingSpinner && !this.leaf && this.downloading && (h("div", { class: "downloading", part: "downloading" }))
|
|
552
560
|
]), (showAllLines || showLastLine) && (h("div", { class: {
|
|
553
561
|
"dashed-line": true,
|
|
554
562
|
"last-all-line": showAllLines && this.lastItem,
|
|
555
563
|
"last-line": showLastLine
|
|
556
|
-
}, part: `dashed-line${this.lastItem ? " last-all-line" : ""}` }))), hasContent && (h("div", { "aria-busy": this.downloading.toString(), "aria-live": this.downloading ? "polite" : null, id: EXPANDABLE_ID, class: {
|
|
564
|
+
}, part: `dashed-line${this.lastItem ? " last-all-line" : ""}` }))), hasContent && (h("div", { role: "group", "aria-busy": this.downloading.toString(), "aria-live": this.downloading ? "polite" : null, id: EXPANDABLE_ID, class: {
|
|
565
|
+
expandable: true,
|
|
566
|
+
"expandable--collapsed": !this.expanded
|
|
567
|
+
}, part: `expandable${this.expanded ? " expanded" : " collapsed"}` }, h("slot", null)))));
|
|
557
568
|
}
|
|
558
569
|
get el() { return this; }
|
|
559
570
|
static get watchers() { return {
|
|
@@ -575,6 +586,7 @@ const ChTreeXListItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
575
586
|
"dropDisabled": [4, "drop-disabled"],
|
|
576
587
|
"dragState": [1025, "drag-state"],
|
|
577
588
|
"downloading": [4],
|
|
589
|
+
"editable": [4],
|
|
578
590
|
"editing": [1028],
|
|
579
591
|
"expanded": [1028],
|
|
580
592
|
"lastItem": [4, "last-item"],
|