@topconsultnpm/sdkui-react-beta 6.13.48 → 6.13.50
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.
- package/lib/assets/icomoon.svg +96 -96
- package/lib/assets/italy.svg +16 -16
- package/lib/assets/topmedia-six.svg +65 -65
- package/lib/assets/topmeida-six-bianco.svg +65 -65
- package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +9 -0
- package/lib/components/layout/panelManager/TMPanelManagerContainer.js +212 -0
- package/lib/components/layout/panelManager/TMPanelManagerContext.d.ts +36 -0
- package/lib/components/layout/panelManager/TMPanelManagerContext.js +234 -0
- package/lib/components/layout/panelManager/TMPanelManagerToolbar.d.ts +11 -0
- package/lib/components/layout/panelManager/TMPanelManagerToolbar.js +58 -0
- package/lib/components/layout/panelManager/TMPanelWrapper.d.ts +8 -0
- package/lib/components/layout/panelManager/TMPanelWrapper.js +35 -0
- package/lib/components/layout/panelManager/types.d.ts +36 -0
- package/lib/components/layout/panelManager/types.js +1 -0
- package/lib/components/layout/panelManager/utils.d.ts +21 -0
- package/lib/components/layout/panelManager/utils.js +208 -0
- package/lib/helper/SDKUI_Globals.js +2 -1
- package/lib/helper/helpers.d.ts +1 -1
- package/lib/helper/helpers.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
import { TMPanelDefinition, TMPanelDimensionsMap, TMPanelHierarchyMap } from "./types";
|
2
|
+
export declare const flattenPanels: (panels: Array<TMPanelDefinition>) => Array<TMPanelDefinition>;
|
3
|
+
export declare function getToolbarStates(panels: Array<TMPanelDefinition>): {
|
4
|
+
visibilityMap: {
|
5
|
+
[id: string]: boolean;
|
6
|
+
};
|
7
|
+
disabledMap: {
|
8
|
+
[id: string]: boolean;
|
9
|
+
};
|
10
|
+
};
|
11
|
+
export declare const generatePanelHierarchyMap: (panels: Array<TMPanelDefinition>) => TMPanelHierarchyMap;
|
12
|
+
export declare const showParentRecursively: (panelId: string, hierarchyMap: TMPanelHierarchyMap) => Array<[string, boolean]>;
|
13
|
+
export declare const hideParentRecursively: (panelId: string, hierarchyMap: TMPanelHierarchyMap, currentVisibility: {
|
14
|
+
[id: string]: boolean;
|
15
|
+
}) => Array<[string, boolean]>;
|
16
|
+
export declare const redistributeDimensionsOnHide: (hiddenPanelId: string, currentDimensions: TMPanelDimensionsMap, hierarchyMap: TMPanelHierarchyMap, panelVisibility: {
|
17
|
+
[id: string]: boolean;
|
18
|
+
}) => TMPanelDimensionsMap;
|
19
|
+
export declare const redistributeDimensionsOnShow: (shownPanelId: string, currentDimensions: TMPanelDimensionsMap, initialDimensions: TMPanelDimensionsMap, hierarchyMap: TMPanelHierarchyMap, panelVisibility: {
|
20
|
+
[id: string]: boolean;
|
21
|
+
}) => TMPanelDimensionsMap;
|
@@ -0,0 +1,208 @@
|
|
1
|
+
// Recursive function to flatten the panel hierarchy into a single array (includes children)
|
2
|
+
export const flattenPanels = (panels) => {
|
3
|
+
return panels.reduce((acc, panel) => {
|
4
|
+
// Add the current panel
|
5
|
+
acc.push(panel);
|
6
|
+
// Recursively add all child panels
|
7
|
+
if (panel.children && panel.children.length > 0) {
|
8
|
+
acc.push(...flattenPanels(panel.children));
|
9
|
+
}
|
10
|
+
return acc;
|
11
|
+
}, []);
|
12
|
+
};
|
13
|
+
// Recursive helper to traverse panels and children, accumulating visibility and disabled states
|
14
|
+
// Recursive function that returns visibility and disabled maps for panels and all children
|
15
|
+
export function getToolbarStates(panels) {
|
16
|
+
let visibilityMap = {};
|
17
|
+
let disabledMap = {};
|
18
|
+
panels.forEach(panel => {
|
19
|
+
if (panel.toolbarOptions?.visible !== undefined) {
|
20
|
+
visibilityMap[panel.id] = panel.toolbarOptions.visible;
|
21
|
+
disabledMap[panel.id] = panel.toolbarOptions.disabled ?? false;
|
22
|
+
}
|
23
|
+
if (panel.children && panel.children.length > 0) {
|
24
|
+
const childStates = getToolbarStates(panel.children);
|
25
|
+
visibilityMap = { ...visibilityMap, ...childStates.visibilityMap };
|
26
|
+
disabledMap = { ...disabledMap, ...childStates.disabledMap };
|
27
|
+
}
|
28
|
+
});
|
29
|
+
return { visibilityMap, disabledMap };
|
30
|
+
}
|
31
|
+
export const generatePanelHierarchyMap = (panels) => {
|
32
|
+
const hierarchyMap = new Map();
|
33
|
+
const traverse = (node, parentId, siblings = []) => {
|
34
|
+
const children = node.children || [];
|
35
|
+
const info = {
|
36
|
+
parentId: parentId,
|
37
|
+
childrenIds: children.map(child => child.id),
|
38
|
+
siblingIds: siblings.filter(s => s.id !== node.id).map(s => s.id),
|
39
|
+
groupDirection: node.currentGroupDirection ?? 'horizontal',
|
40
|
+
};
|
41
|
+
hierarchyMap.set(node.id, info);
|
42
|
+
for (const child of children) {
|
43
|
+
traverse(child, node.id, children);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
for (const panel of panels) {
|
47
|
+
traverse(panel, undefined, panels);
|
48
|
+
}
|
49
|
+
return hierarchyMap;
|
50
|
+
};
|
51
|
+
export const showParentRecursively = (panelId, hierarchyMap) => {
|
52
|
+
const result = [];
|
53
|
+
const visit = (id) => {
|
54
|
+
const panelInfo = hierarchyMap.get(id);
|
55
|
+
if (!panelInfo)
|
56
|
+
return;
|
57
|
+
if (panelInfo.parentId) {
|
58
|
+
if (!result.some(([pid]) => pid === panelInfo.parentId)) {
|
59
|
+
result.push([panelInfo.parentId, true]);
|
60
|
+
visit(panelInfo.parentId);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
};
|
64
|
+
visit(panelId);
|
65
|
+
return result;
|
66
|
+
};
|
67
|
+
export const hideParentRecursively = (panelId, hierarchyMap, currentVisibility) => {
|
68
|
+
const result = [];
|
69
|
+
const visit = (id) => {
|
70
|
+
const panelInfo = hierarchyMap.get(id);
|
71
|
+
if (!panelInfo)
|
72
|
+
return;
|
73
|
+
if (panelInfo.parentId) {
|
74
|
+
const parentInfo = hierarchyMap.get(panelInfo.parentId);
|
75
|
+
if (!parentInfo)
|
76
|
+
return;
|
77
|
+
const visibleChildren = parentInfo.childrenIds.filter(childId => childId !== id && currentVisibility[childId]);
|
78
|
+
if (visibleChildren.length === 0) {
|
79
|
+
if (!result.some(([pid]) => pid === panelInfo.parentId)) {
|
80
|
+
result.push([panelInfo.parentId, false]);
|
81
|
+
visit(panelInfo.parentId);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
};
|
86
|
+
visit(panelId);
|
87
|
+
return result;
|
88
|
+
};
|
89
|
+
export const redistributeDimensionsOnHide = (hiddenPanelId, currentDimensions, hierarchyMap, panelVisibility) => {
|
90
|
+
const parentId = hierarchyMap.get(hiddenPanelId)?.parentId;
|
91
|
+
const siblings = hierarchyMap.get(hiddenPanelId)?.siblingIds || [];
|
92
|
+
if (siblings.length === 0)
|
93
|
+
return currentDimensions;
|
94
|
+
const hiddenDims = currentDimensions[hiddenPanelId];
|
95
|
+
if (!hiddenDims)
|
96
|
+
return currentDimensions;
|
97
|
+
const hiddenWidthNum = parseFloat(hiddenDims.width);
|
98
|
+
const hiddenHeightNum = parseFloat(hiddenDims.height);
|
99
|
+
const visibleSiblings = siblings.filter(siblingId => panelVisibility[siblingId]);
|
100
|
+
const widthIncrement = hiddenWidthNum / visibleSiblings.length;
|
101
|
+
const heightIncrement = hiddenHeightNum / visibleSiblings.length;
|
102
|
+
let newDimensions = { ...currentDimensions };
|
103
|
+
visibleSiblings.forEach(siblingId => {
|
104
|
+
const siblingDims = newDimensions[siblingId] || { width: '0%', height: '0%' };
|
105
|
+
const siblingWidthNum = parseFloat(siblingDims.width) || 0;
|
106
|
+
const siblingHeightNum = parseFloat(siblingDims.height) || 0;
|
107
|
+
const newWidthNum = Math.min(siblingWidthNum + widthIncrement, 100);
|
108
|
+
const newHeightNum = Math.min(siblingHeightNum + heightIncrement, 100);
|
109
|
+
newDimensions[siblingId] = { width: `${newWidthNum}%`, height: `${newHeightNum}%` };
|
110
|
+
});
|
111
|
+
newDimensions[hiddenPanelId] = { width: '0%', height: '0%' };
|
112
|
+
// Ora controllo se il parent non ha più figli visibili e chiamo ricorsivamente
|
113
|
+
if (parentId) {
|
114
|
+
const parentInfo = hierarchyMap.get(parentId);
|
115
|
+
if (parentInfo) {
|
116
|
+
const visibleSiblings = parentInfo.childrenIds.filter(childId => childId !== hiddenPanelId && panelVisibility[childId]);
|
117
|
+
// Se non ci sono figli visibili rimanenti, chiamo ricorsivamente sul parent
|
118
|
+
if (visibleSiblings.length === 0) {
|
119
|
+
newDimensions = redistributeDimensionsOnHide(parentId, newDimensions, hierarchyMap, panelVisibility);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return newDimensions;
|
124
|
+
};
|
125
|
+
export const redistributeDimensionsOnShow = (shownPanelId, currentDimensions, initialDimensions, hierarchyMap, panelVisibility) => {
|
126
|
+
let updatedDimensions = { ...currentDimensions };
|
127
|
+
const redistribute = (panelId) => {
|
128
|
+
const panel = hierarchyMap.get(panelId);
|
129
|
+
if (!panel)
|
130
|
+
return;
|
131
|
+
const parentId = panel.parentId;
|
132
|
+
if (!parentId) {
|
133
|
+
// Caso root (senza parent)
|
134
|
+
const siblingIds = panel.siblingIds || [];
|
135
|
+
const visibleSiblings = siblingIds.filter(sibId => panelVisibility[sibId]);
|
136
|
+
const allVisible = [panelId, ...visibleSiblings];
|
137
|
+
if (panel.groupDirection === 'horizontal') {
|
138
|
+
const totalInitialWidth = allVisible.reduce((sum, id) => {
|
139
|
+
const w = parseFloat(initialDimensions[id]?.width || '0');
|
140
|
+
return sum + w;
|
141
|
+
}, 0);
|
142
|
+
allVisible.forEach(id => {
|
143
|
+
const w = parseFloat(initialDimensions[id]?.width || '0');
|
144
|
+
const proportionalWidth = (w / totalInitialWidth) * 100;
|
145
|
+
updatedDimensions[id] = {
|
146
|
+
width: `${proportionalWidth}%`,
|
147
|
+
height: '100%'
|
148
|
+
};
|
149
|
+
});
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
// vertical
|
153
|
+
const totalInitialHeight = allVisible.reduce((sum, id) => {
|
154
|
+
const h = parseFloat(initialDimensions[id]?.height || '0');
|
155
|
+
return sum + h;
|
156
|
+
}, 0);
|
157
|
+
allVisible.forEach(id => {
|
158
|
+
const h = parseFloat(initialDimensions[id]?.height || '0');
|
159
|
+
const proportionalHeight = (h / totalInitialHeight) * 100;
|
160
|
+
updatedDimensions[id] = {
|
161
|
+
width: '100%',
|
162
|
+
height: `${proportionalHeight}%`
|
163
|
+
};
|
164
|
+
});
|
165
|
+
}
|
166
|
+
}
|
167
|
+
else {
|
168
|
+
const siblingIds = panel.siblingIds || [];
|
169
|
+
const visibleSiblings = siblingIds.filter(sibId => panelVisibility[sibId]);
|
170
|
+
const allVisible = [panelId, ...visibleSiblings];
|
171
|
+
if (panel.groupDirection === 'horizontal') {
|
172
|
+
const totalInitialWidth = allVisible.reduce((sum, id) => {
|
173
|
+
const w = parseFloat(initialDimensions[id]?.width || '0');
|
174
|
+
return sum + w;
|
175
|
+
}, 0);
|
176
|
+
allVisible.forEach(id => {
|
177
|
+
const w = parseFloat(initialDimensions[id]?.width || '0');
|
178
|
+
const proportionalWidth = (w / totalInitialWidth) * 100;
|
179
|
+
updatedDimensions[id] = {
|
180
|
+
width: `${proportionalWidth}%`,
|
181
|
+
height: '100%'
|
182
|
+
};
|
183
|
+
});
|
184
|
+
}
|
185
|
+
else {
|
186
|
+
// vertical
|
187
|
+
const totalInitialHeight = allVisible.reduce((sum, id) => {
|
188
|
+
const h = parseFloat(initialDimensions[id]?.height || '0');
|
189
|
+
return sum + h;
|
190
|
+
}, 0);
|
191
|
+
allVisible.forEach(id => {
|
192
|
+
const h = parseFloat(initialDimensions[id]?.height || '0');
|
193
|
+
const proportionalHeight = (h / totalInitialHeight) * 100;
|
194
|
+
updatedDimensions[id] = {
|
195
|
+
width: '100%',
|
196
|
+
height: `${proportionalHeight}%`
|
197
|
+
};
|
198
|
+
});
|
199
|
+
}
|
200
|
+
// Chiamo ricorsivamente sul parent corretto (non sempre shownPanelId)
|
201
|
+
const parent = hierarchyMap.get(panelId)?.parentId;
|
202
|
+
if (parent)
|
203
|
+
redistribute(parent);
|
204
|
+
}
|
205
|
+
};
|
206
|
+
redistribute(shownPanelId);
|
207
|
+
return updatedDimensions;
|
208
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { InvoiceRetrieveFormats, LocalStorageService, OrderRetrieveFormats } from "@topconsultnpm/sdk-ts-beta";
|
2
2
|
import { FontSize, Gutters } from "../utils/theme";
|
3
|
+
// import { LandingPages } from "./helpers";
|
3
4
|
export const dcmtsFileCacheDownload = new Map();
|
4
5
|
export const dcmtsFileCachePreview = new Map();
|
5
6
|
export const CACHE_SIZE_LIMIT = 10;
|
@@ -9,7 +10,7 @@ export const isDcmtFileInCache = (key) => dcmtsFileCachePreview.has(key);
|
|
9
10
|
export class UserSettings {
|
10
11
|
constructor() {
|
11
12
|
this.archiveID = undefined;
|
12
|
-
this.landingPage = '';
|
13
|
+
this.landingPage = 'dashboard'; // TODO: se usiamo LandingPages errore sulle dipendenze.
|
13
14
|
this.userID = undefined;
|
14
15
|
this.advancedSettings = new AdvancedSettings();
|
15
16
|
this.archivingSettings = new ArchivingSettings();
|
package/lib/helper/helpers.d.ts
CHANGED
@@ -40,7 +40,7 @@ export declare function isPositiveNumber(val: unknown): val is number;
|
|
40
40
|
export declare function sleep(ms: number): Promise<void>;
|
41
41
|
export declare const dialogConfirmOperation: (title: string, msg: string, operationAsync: () => Promise<void>) => void;
|
42
42
|
export declare enum LandingPages {
|
43
|
-
|
43
|
+
DASHBOARD = "dashboard",
|
44
44
|
SEARCH = "search",
|
45
45
|
ARCHIVE = "archive",
|
46
46
|
WORKING_GROUPS = "workingGroups",
|
package/lib/helper/helpers.js
CHANGED
@@ -660,7 +660,7 @@ export const dialogConfirmOperation = (title, msg, operationAsync) => {
|
|
660
660
|
};
|
661
661
|
export var LandingPages;
|
662
662
|
(function (LandingPages) {
|
663
|
-
LandingPages["
|
663
|
+
LandingPages["DASHBOARD"] = "dashboard";
|
664
664
|
LandingPages["SEARCH"] = "search";
|
665
665
|
LandingPages["ARCHIVE"] = "archive";
|
666
666
|
LandingPages["WORKING_GROUPS"] = "workingGroups";
|