@tap-payments/os-micro-frontend-shared 0.1.373-test.3-test.4-test.5 → 0.1.373-test.3-test.4-test.5-test.6
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.
|
@@ -18,6 +18,8 @@ export const useViewsMenu = ({ mode, onViewChange, onCreateCustomView, onEditCus
|
|
|
18
18
|
const [selectedView, setSelectedView] = useState(undefined);
|
|
19
19
|
const [currentViewColumns, setCurrentViewColumns] = useState([]);
|
|
20
20
|
const hasInitializedRef = useRef(false);
|
|
21
|
+
const pendingSelectAfterCreateRef = useRef(false);
|
|
22
|
+
const allTemplatesLengthRef = useRef(allTemplates.length);
|
|
21
23
|
const getViewForParent = useCallback((view) => {
|
|
22
24
|
var _a;
|
|
23
25
|
const selectedColumns = ((_a = view.submenu) === null || _a === void 0 ? void 0 : _a.filter((col) => col.selected)) || [];
|
|
@@ -98,6 +100,21 @@ export const useViewsMenu = ({ mode, onViewChange, onCreateCustomView, onEditCus
|
|
|
98
100
|
onViewChange === null || onViewChange === void 0 ? void 0 : onViewChange(viewForParent);
|
|
99
101
|
}
|
|
100
102
|
}, [allTemplates, selectedView, onViewChange]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const prevLength = allTemplatesLengthRef.current;
|
|
105
|
+
allTemplatesLengthRef.current = allTemplates.length;
|
|
106
|
+
if (!pendingSelectAfterCreateRef.current || allTemplates.length === 0 || allTemplates.length <= prevLength)
|
|
107
|
+
return;
|
|
108
|
+
const customViews = allTemplates.filter((t) => t.isCustom);
|
|
109
|
+
if (customViews.length === 0)
|
|
110
|
+
return;
|
|
111
|
+
const newView = customViews[customViews.length - 1];
|
|
112
|
+
setSelectedView(newView);
|
|
113
|
+
setCurrentViewColumns(deepCloneColumns(newView.submenu || []));
|
|
114
|
+
setSelectedViewInfo({ id: newView.id, label: newView.label });
|
|
115
|
+
onViewChange === null || onViewChange === void 0 ? void 0 : onViewChange(getViewForParent(newView));
|
|
116
|
+
pendingSelectAfterCreateRef.current = false;
|
|
117
|
+
}, [allTemplates, onViewChange, getViewForParent]);
|
|
101
118
|
const handleViewButtonClick = useCallback((event) => {
|
|
102
119
|
setAnchorEl((current) => (current ? null : event.currentTarget));
|
|
103
120
|
}, []);
|
|
@@ -139,12 +156,17 @@ export const useViewsMenu = ({ mode, onViewChange, onCreateCustomView, onEditCus
|
|
|
139
156
|
if (editingView) {
|
|
140
157
|
const templateId = editingView.templateId || editingView.id;
|
|
141
158
|
yield (onEditCustomView === null || onEditCustomView === void 0 ? void 0 : onEditCustomView(templateId, data));
|
|
142
|
-
|
|
159
|
+
const updatedView = Object.assign(Object.assign({}, editingView), { label: data.name, submenu: deepCloneColumns(data.selectedColumns), columns: data.selectedColumns.map((c) => c.name) });
|
|
160
|
+
setSelectedView(updatedView);
|
|
161
|
+
setCurrentViewColumns(deepCloneColumns(data.selectedColumns));
|
|
162
|
+
setSelectedViewInfo({ id: updatedView.id, label: updatedView.label });
|
|
163
|
+
onViewChange === null || onViewChange === void 0 ? void 0 : onViewChange(getViewForParent(updatedView));
|
|
143
164
|
}
|
|
144
165
|
else {
|
|
145
166
|
yield (onCreateCustomView === null || onCreateCustomView === void 0 ? void 0 : onCreateCustomView(data));
|
|
167
|
+
pendingSelectAfterCreateRef.current = true;
|
|
146
168
|
}
|
|
147
|
-
}), [editingView, onEditCustomView, onCreateCustomView]);
|
|
169
|
+
}), [editingView, onEditCustomView, onCreateCustomView, onViewChange, getViewForParent]);
|
|
148
170
|
const handleDeleteView = useCallback((viewId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
171
|
const viewToDelete = allTemplates.find((view) => view.id === viewId || view.templateId === viewId);
|
|
150
172
|
const templateId = (viewToDelete === null || viewToDelete === void 0 ? void 0 : viewToDelete.templateId) || viewId;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/os-micro-frontend-shared",
|
|
3
3
|
"description": "Shared components and utilities for Tap Payments micro frontends",
|
|
4
|
-
"version": "0.1.373-test.3-test.4-test.5",
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.373-test.3-test.4-test.5-test.6",
|
|
5
|
+
"testVersion": 6,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|