reneco-hierarchized-picker 0.5.2 → 0.5.4-beta.1

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.
@@ -298,6 +298,13 @@ Tree.prototype.bindEvent = function (ele) {
298
298
  if (!this.options.parentApi.isDisabled) {
299
299
  const contextMenu = this.options.parentApi.theOptions.contextMenu;
300
300
  if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
301
+ ele.addEventListener('contextmenu', async (e) => {
302
+ if (this.options.parentApi.theOptions.multiple) {
303
+ e.preventDefault();
304
+ e.stopImmediatePropagation();
305
+ return false;
306
+ }
307
+ });
301
308
  new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
302
309
  return typeof item === 'string'
303
310
  ? item
@@ -18467,6 +18474,9 @@ function normalizeStr(str) {
18467
18474
  */
18468
18475
  function fillTreeWithObject(tree, myObject, searched, options) {
18469
18476
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18477
+ if (myObject && myObject.children) {
18478
+ myObject = [myObject];
18479
+ }
18470
18480
  if (myObject && myObject.length) {
18471
18481
  myObject.forEach(value => {
18472
18482
  var _a, _b, _c, _d;
@@ -19539,7 +19549,7 @@ const HierarchizedPickerComponent = class {
19539
19549
  if (searched) {
19540
19550
  this.setSearchResults(treeToDisplay);
19541
19551
  }
19542
- this.displayTree(treeToDisplay, searched != null);
19552
+ this.displayTree(treeToDisplay);
19543
19553
  }
19544
19554
  deactivateNodesOutOfDepthSettings() {
19545
19555
  if (this.optionsManager.getOptions().maxDepth != undefined || this.optionsManager.getOptions().minDepth != undefined) {
@@ -19559,12 +19569,16 @@ const HierarchizedPickerComponent = class {
19559
19569
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19560
19570
  return;
19561
19571
  }
19572
+ if (!this.loadedTreeJs || forceTreeReset) {
19573
+ const dataManagerData = this.rawDataManager.getData();
19574
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19575
+ }
19562
19576
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19563
19577
  const myTree = new Tree('#tree-area-' + this.componentID, {
19564
19578
  parentApi: this,
19565
19579
  rawDataManager: this.rawDataManager,
19566
19580
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19567
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19581
+ data: treeData,
19568
19582
  onChange: async () => {
19569
19583
  let oldValue;
19570
19584
  try {
@@ -802,7 +802,7 @@ export class HierarchizedPickerComponent {
802
802
  if (searched) {
803
803
  this.setSearchResults(treeToDisplay);
804
804
  }
805
- this.displayTree(treeToDisplay, searched != null);
805
+ this.displayTree(treeToDisplay);
806
806
  }
807
807
  deactivateNodesOutOfDepthSettings() {
808
808
  if (this.optionsManager.getOptions().maxDepth != undefined || this.optionsManager.getOptions().minDepth != undefined) {
@@ -822,12 +822,16 @@ export class HierarchizedPickerComponent {
822
822
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
823
823
  return;
824
824
  }
825
+ if (!this.loadedTreeJs || forceTreeReset) {
826
+ const dataManagerData = this.rawDataManager.getData();
827
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
828
+ }
825
829
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
826
830
  const myTree = new Tree('#tree-area-' + this.componentID, {
827
831
  parentApi: this,
828
832
  rawDataManager: this.rawDataManager,
829
833
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
830
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
834
+ data: treeData,
831
835
  onChange: async () => {
832
836
  let oldValue;
833
837
  try {
@@ -147,14 +147,6 @@ Tree.prototype.buildTree = function (nodes, depth) {
147
147
  };
148
148
  Tree.prototype.bindEvent = function (ele) {
149
149
  var _a;
150
- // const that = this;
151
- // let parentOptions:any = {};
152
- // try{
153
- // parentOptions = JSON.parse(this.options.parentApi.theOptions);
154
- // }
155
- // catch {
156
- // parentOptions = this.options.parentApi.theOptions;
157
- // }
158
150
  // @ts-ignore
159
151
  function getLi(target) {
160
152
  return target.classList.contains('treejs-node') ? target : target.closest('.treejs-node');
@@ -162,6 +154,13 @@ Tree.prototype.bindEvent = function (ele) {
162
154
  if (!this.options.parentApi.isDisabled) {
163
155
  const contextMenu = this.options.parentApi.theOptions.contextMenu;
164
156
  if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
157
+ ele.addEventListener('contextmenu', async (e) => {
158
+ if (this.options.parentApi.theOptions.multiple) {
159
+ e.preventDefault();
160
+ e.stopImmediatePropagation();
161
+ return false;
162
+ }
163
+ });
165
164
  new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
166
165
  return typeof item === 'string'
167
166
  ? item
@@ -52,6 +52,9 @@ function normalizeStr(str) {
52
52
  */
53
53
  export function fillTreeWithObject(tree, myObject, searched, options) {
54
54
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
55
+ if (myObject && myObject.children) {
56
+ myObject = [myObject];
57
+ }
55
58
  if (myObject && myObject.length) {
56
59
  myObject.forEach(value => {
57
60
  var _a, _b, _c, _d;
@@ -295,6 +295,13 @@ Tree.prototype.bindEvent = function (ele) {
295
295
  if (!this.options.parentApi.isDisabled) {
296
296
  const contextMenu = this.options.parentApi.theOptions.contextMenu;
297
297
  if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
298
+ ele.addEventListener('contextmenu', async (e) => {
299
+ if (this.options.parentApi.theOptions.multiple) {
300
+ e.preventDefault();
301
+ e.stopImmediatePropagation();
302
+ return false;
303
+ }
304
+ });
298
305
  new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
299
306
  return typeof item === 'string'
300
307
  ? item
@@ -18464,6 +18471,9 @@ function normalizeStr(str) {
18464
18471
  */
18465
18472
  function fillTreeWithObject(tree, myObject, searched, options) {
18466
18473
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18474
+ if (myObject && myObject.children) {
18475
+ myObject = [myObject];
18476
+ }
18467
18477
  if (myObject && myObject.length) {
18468
18478
  myObject.forEach(value => {
18469
18479
  var _a, _b, _c, _d;
@@ -19537,7 +19547,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19537
19547
  if (searched) {
19538
19548
  this.setSearchResults(treeToDisplay);
19539
19549
  }
19540
- this.displayTree(treeToDisplay, searched != null);
19550
+ this.displayTree(treeToDisplay);
19541
19551
  }
19542
19552
  deactivateNodesOutOfDepthSettings() {
19543
19553
  if (this.optionsManager.getOptions().maxDepth != undefined || this.optionsManager.getOptions().minDepth != undefined) {
@@ -19557,12 +19567,16 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19557
19567
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19558
19568
  return;
19559
19569
  }
19570
+ if (!this.loadedTreeJs || forceTreeReset) {
19571
+ const dataManagerData = this.rawDataManager.getData();
19572
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19573
+ }
19560
19574
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19561
19575
  const myTree = new Tree('#tree-area-' + this.componentID, {
19562
19576
  parentApi: this,
19563
19577
  rawDataManager: this.rawDataManager,
19564
19578
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19565
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19579
+ data: treeData,
19566
19580
  onChange: async () => {
19567
19581
  let oldValue;
19568
19582
  try {
@@ -294,6 +294,13 @@ Tree.prototype.bindEvent = function (ele) {
294
294
  if (!this.options.parentApi.isDisabled) {
295
295
  const contextMenu = this.options.parentApi.theOptions.contextMenu;
296
296
  if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
297
+ ele.addEventListener('contextmenu', async (e) => {
298
+ if (this.options.parentApi.theOptions.multiple) {
299
+ e.preventDefault();
300
+ e.stopImmediatePropagation();
301
+ return false;
302
+ }
303
+ });
297
304
  new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
298
305
  return typeof item === 'string'
299
306
  ? item
@@ -18463,6 +18470,9 @@ function normalizeStr(str) {
18463
18470
  */
18464
18471
  function fillTreeWithObject(tree, myObject, searched, options) {
18465
18472
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18473
+ if (myObject && myObject.children) {
18474
+ myObject = [myObject];
18475
+ }
18466
18476
  if (myObject && myObject.length) {
18467
18477
  myObject.forEach(value => {
18468
18478
  var _a, _b, _c, _d;
@@ -19535,7 +19545,7 @@ const HierarchizedPickerComponent = class {
19535
19545
  if (searched) {
19536
19546
  this.setSearchResults(treeToDisplay);
19537
19547
  }
19538
- this.displayTree(treeToDisplay, searched != null);
19548
+ this.displayTree(treeToDisplay);
19539
19549
  }
19540
19550
  deactivateNodesOutOfDepthSettings() {
19541
19551
  if (this.optionsManager.getOptions().maxDepth != undefined || this.optionsManager.getOptions().minDepth != undefined) {
@@ -19555,12 +19565,16 @@ const HierarchizedPickerComponent = class {
19555
19565
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19556
19566
  return;
19557
19567
  }
19568
+ if (!this.loadedTreeJs || forceTreeReset) {
19569
+ const dataManagerData = this.rawDataManager.getData();
19570
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19571
+ }
19558
19572
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19559
19573
  const myTree = new Tree('#tree-area-' + this.componentID, {
19560
19574
  parentApi: this,
19561
19575
  rawDataManager: this.rawDataManager,
19562
19576
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19563
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19577
+ data: treeData,
19564
19578
  onChange: async () => {
19565
19579
  let oldValue;
19566
19580
  try {