@tap-payments/os-micro-frontend-shared 0.1.371-test.1-test.2-test.3 → 0.1.371-test.1-test.2-test.3-test.4-test.5-test.6-test.7
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/build/components/Sandbox/style.js +3 -2
- package/build/components/TableHeader/TableView/CreateViewDialog.d.ts +1 -1
- package/build/components/TableHeader/TableView/CreateViewDialog.js +4 -2
- package/build/components/TableHeader/TableView/ViewsDropdown.js +24 -3
- package/build/components/TableHeader/TableView/ViewsManager.js +15 -2
- package/build/components/TableHeader/TableView/components/ColumnList.js +1 -1
- package/build/components/TableHeader/TableView/components/ViewsSubmenu.js +8 -7
- package/build/components/TableHeader/TableView/hooks/useViewsManager.js +5 -2
- package/build/components/TableHeader/TableView/index.d.ts +2 -2
- package/build/components/TableHeader/TableView/index.js +1 -1
- package/build/components/TableHeader/TableView/types.d.ts +34 -0
- package/build/components/TableHeader/TableView/utils.d.ts +19 -1
- package/build/components/TableHeader/TableView/utils.js +63 -3
- package/build/components/TableHeader/type.d.ts +3 -1
- package/build/components/Toolbar/Toolbar.js +1 -1
- package/package.json +2 -2
|
@@ -11,8 +11,10 @@ export const StyledContainer = styled(Box, {
|
|
|
11
11
|
}));
|
|
12
12
|
export const SandBoxWrapper = styled(Box)(() => ({
|
|
13
13
|
display: 'flex',
|
|
14
|
-
|
|
14
|
+
flexDirection: 'row-reverse',
|
|
15
|
+
justifyContent: 'flex-start',
|
|
15
16
|
alignItems: 'center',
|
|
17
|
+
gap: '0.25rem',
|
|
16
18
|
}));
|
|
17
19
|
export const StyledImage = styled('img')(() => ({
|
|
18
20
|
height: '0.75rem',
|
|
@@ -38,7 +40,6 @@ export const StyledText = styled('p', {
|
|
|
38
40
|
color: theme.palette.common.orange,
|
|
39
41
|
fontSize: '0.62rem',
|
|
40
42
|
fontWeight: 600,
|
|
41
|
-
paddingRight: '0.25rem',
|
|
42
43
|
opacity: isContentHovered ? 1 : 0,
|
|
43
44
|
display: isContentHovered ? 'block' : 'none',
|
|
44
45
|
transition: 'opacity 0.2s ease-in-out',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CreateCustomViewDialogProps } from './types';
|
|
2
|
-
declare function CreateViewDialog({ open, onClose, onCreate, availableColumns, isLoading, defaultColumns, editingView, onDelete, tableViews, }: Readonly<CreateCustomViewDialogProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
declare function CreateViewDialog({ open, onClose, onCreate, availableColumns, isLoading, defaultColumns, editingView, onDelete, tableViews, mode, }: Readonly<CreateCustomViewDialogProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default CreateViewDialog;
|
|
@@ -19,7 +19,8 @@ import { DialogContentWrapper, ScrollableContent, TitleSection, FooterBar, Creat
|
|
|
19
19
|
import { DIALOG_WIDTH, DIALOG_HEIGHT } from './constants';
|
|
20
20
|
import { useCreateViewDialog } from './hooks';
|
|
21
21
|
import { ColumnList } from './components/ColumnList';
|
|
22
|
-
|
|
22
|
+
import { convertColumnsToLayoutSection } from './utils';
|
|
23
|
+
function CreateViewDialog({ open, onClose, onCreate, availableColumns = [], isLoading = false, defaultColumns = [], editingView, onDelete, tableViews = [], mode = 'sheet', }) {
|
|
23
24
|
const { t } = useTranslation();
|
|
24
25
|
const { templateName, setTemplateName, selectedColumns, columnNames, allSelected, someSelected, isNameValid, hoveredColumn, anchorEl, openSubmenu, closeSubmenu, cancelClose, handleReorder, handleColumnToggle, handleSubItemToggle, handleSelectAll, handleResetToDefault, } = useCreateViewDialog({
|
|
25
26
|
open,
|
|
@@ -32,7 +33,8 @@ function CreateViewDialog({ open, onClose, onCreate, availableColumns = [], isLo
|
|
|
32
33
|
if (!isNameValid)
|
|
33
34
|
return;
|
|
34
35
|
const columnsToCreate = selectedColumns.filter((col) => col.selected);
|
|
35
|
-
|
|
36
|
+
const layout = convertColumnsToLayoutSection(columnsToCreate, mode);
|
|
37
|
+
yield (onCreate === null || onCreate === void 0 ? void 0 : onCreate({ name: templateName, selectedColumns: columnsToCreate, layout }));
|
|
36
38
|
onClose();
|
|
37
39
|
});
|
|
38
40
|
const handleDelete = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -22,7 +22,17 @@ function ViewsDropdown({ open, selectedViewInfo, setSelectedViewInfo, onSelect,
|
|
|
22
22
|
const [baselineColumns, setBaselineColumns] = React.useState([]);
|
|
23
23
|
const { originalColumns, saveOriginalState, clearOriginalState } = useOriginalColumns(defaultColumns);
|
|
24
24
|
const { hoveredNestedColumn, nestedSubmenuAnchorEl, openNestedSubmenu, closeNestedSubmenu, cancelNestedClose } = useNestedSubmenu();
|
|
25
|
-
|
|
25
|
+
// Sort custom views: default first, then others
|
|
26
|
+
const sortedCustomViews = useMemo(() => {
|
|
27
|
+
return [...customViews].sort((a, b) => {
|
|
28
|
+
if (a.default && !b.default)
|
|
29
|
+
return -1;
|
|
30
|
+
if (!a.default && b.default)
|
|
31
|
+
return 1;
|
|
32
|
+
return 0;
|
|
33
|
+
});
|
|
34
|
+
}, [customViews]);
|
|
35
|
+
const viewList = [...defaultViewList, ...sortedCustomViews];
|
|
26
36
|
const toggleColumnSelection = (columnName) => {
|
|
27
37
|
if (!setDefaultColumns)
|
|
28
38
|
return;
|
|
@@ -42,6 +52,17 @@ function ViewsDropdown({ open, selectedViewInfo, setSelectedViewInfo, onSelect,
|
|
|
42
52
|
return item ? getSubmenuItems(item, defaultColumns) : [];
|
|
43
53
|
};
|
|
44
54
|
const currentSubmenuColumns = useMemo(() => getHoveredSubmenu(), [hoveredItem, defaultColumns, viewList]);
|
|
55
|
+
const originalSubmenuColumns = useMemo(() => {
|
|
56
|
+
if (!hoveredItem || originalColumns.length === 0)
|
|
57
|
+
return [];
|
|
58
|
+
const item = viewList.find((i) => i.id === hoveredItem);
|
|
59
|
+
return item ? getSubmenuItems(item, originalColumns) : [];
|
|
60
|
+
}, [hoveredItem, originalColumns, viewList]);
|
|
61
|
+
const isSubmenuModified = useMemo(() => {
|
|
62
|
+
if (originalSubmenuColumns.length === 0)
|
|
63
|
+
return true;
|
|
64
|
+
return !areColumnsEqual(currentSubmenuColumns, originalSubmenuColumns);
|
|
65
|
+
}, [currentSubmenuColumns, originalSubmenuColumns]);
|
|
45
66
|
const allCurrentSelected = useMemo(() => areAllCurrentColumnsSelected(currentSubmenuColumns), [currentSubmenuColumns]);
|
|
46
67
|
const someCurrentSelected = useMemo(() => areSomeCurrentColumnsSelected(currentSubmenuColumns, allCurrentSelected), [currentSubmenuColumns, allCurrentSelected]);
|
|
47
68
|
const handleSelectAll = () => {
|
|
@@ -126,7 +147,7 @@ function ViewsDropdown({ open, selectedViewInfo, setSelectedViewInfo, onSelect,
|
|
|
126
147
|
} }, { children: [item.id === selectedViewInfo.id ? (_jsx("img", { style: {
|
|
127
148
|
width: 15,
|
|
128
149
|
height: 15,
|
|
129
|
-
}, className: "check-icon", src: smallBlueCheckIcon, alt: "check" })) : (_jsx(Space, {})), _jsxs("span", Object.assign({ style: { flex: 1, fontSize: 11 } }, { children: [item.label, item.id === 'default' && isDefaultModified && _jsx("span", Object.assign({ style: ModifiedTextSx }, { children: "(Modified)" }))] })), item.isCustom && hoveredCustomView === item.id && (_jsx("img", { src: editIcon, alt: "edit", style: { width: 12, height: 12, cursor: 'pointer' }, onClick: (e) => {
|
|
150
|
+
}, className: "check-icon", src: smallBlueCheckIcon, alt: "check" })) : (_jsx(Space, {})), _jsxs("span", Object.assign({ style: { flex: 1, fontSize: 11 } }, { children: [item.label, item.id === 'default' && isDefaultModified && _jsx("span", Object.assign({ style: ModifiedTextSx }, { children: "(Modified)" })), item.isCustom && item.default && _jsx("span", Object.assign({ style: Object.assign(Object.assign({}, ModifiedTextSx), { color: '#1F88D0', marginLeft: 4 }) }, { children: "(Default)" }))] })), item.isCustom && hoveredCustomView === item.id && (_jsx("img", { src: editIcon, alt: "edit", style: { width: 12, height: 12, cursor: 'pointer' }, onClick: (e) => {
|
|
130
151
|
e.stopPropagation();
|
|
131
152
|
onSelect(e);
|
|
132
153
|
onEditCustomView === null || onEditCustomView === void 0 ? void 0 : onEditCustomView(item);
|
|
@@ -143,6 +164,6 @@ function ViewsDropdown({ open, selectedViewInfo, setSelectedViewInfo, onSelect,
|
|
|
143
164
|
handleSubmenuLeave();
|
|
144
165
|
onSelect(e);
|
|
145
166
|
onCreateCustomView === null || onCreateCustomView === void 0 ? void 0 : onCreateCustomView(false); // Don't use current state for "New Custom View"
|
|
146
|
-
} }, { children: [_jsx(Space, {}), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: 0.5 } }, { children: [_jsx("img", { src: bluePlusIcon, alt: "icon", style: { opacity: shouldDimNewCustomView ? 0.5 : 1, width: 10, height: 10 } }), _jsx("span", Object.assign({ style: { color: shouldDimNewCustomView ? '#999' : '#1F88D0', fontSize: 11, fontWeight: 500 } }, { children: t('New Custom View') }))] })), _jsx(SpaceAfter, {})] })) }))] }) })), hoveredItem && submenuAnchorEl && getHoveredSubmenu().length > 0 && (_jsx(Menu, Object.assign({ open: Boolean(hoveredItem), anchorEl: submenuAnchorEl, placement: "right-start", onMouseEnter: handleSubmenuEnter, onMouseLeave: handleSubmenuLeave }, { children: _jsxs(SubmenuContainer, { children: [_jsx(ViewsSubmenu, { columns: getHoveredSubmenu(), allCurrentSelected: allCurrentSelected, someCurrentSelected: someCurrentSelected, onSelectAll: handleSelectAll, onReset: handleReset, onColumnToggle: toggleColumnSelection, onNestedItemToggle: toggleNestedItem, anchorEl: submenuAnchorEl }), _jsx(SaveCustomViewBox, { children: _jsx(Tooltip, Object.assign({ title: "Limit reached. Delete a view to create a new one.", placement: "left", disableHoverListener: !shouldDimNewCustomView }, { children: _jsxs(SaveCustomViewInnerBox, Object.assign({ disabled: shouldDimNewCustomView, onClick: shouldDimNewCustomView ? undefined : handleSaveAsCustomView }, { children: [_jsx(Typography, Object.assign({ sx: { fontSize: 11, color: 'text.secondary' } }, { children: "Save as a custom view" })), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: 0.5 } }, { children: [_jsx("img", { src: bluePlusIcon, alt: "add", style: { width: 10, height: 10, opacity: shouldDimNewCustomView ? 0.5 : 1 } }), _jsx(Typography, Object.assign({ sx: { fontSize: 10, fontWeight: 600, color: shouldDimNewCustomView ? '#999' : '#1F88D0' } }, { children: "Custom View" }))] }))] })) })) }), _jsxs(ButtonsContainer, { children: [_jsx(Button, Object.assign({ variant: "text", onClick: handleCancel, sx: CancelButtonSx }, { children: "Cancel" })), _jsx(Button, Object.assign({ variant: "contained", onClick: handleOkay, sx: OkayButtonSx }, { children: "Okay" }))] })] }) })))] })));
|
|
167
|
+
} }, { children: [_jsx(Space, {}), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: 0.5 } }, { children: [_jsx("img", { src: bluePlusIcon, alt: "icon", style: { opacity: shouldDimNewCustomView ? 0.5 : 1, width: 10, height: 10 } }), _jsx("span", Object.assign({ style: { color: shouldDimNewCustomView ? '#999' : '#1F88D0', fontSize: 11, fontWeight: 500 } }, { children: t('New Custom View') }))] })), _jsx(SpaceAfter, {})] })) }))] }) })), hoveredItem && submenuAnchorEl && getHoveredSubmenu().length > 0 && (_jsx(Menu, Object.assign({ open: Boolean(hoveredItem), anchorEl: submenuAnchorEl, placement: "right-start", onMouseEnter: handleSubmenuEnter, onMouseLeave: handleSubmenuLeave }, { children: _jsxs(SubmenuContainer, { children: [_jsx(ViewsSubmenu, { columns: getHoveredSubmenu(), allCurrentSelected: allCurrentSelected, someCurrentSelected: someCurrentSelected, onSelectAll: handleSelectAll, onReset: handleReset, onColumnToggle: toggleColumnSelection, onNestedItemToggle: toggleNestedItem, anchorEl: submenuAnchorEl, isModified: isSubmenuModified }), _jsx(SaveCustomViewBox, { children: _jsx(Tooltip, Object.assign({ title: "Limit reached. Delete a view to create a new one.", placement: "left", disableHoverListener: !shouldDimNewCustomView }, { children: _jsxs(SaveCustomViewInnerBox, Object.assign({ disabled: shouldDimNewCustomView, onClick: shouldDimNewCustomView ? undefined : handleSaveAsCustomView }, { children: [_jsx(Typography, Object.assign({ sx: { fontSize: 11, color: 'text.secondary' } }, { children: "Save as a custom view" })), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: 0.5 } }, { children: [_jsx("img", { src: bluePlusIcon, alt: "add", style: { width: 10, height: 10, opacity: shouldDimNewCustomView ? 0.5 : 1 } }), _jsx(Typography, Object.assign({ sx: { fontSize: 10, fontWeight: 600, color: shouldDimNewCustomView ? '#999' : '#1F88D0' } }, { children: "Custom View" }))] }))] })) })) }), _jsxs(ButtonsContainer, { children: [_jsx(Button, Object.assign({ variant: "text", onClick: handleCancel, sx: CancelButtonSx }, { children: "Cancel" })), _jsx(Button, Object.assign({ variant: "contained", onClick: handleOkay, sx: OkayButtonSx }, { children: "Okay" }))] })] }) })))] })));
|
|
147
168
|
}
|
|
148
169
|
export default React.memo(ViewsDropdown);
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { memo, useState } from 'react';
|
|
11
|
+
import { memo, useState, useEffect } from 'react';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
14
14
|
import { Icon, StyledButton } from '../../index.js';
|
|
@@ -39,6 +39,19 @@ function ViewsManager({ onViewChange, setIsViewVisible, setTableViews, tableView
|
|
|
39
39
|
onTableViewsChange === null || onTableViewsChange === void 0 ? void 0 : onTableViewsChange(newTableViews);
|
|
40
40
|
};
|
|
41
41
|
const customViews = externalCustomViews !== null && externalCustomViews !== void 0 ? externalCustomViews : internalCustomViews;
|
|
42
|
+
// Auto-select default template when custom views are loaded
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (customViews.length > 0) {
|
|
45
|
+
const defaultView = customViews.find((view) => view.default);
|
|
46
|
+
if (defaultView && selectedViewInfo.id === 'default') {
|
|
47
|
+
setSelectedViewInfo(defaultView);
|
|
48
|
+
if (defaultView.submenu) {
|
|
49
|
+
handleTableViewsChange(defaultView.submenu);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, [customViews]);
|
|
42
55
|
const handleCustomViewsChange = (newCustomViews) => {
|
|
43
56
|
setInternalCustomViews(newCustomViews);
|
|
44
57
|
onCustomViewsChange === null || onCustomViewsChange === void 0 ? void 0 : onCustomViewsChange(newCustomViews);
|
|
@@ -100,7 +113,7 @@ function ViewsManager({ onViewChange, setIsViewVisible, setTableViews, tableView
|
|
|
100
113
|
resetTableViews({ id: views[0], label: views[0] });
|
|
101
114
|
}
|
|
102
115
|
else {
|
|
103
|
-
const resetColumns =
|
|
116
|
+
const resetColumns = getColumnsByMode(mode, layoutData);
|
|
104
117
|
handleTableViewsChange(resetColumns);
|
|
105
118
|
}
|
|
106
119
|
}, tableViews: tableViews, setTableViews: handleTableViewsChange, onCreateCustomView: (useCurrentState) => handleOpenCreateDialog(useCurrentState), customViews: customViews, onEditCustomView: handleOpenEditDialog, defaultColumns: defaultColumns, setDefaultColumns: setDefaultColumns })] })) })), _jsx(CreateViewDialog, { open: isCreateDialogOpen, onClose: handleCloseCreateDialog, availableColumns: defaultColumns, defaultColumns: defaultColumns, onCreate: handleSaveView, editingView: editingView, onDelete: handleDeleteView, tableViews: shouldUseCurrentState ? defaultColumns : undefined })] }));
|
|
@@ -26,7 +26,7 @@ export const ColumnList = ({ selectedColumns, columnNames, allSelected, someSele
|
|
|
26
26
|
const isDate = isDateColumn(column.name);
|
|
27
27
|
const hasSubmenu = column.menuItems && column.menuItems.length > 0;
|
|
28
28
|
const { checked, indeterminate } = getColumnCheckState(column);
|
|
29
|
-
return (_jsxs(Reorder.Item, Object.assign({ value: column.name, drag: !isDate, dragListener: !isDate, whileDrag: { zIndex: 9999, boxShadow: '0 4px 12px rgba(0,0,0,0.15)' }, style: { listStyle: 'none', margin: 0, padding: 0, position: 'relative', zIndex: 1, backgroundColor: '#fff' }, onDragStart: (e) => {
|
|
29
|
+
return (_jsxs(Reorder.Item, Object.assign({ value: column.name, drag: !isDate, dragListener: !isDate, transition: { duration: 0 }, whileDrag: { zIndex: 9999, boxShadow: '0 4px 12px rgba(0,0,0,0.15)' }, style: { listStyle: 'none', margin: 0, padding: 0, position: 'relative', zIndex: 1, backgroundColor: '#fff' }, onDragStart: (e) => {
|
|
30
30
|
const target = e.target;
|
|
31
31
|
if (target.closest('[role="checkbox"]') ||
|
|
32
32
|
target.closest('input[type="checkbox"]') ||
|
|
@@ -6,14 +6,14 @@ import { blackRightArrowIcon } from '../../../../constants/index.js';
|
|
|
6
6
|
import { getColumnCheckState } from '../utils';
|
|
7
7
|
import { ResetHeaderBox, ResetCheckboxSx, ColumnItemsContainer, SubmenuPaper } from '../styles';
|
|
8
8
|
import { useNestedSubmenu } from '../hooks/useNestedSubmenu';
|
|
9
|
-
export const ViewsSubmenu = ({ columns, allCurrentSelected, someCurrentSelected, onSelectAll, onReset, onColumnToggle, onNestedItemToggle, anchorEl, }) => {
|
|
9
|
+
export const ViewsSubmenu = ({ columns, allCurrentSelected, someCurrentSelected, onSelectAll, onReset, onColumnToggle, onNestedItemToggle, anchorEl, isModified = false, }) => {
|
|
10
10
|
const { hoveredNestedColumn, nestedSubmenuAnchorEl, openNestedSubmenu, closeNestedSubmenu, cancelNestedClose } = useNestedSubmenu();
|
|
11
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ResetHeaderBox, { children: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ResetHeaderBox, { children: [_jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center', gap: 1 } }, { children: _jsx(Checkbox, { checked: allCurrentSelected, indeterminate: someCurrentSelected, onChange: (e) => {
|
|
12
|
+
e.stopPropagation();
|
|
13
|
+
onSelectAll();
|
|
14
|
+
}, onClick: (e) => {
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
}, sx: ResetCheckboxSx }) })), _jsx(Typography, Object.assign({ component: "button", onClick: (e) => {
|
|
17
17
|
e.stopPropagation();
|
|
18
18
|
onReset();
|
|
19
19
|
}, sx: {
|
|
@@ -24,6 +24,7 @@ export const ViewsSubmenu = ({ columns, allCurrentSelected, someCurrentSelected,
|
|
|
24
24
|
border: 'none',
|
|
25
25
|
cursor: 'pointer',
|
|
26
26
|
padding: 0,
|
|
27
|
+
opacity: isModified ? 1 : 0.5,
|
|
27
28
|
'&:hover': {
|
|
28
29
|
textDecoration: 'underline',
|
|
29
30
|
},
|
|
@@ -2,11 +2,14 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
import { getColumnsByMode } from '../utils';
|
|
3
3
|
export const useViewsManager = ({ mode, layoutData, initialTableViews, initialCustomViews }) => {
|
|
4
4
|
const [defaultColumns, setDefaultColumns] = useState(() => getColumnsByMode(mode, layoutData));
|
|
5
|
-
const [internalTableViews, setInternalTableViews] = useState(initialTableViews || []);
|
|
5
|
+
const [internalTableViews, setInternalTableViews] = useState(initialTableViews || getColumnsByMode(mode, layoutData) || []);
|
|
6
6
|
const [internalCustomViews, setInternalCustomViews] = useState(initialCustomViews || []);
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
setDefaultColumns(getColumnsByMode(mode, layoutData));
|
|
9
|
-
|
|
9
|
+
if (!initialTableViews && layoutData) {
|
|
10
|
+
setInternalTableViews(getColumnsByMode(mode, layoutData));
|
|
11
|
+
}
|
|
12
|
+
}, [mode, layoutData, initialTableViews]);
|
|
10
13
|
return {
|
|
11
14
|
defaultColumns,
|
|
12
15
|
setDefaultColumns,
|
|
@@ -5,8 +5,8 @@ export { default as CustomViews } from './CustomViews';
|
|
|
5
5
|
export { default as ViewsManager } from './ViewsManager';
|
|
6
6
|
export { default as ViewsDropdown } from './ViewsDropdown';
|
|
7
7
|
export { default as CreateViewDialog } from './CreateViewDialog';
|
|
8
|
-
export type { ViewMenuItem, ViewMode, CreateCustomViewDialogProps, LayoutSection, ColumnItem, FieldItem } from './types';
|
|
9
|
-
export { transformLayoutToColumns, getColumnsByMode, createCustomViewMenuItem, isDateColumn, getColumnCheckState } from './utils';
|
|
8
|
+
export type { ViewMenuItem, ViewMode, CreateCustomViewDialogProps, LayoutSection, ColumnItem, FieldItem, TemplateResponse, TemplatesListResponse } from './types';
|
|
9
|
+
export { transformLayoutToColumns, getColumnsByMode, createCustomViewMenuItem, setViewAsDefault, transformTemplatesToViewMenuItems, convertColumnsToLayoutSection, isDateColumn, getColumnCheckState } from './utils';
|
|
10
10
|
export { useSubmenuHover, useDialogPosition } from './hooks';
|
|
11
11
|
export { DIALOG_WIDTH, DIALOG_HEIGHT, MAX_CUSTOM_VIEWS, TEMPLATE_NAME_MAX_LENGTH } from './constants';
|
|
12
12
|
export { defaultViewList, advancedColumns, sheetColumns } from './data';
|
|
@@ -5,7 +5,7 @@ export { default as CustomViews } from './CustomViews';
|
|
|
5
5
|
export { default as ViewsManager } from './ViewsManager';
|
|
6
6
|
export { default as ViewsDropdown } from './ViewsDropdown';
|
|
7
7
|
export { default as CreateViewDialog } from './CreateViewDialog';
|
|
8
|
-
export { transformLayoutToColumns, getColumnsByMode, createCustomViewMenuItem, isDateColumn, getColumnCheckState } from './utils';
|
|
8
|
+
export { transformLayoutToColumns, getColumnsByMode, createCustomViewMenuItem, setViewAsDefault, transformTemplatesToViewMenuItems, convertColumnsToLayoutSection, isDateColumn, getColumnCheckState } from './utils';
|
|
9
9
|
export { useSubmenuHover, useDialogPosition } from './hooks';
|
|
10
10
|
export { DIALOG_WIDTH, DIALOG_HEIGHT, MAX_CUSTOM_VIEWS, TEMPLATE_NAME_MAX_LENGTH } from './constants';
|
|
11
11
|
export { defaultViewList, advancedColumns, sheetColumns } from './data';
|
|
@@ -8,6 +8,7 @@ export interface ViewMenuItem {
|
|
|
8
8
|
columns?: string[];
|
|
9
9
|
submenu?: ColumnViewProps[];
|
|
10
10
|
isCustom?: boolean;
|
|
11
|
+
default?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface FieldItem {
|
|
13
14
|
code: string;
|
|
@@ -31,12 +32,41 @@ export interface LayoutSection {
|
|
|
31
32
|
code: string;
|
|
32
33
|
columns: ColumnItem[];
|
|
33
34
|
}
|
|
35
|
+
export interface TemplateResponse {
|
|
36
|
+
id: string;
|
|
37
|
+
object: string;
|
|
38
|
+
master: boolean;
|
|
39
|
+
live_mode: boolean;
|
|
40
|
+
api_version: string;
|
|
41
|
+
feature_version: string;
|
|
42
|
+
created: number;
|
|
43
|
+
updated: number;
|
|
44
|
+
segment: string;
|
|
45
|
+
app: string;
|
|
46
|
+
service: string;
|
|
47
|
+
user: {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
name: string;
|
|
51
|
+
default: boolean;
|
|
52
|
+
layout: LayoutSection[];
|
|
53
|
+
}
|
|
54
|
+
export interface TemplatesListResponse {
|
|
55
|
+
object: string;
|
|
56
|
+
live_mode: boolean;
|
|
57
|
+
api_version: string;
|
|
58
|
+
feature_version: string;
|
|
59
|
+
count: number;
|
|
60
|
+
has_more: boolean;
|
|
61
|
+
templates: TemplateResponse[];
|
|
62
|
+
}
|
|
34
63
|
export interface CreateCustomViewDialogProps {
|
|
35
64
|
open: boolean;
|
|
36
65
|
onClose: () => void;
|
|
37
66
|
onCreate?: (data: {
|
|
38
67
|
name: string;
|
|
39
68
|
selectedColumns: ColumnViewProps[];
|
|
69
|
+
layout: LayoutSection;
|
|
40
70
|
}) => Promise<void>;
|
|
41
71
|
availableColumns?: ColumnViewProps[];
|
|
42
72
|
isLoading?: boolean;
|
|
@@ -48,6 +78,7 @@ export interface CreateCustomViewDialogProps {
|
|
|
48
78
|
} | null;
|
|
49
79
|
onDelete?: (viewId: string) => Promise<void>;
|
|
50
80
|
tableViews?: ColumnViewProps[];
|
|
81
|
+
mode?: ViewMode;
|
|
51
82
|
}
|
|
52
83
|
export interface ColumnCheckState {
|
|
53
84
|
checked: boolean;
|
|
@@ -63,10 +94,12 @@ export interface ViewsManagerProps {
|
|
|
63
94
|
onCreateCustomView?: (data: {
|
|
64
95
|
name: string;
|
|
65
96
|
selectedColumns: ColumnViewProps[];
|
|
97
|
+
layout: LayoutSection;
|
|
66
98
|
}) => Promise<void>;
|
|
67
99
|
onEditCustomView?: (viewId: string, data: {
|
|
68
100
|
name: string;
|
|
69
101
|
selectedColumns: ColumnViewProps[];
|
|
102
|
+
layout: LayoutSection;
|
|
70
103
|
}) => Promise<void>;
|
|
71
104
|
onDeleteCustomView?: (viewId: string) => Promise<void>;
|
|
72
105
|
mode?: ViewMode;
|
|
@@ -117,6 +150,7 @@ export interface ViewsSubmenuProps {
|
|
|
117
150
|
onColumnToggle: (columnName: string) => void;
|
|
118
151
|
onNestedItemToggle: (columnName: string, subItemName: string) => void;
|
|
119
152
|
anchorEl: HTMLElement | null;
|
|
153
|
+
isModified?: boolean;
|
|
120
154
|
}
|
|
121
155
|
export interface UseCreateViewDialogProps {
|
|
122
156
|
open: boolean;
|
|
@@ -7,7 +7,25 @@ export declare const transformLayoutToColumns: (layout: LayoutSection[], lang?:
|
|
|
7
7
|
export declare const getColumnsByMode: (mode: ViewMode, layoutData?: LayoutSection[]) => ColumnViewProps[];
|
|
8
8
|
export declare const isDateColumn: (name: string) => boolean;
|
|
9
9
|
export declare const getColumnCheckState: (column: ColumnViewProps) => ColumnCheckState;
|
|
10
|
-
export declare const createCustomViewMenuItem: (name: string, selectedColumns: ColumnViewProps[]) => ViewMenuItem;
|
|
10
|
+
export declare const createCustomViewMenuItem: (name: string, selectedColumns: ColumnViewProps[], isDefault?: boolean) => ViewMenuItem;
|
|
11
|
+
/**
|
|
12
|
+
* Set a view as default and ensure only one view is default at a time
|
|
13
|
+
*/
|
|
14
|
+
export declare const setViewAsDefault: (views: ViewMenuItem[], viewId: string) => ViewMenuItem[];
|
|
15
|
+
/**
|
|
16
|
+
* Transform API templates response to ViewMenuItem array
|
|
17
|
+
* Filters templates by mode and only shows the section matching the current mode
|
|
18
|
+
*/
|
|
19
|
+
export declare const transformTemplatesToViewMenuItems: (templates: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
default: boolean;
|
|
23
|
+
layout: LayoutSection[];
|
|
24
|
+
}>, mode?: ViewMode, lang?: string) => ViewMenuItem[];
|
|
25
|
+
/**
|
|
26
|
+
* Convert ColumnViewProps back to LayoutSection format for API requests
|
|
27
|
+
*/
|
|
28
|
+
export declare const convertColumnsToLayoutSection: (columns: ColumnViewProps[], mode: ViewMode, lang?: string) => LayoutSection;
|
|
11
29
|
/**
|
|
12
30
|
* Initialize columns for editing mode
|
|
13
31
|
*/
|
|
@@ -51,13 +51,71 @@ export const getColumnCheckState = (column) => {
|
|
|
51
51
|
indeterminate: selectedCount > 0 && selectedCount < column.menuItems.length,
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
-
export const createCustomViewMenuItem = (name, selectedColumns) => ({
|
|
54
|
+
export const createCustomViewMenuItem = (name, selectedColumns, isDefault = false) => ({
|
|
55
55
|
label: name,
|
|
56
56
|
id: `custom_${Date.now()}`,
|
|
57
57
|
columns: selectedColumns.map((col) => col.name),
|
|
58
58
|
submenu: selectedColumns,
|
|
59
59
|
isCustom: true,
|
|
60
|
+
default: isDefault,
|
|
60
61
|
});
|
|
62
|
+
/**
|
|
63
|
+
* Set a view as default and ensure only one view is default at a time
|
|
64
|
+
*/
|
|
65
|
+
export const setViewAsDefault = (views, viewId) => {
|
|
66
|
+
return views.map((view) => (Object.assign(Object.assign({}, view), { default: view.id === viewId })));
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Transform API templates response to ViewMenuItem array
|
|
70
|
+
* Filters templates by mode and only shows the section matching the current mode
|
|
71
|
+
*/
|
|
72
|
+
export const transformTemplatesToViewMenuItems = (templates, mode = 'sheet', lang = 'en') => {
|
|
73
|
+
return templates.map((template) => {
|
|
74
|
+
// Get columns for the specified mode
|
|
75
|
+
const section = template.layout.find((s) => s.code.toLowerCase() === mode.toLowerCase());
|
|
76
|
+
const columns = section ? transformLayoutToColumns([section], lang) : [];
|
|
77
|
+
return {
|
|
78
|
+
id: template.id,
|
|
79
|
+
label: template.name,
|
|
80
|
+
isCustom: true,
|
|
81
|
+
default: template.default,
|
|
82
|
+
columns: columns.map((col) => col.name),
|
|
83
|
+
submenu: columns,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Convert ColumnViewProps back to LayoutSection format for API requests
|
|
89
|
+
*/
|
|
90
|
+
export const convertColumnsToLayoutSection = (columns, mode, lang = 'en') => {
|
|
91
|
+
const columnItems = columns.map((col, index) => {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const fieldItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((field) => {
|
|
94
|
+
var _a;
|
|
95
|
+
return ({
|
|
96
|
+
code: field.name,
|
|
97
|
+
name: [
|
|
98
|
+
{
|
|
99
|
+
text: typeof field.label === 'string' ? field.label : field.name,
|
|
100
|
+
lang: lang || '',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
default: (_a = field.selected) !== null && _a !== void 0 ? _a : false,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
const columnLabel = typeof col.label === 'string' ? col.label : col.name;
|
|
107
|
+
return Object.assign({ code: col.name, name: [
|
|
108
|
+
{
|
|
109
|
+
text: columnLabel,
|
|
110
|
+
lang,
|
|
111
|
+
},
|
|
112
|
+
], order: index + 1, default: (_b = col.selected) !== null && _b !== void 0 ? _b : false }, (fieldItems && fieldItems.length > 0 && { fields: fieldItems }));
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
code: mode === 'advanced' ? 'Advanced' : 'Sheet',
|
|
116
|
+
columns: columnItems,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
61
119
|
/**
|
|
62
120
|
* Initialize columns for editing mode
|
|
63
121
|
*/
|
|
@@ -158,7 +216,8 @@ export const areAllColumnsSelected = (columns) => {
|
|
|
158
216
|
nonDateColumns.every((col) => {
|
|
159
217
|
var _a;
|
|
160
218
|
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
161
|
-
|
|
219
|
+
// For columns with menuItems, all items must be selected
|
|
220
|
+
return col.menuItems.every((item) => item.selected);
|
|
162
221
|
}
|
|
163
222
|
return col.selected;
|
|
164
223
|
}));
|
|
@@ -236,7 +295,8 @@ export const areAllCurrentColumnsSelected = (columns) => {
|
|
|
236
295
|
return columns.every((col) => {
|
|
237
296
|
var _a;
|
|
238
297
|
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
239
|
-
|
|
298
|
+
// For columns with menuItems, all items must be selected
|
|
299
|
+
return col.menuItems.every((item) => item.selected);
|
|
240
300
|
}
|
|
241
301
|
return col.selected;
|
|
242
302
|
});
|
|
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import type { CalenderMode, TableHeaderStatus, ColumnViewProps, TableMode, Timezone, SegmentCountry } from '../../types/index.js';
|
|
3
3
|
import { AvailableStatus } from '../StatusBar/type';
|
|
4
4
|
import { PartialExcept } from '../../types/index.js';
|
|
5
|
-
import type { ViewMenuItem } from './TableView/types';
|
|
5
|
+
import type { ViewMenuItem, LayoutSection } from './TableView/types';
|
|
6
6
|
type ViewsOptions = {
|
|
7
7
|
default: {};
|
|
8
8
|
developer: {};
|
|
@@ -49,10 +49,12 @@ export interface TableHeaderProps<IStatus extends TableHeaderStatus | TableHeade
|
|
|
49
49
|
onCreateCustomView?: (data: {
|
|
50
50
|
name: string;
|
|
51
51
|
selectedColumns: ColumnViewProps[];
|
|
52
|
+
layout: LayoutSection;
|
|
52
53
|
}) => Promise<void>;
|
|
53
54
|
onEditCustomView?: (viewId: string, data: {
|
|
54
55
|
name: string;
|
|
55
56
|
selectedColumns: ColumnViewProps[];
|
|
57
|
+
layout: LayoutSection;
|
|
56
58
|
}) => Promise<void>;
|
|
57
59
|
onDeleteCustomView?: (viewId: string) => Promise<void>;
|
|
58
60
|
viewMode?: 'advanced' | 'sheet';
|
|
@@ -15,6 +15,6 @@ import { ToolbarStyled, StyledBox, ActionsBox } from './style';
|
|
|
15
15
|
import WindowAppIcon from '../WindowAppIcon';
|
|
16
16
|
function Toolbar(_a) {
|
|
17
17
|
var { onMouseEnter, onMouseLeave, isMaximized, isHovered, children, rightActions, leftActions, title, icon } = _a, props = __rest(_a, ["onMouseEnter", "onMouseLeave", "isMaximized", "isHovered", "children", "rightActions", "leftActions", "title", "icon"]);
|
|
18
|
-
return (_jsx(ToolbarStyled, Object.assign({ onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, maximized: isMaximized, id: "toolbar", isHovered: isHovered }, props, { children: _jsxs(StyledBox, Object.assign({ className: "toolbar-wrapper" }, { children: [leftActions ? _jsx(ActionsBox, Object.assign({ className: "action-box" }, { children: leftActions })) : _jsx("div", {}), _jsx(WindowAppIcon, { title: title, icon: icon }), rightActions ? _jsx(ActionsBox, Object.assign({ className: "action-box" }, { children: rightActions })) : _jsx("div", {})] })) })));
|
|
18
|
+
return (_jsx(ToolbarStyled, Object.assign({ onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, maximized: isMaximized, id: "toolbar", isHovered: isHovered }, props, { children: _jsxs(StyledBox, Object.assign({ className: "toolbar-wrapper" }, { children: [leftActions ? _jsx(ActionsBox, Object.assign({ className: "action-box" }, { children: leftActions })) : _jsx("div", {}), _jsx(WindowAppIcon, { title: title, icon: icon }), rightActions ? (_jsx(ActionsBox, Object.assign({ sx: { justifyContent: 'flex-end' }, className: "action-box" }, { children: rightActions }))) : (_jsx("div", {}))] })) })));
|
|
19
19
|
}
|
|
20
20
|
export default memo(Toolbar);
|
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.371-test.1-test.2-test.3",
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.371-test.1-test.2-test.3-test.4-test.5-test.6-test.7",
|
|
5
|
+
"testVersion": 7,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|