@topconsultnpm/sdkui-react-beta 6.16.91 → 6.16.93

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.
@@ -16,6 +16,9 @@ interface ITMMessageBox extends ITMPopup {
16
16
  parentId?: string;
17
17
  onClose?: () => void;
18
18
  confirmOnEnter?: boolean;
19
+ showToppy?: boolean;
20
+ initialWidth?: string;
21
+ initialHeight?: string;
19
22
  }
20
23
  interface ITMExceptionBox extends ITMPopup {
21
24
  exception?: any;
@@ -24,6 +27,6 @@ declare class TMExceptionBoxManager {
24
27
  static show({ title, exception }: ITMExceptionBox): void;
25
28
  }
26
29
  declare class TMMessageBoxManager {
27
- static show({ title, buttons, onButtonClick, message, parentId, resizable, onClose, confirmOnEnter }: ITMMessageBox): void;
30
+ static show({ title, buttons, onButtonClick, message, parentId, resizable, onClose, confirmOnEnter, showToppy, initialHeight, initialWidth }: ITMMessageBox): void;
28
31
  }
29
32
  export { TMExceptionBoxManager, TMMessageBoxManager };
@@ -13,7 +13,6 @@ import TMLayoutContainer, { TMLayoutItem } from './TMLayout';
13
13
  import { Popup } from 'devextreme-react';
14
14
  import TMTabGroup, { TMTab } from './TMTab';
15
15
  import { DeviceType, TMDeviceProvider, useDeviceType } from './TMDeviceProvider';
16
- let TOOLBAR_HEIGHT = 38;
17
16
  export var ButtonNames;
18
17
  (function (ButtonNames) {
19
18
  ButtonNames["YES"] = "Yes";
@@ -171,14 +170,14 @@ const ResponsiveButton = styled(TMButton) `
171
170
  font-size: 7px !important;
172
171
  }
173
172
  `;
174
- const ResponsiveMessageBody = ({ message, isMobile, MessageToolbar }) => {
175
- return (_jsxs(ResponsiveMessageContainer, { children: [_jsxs(ResponsiveMessageContent, { "$isMobile": isMobile, children: [_jsx(ResponsiveToppyImage, { "$isMobile": isMobile, src: toppy, alt: "Toppy" }), _jsx(ResponsiveMessageText, { "$isMobile": isMobile, children: typeof message === 'string' ? _jsx(Message, { msg: message }) : message })] }), _jsx(MessageToolbar, {})] }));
173
+ const ResponsiveMessageBody = ({ message, isMobile, MessageToolbar, showToppy }) => {
174
+ return (_jsxs(ResponsiveMessageContainer, { children: [_jsxs(ResponsiveMessageContent, { "$isMobile": isMobile, children: [showToppy && _jsx(ResponsiveToppyImage, { "$isMobile": isMobile, src: toppy, alt: "Toppy" }), _jsx(ResponsiveMessageText, { "$isMobile": isMobile, children: typeof message === 'string' ? _jsx(Message, { msg: message }) : message })] }), _jsx(MessageToolbar, {})] }));
176
175
  };
177
- const TMMessageBox = ({ resizable = false, onButtonClick, title = 'TopMedia', message = '', buttons, onClose, confirmOnEnter = false }) => {
176
+ const TMMessageBox = ({ resizable = false, onButtonClick, title = 'TopMedia', message = '', buttons, onClose, confirmOnEnter = false, showToppy = true, initialWidth = 'clamp(100px, 90vw, 400px)', initialHeight = 'auto' }) => {
178
177
  let deviceType = useDeviceType();
179
178
  const isMobile = useMemo(() => { return deviceType === DeviceType.MOBILE; }, [deviceType]);
180
- const [initialWidth, setInitialWidth] = useState('clamp(100px, 90vw, 400px)');
181
- const [initialHeight, setInitialHeight] = useState('auto');
179
+ const [width, setWidth] = useState(initialWidth);
180
+ const [height, setHeight] = useState(initialHeight);
182
181
  const [isVisible, setIsVisible] = useState(true);
183
182
  const [btns, setBtns] = useState(buttons || []);
184
183
  useEffect(() => {
@@ -221,14 +220,14 @@ const TMMessageBox = ({ resizable = false, onButtonClick, title = 'TopMedia', me
221
220
  }, caption: SDKUI_Localizator.Cancel, showTooltip: false, color: 'error' })] }));
222
221
  };
223
222
  const handleResizeEnd = (e) => {
224
- setInitialWidth(e.width.toString());
225
- setInitialHeight(e.height.toString());
223
+ setWidth(e.width.toString());
224
+ setHeight(e.height.toString());
226
225
  };
227
- return (_jsx(Popup, { animation: undefined, visible: isVisible, showCloseButton: true, width: initialWidth, height: initialHeight, minHeight: 'clamp(100px, 20vh, 180px)', title: title, onHidden: () => { onClose?.(); setIsVisible(false); }, resizeEnabled: resizable, onResizeEnd: handleResizeEnd, wrapperAttr: { id: 'tm-messagebox-wrapper' }, onShown: () => {
226
+ return (_jsx(Popup, { animation: undefined, visible: isVisible, showCloseButton: true, width: width, height: height, minHeight: 'clamp(100px, 20vh, 180px)', title: title, onHidden: () => { onClose?.(); setIsVisible(false); }, resizeEnabled: resizable, onResizeEnd: handleResizeEnd, wrapperAttr: { id: 'tm-messagebox-wrapper' }, onShown: () => {
228
227
  const el = document.getElementById('tm-messagebox-wrapper');
229
228
  if (el)
230
229
  el.style.zIndex = '20000';
231
- }, children: _jsx(ResponsiveMessageBody, { message: message, isMobile: isMobile, MessageToolbar: MessageToolbar }) }));
230
+ }, children: _jsx(ResponsiveMessageBody, { message: message, isMobile: isMobile, MessageToolbar: MessageToolbar, showToppy: showToppy }) }));
232
231
  };
233
232
  const TMExceptionBox = ({ resizable = false, exception, title = `${SDK_Globals.appModule} v. ${SDK_Globals.appVersion}` }) => {
234
233
  const [isVisible, setIsVisible] = useState(true);
@@ -260,7 +259,7 @@ class TMExceptionBoxManager {
260
259
  }
261
260
  }
262
261
  class TMMessageBoxManager {
263
- static show({ title, buttons, onButtonClick, message, parentId, resizable, onClose, confirmOnEnter = false }) {
262
+ static show({ title, buttons, onButtonClick, message, parentId, resizable, onClose, confirmOnEnter = false, showToppy = true, initialHeight, initialWidth }) {
264
263
  let container = document.createElement('div');
265
264
  if (parentId) {
266
265
  const parent = document.getElementById(parentId);
@@ -275,7 +274,7 @@ class TMMessageBoxManager {
275
274
  document.body.appendChild(container);
276
275
  }
277
276
  const root = ReactDOM.createRoot(container);
278
- root.render(_jsx(TMDeviceProvider, { children: React.createElement(TMMessageBox, { title, buttons, onButtonClick, message, resizable, onClose, confirmOnEnter }) }));
277
+ root.render(_jsx(TMDeviceProvider, { children: React.createElement(TMMessageBox, { title, buttons, onButtonClick, message, resizable, onClose, confirmOnEnter, showToppy, initialHeight, initialWidth }) }));
279
278
  }
280
279
  }
281
280
  export { TMExceptionBoxManager, TMMessageBoxManager };
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { UserListCacheService } from '@topconsultnpm/sdk-ts-beta';
2
4
  import styled from 'styled-components';
5
+ import { TMColors } from '../../utils/theme';
3
6
  const Wrapper = styled.div `
4
7
  * {
5
8
  color: ${(props) => props.$isSelected && '#fff !important'};
@@ -23,6 +26,19 @@ const convertLinksToAnchors = (markup) => {
23
26
  return `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`;
24
27
  });
25
28
  };
29
+ const addMentionStyling = (input, usersName) => {
30
+ if (typeof input !== 'string' || input.trim().length === 0)
31
+ return input;
32
+ const mentionRegex = /@(\w+)/g;
33
+ return input.replace(mentionRegex, (_match, username) => {
34
+ if (usersName.includes(username)) {
35
+ return `<span style="color: ${TMColors.primary}; font-weight: bold;">${username}</span>`;
36
+ }
37
+ else {
38
+ return `@${username}`;
39
+ }
40
+ });
41
+ };
26
42
  const highlightText = (input, searchText) => {
27
43
  if (!searchText)
28
44
  return input;
@@ -44,8 +60,18 @@ const highlightText = (input, searchText) => {
44
60
  };
45
61
  const TMHtmlContentDisplay = (props) => {
46
62
  const { markup, searchText, isSelected } = props;
63
+ const [usersName, setUsersName] = useState([]);
64
+ useEffect(() => {
65
+ const getUserNames = async () => {
66
+ const userDescriptorList = await UserListCacheService.GetAllAsync();
67
+ const names = userDescriptorList.map(userDescriptor => userDescriptor.name).filter((name) => name !== undefined);
68
+ setUsersName(names);
69
+ };
70
+ getUserNames();
71
+ }, []);
47
72
  let updatedMarkup = markup.replace(/(\r\n|\n|\r)/g, '</br>');
48
73
  updatedMarkup = convertLinksToAnchors(updatedMarkup);
74
+ updatedMarkup = addMentionStyling(updatedMarkup, usersName);
49
75
  updatedMarkup = highlightText(updatedMarkup, searchText);
50
76
  return (_jsx(Wrapper, { "$isSelected": isSelected, children: _jsx("div", { dangerouslySetInnerHTML: { __html: updatedMarkup } }) }));
51
77
  };
@@ -841,9 +841,9 @@ const WfButtonStateHandler = ({ isWFDisabled }) => {
841
841
  return null; // Non renderizza elementi nel DOM
842
842
  };
843
843
  const TMDcmtPreviewWrapper = ({ currentDcmt, layoutMode, fromDTD, dcmtFile, deviceType, isVisible, onFileUpload, enableDragDropOverlay = false }) => {
844
- const { setPanelVisibilityById, toggleMaximize, isResizingActive, countVisibleLeafPanels, setToolbarButtonDisabled } = useTMPanelManagerContext();
844
+ const { setPanelVisibilityById, toggleMaximize, isResizingActive, countVisibleLeafPanels, panelVisibility } = useTMPanelManagerContext();
845
845
  const isMobile = deviceType === DeviceType.MOBILE;
846
846
  return (layoutMode === LayoutModes.Update ?
847
847
  _jsx(TMDcmtPreview, { isVisible: isVisible, onClosePanel: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, allowMaximize: !isMobile && countVisibleLeafPanels() > 1, onMaximizePanel: (!isMobile && countVisibleLeafPanels() > 1) ? () => toggleMaximize("tmDcmtPreview") : undefined, dcmtData: currentDcmt, isResizingActive: isResizingActive }) :
848
- _jsx(TMFileUploader, { onFileUpload: onFileUpload, onClose: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, isRequired: fromDTD?.archiveConstraint === ArchiveConstraints.ContentCompulsory && dcmtFile === null, defaultBlob: dcmtFile, deviceType: deviceType, isResizingActive: isResizingActive, enableDragDropOverlay: enableDragDropOverlay }));
848
+ _jsx(TMFileUploader, { onFileUpload: onFileUpload, onClose: (!isMobile && countVisibleLeafPanels() > 1) ? () => setPanelVisibilityById('tmDcmtPreview', false) : undefined, isRequired: fromDTD?.archiveConstraint === ArchiveConstraints.ContentCompulsory && dcmtFile === null, defaultBlob: dcmtFile, deviceType: deviceType, isResizingActive: isResizingActive, enableDragDropOverlay: panelVisibility['tmDcmtPreview'] && enableDragDropOverlay }));
849
849
  };
@@ -22,9 +22,10 @@ const TMDragDropOverlay = (props) => {
22
22
  e.preventDefault();
23
23
  setDragOver(false);
24
24
  const file = e.dataTransfer?.files?.[0];
25
- if (file)
25
+ if (file) {
26
26
  handleFile(file);
27
- refocusAfterFileInput();
27
+ refocusAfterFileInput();
28
+ }
28
29
  };
29
30
  window.addEventListener('dragenter', handleWindowDragEnter);
30
31
  window.addEventListener('dragover', handleWindowDragOver);
@@ -83,10 +83,10 @@ const TMFileUploader = ({ deviceType = DeviceType.DESKTOP, onClose, onFileUpload
83
83
  document.getElementById('fileInput')?.click();
84
84
  }, []);
85
85
  let content = !uploadedFile ?
86
- _jsx("div", { style: { display: 'flex', gap: 10, width: '100%', height: '100%' }, children: _jsxs(UploadContainer, { ref: uploaderRef, tabIndex: 0, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, style: { backgroundColor: dragOver ? '#76b1e6' : 'white' }, onDoubleClick: browseHandler, "$isRequired": isRequired, children: [_jsx("div", { style: { display: 'flex', gap: '10px', flexDirection: 'column', position: 'absolute', right: 5, top: 5 }, children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Sfoglia', color: isRequired && !uploadedFile ? 'error' : 'primary', onClick: browseHandler, icon: _jsx(IconFolderOpen, { fontSize: 22 }) }) }), _jsx("p", { style: { fontSize: '1.2rem', fontWeight: 'bold' }, children: deviceType === DeviceType.MOBILE ? 'Clicca per sfogliare il tuo file' : 'Trascina il tuo file o fai doppio click per sfogliarlo' }), isRequired && _jsxs("p", { style: { fontWeight: 'bold' }, children: [" ", SDKUI_Localizator.RequiredField, " "] })] }) }) :
86
+ _jsxs("div", { style: { display: 'flex', gap: 10, width: '100%', height: '100%' }, children: [_jsx(HiddenInput, { id: "fileInput", type: "file", onChange: handleInputChange }), _jsxs(UploadContainer, { ref: uploaderRef, tabIndex: 0, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, style: { backgroundColor: dragOver ? '#76b1e6' : 'white' }, onDoubleClick: browseHandler, "$isRequired": isRequired, children: [_jsx("div", { style: { display: 'flex', gap: '10px', flexDirection: 'column', position: 'absolute', right: 5, top: 5 }, children: _jsx(TMButton, { btnStyle: 'icon', caption: 'Sfoglia', color: isRequired && !uploadedFile ? 'error' : 'primary', onClick: browseHandler, icon: _jsx(IconFolderOpen, { fontSize: 22 }) }) }), _jsx("p", { style: { fontSize: '1.2rem', fontWeight: 'bold' }, children: deviceType === DeviceType.MOBILE ? 'Clicca per sfogliare il tuo file' : 'Trascina il tuo file o fai doppio click per sfogliarlo' }), isRequired && _jsxs("p", { style: { fontWeight: 'bold' }, children: [" ", SDKUI_Localizator.RequiredField, " "] })] })] }) :
87
87
  _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 10, width: '100%', height: '100%' }, children: [_jsxs("div", { style: { backgroundColor: 'white', padding: '5px 10px', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: TMColors.primaryColor }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 5 }, children: [_jsx("p", { children: "File name:" }), _jsxs("div", { style: { fontWeight: 'bold' }, children: [fileName, " ", _jsxs("span", { children: [" ", ` (${formatBytes(fileSize)})`, " "] })] })] }), uploadedFile && _jsx(TMButton, { btnStyle: 'icon', color: 'error', caption: 'Pulisci', onClick: () => clearFile(true), icon: _jsx(IconClear, { fontSize: 22 }) })] }), extensionHandler(fileExt) === FileExtensionHandler.READY_TO_SHOW ? _jsx(TMFileViewer, { fileBlob: uploadedFile, isResizingActive: isResizingActive }) :
88
88
  _jsx("div", { style: { backgroundColor: '#f6dbdb', padding: '5px 10px', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: TMColors.error }, children: _jsxs("div", { children: [" ", 'Anteprima non disponibile.', fileExt && _jsx("b", { children: ` (*.${fileExt})` })] }) })] });
89
- const innerContent = (_jsxs("div", { style: { width: '100%', height: '100%', padding: '2px', display: 'flex', flexDirection: 'column', gap: 10 }, children: [_jsx(HiddenInput, { id: "fileInput", type: "file", onChange: handleInputChange }), enableDragDropOverlay && _jsx(TMDragDropOverlay, { handleFile: handleFile, refocusAfterFileInput: refocusAfterFileInput }), content] }));
89
+ const innerContent = (_jsxs("div", { style: { width: '100%', height: '100%', padding: '2px', display: 'flex', flexDirection: 'column', gap: 10 }, children: [enableDragDropOverlay && _jsx(TMDragDropOverlay, { handleFile: handleFile, refocusAfterFileInput: refocusAfterFileInput }), content] }));
90
90
  return showTMPanel ? (_jsx(TMPanel, { ref: fileUploaderPanelRef, panelID: 'file-uploader-panel', title: SDKUI_Localizator.FileUpload, onBack: deviceType === DeviceType.MOBILE ? () => onClose?.() : undefined, toolbar: deviceType !== DeviceType.MOBILE ? (_jsx(StyledHeaderIcon, { onClick: onClose, "$color": 'white', children: _jsx(TMTooltip, { content: SDKUI_Localizator.Close, children: _jsx(IconCloseOutline, {}) }) })) : undefined, children: innerContent })) : (innerContent);
91
91
  };
92
92
  const UploadContainer = styled.div `
@@ -3,5 +3,5 @@ import { DcmtTypeDescriptor, FileDescriptor, FileFormats, LayoutModes, WorkingGr
3
3
  import { TMDataGridContextMenuItem } from '../../base/TMDataGrid';
4
4
  import { DcmtInfo, DcmtOperationTypes, DownloadModes, DownloadTypes, SearchResultContext } from '../../../ts';
5
5
  export declare const getSelectedDcmtsOrFocused: (selectedItems: Array<any>, focusedItem: any, fileFormat?: FileFormats) => DcmtInfo[];
6
- export declare const signatureInformationCallback: (inputDcmts: DcmtInfo[] | undefined) => Promise<void>;
6
+ export declare const signatureInformationCallback: (isMobile: boolean, inputDcmts: DcmtInfo[] | undefined) => Promise<void>;
7
7
  export declare const getCommandsMenuItems: (isMobile: boolean, dtd: DcmtTypeDescriptor | undefined, selectedItems: Array<any>, focusedItem: any, context: SearchResultContext, showFloatingBar: boolean, workingGroupContext: WorkingGroupDescriptor | undefined, showSearch: boolean, setShowFloatingBar: React.Dispatch<React.SetStateAction<boolean>>, openFormHandler: (layoutMode: LayoutModes) => void, downloadDcmtsAsync: (inputDcmts: DcmtInfo[] | undefined, downloadType: DownloadTypes, downloadMode: DownloadModes, onFileDownloaded?: (dcmtFile: File | undefined) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>) => Promise<void>, runOperationAsync: (inputDcmts: DcmtInfo[] | undefined, dcmtOperationType: DcmtOperationTypes, actionAfterOperationAsync?: () => Promise<void>) => Promise<void>, onRefreshSearchAsync: (() => Promise<void>) | undefined, onRefreshDataRowsAsync: (() => Promise<void>) | undefined, onRefreshAfterAddDcmtToFavs: (() => void) | undefined, confirmFormat: () => Promise<FileFormats>, confirmAttachments: (list: FileDescriptor[]) => Promise<string[] | undefined>, openTaskFormHandler: () => void, openDetailDcmtsFormHandler: (value: boolean) => void, openMasterDcmtsFormHandler: (value: boolean) => void, openBatchUpdateFormHandler: (value: boolean) => void, openExportForm: () => void, handleToggleSearch: () => void, handleSignApprove: () => void, openWGsCopyMoveForm?: ((mode: "copyToWgDraft" | "copyToWgArchivedDoc", dcmtTypeDescriptor: DcmtTypeDescriptor, documents: Array<DcmtInfo>) => void), openCommentFormCallback?: ((documents: Array<DcmtInfo>) => void), openEditPdf?: ((documents: Array<DcmtInfo>) => void), openAddDocumentForm?: () => void) => Array<TMDataGridContextMenuItem>;
@@ -24,7 +24,7 @@ export const getSelectedDcmtsOrFocused = (selectedItems, focusedItem, fileFormat
24
24
  }
25
25
  return [];
26
26
  };
27
- export const signatureInformationCallback = async (inputDcmts) => {
27
+ export const signatureInformationCallback = async (isMobile, inputDcmts) => {
28
28
  try {
29
29
  if (!inputDcmts || inputDcmts.length === 0) {
30
30
  ShowAlert({
@@ -56,7 +56,9 @@ export const signatureInformationCallback = async (inputDcmts) => {
56
56
  TMMessageBoxManager.show({
57
57
  title: SDKUI_Localizator.SignatureInformation,
58
58
  buttons: [ButtonNames.OK],
59
+ showToppy: false,
59
60
  resizable: true,
61
+ initialWidth: !isMobile ? '500px' : undefined,
60
62
  message: (_jsx("div", { style: { lineHeight: "1.4em", overflowY: "auto", maxHeight: "400px", paddingRight: "8px", boxSizing: "border-box" }, children: res.signers && res.signers.length > 0 ? (res.signers.map((signer, idx) => (_jsxs("div", { style: {
61
63
  border: "1px solid #ccc",
62
64
  borderRadius: "10px",
@@ -226,7 +228,7 @@ export const getCommandsMenuItems = (isMobile, dtd, selectedItems, focusedItem,
226
228
  text: SDKUI_Localizator.SignatureInformation,
227
229
  operationType: 'singleRow',
228
230
  disabled: disabledForSingleRow(selectedItems, focusedItem),
229
- onClick: () => signatureInformationCallback(getSelectedDcmtsOrFocused(selectedItems, focusedItem))
231
+ onClick: () => signatureInformationCallback(isMobile, getSelectedDcmtsOrFocused(selectedItems, focusedItem))
230
232
  },
231
233
  {
232
234
  icon: svgToString(_jsx(IconSignature, {})),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.16.91",
3
+ "version": "6.16.93",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",