@topconsultnpm/sdkui-react-beta 6.7.84 → 6.7.86
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/editors/TMTreeDropDown.d.ts +16 -0
- package/lib/components/editors/{TMTreeDropdownBox.js → TMTreeDropDown.js} +11 -7
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/package.json +1 -1
- package/lib/components/editors/TMTreeDropdownBox.d.ts +0 -17
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TMTreeDropDownProps {
|
|
3
|
+
dataSource: Array<{
|
|
4
|
+
id: number;
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
categoryId?: number;
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
values: Array<number>;
|
|
11
|
+
setValues: React.Dispatch<React.SetStateAction<Array<number>>>;
|
|
12
|
+
isValidKey?: (key: number) => boolean;
|
|
13
|
+
elementStyle?: React.CSSProperties | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare const TMTreeDropDown: (props: TMTreeDropDownProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default TMTreeDropDown;
|
|
@@ -4,16 +4,20 @@ import DropDownBox from 'devextreme-react/drop-down-box';
|
|
|
4
4
|
import TreeView from 'devextreme-react/tree-view';
|
|
5
5
|
import { TMTooltip } from '@topconsultnpm/sdkui-react-beta/lib';
|
|
6
6
|
import { SDKUI_Localizator } from '../../helper';
|
|
7
|
-
// The
|
|
8
|
-
const
|
|
7
|
+
// The TMTreeDropDown functional component
|
|
8
|
+
const TMTreeDropDown = (props) => {
|
|
9
9
|
// Destructure props for easy access
|
|
10
10
|
const { dataSource, values, setValues, isValidKey, elementStyle } = props;
|
|
11
11
|
// Reference to the TreeView component for programmatic control
|
|
12
12
|
const treeViewRef = useRef(null);
|
|
13
13
|
// Helper function to get a comma-separated string of labels for the selected IDs
|
|
14
|
-
const getLabelsByIds = (ids) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
14
|
+
const getLabelsByIds = (ids, outputFormat) => {
|
|
15
|
+
const filteredLabels = dataSource.filter(item => ids.includes(item.id));
|
|
16
|
+
if (outputFormat === 'text') {
|
|
17
|
+
const labels = filteredLabels.map(item => item.label).join(', ');
|
|
18
|
+
return _jsx("p", { children: labels });
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { style: { textAlign: 'left' }, children: filteredLabels.map(item => (_jsx("p", { children: item.label }, item.id))) }));
|
|
17
21
|
};
|
|
18
22
|
// Synchronizes the selection in the TreeView when the dropdown value changes
|
|
19
23
|
const syncTreeViewSelection = useCallback((e) => {
|
|
@@ -43,6 +47,6 @@ const TMTreeDropDownBox = (props) => {
|
|
|
43
47
|
filteredKeys = selectedKeys.filter(isValidKey); // If a validation function is provided, filter the selected keys
|
|
44
48
|
setValues(filteredKeys);
|
|
45
49
|
}, []);
|
|
46
|
-
return _jsx(TMTooltip, { content: getLabelsByIds(values), children: _jsx(DropDownBox, { width: "100%", style: elementStyle, valueExpr: "id", displayExpr: "label", value: values, dataSource: dataSource, placeholder: SDKUI_Localizator.SelectDesiredFilters, onContentReady: syncTreeViewSelection, focusStateEnabled: true, contentRender: () => _jsx(TreeView, { ref: treeViewRef, keyExpr: "id", dataSource: dataSource, selectByClick: true, selectNodesRecursive: true, selectionMode: "multiple", displayExpr: "label", parentIdExpr: "categoryId", dataStructure: "plain", showCheckBoxesMode: "normal", onContentReady: syncTreeViewSelection, onItemSelectionChanged: (e) => treeViewItemSelectionChanged(e) }) }) });
|
|
50
|
+
return _jsx(TMTooltip, { content: getLabelsByIds(values, 'formatted'), children: _jsx(DropDownBox, { width: "100%", style: elementStyle, valueExpr: "id", displayExpr: "label", value: values, dataSource: dataSource, placeholder: SDKUI_Localizator.SelectDesiredFilters, onContentReady: syncTreeViewSelection, focusStateEnabled: true, contentRender: () => _jsx(TreeView, { ref: treeViewRef, keyExpr: "id", dataSource: dataSource, selectByClick: true, selectNodesRecursive: true, selectionMode: "multiple", displayExpr: "label", parentIdExpr: "categoryId", dataStructure: "plain", showCheckBoxesMode: "normal", onContentReady: syncTreeViewSelection, onItemSelectionChanged: (e) => treeViewItemSelectionChanged(e) }) }) });
|
|
47
51
|
};
|
|
48
|
-
export default
|
|
52
|
+
export default TMTreeDropDown;
|
|
@@ -17,6 +17,7 @@ export { default as TMToggleButton } from './base/TMToggleButton';
|
|
|
17
17
|
export { default as TMTooltip } from './base/TMTooltip';
|
|
18
18
|
export { default as TMVilViewer } from './base/TMVilViewer';
|
|
19
19
|
export { default as TMDropDown } from './editors/TMDropDown';
|
|
20
|
+
export { default as TMTreeDropDown } from './editors/TMTreeDropDown';
|
|
20
21
|
export { default as TMSummary } from './editors/TMSummary';
|
|
21
22
|
export { default as TMTextBox } from './editors/TMTextBox';
|
|
22
23
|
export { default as TMTextArea } from './editors/TMTextArea';
|
package/lib/components/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { default as TMTooltip } from './base/TMTooltip';
|
|
|
21
21
|
export { default as TMVilViewer } from './base/TMVilViewer';
|
|
22
22
|
//editors
|
|
23
23
|
export { default as TMDropDown } from './editors/TMDropDown';
|
|
24
|
+
export { default as TMTreeDropDown } from './editors/TMTreeDropDown';
|
|
24
25
|
export { default as TMSummary } from './editors/TMSummary';
|
|
25
26
|
export { default as TMTextBox } from './editors/TMTextBox';
|
|
26
27
|
export { default as TMTextArea } from './editors/TMTextArea';
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface ITMTreeDataSource {
|
|
3
|
-
id: number;
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
categoryId?: number;
|
|
7
|
-
expanded?: boolean;
|
|
8
|
-
}
|
|
9
|
-
interface TMTreeDropDownBoxProps {
|
|
10
|
-
dataSource: Array<ITMTreeDataSource>;
|
|
11
|
-
values: Array<number>;
|
|
12
|
-
setValues: React.Dispatch<React.SetStateAction<Array<number>>>;
|
|
13
|
-
isValidKey?: (key: number) => boolean;
|
|
14
|
-
elementStyle?: React.CSSProperties | undefined;
|
|
15
|
-
}
|
|
16
|
-
declare const TMTreeDropDownBox: (props: TMTreeDropDownBoxProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export default TMTreeDropDownBox;
|