@topconsultnpm/sdkui-react-beta 6.15.31 → 6.15.32

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.
@@ -4,16 +4,21 @@ export class DeepCompareHelper {
4
4
  static deepCompareUnorderedNormalized(obj1, obj2) {
5
5
  if (JSON.stringify(obj1) === JSON.stringify(obj2))
6
6
  return true;
7
- if (obj1.mailFormat?.bodyMapping6?.fixedValue?.length !== obj2.mailFormat?.bodyMapping6?.fixedValue?.length)
8
- return false;
7
+ //if (obj1.mailFormat?.bodyMapping6?.fixedValue?.length !== obj2.mailFormat?.bodyMapping6?.fixedValue?.length) return false;
9
8
  const normalizedObj1 = DeepCompareHelper.normalizeObject(obj1);
10
9
  const normalizedObj2 = DeepCompareHelper.normalizeObject(obj2);
10
+ // let equals = (JSON.stringify(normalizedObj1) === JSON.stringify(normalizedObj2));
11
+ // if (!equals)
12
+ // {
13
+ // console.log(obj1.mailFormat?.bodyMapping6?.fixedValue);
14
+ // console.log(obj2.mailFormat?.bodyMapping6?.fixedValue);
15
+ // }
11
16
  return JSON.stringify(normalizedObj1) === JSON.stringify(normalizedObj2);
12
17
  }
13
18
  static normalizeObject(obj) {
14
19
  if (typeof obj !== 'object' || obj === null) {
15
20
  // Gestione specifica per stringhe che contengono HTML
16
- if (typeof obj === 'string' && obj.includes('<p') && obj.includes('style')) {
21
+ if (typeof obj === 'string' && (obj.includes('<') && obj.includes('>'))) {
17
22
  return DeepCompareHelper.normalizeHtmlString(obj); // Normalizza la stringa HTML
18
23
  }
19
24
  return obj; // Restituisci il valore se non è un oggetto
@@ -49,6 +54,14 @@ export class DeepCompareHelper {
49
54
  }, {});
50
55
  node.attribs = sortedAttributes;
51
56
  }
57
+ // Normalizza il contenuto testuale
58
+ if (node.type === 'text') {
59
+ // Normalizza spazi bianchi: rimuovi spazi extra e converti &nbsp; in spazi normali
60
+ node.data = node.data
61
+ .replace(/\u00A0/g, ' ') // Sostituisce caratteri non-breaking space
62
+ .replace(/\s+/g, ' ') // Sostituisce spazi multipli con uno singolo
63
+ .trim(); // Rimuove spazi iniziali e finali
64
+ }
52
65
  // Applica la funzione ai figli del nodo
53
66
  if (node.children) {
54
67
  node.children.forEach(reorderAttributes);
@@ -60,7 +73,20 @@ export class DeepCompareHelper {
60
73
  }
61
74
  // Ricostruisci la stringa HTML
62
75
  let output = DomSerializer(document);
63
- //output = output.replace(/&#xA0;/g, ' '); // Sostituisci &#xA0; con uno spazio normale
76
+ // Normalizzazioni aggiuntive dell'output finale
77
+ output = output
78
+ .replace(/\s+/g, ' ') // Riduci spazi multipli
79
+ .replace(/<p>\s*<\/p>/g, '<p><br></p>') // Normalizza paragrafi vuoti
80
+ .replace(/<p>\s+<\/p>/g, '<p><br></p>') // Normalizza paragrafi con solo spazi
81
+ .replace(/<p>&nbsp;<\/p>/g, '<p><br></p>') // Normalizza paragrafi con &nbsp;
82
+ // Rimuovi attributi data-cell* che possono variare
83
+ .replace(/\s*data-cell[a-z]*="[^"]*"/g, '')
84
+ // Rimuovi spazi extra creati dalla rimozione degli attributi
85
+ .replace(/\s+/g, ' ')
86
+ .replace(/(<p><br><\/p>\s*)+$/g, '') // Rimuovi paragrafi vuoti finali
87
+ .replace(/(<p>\s*<\/p>\s*)+$/g, '') // Rimuovi paragrafi con spazi finali
88
+ .replace(/\s+$/g, '') // Rimuovi spazi finali
89
+ .trim();
64
90
  return output;
65
91
  }
66
92
  static normalizeCssString(css) {
@@ -68,14 +94,13 @@ export class DeepCompareHelper {
68
94
  const stylePairs = css
69
95
  .split(';') // Dividi per punto e virgola
70
96
  .map(pair => pair.trim()) // Rimuovi spazi inutili
71
- .filter(pair => pair); // Rimuovi stringhe vuote
72
- // Ordina le coppie chiave-valore in ordine alfabetico
73
- const sortedStylePairs = [...stylePairs].sort((a, b) => {
74
- const [keyA] = a.split(':').map(part => part.trim());
75
- const [keyB] = b.split(':').map(part => part.trim());
76
- return keyA.localeCompare(keyB);
77
- });
97
+ .filter(pair => pair?.includes(':')); // Rimuovi stringhe vuote e senza ':'
98
+ // Normalizza e ordina le coppie chiave-valore
99
+ const normalizedPairs = stylePairs.map(pair => {
100
+ const [key, value] = pair.split(':').map(part => part.trim());
101
+ return `${key}: ${value}`;
102
+ }).sort((a, b) => a.localeCompare(b));
78
103
  // Ricostruisci la stringa CSS
79
- return sortedStylePairs.join('; ') + (sortedStylePairs.length > 0 ? ';' : '');
104
+ return normalizedPairs.length > 0 ? normalizedPairs.join('; ') + ';' : '';
80
105
  }
81
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.15.31",
3
+ "version": "6.15.32",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -42,7 +42,7 @@
42
42
  "lib"
43
43
  ],
44
44
  "dependencies": {
45
- "@topconsultnpm/sdk-ts-beta": "6.15.2",
45
+ "@topconsultnpm/sdk-ts-beta": "6.15.3",
46
46
  "buffer": "^6.0.3",
47
47
  "devextreme": "24.2.6",
48
48
  "devextreme-react": "24.2.6",