@topconsultnpm/sdkui-react-beta 6.7.102 → 6.7.103
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
2
3
|
import { Popup } from 'devextreme-react';
|
|
3
|
-
import { useState } from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import TMLayoutContainer, { TMCard, TMLayoutItem } from './TMLayout';
|
|
6
6
|
import { FontSize, TMColors } from '../../utils/theme';
|
|
7
7
|
const StyledModal = styled.div `
|
|
8
8
|
width: ${props => props.$width};
|
|
9
9
|
height: ${props => props.$height};
|
|
10
|
-
position: ${props => props.$isModal ? 'relative' : 'fixed'};
|
|
10
|
+
position: ${props => (props.$isModal ? 'relative' : 'fixed')};
|
|
11
11
|
background-color: white;
|
|
12
12
|
box-shadow: 2px 2px 10px #939393;
|
|
13
13
|
border-radius: 5px;
|
|
@@ -39,10 +39,25 @@ const StyledModalContext = styled.div `
|
|
|
39
39
|
height: 100%;
|
|
40
40
|
`;
|
|
41
41
|
const TMModal = ({ resizable = true, isModal = true, title = '', toolbar, onClose, children, width = '100%', height = '100%', fontSize = FontSize.defaultFontSize }) => {
|
|
42
|
+
const [initialWidth, setInitialWidth] = useState(width);
|
|
43
|
+
const [initialHeight, setInitialHeight] = useState(height);
|
|
42
44
|
const [showPopup, setShowPopup] = useState(true);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setInitialWidth(width);
|
|
48
|
+
setInitialHeight(height);
|
|
49
|
+
}, [width, height]);
|
|
50
|
+
const handleResizeStart = () => {
|
|
51
|
+
setIsResizing(true);
|
|
52
|
+
};
|
|
53
|
+
const handleResizeEnd = (e) => {
|
|
54
|
+
setIsResizing(false);
|
|
55
|
+
setInitialWidth(e.width.toString());
|
|
56
|
+
setInitialHeight(e.height.toString());
|
|
57
|
+
};
|
|
58
|
+
return (_jsx(_Fragment, { children: isModal ? (_jsx(Popup, { showCloseButton: true, animation: undefined, maxHeight: '95%', maxWidth: '95%', dragEnabled: !isResizing, resizeEnabled: resizable, width: initialWidth, height: initialHeight, title: title, visible: showPopup, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd, onHidden: () => {
|
|
59
|
+
setShowPopup(false);
|
|
60
|
+
onClose && onClose();
|
|
61
|
+
}, children: _jsxs(TMLayoutContainer, { children: [toolbar && (_jsx(TMLayoutItem, { height: "40px", children: _jsx(StyledModalToolbar, { children: toolbar }) })), _jsx(TMLayoutItem, { height: 'calc(100% - 50px)', children: _jsx(TMCard, { showBorder: false, padding: false, scrollY: true, children: children }) })] }) })) : (_jsxs(StyledModal, { "$isModal": isModal, className: "temp-modal", "$fontSize": fontSize, "$width": initialWidth, "$height": initialHeight, children: [toolbar ? _jsx(StyledModalToolbar, { children: toolbar }) : _jsx(_Fragment, {}), _jsx(StyledModalContext, { children: children })] })) }));
|
|
47
62
|
};
|
|
48
63
|
export default TMModal;
|