reneco-hierarchized-picker 0.4.3-beta.20 → 0.4.3-beta.21

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.
@@ -328,7 +328,6 @@ Tree.prototype.bindEvent = function (ele) {
328
328
  };
329
329
  Tree.prototype.onItemClick = async function (id, rightclick = false) {
330
330
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
331
- console.log("coucou");
332
331
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
333
332
  return;
334
333
  const pickerValue = await this.options.parentApi.getValue();
@@ -18623,28 +18622,20 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
18623
18622
  if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
18624
18623
  focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
18625
18624
  }
18626
- //todo, put back ?
18627
- // if ((component.el as any)._hasKeydownListener) {
18628
- // return;
18629
- // }
18630
18625
  component.el._hasKeydownListener = true;
18631
18626
  if (!component._keydownListenerAdded) {
18632
18627
  component._keydownListenerAdded = true;
18633
18628
  component.el.addEventListener('keydown', (event) => {
18634
18629
  var _a, _b;
18635
- console.log("Navigation 01", event);
18636
18630
  event.stopPropagation();
18637
- console.log("Navigation 02");
18638
18631
  const tree = component.loadedTreeJs;
18639
18632
  let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
18640
- console.log("Navigation 03");
18641
18633
  if (!tree || !treeNodesFromTree.length)
18642
18634
  return;
18643
18635
  let spaceNode = treeNodesFromTree[focusedNodeIndex];
18644
18636
  let activeNode = treeNodesFromTree[focusedNodeIndex];
18645
18637
  let liElement = tree.liElementsById[activeNode.id];
18646
18638
  const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
18647
- console.log("Navigation 04", event.key);
18648
18639
  switch (event.key.toLowerCase()) {
18649
18640
  case 'tab':
18650
18641
  case '0':
@@ -18836,15 +18827,39 @@ const HierarchizedPickerComponent = class {
18836
18827
  const val1 = obj1[key];
18837
18828
  const val2 = obj2[key];
18838
18829
  if (Array.isArray(val1) && Array.isArray(val2)) {
18839
- if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
18830
+ // Compare array length
18831
+ if (val1.length !== val2.length) {
18840
18832
  diffs.push(fullKey);
18833
+ continue;
18834
+ }
18835
+ // Compare each element deeply
18836
+ for (let i = 0; i < val1.length; i++) {
18837
+ const v1 = val1[i];
18838
+ const v2 = val2[i];
18839
+ if (typeof v1 === 'object' &&
18840
+ v1 !== null &&
18841
+ typeof v2 === 'object' &&
18842
+ v2 !== null) {
18843
+ const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
18844
+ if (subDiffs.length > 0) {
18845
+ diffs.push(fullKey);
18846
+ break; // stop at first mismatch in array
18847
+ }
18848
+ }
18849
+ else if (v1 !== v2) {
18850
+ diffs.push(fullKey);
18851
+ break;
18852
+ }
18841
18853
  }
18842
18854
  }
18843
18855
  else if (val1 &&
18844
18856
  val2 &&
18845
18857
  typeof val1 === 'object' &&
18846
18858
  typeof val2 === 'object') {
18847
- diffs.push(...this.diffKeys(val1, val2, fullKey));
18859
+ // Recursive deep object comparison
18860
+ const subDiffs = this.diffKeys(val1, val2, fullKey);
18861
+ if (subDiffs.length > 0)
18862
+ diffs.push(...subDiffs);
18848
18863
  }
18849
18864
  else if (val1 !== val2) {
18850
18865
  diffs.push(fullKey);
@@ -18906,9 +18921,10 @@ const HierarchizedPickerComponent = class {
18906
18921
  console.log("Setnewoptions 02");
18907
18922
  const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
18908
18923
  const noReloadProps = ["multiple"];
18909
- console.log("Setnewoptions 03", propDiffs);
18910
- if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
18911
- const propChanged = propDiffs[0];
18924
+ const ignoredProps = ["token"];
18925
+ const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
18926
+ if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
18927
+ const propChanged = filteredDiffs[0];
18912
18928
  switch (propChanged) {
18913
18929
  case "multiple":
18914
18930
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
@@ -98,15 +98,39 @@ export class HierarchizedPickerComponent {
98
98
  const val1 = obj1[key];
99
99
  const val2 = obj2[key];
100
100
  if (Array.isArray(val1) && Array.isArray(val2)) {
101
- if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
101
+ // Compare array length
102
+ if (val1.length !== val2.length) {
102
103
  diffs.push(fullKey);
104
+ continue;
105
+ }
106
+ // Compare each element deeply
107
+ for (let i = 0; i < val1.length; i++) {
108
+ const v1 = val1[i];
109
+ const v2 = val2[i];
110
+ if (typeof v1 === 'object' &&
111
+ v1 !== null &&
112
+ typeof v2 === 'object' &&
113
+ v2 !== null) {
114
+ const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
115
+ if (subDiffs.length > 0) {
116
+ diffs.push(fullKey);
117
+ break; // stop at first mismatch in array
118
+ }
119
+ }
120
+ else if (v1 !== v2) {
121
+ diffs.push(fullKey);
122
+ break;
123
+ }
103
124
  }
104
125
  }
105
126
  else if (val1 &&
106
127
  val2 &&
107
128
  typeof val1 === 'object' &&
108
129
  typeof val2 === 'object') {
109
- diffs.push(...this.diffKeys(val1, val2, fullKey));
130
+ // Recursive deep object comparison
131
+ const subDiffs = this.diffKeys(val1, val2, fullKey);
132
+ if (subDiffs.length > 0)
133
+ diffs.push(...subDiffs);
110
134
  }
111
135
  else if (val1 !== val2) {
112
136
  diffs.push(fullKey);
@@ -168,9 +192,10 @@ export class HierarchizedPickerComponent {
168
192
  console.log("Setnewoptions 02");
169
193
  const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
170
194
  const noReloadProps = ["multiple"];
171
- console.log("Setnewoptions 03", propDiffs);
172
- if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
173
- const propChanged = propDiffs[0];
195
+ const ignoredProps = ["token"];
196
+ const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
197
+ if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
198
+ const propChanged = filteredDiffs[0];
174
199
  switch (propChanged) {
175
200
  case "multiple":
176
201
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
@@ -192,7 +192,6 @@ Tree.prototype.bindEvent = function (ele) {
192
192
  };
193
193
  Tree.prototype.onItemClick = async function (id, rightclick = false) {
194
194
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
195
- console.log("coucou");
196
195
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
197
196
  return;
198
197
  const pickerValue = await this.options.parentApi.getValue();
@@ -29,28 +29,20 @@ export function setupKeyboardNavigation(component, optionsManager, navigateInTre
29
29
  if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
30
30
  focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
31
31
  }
32
- //todo, put back ?
33
- // if ((component.el as any)._hasKeydownListener) {
34
- // return;
35
- // }
36
32
  component.el._hasKeydownListener = true;
37
33
  if (!component._keydownListenerAdded) {
38
34
  component._keydownListenerAdded = true;
39
35
  component.el.addEventListener('keydown', (event) => {
40
36
  var _a, _b;
41
- console.log("Navigation 01", event);
42
37
  event.stopPropagation();
43
- console.log("Navigation 02");
44
38
  const tree = component.loadedTreeJs;
45
39
  let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
46
- console.log("Navigation 03");
47
40
  if (!tree || !treeNodesFromTree.length)
48
41
  return;
49
42
  let spaceNode = treeNodesFromTree[focusedNodeIndex];
50
43
  let activeNode = treeNodesFromTree[focusedNodeIndex];
51
44
  let liElement = tree.liElementsById[activeNode.id];
52
45
  const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
53
- console.log("Navigation 04", event.key);
54
46
  switch (event.key.toLowerCase()) {
55
47
  case 'tab':
56
48
  case '0':
@@ -325,7 +325,6 @@ Tree.prototype.bindEvent = function (ele) {
325
325
  };
326
326
  Tree.prototype.onItemClick = async function (id, rightclick = false) {
327
327
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
328
- console.log("coucou");
329
328
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
330
329
  return;
331
330
  const pickerValue = await this.options.parentApi.getValue();
@@ -18620,28 +18619,20 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
18620
18619
  if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
18621
18620
  focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
18622
18621
  }
18623
- //todo, put back ?
18624
- // if ((component.el as any)._hasKeydownListener) {
18625
- // return;
18626
- // }
18627
18622
  component.el._hasKeydownListener = true;
18628
18623
  if (!component._keydownListenerAdded) {
18629
18624
  component._keydownListenerAdded = true;
18630
18625
  component.el.addEventListener('keydown', (event) => {
18631
18626
  var _a, _b;
18632
- console.log("Navigation 01", event);
18633
18627
  event.stopPropagation();
18634
- console.log("Navigation 02");
18635
18628
  const tree = component.loadedTreeJs;
18636
18629
  let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
18637
- console.log("Navigation 03");
18638
18630
  if (!tree || !treeNodesFromTree.length)
18639
18631
  return;
18640
18632
  let spaceNode = treeNodesFromTree[focusedNodeIndex];
18641
18633
  let activeNode = treeNodesFromTree[focusedNodeIndex];
18642
18634
  let liElement = tree.liElementsById[activeNode.id];
18643
18635
  const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
18644
- console.log("Navigation 04", event.key);
18645
18636
  switch (event.key.toLowerCase()) {
18646
18637
  case 'tab':
18647
18638
  case '0':
@@ -18833,15 +18824,39 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18833
18824
  const val1 = obj1[key];
18834
18825
  const val2 = obj2[key];
18835
18826
  if (Array.isArray(val1) && Array.isArray(val2)) {
18836
- if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
18827
+ // Compare array length
18828
+ if (val1.length !== val2.length) {
18837
18829
  diffs.push(fullKey);
18830
+ continue;
18831
+ }
18832
+ // Compare each element deeply
18833
+ for (let i = 0; i < val1.length; i++) {
18834
+ const v1 = val1[i];
18835
+ const v2 = val2[i];
18836
+ if (typeof v1 === 'object' &&
18837
+ v1 !== null &&
18838
+ typeof v2 === 'object' &&
18839
+ v2 !== null) {
18840
+ const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
18841
+ if (subDiffs.length > 0) {
18842
+ diffs.push(fullKey);
18843
+ break; // stop at first mismatch in array
18844
+ }
18845
+ }
18846
+ else if (v1 !== v2) {
18847
+ diffs.push(fullKey);
18848
+ break;
18849
+ }
18838
18850
  }
18839
18851
  }
18840
18852
  else if (val1 &&
18841
18853
  val2 &&
18842
18854
  typeof val1 === 'object' &&
18843
18855
  typeof val2 === 'object') {
18844
- diffs.push(...this.diffKeys(val1, val2, fullKey));
18856
+ // Recursive deep object comparison
18857
+ const subDiffs = this.diffKeys(val1, val2, fullKey);
18858
+ if (subDiffs.length > 0)
18859
+ diffs.push(...subDiffs);
18845
18860
  }
18846
18861
  else if (val1 !== val2) {
18847
18862
  diffs.push(fullKey);
@@ -18903,9 +18918,10 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18903
18918
  console.log("Setnewoptions 02");
18904
18919
  const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
18905
18920
  const noReloadProps = ["multiple"];
18906
- console.log("Setnewoptions 03", propDiffs);
18907
- if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
18908
- const propChanged = propDiffs[0];
18921
+ const ignoredProps = ["token"];
18922
+ const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
18923
+ if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
18924
+ const propChanged = filteredDiffs[0];
18909
18925
  switch (propChanged) {
18910
18926
  case "multiple":
18911
18927
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
@@ -324,7 +324,6 @@ Tree.prototype.bindEvent = function (ele) {
324
324
  };
325
325
  Tree.prototype.onItemClick = async function (id, rightclick = false) {
326
326
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
327
- console.log("coucou");
328
327
  if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
329
328
  return;
330
329
  const pickerValue = await this.options.parentApi.getValue();
@@ -18619,28 +18618,20 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
18619
18618
  if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
18620
18619
  focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
18621
18620
  }
18622
- //todo, put back ?
18623
- // if ((component.el as any)._hasKeydownListener) {
18624
- // return;
18625
- // }
18626
18621
  component.el._hasKeydownListener = true;
18627
18622
  if (!component._keydownListenerAdded) {
18628
18623
  component._keydownListenerAdded = true;
18629
18624
  component.el.addEventListener('keydown', (event) => {
18630
18625
  var _a, _b;
18631
- console.log("Navigation 01", event);
18632
18626
  event.stopPropagation();
18633
- console.log("Navigation 02");
18634
18627
  const tree = component.loadedTreeJs;
18635
18628
  let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
18636
- console.log("Navigation 03");
18637
18629
  if (!tree || !treeNodesFromTree.length)
18638
18630
  return;
18639
18631
  let spaceNode = treeNodesFromTree[focusedNodeIndex];
18640
18632
  let activeNode = treeNodesFromTree[focusedNodeIndex];
18641
18633
  let liElement = tree.liElementsById[activeNode.id];
18642
18634
  const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
18643
- console.log("Navigation 04", event.key);
18644
18635
  switch (event.key.toLowerCase()) {
18645
18636
  case 'tab':
18646
18637
  case '0':
@@ -18832,15 +18823,39 @@ const HierarchizedPickerComponent = class {
18832
18823
  const val1 = obj1[key];
18833
18824
  const val2 = obj2[key];
18834
18825
  if (Array.isArray(val1) && Array.isArray(val2)) {
18835
- if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
18826
+ // Compare array length
18827
+ if (val1.length !== val2.length) {
18836
18828
  diffs.push(fullKey);
18829
+ continue;
18830
+ }
18831
+ // Compare each element deeply
18832
+ for (let i = 0; i < val1.length; i++) {
18833
+ const v1 = val1[i];
18834
+ const v2 = val2[i];
18835
+ if (typeof v1 === 'object' &&
18836
+ v1 !== null &&
18837
+ typeof v2 === 'object' &&
18838
+ v2 !== null) {
18839
+ const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
18840
+ if (subDiffs.length > 0) {
18841
+ diffs.push(fullKey);
18842
+ break; // stop at first mismatch in array
18843
+ }
18844
+ }
18845
+ else if (v1 !== v2) {
18846
+ diffs.push(fullKey);
18847
+ break;
18848
+ }
18837
18849
  }
18838
18850
  }
18839
18851
  else if (val1 &&
18840
18852
  val2 &&
18841
18853
  typeof val1 === 'object' &&
18842
18854
  typeof val2 === 'object') {
18843
- diffs.push(...this.diffKeys(val1, val2, fullKey));
18855
+ // Recursive deep object comparison
18856
+ const subDiffs = this.diffKeys(val1, val2, fullKey);
18857
+ if (subDiffs.length > 0)
18858
+ diffs.push(...subDiffs);
18844
18859
  }
18845
18860
  else if (val1 !== val2) {
18846
18861
  diffs.push(fullKey);
@@ -18902,9 +18917,10 @@ const HierarchizedPickerComponent = class {
18902
18917
  console.log("Setnewoptions 02");
18903
18918
  const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
18904
18919
  const noReloadProps = ["multiple"];
18905
- console.log("Setnewoptions 03", propDiffs);
18906
- if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
18907
- const propChanged = propDiffs[0];
18920
+ const ignoredProps = ["token"];
18921
+ const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
18922
+ if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
18923
+ const propChanged = filteredDiffs[0];
18908
18924
  switch (propChanged) {
18909
18925
  case "multiple":
18910
18926
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));