@genexus/genexus-ide-ui 0.0.15 → 0.0.17

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 (67) 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-directory-selector.cjs.entry.js +0 -1
  5. package/dist/cjs/gx-ide-entity-selector.cjs.entry.js +12 -2
  6. package/dist/cjs/gx-ide-new-kb.cjs.entry.js +16 -17
  7. package/dist/cjs/gx-ide-template.cjs.entry.js +2 -2
  8. package/dist/cjs/gx-ide-top-bar.cjs.entry.js +37 -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 +386 -281
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/collection/components/_template/template.js +9 -10
  15. package/dist/collection/components/directory-selector/directory-selector.js +0 -1
  16. package/dist/collection/components/entity-selector/entity-selector.js +39 -2
  17. package/dist/collection/components/new-kb/new-kb.js +16 -35
  18. package/dist/components/ch-grid2.js +74 -28
  19. package/dist/components/combo-box.js +4 -3
  20. package/dist/components/form-radio.js +0 -5
  21. package/dist/components/gx-ide-directory-selector.js +0 -1
  22. package/dist/components/gx-ide-entity-selector.js +13 -3
  23. package/dist/components/gx-ide-new-kb.js +20 -28
  24. package/dist/components/gx-ide-template.js +7 -13
  25. package/dist/components/gxg-menu.js +2 -2
  26. package/dist/components/gxg-test.js +4 -23
  27. package/dist/components/gxg-tree-item2.js +344 -277
  28. package/dist/components/gxg-tree2.js +47 -8
  29. package/dist/esm/ch-grid_7.entry.js +73 -27
  30. package/dist/esm/genexus-ide-ui.js +1 -1
  31. package/dist/esm/{gx-ide-container_2.entry.js → gx-ide-container.entry.js} +1 -31
  32. package/dist/esm/gx-ide-directory-selector.entry.js +0 -1
  33. package/dist/esm/gx-ide-entity-selector.entry.js +13 -3
  34. package/dist/esm/gx-ide-new-kb.entry.js +16 -17
  35. package/dist/esm/gx-ide-template.entry.js +2 -2
  36. package/dist/esm/gx-ide-top-bar.entry.js +33 -0
  37. package/dist/esm/gxg-combo-box_8.entry.js +3 -8
  38. package/dist/esm/gxg-menu.entry.js +2 -2
  39. package/dist/esm/gxg-test.entry.js +4 -23
  40. package/dist/esm/gxg-tree_2.entry.js +387 -282
  41. package/dist/esm/loader.js +1 -1
  42. package/dist/genexus-ide-ui/genexus-ide-ui.css +1 -1
  43. package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
  44. package/dist/genexus-ide-ui/p-1042318d.entry.js +1 -0
  45. package/dist/genexus-ide-ui/p-1d4cf2ae.entry.js +1 -0
  46. package/dist/genexus-ide-ui/p-48482e25.entry.js +1 -0
  47. package/dist/genexus-ide-ui/p-49433b58.entry.js +1 -0
  48. package/dist/genexus-ide-ui/p-79cf24a3.entry.js +1 -0
  49. package/dist/genexus-ide-ui/p-b196d91d.entry.js +1 -0
  50. package/dist/genexus-ide-ui/p-c5c6e102.entry.js +1 -0
  51. package/dist/genexus-ide-ui/p-cd503583.entry.js +1 -0
  52. package/dist/genexus-ide-ui/p-e4ee28c7.entry.js +1 -0
  53. package/dist/genexus-ide-ui/{p-1e412d88.entry.js → p-fcc98e20.entry.js} +1 -1
  54. package/dist/node_modules/@genexus/gemini/dist/collection/components/tree-item/gxg-tree-item.css +2 -2
  55. package/dist/types/components/_template/template.d.ts +2 -2
  56. package/dist/types/components/entity-selector/entity-selector.d.ts +10 -0
  57. package/dist/types/components/new-kb/new-kb.d.ts +0 -4
  58. package/dist/types/components.d.ts +12 -12
  59. package/package.json +3 -3
  60. package/dist/genexus-ide-ui/p-0f5d0ccc.entry.js +0 -1
  61. package/dist/genexus-ide-ui/p-18936375.entry.js +0 -1
  62. package/dist/genexus-ide-ui/p-2761a056.entry.js +0 -1
  63. package/dist/genexus-ide-ui/p-62814082.entry.js +0 -1
  64. package/dist/genexus-ide-ui/p-97430828.entry.js +0 -1
  65. package/dist/genexus-ide-ui/p-9e32e006.entry.js +0 -1
  66. package/dist/genexus-ide-ui/p-eb8e9655.entry.js +0 -1
  67. package/dist/genexus-ide-ui/p-f58b607d.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,12 +75,19 @@ 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 //
70
91
  selectionChangedHandler(e) {
71
92
  //Unselect all items, except the one that triggered this event. This action should be done once, by the master tree.
72
93
  if ((this.masterTree && !this.multiSelection) ||
@@ -78,7 +99,24 @@ const GxgTree = class {
78
99
  });
79
100
  }
80
101
  }
102
+ const itemData = e.detail;
103
+ if (this.masterTree) {
104
+ this.emitTreeItemNewState(itemData, "selectionChanged");
105
+ }
81
106
  }
107
+ checkboxToggledHandler(e) {
108
+ const itemData = e.detail;
109
+ if (this.masterTree) {
110
+ this.emitTreeItemNewState(itemData, "checkboxToggled");
111
+ }
112
+ }
113
+ toggleIconClickedHandler(e) {
114
+ const itemData = e.detail;
115
+ if (this.masterTree) {
116
+ this.emitTreeItemNewState(itemData, "toggleIconClicked");
117
+ }
118
+ }
119
+ // 8.PUBLIC METHODS API //
82
120
  /**
83
121
  * Returns an array of the selected tree-items, providing the id, checked status, selected status, and label.
84
122
  */
@@ -162,6 +200,7 @@ const GxgTree = class {
162
200
  });
163
201
  return toggledTreeItems;
164
202
  }
203
+ // 10.RENDER() FUNCTION //
165
204
  render() {
166
205
  return (index.h(index.Host, null, index.h("div", { class: {
167
206
  tree: true,
@@ -171,7 +210,7 @@ const GxgTree = class {
171
210
  };
172
211
  GxgTree.style = gxgTreeCss;
173
212
 
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}";
213
+ 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
214
 
176
215
  const GxgTreeItem = class {
177
216
  constructor(hostRef) {
@@ -180,12 +219,29 @@ const GxgTreeItem = class {
180
219
  this.selectionChanged = index.createEvent(this, "selectionChanged", 7);
181
220
  this.doubleClicked = index.createEvent(this, "doubleClicked", 7);
182
221
  this.checkboxToggled = index.createEvent(this, "checkboxToggled", 7);
222
+ this.lazyChanged = index.createEvent(this, "lazyChanged", 7);
223
+ this.lazy = false; //True if not leaf but no children.
224
+ this.parentTreeIsMasterTree = false;
225
+ this.numberOfParentTrees = 1;
226
+ this.firstItem = false;
227
+ this.lastItem = false;
228
+ this.leftPadding = "0px";
229
+ this.verticalLineStartPosition = "0px";
230
+ this.horizontalLineWidth = "24px";
231
+ this.horizontalLineStartPosition = "0px";
183
232
  this.parts = {
184
233
  item: "item",
185
234
  checkbox: "checkbox",
186
235
  toggleButton: "toggle-button",
187
236
  };
188
- //PROPS
237
+ // 3.STATE() VARIABLES //
238
+ this.horizontalLinePaddingLeft = 0;
239
+ this.lastTreeItem = false;
240
+ this.lastTreeItemOfParentTree = false;
241
+ this.numberOfVisibleDescendantItems = 0;
242
+ this.time = 0;
243
+ this.downloading = false;
244
+ // 4.PUBLIC PROPERTY API | WATCH'S //
189
245
  /**
190
246
  * 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
247
  */
@@ -218,24 +274,15 @@ const GxgTreeItem = class {
218
274
  * This property is for internal use, when using the treeModel.
219
275
  */
220
276
  this.numberOfChildren = 0;
277
+ /**
278
+ * This property is for internal use. It indicates that the item has children.
279
+ */
221
280
  this.hasChildTree = false;
281
+ /**
282
+ * This property is for internal use. It indicates that the checkbox has an indeterminate state.
283
+ */
222
284
  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";
285
+ // 9.LOCAL METHODS //
239
286
  this.evaluateId = () => {
240
287
  if (!this.id) {
241
288
  this.id = this.el.getAttribute("id");
@@ -259,31 +306,6 @@ const GxgTreeItem = class {
259
306
  this.initiateMutationObserver = () => {
260
307
  this.observer.observe(this.el, { childList: true, subtree: true });
261
308
  };
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
309
  /**
288
310
  * @description Set some properties based on the parent tree configuration, unless this item has this properties already set.
289
311
  */
@@ -348,296 +370,375 @@ const GxgTreeItem = class {
348
370
  this.leftPadding = `${value}px`;
349
371
  this.horizontalLineStartPosition = `${horizontalLineStartPosition}px`;
350
372
  };
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,
373
+ this.liTextClickedHandler = (e) => {
374
+ const toggleWasClicked = e.target.classList.contains("toggle-icon");
375
+ const checkboxClicked = e.target.nodeName === "GXG-FORM-CHECKBOX";
376
+ if (toggleWasClicked || checkboxClicked)
377
+ return;
378
+ if (e.ctrlKey || !this.selected) {
379
+ this.selectionChanged.emit({
380
+ id: this.id,
381
+ label: this.label,
360
382
  checked: this.checked,
361
- selected: this.selected,
383
+ selected: !this.selected,
384
+ ctrlKey: e.ctrlKey,
362
385
  });
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
+ if (e.ctrlKey) {
388
+ this.selected = !this.selected;
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({
390
+ else if (!this.selected) {
391
+ this.selected = true;
392
+ }
393
+ };
394
+ this.liTextDoubleClicked = () => {
395
+ this.doubleClicked.emit({
432
396
  id: this.id,
433
- label: this.label,
434
- checked: this.checked,
435
- selected: !this.selected,
436
- ctrlKey: e.ctrlKey,
437
397
  });
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;
398
+ !this.leaf && this.toggleClickedHandler();
399
+ };
400
+ this.liTextKeyDownPressed = (e) => {
401
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
402
+ e.preventDefault(); //prevents scrolling
466
403
  }
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();
404
+ //ENTER
405
+ if (e.key === "Enter") {
406
+ //Enter should check/uncheck the checkbox (if present)
407
+ this.checkboxClickedHandler();
472
408
  }
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();
409
+ //LEFT/RIGHT NAVIGATION
410
+ if (e.key === "ArrowRight" && !this.leaf) {
411
+ //Toggle the tree
412
+ if (!this.opened) {
413
+ this.opened = true;
414
+ }
415
+ else {
416
+ const childTree = this.el.querySelector("gxg-tree");
417
+ const childTreeFirstChildren = childTree.querySelector("gxg-tree-item");
418
+ const childTreeFirstChildrenLiText = childTreeFirstChildren.shadowRoot.querySelector(".li-text");
419
+ childTreeFirstChildrenLiText.focus();
486
420
  }
487
421
  }
488
- else {
489
- const li = this.el.shadowRoot.querySelector("li");
490
- if (li.classList.contains("tree-open")) {
491
- this.opened = false;
422
+ if (e.key === "ArrowLeft") {
423
+ let hasParent = false;
424
+ const parentGxgTreeItem = this.el.parentElement.parentElement;
425
+ let parentGxgTreeItemLiText = null;
426
+ if (parentGxgTreeItem.tagName === "GXG-TREE-ITEM") {
427
+ hasParent = true;
428
+ parentGxgTreeItemLiText = parentGxgTreeItem.shadowRoot.querySelector(".li-text");
492
429
  }
493
- else {
430
+ if (this.leaf) {
494
431
  if (hasParent) {
495
432
  parentGxgTreeItemLiText.focus();
496
433
  }
497
434
  }
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
435
  else {
516
- if (prevElementSibling === null) {
517
- const parentItem = this.el.parentElement;
518
- const parentParentItem = parentItem.parentElement;
519
- prevItem = parentParentItem.shadowRoot.querySelector("li .li-text");
436
+ const li = this.el.shadowRoot.querySelector("li");
437
+ if (li.classList.contains("tree-open")) {
438
+ this.opened = false;
520
439
  }
521
440
  else {
522
- prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
441
+ if (hasParent) {
442
+ parentGxgTreeItemLiText.focus();
443
+ }
444
+ }
445
+ }
446
+ }
447
+ // UP/DOWN NAVIGATION
448
+ if (e.key === "ArrowUp" || (e.key === "Tab" && e.shiftKey)) {
449
+ e.preventDefault();
450
+ if (!this.firstItem) {
451
+ //Is not the first element of the parent
452
+ //Set focus on the prev item
453
+ let prevItem;
454
+ const prevElementSibling = this.el.previousElementSibling;
455
+ if (e.shiftKey && e.key !== "Tab") {
456
+ //if shift key was pressed, navigate to the previous sibling
523
457
  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");
458
+ prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
459
+ }
460
+ }
461
+ else {
462
+ if (prevElementSibling === null) {
463
+ const parentItem = this.el.parentElement;
464
+ const parentParentItem = parentItem.parentElement;
465
+ prevItem = parentParentItem.shadowRoot.querySelector("li .li-text");
466
+ }
467
+ else {
468
+ prevItem = prevElementSibling.shadowRoot.querySelector("li .li-text");
469
+ if (prevElementSibling !== null) {
470
+ //If the preceding tree-item has tree inside...
471
+ const prevElementSiblingHasChildTree = prevElementSibling
472
+ .hasChildTree;
473
+ if (prevElementSiblingHasChildTree) {
474
+ const prevElementSiblingHasOpenTree = prevElementSibling
475
+ .opened;
476
+ if (prevElementSiblingHasOpenTree) {
477
+ //If preceding tree-item tree is opened, then the prev item is the last item of that tree
478
+ const prevElemSiblingTreeItem = this.el
479
+ .previousElementSibling;
480
+ const prevElemSiblingTreeItemTree = prevElemSiblingTreeItem.querySelector("gxg-tree");
481
+ //
482
+ if (prevElemSiblingTreeItemTree.lastElementChild
483
+ .hasChildTree) {
484
+ if (prevElemSiblingTreeItemTree.lastElementChild.shadowRoot
485
+ .querySelector("li")
486
+ .classList.contains("tree-open")) {
487
+ prevItem = prevElemSiblingTreeItemTree.lastElementChild
488
+ .querySelector("gxg-tree")
489
+ .lastElementChild.shadowRoot.querySelector("li .li-text");
490
+ }
491
+ else {
492
+ prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
493
+ }
544
494
  }
545
495
  else {
546
496
  prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
547
497
  }
498
+ //
548
499
  }
549
500
  else {
550
- prevItem = prevElemSiblingTreeItemTree.lastElementChild.shadowRoot.querySelector("li .li-text");
501
+ //The preciding item has a tree, but it is closed
502
+ prevItem = this.el.previousElementSibling.shadowRoot.querySelector("li .li-text");
551
503
  }
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
504
  }
558
505
  }
559
506
  }
560
507
  }
561
- }
562
- if (prevItem !== null && prevItem !== undefined) {
563
- prevItem.focus();
508
+ if (prevItem !== null && prevItem !== undefined) {
509
+ prevItem.focus();
510
+ }
564
511
  }
565
512
  }
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");
513
+ if (e.key === "ArrowDown" || (e.key === "Tab" && !e.shiftKey)) {
514
+ e.preventDefault();
515
+ if (!this.lastTreeItemOfParentTree) {
516
+ //Set focus on the next item
517
+ let nextItem;
518
+ if (e.shiftKey) {
519
+ //if shift key was pressed, navigate to the next sibling
520
+ if (this.el.nextElementSibling !== null) {
521
+ nextItem = this.el.nextElementSibling.shadowRoot.querySelector("li .li-text");
522
+ }
576
523
  }
577
- }
578
- else {
579
- if (this.lastTreeItem) {
580
- if (this.hasChildTree && this.opened) {
581
- nextItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector(".li-text");
524
+ else {
525
+ if (this.lastTreeItem) {
526
+ if (this.hasChildTree && this.opened) {
527
+ nextItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector(".li-text");
528
+ }
529
+ else {
530
+ const thisTree = this.el.parentElement;
531
+ const thisTreeParent = thisTree.parentElement;
532
+ const thisTreeParentNextTree = thisTreeParent.nextElementSibling;
533
+ if (thisTreeParentNextTree === null) {
534
+ if (thisTreeParent.parentElement.parentElement
535
+ .nextElementSibling !== null) {
536
+ nextItem = thisTreeParent.parentElement.parentElement.nextElementSibling.shadowRoot.querySelector(".li-text");
537
+ }
538
+ }
539
+ else {
540
+ nextItem = thisTreeParentNextTree.shadowRoot.querySelector(".li-text");
541
+ }
542
+ }
582
543
  }
583
544
  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
- }
545
+ if (this.hasChildTree && this.opened) {
546
+ nextItem = this.el
547
+ .querySelector("gxg-tree gxg-tree-item")
548
+ .shadowRoot.querySelector("li .li-text");
592
549
  }
593
550
  else {
594
- nextItem = thisTreeParentNextTree.shadowRoot.querySelector(".li-text");
551
+ nextItem = this.el.nextElementSibling.shadowRoot.querySelector(".li-text");
595
552
  }
596
553
  }
597
554
  }
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
- }
555
+ if (nextItem !== null && nextItem !== undefined) {
556
+ nextItem.focus();
607
557
  }
608
558
  }
609
- if (nextItem !== null && nextItem !== undefined) {
610
- nextItem.focus();
559
+ else {
560
+ //Last element of parent tree
561
+ if (!this.leaf && this.opened) {
562
+ const childTreeFirstTreeItem = this.el.firstElementChild.firstElementChild.shadowRoot.querySelector("li .li-text");
563
+ childTreeFirstTreeItem.focus();
564
+ }
611
565
  }
612
566
  }
567
+ };
568
+ this.returnToggleIconType = () => {
569
+ //Returns the type of icon : expand or collapse
570
+ if (!this.opened || this.lazy) {
571
+ return "gemini-tools/add";
572
+ }
613
573
  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();
574
+ return "gemini-tools/minus";
575
+ }
576
+ };
577
+ /**
578
+ * When a checkbox is clicked, it state changes and so it's children, and parent items do.
579
+ * First evaluate the children, and then the parent items.
580
+ */
581
+ this.checkboxClickedHandler = () => {
582
+ if (this.checkbox) {
583
+ this.checked = !this.checked;
584
+ if (!this.leaf) {
585
+ this.toggleChildrenCheckboxes(this.checked);
618
586
  }
587
+ const parentItems = this.getParentItems();
588
+ parentItems.forEach((parentItem) => {
589
+ parentItem.evaluateCheckboxStatus();
590
+ });
619
591
  }
592
+ };
593
+ this.toggleChildrenCheckboxes = (checked) => {
594
+ this.indeterminate = false;
595
+ const allChildren = this.el.querySelectorAll("gxg-tree-item");
596
+ if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
597
+ Array.from(allChildren).forEach((item) => {
598
+ item.indeterminate = false;
599
+ item.checked = checked;
600
+ });
601
+ }
602
+ };
603
+ this.getParentItems = () => {
604
+ var _a;
605
+ const parentItems = [];
606
+ let parentItem = this.el.parentElement.parentElement;
607
+ while ((parentItem === null || parentItem === void 0 ? void 0 : parentItem.nodeName) === "GXG-TREE-ITEM") {
608
+ parentItems.push(parentItem);
609
+ parentItem = (_a = parentItem.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
610
+ }
611
+ return parentItems;
612
+ };
613
+ this.getParentsNumber = () => {
614
+ var _a;
615
+ let count = 0;
616
+ let parentElement = this.el.parentElement;
617
+ while ((parentElement === null || parentElement === void 0 ? void 0 : parentElement.nodeName) === "GXG-TREE") {
618
+ count++;
619
+ parentElement = (_a = parentElement.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
620
+ }
621
+ return count;
622
+ };
623
+ this.getChildrenNumber = () => {
624
+ if (this.numberOfChildren === 0) {
625
+ //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.
626
+ return this.el.querySelectorAll("gxg-tree-item").length;
627
+ }
628
+ };
629
+ this.toggleClickedHandler = () => {
630
+ if (this.lazy && !this.opened) {
631
+ this.downloading = true;
632
+ this.toggleIconClicked.emit({
633
+ checked: this.checked,
634
+ description: this.description,
635
+ icon: this.icon,
636
+ id: this.id,
637
+ indeterminate: this.indeterminate,
638
+ label: this.label,
639
+ lazy: this.lazy,
640
+ leaf: this.leaf,
641
+ opened: this.opened,
642
+ selected: this.selected,
643
+ });
644
+ }
645
+ if (!this.lazy) {
646
+ this.opened = !this.opened;
647
+ }
648
+ };
649
+ }
650
+ checkedHandler(newValue, oldValue) {
651
+ if (oldValue !== undefined) {
652
+ this.checkboxToggled.emit({
653
+ checked: newValue,
654
+ description: this.description,
655
+ icon: this.icon,
656
+ id: this.id,
657
+ indeterminate: this.indeterminate,
658
+ label: this.label,
659
+ lazy: this.lazy,
660
+ leaf: this.leaf,
661
+ opened: this.opened,
662
+ selected: this.selected,
663
+ });
620
664
  }
621
665
  }
622
- returnToggleIconType() {
623
- //Returns the type of icon : expand or collapse
624
- if (!this.opened || this.lazy) {
625
- return "gemini-tools/add";
666
+ openedHandler(newValue, oldValue) {
667
+ if (oldValue !== undefined) {
668
+ this.toggleIconClicked.emit({
669
+ checked: this.checked,
670
+ description: this.description,
671
+ icon: this.icon,
672
+ id: this.id,
673
+ indeterminate: this.indeterminate,
674
+ label: this.label,
675
+ lazy: this.lazy,
676
+ leaf: this.leaf,
677
+ opened: newValue,
678
+ selected: this.selected,
679
+ });
626
680
  }
627
- else {
628
- return "gemini-tools/minus";
681
+ }
682
+ // 6.COMPONENT LIFECYCLE METHODS //
683
+ componentWillLoad() {
684
+ //Count number of parent trees in order to set the appropriate padding-left
685
+ this.numberOfParentTrees = this.getParentsNumber();
686
+ this.numberOfChildren = this.getChildrenNumber();
687
+ //If is last item of tree
688
+ const nextItem = this.el.nextElementSibling;
689
+ if (nextItem === null) {
690
+ this.lastTreeItem = true;
629
691
  }
692
+ if (this.numberOfParentTrees === 1) {
693
+ this.parentTreeIsMasterTree = true;
694
+ const prevItem = this.el.previousElementSibling;
695
+ if (prevItem === null) {
696
+ //If is first item of parent tree...
697
+ this.firstItem = true;
698
+ }
699
+ }
700
+ if (!this.el.nextElementSibling) {
701
+ this.lastItem = true;
702
+ }
703
+ this.evaluateId();
704
+ this.evaluateLazy();
705
+ this.defineLineHeight();
706
+ this.defineStartPosition();
707
+ this.cascadeConfig();
708
+ this.attachExportParts();
709
+ this.initiateMutationObserver();
630
710
  }
631
- toggleChildrenCheckboxes(checked) {
632
- this.indeterminate = false;
711
+ // 7.LISTENERS //
712
+ // 8.PUBLIC METHODS API //
713
+ async reRender() {
714
+ this.defineLineHeight();
715
+ }
716
+ evaluateCheckboxStatus() {
633
717
  const allChildren = this.el.querySelectorAll("gxg-tree-item");
718
+ let checked = 0;
634
719
  if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
635
720
  Array.from(allChildren).forEach((item) => {
636
- item.indeterminate = false;
637
- item.checked = checked;
721
+ if (item.checked) {
722
+ checked++;
723
+ }
638
724
  });
725
+ if (allChildren.length === checked) {
726
+ //all checked
727
+ this.checked = true;
728
+ this.indeterminate = false;
729
+ }
730
+ else if (checked === 0) {
731
+ //all unchecked
732
+ this.checked = false;
733
+ this.indeterminate = false;
734
+ }
735
+ else {
736
+ //indeterminate
737
+ this.indeterminate = true;
738
+ }
639
739
  }
640
740
  }
741
+ // 10.RENDER() FUNCTION //
641
742
  render() {
642
743
  return (index.h(index.Host, { class: { leaf: this.leaf, "not-leaf": !this.leaf }, exportParts: this.exportparts ? this.exportparts : null }, index.h("li", { class: {
643
744
  "tree-open": this.opened,
@@ -669,6 +770,10 @@ const GxgTreeItem = class {
669
770
  }
670
771
  static get assetsDirs() { return ["tree-item-assets"]; }
671
772
  get el() { return index.getElement(this); }
773
+ static get watchers() { return {
774
+ "checked": ["checkedHandler"],
775
+ "opened": ["openedHandler"]
776
+ }; }
672
777
  };
673
778
  GxgTreeItem.style = gxgTreeItemCss;
674
779