@genexus/genexus-ide-ui 0.0.16 → 0.0.18

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.
Files changed (81) hide show
  1. package/dist/cjs/ch-grid_7.cjs.entry.js +73 -27
  2. package/dist/cjs/genexus-ide-ui.cjs.js +1 -1
  3. package/dist/cjs/{gx-ide-container_2.cjs.entry.js → gx-ide-container.cjs.entry.js} +0 -31
  4. package/dist/cjs/gx-ide-new-kb.cjs.entry.js +16 -17
  5. package/dist/cjs/gx-ide-references.cjs.entry.js +115 -90
  6. package/dist/cjs/gx-ide-template.cjs.entry.js +2 -2
  7. package/dist/cjs/gx-ide-test.cjs.entry.js +40 -3
  8. package/dist/cjs/{gxg-form-radio-group.cjs.entry.js → gx-ide-top-bar_2.cjs.entry.js} +31 -0
  9. package/dist/cjs/gxg-combo-box_8.cjs.entry.js +3 -8
  10. package/dist/cjs/gxg-menu.cjs.entry.js +2 -2
  11. package/dist/cjs/gxg-test.cjs.entry.js +4 -23
  12. package/dist/cjs/gxg-tree_2.cjs.entry.js +381 -295
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/update-tree-model-445c63a8.js +53 -0
  15. package/dist/collection/common/render-tree.js +1 -1
  16. package/dist/collection/common/update-tree-model.js +22 -0
  17. package/dist/collection/components/_template/template.js +9 -10
  18. package/dist/collection/components/_test/test.js +129 -2
  19. package/dist/collection/components/new-kb/new-kb.js +16 -35
  20. package/dist/collection/components/references/references.js +119 -113
  21. package/dist/collection/pages/assets/common.js +105 -95
  22. package/dist/components/ch-grid2.js +74 -28
  23. package/dist/components/combo-box.js +4 -3
  24. package/dist/components/form-radio.js +0 -5
  25. package/dist/components/gx-ide-new-kb.js +20 -28
  26. package/dist/components/gx-ide-references.js +131 -111
  27. package/dist/components/gx-ide-template.js +7 -13
  28. package/dist/components/gx-ide-test.js +45 -4
  29. package/dist/components/gxg-menu.js +2 -2
  30. package/dist/components/gxg-test.js +4 -23
  31. package/dist/components/gxg-tree-item2.js +326 -284
  32. package/dist/components/gxg-tree2.js +60 -15
  33. package/dist/components/update-tree-model.js +50 -0
  34. package/dist/esm/ch-grid_7.entry.js +73 -27
  35. package/dist/esm/genexus-ide-ui.js +1 -1
  36. package/dist/esm/{gx-ide-container_2.entry.js → gx-ide-container.entry.js} +1 -31
  37. package/dist/esm/gx-ide-new-kb.entry.js +16 -17
  38. package/dist/esm/gx-ide-references.entry.js +115 -90
  39. package/dist/esm/gx-ide-template.entry.js +2 -2
  40. package/dist/esm/gx-ide-test.entry.js +40 -3
  41. package/dist/esm/{gxg-form-radio-group.entry.js → gx-ide-top-bar_2.entry.js} +32 -2
  42. package/dist/esm/gxg-combo-box_8.entry.js +3 -8
  43. package/dist/esm/gxg-menu.entry.js +2 -2
  44. package/dist/esm/gxg-test.entry.js +4 -23
  45. package/dist/esm/gxg-tree_2.entry.js +382 -296
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/esm/update-tree-model-80419058.js +50 -0
  48. package/dist/genexus-ide-ui/genexus-ide-ui.css +1 -1
  49. package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
  50. package/dist/genexus-ide-ui/p-1042318d.entry.js +1 -0
  51. package/dist/genexus-ide-ui/p-1d4cf2ae.entry.js +1 -0
  52. package/dist/genexus-ide-ui/p-254f9ce7.entry.js +1 -0
  53. package/dist/genexus-ide-ui/p-49433b58.entry.js +1 -0
  54. package/dist/genexus-ide-ui/p-67cf60f5.js +1 -0
  55. package/dist/genexus-ide-ui/p-7007965c.entry.js +1 -0
  56. package/dist/genexus-ide-ui/p-78a90113.entry.js +1 -0
  57. package/dist/genexus-ide-ui/p-79cf24a3.entry.js +1 -0
  58. package/dist/genexus-ide-ui/p-b66a4121.entry.js +1 -0
  59. package/dist/genexus-ide-ui/p-cd503583.entry.js +1 -0
  60. package/dist/genexus-ide-ui/{p-1e412d88.entry.js → p-fcc98e20.entry.js} +1 -1
  61. package/dist/node_modules/@genexus/gemini/dist/collection/components/tree-item/gxg-tree-item.css +2 -2
  62. package/dist/types/common/update-tree-model.d.ts +2 -0
  63. package/dist/types/components/_template/template.d.ts +2 -2
  64. package/dist/types/components/_test/test.d.ts +19 -1
  65. package/dist/types/components/new-kb/new-kb.d.ts +0 -4
  66. package/dist/types/components/references/references.d.ts +28 -24
  67. package/dist/types/components.d.ts +41 -21
  68. package/package.json +3 -3
  69. package/dist/cjs/render-tree-25d5b8a1.js +0 -29
  70. package/dist/components/render-tree.js +0 -27
  71. package/dist/esm/render-tree-fc8636a3.js +0 -27
  72. package/dist/genexus-ide-ui/p-0f5d0ccc.entry.js +0 -1
  73. package/dist/genexus-ide-ui/p-2761a056.entry.js +0 -1
  74. package/dist/genexus-ide-ui/p-62814082.entry.js +0 -1
  75. package/dist/genexus-ide-ui/p-97430828.entry.js +0 -1
  76. package/dist/genexus-ide-ui/p-9e32e006.entry.js +0 -1
  77. package/dist/genexus-ide-ui/p-a5fee36d.entry.js +0 -1
  78. package/dist/genexus-ide-ui/p-abee8c7b.js +0 -1
  79. package/dist/genexus-ide-ui/p-be9406e7.entry.js +0 -1
  80. package/dist/genexus-ide-ui/p-eb8e9655.entry.js +0 -1
  81. package/dist/genexus-ide-ui/p-f6536bbc.entry.js +0 -1
@@ -10,7 +10,24 @@ const gxgTreeCss = ":root{--ui-animaton-speed:0.2s}.gxg-title-01{font-family:var
10
10
  const GxgTree = class {
11
11
  constructor(hostRef) {
12
12
  index.registerInstance(this, hostRef);
13
- //PROPS
13
+ this.treeItemStateChanged = index.createEvent(this, "treeItemStateChanged", 7);
14
+ /*
15
+ INDEX:
16
+ 1.OWN PROPERTIES
17
+ 2.REFERENCE TO ELEMENTS
18
+ 3.STATE() VARIABLES
19
+ 4.PUBLIC PROPERTY API | WATCH'S
20
+ 5.EVENTS (EMIT)
21
+ 6.COMPONENT LIFECYCLE METHODS
22
+ 7.LISTENERS
23
+ 8.PUBLIC METHODS API
24
+ 9.LOCAL METHODS
25
+ 10.RENDER() FUNCTION
26
+ */
27
+ // 1.OWN PROPERTIES //
28
+ this.masterTree = false;
29
+ // 3.STATE() VARIABLES //
30
+ // 4.PUBLIC PROPERTY API | WATCH'S //
14
31
  /**
15
32
  * Set this attribute if you want all the items to have a checkbox.
16
33
  */
@@ -31,10 +48,7 @@ const GxgTree = class {
31
48
  * Set this attribute if you want to allow multi selection of the items. This property should only be set on the master tree.
32
49
  */
33
50
  this.multiSelection = false;
34
- /**
35
- * Indicates if this the is master tree
36
- */
37
- this.masterTree = false;
51
+ // 9.LOCAL METHODS //
38
52
  /**
39
53
  * This method evaluates if this tree is the master tree
40
54
  */
@@ -61,24 +75,54 @@ const GxgTree = class {
61
75
  : this.toggleCheckboxes;
62
76
  }
63
77
  };
78
+ /**
79
+ * @description This functions is supposed to be called from any of the listeners that are attached to the tree-item events that are emitted when the state changes (toggleIconClicked, selectionChanged, checkboxToggled). When an item state is changed, this function emits the update item data, so that the host can update the tree model, if any, if desired.
80
+ */
81
+ this.emitTreeItemNewState = (itemData, emittedBy) => {
82
+ this.treeItemStateChanged.emit({ itemData, emittedBy: emittedBy });
83
+ };
64
84
  }
85
+ // 6.COMPONENT LIFECYCLE METHODS //
65
86
  componentWillLoad() {
66
- //this.initialConfig();
67
87
  this.initialConfig();
68
88
  this.evaluateIsMasterTree();
69
89
  }
90
+ // 7.LISTENERS //
91
+ checkboxToggledHandler(e) {
92
+ const itemData = e.detail;
93
+ if (this.masterTree) {
94
+ this.emitTreeItemNewState(itemData, "checkboxToggled");
95
+ }
96
+ }
97
+ doubleClickedHandler(e) {
98
+ const itemData = e.detail;
99
+ if (this.masterTree) {
100
+ this.emitTreeItemNewState(itemData, "doubleClicked");
101
+ }
102
+ }
70
103
  selectionChangedHandler(e) {
71
104
  //Unselect all items, except the one that triggered this event. This action should be done once, by the master tree.
72
- if ((this.masterTree && !this.multiSelection) ||
73
- (this.masterTree && this.multiSelection && !e.detail.ctrlKey)) {
74
- const allChildren = this.el.querySelectorAll("gxg-tree-item");
75
- if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
76
- Array.from(allChildren).forEach((item) => {
105
+ const allChildren = this.el.querySelectorAll("gxg-tree-item");
106
+ if ((this.masterTree && this.multiSelection && !e.detail.ctrl) ||
107
+ (this.masterTree && !this.multiSelection)) {
108
+ Array.from(allChildren).forEach((item) => {
109
+ if (item !== e.detail.ref) {
77
110
  item.selected = false;
78
- });
79
- }
111
+ }
112
+ });
113
+ }
114
+ const itemData = e.detail;
115
+ if (this.masterTree) {
116
+ this.emitTreeItemNewState(itemData, "selectionChanged");
117
+ }
118
+ }
119
+ toggleIconClickedHandler(e) {
120
+ const itemData = e.detail;
121
+ if (this.masterTree) {
122
+ this.emitTreeItemNewState(itemData, "toggleIconClicked");
80
123
  }
81
124
  }
125
+ // 8.PUBLIC METHODS API //
82
126
  /**
83
127
  * Returns an array of the selected tree-items, providing the id, checked status, selected status, and label.
84
128
  */
@@ -162,6 +206,7 @@ const GxgTree = class {
162
206
  });
163
207
  return toggledTreeItems;
164
208
  }
209
+ // 10.RENDER() FUNCTION //
165
210
  render() {
166
211
  return (index.h(index.Host, null, index.h("div", { class: {
167
212
  tree: true,
@@ -171,21 +216,38 @@ const GxgTree = class {
171
216
  };
172
217
  GxgTree.style = gxgTreeCss;
173
218
 
174
- const gxgTreeItemCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0;}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px;}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}: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}:host{--text-color:var(--color-on-background);--font-family:\"Source Sans Pro\", sans-serif;--font-weight:normal;--font-size:12px;--guide-color:var(--gray-06);--item-hover-color:var(--gray-01);--item-active-color:var(--silverGray);color:var(--color-on-background);width:100%;display:block}:host li{list-style:none;font-family:var(--font-family);font-size:var(--font-size);font-weight:var(--font-weight);color:var(--text-color);overflow:hidden}:host li>::slotted(gxg-tree){display:none}:host li.tree-open>::slotted(gxg-tree){display:block}:host li.tree-closed .vertical-line{display:none}:host li .li-text{min-height:24px;cursor:pointer;display:flex;align-items:center;position:relative;padding-inline-end:var(--spacing-comp-01)}:host li .li-text:hover{background-color:var(--item-hover-color)}:host li .li-text:active{background-color:var(--gxg-color-selected)}:host li .li-text:focus{outline-style:solid;outline-color:var(--color-primary-active);outline-width:var(--border-width-md);outline-offset:-2px}:host li .li-text--selected{background-color:var(--gxg-color-selected)}:host li .li-text>*{flex-shrink:0}:host li .vertical-line{position:absolute;width:1px;height:0;top:23px;left:15px;z-index:1;background-image:linear-gradient(var(--guide-color) 28%, rgba(255, 255, 255, 0) 0%);background-position:right;background-size:1px 4px;background-repeat:repeat-y}:host li .horizontal-line{position:absolute;height:1px;top:11px;z-index:1;background-image:linear-gradient(to right, var(--guide-color) 33%, rgba(255, 255, 255, 0) 0%);background-position:bottom;background-size:3px 1px;background-repeat:repeat-x}:host li .horizontal-line.display-none{display:none}:host li .closed-opened-icons{position:relative;display:flex;margin-left:-2px}:host li .toggle-icon{position:relative;z-index:2;transform:scale(0.75, 0.75);margin-inline-end:var(--spacing-comp-00);transition-property:opacity;transition-duration:0.5s;transition-timing-function:ease;background-color:var(--color-hover)}:host li .toggle-icon:hover{background-color:var(--color-background)}:host .checkbox{margin-inline-end:var(--spacing-comp-01)}:host .icon--left{margin:0 var(--spacing-comp-01) 0 var(--spacing-comp-00)}:host .right-icon{margin-inline-start:auto;position:relative;top:0;transition-property:top;transition-duration:0.5s;transition-timing-function:ease}:host .loading{opacity:1;display:inline;z-index:1;margin-inline-end:var(--spacing-comp-01);border-radius:50%;width:8px;height:8px;border:0.18rem solid var(--gray-04);border-top-color:var(--gray-01);animation:spin 1s infinite linear}:host .loading--double{border-style:double;border-width:0.5rem}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}:host([disabled]) li .text{color:var(--darkGray)}:host([disabled]) .toggle-icon{pointer-events:none}";
219
+ const gxgTreeItemCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0;}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px;}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}: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}:host{--text-color:var(--color-on-background);--font-family:\"Source Sans Pro\", sans-serif;--font-weight:normal;--font-size:12px;--guide-color:var(--gray-06);--item-hover-color:var(--gray-01);--item-active-color:var(--silverGray);color:var(--color-on-background);width:100%;display:block}:host li{list-style:none;font-family:var(--font-family);font-size:var(--font-size);font-weight:var(--font-weight);color:var(--text-color);overflow:hidden}:host li>::slotted(gxg-tree){display:none}:host li.tree-open>::slotted(gxg-tree){display:block}:host li.tree-closed .vertical-line{display:none}:host li .li-text{min-height:24px;cursor:pointer;display:flex;align-items:center;position:relative;padding-inline-end:var(--spacing-comp-01)}:host li .li-text:hover{background-color:var(--item-hover-color)}:host li .li-text:active{background-color:var(--gxg-background-color-item-selected)}:host li .li-text:focus{outline-style:solid;outline-color:var(--color-primary-active);outline-width:var(--border-width-md);outline-offset:-2px}:host li .li-text--selected{background-color:var(--gxg-background-color-item-selected)}:host li .li-text>*{flex-shrink:0}:host li .vertical-line{position:absolute;width:1px;height:0;top:23px;left:15px;z-index:1;background-image:linear-gradient(var(--guide-color) 28%, rgba(255, 255, 255, 0) 0%);background-position:right;background-size:1px 4px;background-repeat:repeat-y}:host li .horizontal-line{position:absolute;height:1px;top:11px;z-index:1;background-image:linear-gradient(to right, var(--guide-color) 33%, rgba(255, 255, 255, 0) 0%);background-position:bottom;background-size:3px 1px;background-repeat:repeat-x}:host li .horizontal-line.display-none{display:none}:host li .closed-opened-icons{position:relative;display:flex;margin-left:-2px}:host li .toggle-icon{position:relative;z-index:2;transform:scale(0.75, 0.75);margin-inline-end:var(--spacing-comp-00);transition-property:opacity;transition-duration:0.5s;transition-timing-function:ease;background-color:var(--color-hover)}:host li .toggle-icon:hover{background-color:var(--color-background)}:host .checkbox{margin-inline-end:var(--spacing-comp-01)}:host .icon--left{margin:0 var(--spacing-comp-01) 0 var(--spacing-comp-00)}:host .right-icon{margin-inline-start:auto;position:relative;top:0;transition-property:top;transition-duration:0.5s;transition-timing-function:ease}:host .loading{opacity:1;display:inline;z-index:1;margin-inline-end:var(--spacing-comp-01);border-radius:50%;width:8px;height:8px;border:0.18rem solid var(--gray-04);border-top-color:var(--gray-01);animation:spin 1s infinite linear}:host .loading--double{border-style:double;border-width:0.5rem}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}:host([disabled]) li .text{color:var(--darkGray)}:host([disabled]) .toggle-icon{pointer-events:none}";
175
220
 
176
221
  const GxgTreeItem = class {
177
222
  constructor(hostRef) {
178
223
  index.registerInstance(this, hostRef);
179
- this.toggleIconClicked = index.createEvent(this, "toggleIconClicked", 7);
180
- this.selectionChanged = index.createEvent(this, "selectionChanged", 7);
181
- this.doubleClicked = index.createEvent(this, "doubleClicked", 7);
182
224
  this.checkboxToggled = index.createEvent(this, "checkboxToggled", 7);
225
+ this.doubleClicked = index.createEvent(this, "doubleClicked", 7);
226
+ this.lazyChanged = index.createEvent(this, "lazyChanged", 7);
227
+ this.selectionChanged = index.createEvent(this, "selectionChanged", 7);
228
+ this.toggleIconClicked = index.createEvent(this, "toggleIconClicked", 7);
229
+ this.lazy = false; //True if not leaf but no children.
230
+ this.parentTreeIsMasterTree = false;
231
+ this.numberOfParentTrees = 1;
232
+ this.firstItem = false;
233
+ this.lastItem = false;
234
+ this.leftPadding = "0px";
235
+ this.verticalLineStartPosition = "0px";
236
+ this.horizontalLineWidth = "24px";
237
+ this.horizontalLineStartPosition = "0px";
183
238
  this.parts = {
184
239
  item: "item",
185
240
  checkbox: "checkbox",
186
241
  toggleButton: "toggle-button",
187
242
  };
188
- //PROPS
243
+ // 3.STATE() VARIABLES //
244
+ this.horizontalLinePaddingLeft = 0;
245
+ this.lastTreeItem = false;
246
+ this.lastTreeItemOfParentTree = false;
247
+ this.numberOfVisibleDescendantItems = 0;
248
+ this.time = 0;
249
+ this.downloading = false;
250
+ // 4.PUBLIC PROPERTY API | WATCH'S //
189
251
  /**
190
252
  * Set this attribute if you want this item to display a checkbox. This attribute is affected by the parent tree-item checkbox attribute, unless it is set in this item.
191
253
  */
@@ -218,24 +280,15 @@ const GxgTreeItem = class {
218
280
  * This property is for internal use, when using the treeModel.
219
281
  */
220
282
  this.numberOfChildren = 0;
283
+ /**
284
+ * This property is for internal use. It indicates that the item has children.
285
+ */
221
286
  this.hasChildTree = false;
287
+ /**
288
+ * This property is for internal use. It indicates that the checkbox has an indeterminate state.
289
+ */
222
290
  this.indeterminate = false;
223
- //STATE
224
- this.horizontalLinePaddingLeft = 0;
225
- this.lastTreeItem = false;
226
- this.lastTreeItemOfParentTree = false;
227
- this.numberOfVisibleDescendantItems = 0;
228
- this.time = 0;
229
- this.downloading = false;
230
- this.lazy = false; //True if not leaf but no children.
231
- this.parentTreeIsMasterTree = false;
232
- this.numberOfParentTrees = 1;
233
- this.firstItem = false;
234
- this.lastItem = false;
235
- this.leftPadding = "0px";
236
- this.verticalLineStartPosition = "0px";
237
- this.horizontalLineWidth = "24px";
238
- this.horizontalLineStartPosition = "0px";
291
+ // 9.LOCAL METHODS //
239
292
  this.evaluateId = () => {
240
293
  if (!this.id) {
241
294
  this.id = this.el.getAttribute("id");
@@ -259,31 +312,6 @@ const GxgTreeItem = class {
259
312
  this.initiateMutationObserver = () => {
260
313
  this.observer.observe(this.el, { childList: true, subtree: true });
261
314
  };
262
- this.evaluateCheckboxStatus = () => {
263
- const allChildren = this.el.querySelectorAll("gxg-tree-item");
264
- let checked = 0;
265
- if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
266
- Array.from(allChildren).forEach((item) => {
267
- if (item.checked) {
268
- checked++;
269
- }
270
- });
271
- if (allChildren.length === checked) {
272
- //all checked
273
- this.checked = true;
274
- this.indeterminate = false;
275
- }
276
- else if (checked === 0) {
277
- //all unchecked
278
- this.checked = false;
279
- this.indeterminate = false;
280
- }
281
- else {
282
- //indeterminate
283
- this.indeterminate = true;
284
- }
285
- }
286
- };
287
315
  /**
288
316
  * @description Set some properties based on the parent tree configuration, unless this item has this properties already set.
289
317
  */
@@ -348,296 +376,350 @@ const GxgTreeItem = class {
348
376
  this.leftPadding = `${value}px`;
349
377
  this.horizontalLineStartPosition = `${horizontalLineStartPosition}px`;
350
378
  };
351
- this.checkboxClickedHandler = () => {
352
- if (this.checkbox) {
353
- this.checked = !this.checked;
354
- if (!this.leaf) {
355
- this.toggleChildrenCheckboxes(this.checked);
356
- }
357
- this.checkboxToggled.emit({
358
- id: this.el.id,
359
- label: this.el.label,
360
- checked: this.checked,
361
- selected: this.selected,
362
- });
379
+ this.liTextClickedHandler = (e) => {
380
+ const toggleWasClicked = e.target.classList.contains("toggle-icon");
381
+ const checkboxClicked = e.target.nodeName === "GXG-FORM-CHECKBOX";
382
+ if (toggleWasClicked || checkboxClicked)
383
+ return;
384
+ if (e.ctrlKey) {
385
+ this.selected = !this.selected;
363
386
  }
364
- };
365
- }
366
- checkboxToggledHandler() {
367
- this.evaluateCheckboxStatus();
368
- }
369
- componentWillLoad() {
370
- //Count number of parent trees in order to set the appropriate padding-left
371
- this.numberOfParentTrees = this.getParentsNumber();
372
- this.numberOfChildren = this.getChildrenNumber();
373
- //If is last item of tree
374
- const nextItem = this.el.nextElementSibling;
375
- if (nextItem === null) {
376
- this.lastTreeItem = true;
377
- }
378
- if (this.numberOfParentTrees === 1) {
379
- this.parentTreeIsMasterTree = true;
380
- const prevItem = this.el.previousElementSibling;
381
- if (prevItem === null) {
382
- //If is first item of parent tree...
383
- this.firstItem = true;
387
+ else {
388
+ this.selected = true;
384
389
  }
385
- }
386
- if (!this.el.nextElementSibling) {
387
- this.lastItem = true;
388
- }
389
- this.evaluateId();
390
- this.evaluateLazy();
391
- this.defineLineHeight();
392
- this.defineStartPosition();
393
- this.cascadeConfig();
394
- this.attachExportParts();
395
- this.initiateMutationObserver();
396
- }
397
- getParentsNumber() {
398
- var _a;
399
- let count = 0;
400
- let parentElement = this.el.parentElement;
401
- while ((parentElement === null || parentElement === void 0 ? void 0 : parentElement.nodeName) === "GXG-TREE") {
402
- count++;
403
- parentElement = (_a = parentElement.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
404
- }
405
- return count;
406
- }
407
- getChildrenNumber() {
408
- if (this.numberOfChildren === 0) {
409
- //If this.numberOfChildren === 0 it might be because the whole tree was created with markup, and not by passing a model. In that case, count the children with querySelectorAll.
410
- return this.el.querySelectorAll("gxg-tree-item").length;
411
- }
412
- }
413
- toggleClickedHandler(e) {
414
- this.toggleIconClicked.emit({ id: this.id, lazy: this.lazy });
415
- if (this.lazy && !this.opened) {
416
- this.downloading = true;
417
- }
418
- if (!this.lazy) {
419
- this.opened = !this.opened;
420
- }
421
- }
422
- async reRender() {
423
- this.defineLineHeight();
424
- }
425
- liTextClickedHandler(e) {
426
- const toggleWasClicked = e.target.classList.contains("toggle-icon");
427
- const checkboxClicked = e.target.nodeName === "GXG-FORM-CHECKBOX";
428
- if (toggleWasClicked || checkboxClicked)
429
- return;
430
- if (e.ctrlKey || !this.selected) {
431
- this.selectionChanged.emit({
432
- id: this.id,
433
- label: this.label,
434
- checked: this.checked,
435
- selected: !this.selected,
436
- ctrlKey: e.ctrlKey,
437
- });
438
- }
439
- if (e.ctrlKey) {
440
- this.selected = !this.selected;
441
- }
442
- else if (!this.selected) {
443
- this.selected = true;
444
- }
445
- }
446
- liTextDoubleClicked(e) {
447
- this.doubleClicked.emit({
448
- id: this.id,
449
- });
450
- !this.leaf && this.toggleClickedHandler(e);
451
- }
452
- liTextKeyDownPressed(e) {
453
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
454
- e.preventDefault(); //prevents scrolling
455
- }
456
- //ENTER
457
- if (e.key === "Enter") {
458
- //Enter should check/uncheck the checkbox (if present)
459
- this.checkboxClickedHandler();
460
- }
461
- //LEFT/RIGHT NAVIGATION
462
- if (e.key === "ArrowRight" && !this.leaf) {
463
- //Toggle the tree
464
- if (!this.opened) {
465
- this.opened = true;
390
+ this.selectionChanged.emit(this.getItemData(e.ctrlKey));
391
+ };
392
+ this.liTextDoubleClicked = () => {
393
+ this.doubleClicked.emit(this.getItemData(false));
394
+ !this.leaf && this.toggleClickedHandler();
395
+ };
396
+ this.liTextKeyDownPressed = (e) => {
397
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
398
+ e.preventDefault(); //prevents scrolling
466
399
  }
467
- else {
468
- const childTree = this.el.querySelector("gxg-tree");
469
- const childTreeFirstChildren = childTree.querySelector("gxg-tree-item");
470
- const childTreeFirstChildrenLiText = childTreeFirstChildren.shadowRoot.querySelector(".li-text");
471
- childTreeFirstChildrenLiText.focus();
400
+ //ENTER
401
+ if (e.key === "Enter") {
402
+ //Enter should check/uncheck the checkbox (if present)
403
+ this.checkboxClickedHandler();
472
404
  }
473
- this.toggleIconClicked.emit({ id: this.id }); //this recalculates the vertical line height
474
- }
475
- if (e.key === "ArrowLeft") {
476
- let hasParent = false;
477
- const parentGxgTreeItem = this.el.parentElement.parentElement;
478
- let parentGxgTreeItemLiText = null;
479
- if (parentGxgTreeItem.tagName === "GXG-TREE-ITEM") {
480
- hasParent = true;
481
- parentGxgTreeItemLiText = parentGxgTreeItem.shadowRoot.querySelector(".li-text");
482
- }
483
- if (this.leaf) {
484
- if (hasParent) {
485
- parentGxgTreeItemLiText.focus();
405
+ //LEFT/RIGHT NAVIGATION
406
+ if (e.key === "ArrowRight" && !this.leaf) {
407
+ //Toggle the tree
408
+ if (!this.opened) {
409
+ this.opened = true;
410
+ }
411
+ else {
412
+ const childTree = this.el.querySelector("gxg-tree");
413
+ const childTreeFirstChildren = childTree.querySelector("gxg-tree-item");
414
+ const childTreeFirstChildrenLiText = childTreeFirstChildren.shadowRoot.querySelector(".li-text");
415
+ childTreeFirstChildrenLiText.focus();
486
416
  }
487
417
  }
488
- else {
489
- const li = this.el.shadowRoot.querySelector("li");
490
- if (li.classList.contains("tree-open")) {
491
- this.opened = false;
418
+ if (e.key === "ArrowLeft") {
419
+ let hasParent = false;
420
+ const parentGxgTreeItem = this.el.parentElement.parentElement;
421
+ let parentGxgTreeItemLiText = null;
422
+ if (parentGxgTreeItem.tagName === "GXG-TREE-ITEM") {
423
+ hasParent = true;
424
+ parentGxgTreeItemLiText = parentGxgTreeItem.shadowRoot.querySelector(".li-text");
492
425
  }
493
- else {
426
+ if (this.leaf) {
494
427
  if (hasParent) {
495
428
  parentGxgTreeItemLiText.focus();
496
429
  }
497
430
  }
498
- }
499
- this.toggleIconClicked.emit({ id: this.id }); //this recalculates the vertical line height
500
- }
501
- // UP/DOWN NAVIGATION
502
- if (e.key === "ArrowUp" || (e.key === "Tab" && e.shiftKey)) {
503
- e.preventDefault();
504
- if (!this.firstItem) {
505
- //Is not the first element of the parent
506
- //Set focus on the prev item
507
- let prevItem;
508
- const prevElementSibling = this.el.previousElementSibling;
509
- if (e.shiftKey && e.key !== "Tab") {
510
- //if shift key was pressed, navigate to the previous sibling
511
- if (prevElementSibling !== null) {
512
- prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
513
- }
514
- }
515
431
  else {
516
- if (prevElementSibling === null) {
517
- const parentItem = this.el.parentElement;
518
- const parentParentItem = parentItem.parentElement;
519
- prevItem = parentParentItem.shadowRoot.querySelector("li .li-text");
432
+ const li = this.el.shadowRoot.querySelector("li");
433
+ if (li.classList.contains("tree-open")) {
434
+ this.opened = false;
520
435
  }
521
436
  else {
522
- prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
437
+ if (hasParent) {
438
+ parentGxgTreeItemLiText.focus();
439
+ }
440
+ }
441
+ }
442
+ }
443
+ // UP/DOWN NAVIGATION
444
+ if (e.key === "ArrowUp" || (e.key === "Tab" && e.shiftKey)) {
445
+ e.preventDefault();
446
+ if (!this.firstItem) {
447
+ //Is not the first element of the parent
448
+ //Set focus on the prev item
449
+ let prevItem;
450
+ const prevElementSibling = this.el.previousElementSibling;
451
+ if (e.shiftKey && e.key !== "Tab") {
452
+ //if shift key was pressed, navigate to the previous sibling
523
453
  if (prevElementSibling !== null) {
524
- //If the preceding tree-item has tree inside...
525
- const prevElementSiblingHasChildTree = prevElementSibling
526
- .hasChildTree;
527
- if (prevElementSiblingHasChildTree) {
528
- const prevElementSiblingHasOpenTree = prevElementSibling
529
- .opened;
530
- if (prevElementSiblingHasOpenTree) {
531
- //If preceding tree-item tree is opened, then the prev item is the last item of that tree
532
- const prevElemSiblingTreeItem = this.el
533
- .previousElementSibling;
534
- const prevElemSiblingTreeItemTree = prevElemSiblingTreeItem.querySelector("gxg-tree");
535
- //
536
- if (prevElemSiblingTreeItemTree.lastElementChild
537
- .hasChildTree) {
538
- if (prevElemSiblingTreeItemTree.lastElementChild.shadowRoot
539
- .querySelector("li")
540
- .classList.contains("tree-open")) {
541
- prevItem = prevElemSiblingTreeItemTree.lastElementChild
542
- .querySelector("gxg-tree")
543
- .lastElementChild.shadowRoot.querySelector("li .li-text");
454
+ prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
455
+ }
456
+ }
457
+ else {
458
+ if (prevElementSibling === null) {
459
+ const parentItem = this.el.parentElement;
460
+ const parentParentItem = parentItem.parentElement;
461
+ prevItem = parentParentItem.shadowRoot.querySelector("li .li-text");
462
+ }
463
+ else {
464
+ prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
465
+ if (prevElementSibling !== null) {
466
+ //If the preceding tree-item has tree inside...
467
+ const prevElementSiblingHasChildTree = prevElementSibling
468
+ .hasChildTree;
469
+ if (prevElementSiblingHasChildTree) {
470
+ const prevElementSiblingHasOpenTree = prevElementSibling
471
+ .opened;
472
+ if (prevElementSiblingHasOpenTree) {
473
+ //If preceding tree-item tree is opened, then the prev item is the last item of that tree
474
+ const prevElemSiblingTreeItem = this.el
475
+ .previousElementSibling;
476
+ const prevElemSiblingTreeItemTree = prevElemSiblingTreeItem.querySelector("gxg-tree");
477
+ //
478
+ if (prevElemSiblingTreeItemTree.lastElementChild
479
+ .hasChildTree) {
480
+ if (prevElemSiblingTreeItemTree.lastElementChild.shadowRoot
481
+ .querySelector("li")
482
+ .classList.contains("tree-open")) {
483
+ prevItem = prevElemSiblingTreeItemTree.lastElementChild
484
+ .querySelector("gxg-tree")
485
+ .lastElementChild.shadowRoot.querySelector("li .li-text");
486
+ }
487
+ else {
488
+ prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
489
+ }
544
490
  }
545
491
  else {
546
492
  prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
547
493
  }
494
+ //
548
495
  }
549
496
  else {
550
- prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
497
+ //The preciding item has a tree, but it is closed
498
+ prevItem = this.el.previousElementSibling.shadowRoot.querySelector("li .li-text");
551
499
  }
552
- //
553
- }
554
- else {
555
- //The preciding item has a tree, but it is closed
556
- prevItem = this.el.previousElementSibling.shadowRoot.querySelector("li .li-text");
557
500
  }
558
501
  }
559
502
  }
560
503
  }
561
- }
562
- if (prevItem !== null && prevItem !== undefined) {
563
- prevItem.focus();
504
+ if (prevItem !== null && prevItem !== undefined) {
505
+ prevItem.focus();
506
+ }
564
507
  }
565
508
  }
566
- }
567
- if (e.key === "ArrowDown" || (e.key === "Tab" && !e.shiftKey)) {
568
- e.preventDefault();
569
- if (!this.lastTreeItemOfParentTree) {
570
- //Set focus on the next item
571
- let nextItem;
572
- if (e.shiftKey) {
573
- //if shift key was pressed, navigate to the next sibling
574
- if (this.el.nextElementSibling !== null) {
575
- nextItem = this.el.nextElementSibling.shadowRoot.querySelector("li .li-text");
509
+ if (e.key === "ArrowDown" || (e.key === "Tab" && !e.shiftKey)) {
510
+ e.preventDefault();
511
+ if (!this.lastTreeItemOfParentTree) {
512
+ //Set focus on the next item
513
+ let nextItem;
514
+ if (e.shiftKey) {
515
+ //if shift key was pressed, navigate to the next sibling
516
+ if (this.el.nextElementSibling !== null) {
517
+ nextItem = this.el.nextElementSibling.shadowRoot.querySelector("li .li-text");
518
+ }
576
519
  }
577
- }
578
- else {
579
- if (this.lastTreeItem) {
580
- if (this.hasChildTree && this.opened) {
581
- nextItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector(".li-text");
520
+ else {
521
+ if (this.lastTreeItem) {
522
+ if (this.hasChildTree && this.opened) {
523
+ nextItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector(".li-text");
524
+ }
525
+ else {
526
+ const thisTree = this.el.parentElement;
527
+ const thisTreeParent = thisTree.parentElement;
528
+ const thisTreeParentNextTree = thisTreeParent.nextElementSibling;
529
+ if (thisTreeParentNextTree === null) {
530
+ if (thisTreeParent.parentElement.parentElement
531
+ .nextElementSibling !== null) {
532
+ nextItem = thisTreeParent.parentElement.parentElement.nextElementSibling.shadowRoot.querySelector(".li-text");
533
+ }
534
+ }
535
+ else {
536
+ nextItem = thisTreeParentNextTree.shadowRoot.querySelector(".li-text");
537
+ }
538
+ }
582
539
  }
583
540
  else {
584
- const thisTree = this.el.parentElement;
585
- const thisTreeParent = thisTree.parentElement;
586
- const thisTreeParentNextTree = thisTreeParent.nextElementSibling;
587
- if (thisTreeParentNextTree === null) {
588
- if (thisTreeParent.parentElement.parentElement
589
- .nextElementSibling !== null) {
590
- nextItem = thisTreeParent.parentElement.parentElement.nextElementSibling.shadowRoot.querySelector(".li-text");
591
- }
541
+ if (this.hasChildTree && this.opened) {
542
+ nextItem = this.el
543
+ .querySelector("gxg-tree gxg-tree-item")
544
+ .shadowRoot.querySelector("li .li-text");
592
545
  }
593
546
  else {
594
- nextItem = thisTreeParentNextTree.shadowRoot.querySelector(".li-text");
547
+ nextItem = this.el.nextElementSibling.shadowRoot.querySelector(".li-text");
595
548
  }
596
549
  }
597
550
  }
598
- else {
599
- if (this.hasChildTree && this.opened) {
600
- nextItem = this.el
601
- .querySelector("gxg-tree gxg-tree-item")
602
- .shadowRoot.querySelector("li .li-text");
603
- }
604
- else {
605
- nextItem = this.el.nextElementSibling.shadowRoot.querySelector(".li-text");
606
- }
551
+ if (nextItem !== null && nextItem !== undefined) {
552
+ nextItem.focus();
607
553
  }
608
554
  }
609
- if (nextItem !== null && nextItem !== undefined) {
610
- nextItem.focus();
555
+ else {
556
+ //Last element of parent tree
557
+ if (!this.leaf && this.opened) {
558
+ const childTreeFirstTreeItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector("li .li-text");
559
+ childTreeFirstTreeItem.focus();
560
+ }
611
561
  }
612
562
  }
563
+ };
564
+ this.returnToggleIconType = () => {
565
+ //Returns the type of icon : expand or collapse
566
+ if (!this.opened || this.lazy) {
567
+ return "gemini-tools/add";
568
+ }
613
569
  else {
614
- //Last element of parent tree
615
- if (!this.leaf && this.opened) {
616
- const childTreeFirstTreeItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector("li .li-text");
617
- childTreeFirstTreeItem.focus();
570
+ return "gemini-tools/minus";
571
+ }
572
+ };
573
+ /**
574
+ * When a checkbox is clicked, it state changes and so it's children, and parent items do.
575
+ * First evaluate the children, and then the parent items.
576
+ */
577
+ this.checkboxClickedHandler = () => {
578
+ if (this.checkbox) {
579
+ this.checked = !this.checked;
580
+ if (!this.leaf) {
581
+ this.toggleChildrenCheckboxes(this.checked);
618
582
  }
583
+ const parentItems = this.getParentItems();
584
+ parentItems.forEach((parentItem) => {
585
+ parentItem.evaluateCheckboxStatus();
586
+ });
587
+ }
588
+ };
589
+ this.toggleChildrenCheckboxes = (checked) => {
590
+ this.indeterminate = false;
591
+ const allChildren = this.el.querySelectorAll("gxg-tree-item");
592
+ if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
593
+ Array.from(allChildren).forEach((item) => {
594
+ item.indeterminate = false;
595
+ item.checked = checked;
596
+ });
597
+ }
598
+ };
599
+ this.getParentItems = () => {
600
+ var _a;
601
+ const parentItems = [];
602
+ let parentItem = this.el.parentElement.parentElement;
603
+ while ((parentItem === null || parentItem === void 0 ? void 0 : parentItem.nodeName) === "GXG-TREE-ITEM") {
604
+ parentItems.push(parentItem);
605
+ parentItem = (_a = parentItem.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
606
+ }
607
+ return parentItems;
608
+ };
609
+ this.getParentsNumber = () => {
610
+ var _a;
611
+ let count = 0;
612
+ let parentElement = this.el.parentElement;
613
+ while ((parentElement === null || parentElement === void 0 ? void 0 : parentElement.nodeName) === "GXG-TREE") {
614
+ count++;
615
+ parentElement = (_a = parentElement.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
616
+ }
617
+ return count;
618
+ };
619
+ this.getChildrenNumber = () => {
620
+ if (this.numberOfChildren === 0) {
621
+ //If this.numberOfChildren === 0 it might be because the whole tree was created with markup, and not by passing a model. In that case, count the children with querySelectorAll.
622
+ return this.el.querySelectorAll("gxg-tree-item").length;
619
623
  }
624
+ };
625
+ this.toggleClickedHandler = () => {
626
+ if (this.lazy && !this.opened) {
627
+ this.downloading = true;
628
+ this.toggleIconClicked.emit(this.getItemData());
629
+ }
630
+ if (!this.lazy) {
631
+ this.opened = !this.opened;
632
+ }
633
+ };
634
+ this.getItemData = (ctrl = false) => {
635
+ return {
636
+ ref: this.el,
637
+ checkbox: this.checkbox,
638
+ checked: this.checked,
639
+ ctrl: ctrl,
640
+ description: this.description,
641
+ disabled: this.disabled,
642
+ icon: this.icon,
643
+ id: this.id,
644
+ indeterminate: this.indeterminate,
645
+ label: this.label,
646
+ lazy: this.lazy,
647
+ leaf: this.leaf,
648
+ opened: this.opened,
649
+ selected: this.selected,
650
+ };
651
+ };
652
+ }
653
+ checkedHandler(newValue, oldValue) {
654
+ if (oldValue !== undefined) {
655
+ this.checkboxToggled.emit(this.getItemData(false));
620
656
  }
621
657
  }
622
- returnToggleIconType() {
623
- //Returns the type of icon : expand or collapse
624
- if (!this.opened || this.lazy) {
625
- return "gemini-tools/add";
658
+ openedHandler(newValue, oldValue) {
659
+ if (oldValue !== undefined) {
660
+ this.toggleIconClicked.emit(this.getItemData(false));
626
661
  }
627
- else {
628
- return "gemini-tools/minus";
662
+ }
663
+ // 6.COMPONENT LIFECYCLE METHODS //
664
+ componentWillLoad() {
665
+ //Count number of parent trees in order to set the appropriate padding-left
666
+ this.numberOfParentTrees = this.getParentsNumber();
667
+ this.numberOfChildren = this.getChildrenNumber();
668
+ //If is last item of tree
669
+ const nextItem = this.el.nextElementSibling;
670
+ if (nextItem === null) {
671
+ this.lastTreeItem = true;
672
+ }
673
+ if (this.numberOfParentTrees === 1) {
674
+ this.parentTreeIsMasterTree = true;
675
+ const prevItem = this.el.previousElementSibling;
676
+ if (prevItem === null) {
677
+ //If is first item of parent tree...
678
+ this.firstItem = true;
679
+ }
629
680
  }
681
+ if (!this.el.nextElementSibling) {
682
+ this.lastItem = true;
683
+ }
684
+ this.evaluateId();
685
+ this.evaluateLazy();
686
+ this.defineLineHeight();
687
+ this.defineStartPosition();
688
+ this.cascadeConfig();
689
+ this.attachExportParts();
690
+ this.initiateMutationObserver();
630
691
  }
631
- toggleChildrenCheckboxes(checked) {
632
- this.indeterminate = false;
692
+ // 7.LISTENERS //
693
+ // 8.PUBLIC METHODS API //
694
+ async reRender() {
695
+ this.defineLineHeight();
696
+ }
697
+ evaluateCheckboxStatus() {
633
698
  const allChildren = this.el.querySelectorAll("gxg-tree-item");
699
+ let checked = 0;
634
700
  if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
635
701
  Array.from(allChildren).forEach((item) => {
636
- item.indeterminate = false;
637
- item.checked = checked;
702
+ if (item.checked) {
703
+ checked++;
704
+ }
638
705
  });
706
+ if (allChildren.length === checked) {
707
+ //all checked
708
+ this.checked = true;
709
+ this.indeterminate = false;
710
+ }
711
+ else if (checked === 0) {
712
+ //all unchecked
713
+ this.checked = false;
714
+ this.indeterminate = false;
715
+ }
716
+ else {
717
+ //indeterminate
718
+ this.indeterminate = true;
719
+ }
639
720
  }
640
721
  }
722
+ // 10.RENDER() FUNCTION //
641
723
  render() {
642
724
  return (index.h(index.Host, { class: { leaf: this.leaf, "not-leaf": !this.leaf }, exportParts: this.exportparts ? this.exportparts : null }, index.h("li", { class: {
643
725
  "tree-open": this.opened,
@@ -669,6 +751,10 @@ const GxgTreeItem = class {
669
751
  }
670
752
  static get assetsDirs() { return ["tree-item-assets"]; }
671
753
  get el() { return index.getElement(this); }
754
+ static get watchers() { return {
755
+ "checked": ["checkedHandler"],
756
+ "opened": ["openedHandler"]
757
+ }; }
672
758
  };
673
759
  GxgTreeItem.style = gxgTreeItemCss;
674
760