@topconsultnpm/sdkui-react 6.19.0-dev2.50 → 6.19.0-dev2.52
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,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import { Popup } from 'devextreme-react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import TMLayoutContainer, { TMCard, TMLayoutItem } from './TMLayout';
|
|
@@ -40,11 +40,45 @@ const StyledModalContext = styled.div `
|
|
|
40
40
|
height: 100%;
|
|
41
41
|
`;
|
|
42
42
|
const TMModal = ({ resizable = true, expandable = false, isModal = true, title = '', toolbar, onClose, children, width = '100%', height = '100%', fontSize = FontSize.defaultFontSize, hidePopup = true, askClosingConfirm = false, showCloseButton = true }) => {
|
|
43
|
+
const popupRef = useRef(null);
|
|
43
44
|
const [initialWidth, setInitialWidth] = useState(width);
|
|
44
45
|
const [initialHeight, setInitialHeight] = useState(height);
|
|
45
46
|
const [showPopup, setShowPopup] = useState(false);
|
|
46
47
|
const [isResizing, setIsResizing] = useState(false);
|
|
47
48
|
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
49
|
+
// Dimensioni minime di default per il popup
|
|
50
|
+
const DEFAULT_MIN_WIDTH = 500;
|
|
51
|
+
const DEFAULT_MIN_HEIGHT = 400;
|
|
52
|
+
const [minWidth, setMinWidth] = useState(0);
|
|
53
|
+
const [minHeight, setMinHeight] = useState(0);
|
|
54
|
+
/**
|
|
55
|
+
* Gestore chiamato quando il popup viene mostrato.
|
|
56
|
+
* Calcola e imposta le dimensioni minime del popup in base allo spazio disponibile.
|
|
57
|
+
* Le dimensioni minime sono il valore più piccolo tra le dimensioni effettive del parent e le dimensioni minime di default
|
|
58
|
+
*/
|
|
59
|
+
const handleShown = () => {
|
|
60
|
+
// Usa requestAnimationFrame per attendere il completamento del rendering
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
if (popupRef.current && popupRef.current.instance) {
|
|
63
|
+
const instance = popupRef.current.instance();
|
|
64
|
+
if (instance) {
|
|
65
|
+
// Ottiene l'elemento content del popup
|
|
66
|
+
const element = instance.content();
|
|
67
|
+
if (element) {
|
|
68
|
+
const parentElement = element.parentElement;
|
|
69
|
+
if (parentElement) {
|
|
70
|
+
// Legge le dimensioni effettive del contenitore parent
|
|
71
|
+
const widthPx = parentElement.offsetWidth;
|
|
72
|
+
const heightPx = parentElement.offsetHeight;
|
|
73
|
+
// Imposta le dimensioni minime usando il valore più piccolo tra le dimensioni disponibili e quelle di default
|
|
74
|
+
setMinWidth(widthPx < DEFAULT_MIN_WIDTH ? widthPx : DEFAULT_MIN_WIDTH);
|
|
75
|
+
setMinHeight(heightPx < DEFAULT_MIN_HEIGHT ? heightPx : DEFAULT_MIN_HEIGHT);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
48
82
|
useEffect(() => {
|
|
49
83
|
setShowPopup(isModal);
|
|
50
84
|
}, [isModal]);
|
|
@@ -67,7 +101,7 @@ const TMModal = ({ resizable = true, expandable = false, isModal = true, title =
|
|
|
67
101
|
setShowPopup(false);
|
|
68
102
|
onClose && onClose();
|
|
69
103
|
};
|
|
70
|
-
return (_jsx(_Fragment, { children: isModal ? (_jsx(Popup, { showCloseButton: showCloseButton, animation: undefined, maxHeight: '95%', maxWidth: '95%', dragEnabled: !isResizing, resizeEnabled: resizable, width: expandable && isFullScreen ? '95%' : initialWidth, height: expandable && isFullScreen ? '95%' : initialHeight, title: title, visible: showPopup, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd, onHiding: onHiding, toolbarItems: expandable ? [
|
|
104
|
+
return (_jsx(_Fragment, { children: isModal ? (_jsx(Popup, { ref: popupRef, showCloseButton: showCloseButton, animation: undefined, minWidth: minWidth, minHeight: minHeight, maxHeight: '95%', maxWidth: '95%', dragEnabled: !isResizing, resizeEnabled: resizable, width: expandable && isFullScreen ? '95%' : initialWidth, height: expandable && isFullScreen ? '95%' : initialHeight, title: title, visible: showPopup, onShown: handleShown, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd, onHiding: onHiding, toolbarItems: expandable ? [
|
|
71
105
|
{
|
|
72
106
|
widget: 'dxButton',
|
|
73
107
|
location: 'after',
|
|
@@ -33,7 +33,7 @@ export const TMDataListItemChooserForm = (props) => {
|
|
|
33
33
|
if (!props.dataListId)
|
|
34
34
|
return [];
|
|
35
35
|
if (refreshCache)
|
|
36
|
-
DataListCacheService.
|
|
36
|
+
DataListCacheService.Remove();
|
|
37
37
|
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
|
38
38
|
let dataList = await DataListCacheService.GetAsync(props.dataListId);
|
|
39
39
|
TMSpinner.hide();
|