@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.
- package/lib/assets/Toppy-help-center.png +0 -0
- package/lib/assets/headergradient.svg +87 -0
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +285 -28
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +8 -1
- package/lib/components/NewComponents/ContextMenu/hooks.js +80 -8
- package/lib/components/NewComponents/ContextMenu/index.d.ts +3 -0
- package/lib/components/NewComponents/ContextMenu/index.js +2 -0
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +9 -1
- package/lib/components/NewComponents/ContextMenu/styles.js +157 -37
- package/lib/components/NewComponents/ContextMenu/types.d.ts +14 -1
- package/lib/components/NewComponents/ContextMenu/useLongPress.d.ts +21 -0
- package/lib/components/NewComponents/ContextMenu/useLongPress.js +112 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +563 -112
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +21 -5
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +210 -58
- package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +8 -2
- package/lib/components/base/TMAccordionNew.js +35 -14
- package/lib/components/base/TMCustomButton.js +61 -17
- package/lib/components/base/TMDataGrid.d.ts +7 -4
- package/lib/components/base/TMDataGrid.js +153 -11
- package/lib/components/base/TMDropDownMenu.js +19 -18
- package/lib/components/base/TMFileManager.d.ts +4 -3
- package/lib/components/base/TMFileManager.js +32 -24
- package/lib/components/base/TMFileManagerDataGridView.d.ts +3 -2
- package/lib/components/base/TMFileManagerDataGridView.js +1 -11
- package/lib/components/base/TMFileManagerThumbnailItems.d.ts +7 -1
- package/lib/components/base/TMFileManagerThumbnailItems.js +5 -2
- package/lib/components/base/TMFileManagerThumbnailsView.d.ts +17 -4
- package/lib/components/base/TMFileManagerThumbnailsView.js +18 -6
- package/lib/components/base/TMFileManagerUtils.d.ts +0 -12
- package/lib/components/base/TMListView.js +33 -15
- package/lib/components/base/TMPanel.d.ts +1 -1
- package/lib/components/base/TMPanel.js +1 -1
- package/lib/components/base/TMTreeView.d.ts +2 -1
- package/lib/components/base/TMTreeView.js +33 -26
- package/lib/components/choosers/TMDistinctValues.js +2 -2
- package/lib/components/choosers/TMInvoiceRetrieveFormats.js +1 -1
- package/lib/components/choosers/TMMetadataChooser.js +8 -1
- package/lib/components/choosers/TMOrderRetrieveFormats.js +1 -1
- package/lib/components/choosers/TMUserChooser.d.ts +0 -5
- package/lib/components/choosers/TMUserChooser.js +25 -45
- package/lib/components/editors/TMDateBox.js +18 -9
- package/lib/components/editors/TMLocalizedTextBox.d.ts +3 -1
- package/lib/components/editors/TMLocalizedTextBox.js +16 -14
- package/lib/components/editors/TMMetadataTextBox.d.ts +9 -0
- package/lib/components/editors/TMMetadataTextBox.js +92 -0
- package/lib/components/editors/TMMetadataValues.js +23 -5
- package/lib/components/editors/TMTextArea.js +18 -30
- package/lib/components/editors/TMTextBox.d.ts +1 -1
- package/lib/components/editors/TMTextBox.js +6 -3
- package/lib/components/editors/TMTextExpression.js +6 -91
- package/lib/components/features/archive/TMArchive.js +2 -2
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.d.ts +15 -0
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +460 -0
- package/lib/components/features/assistant/TMToppySpeechBubble.d.ts +11 -0
- package/lib/components/features/assistant/TMToppySpeechBubble.js +126 -0
- package/lib/components/features/documents/TMDcmtForm.d.ts +14 -2
- package/lib/components/features/documents/TMDcmtForm.js +457 -206
- package/lib/components/features/documents/TMDcmtPreview.js +44 -110
- package/lib/components/features/documents/TMDcmtTasks.js +9 -9
- package/lib/components/features/documents/TMMasterDetailDcmts.js +38 -53
- package/lib/components/features/documents/TMRelationViewer.d.ts +1 -1
- package/lib/components/features/documents/TMRelationViewer.js +2 -2
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +2 -2
- package/lib/components/features/search/TMSavedQuerySelector.js +72 -67
- package/lib/components/features/search/TMSearch.d.ts +3 -0
- package/lib/components/features/search/TMSearch.js +50 -11
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -0
- package/lib/components/features/search/TMSearchQueryPanel.js +29 -21
- package/lib/components/features/search/TMSearchResult.d.ts +3 -0
- package/lib/components/features/search/TMSearchResult.js +208 -250
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.js +205 -169
- package/lib/components/features/search/TMSignSettingsForm.js +1 -1
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +6 -0
- package/lib/components/features/search/TMSignatureInfoContent.js +140 -0
- package/lib/components/features/search/TMViewHistoryDcmt.js +2 -2
- package/lib/components/features/tasks/TMTaskForm.js +20 -1
- package/lib/components/features/tasks/TMTasksAgenda.d.ts +3 -1
- package/lib/components/features/tasks/TMTasksAgenda.js +48 -9
- package/lib/components/features/tasks/TMTasksCalendar.d.ts +2 -0
- package/lib/components/features/tasks/TMTasksCalendar.js +19 -7
- package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -2
- package/lib/components/features/tasks/TMTasksUtils.js +43 -36
- package/lib/components/features/tasks/TMTasksView.js +28 -19
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +33 -2
- package/lib/components/features/workflow/TMWorkflowPopup.js +139 -34
- package/lib/components/features/workflow/diagram/DiagramItemComponent.d.ts +2 -0
- package/lib/components/features/workflow/diagram/DiagramItemComponent.js +12 -7
- package/lib/components/features/workflow/diagram/DiagramItemForm.js +1 -1
- package/lib/components/features/workflow/diagram/RecipientList.js +3 -2
- package/lib/components/features/workflow/diagram/WFDiagram.d.ts +4 -0
- package/lib/components/features/workflow/diagram/WFDiagram.js +164 -13
- package/lib/components/forms/Login/LoginValidatorService.d.ts +2 -0
- package/lib/components/forms/Login/LoginValidatorService.js +7 -2
- package/lib/components/forms/Login/TMLoginForm.js +34 -6
- package/lib/components/forms/TMChooserForm.js +1 -1
- package/lib/components/grids/TMBlogsPost.js +56 -31
- package/lib/components/grids/TMRecentsManager.js +20 -10
- package/lib/components/index.d.ts +6 -3
- package/lib/components/index.js +6 -3
- package/lib/components/query/TMQueryEditor.d.ts +2 -1
- package/lib/components/query/TMQueryEditor.js +92 -92
- package/lib/components/settings/SettingsAppearance.d.ts +2 -1
- package/lib/components/settings/SettingsAppearance.js +99 -30
- package/lib/components/sidebar/TMHeader.js +7 -7
- package/lib/components/sidebar/TMSidebar.d.ts +0 -1
- package/lib/components/sidebar/TMSidebar.js +16 -44
- package/lib/components/sidebar/TMSidebarItem.js +34 -17
- package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -1
- package/lib/components/viewers/TMDataListItemViewer.js +35 -71
- package/lib/components/viewers/TMDataUserIdItemViewer.d.ts +8 -0
- package/lib/components/viewers/TMDataUserIdItemViewer.js +39 -0
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +22 -0
- package/lib/helper/SDKUI_Globals.js +10 -1
- package/lib/helper/SDKUI_Localizator.d.ts +17 -1
- package/lib/helper/SDKUI_Localizator.js +167 -1
- package/lib/helper/TMCommandsContextMenu.d.ts +4 -2
- package/lib/helper/TMCommandsContextMenu.js +15 -4
- package/lib/helper/TMIcons.d.ts +4 -0
- package/lib/helper/TMIcons.js +13 -3
- package/lib/helper/TMPdfViewer.d.ts +8 -0
- package/lib/helper/TMPdfViewer.js +373 -0
- package/lib/helper/checkinCheckoutManager.d.ts +31 -1
- package/lib/helper/checkinCheckoutManager.js +112 -30
- package/lib/helper/devextremeCustomMessages.d.ts +30 -0
- package/lib/helper/devextremeCustomMessages.js +30 -0
- package/lib/helper/helpers.d.ts +28 -1
- package/lib/helper/helpers.js +130 -3
- package/lib/helper/index.d.ts +2 -0
- package/lib/helper/index.js +2 -0
- package/lib/helper/queryHelper.d.ts +1 -1
- package/lib/helper/queryHelper.js +33 -3
- package/lib/helper/workItemsHelper.d.ts +6 -0
- package/lib/helper/workItemsHelper.js +230 -0
- package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
- package/lib/hooks/useCheckInOutOperations.js +223 -0
- package/lib/hooks/useDataListItem.d.ts +12 -0
- package/lib/hooks/useDataListItem.js +132 -0
- package/lib/hooks/useDataUserIdItem.d.ts +10 -0
- package/lib/hooks/useDataUserIdItem.js +96 -0
- package/lib/hooks/useMetadataExpression.d.ts +19 -0
- package/lib/hooks/useMetadataExpression.js +99 -0
- package/lib/hooks/useSettingsFeedback.d.ts +11 -0
- package/lib/hooks/useSettingsFeedback.js +38 -0
- package/lib/hooks/useWorkflowApprove.d.ts +4 -0
- package/lib/hooks/useWorkflowApprove.js +14 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -2
- package/lib/services/platform_services.d.ts +3 -3
- package/lib/ts/types.d.ts +61 -1
- package/lib/utils/theme.d.ts +1 -1
- package/lib/utils/theme.js +1 -1
- package/package.json +7 -4
- package/lib/components/NewComponents/Notification/Notification.d.ts +0 -4
- package/lib/components/NewComponents/Notification/Notification.js +0 -60
- package/lib/components/NewComponents/Notification/NotificationContainer.d.ts +0 -8
- package/lib/components/NewComponents/Notification/NotificationContainer.js +0 -33
- package/lib/components/NewComponents/Notification/index.d.ts +0 -2
- package/lib/components/NewComponents/Notification/index.js +0 -2
- package/lib/components/NewComponents/Notification/styles.d.ts +0 -21
- package/lib/components/NewComponents/Notification/styles.js +0 -180
- package/lib/components/NewComponents/Notification/types.d.ts +0 -18
- package/lib/components/NewComponents/Notification/types.js +0 -1
- package/lib/components/base/TMContextMenu.d.ts +0 -25
- package/lib/components/base/TMContextMenu.js +0 -109
- package/lib/components/base/TMContextMenuOLD.d.ts +0 -26
- package/lib/components/base/TMContextMenuOLD.js +0 -56
- package/lib/components/base/TMFloatingToolbar.d.ts +0 -9
- package/lib/components/base/TMFloatingToolbar.js +0 -101
- package/lib/components/features/assistant/ToppyDraggableHelpCenter.d.ts +0 -30
- package/lib/components/features/assistant/ToppyDraggableHelpCenter.js +0 -482
- package/lib/components/features/assistant/ToppySpeechBubble.d.ts +0 -9
- package/lib/components/features/assistant/ToppySpeechBubble.js +0 -117
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { OwnershipLevels, SDK_Localizator, UserLevels, UserListCacheService } from '@topconsultnpm/sdk-ts';
|
|
4
|
-
import { SDKUI_Localizator, IconSearch, IconUserLevelMember, IconUserLevelAdministrator, IconUserLevelSystemAdministrator, IconUserLevelAutonomousAdministrator,
|
|
5
|
-
import { StyledDivHorizontal
|
|
4
|
+
import { SDKUI_Localizator, IconSearch, IconUserLevelMember, IconUserLevelAdministrator, IconUserLevelSystemAdministrator, IconUserLevelAutonomousAdministrator, LocalizeOwnershipLevels, LocalizeUserLevels, IconShowAllUsersOff, IconShowAllUsers } from '../../helper';
|
|
5
|
+
import { StyledDivHorizontal } from '../base/Styled';
|
|
6
6
|
import TMSpinner from '../base/TMSpinner';
|
|
7
|
-
import TMTooltip from '../base/TMTooltip';
|
|
8
7
|
import TMSummary from '../editors/TMSummary';
|
|
9
8
|
import TMChooserForm from '../forms/TMChooserForm';
|
|
10
|
-
import { TMColors } from '../../utils/theme';
|
|
11
|
-
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
12
9
|
import TMButton from '../base/TMButton';
|
|
10
|
+
import TMDataUserIdItemViewer from '../viewers/TMDataUserIdItemViewer';
|
|
13
11
|
const TMUserChooser = ({ labelColor, titleForm, filter, readOnly = false, icon, width, dataSource, backgroundColor, openChooserBySingleClick, buttons = [], disabled = false, showBorder = true, hideRefresh = false, hideShowId = false, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], onValueChanged, showClearButton, initialShowChooser = false, allowShowAllUsers = false }) => {
|
|
14
12
|
const [showChooser, setShowChooser] = useState(initialShowChooser);
|
|
15
13
|
useEffect(() => {
|
|
@@ -18,7 +16,7 @@ const TMUserChooser = ({ labelColor, titleForm, filter, readOnly = false, icon,
|
|
|
18
16
|
const summaryInputRef = useRef(null);
|
|
19
17
|
const renderTemplate = () => {
|
|
20
18
|
const isPlaceholder = values?.[0] === placeHolder;
|
|
21
|
-
return (_jsxs(StyledDivHorizontal, { style: { minWidth: '125px', color: isPlaceholder ? '#a9a9a9' : 'inherit' }, children: [values && values.length > 0 && _jsx(
|
|
19
|
+
return (_jsxs(StyledDivHorizontal, { style: { minWidth: '125px', color: isPlaceholder ? '#a9a9a9' : 'inherit' }, children: [values && values.length > 0 && _jsx(TMDataUserIdItemViewer, { userId: values?.[0], showIcon: true }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` })] }));
|
|
22
20
|
};
|
|
23
21
|
return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { ref: summaryInputRef, width: width, disabled: disabled, placeHolder: placeHolder, readOnly: readOnly, labelColor: labelColor, icon: icon, backgroundColor: backgroundColor, buttons: buttons, showBorder: showBorder, hasValue: values && values.length > 0, showClearButton: showClearButton, iconEditButton: _jsx(IconSearch, { fontSize: 16 }), onEditorClick: () => !readOnly && setShowChooser(true), elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, openEditorOnSummaryClick: openChooserBySingleClick, label: label, template: renderTemplate(), onClearClick: showClearButton ? () => { onValueChanged?.([]); } : undefined, validationItems: validationItems }), showChooser &&
|
|
24
22
|
_jsx(TMUserChooserForm, { title: titleForm, allowMultipleSelection: allowMultipleSelection, hasShowOnlySelectedItems: true, dataSource: dataSource, filter: filter, selectedIDs: values, hideRefresh: hideRefresh, hideShowId: hideShowId, allowShowAllUsers: allowShowAllUsers, onClose: () => {
|
|
@@ -67,40 +65,6 @@ export const TMUserChooserForm = ({ allowMultipleSelection, columns, hideRefresh
|
|
|
67
65
|
const customButton = (allowShowAllUsers && dataSource) ? (_jsx(TMButton, { btnStyle: 'toolbar', caption: showingAllUsers ? SDKUI_Localizator.HideAll : SDKUI_Localizator.ShowAll, onClick: handleToggleAllUsers, icon: showingAllUsers ? _jsx(IconShowAllUsersOff, {}) : _jsx(IconShowAllUsers, {}) })) : undefined;
|
|
68
66
|
return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: allowMultipleSelection, startWithShowOnlySelectedItems: startWithShowOnlySelectedItems, hasShowOnlySelectedItems: hasShowOnlySelectedItems, width: width, height: height, manageUseLocalizedName: false, columns: columns ?? dataColumns, showDefaultColumns: false, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon, dataSource: currentDataSource, getItems: getItems, hasShowId: !hideShowId, hideRefresh: hideRefresh, customButtons: customButton, onClose: onClose, onChoose: (IDs) => onChoose?.(IDs) }));
|
|
69
67
|
};
|
|
70
|
-
export const TMUserIdViewer = ({ userId, showIcon = false, noneSelectionText = `<${SDKUI_Localizator.NoneSelection}>` }) => {
|
|
71
|
-
const [ud, setUd] = useState();
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (!userId || userId <= 0) {
|
|
74
|
-
setUd(undefined);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
|
|
78
|
-
UserListCacheService.GetAsync(userId).then((ud) => { setUd(ud); TMSpinner.hide(); }).catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
79
|
-
}, [userId]);
|
|
80
|
-
const getIcon = () => {
|
|
81
|
-
if (!showIcon)
|
|
82
|
-
return null;
|
|
83
|
-
if (!userId)
|
|
84
|
-
return null;
|
|
85
|
-
return ud ?
|
|
86
|
-
_jsx(TMUserIcon, { ud: ud })
|
|
87
|
-
:
|
|
88
|
-
_jsx(TMTooltip, { content: SDKUI_Localizator.ValueNotPresent, children: _jsx(IconWarning, { color: TMColors.warning }) });
|
|
89
|
-
};
|
|
90
|
-
const getDescription = () => {
|
|
91
|
-
if (!userId)
|
|
92
|
-
return undefined;
|
|
93
|
-
return ud ? getCompleteUserName(ud.domain, ud.name) : userId.toString() ?? noneSelectionText;
|
|
94
|
-
};
|
|
95
|
-
return (_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: '4px' }, children: [getIcon(), _jsx("span", { children: getDescription() })] })
|
|
96
|
-
// <StyledDivHorizontal>
|
|
97
|
-
// {getIcon()}
|
|
98
|
-
// <p style={{ textAlign: 'left', marginLeft: showIcon ? '5px' : '', opacity: ud ? 1 : 0.5 }}>
|
|
99
|
-
// {getDescription()}
|
|
100
|
-
// </p>
|
|
101
|
-
// </StyledDivHorizontal>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
68
|
export const TMUserIcon = ({ ud }) => {
|
|
105
69
|
if (!ud)
|
|
106
70
|
return null;
|
|
@@ -109,12 +73,28 @@ export const TMUserIcon = ({ ud }) => {
|
|
|
109
73
|
return (_jsx(TMUserTooltip, { ud: ud, children: icon }));
|
|
110
74
|
};
|
|
111
75
|
export const TMUserTooltip = ({ ud, children }) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
76
|
+
const buildTitle = (ud) => {
|
|
77
|
+
if (!ud)
|
|
78
|
+
return '';
|
|
79
|
+
const isExpired = User_IsExpired(ud);
|
|
80
|
+
return [
|
|
81
|
+
`ID: ${ud.id ?? ''}`,
|
|
82
|
+
`${SDKUI_Localizator.Name}: ${getCompleteUserName(ud.domain, ud.name) ?? ''}`,
|
|
83
|
+
ud.description && `${SDKUI_Localizator.Description}: ${ud.description}`,
|
|
84
|
+
ud.type && `${SDKUI_Localizator.Type}: ${ud.type}`,
|
|
85
|
+
ud.level && `${SDKUI_Localizator.UserLevel}: ${LocalizeUserLevels(ud.level) ?? ''}`,
|
|
86
|
+
`${SDKUI_Localizator.Valid}: ${isExpired ? SDKUI_Localizator.No : SDKUI_Localizator.Yes}`,
|
|
87
|
+
`${SDKUI_Localizator.Disabled}: ${ud.disabled ? SDKUI_Localizator.Yes : SDKUI_Localizator.No}`,
|
|
88
|
+
`---`,
|
|
89
|
+
`${SDKUI_Localizator.OwnerName}: ${ud.ownerName ?? ''} (${ud.ownerID ?? ''})`,
|
|
90
|
+
`${SDKUI_Localizator.OwnershipLevel}: ${LocalizeOwnershipLevels(ud.ownershipLevel) ?? ''}`,
|
|
91
|
+
`${SDKUI_Localizator.CreationTime}: ${ud.creationTime?.toDateString() ?? ''}`,
|
|
92
|
+
`${SDKUI_Localizator.LastUpdateTime}: ${ud.lastUpdateTime?.toDateString() ?? ''}`
|
|
93
|
+
]
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.join('\n');
|
|
116
96
|
};
|
|
117
|
-
return (_jsx(
|
|
97
|
+
return (_jsx("div", { title: buildTitle(ud), children: children }));
|
|
118
98
|
};
|
|
119
99
|
const getCompleteUserName = (domain, name) => {
|
|
120
100
|
if (!name)
|
|
@@ -10,27 +10,36 @@ const TMDateBox = (props) => {
|
|
|
10
10
|
let htmlElement = dateBoxRef?.current?.instance().element();
|
|
11
11
|
if (!htmlElement)
|
|
12
12
|
return;
|
|
13
|
-
let
|
|
13
|
+
let borderColor = props.isModifiedWhen ? TMColors.tertiary : TMColors.border_normal;
|
|
14
|
+
let textColor = props.isModifiedWhen ? TMColors.isModified : TMColors.text_normal;
|
|
14
15
|
let inputContainer = htmlElement.getElementsByClassName("dx-texteditor-input-container")[0];
|
|
15
16
|
if (inputContainer) {
|
|
16
17
|
inputContainer.style.background = props.readOnly ? 'linear-gradient(white 20%, #d6d6d6 80%)' : '';
|
|
17
|
-
inputContainer.style.color = props.readOnly ? '#525252' :
|
|
18
|
+
inputContainer.style.color = props.readOnly ? '#525252' : textColor;
|
|
19
|
+
}
|
|
20
|
+
let input = htmlElement.querySelector(".dx-texteditor-input");
|
|
21
|
+
if (input) {
|
|
22
|
+
if (!props.readOnly) {
|
|
23
|
+
input.style.color = textColor;
|
|
24
|
+
}
|
|
25
|
+
input.style.fontSize = 'var(--base-font-size)';
|
|
26
|
+
input.style.fontFamily = 'var(--base-font-family)';
|
|
18
27
|
}
|
|
19
28
|
let label = htmlElement.getElementsByClassName("dx-label")[0];
|
|
20
29
|
if (label) {
|
|
21
|
-
label.style.borderBottomColor =
|
|
30
|
+
label.style.borderBottomColor = borderColor;
|
|
22
31
|
}
|
|
23
32
|
let labelBefore = htmlElement.getElementsByClassName("dx-label-before")[0];
|
|
24
33
|
if (labelBefore) {
|
|
25
|
-
labelBefore.style.borderBottomColor =
|
|
26
|
-
labelBefore.style.borderTopColor =
|
|
27
|
-
labelBefore.style.borderInlineStartColor =
|
|
34
|
+
labelBefore.style.borderBottomColor = borderColor;
|
|
35
|
+
labelBefore.style.borderTopColor = borderColor;
|
|
36
|
+
labelBefore.style.borderInlineStartColor = borderColor;
|
|
28
37
|
}
|
|
29
38
|
let labelAfter = htmlElement.getElementsByClassName("dx-label-after")[0];
|
|
30
39
|
if (labelAfter) {
|
|
31
|
-
labelAfter.style.borderBottomColor =
|
|
32
|
-
labelAfter.style.borderTopColor =
|
|
33
|
-
labelAfter.style.borderInlineEndColor =
|
|
40
|
+
labelAfter.style.borderBottomColor = borderColor;
|
|
41
|
+
labelAfter.style.borderTopColor = borderColor;
|
|
42
|
+
labelAfter.style.borderInlineEndColor = borderColor;
|
|
34
43
|
}
|
|
35
44
|
}, [props.isModifiedWhen, props.readOnly]);
|
|
36
45
|
const dateBoxRef = useRef(null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CultureIDs } from '@topconsultnpm/sdk-ts';
|
|
2
|
+
import { CultureIDs, QueryDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
3
|
import { ValidationItem } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
export declare const getCultureIDImg: (cultureID: CultureIDs) => any;
|
|
5
5
|
interface TMLocalizedTextBoxProps {
|
|
@@ -13,6 +13,8 @@ interface TMLocalizedTextBoxProps {
|
|
|
13
13
|
value_ES?: string;
|
|
14
14
|
value_DE?: string;
|
|
15
15
|
validationItems?: ValidationItem[];
|
|
16
|
+
qd?: QueryDescriptor;
|
|
17
|
+
tid?: number;
|
|
16
18
|
onValueChanged: (lang: CultureIDs, value: string) => void;
|
|
17
19
|
}
|
|
18
20
|
declare const TMLocalizedTextBox: React.FC<TMLocalizedTextBoxProps>;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import TMTextBox from './TMTextBox';
|
|
5
|
+
import TMMetadataTextBox from './TMMetadataTextBox';
|
|
5
6
|
import { IconLanguage, SDKUI_Localizator } from '../../helper';
|
|
6
7
|
import { CultureIDs } from '@topconsultnpm/sdk-ts';
|
|
7
8
|
import it from '../../assets/italy.svg';
|
|
@@ -13,11 +14,9 @@ import pt from '../../assets/portugal.svg';
|
|
|
13
14
|
import { createPortal } from 'react-dom';
|
|
14
15
|
const Portal = ({ children, popoverRef }) => {
|
|
15
16
|
const mount = document.body;
|
|
16
|
-
// Usa un ref per l'elemento del portale per evitare di ricrearlo ad ogni render
|
|
17
17
|
const elRef = useRef(document.createElement('div'));
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
const el = elRef.current;
|
|
20
|
-
// Assegna il ref al div del portale
|
|
21
20
|
el.ref = popoverRef;
|
|
22
21
|
mount.appendChild(el);
|
|
23
22
|
return () => {
|
|
@@ -33,7 +32,7 @@ const LocalizedContainer = styled.div `
|
|
|
33
32
|
const Popover = styled.div `
|
|
34
33
|
display: ${props => props.$isVisible ? 'flex' : 'none'};
|
|
35
34
|
flex-direction: column;
|
|
36
|
-
position: fixed;
|
|
35
|
+
position: fixed;
|
|
37
36
|
top: ${props => props.$top}px;
|
|
38
37
|
left: ${props => props.$left}px;
|
|
39
38
|
width: ${props => props.$width}px;
|
|
@@ -41,7 +40,7 @@ const Popover = styled.div `
|
|
|
41
40
|
border-radius: 4px;
|
|
42
41
|
background-color: #fff;
|
|
43
42
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
44
|
-
z-index:
|
|
43
|
+
z-index: 1502;
|
|
45
44
|
padding: 8px;
|
|
46
45
|
`;
|
|
47
46
|
const Badge = styled.span `
|
|
@@ -72,10 +71,10 @@ export const getCultureIDImg = (cultureID) => {
|
|
|
72
71
|
default: return it;
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
|
-
const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_PT, value_ES, value_DE, isModifiedWhen, validationItems, onValueChanged, }) => {
|
|
74
|
+
const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_PT, value_ES, value_DE, isModifiedWhen, validationItems, qd, tid, onValueChanged, }) => {
|
|
76
75
|
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
|
|
77
|
-
const containerRef = useRef(null);
|
|
78
|
-
const popoverRef = useRef(null);
|
|
76
|
+
const containerRef = useRef(null);
|
|
77
|
+
const popoverRef = useRef(null);
|
|
79
78
|
const [popoverPosition, setPopoverPosition] = useState({ top: 0, left: 0, width: 0 });
|
|
80
79
|
const languages = [
|
|
81
80
|
{ code: CultureIDs.It_IT, label: 'Italiano', value: value_IT },
|
|
@@ -85,13 +84,12 @@ const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_
|
|
|
85
84
|
{ code: CultureIDs.Es_ES, label: 'Español', value: value_ES },
|
|
86
85
|
{ code: CultureIDs.De_DE, label: 'Deutsch', value: value_DE },
|
|
87
86
|
];
|
|
88
|
-
// Calcola il numero di lingue con valori non nulli o vuoti
|
|
89
87
|
const localizedCount = languages.filter(lang => lang.value && lang.value.trim() !== '').length;
|
|
90
88
|
const handleTogglePopover = () => {
|
|
91
89
|
if (containerRef.current) {
|
|
92
90
|
const rect = containerRef.current.getBoundingClientRect();
|
|
93
91
|
setPopoverPosition({
|
|
94
|
-
top: rect.bottom,
|
|
92
|
+
top: rect.bottom,
|
|
95
93
|
left: rect.left,
|
|
96
94
|
width: rect.width
|
|
97
95
|
});
|
|
@@ -99,19 +97,23 @@ const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_
|
|
|
99
97
|
setIsPopoverVisible(prev => !prev);
|
|
100
98
|
};
|
|
101
99
|
const handleClosePopover = () => setIsPopoverVisible(false);
|
|
102
|
-
// Close popover when clicking outside
|
|
103
100
|
useEffect(() => {
|
|
101
|
+
if (!isPopoverVisible)
|
|
102
|
+
return;
|
|
104
103
|
const handleClickOutside = (event) => {
|
|
105
|
-
if (
|
|
106
|
-
containerRef.current &&
|
|
104
|
+
if (containerRef.current &&
|
|
107
105
|
!containerRef.current.contains(event.target) &&
|
|
108
106
|
popoverRef.current &&
|
|
109
107
|
!popoverRef.current.contains(event.target)) {
|
|
110
108
|
handleClosePopover();
|
|
111
109
|
}
|
|
112
110
|
};
|
|
113
|
-
|
|
111
|
+
// Ritarda l'aggiunta del listener per evitare che catturi il click di apertura
|
|
112
|
+
const timeoutId = setTimeout(() => {
|
|
113
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
114
|
+
}, 0);
|
|
114
115
|
return () => {
|
|
116
|
+
clearTimeout(timeoutId);
|
|
115
117
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
116
118
|
};
|
|
117
119
|
}, [isPopoverVisible]);
|
|
@@ -120,6 +122,6 @@ const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_
|
|
|
120
122
|
icon: (_jsxs(IconContainer, { children: [_jsx(IconLanguage, {}), localizedCount > 0 && _jsx(Badge, { children: localizedCount })] })),
|
|
121
123
|
onClick: handleTogglePopover,
|
|
122
124
|
};
|
|
123
|
-
return (_jsxs(LocalizedContainer, { ref: containerRef, children: [_jsx(TMTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) }), isPopoverVisible && (_jsx(Portal, { popoverRef: popoverRef, children: _jsx(Popover, { ref: popoverRef, "$isVisible": isPopoverVisible, "$top": popoverPosition.top, "$left": popoverPosition.left, "$width": popoverPosition.width, onMouseDown: (e) => e.stopPropagation(), children: languages.map((lang) => (_jsx(TMTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code))) }) }))] }));
|
|
125
|
+
return (_jsxs(LocalizedContainer, { ref: containerRef, children: [(qd || tid) ? (_jsx(TMMetadataTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, qd: qd, tid: tid, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })) : (_jsx(TMTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })), isPopoverVisible && (_jsx(Portal, { popoverRef: popoverRef, children: _jsx(Popover, { ref: popoverRef, "$isVisible": isPopoverVisible, "$top": popoverPosition.top, "$left": popoverPosition.left, "$width": popoverPosition.width, onMouseDown: (e) => e.stopPropagation(), children: languages.map((lang) => ((qd || tid) ? (_jsx(TMMetadataTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', qd: qd, tid: tid, onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)) : (_jsx(TMTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)))) }) }))] }));
|
|
124
126
|
};
|
|
125
127
|
export default TMLocalizedTextBox;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import type { ITMTextBox } from './TMTextBox';
|
|
4
|
+
interface ITMMetadataTextBox extends ITMTextBox {
|
|
5
|
+
qd?: QueryDescriptor;
|
|
6
|
+
tid?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const TMMetadataTextBox: React.FC<ITMMetadataTextBox>;
|
|
9
|
+
export default TMMetadataTextBox;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import TMTextBox from './TMTextBox';
|
|
4
|
+
import TMContextMenu from '../NewComponents/ContextMenu/TMContextMenu';
|
|
5
|
+
import { useMetadataExpression } from '../../hooks/useMetadataExpression';
|
|
6
|
+
const TMMetadataTextBox = (props) => {
|
|
7
|
+
const { metadatas_Info_Source, Expression_IDs2Names, Expression_Names2IDs } = useMetadataExpression({
|
|
8
|
+
qd: props.qd,
|
|
9
|
+
tid: props.tid
|
|
10
|
+
});
|
|
11
|
+
const insertAtCursor = (textToInsert) => {
|
|
12
|
+
const currentValue = Expression_IDs2Names(props.value) || '';
|
|
13
|
+
let newValue = currentValue;
|
|
14
|
+
let cursorPosition = currentValue.length;
|
|
15
|
+
const activeElement = document.activeElement;
|
|
16
|
+
if (activeElement && activeElement.tagName === 'INPUT' && activeElement.selectionStart !== null) {
|
|
17
|
+
const start = activeElement.selectionStart || 0;
|
|
18
|
+
const end = activeElement.selectionEnd || 0;
|
|
19
|
+
newValue =
|
|
20
|
+
currentValue.substring(0, start) +
|
|
21
|
+
textToInsert +
|
|
22
|
+
currentValue.substring(end);
|
|
23
|
+
cursorPosition = start + textToInsert.length;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
newValue = currentValue + textToInsert;
|
|
27
|
+
cursorPosition = newValue.length;
|
|
28
|
+
}
|
|
29
|
+
const syntheticEvent = {
|
|
30
|
+
target: { value: Expression_Names2IDs(newValue) }
|
|
31
|
+
};
|
|
32
|
+
props.onValueChanged?.(syntheticEvent);
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
const activeElement = document.activeElement;
|
|
35
|
+
if (activeElement && activeElement.tagName === 'INPUT') {
|
|
36
|
+
activeElement.setSelectionRange(cursorPosition, cursorPosition);
|
|
37
|
+
activeElement.focus();
|
|
38
|
+
}
|
|
39
|
+
}, 0);
|
|
40
|
+
};
|
|
41
|
+
// Crea i menu items per il context menu
|
|
42
|
+
const contextMenuItems = useMemo(() => {
|
|
43
|
+
// Separa metadati di sistema (Mid < 100) da quelli normali
|
|
44
|
+
const systemMetadata = metadatas_Info_Source.filter(mh => mh.Mid < 100);
|
|
45
|
+
const normalMetadata = metadatas_Info_Source.filter(mh => mh.Mid >= 100);
|
|
46
|
+
const items = [];
|
|
47
|
+
// Aggiungi metadati normali
|
|
48
|
+
normalMetadata.forEach(mh => {
|
|
49
|
+
items.push({
|
|
50
|
+
name: mh.MetadataName,
|
|
51
|
+
onClick: () => insertAtCursor(`{@${mh.MetadataName}}`)
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
// Aggiungi sottomenu per metadati di sistema se presenti
|
|
55
|
+
if (systemMetadata.length > 0) {
|
|
56
|
+
items.push({
|
|
57
|
+
name: 'Metadati di sistema',
|
|
58
|
+
beginGroup: normalMetadata.length > 0, // Separatore se ci sono anche metadati normali
|
|
59
|
+
submenu: systemMetadata.map(mh => ({
|
|
60
|
+
name: mh.MetadataName,
|
|
61
|
+
onClick: () => insertAtCursor(`{@${mh.MetadataName}}`)
|
|
62
|
+
}))
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return items;
|
|
66
|
+
}, [metadatas_Info_Source, props.value]);
|
|
67
|
+
const renderButtons = () => {
|
|
68
|
+
const customButtons = [];
|
|
69
|
+
// Aggiungi eventuali bottoni custom passati via props
|
|
70
|
+
if (props.buttons) {
|
|
71
|
+
customButtons.push(...props.buttons);
|
|
72
|
+
}
|
|
73
|
+
return customButtons;
|
|
74
|
+
};
|
|
75
|
+
const handleValueChanged = (e) => {
|
|
76
|
+
const syntheticEvent = {
|
|
77
|
+
...e,
|
|
78
|
+
target: {
|
|
79
|
+
...e.target,
|
|
80
|
+
value: Expression_Names2IDs(e.target.value) || ''
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
props.onValueChanged?.(syntheticEvent);
|
|
84
|
+
};
|
|
85
|
+
// Se non ci sono metadati (qd o tid non specificati), usa TMTextBox normale
|
|
86
|
+
if (!props.qd && !props.tid) {
|
|
87
|
+
return (_jsx(TMTextBox, { ...props, buttons: renderButtons(), value: Expression_IDs2Names(props.value) ?? '', onValueChanged: handleValueChanged }));
|
|
88
|
+
}
|
|
89
|
+
// Altrimenti, wrappa TMTextBox con TMContextMenu
|
|
90
|
+
return (_jsx(TMContextMenu, { items: contextMenuItems, trigger: "right", children: _jsx(TMTextBox, { ...props, buttons: renderButtons(), value: Expression_IDs2Names(props.value) ?? '', onValueChanged: handleValueChanged }) }));
|
|
91
|
+
};
|
|
92
|
+
export default TMMetadataTextBox;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
|
-
import { AccessLevels, DcmtTypeListCacheService, LayoutGroupBorderStyles, LayoutGroupOrientations, LayoutItemTypes, LayoutModes, MetadataDataDomains, MetadataDataTypes, SDK_Globals, SystemMIDsAsNumber, SystemTIDs,
|
|
5
|
-
import { IconUndo, IconPencil, IconFunction, IconMenuVertical, IconDataList, SDKUI_Localizator, IconNull, stringIsNullOrEmpty, deepCompare, SDKUI_Globals, IconDcmtTypeSys } from "../../helper";
|
|
4
|
+
import { AccessLevels, DcmtTypeListCacheService, LayoutGroupBorderStyles, LayoutGroupOrientations, LayoutItemTypes, LayoutModes, MetadataDataDomains, MetadataDataTypes, SDK_Globals, SystemMIDsAsNumber, SystemTIDs, WorkItemMetadataNames } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
import { IconUndo, IconPencil, IconFunction, IconMenuVertical, IconDataList, SDKUI_Localizator, IconNull, stringIsNullOrEmpty, deepCompare, SDKUI_Globals, IconDcmtTypeSys, isApprovalWorkflowView } from "../../helper";
|
|
6
6
|
import { TMColors } from "../../utils/theme";
|
|
7
7
|
import TMButton from "../base/TMButton";
|
|
8
8
|
import TMDropDownMenu from "../base/TMDropDownMenu";
|
|
@@ -389,17 +389,35 @@ const TMMetadataValues = ({ showCheckBoxes = ShowCheckBoxesMode.Never, checkPerm
|
|
|
389
389
|
return (_jsxs("div", { style: { width: '100%' }, children: [draftData.length > 0 && _jsx(TMAccordion, { title: SDKUI_Localizator.Draft, children: draftData.map(item => renderMetadataItem(item, isReadOnly)) }), checkOutData.length > 0 && _jsx(TMAccordion, { title: `${SDKUI_Localizator.CheckIn}/${SDKUI_Localizator.CheckOut}`, children: checkOutData.map(item => renderMetadataItem(item, true)) })] }));
|
|
390
390
|
}, [metadataValues, showCheckBoxes, showNullValueCheckBoxes, isReadOnly, dynDataListsToBeRefreshed, validationItems, selectedMID, isOpenDistinctValues, openChooserBySingleClick, metadataValuesOrig]);
|
|
391
391
|
const layoutChronology = useMemo(() => {
|
|
392
|
-
|
|
392
|
+
// Definiamo l'ordine desiderato: Version, Tipo, Dimensione, Autore, Data Ultima modifica
|
|
393
|
+
const desiredChronologyOrder = [
|
|
394
|
+
ChronologyMIDs.Ver,
|
|
395
|
+
SystemMIDsAsNumber.FileExt,
|
|
396
|
+
SystemMIDsAsNumber.FileSize,
|
|
397
|
+
ChronologyMIDs.AuthorID,
|
|
398
|
+
ChronologyMIDs.CheckInTime,
|
|
399
|
+
];
|
|
400
|
+
const tempChronologyDataMap = {};
|
|
393
401
|
metadataValues.forEach(item => {
|
|
394
402
|
switch (item.md?.id) {
|
|
395
403
|
case ChronologyMIDs.Ver:
|
|
396
404
|
case ChronologyMIDs.AuthorID:
|
|
397
|
-
|
|
405
|
+
case ChronologyMIDs.CheckInTime:
|
|
406
|
+
case SystemMIDsAsNumber.FileExt:
|
|
407
|
+
case SystemMIDsAsNumber.FileSize:
|
|
408
|
+
tempChronologyDataMap[item.md.id] = item;
|
|
398
409
|
break;
|
|
399
410
|
default:
|
|
400
411
|
break;
|
|
401
412
|
}
|
|
402
413
|
});
|
|
414
|
+
// Visualizziamo nell'ordine desiderato
|
|
415
|
+
const chronologyData = [];
|
|
416
|
+
desiredChronologyOrder.forEach(id => {
|
|
417
|
+
if (tempChronologyDataMap[id]) {
|
|
418
|
+
chronologyData.push(tempChronologyDataMap[id]);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
403
421
|
return (_jsx("div", { style: { width: '100%' }, children: chronologyData.length > 0 && chronologyData.map(item => renderMetadataItem(item, isReadOnly)) }));
|
|
404
422
|
}, [metadataValues, showCheckBoxes, showNullValueCheckBoxes, isReadOnly, dynDataListsToBeRefreshed, validationItems, selectedMID, isOpenDistinctValues, openChooserBySingleClick, metadataValuesOrig]);
|
|
405
423
|
const layoutDsAttachs = useMemo(() => {
|
|
@@ -550,7 +568,7 @@ const TMMetadataValues = ({ showCheckBoxes = ShowCheckBoxesMode.Never, checkPerm
|
|
|
550
568
|
if (allSystem) {
|
|
551
569
|
return metadataValues.map((item) => renderMetadataItem(item, true));
|
|
552
570
|
}
|
|
553
|
-
if (currentDTD
|
|
571
|
+
if (isApprovalWorkflowView(currentDTD) && !isReadOnly) {
|
|
554
572
|
return layoutWorkItem;
|
|
555
573
|
}
|
|
556
574
|
switch (currentDTD?.id) {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import { StyledEditorContainer, StyledEditorIcon, StyledEditorLabel, StyledTextareaEditor } from './TMEditorStyled';
|
|
4
4
|
import { FontSize, TMColors } from '../../utils/theme';
|
|
5
|
-
import TMContextMenu
|
|
5
|
+
import TMContextMenu from '../NewComponents/ContextMenu/TMContextMenu';
|
|
6
6
|
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
7
7
|
import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
|
|
8
8
|
import TMVilViewer from '../base/TMVilViewer';
|
|
@@ -35,14 +35,10 @@ const TMTextArea = (props) => {
|
|
|
35
35
|
const [isFocused, setIsFocused] = useState(false);
|
|
36
36
|
// Stores the current value of the textarea
|
|
37
37
|
const [currentValue, setCurrentValue] = useState(value);
|
|
38
|
-
// Stores the items for the context menu
|
|
39
|
-
const [formulaMenuItems, setFormulaMenuItems] = useState([]);
|
|
40
38
|
// Stores the calculated number of rows for the textarea
|
|
41
39
|
const [calculatedRows, setCalculatedRows] = useState(rows ?? 1);
|
|
42
40
|
//Show chooserForm formulaItems
|
|
43
41
|
const [showFormulaItemsChooser, setShowFormulaItemsChooser] = useState(false);
|
|
44
|
-
// Manages the state for the custom context menu
|
|
45
|
-
const { clicked, setClicked, points, setPoints } = useContextMenu();
|
|
46
42
|
const deviceType = useDeviceType();
|
|
47
43
|
// Attach a `ResizeObserver` to the textarea to monitor changes in width: dynamically updates rows based on textarea content and width
|
|
48
44
|
useEffect(() => {
|
|
@@ -69,16 +65,15 @@ const TMTextArea = (props) => {
|
|
|
69
65
|
setCalculatedRows(newRowCount);
|
|
70
66
|
}
|
|
71
67
|
}, [currentValue, autoCalculateRows]);
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
if (formulaItems
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, [formulaItems]);
|
|
68
|
+
// Build context menu items for formulas
|
|
69
|
+
const getFormulaMenuItems = () => {
|
|
70
|
+
if (!formulaItems || formulaItems.length === 0)
|
|
71
|
+
return [];
|
|
72
|
+
return formulaItems.map(formula => ({
|
|
73
|
+
name: formula,
|
|
74
|
+
onClick: () => insertText(formula)
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
82
77
|
function getFormulaDataSorce() {
|
|
83
78
|
let fiarray = [];
|
|
84
79
|
if (!formulaItems)
|
|
@@ -153,20 +148,8 @@ const TMTextArea = (props) => {
|
|
|
153
148
|
};
|
|
154
149
|
// Renders the textarea
|
|
155
150
|
const renderTextArea = () => {
|
|
156
|
-
|
|
157
|
-
onBlur?.(currentValue); }, onChange: (e) => { setCurrentValue(e.target.value); onValueChanged?.(e); },
|
|
158
|
-
if (formulaItems.length <= 0)
|
|
159
|
-
return;
|
|
160
|
-
// prevent default right click behavior
|
|
161
|
-
e.preventDefault();
|
|
162
|
-
// set our click state to true when a user right clicks
|
|
163
|
-
setClicked(true);
|
|
164
|
-
const bounds = e.currentTarget.getBoundingClientRect();
|
|
165
|
-
const x = e.clientX - bounds.left;
|
|
166
|
-
const y = e.clientY - bounds.top;
|
|
167
|
-
// set the x and y coordinates of our users right click
|
|
168
|
-
setPoints({ x, y });
|
|
169
|
-
}, "$isMobile": deviceType === DeviceType.MOBILE, "$maxHeight": maxHeight, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$width": width, "$resize": resize }), _jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: calculatedRows === 1 ? (label.length > 0 ? '20px' : '7px') : (label.length > 0 ? '22px' : '7px'), pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [formulaItems.length > 0 &&
|
|
151
|
+
const textareaElement = _jsxs(_Fragment, { children: [_jsx(StyledTextareaEditor, { ref: inputRef, autoFocus: autoFocus, readOnly: readOnly, disabled: disabled, value: currentValue, placeholder: placeHolder, rows: calculatedRows, maxLength: maxLength, spellCheck: false, onFocus: () => setIsFocused(true), onBlur: (e) => { setIsFocused(false); if (currentValue != value)
|
|
152
|
+
onBlur?.(currentValue); }, onChange: (e) => { setCurrentValue(e.target.value); onValueChanged?.(e); }, "$isMobile": deviceType === DeviceType.MOBILE, "$maxHeight": maxHeight, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$width": width, "$resize": resize }), _jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: calculatedRows === 1 ? (label.length > 0 ? '20px' : '7px') : (label.length > 0 ? '22px' : '7px'), pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [formulaItems.length > 0 &&
|
|
170
153
|
_jsx(StyledTextAreaEditorButton, { onClick: () => {
|
|
171
154
|
setShowFormulaItemsChooser(true);
|
|
172
155
|
}, children: _jsx(IconDataList, {}) }), showClearButton && currentValue &&
|
|
@@ -178,7 +161,12 @@ const TMTextArea = (props) => {
|
|
|
178
161
|
onBlur?.(undefined);
|
|
179
162
|
}, children: _jsx(IconClearButton, {}) }), buttons.map((buttonItem, index) => {
|
|
180
163
|
return (_jsx(StyledTextAreaEditorButton, { onClick: buttonItem.onClick, children: _jsx(TMTooltip, { content: buttonItem.text, children: buttonItem.icon }) }, buttonItem.text));
|
|
181
|
-
})] }), openFormulaItemsChooser(),
|
|
164
|
+
})] }), openFormulaItemsChooser(), _jsx(TMVilViewer, { vil: validationItems })] });
|
|
165
|
+
// Wrap with context menu if formula items exist
|
|
166
|
+
if (formulaItems.length > 0) {
|
|
167
|
+
return (_jsx(TMContextMenu, { items: getFormulaMenuItems(), trigger: "right", children: textareaElement }));
|
|
168
|
+
}
|
|
169
|
+
return textareaElement;
|
|
182
170
|
};
|
|
183
171
|
// Layout for the textarea with a left-aligned label
|
|
184
172
|
const renderedLeftLabelTextArea = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ITMEditorBase } from '../base/TMEditorBase';
|
|
3
3
|
export type TextBoxType = 'text' | 'email' | 'password' | 'number' | 'secureText';
|
|
4
|
-
interface ITMTextBox extends ITMEditorBase {
|
|
4
|
+
export interface ITMTextBox extends ITMEditorBase {
|
|
5
5
|
autoFocus?: boolean;
|
|
6
6
|
formulaItems?: string[];
|
|
7
7
|
maxValue?: number;
|
|
@@ -9,7 +9,7 @@ import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
|
9
9
|
import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
|
|
10
10
|
import TMVilViewer from '../base/TMVilViewer';
|
|
11
11
|
import TMTooltip from '../base/TMTooltip';
|
|
12
|
-
import
|
|
12
|
+
import TMContextMenu from '../NewComponents/ContextMenu/TMContextMenu';
|
|
13
13
|
import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
|
|
14
14
|
import TMChooserForm from '../forms/TMChooserForm';
|
|
15
15
|
import { FormulaItemHelper } from './TMTextExpression';
|
|
@@ -94,7 +94,10 @@ const TMTextBox = ({ autoFocus, maxLength, labelColor, precision, fromModal = fa
|
|
|
94
94
|
if (formulaItems && formulaItems.length > 0) {
|
|
95
95
|
let menuItems = [];
|
|
96
96
|
for (const formula of formulaItems) {
|
|
97
|
-
menuItems.push({
|
|
97
|
+
menuItems.push({
|
|
98
|
+
name: formula,
|
|
99
|
+
onClick: () => insertText(formula)
|
|
100
|
+
});
|
|
98
101
|
}
|
|
99
102
|
setFormulaMenuItems(menuItems);
|
|
100
103
|
}
|
|
@@ -269,7 +272,7 @@ const TMTextBox = ({ autoFocus, maxLength, labelColor, precision, fromModal = fa
|
|
|
269
272
|
onBlur?.(undefined);
|
|
270
273
|
}, children: _jsx(IconClearButton, {}) }), buttons.map((buttonItem, index) => {
|
|
271
274
|
return (_jsx(StyledTextBoxEditorButton, { onClick: buttonItem.onClick, children: _jsx(TMTooltip, { content: buttonItem.text, children: buttonItem.icon }) }, buttonItem.text));
|
|
272
|
-
})] }), openFormulaItemsChooser(), formulaItems.length > 0 && (_jsx(
|
|
275
|
+
})] }), openFormulaItemsChooser(), formulaItems.length > 0 && (_jsx(TMContextMenu, { items: formulaMenuItems, target: `#text-${id}` })), _jsx(TMVilViewer, { vil: validationItems })] }));
|
|
273
276
|
};
|
|
274
277
|
const renderedLeftLabelTextBox = () => {
|
|
275
278
|
return (_jsxs(TMLayoutContainer, { direction: 'horizontal', children: [icon && _jsx(TMLayoutItem, { width: '20px', children: _jsx(StyledEditorIcon, { "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, children: icon }) }), _jsx(TMLayoutItem, { children: _jsxs(StyledEditorContainer, { "$width": width, children: [label && _jsx(StyledEditorLabel, { "$color": labelColor, "$isFocused": isFocused, "$labelPosition": labelPosition, "$disabled": disabled, children: label }), renderInputField()] }) })] }));
|