@topconsultnpm/sdkui-react-beta 6.7.103 → 6.7.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
- import { MetadataDataDomains, MetadataDataTypes, DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts-beta';
3
+ import { MetadataDataDomains, MetadataDataTypes, DcmtTypeListCacheService, LayoutModes } from '@topconsultnpm/sdk-ts-beta';
4
4
  import { IconLayerGroup } from '../../helper';
5
5
  import { TMColors } from '../../utils/theme';
6
6
  import ShowAlert from '../base/TMAlert';
@@ -11,52 +11,64 @@ import TMDateBox from './TMDateBox';
11
11
  import TMTextBox from './TMTextBox';
12
12
  import { TMMetadataIcon } from '../viewers/TMMidViewer';
13
13
  import TMTextArea from './TMTextArea';
14
- const TMMetadataEditor = ({ isModifiedWhen = false, hasLabel = false, readOnly, tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, validationItems = [], disabled = false, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
14
+ const TMMetadataEditor = ({ isLexProt, layoutMode, isModifiedWhen = false, tid, mid, value, queryParamsDynDataList, containerElement, allowMultipleSelection, autoFocus, showAsText, showAsNumber, validationItems = [], disabled = false, onValueChanged, onValueChange, onCascadeRefreshDynDataLists }) => {
15
15
  const [md, setMd] = useState();
16
16
  useEffect(() => {
17
17
  DcmtTypeListCacheService.GetAsync(tid).then((dtd) => {
18
18
  setMd(dtd?.metadata?.find(o => o.id == mid));
19
19
  });
20
20
  }, [mid]);
21
- const isReadOnly = readOnly || (md && md.isLexProt === 1) || (md && md.isLexProt === 3);
21
+ const isReadOnlyInternal = () => {
22
+ if (md?.isSystem === 1)
23
+ return true;
24
+ switch (layoutMode) {
25
+ case LayoutModes.Update: return md?.dataDomain === MetadataDataDomains.Computed || (isLexProt === 1 && (md?.isLexProt === 1 || md?.isLexProt === 3));
26
+ default: return false;
27
+ }
28
+ };
29
+ const isModifiedWhenInternal = () => {
30
+ return isModifiedWhen && !md?.isSystem;
31
+ };
32
+ const showLabelTop = (layoutMode === LayoutModes.Update) || (layoutMode === LayoutModes.Ark);
22
33
  const showByTextarea = md && md.length && md?.dataType === MetadataDataTypes.Varchar && md.length > 80;
23
34
  let btnDistincValues = { text: 'Valori distinti', icon: _jsx(IconLayerGroup, { fontSize: 16 }), onClick: () => { ShowAlert({ message: "TODO Valori distinti", mode: 'info', title: `${"TODO"}`, duration: 3000 }); } };
35
+ let isReadOnlyResult = isReadOnlyInternal();
24
36
  if (value?.startsWith("{@QueryParam") || value == "{@UserName}" || value == "{@UserID}")
25
- return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
37
+ return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', maxLength: md?.length, autoFocus: autoFocus, value: value || '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
26
38
  if (md?.dataDomain == MetadataDataDomains.DynamicDataList)
27
- return _jsx(TMDynDataListItemChooser, { readOnly: isReadOnly, isModifiedWhen: isModifiedWhen, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, md: md, tid: tid, buttons: !isReadOnly ? [btnDistincValues] : undefined, queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, allowMultipleSelection: allowMultipleSelection, values: value ? [value] : [], showClearButton: !isReadOnly, onValueChanged: (IDs) => {
39
+ return _jsx(TMDynDataListItemChooser, { readOnly: isReadOnlyResult, isModifiedWhen: isModifiedWhenInternal(), label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, md: md, tid: tid, buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, allowMultipleSelection: allowMultipleSelection, values: value ? [value] : [], showClearButton: !isReadOnlyResult, onValueChanged: (IDs) => {
28
40
  if (!IDs || IDs.length <= 0)
29
41
  onValueChanged?.(undefined);
30
42
  else
31
43
  onValueChanged?.(IDs[0]);
32
44
  } });
33
45
  if (md?.dataDomain == MetadataDataDomains.DataList)
34
- return _jsx(TMDataListItemChooser, { isModifiedWhen: isModifiedWhen, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, dataListId: md.dataListID, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? item : item.slice(1, -1)) ?? [], showClearButton: !isReadOnly, buttons: !isReadOnly ? [btnDistincValues] : undefined, onValueChanged: (IDs) => {
46
+ return _jsx(TMDataListItemChooser, { readOnly: isReadOnlyResult, isModifiedWhen: isModifiedWhenInternal(), label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, dataListId: md.dataListID, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? item : item.slice(1, -1)) ?? [], showClearButton: !isReadOnlyResult, buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, onValueChanged: (IDs) => {
35
47
  if (!IDs || IDs.length <= 0)
36
48
  onValueChanged?.(undefined);
37
49
  else
38
50
  onValueChanged?.(IDs.join(","));
39
51
  } });
40
52
  if (md?.dataDomain == MetadataDataDomains.UserID)
41
- return _jsx(TMUserChooser, { isModifiedWhen: isModifiedWhen, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, placeHolder: " ", showClearButton: !isReadOnly, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? Number(item) : Number(item.slice(1, -1))) ?? [], buttons: !isReadOnly ? [btnDistincValues] : undefined, onValueChanged: (IDs) => {
53
+ return _jsx(TMUserChooser, { readOnly: isReadOnlyResult, isModifiedWhen: isModifiedWhenInternal(), label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, backgroundColor: TMColors.default_background, placeHolder: " ", showClearButton: !isReadOnlyResult, allowMultipleSelection: allowMultipleSelection, values: value?.split(',').map((item) => !item.startsWith("'") ? Number(item) : Number(item.slice(1, -1))) ?? [], buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, onValueChanged: (IDs) => {
42
54
  if (!IDs || IDs.length <= 0)
43
55
  onValueChanged?.(undefined);
44
56
  else
45
57
  onValueChanged?.(IDs.join(","));
46
58
  } });
47
59
  if (showAsText)
48
- return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', buttons: !isReadOnly ? [btnDistincValues] : undefined, showClearButton: !isReadOnly, maxLength: md?.length, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
60
+ return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'text', buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, showClearButton: !isReadOnlyResult, maxLength: md?.length, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
49
61
  if (showAsNumber)
50
- return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: !isReadOnly, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
62
+ return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', showClearButton: !isReadOnlyResult, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
51
63
  switch (md?.dataType) {
52
- case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, label: hasLabel ? md?.nameLoc : undefined, validationItems: validationItems, disabled: disabled, width: '100%', value: value, buttons: !isReadOnly ? [btnDistincValues] : undefined, showClearButton: !isReadOnly, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => { onValueChange?.(newValue ? newValue.toString() : undefined); onValueChanged?.(newValue ? newValue.toString() : undefined); } });
53
- case MetadataDataTypes.Number: return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', buttons: !isReadOnly ? [btnDistincValues] : undefined, showClearButton: !isReadOnly, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
64
+ case MetadataDataTypes.DateTime: return _jsx(TMDateBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, label: showLabelTop ? md?.nameLoc : undefined, validationItems: validationItems, disabled: disabled, width: '100%', value: value, buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, showClearButton: !isReadOnlyResult, useDateSerializationFormat: true, containerElement: containerElement, onValueChange: (newValue) => { onValueChange?.(newValue ? newValue.toString() : undefined); onValueChanged?.(newValue ? newValue.toString() : undefined); } });
65
+ case MetadataDataTypes.Number: return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, type: 'number', buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, showClearButton: !isReadOnlyResult, precision: md?.length, scale: md?.scale, autoFocus: autoFocus, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => onValueChanged?.(newValue) });
54
66
  default:
55
67
  if (showByTextarea) {
56
- return _jsx(TMTextArea, { rows: 1, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, isModifiedWhen: isModifiedWhen, validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, showClearButton: !isReadOnly, buttons: !isReadOnly ? [btnDistincValues] : undefined, autoFocus: autoFocus, maxLength: md?.length, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
68
+ return _jsx(TMTextArea, { rows: 1, readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, isModifiedWhen: isModifiedWhenInternal(), validationItems: validationItems, disabled: disabled, elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, autoFocus: autoFocus, maxLength: md?.length, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
57
69
  }
58
70
  else {
59
- return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhen, readOnly: isReadOnly, label: hasLabel ? md?.nameLoc : undefined, icon: hasLabel ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, disabled: disabled, validationItems: validationItems, type: 'text', elementStyle: { width: '100%' }, showClearButton: !isReadOnly, buttons: !isReadOnly ? [btnDistincValues] : undefined, autoFocus: autoFocus, maxLength: md?.length, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
71
+ return _jsx(TMTextBox, { isModifiedWhen: isModifiedWhenInternal(), readOnly: isReadOnlyResult, label: showLabelTop ? md?.nameLoc : undefined, icon: showLabelTop ? _jsx(TMMetadataIcon, { md: md, tid: tid }) : undefined, disabled: disabled, validationItems: validationItems, type: 'text', elementStyle: { width: '100%' }, showClearButton: !isReadOnlyResult, buttons: !isReadOnlyResult ? [btnDistincValues] : undefined, autoFocus: autoFocus, maxLength: md?.length, value: value ?? '', onValueChanged: (e) => onValueChange?.(e.target.value), onBlur: (newValue) => { onValueChanged?.(newValue); } });
60
72
  }
61
73
  }
62
74
  };
@@ -39,11 +39,11 @@ export declare const cultureIDsDataSource: {
39
39
  }[];
40
40
  declare const TMLoginForm: React.FunctionComponent<ITMLoginFormProps>;
41
41
  export declare const TMChangePassword: ({ deviceType, tmSession, username, onClose, enable, hasBack }: {
42
- deviceType?: DeviceType;
43
- hasBack?: boolean;
44
- tmSession?: ITopMediaSession;
42
+ deviceType?: DeviceType | undefined;
43
+ hasBack?: boolean | undefined;
44
+ tmSession?: ITopMediaSession | undefined;
45
45
  username: string;
46
- onClose?: () => void;
47
- enable?: boolean;
46
+ onClose?: (() => void) | undefined;
47
+ enable?: boolean | undefined;
48
48
  }) => import("react/jsx-runtime").JSX.Element;
49
49
  export default TMLoginForm;