@tap-payments/os-micro-frontend-shared 0.1.373-test.2-test.3-test.4 → 0.1.373-test.2-test.3-test.4-test.5
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.
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
10
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
11
11
|
import { createCustomViewMenuItem } from '../utils';
|
|
12
12
|
export const useViewSelector = ({ mode, onViewChange, onTableViewsChange, onCustomViewsChange, onCreateCustomView, onEditCustomView, onDeleteCustomView, resetTableViews, setTableViews, tableViews, customViews, defaultColumns, defaultTemplate, setInternalCustomViews, setInternalTableViews, setDefaultColumns, }) => {
|
|
13
13
|
const [anchorViewEl, setAnchorViewEl] = useState(null);
|
|
@@ -17,6 +17,7 @@ export const useViewSelector = ({ mode, onViewChange, onTableViewsChange, onCust
|
|
|
17
17
|
const [selectedViewInfo, setSelectedViewInfo] = useState({ id: 'default', label: 'Default' });
|
|
18
18
|
const [shouldUseCurrentState, setShouldUseCurrentState] = useState(false);
|
|
19
19
|
const [selectedView, setSelectedView] = useState(undefined);
|
|
20
|
+
const hasInitializedRef = useRef(false);
|
|
20
21
|
// Update editingView when customViews changes to ensure it reflects the latest saved state
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
if (editingView && customViews.length > 0) {
|
|
@@ -43,14 +44,18 @@ export const useViewSelector = ({ mode, onViewChange, onTableViewsChange, onCust
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}, [customViews, selectedView, onViewChange]);
|
|
46
|
-
// Notify parent of initial view on mount
|
|
47
|
+
// Notify parent of initial view on mount only
|
|
47
48
|
useEffect(() => {
|
|
49
|
+
// Only initialize once on mount, don't reset if user has already selected a view
|
|
50
|
+
if (hasInitializedRef.current)
|
|
51
|
+
return;
|
|
48
52
|
// Use defaultTemplate if available, otherwise undefined (built-in default view)
|
|
49
53
|
const initialView = defaultTemplate || undefined;
|
|
50
54
|
console.log('initialView', initialView);
|
|
51
55
|
setSelectedView(initialView);
|
|
52
56
|
onViewChange === null || onViewChange === void 0 ? void 0 : onViewChange(initialView);
|
|
53
|
-
|
|
57
|
+
hasInitializedRef.current = true;
|
|
58
|
+
}, [defaultTemplate, onViewChange]);
|
|
54
59
|
const handleTableViewsChange = useCallback((newTableViews) => {
|
|
55
60
|
const setTableViewsState = setTableViews !== null && setTableViews !== void 0 ? setTableViews : setInternalTableViews;
|
|
56
61
|
setTableViewsState(newTableViews);
|
|
@@ -350,18 +350,24 @@ export const ResetCheckboxSx = {
|
|
|
350
350
|
};
|
|
351
351
|
export const SubmenuContainer = styled(Box)(() => ({
|
|
352
352
|
minWidth: 200,
|
|
353
|
+
display: 'flex',
|
|
354
|
+
flexDirection: 'column',
|
|
355
|
+
maxHeight: '80vh',
|
|
356
|
+
overflow: 'hidden',
|
|
353
357
|
}));
|
|
354
358
|
export const ColumnItemsContainer = styled(Box)(() => ({
|
|
355
|
-
|
|
359
|
+
flex: 1,
|
|
356
360
|
overflowY: 'auto',
|
|
357
361
|
paddingLeft: 6,
|
|
358
362
|
paddingRight: 6,
|
|
363
|
+
minHeight: 0,
|
|
359
364
|
}));
|
|
360
365
|
export const SaveCustomViewBox = styled(Box)(() => ({
|
|
361
366
|
paddingLeft: 8,
|
|
362
367
|
paddingRight: 8,
|
|
363
368
|
paddingTop: 8,
|
|
364
369
|
paddingBottom: 8,
|
|
370
|
+
flexShrink: 0,
|
|
365
371
|
}));
|
|
366
372
|
export const SaveCustomViewInnerBox = styled(Box)(({ disabled }) => ({
|
|
367
373
|
width: '100%',
|
|
@@ -376,7 +382,7 @@ export const SaveCustomViewInnerBox = styled(Box)(({ disabled }) => ({
|
|
|
376
382
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
377
383
|
opacity: disabled ? 0.5 : 1,
|
|
378
384
|
}));
|
|
379
|
-
export const ButtonsContainer = styled(Box)(() => ({
|
|
385
|
+
export const ButtonsContainer = styled(Box)(({ theme }) => ({
|
|
380
386
|
display: 'flex',
|
|
381
387
|
justifyContent: 'flex-end',
|
|
382
388
|
gap: 12,
|
|
@@ -384,6 +390,9 @@ export const ButtonsContainer = styled(Box)(() => ({
|
|
|
384
390
|
paddingBottom: 8,
|
|
385
391
|
paddingLeft: 12,
|
|
386
392
|
paddingRight: 12,
|
|
393
|
+
flexShrink: 0,
|
|
394
|
+
borderTop: '1px solid',
|
|
395
|
+
borderColor: theme.palette.divider,
|
|
387
396
|
}));
|
|
388
397
|
export const CancelButtonSx = {
|
|
389
398
|
fontSize: 11,
|
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.2-test.3-test.4",
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.373-test.2-test.3-test.4-test.5",
|
|
5
|
+
"testVersion": 5,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|