@topconsultnpm/sdkui-react-beta 6.12.17 → 6.12.19

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.
@@ -42,5 +42,5 @@ export const TMDcmtTypeChooserForm = (props) => {
42
42
  return dtdList?.filter(d => d.templateTID && props.filterTemplateTID?.includes(d.templateTID));
43
43
  return dtdList;
44
44
  };
45
- return (_jsx(TMChooserForm, { title: SDK_Localizator.ListDcmtTypeOrView, allowMultipleSelection: props.allowMultipleSelection, hasShowOnlySelectedItems: true, width: props.width, height: props.height, selectedIDs: props.selectedIDs, cellRenderIcon: cellRenderIcon, cellRenderNameAndDesc: cellRenderNameAndDesc, dataSource: props.dataSource, getItems: getItems, onClose: props.onClose, onChoose: (IDs) => props.onChoose?.(IDs) }));
45
+ return (_jsx(TMChooserForm, { title: SDK_Localizator.ListDcmtTypeOrView, allowMultipleSelection: props.allowMultipleSelection, hasShowOnlySelectedItems: props.allowMultipleSelection, width: props.width, height: props.height, selectedIDs: props.selectedIDs, cellRenderIcon: cellRenderIcon, cellRenderNameAndDesc: cellRenderNameAndDesc, dataSource: props.dataSource, getItems: getItems, onClose: props.onClose, onChoose: (IDs) => props.onChoose?.(IDs) }));
46
46
  };
@@ -13,9 +13,6 @@ const Wrapper = styled.div `
13
13
  .highlight {
14
14
  background-color: ${(props) => props.$isSelected ? '#6c9023' : 'yellow'};
15
15
  }
16
- .dx-mention{
17
- color: #000 !important
18
- }
19
16
  a {
20
17
  color: ${(props) => (props.$isSelected ? '#fff' : 'rgb(26, 13, 171)')};
21
18
  }
@@ -33,7 +30,10 @@ const highlightSearchText = (markup, searchText) => {
33
30
  };
34
31
  const TMHtmlContentDisplay = (props) => {
35
32
  const { markup, searchText, isSelected } = props;
36
- const highlightedMarkup = searchText ? highlightSearchText(markup, searchText) : markup;
37
- return (_jsx(Wrapper, { "$isSelected": isSelected, children: _jsx("div", { dangerouslySetInnerHTML: { __html: highlightedMarkup } }) }));
33
+ let updatedMarkup = markup;
34
+ if (searchText) {
35
+ updatedMarkup = highlightSearchText(updatedMarkup, searchText);
36
+ }
37
+ return (_jsx(Wrapper, { "$isSelected": isSelected, children: _jsx("div", { dangerouslySetInnerHTML: { __html: updatedMarkup } }) }));
38
38
  };
39
39
  export default TMHtmlContentDisplay;
@@ -4,8 +4,6 @@ export interface ITMHtmlEditor {
4
4
  width?: string;
5
5
  /** Height of the editor (e.g., '300px') */
6
6
  height?: string;
7
- /** Initial or current value of the editor content as an HTML string */
8
- value?: string;
9
7
  /** Callback function triggered when the content value changes */
10
8
  onValueChanged?: (e: {
11
9
  value: string;
@@ -25,3 +23,5 @@ export interface ITMHtmlEditor {
25
23
  /** If true, enables rich text editing mode */
26
24
  isEditorEnabled?: boolean;
27
25
  }
26
+ declare const TMHtmlEditor: (props: ITMHtmlEditor) => import("react/jsx-runtime").JSX.Element;
27
+ export default TMHtmlEditor;
@@ -4,24 +4,45 @@ import HtmlEditor, { Toolbar, Item } from 'devextreme-react/html-editor';
4
4
  import TMVilViewer from '../base/TMVilViewer';
5
5
  import { SDKUI_Localizator } from '../../helper';
6
6
  const TMHtmlEditor = (props) => {
7
- const { width = "100%", height = "100%", value = "", mentionsConfig, onValueChanged, validationItems = [], isEditorEnabled: isEditorEnabledProp = false } = props;
7
+ const { width = "100%", height = "100%", mentionsConfig, onValueChanged, validationItems = [], isEditorEnabled: isEditorEnabledProp = false } = props;
8
+ // Ref for HtmlEditor instance
8
9
  const editorRef = useRef(null);
10
+ // State for editor enable/disable
9
11
  const [isEditorEnabled, setIsEditorEnabled] = useState(false);
10
- const [markup, setMarkup] = useState(value);
12
+ // State to hold HTML markup
13
+ const [markup, setMarkup] = useState("");
14
+ // Effect hook to handle quill instance and @mention behavior
15
+ useEffect(() => {
16
+ if (editorRef.current) {
17
+ const instance = editorRef.current.instance();
18
+ const quill = instance.getQuillInstance();
19
+ // Listen for text changes
20
+ quill.on('text-change', (delta) => {
21
+ const html = instance.option('value');
22
+ // Remove span tags and replace non-breaking spaces
23
+ const cleaned = html.replace(/<span[^>]*>|<\/span>/g, '').replace(/&nbsp;/g, ' ');
24
+ // Update value only if changed
25
+ if (html !== cleaned) {
26
+ instance.option('value', cleaned);
27
+ }
28
+ });
29
+ }
30
+ }, [markup]);
31
+ // Handler for value change
11
32
  const onValueChangeCallback = (text) => {
12
33
  setMarkup(text);
13
34
  if (onValueChanged) {
14
35
  onValueChanged({ value: text });
15
36
  }
16
37
  };
38
+ // Update isEditorEnabled when prop changes
17
39
  useEffect(() => {
18
40
  setIsEditorEnabled(isEditorEnabledProp);
19
41
  }, [isEditorEnabledProp]);
20
- useEffect(() => {
21
- setMarkup(value);
22
- }, [value]);
42
+ // Memoized check for validation errors
23
43
  const hasValidationErrors = useMemo(() => {
24
44
  return validationItems && validationItems.length > 0;
25
45
  }, [validationItems]);
26
- return (_jsxs("div", { style: { height: validationItems.length > 0 ? `calc(${height} - 30px)` : "100%", width: width }, children: [_jsx("div", { style: { borderWidth: '1px', borderStyle: 'solid', borderColor: hasValidationErrors ? "red" : "#e0e0e0 #e0e0e0 #616161", width: "100%", height: "100%" }, children: _jsx(HtmlEditor, { placeholder: SDKUI_Localizator.TypeAMessage + "...", ref: editorRef, width: "100%", height: "100%", value: markup, onValueChange: onValueChangeCallback, mentions: mentionsConfig, style: { overflow: 'hidden', outline: "none" }, children: isEditorEnabled && (_jsxs(Toolbar, { multiline: false, children: [_jsx(Item, { name: "undo" }), _jsx(Item, { name: "redo" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "bold" }), _jsx(Item, { name: "italic" }), _jsx(Item, { name: "underline" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "orderedList" }), _jsx(Item, { name: "bulletList" })] })) }) }), _jsx("div", { style: { width: "100%", height: validationItems.length > 0 ? "30px" : '0px' }, children: _jsx(TMVilViewer, { vil: validationItems }) })] }));
46
+ return (_jsxs("div", { style: { height: validationItems.length > 0 ? `calc(${height} - 30px)` : "100%", width: width }, children: [_jsx("div", { className: "custom-mentions-wrapper", style: { borderWidth: '1px', borderStyle: 'solid', borderColor: hasValidationErrors ? "red" : "#e0e0e0 #e0e0e0 #616161", width: "100%", height: "100%" }, children: _jsx(HtmlEditor, { ref: editorRef, placeholder: SDKUI_Localizator.TypeAMessage + "...", width: "100%", height: "100%", value: markup, onValueChange: onValueChangeCallback, mentions: mentionsConfig, style: { overflow: 'hidden', outline: "none" }, children: isEditorEnabled && (_jsxs(Toolbar, { multiline: false, children: [_jsx(Item, { name: "undo" }), _jsx(Item, { name: "redo" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "bold" }), _jsx(Item, { name: "italic" }), _jsx(Item, { name: "underline" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "orderedList" }), _jsx(Item, { name: "bulletList" })] })) }) }), _jsx("div", { style: { width: "100%", height: validationItems.length > 0 ? "30px" : '0px' }, children: _jsx(TMVilViewer, { vil: validationItems }) })] }));
27
47
  };
48
+ export default TMHtmlEditor;
@@ -14,7 +14,7 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, startWithShowO
14
14
  const [allItems, setAllItems] = useState([]);
15
15
  const [filteredItems, setFilteredItems] = useState([]);
16
16
  const [selectedRowKeys, setSelectedRowKeys] = useState(selectedIDs ?? []);
17
- const [focusedRowKey, setFocusedRowKey] = useState(undefined);
17
+ const [focusedRowKey, setFocusedRowKey] = useState(selectedIDs?.[0]);
18
18
  useEffect(() => { doGetItems(false); }, [getItems]);
19
19
  useEffect(() => {
20
20
  if (showOnlySelectedItems)
@@ -39,14 +39,16 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, startWithShowO
39
39
  };
40
40
  const handleSelectionChanged = useCallback((e) => {
41
41
  const selectedKeys = e.component.getSelectedRowKeys() ?? [];
42
+ if (JSON.stringify(selectedKeys) === JSON.stringify(selectedRowKeys))
43
+ return;
42
44
  setSelectedRowKeys(selectedKeys);
43
- }, []);
44
- const handleRowDoubleClick = () => {
45
+ }, [selectedRowKeys]);
46
+ const handleRowDoubleClick = useCallback(() => {
45
47
  if (allowMultipleSelection && selectedRowKeys.length > 1)
46
48
  return;
47
49
  onChoose?.(getFocusedIDs());
48
50
  onClose?.();
49
- };
51
+ }, [selectedRowKeys, allowMultipleSelection, onChoose, onClose]);
50
52
  const handleFocusedRowChange = useCallback((e) => {
51
53
  setFocusedRowKey(e.row?.key);
52
54
  }, []);
@@ -70,7 +72,7 @@ const TMChooserForm = ({ children, title, allowMultipleSelection, startWithShowO
70
72
  }, [manageUseLocalizedName, summaryItems]);
71
73
  return (_jsx(TMModal, { title: renderTitle(), width: width ?? '550px', height: height ?? '600px', toolbar: _jsx(ToolbarButtons, {}), onClose: onClose, children: (children ??
72
74
  filteredItems.length > 0)
73
- ? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: [...selectedRowKeys], showRowLines: SDKUI_Globals.dataGridShowRowLines, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
75
+ ? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, showRowLines: SDKUI_Globals.dataGridShowRowLines, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
74
76
  : _jsx(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: _jsx(TMLayoutItem, { children: _jsx("p", { style: { height: "100%", color: TMColors.primaryColor, fontSize: "1.5rem", display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: SDKUI_Localizator.NoDataToDisplay }) }) }) }));
75
77
  };
76
78
  export default TMChooserForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.12.17",
3
+ "version": "6.12.19",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",