@topconsultnpm/sdkui-react 6.22.0-dev1.9 → 6.22.0-dev2.3
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/components/base/TMDataGridExportForm.js +39 -30
- package/lib/components/base/TMModal.js +1 -1
- package/lib/components/choosers/TMDynDataListItemChooser.d.ts +2 -0
- package/lib/components/choosers/TMDynDataListItemChooser.js +4 -6
- package/lib/components/editors/TMDateBox.d.ts +16 -1
- package/lib/components/editors/TMDateBox.js +90 -22
- package/lib/components/editors/TMMetadataEditor.js +19 -20
- package/lib/components/editors/TMTextArea.d.ts +1 -0
- package/lib/components/editors/TMTextArea.js +23 -15
- package/lib/components/editors/TMTextBox.d.ts +2 -0
- package/lib/components/editors/TMTextBox.js +38 -22
- package/lib/components/features/documents/TMDcmtForm.d.ts +2 -1
- package/lib/components/features/documents/TMDcmtForm.js +107 -8
- package/lib/components/features/documents/TMRelationViewer.js +13 -32
- package/lib/components/features/search/TMSearch.d.ts +2 -1
- package/lib/components/features/search/TMSearch.js +2 -2
- package/lib/components/features/search/TMSearchResult.d.ts +2 -1
- package/lib/components/features/search/TMSearchResult.js +13 -40
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +4 -2
- package/lib/components/features/search/TMSignatureInfoContent.js +373 -79
- package/lib/components/forms/Login/TMLoginForm.d.ts +2 -0
- package/lib/components/forms/Login/TMLoginForm.js +17 -3
- package/lib/components/forms/Login/TextBox.d.ts +3 -0
- package/lib/components/forms/Login/TextBox.js +2 -2
- package/lib/components/pages/TMPage.js +3 -1
- package/lib/components/query/TMQueryEditor.js +1 -1
- package/lib/components/viewers/TMMidViewer.js +1 -1
- package/lib/helper/Globalization.d.ts +1 -1
- package/lib/helper/SDKUI_Globals.js +22 -2
- package/lib/helper/SDKUI_Localizator.d.ts +9 -0
- package/lib/helper/SDKUI_Localizator.js +90 -0
- package/lib/helper/TMUtils.d.ts +29 -1
- package/lib/helper/TMUtils.js +249 -10
- package/lib/helper/grafometricSignaturesCache.d.ts +45 -0
- package/lib/helper/grafometricSignaturesCache.js +56 -0
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/hooks/useDocumentOperations.d.ts +2 -1
- package/lib/hooks/useDocumentOperations.js +15 -15
- package/lib/hooks/usePreventFileDrop.js +14 -3
- package/lib/ts/graphometricTypes.d.ts +62 -0
- package/lib/ts/graphometricTypes.js +1 -0
- package/lib/ts/index.d.ts +1 -0
- package/lib/ts/index.js +1 -0
- package/package.json +66 -61
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Workbook } from 'devextreme-exceljs-fork';
|
|
4
|
-
import { buildValueToLabelMapFromDataColumns, getExceptionMessage, SDKUI_Localizator } from '../../helper';
|
|
4
|
+
import { buildValueToLabelMapFromDataColumns, findDataColumnByField, formatValueForExport, getExceptionMessage, SDKUI_Localizator } from '../../helper';
|
|
5
5
|
import TMCheckBox from '../editors/TMCheckBox';
|
|
6
6
|
import TMButton from './TMButton';
|
|
7
7
|
import TMModal from './TMModal';
|
|
@@ -96,43 +96,52 @@ const TMDataGridExportForm = (props) => {
|
|
|
96
96
|
if (mapForField) {
|
|
97
97
|
result = mapForField.get(value) ?? value;
|
|
98
98
|
}
|
|
99
|
-
else {
|
|
100
|
-
result = value;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// If the column is a datetime type, attempt to format it as a locale date string
|
|
104
|
-
if (col.dataType === 'datetime' && result) {
|
|
105
|
-
const parsedDate = new Date(result);
|
|
106
|
-
if (!isNaN(parsedDate.getTime())) {
|
|
107
|
-
result = parsedDate.toLocaleDateString();
|
|
108
|
-
}
|
|
109
99
|
}
|
|
110
|
-
//
|
|
111
|
-
|
|
100
|
+
// Find column and format value
|
|
101
|
+
const dataCol = findDataColumnByField(columns, col.dataField, col.caption);
|
|
102
|
+
return formatValueForExport(result, dataCol, col.dataType);
|
|
112
103
|
};
|
|
113
104
|
switch (formatSelected) {
|
|
114
105
|
case 'csv': {
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
// Escape dei valori CSV per gestire separatori, virgolette e ritorni a capo
|
|
107
|
+
const escapeCsv = (v) => { const s = String(v ?? ''); return /[;"\r\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s; };
|
|
108
|
+
// Recupera il nome della colonna e lo prepara per il formato CSV
|
|
109
|
+
const getHeader = (c) => escapeCsv(c.caption ?? c.dataField);
|
|
110
|
+
// Crea la prima riga del CSV con le intestazioni delle colonne
|
|
111
|
+
const rows = [
|
|
112
|
+
(exportSelectedFormatColumns
|
|
113
|
+
? [SDKUI_Localizator.SelectedSingular, ...visibleColumns.map(getHeader)]
|
|
114
|
+
: visibleColumns.map(getHeader)).join(';')
|
|
115
|
+
];
|
|
116
|
+
// Scorre tutte le righe da esportare
|
|
119
117
|
rowsToExport.forEach((item, idx) => {
|
|
118
|
+
// Recupera l'indice originale della riga per verificare la selezione
|
|
120
119
|
const originalIndex = exportSelectedOnly ? selectedRowKeys[idx] : dataSource.indexOf(item);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
120
|
+
// Costruisce i valori della riga corrente
|
|
121
|
+
const values = [
|
|
122
|
+
// Aggiunge lo stato selezionato/deselezionato se richiesto
|
|
123
|
+
...(exportSelectedFormatColumns
|
|
124
|
+
? [selectedSet.has(originalIndex) ? SDKUI_Localizator.SelectedSingular : SDKUI_Localizator.Deselected]
|
|
125
|
+
: []),
|
|
126
|
+
// Aggiunge i valori delle colonne applicando l'escape CSV
|
|
127
|
+
...visibleColumns.map(col => escapeCsv(col.dataField ? getValue(col, item[col.dataField]) : ''))
|
|
128
|
+
];
|
|
129
|
+
// Aggiunge la riga completa al contenuto CSV
|
|
130
|
+
rows.push(values.join(';'));
|
|
132
131
|
});
|
|
133
|
-
|
|
132
|
+
// Crea il file CSV aggiungendo il BOM UTF-8 per la corretta lettura degli accenti in Excel
|
|
133
|
+
const blob = new Blob(['\uFEFF', rows.join('\r\n')], { type: 'text/csv;charset=utf-8;' });
|
|
134
|
+
// Avvia il download del file generato
|
|
134
135
|
downloadFile(blob, formatSelected);
|
|
135
|
-
|
|
136
|
+
// Registra il risultato positivo dell'operazione di esportazione
|
|
137
|
+
result.push({
|
|
138
|
+
rowIndex: 1,
|
|
139
|
+
id1: 1,
|
|
140
|
+
id2: 0,
|
|
141
|
+
description: SDKUI_Localizator.OperationSuccess,
|
|
142
|
+
resultType: ResultTypes.SUCCESS
|
|
143
|
+
});
|
|
144
|
+
// Termina il caso CSV nello switch
|
|
136
145
|
break;
|
|
137
146
|
}
|
|
138
147
|
case 'xlsx': {
|
|
@@ -101,7 +101,7 @@ const TMModal = ({ resizable = true, expandable = false, isModal = true, title =
|
|
|
101
101
|
setShowPopup(false);
|
|
102
102
|
onClose && onClose();
|
|
103
103
|
};
|
|
104
|
-
return (_jsx(_Fragment, { children: isModal ? (_jsx(Popup, { ref: popupRef, showCloseButton: showHeader ? showCloseButton : false, showTitle: showHeader, animation: undefined, minWidth: minWidth, minHeight: minHeight, maxHeight: '95%', maxWidth: '95%', dragEnabled: !isResizing, resizeEnabled: resizable, width: expandable && isFullScreen ? '95%' : initialWidth, height: expandable && isFullScreen ? '95%' : initialHeight, title: title, visible: showPopup, onShown: handleShown, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd, onHiding: onHiding, toolbarItems: showHeader && expandable ? [
|
|
104
|
+
return (_jsx(_Fragment, { children: isModal ? (_jsx(Popup, { ref: popupRef, showCloseButton: showHeader ? showCloseButton : false, showTitle: showHeader, animation: undefined, minWidth: minWidth, minHeight: minHeight, maxHeight: '95%', maxWidth: '95%', dragEnabled: !isResizing && !isFullScreen, resizeEnabled: resizable && !isFullScreen, position: expandable && isFullScreen ? { my: 'center', at: 'center', of: window } : undefined, width: expandable && isFullScreen ? '95%' : initialWidth, height: expandable && isFullScreen ? '95%' : initialHeight, title: title, visible: showPopup, onShown: handleShown, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd, onHiding: onHiding, toolbarItems: showHeader && expandable ? [
|
|
105
105
|
{
|
|
106
106
|
widget: 'dxButton',
|
|
107
107
|
location: 'after',
|
|
@@ -38,5 +38,7 @@ interface ITMDynDataListItemChooserFormProps extends ITMChooserFormProps<DataLis
|
|
|
38
38
|
layoutMode?: LayoutModes;
|
|
39
39
|
dynDL?: DynamicDataListDescriptor;
|
|
40
40
|
searchResult?: SearchResultDescriptor;
|
|
41
|
+
/** Se presente, sono i parametri da passare alla query per recuperare il dataSource */
|
|
42
|
+
queryParamsDynDataList?: string[];
|
|
41
43
|
}
|
|
42
44
|
export declare const TMDynDataListItemChooserForm: (props: ITMDynDataListItemChooserFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -122,7 +122,7 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
|
|
|
122
122
|
updateIsModalOpen?.(true);
|
|
123
123
|
}
|
|
124
124
|
}, elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, openEditorOnSummaryClick: openChooserBySingleClick, label: label, template: renderTemplate(), onClearClick: showClearButton ? () => { onValueChanged?.([]); } : undefined, validationItems: validationItems }), showChooser &&
|
|
125
|
-
_jsx(TMDynDataListItemChooserForm, { TID: tid, MID: md?.id, dynDL: dynDl, title: titleForm, allowMultipleSelection: allowMultipleSelection, searchResult: dataSource, selectedIDs: values, onClose: () => {
|
|
125
|
+
_jsx(TMDynDataListItemChooserForm, { TID: tid, MID: md?.id, dynDL: dynDl, title: titleForm, allowMultipleSelection: allowMultipleSelection, searchResult: dataSource, selectedIDs: values, queryParamsDynDataList: queryParamsDynDataList, onClose: () => {
|
|
126
126
|
setShowChooser(false);
|
|
127
127
|
updateIsModalOpen?.(false);
|
|
128
128
|
summaryInputRef.current?.focus();
|
|
@@ -167,7 +167,7 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
|
|
|
167
167
|
export default TMDynDataListItemChooser;
|
|
168
168
|
const cellRenderIcon = () => _jsx(IconDetails, {});
|
|
169
169
|
export const TMDynDataListItemChooserForm = (props) => {
|
|
170
|
-
const { TID, MID, layoutMode, dynDL, searchResult, selectedIDs, title, width, height, onChoose } = props;
|
|
170
|
+
const { TID, MID, layoutMode, dynDL, searchResult, selectedIDs, title, width, height, onChoose, queryParamsDynDataList } = props;
|
|
171
171
|
// Generate unique keys for all columns
|
|
172
172
|
const uniqueKeys = generateUniqueColumnKeys(searchResult?.dtdResult?.columns, searchResult?.fromTID);
|
|
173
173
|
const dataColumns = searchResult?.dtdResult?.columns?.map((col, index) => {
|
|
@@ -184,12 +184,10 @@ export const TMDynDataListItemChooserForm = (props) => {
|
|
|
184
184
|
});
|
|
185
185
|
const keyValue = uniqueKeys[dynDL?.selectItemForValue ?? 0] ?? '';
|
|
186
186
|
const getItems = async (refreshCache) => {
|
|
187
|
-
if (!searchResult)
|
|
188
|
-
return [];
|
|
189
187
|
if (refreshCache)
|
|
190
188
|
DataListCacheService.RemoveAll();
|
|
191
189
|
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
|
192
|
-
let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(TID, MID, layoutMode, [])
|
|
190
|
+
let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(TID, MID, layoutMode, queryParamsDynDataList ?? [])
|
|
193
191
|
.catch((err) => { TMSpinner.hide(); TMExceptionBoxManager.show({ exception: err }); });
|
|
194
192
|
TMSpinner.hide();
|
|
195
193
|
return result ? searchResultDescriptorToSimpleArray(result) ?? [] : [];
|
|
@@ -200,5 +198,5 @@ export const TMDynDataListItemChooserForm = (props) => {
|
|
|
200
198
|
titleDataList += `: ${title}`;
|
|
201
199
|
return titleDataList;
|
|
202
200
|
};
|
|
203
|
-
return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: props.allowMultipleSelection, width: width, height: height, keyName: keyValue ?? '', showDefaultColumns: false, hasShowId: false, columns: dataColumns, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon,
|
|
201
|
+
return (_jsx(TMChooserForm, { title: getTitle(), allowMultipleSelection: props.allowMultipleSelection, width: width, height: height, keyName: keyValue ?? '', showDefaultColumns: false, hasShowId: false, columns: dataColumns, selectedIDs: selectedIDs, cellRenderIcon: cellRenderIcon, getItems: getItems, onClose: props.onClose, onChoose: (IDs) => onChoose?.(IDs) }));
|
|
204
202
|
};
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ValidationItem } from '@topconsultnpm/sdk-ts';
|
|
2
|
+
import { MetadataFormats, ValidationItem } from '@topconsultnpm/sdk-ts';
|
|
3
3
|
import { IDateBoxOptions } from 'devextreme-react/date-box';
|
|
4
4
|
import { DateDisplayTypes } from '../../helper';
|
|
5
5
|
interface ITMDateBoxProps extends IDateBoxOptions {
|
|
6
|
+
/** Tipo di picker da mostrare: Date (solo calendario), Time (solo ora), DateTime (entrambi). Determina quali controlli appaiono nel dropdown. */
|
|
6
7
|
dateDisplayType?: DateDisplayTypes;
|
|
8
|
+
/** Lista di errori/warning di validazione da mostrare sotto il campo */
|
|
7
9
|
validationItems?: ValidationItem[];
|
|
10
|
+
/** Se true, evidenzia il campo come modificato (bordo e testo colorati) */
|
|
8
11
|
isModifiedWhen?: boolean;
|
|
12
|
+
/** Se true, serializza la data nel formato ISO 'yyyy-MM-ddTHH:mm:ss' */
|
|
9
13
|
useDateSerializationFormat?: boolean;
|
|
14
|
+
/** Elemento DOM contenitore per il dropdown del calendario */
|
|
10
15
|
containerElement?: Element;
|
|
16
|
+
/** Pulsanti aggiuntivi da mostrare nel campo */
|
|
11
17
|
buttons?: any;
|
|
18
|
+
/** Se true (default), resetta l'ora a 00:00:00 quando si preme un tasto */
|
|
12
19
|
resetTimeToZeroOnKeyPress?: boolean;
|
|
20
|
+
/** Icona da mostrare a sinistra del campo */
|
|
13
21
|
icon?: any;
|
|
22
|
+
/** Padding del contenitore esterno */
|
|
14
23
|
padding?: string;
|
|
24
|
+
/** Cultura/locale per la formattazione (es. 'en-gb', 'it-it'). Usata per tradurre i nomi dei mesi/giorni nella lingua corretta. */
|
|
25
|
+
formatCulture?: string;
|
|
26
|
+
/** Formato di visualizzazione della data (es. ShortDate='17/07/2026', LongDate='17 July 2026'). Determina come la data viene rappresentata come stringa nel campo. */
|
|
27
|
+
metadataFormat?: MetadataFormats;
|
|
28
|
+
/** Messaggio personalizzato per data non valida. Se non specificato, genera automaticamente un messaggio con esempio del formato (es. 'Formato richiesto: 20/07/2026') */
|
|
29
|
+
invalidDateMessage?: string;
|
|
15
30
|
}
|
|
16
31
|
declare const TMDateBox: React.FC<ITMDateBoxProps>;
|
|
17
32
|
export default TMDateBox;
|
|
@@ -1,35 +1,103 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef } from 'react';
|
|
2
|
+
import { useEffect, useId, useMemo, useRef } from 'react';
|
|
3
3
|
import { DateBox } from 'devextreme-react';
|
|
4
|
-
import {
|
|
4
|
+
import { MetadataFormats } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
import { DateDisplayTypes, Globalization, SDKUI_Localizator } from '../../helper';
|
|
5
6
|
import { TMColors } from '../../utils/theme';
|
|
6
7
|
import TMVilViewer from '../base/TMVilViewer';
|
|
8
|
+
import { formatDateTimeByMetadataFormat } from '../../helper/TMUtils';
|
|
7
9
|
const TMDateBox = (props) => {
|
|
8
|
-
const
|
|
10
|
+
const { dateDisplayType, validationItems, isModifiedWhen, useDateSerializationFormat, containerElement, resetTimeToZeroOnKeyPress, icon, padding, formatCulture, metadataFormat, invalidDateMessage, readOnly, showClearButton, disabled, displayFormat, label, type, value, width, onValueChange, onInitialized, onContentReady, placeholder, name, inputAttr } = props;
|
|
11
|
+
const resetTimeToZero = resetTimeToZeroOnKeyPress ?? true;
|
|
9
12
|
const autoId = useId();
|
|
10
|
-
const effectiveInputAttr = { id: autoId, ...
|
|
13
|
+
const effectiveInputAttr = { id: autoId, ...inputAttr };
|
|
14
|
+
// Determina se il formato richiede nomi testuali (mesi/giorni) che dipendono dalla cultura
|
|
15
|
+
const requiresTextualFormat = useMemo(() => {
|
|
16
|
+
// Solo i formati con "Long" nella data hanno nomi di mesi/giorni che variano per cultura
|
|
17
|
+
return metadataFormat === MetadataFormats.LongDate ||
|
|
18
|
+
metadataFormat === MetadataFormats.LongDateShortTime ||
|
|
19
|
+
metadataFormat === MetadataFormats.LongDateLongTime;
|
|
20
|
+
}, [metadataFormat]);
|
|
21
|
+
// Funzione di formattazione personalizzata per rispettare formatCulture
|
|
22
|
+
// Usata SOLO per formati con nomi testuali (LongDate, LongDateShortTime, LongDateLongTime) e se formatCulture è specificato
|
|
23
|
+
const customDisplayFormat = useMemo(() => {
|
|
24
|
+
// Usa funzione custom solo se c'è formatCulture E il formato richiede nomi testuali
|
|
25
|
+
if (!formatCulture || !requiresTextualFormat)
|
|
26
|
+
return undefined;
|
|
27
|
+
// Restituisce una funzione che DevExtreme userà per formattare la data
|
|
28
|
+
return (date) => {
|
|
29
|
+
try {
|
|
30
|
+
if (!date)
|
|
31
|
+
return '';
|
|
32
|
+
// Assicurati che sia un oggetto Date valido
|
|
33
|
+
const dateObj = date instanceof Date ? date : new Date(date);
|
|
34
|
+
if (isNaN(dateObj.getTime()))
|
|
35
|
+
return '';
|
|
36
|
+
return formatDateTimeByMetadataFormat(dateObj, metadataFormat, formatCulture);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Fallback: restituisce stringa ISO o vuota in caso di errore
|
|
40
|
+
try {
|
|
41
|
+
return date instanceof Date ? date.toISOString() : String(date ?? '');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, [formatCulture, metadataFormat, requiresTextualFormat]);
|
|
49
|
+
// Genera il messaggio di errore con esempio del formato supportato
|
|
50
|
+
const computedInvalidDateMessage = useMemo(() => {
|
|
51
|
+
try {
|
|
52
|
+
if (invalidDateMessage)
|
|
53
|
+
return invalidDateMessage;
|
|
54
|
+
// Genera un esempio usando la data corrente
|
|
55
|
+
const exampleDate = new Date();
|
|
56
|
+
let exampleFormatted;
|
|
57
|
+
if (customDisplayFormat) {
|
|
58
|
+
// Usa la funzione custom se disponibile
|
|
59
|
+
exampleFormatted = customDisplayFormat(exampleDate);
|
|
60
|
+
}
|
|
61
|
+
else if (typeof displayFormat === 'string') {
|
|
62
|
+
// Usa formatDateTimeByMetadataFormat se abbiamo un formato stringa
|
|
63
|
+
exampleFormatted = formatDateTimeByMetadataFormat(exampleDate, metadataFormat, formatCulture) || displayFormat;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Fallback: usa il formato di Globalization o localizzazione standard
|
|
67
|
+
const globFormat = Globalization.getDateDisplayFormat(dateDisplayType);
|
|
68
|
+
exampleFormatted = typeof globFormat === 'string' ? globFormat : exampleDate.toLocaleDateString(formatCulture || 'it-IT');
|
|
69
|
+
}
|
|
70
|
+
if (!exampleFormatted)
|
|
71
|
+
return SDKUI_Localizator.ValueMustBeDateOrTime;
|
|
72
|
+
return `${SDKUI_Localizator.RequiredFormat}: ${exampleFormatted}`;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// In caso di errore, usa il messaggio generico tradotto
|
|
76
|
+
return SDKUI_Localizator.ValueMustBeDateOrTime;
|
|
77
|
+
}
|
|
78
|
+
}, [invalidDateMessage, customDisplayFormat, displayFormat, dateDisplayType, metadataFormat, formatCulture]);
|
|
11
79
|
useEffect(() => {
|
|
12
80
|
let htmlElement = dateBoxRef?.current?.instance().element();
|
|
13
81
|
if (!htmlElement)
|
|
14
82
|
return;
|
|
15
|
-
let borderColor =
|
|
16
|
-
let textColor =
|
|
83
|
+
let borderColor = isModifiedWhen ? TMColors.tertiary : TMColors.border_normal;
|
|
84
|
+
let textColor = isModifiedWhen ? TMColors.isModified : TMColors.text_normal;
|
|
17
85
|
let inputContainer = htmlElement.getElementsByClassName("dx-texteditor-input-container")[0];
|
|
18
86
|
if (inputContainer) {
|
|
19
|
-
inputContainer.style.background =
|
|
20
|
-
inputContainer.style.color =
|
|
87
|
+
inputContainer.style.background = readOnly ? 'linear-gradient(white 20%, #d6d6d6 80%)' : '';
|
|
88
|
+
inputContainer.style.color = readOnly ? '#525252' : textColor;
|
|
21
89
|
}
|
|
22
90
|
let input = htmlElement.querySelector(".dx-texteditor-input");
|
|
23
91
|
if (input) {
|
|
24
|
-
if (!
|
|
92
|
+
if (!readOnly) {
|
|
25
93
|
input.style.color = textColor;
|
|
26
94
|
}
|
|
27
95
|
input.style.fontSize = 'var(--base-font-size)';
|
|
28
96
|
input.style.fontFamily = 'var(--base-font-family)';
|
|
29
97
|
}
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
|
|
98
|
+
let labelEl = htmlElement.getElementsByClassName("dx-label")[0];
|
|
99
|
+
if (labelEl) {
|
|
100
|
+
labelEl.style.borderBottomColor = borderColor;
|
|
33
101
|
}
|
|
34
102
|
let labelBefore = htmlElement.getElementsByClassName("dx-label-before")[0];
|
|
35
103
|
if (labelBefore) {
|
|
@@ -43,13 +111,13 @@ const TMDateBox = (props) => {
|
|
|
43
111
|
labelAfter.style.borderTopColor = borderColor;
|
|
44
112
|
labelAfter.style.borderInlineEndColor = borderColor;
|
|
45
113
|
}
|
|
46
|
-
}, [
|
|
114
|
+
}, [isModifiedWhen, readOnly]);
|
|
47
115
|
const dateBoxRef = useRef(null);
|
|
48
116
|
// soluzione tratta da https://supportcenter.devexpress.com/ticket/details/t1025617/setting-default-time-in-datebox
|
|
49
117
|
const dropDownOptions = {
|
|
50
|
-
container:
|
|
118
|
+
container: containerElement,
|
|
51
119
|
onShown: (e) => {
|
|
52
|
-
if (
|
|
120
|
+
if (value != undefined)
|
|
53
121
|
return;
|
|
54
122
|
let dateBoxInstance = dateBoxRef.current?.instance();
|
|
55
123
|
const currentDate = new Date();
|
|
@@ -59,13 +127,13 @@ const TMDateBox = (props) => {
|
|
|
59
127
|
}
|
|
60
128
|
};
|
|
61
129
|
const getType = () => {
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
64
|
-
if (!
|
|
130
|
+
if (type != undefined)
|
|
131
|
+
return type;
|
|
132
|
+
if (!dateDisplayType || dateDisplayType == DateDisplayTypes.DateTime)
|
|
65
133
|
return "datetime";
|
|
66
|
-
return
|
|
134
|
+
return dateDisplayType == DateDisplayTypes.Date ? "date" : "time";
|
|
67
135
|
};
|
|
68
|
-
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center', width: '100%', padding:
|
|
136
|
+
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center', width: '100%', padding: padding }, children: [icon && (_jsx("span", { style: { marginRight: '8px', marginTop: '8px', display: 'flex', alignItems: 'center' }, children: icon })), _jsxs("div", { onContextMenu: (e) => e.stopPropagation(), style: { display: 'flex', flexDirection: 'column', gap: '5px', width: '100%' }, children: [_jsx(DateBox, { readOnly: readOnly, ref: dateBoxRef, showClearButton: showClearButton, dateSerializationFormat: useDateSerializationFormat ? 'yyyy-MM-ddTHH:mm:ss' : undefined, disabled: disabled, displayFormat: customDisplayFormat ?? displayFormat ?? Globalization.getDateDisplayFormat(dateDisplayType), dropDownOptions: dropDownOptions, invalidDateMessage: computedInvalidDateMessage, label: label, labelMode: 'static', type: getType(), useMaskBehavior: !customDisplayFormat, height: '28px', value: value, width: width, valueChangeEvent: 'keyup input change', onValueChange: (e) => { onValueChange?.(e); }, onInitialized: (e) => { onInitialized?.(e); }, onContentReady: (e) => { onContentReady?.(e); }, placeholder: placeholder, ...(name && { name: name }), inputAttr: effectiveInputAttr, onKeyUp: (e) => {
|
|
69
137
|
if (e.event?.code == "Space") {
|
|
70
138
|
const currentDate = new Date();
|
|
71
139
|
currentDate.setHours(0, 0, 0, 0);
|
|
@@ -73,7 +141,7 @@ const TMDateBox = (props) => {
|
|
|
73
141
|
}
|
|
74
142
|
}, onValueChanged: (e) => {
|
|
75
143
|
if (resetTimeToZero) {
|
|
76
|
-
if (
|
|
144
|
+
if (value != undefined)
|
|
77
145
|
return;
|
|
78
146
|
if (!e.value)
|
|
79
147
|
return;
|
|
@@ -81,6 +149,6 @@ const TMDateBox = (props) => {
|
|
|
81
149
|
currentDate.setHours(0, 0, 0, 0);
|
|
82
150
|
e.component.option("value", currentDate.toISOString());
|
|
83
151
|
}
|
|
84
|
-
} }), _jsx(TMVilViewer, { vil:
|
|
152
|
+
} }), _jsx(TMVilViewer, { vil: validationItems })] })] }));
|
|
85
153
|
};
|
|
86
154
|
export default TMDateBox;
|
|
@@ -10,21 +10,10 @@ import TMTextBox from './TMTextBox';
|
|
|
10
10
|
import { TMMetadataIcon } from '../viewers/TMMidViewer';
|
|
11
11
|
import TMTextArea from './TMTextArea';
|
|
12
12
|
import { DateDisplayTypes } from '../../helper/Globalization';
|
|
13
|
+
import { getCurrencySymbol, getDevExtremeDateDisplayFormat } from '../../helper/TMUtils';
|
|
13
14
|
const renderMetadataIcon = (tid, md, layoutMode, isMetadataSelected, showLabel) => {
|
|
14
15
|
return (_jsx(TMMetadataIcon, { isMetadataSelected: isMetadataSelected, layoutMode: layoutMode, md: md, tid: tid, elementStyle: showLabel ? { position: 'relative', top: '4px' } : undefined }));
|
|
15
16
|
};
|
|
16
|
-
const getDateDisplayFormat = (format) => {
|
|
17
|
-
format = format ?? MetadataFormats.None;
|
|
18
|
-
switch (format) {
|
|
19
|
-
case MetadataFormats.LongTime: return "longTime";
|
|
20
|
-
case MetadataFormats.ShortTime: return "shortTime";
|
|
21
|
-
case MetadataFormats.ShortDateLongTime:
|
|
22
|
-
case MetadataFormats.ShortDateShortTime:
|
|
23
|
-
case MetadataFormats.LongDateLongTime:
|
|
24
|
-
case MetadataFormats.LongDateShortTime: return "shortDateShortTime";
|
|
25
|
-
default: return "shortDate";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
17
|
const getDateDisplayType = (format) => {
|
|
29
18
|
format = format ?? MetadataFormats.None;
|
|
30
19
|
switch (format) {
|
|
@@ -37,6 +26,13 @@ const getDateDisplayType = (format) => {
|
|
|
37
26
|
default: return DateDisplayTypes.Date;
|
|
38
27
|
}
|
|
39
28
|
};
|
|
29
|
+
const getTextTransform = (format) => {
|
|
30
|
+
switch (format) {
|
|
31
|
+
case MetadataFormats.LowerCase: return 'lowercase';
|
|
32
|
+
case MetadataFormats.UpperCase: return 'uppercase';
|
|
33
|
+
default: return undefined;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
40
36
|
const TMMetadataEditor = ({ isSelected = false, customLabel, isReadOnly, isLexProt, layoutMode, queryOperator, isEditable, isModifiedWhen = false, tid, mid, value, queryParamsDynDataList, containerElement, autoFocus, validationItems = [], disabled = false, openChooserBySingleClick = true, onValueChanged, onValueChange, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, updateIsModalOpen }) => {
|
|
41
37
|
const [md, setMd] = useState();
|
|
42
38
|
useEffect(() => {
|
|
@@ -104,23 +100,26 @@ const TMMetadataEditor = ({ isSelected = false, customLabel, isReadOnly, isLexPr
|
|
|
104
100
|
else
|
|
105
101
|
onValueChanged?.(IDs.join(","));
|
|
106
102
|
}, updateIsModalOpen: updateIsModalOpen });
|
|
107
|
-
if (showAsText)
|
|
108
|
-
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', showClearButton: !isReadOnlyResult, maxLength: maxLength, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
if (showAsText) {
|
|
104
|
+
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', showClearButton: !isReadOnlyResult, maxLength: maxLength, autoFocus: autoFocus, value: value ?? '', textTransform: getTextTransform(md?.format?.format), onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
105
|
+
}
|
|
106
|
+
if (showAsNumber) {
|
|
107
|
+
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: !isReadOnlyResult, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', currencySymbol: getCurrencySymbol(md?.format?.format), onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
108
|
+
}
|
|
111
109
|
switch (md?.dataType) {
|
|
112
110
|
case MetadataDataTypes.DateTime:
|
|
113
|
-
return _jsx(TMDateBox, { placeholder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', dateDisplayType: getDateDisplayType(md.format?.format), displayFormat:
|
|
111
|
+
return _jsx(TMDateBox, { placeholder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', dateDisplayType: getDateDisplayType(md.format?.format), displayFormat: getDevExtremeDateDisplayFormat(md.format?.format, md.format?.formatCulture), formatCulture: md.format?.formatCulture, metadataFormat: md.format?.format, isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, icon: showLabelTop ? icon : undefined, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, validationItems: validationItems, disabled: disabled, width: '100%', value: value, showClearButton: !isReadOnlyResult, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => {
|
|
114
112
|
onValueChange?.(newValue ? newValue.toString() : undefined);
|
|
115
113
|
onValueChanged?.(newValue ? newValue.toString() : undefined);
|
|
116
114
|
} });
|
|
117
|
-
case MetadataDataTypes.Number:
|
|
115
|
+
case MetadataDataTypes.Number:
|
|
116
|
+
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: !isReadOnlyResult, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', currencySymbol: getCurrencySymbol(md?.format?.format), onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
|
|
118
117
|
default:
|
|
119
118
|
if (showByTextarea) {
|
|
120
|
-
return _jsx(TMTextArea, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', rows: 1, readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, isModifiedWhen: isModifiedWhenInternal(), validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, autoFocus: autoFocus, maxLength: maxLength, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); }, resize: false });
|
|
119
|
+
return _jsx(TMTextArea, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', rows: 1, readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, isModifiedWhen: isModifiedWhenInternal(), validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, autoFocus: autoFocus, maxLength: maxLength, value: value ?? '', textTransform: getTextTransform(md?.format?.format), onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); }, resize: false });
|
|
121
120
|
}
|
|
122
121
|
else {
|
|
123
|
-
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, disabled: disabled, validationItems: validationItems, type: 'text', elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, autoFocus: autoFocus, maxLength: maxLength, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
|
|
122
|
+
return _jsx(TMTextBox, { placeHolder: layoutMode === LayoutModes.Ark ? md?.defaultValue ?? '' : '', isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: (modulesWithLabelTop || showLabelTop) ? (customLabel ?? md?.nameLoc) : undefined, icon: showLabelTop ? icon : undefined, disabled: disabled, validationItems: validationItems, type: 'text', elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, autoFocus: autoFocus, maxLength: maxLength, value: value ?? '', textTransform: getTextTransform(md?.format?.format), onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
};
|
|
@@ -28,7 +28,7 @@ const StyledTextAreaEditorButton = styled.div `
|
|
|
28
28
|
// Define the TMTextArea component
|
|
29
29
|
const TMTextArea = (props) => {
|
|
30
30
|
// Extract properties from the props object
|
|
31
|
-
const { label = '', value = '', width = '100%', height = 'auto', autoFocus = false, showClearButton, validationItems = [], disabled = false, isModifiedWhen = false, fontSize = FontSize.defaultFontSize, elementStyle = {}, icon = null, labelPosition = 'left', readOnly = false, onValueChanged, onBlur, placeHolder, formulaItems = [], buttons = [], maxHeight = 'auto', rows, maxLength, resize = true, autoCalculateRows = true, fillHeight = false, name, id } = props;
|
|
31
|
+
const { label = '', value = '', width = '100%', height = 'auto', autoFocus = false, showClearButton, validationItems = [], disabled = false, isModifiedWhen = false, fontSize = FontSize.defaultFontSize, elementStyle = {}, icon = null, labelPosition = 'left', readOnly = false, onValueChanged, onBlur, placeHolder, formulaItems = [], buttons = [], maxHeight = 'auto', rows, maxLength, resize = true, autoCalculateRows = true, fillHeight = false, name, id, textTransform } = props;
|
|
32
32
|
// Generate a unique id if not provided
|
|
33
33
|
const autoId = useId();
|
|
34
34
|
const effectiveId = id ?? autoId;
|
|
@@ -151,20 +151,28 @@ const TMTextArea = (props) => {
|
|
|
151
151
|
};
|
|
152
152
|
// Renders the textarea
|
|
153
153
|
const renderTextArea = () => {
|
|
154
|
-
const textareaElement = _jsxs(_Fragment, { children: [_jsx(StyledTextareaEditor, { ref: inputRef, id: effectiveId, ...(name && { name }), autoFocus: autoFocus, readOnly: readOnly, disabled: disabled, value: currentValue, placeholder: placeHolder, rows: fillHeight ? undefined : calculatedRows, maxLength: maxLength, spellCheck: false, onFocus: () => setIsFocused(true), onBlur: (e) => { setIsFocused(false); if (currentValue != value)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
154
|
+
const textareaElement = _jsxs(_Fragment, { children: [_jsxs("div", { style: { position: 'relative', ...(fillHeight ? { flex: 1, display: 'flex', flexDirection: 'column' } : {}) }, children: [_jsx(StyledTextareaEditor, { ref: inputRef, id: effectiveId, ...(name && { name }), autoFocus: autoFocus, readOnly: readOnly, disabled: disabled, value: currentValue, placeholder: placeHolder, rows: fillHeight ? undefined : calculatedRows, maxLength: maxLength, spellCheck: false, onFocus: () => setIsFocused(true), onBlur: (e) => { setIsFocused(false); if (currentValue != value)
|
|
155
|
+
onBlur?.(currentValue); }, onChange: (e) => {
|
|
156
|
+
let newValue = e.target.value;
|
|
157
|
+
if (textTransform === 'lowercase')
|
|
158
|
+
newValue = newValue.toLowerCase();
|
|
159
|
+
else if (textTransform === 'uppercase')
|
|
160
|
+
newValue = newValue.toUpperCase();
|
|
161
|
+
setCurrentValue(newValue);
|
|
162
|
+
onValueChanged?.({ ...e, target: { ...e.target, value: newValue } });
|
|
163
|
+
}, "$isMobile": deviceType === DeviceType.MOBILE, "$maxHeight": maxHeight, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$width": width, "$resize": resize, style: fillHeight ? { flex: 1, height: 0 } : undefined }), _jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: '50%', transform: 'translateY(-50%)', pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [formulaItems.length > 0 &&
|
|
164
|
+
_jsx(StyledTextAreaEditorButton, { onClick: () => {
|
|
165
|
+
setShowFormulaItemsChooser(true);
|
|
166
|
+
}, children: _jsx(IconDataList, {}) }), showClearButton && currentValue &&
|
|
167
|
+
_jsx(StyledTextAreaEditorButton, { onClick: () => {
|
|
168
|
+
onValueChanged?.({ target: { value: undefined } });
|
|
169
|
+
setCurrentValue('');
|
|
170
|
+
if (autoCalculateRows)
|
|
171
|
+
setCalculatedRows(1);
|
|
172
|
+
onBlur?.(undefined);
|
|
173
|
+
}, children: _jsx(IconClearButton, {}) }), buttons.map((buttonItem, index) => {
|
|
174
|
+
return (_jsx(StyledTextAreaEditorButton, { onClick: buttonItem.onClick, children: _jsx(TMTooltip, { content: buttonItem.text, children: buttonItem.icon }) }, buttonItem.text));
|
|
175
|
+
})] })] }), openFormulaItemsChooser(), _jsx(TMVilViewer, { vil: validationItems })] });
|
|
168
176
|
// Wrap with context menu if formula items exist
|
|
169
177
|
if (formulaItems.length > 0) {
|
|
170
178
|
return (_jsx(TMContextMenu, { items: getFormulaMenuItems(), trigger: "right", children: textareaElement }));
|
|
@@ -14,6 +14,8 @@ export interface ITMTextBox extends ITMEditorBase {
|
|
|
14
14
|
value?: string | number;
|
|
15
15
|
fromModal?: boolean;
|
|
16
16
|
allowedPattern?: RegExp;
|
|
17
|
+
textTransform?: 'lowercase' | 'uppercase';
|
|
18
|
+
currencySymbol?: string;
|
|
17
19
|
onClick?: () => void;
|
|
18
20
|
onValueChanged?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
21
|
onBlur?: (value: string | undefined) => void;
|