@topconsultnpm/sdkui-react 6.20.0-dev1.11 → 6.20.0-dev1.111

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.
Files changed (177) hide show
  1. package/lib/assets/Toppy-help-center.png +0 -0
  2. package/lib/assets/headergradient.svg +87 -0
  3. package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +285 -28
  4. package/lib/components/NewComponents/ContextMenu/hooks.d.ts +8 -1
  5. package/lib/components/NewComponents/ContextMenu/hooks.js +80 -8
  6. package/lib/components/NewComponents/ContextMenu/index.d.ts +3 -0
  7. package/lib/components/NewComponents/ContextMenu/index.js +2 -0
  8. package/lib/components/NewComponents/ContextMenu/styles.d.ts +9 -1
  9. package/lib/components/NewComponents/ContextMenu/styles.js +157 -37
  10. package/lib/components/NewComponents/ContextMenu/types.d.ts +14 -1
  11. package/lib/components/NewComponents/ContextMenu/useLongPress.d.ts +21 -0
  12. package/lib/components/NewComponents/ContextMenu/useLongPress.js +112 -0
  13. package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +563 -112
  14. package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +21 -5
  15. package/lib/components/NewComponents/FloatingMenuBar/styles.js +210 -58
  16. package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +8 -2
  17. package/lib/components/base/TMAccordionNew.js +35 -14
  18. package/lib/components/base/TMCustomButton.js +61 -17
  19. package/lib/components/base/TMDataGrid.d.ts +7 -4
  20. package/lib/components/base/TMDataGrid.js +153 -11
  21. package/lib/components/base/TMDropDownMenu.js +19 -18
  22. package/lib/components/base/TMFileManager.d.ts +4 -3
  23. package/lib/components/base/TMFileManager.js +32 -24
  24. package/lib/components/base/TMFileManagerDataGridView.d.ts +3 -2
  25. package/lib/components/base/TMFileManagerDataGridView.js +1 -11
  26. package/lib/components/base/TMFileManagerThumbnailItems.d.ts +7 -1
  27. package/lib/components/base/TMFileManagerThumbnailItems.js +5 -2
  28. package/lib/components/base/TMFileManagerThumbnailsView.d.ts +17 -4
  29. package/lib/components/base/TMFileManagerThumbnailsView.js +18 -6
  30. package/lib/components/base/TMFileManagerUtils.d.ts +0 -12
  31. package/lib/components/base/TMListView.js +33 -15
  32. package/lib/components/base/TMPanel.d.ts +1 -1
  33. package/lib/components/base/TMPanel.js +1 -1
  34. package/lib/components/base/TMTreeView.d.ts +2 -1
  35. package/lib/components/base/TMTreeView.js +33 -26
  36. package/lib/components/choosers/TMDistinctValues.js +2 -2
  37. package/lib/components/choosers/TMInvoiceRetrieveFormats.js +1 -1
  38. package/lib/components/choosers/TMMetadataChooser.js +8 -1
  39. package/lib/components/choosers/TMOrderRetrieveFormats.js +1 -1
  40. package/lib/components/choosers/TMUserChooser.d.ts +0 -5
  41. package/lib/components/choosers/TMUserChooser.js +25 -45
  42. package/lib/components/editors/TMDateBox.js +18 -9
  43. package/lib/components/editors/TMLocalizedTextBox.d.ts +3 -1
  44. package/lib/components/editors/TMLocalizedTextBox.js +16 -14
  45. package/lib/components/editors/TMMetadataTextBox.d.ts +9 -0
  46. package/lib/components/editors/TMMetadataTextBox.js +92 -0
  47. package/lib/components/editors/TMMetadataValues.js +23 -5
  48. package/lib/components/editors/TMTextArea.js +18 -30
  49. package/lib/components/editors/TMTextBox.d.ts +1 -1
  50. package/lib/components/editors/TMTextBox.js +6 -3
  51. package/lib/components/editors/TMTextExpression.js +6 -91
  52. package/lib/components/features/archive/TMArchive.js +2 -2
  53. package/lib/components/features/assistant/TMToppyDraggableHelpCenter.d.ts +15 -0
  54. package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +460 -0
  55. package/lib/components/features/assistant/TMToppySpeechBubble.d.ts +11 -0
  56. package/lib/components/features/assistant/TMToppySpeechBubble.js +126 -0
  57. package/lib/components/features/documents/TMDcmtForm.d.ts +14 -2
  58. package/lib/components/features/documents/TMDcmtForm.js +457 -206
  59. package/lib/components/features/documents/TMDcmtPreview.js +44 -110
  60. package/lib/components/features/documents/TMDcmtTasks.js +9 -9
  61. package/lib/components/features/documents/TMMasterDetailDcmts.js +38 -53
  62. package/lib/components/features/documents/TMRelationViewer.d.ts +1 -1
  63. package/lib/components/features/documents/TMRelationViewer.js +2 -2
  64. package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
  65. package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +2 -2
  66. package/lib/components/features/search/TMSavedQuerySelector.js +72 -67
  67. package/lib/components/features/search/TMSearch.d.ts +3 -0
  68. package/lib/components/features/search/TMSearch.js +50 -11
  69. package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -0
  70. package/lib/components/features/search/TMSearchQueryPanel.js +29 -21
  71. package/lib/components/features/search/TMSearchResult.d.ts +3 -0
  72. package/lib/components/features/search/TMSearchResult.js +208 -250
  73. package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +3 -3
  74. package/lib/components/features/search/TMSearchResultsMenuItems.js +205 -169
  75. package/lib/components/features/search/TMSignSettingsForm.js +1 -1
  76. package/lib/components/features/search/TMSignatureInfoContent.d.ts +6 -0
  77. package/lib/components/features/search/TMSignatureInfoContent.js +140 -0
  78. package/lib/components/features/search/TMViewHistoryDcmt.js +2 -2
  79. package/lib/components/features/tasks/TMTaskForm.js +20 -1
  80. package/lib/components/features/tasks/TMTasksAgenda.d.ts +3 -1
  81. package/lib/components/features/tasks/TMTasksAgenda.js +48 -9
  82. package/lib/components/features/tasks/TMTasksCalendar.d.ts +2 -0
  83. package/lib/components/features/tasks/TMTasksCalendar.js +19 -7
  84. package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -2
  85. package/lib/components/features/tasks/TMTasksUtils.js +43 -36
  86. package/lib/components/features/tasks/TMTasksView.js +28 -19
  87. package/lib/components/features/workflow/TMWorkflowPopup.d.ts +33 -2
  88. package/lib/components/features/workflow/TMWorkflowPopup.js +139 -34
  89. package/lib/components/features/workflow/diagram/DiagramItemComponent.d.ts +2 -0
  90. package/lib/components/features/workflow/diagram/DiagramItemComponent.js +12 -7
  91. package/lib/components/features/workflow/diagram/DiagramItemForm.js +1 -1
  92. package/lib/components/features/workflow/diagram/RecipientList.js +3 -2
  93. package/lib/components/features/workflow/diagram/WFDiagram.d.ts +4 -0
  94. package/lib/components/features/workflow/diagram/WFDiagram.js +164 -13
  95. package/lib/components/forms/Login/LoginValidatorService.d.ts +2 -0
  96. package/lib/components/forms/Login/LoginValidatorService.js +7 -2
  97. package/lib/components/forms/Login/TMLoginForm.js +34 -6
  98. package/lib/components/forms/TMChooserForm.js +1 -1
  99. package/lib/components/grids/TMBlogsPost.js +56 -31
  100. package/lib/components/grids/TMRecentsManager.js +20 -10
  101. package/lib/components/index.d.ts +6 -3
  102. package/lib/components/index.js +6 -3
  103. package/lib/components/query/TMQueryEditor.d.ts +2 -1
  104. package/lib/components/query/TMQueryEditor.js +92 -92
  105. package/lib/components/settings/SettingsAppearance.d.ts +2 -1
  106. package/lib/components/settings/SettingsAppearance.js +99 -30
  107. package/lib/components/sidebar/TMHeader.js +7 -7
  108. package/lib/components/sidebar/TMSidebar.d.ts +0 -1
  109. package/lib/components/sidebar/TMSidebar.js +16 -44
  110. package/lib/components/sidebar/TMSidebarItem.js +34 -17
  111. package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -1
  112. package/lib/components/viewers/TMDataListItemViewer.js +35 -71
  113. package/lib/components/viewers/TMDataUserIdItemViewer.d.ts +8 -0
  114. package/lib/components/viewers/TMDataUserIdItemViewer.js +39 -0
  115. package/lib/css/tm-sdkui.css +1 -1
  116. package/lib/helper/SDKUI_Globals.d.ts +22 -0
  117. package/lib/helper/SDKUI_Globals.js +10 -1
  118. package/lib/helper/SDKUI_Localizator.d.ts +17 -1
  119. package/lib/helper/SDKUI_Localizator.js +167 -1
  120. package/lib/helper/TMCommandsContextMenu.d.ts +4 -2
  121. package/lib/helper/TMCommandsContextMenu.js +15 -4
  122. package/lib/helper/TMIcons.d.ts +4 -0
  123. package/lib/helper/TMIcons.js +13 -3
  124. package/lib/helper/TMPdfViewer.d.ts +8 -0
  125. package/lib/helper/TMPdfViewer.js +373 -0
  126. package/lib/helper/checkinCheckoutManager.d.ts +31 -1
  127. package/lib/helper/checkinCheckoutManager.js +112 -30
  128. package/lib/helper/devextremeCustomMessages.d.ts +30 -0
  129. package/lib/helper/devextremeCustomMessages.js +30 -0
  130. package/lib/helper/helpers.d.ts +28 -1
  131. package/lib/helper/helpers.js +130 -3
  132. package/lib/helper/index.d.ts +2 -0
  133. package/lib/helper/index.js +2 -0
  134. package/lib/helper/queryHelper.d.ts +1 -1
  135. package/lib/helper/queryHelper.js +33 -3
  136. package/lib/helper/workItemsHelper.d.ts +6 -0
  137. package/lib/helper/workItemsHelper.js +230 -0
  138. package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
  139. package/lib/hooks/useCheckInOutOperations.js +223 -0
  140. package/lib/hooks/useDataListItem.d.ts +12 -0
  141. package/lib/hooks/useDataListItem.js +132 -0
  142. package/lib/hooks/useDataUserIdItem.d.ts +10 -0
  143. package/lib/hooks/useDataUserIdItem.js +96 -0
  144. package/lib/hooks/useMetadataExpression.d.ts +19 -0
  145. package/lib/hooks/useMetadataExpression.js +99 -0
  146. package/lib/hooks/useSettingsFeedback.d.ts +11 -0
  147. package/lib/hooks/useSettingsFeedback.js +38 -0
  148. package/lib/hooks/useWorkflowApprove.d.ts +4 -0
  149. package/lib/hooks/useWorkflowApprove.js +14 -1
  150. package/lib/index.d.ts +1 -0
  151. package/lib/index.js +3 -2
  152. package/lib/services/platform_services.d.ts +3 -3
  153. package/lib/ts/types.d.ts +61 -1
  154. package/lib/utils/theme.d.ts +1 -1
  155. package/lib/utils/theme.js +1 -1
  156. package/package.json +7 -4
  157. package/lib/components/NewComponents/Notification/Notification.d.ts +0 -4
  158. package/lib/components/NewComponents/Notification/Notification.js +0 -60
  159. package/lib/components/NewComponents/Notification/NotificationContainer.d.ts +0 -8
  160. package/lib/components/NewComponents/Notification/NotificationContainer.js +0 -33
  161. package/lib/components/NewComponents/Notification/index.d.ts +0 -2
  162. package/lib/components/NewComponents/Notification/index.js +0 -2
  163. package/lib/components/NewComponents/Notification/styles.d.ts +0 -21
  164. package/lib/components/NewComponents/Notification/styles.js +0 -180
  165. package/lib/components/NewComponents/Notification/types.d.ts +0 -18
  166. package/lib/components/NewComponents/Notification/types.js +0 -1
  167. package/lib/components/base/TMContextMenu.d.ts +0 -25
  168. package/lib/components/base/TMContextMenu.js +0 -109
  169. package/lib/components/base/TMContextMenuOLD.d.ts +0 -26
  170. package/lib/components/base/TMContextMenuOLD.js +0 -56
  171. package/lib/components/base/TMFloatingToolbar.d.ts +0 -9
  172. package/lib/components/base/TMFloatingToolbar.js +0 -101
  173. package/lib/components/features/assistant/ToppyDraggableHelpCenter.d.ts +0 -30
  174. package/lib/components/features/assistant/ToppyDraggableHelpCenter.js +0 -482
  175. package/lib/components/features/assistant/ToppySpeechBubble.d.ts +0 -9
  176. package/lib/components/features/assistant/ToppySpeechBubble.js +0 -117
  177. package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
@@ -1,96 +1,17 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useState } from 'react';
3
- import { DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts';
2
+ import { useMemo, useState } from 'react';
4
3
  import { IconClear, IconColumns, SDKUI_Localizator, stringIsNullOrEmpty } from '../../helper';
5
- import { TMExceptionBoxManager } from '../base/TMPopUp';
6
4
  import { TMMetadataChooserForm } from '../choosers/TMMetadataChooser';
7
5
  import TMTextBox from './TMTextBox';
8
6
  import TMTextArea from './TMTextArea';
7
+ import { useMetadataExpression } from '../../hooks/useMetadataExpression';
9
8
  const TMTextExpression = (props) => {
10
- const [metadatas_Info_Source, setMetadatas_Info_Source] = useState([]);
9
+ const { metadatas_Info_Source, Expression_IDs2Names, Expression_Names2IDs } = useMetadataExpression({
10
+ qd: props.qd,
11
+ tid: props.tid
12
+ });
11
13
  const [showMetadataChooser, setShowMetadataChooser] = useState(false);
12
14
  const [showFormulaChooser, setShowFormulaChooser] = useState(false);
13
- useEffect(() => { MetadataInfos_Source_Get_Async(); }, [props.qd]);
14
- useEffect(() => { MetadataInfos_Source_GetByTID_Async(); }, [props.tid]);
15
- async function MetadataInfos_Source_Get_Async() {
16
- if (!props.qd?.select)
17
- return;
18
- let mhs_source = [];
19
- try {
20
- let dtd_source;
21
- let md_source;
22
- let tid_source = -1;
23
- let si;
24
- let sis = props.qd?.select?.slice();
25
- sis = sis.slice().sort((a, b) => a.tid - b.tid);
26
- for (si of sis) {
27
- if (si.tid == undefined || si.mid == undefined)
28
- continue;
29
- if (tid_source != si.tid) {
30
- dtd_source = await DcmtTypeListCacheService.GetAsync(si.tid, true);
31
- if (dtd_source == undefined)
32
- continue;
33
- tid_source = si.tid;
34
- }
35
- if (dtd_source?.metadata == undefined)
36
- continue;
37
- md_source = dtd_source.metadata.find(o => o.id == si.mid);
38
- if (md_source?.name == undefined)
39
- continue;
40
- if (tid_source == undefined)
41
- continue;
42
- mhs_source.push(new MetatadaHelper(si.mid, md_source.name));
43
- }
44
- }
45
- catch (e) {
46
- TMExceptionBoxManager.show({ exception: e, title: 'MetadataInfos_Source_Get_Async' });
47
- }
48
- setMetadatas_Info_Source(mhs_source);
49
- }
50
- async function MetadataInfos_Source_GetByTID_Async() {
51
- if (!props.tid)
52
- return;
53
- let mhs_source = [];
54
- try {
55
- let dtd_source = await DcmtTypeListCacheService.GetAsync(props.tid, true);
56
- if (dtd_source == undefined)
57
- return;
58
- if (dtd_source?.metadata == undefined)
59
- return;
60
- for (let md_source of dtd_source?.metadata) {
61
- if (md_source?.name == undefined)
62
- continue;
63
- if (md_source?.id == undefined)
64
- continue;
65
- mhs_source.push(new MetatadaHelper(md_source.id, md_source.name));
66
- }
67
- }
68
- catch (e) {
69
- TMExceptionBoxManager.show({ exception: e, title: 'MetadataInfos_Source_GetByTID_Async' });
70
- }
71
- setMetadatas_Info_Source(mhs_source);
72
- }
73
- function Expression_IDs2Names(expression) {
74
- if (expression == undefined)
75
- return expression;
76
- let temp = expression.slice();
77
- let mh;
78
- for (mh of metadatas_Info_Source) {
79
- temp = temp.replaceAll(`{@${mh.Mid}}`, `{@${mh.MetadataName}}`);
80
- }
81
- temp = temp.replaceAll("{@1}", "{@DID}");
82
- return temp;
83
- }
84
- function Expression_Names2IDs(expression) {
85
- if (expression == undefined)
86
- return expression;
87
- let temp = expression.slice();
88
- let mh;
89
- for (mh of metadatas_Info_Source)
90
- temp = temp.replaceAll(`{@${mh.MetadataName}}`, `{@${mh.Mid}}`);
91
- temp = temp.replaceAll("{@DID}", "{@1}");
92
- return temp;
93
- }
94
15
  const renderButtons = () => {
95
16
  let buttons = [];
96
17
  if (props.qd || props.tid)
@@ -167,12 +88,6 @@ const TMTextExpression = (props) => {
167
88
  :
168
89
  _jsx(TMTextArea, { buttons: renderButtons(), formulaItems: props.formulaItems, isModifiedWhen: props.value != props.valueOrig, label: props.label, rows: props.rows, resize: false, placeHolder: props.placeHolder, value: Expression_IDs2Names(props.value) ?? '', validationItems: props.validationItems, onValueChanged: (e) => { props.onValueChanged?.(Expression_Names2IDs(e.target.value)); } }), openMetadataChooseForm(), " "] }));
169
90
  };
170
- class MetatadaHelper {
171
- constructor(mid, metadataName) {
172
- this.Mid = mid;
173
- this.MetadataName = metadataName;
174
- }
175
- }
176
91
  export class FormulaItemHelper {
177
92
  constructor() {
178
93
  this.id = 0;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useEffect, useMemo, useState } from 'react';
3
3
  import Logo from '../../../assets/Toppy-generico.png';
4
4
  import { DcmtTypeListCacheService, LayoutModes, SDK_Localizator } from '@topconsultnpm/sdk-ts';
5
- import { IconTree, SDKUI_Globals, SDKUI_Localizator, IconRecentlyViewed, IconPreview, IconShow, IconBoard, IconDcmtTypeSys, removeMruTid } from '../../../helper';
5
+ import { IconTree, SDKUI_Globals, SDKUI_Localizator, IconRecentlyViewed, IconPreview, IconShow, IconBoard, IconDcmtTypeSys, removeMruTid, getMoreInfoTasksForDocument } from '../../../helper';
6
6
  import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
7
7
  import TMLayoutContainer from '../../base/TMLayout';
8
8
  import TMRecentsManager from '../../grids/TMRecentsManager';
@@ -77,7 +77,7 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
77
77
  if (onDcmtTypeSelect)
78
78
  onDcmtTypeSelect(tidToUse);
79
79
  passToSearch(tidToUse, outputMids);
80
- } : undefined, isSharedDcmt: isSharedArchive, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }, currentTID)
80
+ } : undefined, isSharedDcmt: isSharedArchive, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers, moreInfoTasks: getMoreInfoTasksForDocument(allTasks, currentTID, currentTID === inputTID ? inputDID : undefined) }, currentTID)
81
81
  :
82
82
  _jsx(TMPanel, { title: 'Archiviazione', allowMaximize: false, children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsx(StyledToppyTextContainer, { children: _jsx(StyledToppyText, { children: SDKUI_Localizator.DcmtTypeSelect }) }), _jsx(StyledToppyImage, { src: Logo, alt: 'Toppy' })] }) }), [currentTID, deviceType, mruTIDs, inputFile, currentInputMids, enableDragDropOverlay, isSharedArchive, allTasks]);
83
83
  const allInitialPanelVisibility = {
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ interface TMToppyDraggableHelpCenterProps {
3
+ /** Contenuto da visualizzare nella speech bubble */
4
+ content?: React.ReactNode;
5
+ /** Se true, renderizza Toppy nel document.body tramite Portal invece che nel parent */
6
+ usePortal?: boolean;
7
+ /** Allineamento iniziale del componente (destra o sinistra) */
8
+ align?: 'right' | 'left';
9
+ /** Visibilità del componente */
10
+ isVisible?: boolean;
11
+ /** Callback chiamato quando si clicca sull'immagine di Toppy */
12
+ onToppyImageClick?: () => void;
13
+ }
14
+ declare const TMToppyDraggableHelpCenter: (props: TMToppyDraggableHelpCenterProps) => import("react/jsx-runtime").JSX.Element;
15
+ export default TMToppyDraggableHelpCenter;
@@ -0,0 +1,460 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
+ import ReactDOM from 'react-dom';
4
+ import styled from 'styled-components';
5
+ import { DeviceType, useDeviceType } from '../../base/TMDeviceProvider';
6
+ import TMToppySpeechBubble from './TMToppySpeechBubble';
7
+ import ToppyHelpCenterImage from '../../../assets/Toppy-help-center.png';
8
+ import { SDKUI_Localizator } from '../../../helper';
9
+ import { IconWindowMaximize } from '../../../helper/TMIcons';
10
+ // Keyframes per l'animazione pulse sull'immagine quando Toppy è collassato
11
+ const pulseAnimation = `
12
+ @keyframes toppyImagePulse {
13
+ 0% {
14
+ transform: translateY(-2px) scale(1);
15
+ filter: drop-shadow(0 0 0 rgba(59, 130, 246, 0));
16
+ }
17
+ 25% {
18
+ transform: translateY(-2px) scale(1.08);
19
+ filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
20
+ }
21
+ 50% {
22
+ transform: translateY(-2px) scale(1);
23
+ filter: drop-shadow(0 0 12px rgba(118, 75, 162, 0.5));
24
+ }
25
+ 75% {
26
+ transform: translateY(-2px) scale(1.05);
27
+ filter: drop-shadow(0 0 6px rgba(240, 147, 251, 0.4));
28
+ }
29
+ 100% {
30
+ transform: translateY(-2px) scale(1);
31
+ filter: drop-shadow(0 0 0 rgba(59, 130, 246, 0));
32
+ }
33
+ }
34
+ `;
35
+ const TMToppyButton = styled.div.attrs((props) => ({
36
+ style: {
37
+ // Applica left/top come stili inline per evitare la generazione di troppe classi CSS
38
+ ...(props.$x !== undefined && props.$y !== undefined
39
+ ? {
40
+ left: `${props.$x}px`,
41
+ top: `${props.$y}px`,
42
+ bottom: 'auto',
43
+ right: 'auto',
44
+ }
45
+ : {}),
46
+ // Cursore applicato come stile inline
47
+ cursor: props.$isDragging ? 'grabbing' : 'grab',
48
+ },
49
+ })) `
50
+ ${pulseAnimation}
51
+ display: ${(props) => (props.$isVisible ? 'flex' : 'none')};
52
+ align-items: center;
53
+ justify-content: center;
54
+ position: ${(props) => props.$usePortal ? 'fixed' : 'absolute'};
55
+ /* Posizionamento di default quando non è draggato (x e y non sono definiti) */
56
+ ${(props) => props.$x === undefined || props.$y === undefined ?
57
+ `bottom: 0px;
58
+ ${props.$align === 'left' ? 'left: 10px;' : 'right: 0px;'};` : ''}
59
+ width: ${(props) => props.$isCollapsed ? '56px' : '110px'};
60
+ height: ${(props) => props.$isCollapsed ? '56px' : '110px'};
61
+ max-width: 100%;
62
+ max-height: 100%;
63
+ z-index: 2147483647;
64
+ background-color: ${(props) => props.$isCollapsed ? '#ffffff' : 'transparent'};
65
+ border: ${(props) => props.$isCollapsed ? '3px solid #3b82f6' : 'none'};
66
+ border-radius: ${(props) => props.$isCollapsed ? '50%' : '0'};
67
+ padding: 0;
68
+ outline: none;
69
+ user-select: none;
70
+ transition: background-color 0.3s ease, border 0.3s ease, border-radius 0.3s ease, box-shadow 0.3s ease, width 0.3s ease, height 0.3s ease;
71
+
72
+ img {
73
+ width: ${(props) => props.$isCollapsed ? '40px' : '110px'};
74
+ height: ${(props) => props.$isCollapsed ? '40px' : '110px'};
75
+ pointer-events: ${(props) => (props.$isMobile ? 'auto' : 'none')};
76
+ transform: ${(props) => props.$isCollapsed ? 'rotate(0deg)' : props.$align === 'left' ? 'rotate(20deg)' : 'rotate(-20deg)'};
77
+ transition: transform 0.3s ease, width 0.3s ease, height 0.3s ease, filter 0.3s ease;
78
+ object-fit: contain;
79
+ ${(props) => props.$isCollapsed && `animation: toppyImagePulse 2.5s ease-in-out infinite;`}
80
+ }
81
+ `;
82
+ /**
83
+ * Pulsante di espansione quando Toppy è minimizzato
84
+ */
85
+ const ExpandButton = styled.button `
86
+ position: absolute;
87
+ top: -8px;
88
+ right: -8px;
89
+ width: 24px;
90
+ height: 24px;
91
+ border-radius: 50%;
92
+ border: 2px solid rgba(255, 255, 255, 0.9);
93
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
94
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 20px rgba(118, 75, 162, 0.2);
95
+ cursor: pointer;
96
+ display: flex;
97
+ align-items: center;
98
+ justify-content: center;
99
+ transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
100
+ z-index: 10001;
101
+ color: white;
102
+ font-size: 14px;
103
+
104
+ &:hover {
105
+ background: linear-gradient(135deg, #764ba2 0%, #f093fb 100%);
106
+ box-shadow: 0 6px 20px rgba(118, 75, 162, 0.6), 0 0 30px rgba(240, 147, 251, 0.4);
107
+ border-color: rgba(255, 255, 255, 1);
108
+ transform: scale(1.1);
109
+ }
110
+
111
+ &:active {
112
+ transform: scale(0.95);
113
+ box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
114
+ }
115
+
116
+ &:focus {
117
+ outline: none;
118
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 0 3px rgba(102, 126, 234, 0.2);
119
+ }
120
+ `;
121
+ /**
122
+ * Overlay trasparente per bloccare le interazioni durante il drag
123
+ * Previene problemi di performance con iframe e altri elementi interattivi
124
+ */
125
+ const DragOverlay = styled.div `
126
+ position: fixed;
127
+ top: 0;
128
+ left: 0;
129
+ right: 0;
130
+ bottom: 0;
131
+ z-index: 2147483646;
132
+ cursor: grabbing;
133
+ `;
134
+ const TMToppyDraggableHelpCenter = (props) => {
135
+ const { content, usePortal, align = 'right', isVisible = true, onToppyImageClick } = props;
136
+ // Get the current device type (e.g., mobile, tablet, desktop) using a custom hook.
137
+ const deviceType = useDeviceType();
138
+ // This avoids unnecessary re-renders by only recalculating when deviceType changes.
139
+ const isMobile = useMemo(() => { return deviceType === DeviceType.MOBILE; }, [deviceType]);
140
+ // Ref per il contenitore principale
141
+ const toppyButtonRef = useRef(null);
142
+ // Ref per la speech bubble per calcolare le sue dimensioni
143
+ const bubbleRef = useRef(null);
144
+ // Dimensioni della bubble (aggiornate dinamicamente)
145
+ const bubbleDimensions = useRef({ width: 0, height: 0 });
146
+ // Posizione corrente del componente (null = posizione di default)
147
+ const [position, setPosition] = useState(null);
148
+ // Stato per tracciare se il componente è in fase di trascinamento
149
+ const [isDragging, setIsDragging] = useState(false);
150
+ // Stato per controllare se il componente è collassato o espanso
151
+ const [isCollapsed, setIsCollapsed] = useState(false);
152
+ // Refs per gestire il drag
153
+ const dragStartPos = useRef(null);
154
+ const dragOffset = useRef(null);
155
+ const hasMoved = useRef(false);
156
+ // Ref per tracciare il dragging dell'ExpandButton
157
+ const isExpandButtonDraggingRef = useRef(false);
158
+ const expandButtonMouseDownPosRef = useRef(null);
159
+ // Soglia minima di movimento in pixel per attivare il drag
160
+ const DRAG_THRESHOLD = 5;
161
+ // Calcola le dimensioni della bubble quando il contenuto cambia
162
+ useEffect(() => {
163
+ if (bubbleRef.current) {
164
+ const rect = bubbleRef.current.getBoundingClientRect();
165
+ bubbleDimensions.current = { width: rect.width, height: rect.height };
166
+ }
167
+ }, [content, isCollapsed]);
168
+ // Handler per l'inizio del drag (mouse)
169
+ const handleMouseDown = (e) => {
170
+ if (isMobile)
171
+ return;
172
+ e.preventDefault();
173
+ const rect = toppyButtonRef.current?.getBoundingClientRect();
174
+ if (!rect)
175
+ return;
176
+ // Salva la posizione iniziale del mouse e l'offset rispetto al componente
177
+ dragStartPos.current = { x: e.clientX, y: e.clientY };
178
+ dragOffset.current = {
179
+ x: e.clientX - rect.left,
180
+ y: e.clientY - rect.top,
181
+ };
182
+ hasMoved.current = false;
183
+ // Aggiungi listener globali per il movimento e il rilascio
184
+ document.addEventListener('mousemove', handleDragMove);
185
+ document.addEventListener('mouseup', handleDragEnd);
186
+ };
187
+ // Handler per l'inizio del drag (touch)
188
+ const handleTouchStart = (e) => {
189
+ if (!isMobile)
190
+ return;
191
+ const touch = e.touches[0];
192
+ if (!touch)
193
+ return;
194
+ const rect = toppyButtonRef.current?.getBoundingClientRect();
195
+ if (!rect)
196
+ return;
197
+ // Salva la posizione iniziale del touch e l'offset rispetto al componente
198
+ dragStartPos.current = { x: touch.clientX, y: touch.clientY };
199
+ dragOffset.current = {
200
+ x: touch.clientX - rect.left,
201
+ y: touch.clientY - rect.top,
202
+ };
203
+ hasMoved.current = false;
204
+ // Aggiungi listener globali per il movimento e il rilascio
205
+ document.addEventListener('touchmove', handleDragMove, { passive: false });
206
+ document.addEventListener('touchend', handleDragEnd);
207
+ };
208
+ // Handler unificato per il movimento durante il drag (mouse e touch)
209
+ const handleDragMove = (e) => {
210
+ if (!dragStartPos.current || !dragOffset.current || !toppyButtonRef.current)
211
+ return;
212
+ // Estrae le coordinate dal tipo di evento appropriato
213
+ const clientX = 'touches' in e ? e.touches[0]?.clientX : e.clientX;
214
+ const clientY = 'touches' in e ? e.touches[0]?.clientY : e.clientY;
215
+ if (clientX === undefined || clientY === undefined)
216
+ return;
217
+ // Calcola la distanza dal punto iniziale
218
+ const deltaX = clientX - dragStartPos.current.x;
219
+ const deltaY = clientY - dragStartPos.current.y;
220
+ const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
221
+ // Attiva il drag solo se il movimento supera la soglia
222
+ if (!hasMoved.current && distance < DRAG_THRESHOLD)
223
+ return;
224
+ if (!hasMoved.current) {
225
+ hasMoved.current = true;
226
+ setIsDragging(true);
227
+ }
228
+ // Previeni lo scroll durante il drag (solo per touch)
229
+ if ('touches' in e) {
230
+ e.preventDefault();
231
+ }
232
+ // Calcola la nuova posizione
233
+ let newX = clientX - dragOffset.current.x;
234
+ let newY = clientY - dragOffset.current.y;
235
+ // Se non usa portal, converti le coordinate da viewport a relative al parent
236
+ if (!usePortal) {
237
+ const parentElement = toppyButtonRef.current.offsetParent;
238
+ if (parentElement) {
239
+ const parentRect = parentElement.getBoundingClientRect();
240
+ newX -= parentRect.left;
241
+ newY -= parentRect.top;
242
+ }
243
+ }
244
+ // Ottieni le dimensioni del componente
245
+ const componentRect = toppyButtonRef.current.getBoundingClientRect();
246
+ const componentWidth = componentRect.width;
247
+ const componentHeight = componentRect.height;
248
+ // Limiti del parent considerando anche la bubble
249
+ let maxX = 0;
250
+ let maxY = 0;
251
+ let minX = 0;
252
+ let minY = 0;
253
+ // Considera le dimensioni della bubble per i limiti solo se non è collassato
254
+ const bubbleWidth = isCollapsed ? 0 : (bubbleDimensions.current.width || 0);
255
+ const bubbleHeight = isCollapsed ? 0 : (bubbleDimensions.current.height || 0);
256
+ // Offset dell'ExpandButton quando Toppy è collassato (top: -8px, right: -8px)
257
+ const expandButtonOffset = isCollapsed ? 8 : 0;
258
+ if (usePortal) {
259
+ // Se usa portal, i limiti sono quelli della viewport
260
+ // Limite superiore: deve lasciare spazio per la bubble sopra o per l'ExpandButton se collassato
261
+ minY = isCollapsed ? expandButtonOffset : bubbleHeight;
262
+ // Limite inferiore: il componente non può uscire dalla viewport
263
+ maxY = window.innerHeight - componentHeight;
264
+ // Limiti orizzontali dipendono dall'allineamento della bubble
265
+ if (align === 'right') {
266
+ // Bubble a sinistra del componente: serve spazio a sinistra
267
+ minX = Math.max(0, bubbleWidth - componentWidth);
268
+ // Quando collassato, l'ExpandButton sporge a destra di 8px
269
+ maxX = window.innerWidth - componentWidth - expandButtonOffset;
270
+ }
271
+ else {
272
+ // Bubble a destra del componente: serve spazio a destra
273
+ minX = 0;
274
+ maxX = window.innerWidth - Math.max(componentWidth, bubbleWidth) - expandButtonOffset;
275
+ }
276
+ }
277
+ else {
278
+ // Se non usa portal, le coordinate devono essere relative al parent
279
+ const parentElement = toppyButtonRef.current.offsetParent;
280
+ if (parentElement) {
281
+ // Usa le dimensioni del parent come riferimento
282
+ const parentWidth = parentElement.clientWidth;
283
+ const parentHeight = parentElement.clientHeight;
284
+ // Limite superiore: deve lasciare spazio per la bubble sopra o per l'ExpandButton se collassato
285
+ minY = isCollapsed ? expandButtonOffset : bubbleHeight;
286
+ // Limite inferiore: il componente non può uscire dal parent
287
+ maxY = parentHeight - componentHeight;
288
+ // Limiti orizzontali dipendono dall'allineamento della bubble
289
+ if (align === 'right') {
290
+ // Bubble a sinistra del componente: serve spazio a sinistra
291
+ minX = Math.max(0, bubbleWidth - componentWidth);
292
+ // Quando collassato, l'ExpandButton sporge a destra di 8px
293
+ maxX = parentWidth - componentWidth - expandButtonOffset;
294
+ }
295
+ else {
296
+ // Bubble a destra del componente: serve spazio a destra
297
+ minX = 0;
298
+ maxX = parentWidth - Math.max(componentWidth, bubbleWidth) - expandButtonOffset;
299
+ }
300
+ }
301
+ }
302
+ // Applica i limiti
303
+ newX = Math.max(minX, Math.min(newX, maxX));
304
+ newY = Math.max(minY, Math.min(newY, maxY));
305
+ setPosition({ x: newX, y: newY });
306
+ };
307
+ // Handler unificato per il rilascio del drag (mouse e touch)
308
+ const handleDragEnd = () => {
309
+ dragStartPos.current = null;
310
+ dragOffset.current = null;
311
+ setIsDragging(false);
312
+ // Rimuovi tutti i listener globali
313
+ document.removeEventListener('mousemove', handleDragMove);
314
+ document.removeEventListener('mouseup', handleDragEnd);
315
+ document.removeEventListener('touchmove', handleDragMove);
316
+ document.removeEventListener('touchend', handleDragEnd);
317
+ };
318
+ // Handler per il doppio click (collassa/espande Toppy su desktop)
319
+ const toggleCollapse = () => {
320
+ setIsCollapsed(prev => {
321
+ const newIsCollapsed = !prev;
322
+ // Se stiamo espandendo (da collassato a espanso), dobbiamo verificare i limiti
323
+ if (!newIsCollapsed && position && toppyButtonRef.current && content) {
324
+ // Usa setTimeout per permettere al DOM di aggiornarsi con le nuove dimensioni
325
+ setTimeout(() => {
326
+ if (!toppyButtonRef.current)
327
+ return;
328
+ // Dimensioni espanse del componente (110px come da styled-component)
329
+ const expandedSize = 110;
330
+ // Ottieni le dimensioni della bubble (usa valori di default se non disponibili)
331
+ const bubbleWidth = bubbleDimensions.current.width || 250;
332
+ const bubbleHeight = bubbleDimensions.current.height || 100;
333
+ let newX = position.x;
334
+ let newY = position.y;
335
+ let needsUpdate = false;
336
+ if (usePortal) {
337
+ // Limiti della viewport considerando la bubble
338
+ const minY = bubbleHeight;
339
+ const maxY = window.innerHeight - expandedSize;
340
+ let minX;
341
+ let maxX;
342
+ if (align === 'right') {
343
+ minX = Math.max(0, bubbleWidth - expandedSize);
344
+ maxX = window.innerWidth - expandedSize;
345
+ }
346
+ else {
347
+ minX = 0;
348
+ maxX = window.innerWidth - Math.max(expandedSize, bubbleWidth);
349
+ }
350
+ // Verifica e correggi la posizione
351
+ if (newX < minX) {
352
+ newX = minX;
353
+ needsUpdate = true;
354
+ }
355
+ if (newX > maxX) {
356
+ newX = maxX;
357
+ needsUpdate = true;
358
+ }
359
+ if (newY < minY) {
360
+ newY = minY;
361
+ needsUpdate = true;
362
+ }
363
+ if (newY > maxY) {
364
+ newY = maxY;
365
+ needsUpdate = true;
366
+ }
367
+ }
368
+ else {
369
+ // Limiti del parent
370
+ const offsetParent = toppyButtonRef.current.offsetParent;
371
+ if (offsetParent) {
372
+ const minY = bubbleHeight;
373
+ const maxY = offsetParent.clientHeight - expandedSize;
374
+ let minX;
375
+ let maxX;
376
+ if (align === 'right') {
377
+ minX = Math.max(0, bubbleWidth - expandedSize);
378
+ maxX = offsetParent.clientWidth - expandedSize;
379
+ }
380
+ else {
381
+ minX = 0;
382
+ maxX = offsetParent.clientWidth - Math.max(expandedSize, bubbleWidth);
383
+ }
384
+ // Verifica e correggi la posizione
385
+ if (newX < minX) {
386
+ newX = minX;
387
+ needsUpdate = true;
388
+ }
389
+ if (newX > maxX) {
390
+ newX = maxX;
391
+ needsUpdate = true;
392
+ }
393
+ if (newY < minY) {
394
+ newY = minY;
395
+ needsUpdate = true;
396
+ }
397
+ if (newY > maxY) {
398
+ newY = maxY;
399
+ needsUpdate = true;
400
+ }
401
+ }
402
+ }
403
+ // Aggiorna la posizione solo se necessario
404
+ if (needsUpdate) {
405
+ setPosition({ x: newX, y: newY });
406
+ }
407
+ }, 50); // Piccolo delay per permettere l'aggiornamento delle dimensioni
408
+ }
409
+ onToppyImageClick?.();
410
+ return newIsCollapsed;
411
+ });
412
+ };
413
+ // Cleanup degli event listener al dismount
414
+ useEffect(() => {
415
+ return () => {
416
+ document.removeEventListener('mousemove', handleDragMove);
417
+ document.removeEventListener('mouseup', handleDragEnd);
418
+ document.removeEventListener('touchmove', handleDragMove);
419
+ document.removeEventListener('touchend', handleDragEnd);
420
+ };
421
+ }, []);
422
+ // Reset della posizione quando cambia la dimensione della finestra/parent
423
+ // Questo evita che Toppy rimanga nascosto oltre i limiti dopo un resize
424
+ useEffect(() => {
425
+ const handleResize = () => {
426
+ // Resetta alla posizione iniziale (bottom-right o bottom-left in base ad align)
427
+ setPosition(null);
428
+ };
429
+ window.addEventListener('resize', handleResize);
430
+ return () => {
431
+ window.removeEventListener('resize', handleResize);
432
+ };
433
+ }, []);
434
+ const toppyContent = (_jsxs(_Fragment, { children: [isDragging && _jsx(DragOverlay, {}), _jsxs(TMToppyButton, { ref: toppyButtonRef, "$align": align, "$isDragging": isDragging, "$isVisible": isVisible, "$isCollapsed": isCollapsed, "$isMobile": isMobile, "$usePortal": usePortal, onContextMenu: (e) => e.preventDefault(), onMouseDown: !isMobile ? handleMouseDown : undefined, onTouchStart: isMobile ? handleTouchStart : undefined, onDoubleClick: !isMobile ? toggleCollapse : undefined, "$x": position?.x, "$y": position?.y, children: [(content && !isCollapsed) && _jsx(TMToppySpeechBubble, { ref: bubbleRef, align: align, onClose: toggleCollapse, children: content }), (content && isCollapsed) && (_jsx(ExpandButton, { onMouseDown: (e) => {
435
+ isExpandButtonDraggingRef.current = false;
436
+ expandButtonMouseDownPosRef.current = { x: e.clientX, y: e.clientY };
437
+ }, onMouseMove: (e) => {
438
+ if (!expandButtonMouseDownPosRef.current)
439
+ return;
440
+ const deltaX = Math.abs(e.clientX - expandButtonMouseDownPosRef.current.x);
441
+ const deltaY = Math.abs(e.clientY - expandButtonMouseDownPosRef.current.y);
442
+ // Considera drag solo se il movimento supera 3px
443
+ if (deltaX > 3 || deltaY > 3) {
444
+ isExpandButtonDraggingRef.current = true;
445
+ }
446
+ }, onMouseUp: () => {
447
+ expandButtonMouseDownPosRef.current = null;
448
+ }, onClick: (e) => {
449
+ if (isExpandButtonDraggingRef.current) {
450
+ e.stopPropagation();
451
+ e.preventDefault();
452
+ return;
453
+ }
454
+ e.stopPropagation();
455
+ toggleCollapse();
456
+ }, onContextMenu: (e) => e.preventDefault(), "aria-label": SDKUI_Localizator.Maximize, title: SDKUI_Localizator.Maximize, type: "button", children: _jsx(IconWindowMaximize, {}) })), _jsx("img", { src: ToppyHelpCenterImage, alt: "Toppy Help", draggable: false })] })] }));
457
+ // Renderizza nel document.body usando un Portal se usePortal è true, altrimenti renderizza normalmente
458
+ return usePortal ? ReactDOM.createPortal(toppyContent, document.body) : toppyContent;
459
+ };
460
+ export default TMToppyDraggableHelpCenter;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface TMToppySpeechBubbleProps {
3
+ /** Contenuto da visualizzare nella speech bubble */
4
+ children: React.ReactNode;
5
+ /** Allineamento della speech bubble (destra o sinistra) */
6
+ align?: 'right' | 'left';
7
+ /** Callback per chiudere/minimizzare la bubble */
8
+ onClose?: () => void;
9
+ }
10
+ declare const TMToppySpeechBubble: React.ForwardRefExoticComponent<TMToppySpeechBubbleProps & React.RefAttributes<HTMLDivElement>>;
11
+ export default TMToppySpeechBubble;