reneco-hierarchized-picker 0.5.1 → 0.5.3

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.
@@ -18043,7 +18043,10 @@ function replacer(key, value) {
18043
18043
  }
18044
18044
  function searchValue(obj, strict, searched) {
18045
18045
  let toret = false;
18046
- if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18046
+ function normalize(s) {
18047
+ return s.replace(/\u00A0/g, " ");
18048
+ }
18049
+ if (normalize(obj.text).toLowerCase().indexOf(normalize(searched).toLowerCase()) > -1) {
18047
18050
  toret = true;
18048
18051
  }
18049
18052
  else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
@@ -18331,7 +18334,7 @@ class RawDataManager {
18331
18334
  toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
18332
18335
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
18333
18336
  ? source[childrenKey].map((child, index) => {
18334
- return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
18337
+ return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[0], idKey, childrenKey);
18335
18338
  })
18336
18339
  : toAdd[childrenKey];
18337
18340
  return source;
@@ -18435,6 +18438,9 @@ function getPropertyFromNode(node, property, logerror = true) {
18435
18438
  function findNodeById(tree, nodeId) {
18436
18439
  return tree.nodesById[nodeId] || null;
18437
18440
  }
18441
+ function normalizeStr(str) {
18442
+ return str.replace(/\u00A0/g, " ");
18443
+ }
18438
18444
  // TODO Deprecated ?
18439
18445
  // export function getNodesFromSearch(data: any, searched: string): any[] {
18440
18446
  // let toret: any[] = [];
@@ -18461,6 +18467,9 @@ function findNodeById(tree, nodeId) {
18461
18467
  */
18462
18468
  function fillTreeWithObject(tree, myObject, searched, options) {
18463
18469
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18470
+ if (myObject && myObject.children) {
18471
+ myObject = [myObject];
18472
+ }
18464
18473
  if (myObject && myObject.length) {
18465
18474
  myObject.forEach(value => {
18466
18475
  var _a, _b, _c, _d;
@@ -18491,9 +18500,9 @@ function fillTreeWithObject(tree, myObject, searched, options) {
18491
18500
  const objToPush = {
18492
18501
  id: keyPropFromNode,
18493
18502
  nodeId: keyPropFromNode,
18494
- text: valueTranslatedPropFromNode,
18495
- fullpath: fullpathPropFromNode,
18496
- fullpathTranslated: fullpathTranslatedPropFromNode,
18503
+ text: normalizeStr(valueTranslatedPropFromNode),
18504
+ fullpath: normalizeStr(fullpathPropFromNode),
18505
+ fullpathTranslated: normalizeStr(fullpathTranslatedPropFromNode),
18497
18506
  children: getPropertyFromNode(value, 'hasChildren', false) && childrenPropFromNode && childrenPropFromNode.length === 0 ? [{}] : [],
18498
18507
  deprecated,
18499
18508
  isDesaturated: false,
@@ -19553,12 +19562,16 @@ const HierarchizedPickerComponent = class {
19553
19562
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19554
19563
  return;
19555
19564
  }
19565
+ if (!this.loadedTreeJs || forceTreeReset) {
19566
+ const dataManagerData = this.rawDataManager.getData();
19567
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19568
+ }
19556
19569
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19557
19570
  const myTree = new Tree('#tree-area-' + this.componentID, {
19558
19571
  parentApi: this,
19559
19572
  rawDataManager: this.rawDataManager,
19560
19573
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19561
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19574
+ data: treeData,
19562
19575
  onChange: async () => {
19563
19576
  let oldValue;
19564
19577
  try {
@@ -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');
@@ -182,7 +182,7 @@ export class RawDataManager {
182
182
  toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
183
183
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
184
184
  ? source[childrenKey].map((child, index) => {
185
- return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
185
+ return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[0], idKey, childrenKey);
186
186
  })
187
187
  : toAdd[childrenKey];
188
188
  return source;
@@ -23,6 +23,9 @@ export function getPropertyFromNode(node, property, logerror = true) {
23
23
  export function findNodeById(tree, nodeId) {
24
24
  return tree.nodesById[nodeId] || null;
25
25
  }
26
+ function normalizeStr(str) {
27
+ return str.replace(/\u00A0/g, " ");
28
+ }
26
29
  // TODO Deprecated ?
27
30
  // export function getNodesFromSearch(data: any, searched: string): any[] {
28
31
  // let toret: any[] = [];
@@ -49,6 +52,9 @@ export function findNodeById(tree, nodeId) {
49
52
  */
50
53
  export function fillTreeWithObject(tree, myObject, searched, options) {
51
54
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
55
+ if (myObject && myObject.children) {
56
+ myObject = [myObject];
57
+ }
52
58
  if (myObject && myObject.length) {
53
59
  myObject.forEach(value => {
54
60
  var _a, _b, _c, _d;
@@ -79,9 +85,9 @@ export function fillTreeWithObject(tree, myObject, searched, options) {
79
85
  const objToPush = {
80
86
  id: keyPropFromNode,
81
87
  nodeId: keyPropFromNode,
82
- text: valueTranslatedPropFromNode,
83
- fullpath: fullpathPropFromNode,
84
- fullpathTranslated: fullpathTranslatedPropFromNode,
88
+ text: normalizeStr(valueTranslatedPropFromNode),
89
+ fullpath: normalizeStr(fullpathPropFromNode),
90
+ fullpathTranslated: normalizeStr(fullpathTranslatedPropFromNode),
85
91
  children: getPropertyFromNode(value, 'hasChildren', false) && childrenPropFromNode && childrenPropFromNode.length === 0 ? [{}] : [],
86
92
  deprecated,
87
93
  isDesaturated: false,
@@ -17,7 +17,10 @@ export function replacer(key, value) {
17
17
  }
18
18
  export function searchValue(obj, strict, searched) {
19
19
  let toret = false;
20
- if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
20
+ function normalize(s) {
21
+ return s.replace(/\u00A0/g, " ");
22
+ }
23
+ if (normalize(obj.text).toLowerCase().indexOf(normalize(searched).toLowerCase()) > -1) {
21
24
  toret = true;
22
25
  }
23
26
  else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
@@ -18040,7 +18040,10 @@ function replacer(key, value) {
18040
18040
  }
18041
18041
  function searchValue(obj, strict, searched) {
18042
18042
  let toret = false;
18043
- if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18043
+ function normalize(s) {
18044
+ return s.replace(/\u00A0/g, " ");
18045
+ }
18046
+ if (normalize(obj.text).toLowerCase().indexOf(normalize(searched).toLowerCase()) > -1) {
18044
18047
  toret = true;
18045
18048
  }
18046
18049
  else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
@@ -18328,7 +18331,7 @@ class RawDataManager {
18328
18331
  toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
18329
18332
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
18330
18333
  ? source[childrenKey].map((child, index) => {
18331
- return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
18334
+ return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[0], idKey, childrenKey);
18332
18335
  })
18333
18336
  : toAdd[childrenKey];
18334
18337
  return source;
@@ -18432,6 +18435,9 @@ function getPropertyFromNode(node, property, logerror = true) {
18432
18435
  function findNodeById(tree, nodeId) {
18433
18436
  return tree.nodesById[nodeId] || null;
18434
18437
  }
18438
+ function normalizeStr(str) {
18439
+ return str.replace(/\u00A0/g, " ");
18440
+ }
18435
18441
  // TODO Deprecated ?
18436
18442
  // export function getNodesFromSearch(data: any, searched: string): any[] {
18437
18443
  // let toret: any[] = [];
@@ -18458,6 +18464,9 @@ function findNodeById(tree, nodeId) {
18458
18464
  */
18459
18465
  function fillTreeWithObject(tree, myObject, searched, options) {
18460
18466
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18467
+ if (myObject && myObject.children) {
18468
+ myObject = [myObject];
18469
+ }
18461
18470
  if (myObject && myObject.length) {
18462
18471
  myObject.forEach(value => {
18463
18472
  var _a, _b, _c, _d;
@@ -18488,9 +18497,9 @@ function fillTreeWithObject(tree, myObject, searched, options) {
18488
18497
  const objToPush = {
18489
18498
  id: keyPropFromNode,
18490
18499
  nodeId: keyPropFromNode,
18491
- text: valueTranslatedPropFromNode,
18492
- fullpath: fullpathPropFromNode,
18493
- fullpathTranslated: fullpathTranslatedPropFromNode,
18500
+ text: normalizeStr(valueTranslatedPropFromNode),
18501
+ fullpath: normalizeStr(fullpathPropFromNode),
18502
+ fullpathTranslated: normalizeStr(fullpathTranslatedPropFromNode),
18494
18503
  children: getPropertyFromNode(value, 'hasChildren', false) && childrenPropFromNode && childrenPropFromNode.length === 0 ? [{}] : [],
18495
18504
  deprecated,
18496
18505
  isDesaturated: false,
@@ -19551,12 +19560,16 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19551
19560
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19552
19561
  return;
19553
19562
  }
19563
+ if (!this.loadedTreeJs || forceTreeReset) {
19564
+ const dataManagerData = this.rawDataManager.getData();
19565
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19566
+ }
19554
19567
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19555
19568
  const myTree = new Tree('#tree-area-' + this.componentID, {
19556
19569
  parentApi: this,
19557
19570
  rawDataManager: this.rawDataManager,
19558
19571
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19559
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19572
+ data: treeData,
19560
19573
  onChange: async () => {
19561
19574
  let oldValue;
19562
19575
  try {
@@ -18039,7 +18039,10 @@ function replacer(key, value) {
18039
18039
  }
18040
18040
  function searchValue(obj, strict, searched) {
18041
18041
  let toret = false;
18042
- if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18042
+ function normalize(s) {
18043
+ return s.replace(/\u00A0/g, " ");
18044
+ }
18045
+ if (normalize(obj.text).toLowerCase().indexOf(normalize(searched).toLowerCase()) > -1) {
18043
18046
  toret = true;
18044
18047
  }
18045
18048
  else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
@@ -18327,7 +18330,7 @@ class RawDataManager {
18327
18330
  toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
18328
18331
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
18329
18332
  ? source[childrenKey].map((child, index) => {
18330
- return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
18333
+ return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[0], idKey, childrenKey);
18331
18334
  })
18332
18335
  : toAdd[childrenKey];
18333
18336
  return source;
@@ -18431,6 +18434,9 @@ function getPropertyFromNode(node, property, logerror = true) {
18431
18434
  function findNodeById(tree, nodeId) {
18432
18435
  return tree.nodesById[nodeId] || null;
18433
18436
  }
18437
+ function normalizeStr(str) {
18438
+ return str.replace(/\u00A0/g, " ");
18439
+ }
18434
18440
  // TODO Deprecated ?
18435
18441
  // export function getNodesFromSearch(data: any, searched: string): any[] {
18436
18442
  // let toret: any[] = [];
@@ -18457,6 +18463,9 @@ function findNodeById(tree, nodeId) {
18457
18463
  */
18458
18464
  function fillTreeWithObject(tree, myObject, searched, options) {
18459
18465
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18466
+ if (myObject && myObject.children) {
18467
+ myObject = [myObject];
18468
+ }
18460
18469
  if (myObject && myObject.length) {
18461
18470
  myObject.forEach(value => {
18462
18471
  var _a, _b, _c, _d;
@@ -18487,9 +18496,9 @@ function fillTreeWithObject(tree, myObject, searched, options) {
18487
18496
  const objToPush = {
18488
18497
  id: keyPropFromNode,
18489
18498
  nodeId: keyPropFromNode,
18490
- text: valueTranslatedPropFromNode,
18491
- fullpath: fullpathPropFromNode,
18492
- fullpathTranslated: fullpathTranslatedPropFromNode,
18499
+ text: normalizeStr(valueTranslatedPropFromNode),
18500
+ fullpath: normalizeStr(fullpathPropFromNode),
18501
+ fullpathTranslated: normalizeStr(fullpathTranslatedPropFromNode),
18493
18502
  children: getPropertyFromNode(value, 'hasChildren', false) && childrenPropFromNode && childrenPropFromNode.length === 0 ? [{}] : [],
18494
18503
  deprecated,
18495
18504
  isDesaturated: false,
@@ -19549,12 +19558,16 @@ const HierarchizedPickerComponent = class {
19549
19558
  this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
19550
19559
  return;
19551
19560
  }
19561
+ if (!this.loadedTreeJs || forceTreeReset) {
19562
+ const dataManagerData = this.rawDataManager.getData();
19563
+ treeData = fillTreeWithObject([], (this.optionsManager.getOptions().displayRootNode ? dataManagerData : dataManagerData.children), null, this.optionsManager.getOptions());
19564
+ }
19552
19565
  // TODO If statement is a quick fix to allow the loadedTreeJs data to be holded instead of being reinitialized after hiding the modale
19553
19566
  const myTree = new Tree('#tree-area-' + this.componentID, {
19554
19567
  parentApi: this,
19555
19568
  rawDataManager: this.rawDataManager,
19556
19569
  completeCurrentTreeWithTree: completeCurrentTreeWithTree,
19557
- data: (!this.loadedTreeJs || forceTreeReset ? treeData : fillTreeWithObject([], this.rawDataManager.getData().children, null, this.optionsManager.getOptions())),
19570
+ data: treeData,
19558
19571
  onChange: async () => {
19559
19572
  let oldValue;
19560
19573
  try {