@tap-payments/os-micro-frontend-shared 0.1.367-test.1-test.2-test.3 → 0.1.367-test.1-test.2-test.3-test.4

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,7 +18,7 @@ import Toolbar, { StyledHeaderWrapperStyled } from '../../Toolbar';
18
18
  import { CloseIcon } from '../../ToolbarIcon';
19
19
  import { dragIcon, rightArrow, viewIcon } from '../../../constants/index.js';
20
20
  import { useWindowDimensions } from '../../../hooks/index.js';
21
- import { useSubmenuHover, useDialogPosition } from './hooks';
21
+ import { useSubmenuHover } from './hooks';
22
22
  import { DIALOG_WIDTH, DIALOG_HEIGHT, DATE_COLUMN_CONFIG, TEMPLATE_NAME_MAX_LENGTH } from './constants';
23
23
  import { isDateColumn, getColumnCheckState, initializeEditingColumns, initializeCreateColumns, resetColumnsToDefault, toggleColumn, toggleSubItem, toggleAllColumns, areAllColumnsSelected, areSomeColumnsSelected, isValidTemplateName, } from './utils';
24
24
  import { DialogContentWrapper, ScrollableContent, TitleSection, ColumnListContainer, SelectAllHeader, ColumnItemRow, DragIconWrapper, CheckboxWrapper, FooterBar, CreateButtonWrapper, SubmenuPaper, SubmenuItem, DeleteButton, CreateButton, NameTextField, checkboxSx, getDialogPaperStyle, dialogSx, } from './styles';
@@ -27,7 +27,6 @@ function CreateViewDialog({ open, onClose, onCreate, availableColumns = [], isLo
27
27
  const { height, width } = useWindowDimensions();
28
28
  const [templateName, setTemplateName] = useState('');
29
29
  const [selectedColumns, setSelectedColumns] = useState([]);
30
- const { position, resetPosition, updatePosition } = useDialogPosition(width, height, DIALOG_WIDTH, DIALOG_HEIGHT);
31
30
  const { hoveredColumn, anchorEl, openSubmenu, closeSubmenu, cancelClose } = useSubmenuHover();
32
31
  const dateColumn = DATE_COLUMN_CONFIG;
33
32
  useEffect(() => {
@@ -43,8 +42,7 @@ function CreateViewDialog({ open, onClose, onCreate, availableColumns = [], isLo
43
42
  setSelectedColumns([dateColumn, ...otherColumns]);
44
43
  setTemplateName('');
45
44
  }
46
- resetPosition();
47
- }, [availableColumns, open, editingView, resetPosition]);
45
+ }, [open, editingView, availableColumns]);
48
46
  const columnNames = useMemo(() => selectedColumns.map((col) => col.name), [selectedColumns]);
49
47
  const allSelected = useMemo(() => areAllColumnsSelected(selectedColumns), [selectedColumns]);
50
48
  const someSelected = useMemo(() => areSomeColumnsSelected(selectedColumns, allSelected), [selectedColumns, allSelected]);
@@ -84,7 +82,15 @@ function CreateViewDialog({ open, onClose, onCreate, availableColumns = [], isLo
84
82
  });
85
83
  if (!open)
86
84
  return null;
87
- return (_jsx(Draggable, Object.assign({ handle: "#draggable-dialog-title", cancel: '[class*="MuiDialogContent-root"]', position: position, onStop: (_, data) => updatePosition(data.x, data.y), bounds: { top: 10 } }, { children: _jsxs(Dialog, Object.assign({ disableEnforceFocus: true, open: open, onClose: onClose, hideBackdrop: true, PaperProps: { style: getDialogPaperStyle(DIALOG_WIDTH, DIALOG_HEIGHT) }, sx: dialogSx }, { children: [_jsx(StyledHeaderWrapperStyled, Object.assign({ id: "draggable-dialog-title", style: { cursor: 'move' } }, { children: _jsx(Toolbar, { isHovered: true, title: editingView ? 'Edit Custom View' : t('createCustomView') || 'Create Custom View', leftActions: _jsx(CloseIcon, { onClick: onClose }) }) })), _jsxs(DialogContentWrapper, { children: [_jsxs(ScrollableContent, { children: [_jsxs(TitleSection, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ sx: { fontSize: 24, fontWeight: 700, color: '#9F9F9F' } }, { children: "Custom" })), _jsx(Typography, Object.assign({ sx: { fontSize: 24, fontWeight: 700, color: '#20232B', lineHeight: 1.2 } }, { children: "View" }))] }), editingView && _jsx(DeleteButton, Object.assign({ onClick: handleDelete }, { children: "Delete View" }))] }), _jsx(Box, Object.assign({ sx: { mb: 3 } }, { children: _jsx(NameTextField, { fullWidth: true, label: _jsxs(Box, Object.assign({ component: "span" }, { children: ["Name", _jsx(Box, Object.assign({ component: "span", sx: { color: 'error.main' } }, { children: "*" }))] })), value: templateName, onChange: (e) => setTemplateName(e.target.value), inputProps: { maxLength: TEMPLATE_NAME_MAX_LENGTH }, size: "small", variant: "filled" }) })), _jsxs(ColumnListContainer, { children: [_jsxs(SelectAllHeader, Object.assign({ onClick: handleSelectAll }, { children: [_jsx(DragIconWrapper, { children: _jsx("img", { src: viewIcon, alt: "drag", style: { width: 16, height: 16, opacity: 0.5 } }) }), _jsx(CheckboxWrapper, { children: _jsx(Checkbox, { checked: allSelected, indeterminate: someSelected, size: "small", sx: checkboxSx }) }), _jsx(Typography, Object.assign({ sx: { flex: 1, fontSize: 13, fontWeight: 500, color: 'text.primary', ml: 0.75 } }, { children: "Select All" })), _jsx(Link, Object.assign({ component: "button", type: "button", onClick: (e) => {
85
+ return (_jsx(Draggable, Object.assign({ handle: "#draggable-dialog-title", cancel: '[class*="MuiDialogContent-root"]' }, { children: _jsxs(Dialog, Object.assign({ disableEnforceFocus: true, open: open, onClose: onClose, hideBackdrop: true, PaperProps: { style: getDialogPaperStyle(DIALOG_WIDTH, DIALOG_HEIGHT) }, sx: dialogSx, TransitionProps: {
86
+ timeout: 0,
87
+ }, slotProps: {
88
+ backdrop: {
89
+ sx: {
90
+ transition: 'none',
91
+ },
92
+ },
93
+ } }, { children: [_jsx(StyledHeaderWrapperStyled, Object.assign({ id: "draggable-dialog-title", style: { cursor: 'move' } }, { children: _jsx(Toolbar, { isHovered: true, title: editingView ? 'Edit Custom View' : t('createCustomView') || 'Create Custom View', leftActions: _jsx(CloseIcon, { onClick: onClose }) }) })), _jsxs(DialogContentWrapper, { children: [_jsxs(ScrollableContent, { children: [_jsxs(TitleSection, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ sx: { fontSize: 24, fontWeight: 700, color: '#9F9F9F' } }, { children: "Custom" })), _jsx(Typography, Object.assign({ sx: { fontSize: 24, fontWeight: 700, color: '#20232B', lineHeight: 1.2 } }, { children: "View" }))] }), editingView && _jsx(DeleteButton, Object.assign({ onClick: handleDelete }, { children: "Delete View" }))] }), _jsx(Box, Object.assign({ sx: { mb: 3 } }, { children: _jsx(NameTextField, { fullWidth: true, label: _jsxs(Box, Object.assign({ component: "span" }, { children: ["Name", _jsx(Box, Object.assign({ component: "span", sx: { color: 'error.main' } }, { children: "*" }))] })), value: templateName, onChange: (e) => setTemplateName(e.target.value), inputProps: { maxLength: TEMPLATE_NAME_MAX_LENGTH }, size: "small", variant: "filled" }) })), _jsxs(ColumnListContainer, { children: [_jsxs(SelectAllHeader, Object.assign({ onClick: handleSelectAll }, { children: [_jsx(DragIconWrapper, { children: _jsx("img", { src: viewIcon, alt: "drag", style: { width: 16, height: 16, opacity: 0.5 } }) }), _jsx(CheckboxWrapper, { children: _jsx(Checkbox, { checked: allSelected, indeterminate: someSelected, size: "small", sx: checkboxSx }) }), _jsx(Typography, Object.assign({ sx: { flex: 1, fontSize: 13, fontWeight: 500, color: 'text.primary', ml: 0.75 } }, { children: "Select All" })), _jsx(Link, Object.assign({ component: "button", type: "button", onClick: (e) => {
88
94
  e.stopPropagation();
89
95
  handleResetToDefault();
90
96
  }, underline: "none", sx: { fontSize: 13, fontWeight: 500, cursor: 'pointer', color: 'common.blue' } }, { children: "Reset to default" }))] })), _jsx(Box, Object.assign({ sx: { flex: 1, overflowY: 'auto', minHeight: 0 } }, { children: _jsx(Reorder.Group, Object.assign({ axis: "y", onReorder: handleReorder, values: columnNames, style: { listStyle: 'none', padding: 0, margin: 0 } }, { children: selectedColumns.map((column) => {
@@ -64,6 +64,8 @@ function ViewsManager({ onViewChange, setIsViewVisible, setTableViews, tableView
64
64
  const handleOpenCreateDialog = () => {
65
65
  setEditingView(null);
66
66
  setIsCreateDialogOpen(true);
67
+ // Close the dropdown menu when opening the popup
68
+ setDefaultViewElement(null);
67
69
  };
68
70
  const handleOpenEditDialog = (view) => {
69
71
  setEditingView(view);
@@ -94,7 +96,7 @@ function ViewsManager({ onViewChange, setIsViewVisible, setTableViews, tableView
94
96
  handleCustomViewsChange(updatedViews);
95
97
  yield (onDeleteCustomView === null || onDeleteCustomView === void 0 ? void 0 : onDeleteCustomView(viewId));
96
98
  });
97
- return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, Object.assign({ onClickAway: handleCloseViewDropdown }, { children: _jsxs(ViewWrapper, Object.assign({ "data-testid": "ViewsManager" }, { children: [_jsx(StyledButton, Object.assign({ title: t('tableView'), "data-testid": "ViewsManager_button", onClick: handleViewButtonClick }, { children: _jsx(Icon, { src: viewIcon, alt: "view", sx: { width: 14, height: 14 } }) })), _jsx(ViewsDropdown, { open: Boolean(defaultViewEl), anchorEl: anchorViewEl, setSelectedViewInfo: handleSelectedViewInfo, selectedViewInfo: selectedViewInfo, onSelect: (e) => setDefaultViewElement(defaultViewEl ? null : e.currentTarget), setViews: (views) => {
99
+ return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, Object.assign({ onClickAway: handleCloseViewDropdown }, { children: _jsxs(ViewWrapper, Object.assign({ sx: { width: '32px' }, "data-testid": "ViewsManager" }, { children: [_jsx(StyledButton, Object.assign({ title: t('tableView'), "data-testid": "ViewsManager_button", onClick: handleViewButtonClick }, { children: _jsx(Icon, { src: viewIcon, alt: "view", sx: { width: 14, height: 14 } }) })), _jsx(ViewsDropdown, { open: Boolean(defaultViewEl), anchorEl: anchorViewEl, setSelectedViewInfo: handleSelectedViewInfo, selectedViewInfo: selectedViewInfo, onSelect: (e) => setDefaultViewElement(defaultViewEl ? null : e.currentTarget), setViews: (views) => {
98
100
  if (resetTableViews) {
99
101
  resetTableViews({ id: views[0], label: views[0] });
100
102
  }
@@ -10,7 +10,7 @@ export declare const useSubmenuHover: () => {
10
10
  cancelClose: () => void;
11
11
  forceClose: () => void;
12
12
  };
13
- export declare const useDialogPosition: (width: number, height: number, dialogWidth: number, dialogHeight: number) => {
13
+ export declare const useDialogPosition: (dialogWidth: number, dialogHeight: number) => {
14
14
  position: {
15
15
  x: number;
16
16
  y: number;
@@ -44,17 +44,16 @@ export const useSubmenuHover = () => {
44
44
  forceClose,
45
45
  };
46
46
  };
47
- export const useDialogPosition = (width, height, dialogWidth, dialogHeight) => {
48
- const [position, setPosition] = useState({
49
- x: width / 2 - dialogWidth / 2,
50
- y: height / 2 - dialogHeight / 2,
51
- });
47
+ export const useDialogPosition = (dialogWidth, dialogHeight) => {
48
+ const [position, setPosition] = useState({ x: 0, y: 0 });
52
49
  const resetPosition = useCallback(() => {
50
+ const centerX = window.innerWidth / 2 - dialogWidth / 2;
51
+ const centerY = window.innerHeight / 2 - dialogHeight / 2;
53
52
  setPosition({
54
- x: width / 2 - dialogWidth / 2,
55
- y: height / 2 - dialogHeight / 2,
53
+ x: Math.max(0, centerX),
54
+ y: Math.max(0, centerY),
56
55
  });
57
- }, [width, height, dialogWidth, dialogHeight]);
56
+ }, [dialogWidth, dialogHeight]);
58
57
  const updatePosition = useCallback((x, y) => {
59
58
  setPosition({ x, y });
60
59
  }, []);
@@ -85,8 +85,15 @@ export declare const getDialogPaperStyle: (width: number, height: number) => {
85
85
  export declare const dialogSx: {
86
86
  backgroundColor: string;
87
87
  pointerEvents: string;
88
+ zIndex: number;
89
+ '& .MuiDialog-container': {
90
+ transition: string;
91
+ zIndex: number;
92
+ };
88
93
  '& .MuiDialog-paper': {
94
+ transition: string;
89
95
  pointerEvents: string;
96
+ zIndex: number;
90
97
  };
91
98
  };
92
99
  export declare const ResetHeaderBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -28,6 +28,8 @@ export const ViewWrapper = styled(Box)(({ theme }) => ({
28
28
  textTransform: 'capitalize',
29
29
  position: 'relative',
30
30
  transition: '0.5s',
31
+ paddingRight: 0,
32
+ marginRight: 0,
31
33
  '&:after': {
32
34
  content: '""',
33
35
  position: 'absolute',
@@ -43,6 +45,10 @@ export const ViewWrapper = styled(Box)(({ theme }) => ({
43
45
  paddingInlineEnd: '9px',
44
46
  zIndex: -1,
45
47
  },
48
+ '& > *:last-child': {
49
+ marginRight: 0,
50
+ paddingRight: 0,
51
+ },
46
52
  }));
47
53
  export const ListStyled = styled(Box)(({ theme }) => ({
48
54
  background: theme.palette.common.white,
@@ -57,6 +63,8 @@ export const ListStyled = styled(Box)(({ theme }) => ({
57
63
  export const DropdownStyled = styled(Box)(() => ({
58
64
  minWidth: 160,
59
65
  position: 'relative',
66
+ marginRight: 0,
67
+ paddingRight: 0,
60
68
  }));
61
69
  export const MenuItem = styled(Box, { shouldForwardProp: (props) => props !== 'addColumnViewEl' })(({ theme }) => ({
62
70
  padding: theme.spacing(1),
@@ -298,7 +306,7 @@ export const checkboxSx = {
298
306
  };
299
307
  export const getDialogPaperStyle = (width, height) => ({
300
308
  margin: 0,
301
- maxHeight: '90vh',
309
+ maxHeight: '100%',
302
310
  maxWidth: 'none',
303
311
  width,
304
312
  height,
@@ -309,8 +317,15 @@ export const getDialogPaperStyle = (width, height) => ({
309
317
  export const dialogSx = {
310
318
  backgroundColor: 'transparent',
311
319
  pointerEvents: 'none',
320
+ zIndex: 1300,
321
+ '& .MuiDialog-container': {
322
+ transition: 'none !important',
323
+ zIndex: 1300,
324
+ },
312
325
  '& .MuiDialog-paper': {
326
+ transition: 'none !important',
313
327
  pointerEvents: 'auto',
328
+ zIndex: 1300,
314
329
  },
315
330
  };
316
331
  export const ResetHeaderBox = styled(Box)(({ theme }) => ({
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.367-test.1-test.2-test.3",
5
- "testVersion": 3,
4
+ "version": "0.1.367-test.1-test.2-test.3-test.4",
5
+ "testVersion": 4,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",