@gridsuite/commons-ui 0.46.0 → 0.47.0
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/README.md +0 -17
- package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
- package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
- package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
- package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
- package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
- package/dist/components/FlatParameters/FlatParameters.js +411 -0
- package/dist/components/Login/Login.js +78 -0
- package/dist/components/Login/Logout.js +69 -0
- package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
- package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
- package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
- package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
- package/dist/components/OverflowableText/overflowable-text.js +87 -0
- package/dist/components/ReportViewer/filter-button.js +64 -0
- package/dist/components/ReportViewer/log-report-item.js +95 -0
- package/dist/components/ReportViewer/log-report.js +49 -0
- package/dist/components/ReportViewer/log-table.js +131 -0
- package/dist/components/ReportViewer/multi-select-list.js +40 -0
- package/dist/components/ReportViewer/report-item.js +112 -0
- package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
- package/dist/components/ReportViewer/report-viewer.js +158 -0
- package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
- package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
- package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
- package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
- package/dist/components/TopBar/AboutDialog.js +467 -0
- package/dist/components/TopBar/GridLogo.js +71 -0
- package/dist/components/TopBar/TopBar.js +679 -0
- package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
- package/dist/components/react-hook-form/autocomplete-input.js +96 -0
- package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
- package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
- package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
- package/dist/components/react-hook-form/error-management/error-input.js +42 -0
- package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
- package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
- package/dist/components/react-hook-form/numbers/float-input.js +51 -0
- package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
- package/dist/components/react-hook-form/numbers/utils.js +10 -0
- package/dist/components/react-hook-form/radio-input.js +44 -0
- package/dist/components/react-hook-form/select-input.js +31 -0
- package/dist/components/react-hook-form/slider-input.js +43 -0
- package/dist/components/react-hook-form/text-input.js +94 -0
- package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
- package/dist/components/react-hook-form/utils/field-label.js +12 -0
- package/dist/components/react-hook-form/utils/functions.js +36 -0
- package/dist/components/react-hook-form/utils/submit-button.js +23 -0
- package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
- package/dist/components/translations/card-error-boundary-en.js +8 -0
- package/dist/components/translations/card-error-boundary-fr.js +8 -0
- package/dist/components/translations/common-button-en.js +7 -0
- package/dist/components/translations/common-button-fr.js +7 -0
- package/dist/components/translations/element-search-en.js +7 -0
- package/dist/components/translations/element-search-fr.js +7 -0
- package/dist/components/translations/equipment-search-en.js +21 -0
- package/dist/components/translations/equipment-search-fr.js +21 -0
- package/dist/components/translations/flat-parameters-en.js +8 -0
- package/dist/components/translations/flat-parameters-fr.js +8 -0
- package/dist/components/translations/login-en.js +14 -0
- package/dist/components/translations/login-fr.js +14 -0
- package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
- package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
- package/dist/components/translations/report-viewer-en.js +8 -0
- package/dist/components/translations/report-viewer-fr.js +8 -0
- package/dist/components/translations/table-en.js +6 -0
- package/dist/components/translations/table-fr.js +6 -0
- package/dist/components/translations/top-bar-en.js +27 -0
- package/dist/components/translations/top-bar-fr.js +27 -0
- package/dist/components/translations/treeview-finder-en.js +12 -0
- package/dist/components/translations/treeview-finder-fr.js +12 -0
- package/dist/hooks/useDebounce.js +17 -0
- package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
- package/dist/hooks/useIntlRef.js +13 -0
- package/dist/hooks/useSnackMessage.js +81 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +154 -0
- package/dist/utils/AuthService.js +336 -0
- package/dist/utils/ElementType.js +38 -0
- package/dist/utils/EquipmentType.js +132 -0
- package/dist/utils/UserManagerMock.js +85 -0
- package/dist/utils/actions.js +71 -0
- package/dist/utils/algos.js +24 -0
- package/dist/utils/styles.js +13 -0
- package/package.json +36 -21
- package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
- package/es/components/AuthenticationRouter/index.js +0 -7
- package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
- package/es/components/CardErrorBoundary/index.js +0 -7
- package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
- package/es/components/ElementSearchDialog/equipment-item.js +0 -63
- package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
- package/es/components/FlatParameters/FlatParameters.js +0 -448
- package/es/components/FlatParameters/index.js +0 -8
- package/es/components/Login/Login.js +0 -79
- package/es/components/Login/Logout.js +0 -78
- package/es/components/Login/index.js +0 -7
- package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
- package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
- package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
- package/es/components/MuiVirtualizedTable/index.js +0 -9
- package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
- package/es/components/MultipleSelectionDialog/index.js +0 -8
- package/es/components/OverflowableText/index.js +0 -7
- package/es/components/OverflowableText/overflowable-text.js +0 -81
- package/es/components/ReportViewer/filter-button.js +0 -77
- package/es/components/ReportViewer/index.js +0 -7
- package/es/components/ReportViewer/log-report-item.js +0 -97
- package/es/components/ReportViewer/log-report.js +0 -63
- package/es/components/ReportViewer/log-table.js +0 -130
- package/es/components/ReportViewer/multi-select-list.js +0 -56
- package/es/components/ReportViewer/report-item.js +0 -131
- package/es/components/ReportViewer/report-tree-view-context.js +0 -13
- package/es/components/ReportViewer/report-viewer.js +0 -167
- package/es/components/ReportViewerDialog/index.js +0 -7
- package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
- package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
- package/es/components/SignInCallbackHandler/index.js +0 -7
- package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
- package/es/components/SilentRenewCallbackHandler/index.js +0 -7
- package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
- package/es/components/SnackbarProvider/index.js +0 -7
- package/es/components/TopBar/AboutDialog.js +0 -456
- package/es/components/TopBar/GridLogo.js +0 -73
- package/es/components/TopBar/TopBar.js +0 -487
- package/es/components/TopBar/index.js +0 -9
- package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
- package/es/components/TreeViewFinder/index.js +0 -7
- package/es/components/images/powsybl_logo.svg +0 -35
- package/es/components/react-hook-form/autocomplete-input.js +0 -110
- package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
- package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
- package/es/components/react-hook-form/booleans/switch-input.js +0 -28
- package/es/components/react-hook-form/error-management/error-input.js +0 -50
- package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
- package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
- package/es/components/react-hook-form/numbers/float-input.js +0 -105
- package/es/components/react-hook-form/numbers/integer-input.js +0 -35
- package/es/components/react-hook-form/numbers/utils.js +0 -6
- package/es/components/react-hook-form/radio-input.js +0 -55
- package/es/components/react-hook-form/select-input.js +0 -40
- package/es/components/react-hook-form/slider-input.js +0 -48
- package/es/components/react-hook-form/text-input.js +0 -100
- package/es/components/react-hook-form/utils/cancel-button.js +0 -28
- package/es/components/react-hook-form/utils/field-label.js +0 -15
- package/es/components/react-hook-form/utils/functions.js +0 -42
- package/es/components/react-hook-form/utils/submit-button.js +0 -29
- package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
- package/es/components/translations/card-error-boundary-en.js +0 -13
- package/es/components/translations/card-error-boundary-fr.js +0 -13
- package/es/components/translations/common-button-en.js +0 -12
- package/es/components/translations/common-button-fr.js +0 -12
- package/es/components/translations/element-search-en.js +0 -12
- package/es/components/translations/element-search-fr.js +0 -12
- package/es/components/translations/equipment-search-en.js +0 -26
- package/es/components/translations/equipment-search-fr.js +0 -26
- package/es/components/translations/flat-parameters-en.js +0 -13
- package/es/components/translations/flat-parameters-fr.js +0 -13
- package/es/components/translations/inputs-en.js +0 -25
- package/es/components/translations/inputs-fr.js +0 -25
- package/es/components/translations/login-en.js +0 -19
- package/es/components/translations/login-fr.js +0 -19
- package/es/components/translations/multiple-selection-dialog-en.js +0 -13
- package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
- package/es/components/translations/report-viewer-en.js +0 -13
- package/es/components/translations/report-viewer-fr.js +0 -13
- package/es/components/translations/table-en.js +0 -11
- package/es/components/translations/table-fr.js +0 -11
- package/es/components/translations/top-bar-en.js +0 -32
- package/es/components/translations/top-bar-fr.js +0 -32
- package/es/components/translations/treeview-finder-en.js +0 -17
- package/es/components/translations/treeview-finder-fr.js +0 -17
- package/es/hooks/useDebounce.js +0 -26
- package/es/hooks/useIntlRef.js +0 -22
- package/es/hooks/useSnackMessage.js +0 -81
- package/es/index.js +0 -71
- package/es/utils/AuthService.js +0 -312
- package/es/utils/ElementType.js +0 -53
- package/es/utils/EquipmentType.js +0 -133
- package/es/utils/UserManagerMock.js +0 -81
- package/es/utils/actions.js +0 -65
- package/es/utils/algos.js +0 -29
- package/es/utils/styles.js +0 -35
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import { toNestedGlobalSelectors, makeComposeClasses } from "../../utils/styles.js";
|
|
6
|
+
import { styled } from "@mui/system";
|
|
7
|
+
import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Typography } from "@mui/material";
|
|
8
|
+
import { TreeView, TreeItem } from "@mui/lab";
|
|
9
|
+
import { ChevronRight, ExpandMore, Check } from "@mui/icons-material";
|
|
10
|
+
import CancelButton from "../react-hook-form/utils/cancel-button.js";
|
|
11
|
+
const cssDialogPaper = "dialogPaper";
|
|
12
|
+
const cssLabelRoot = "labelRoot";
|
|
13
|
+
const cssLabelText = "labelText";
|
|
14
|
+
const cssLabelIcon = "labelIcon";
|
|
15
|
+
const cssIcon = "icon";
|
|
16
|
+
const defaultStyles = {
|
|
17
|
+
[cssDialogPaper]: {
|
|
18
|
+
minWidth: "50%"
|
|
19
|
+
},
|
|
20
|
+
[cssLabelRoot]: {
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignContent: "center",
|
|
23
|
+
alignItems: "center"
|
|
24
|
+
},
|
|
25
|
+
[cssLabelText]: {
|
|
26
|
+
fontWeight: "inherit",
|
|
27
|
+
flexGrow: 1
|
|
28
|
+
},
|
|
29
|
+
[cssLabelIcon]: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
alignContent: "center",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
marginRight: "4px"
|
|
34
|
+
},
|
|
35
|
+
[cssIcon]: {}
|
|
36
|
+
};
|
|
37
|
+
const generateTreeViewFinderClass = (className) => `GsiTreeViewFinder-${className}`;
|
|
38
|
+
const composeClasses = makeComposeClasses(generateTreeViewFinderClass);
|
|
39
|
+
const TreeViewFinder = (props) => {
|
|
40
|
+
const intl = useIntl();
|
|
41
|
+
const {
|
|
42
|
+
classes,
|
|
43
|
+
title,
|
|
44
|
+
contentText,
|
|
45
|
+
open,
|
|
46
|
+
data,
|
|
47
|
+
defaultExpanded,
|
|
48
|
+
defaultSelected,
|
|
49
|
+
onClose,
|
|
50
|
+
onTreeBrowse,
|
|
51
|
+
validationButtonText,
|
|
52
|
+
onlyLeaves,
|
|
53
|
+
multiselect,
|
|
54
|
+
sortMethod,
|
|
55
|
+
className,
|
|
56
|
+
cancelButtonProps
|
|
57
|
+
} = props;
|
|
58
|
+
const [mapPrintedNodes, setMapPrintedNodes] = useState({});
|
|
59
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
60
|
+
const [selected, setSelected] = useState(defaultSelected);
|
|
61
|
+
const isSelectable = (node) => {
|
|
62
|
+
return onlyLeaves ? isLeaf(node) : true;
|
|
63
|
+
};
|
|
64
|
+
const isLeaf = (node) => {
|
|
65
|
+
return node && node.children === void 0;
|
|
66
|
+
};
|
|
67
|
+
const computeMapPrintedNodes = useCallback((nodes) => {
|
|
68
|
+
let newMapPrintedNodes = {};
|
|
69
|
+
nodes.forEach((node) => {
|
|
70
|
+
newMapPrintedNodes[node.id] = node;
|
|
71
|
+
if (!isLeaf(node)) {
|
|
72
|
+
Object.assign(
|
|
73
|
+
newMapPrintedNodes,
|
|
74
|
+
computeMapPrintedNodes(node.children)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return newMapPrintedNodes;
|
|
79
|
+
}, []);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
let newMapPrintedNodes = computeMapPrintedNodes(data);
|
|
82
|
+
console.debug(
|
|
83
|
+
"data updated, new mapPrintedNodes (nbNodes = ",
|
|
84
|
+
Object.keys(newMapPrintedNodes).length,
|
|
85
|
+
") : ",
|
|
86
|
+
newMapPrintedNodes
|
|
87
|
+
);
|
|
88
|
+
setMapPrintedNodes(newMapPrintedNodes);
|
|
89
|
+
}, [data, computeMapPrintedNodes]);
|
|
90
|
+
const computeSelectedNodes = () => {
|
|
91
|
+
return selected.map((nodeId) => {
|
|
92
|
+
return mapPrintedNodes[nodeId];
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const handleNodeToggle = (e, nodeIds) => {
|
|
96
|
+
nodeIds.every((nodeId) => {
|
|
97
|
+
if (!expanded.includes(nodeId)) {
|
|
98
|
+
onTreeBrowse && onTreeBrowse(nodeId);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
});
|
|
103
|
+
setExpanded(nodeIds);
|
|
104
|
+
};
|
|
105
|
+
const handleNodeSelect = (e, values) => {
|
|
106
|
+
if (multiselect) {
|
|
107
|
+
setSelected(
|
|
108
|
+
values.filter((nodeId) => isSelectable(mapPrintedNodes[nodeId]))
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
if (selected.includes(values)) {
|
|
112
|
+
setSelected([]);
|
|
113
|
+
} else {
|
|
114
|
+
setSelected(
|
|
115
|
+
isSelectable(mapPrintedNodes[values]) ? [values] : []
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const getValidationButtonText = () => {
|
|
121
|
+
if (validationButtonText) {
|
|
122
|
+
return validationButtonText;
|
|
123
|
+
} else {
|
|
124
|
+
return intl.formatMessage(
|
|
125
|
+
{ id: "treeview_finder/addElementsValidation" },
|
|
126
|
+
{
|
|
127
|
+
nbElements: selected.length
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const getNodeIcon = (node) => {
|
|
133
|
+
if (!node) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
if (isSelectable(node) && selected.find((nodeId) => nodeId === node.id)) {
|
|
137
|
+
return /* @__PURE__ */ jsx(Check, { className: composeClasses(classes, cssLabelIcon) });
|
|
138
|
+
} else {
|
|
139
|
+
if (node.icon) {
|
|
140
|
+
return /* @__PURE__ */ jsx("div", { className: composeClasses(classes, cssLabelIcon), children: node.icon });
|
|
141
|
+
} else {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const renderTreeItemLabel = (node) => {
|
|
147
|
+
return /* @__PURE__ */ jsxs("div", { className: composeClasses(classes, cssLabelRoot), children: [
|
|
148
|
+
getNodeIcon(node),
|
|
149
|
+
/* @__PURE__ */ jsx(Typography, { className: composeClasses(classes, cssLabelText), children: node.name })
|
|
150
|
+
] });
|
|
151
|
+
};
|
|
152
|
+
const showChevron = (node) => {
|
|
153
|
+
return !!(node.childrenCount == null || node.childrenCount && node.childrenCount > 0);
|
|
154
|
+
};
|
|
155
|
+
const renderTree = (node) => {
|
|
156
|
+
if (!node) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
TreeItem,
|
|
161
|
+
{
|
|
162
|
+
nodeId: node.id,
|
|
163
|
+
label: renderTreeItemLabel(node),
|
|
164
|
+
expandIcon: showChevron(node) ? /* @__PURE__ */ jsx(
|
|
165
|
+
ChevronRight,
|
|
166
|
+
{
|
|
167
|
+
className: composeClasses(classes, cssIcon)
|
|
168
|
+
}
|
|
169
|
+
) : null,
|
|
170
|
+
collapseIcon: showChevron(node) ? /* @__PURE__ */ jsx(
|
|
171
|
+
ExpandMore,
|
|
172
|
+
{
|
|
173
|
+
className: composeClasses(classes, cssIcon)
|
|
174
|
+
}
|
|
175
|
+
) : null,
|
|
176
|
+
children: Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map((child) => renderTree(child)) : [false] : null
|
|
177
|
+
},
|
|
178
|
+
node.id
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
return /* @__PURE__ */ jsxs(
|
|
182
|
+
Dialog,
|
|
183
|
+
{
|
|
184
|
+
open,
|
|
185
|
+
onClose: (e, r) => {
|
|
186
|
+
if (r === "escapeKeyDown" || r === "backdropClick") {
|
|
187
|
+
onClose([]);
|
|
188
|
+
setSelected([]);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"aria-labelledby": "TreeViewFindertitle",
|
|
192
|
+
className,
|
|
193
|
+
classes: {
|
|
194
|
+
paper: composeClasses(classes, cssDialogPaper)
|
|
195
|
+
},
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx(DialogTitle, { id: "TreeViewFindertitle", children: title ? title : intl.formatMessage(
|
|
198
|
+
{ id: "treeview_finder/finderTitle" },
|
|
199
|
+
{ multiselect }
|
|
200
|
+
) }),
|
|
201
|
+
/* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
202
|
+
/* @__PURE__ */ jsx(DialogContentText, { children: contentText ? contentText : intl.formatMessage(
|
|
203
|
+
{ id: "treeview_finder/contentText" },
|
|
204
|
+
{ multiselect }
|
|
205
|
+
) }),
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
TreeView,
|
|
208
|
+
{
|
|
209
|
+
expanded,
|
|
210
|
+
selected,
|
|
211
|
+
onNodeToggle: handleNodeToggle,
|
|
212
|
+
onNodeSelect: handleNodeSelect,
|
|
213
|
+
multiSelect: multiselect,
|
|
214
|
+
children: data && Array.isArray(data) ? data.sort(sortMethod).map((child) => renderTree(child)) : null
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
] }),
|
|
218
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [
|
|
219
|
+
/* @__PURE__ */ jsx(
|
|
220
|
+
CancelButton,
|
|
221
|
+
{
|
|
222
|
+
style: { float: "left", margin: "5px" },
|
|
223
|
+
onClick: () => {
|
|
224
|
+
onClose([]);
|
|
225
|
+
setSelected([]);
|
|
226
|
+
},
|
|
227
|
+
...cancelButtonProps
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ jsx(
|
|
231
|
+
Button,
|
|
232
|
+
{
|
|
233
|
+
variant: "outlined",
|
|
234
|
+
style: { float: "left", margin: "5px" },
|
|
235
|
+
onClick: () => {
|
|
236
|
+
onClose(computeSelectedNodes());
|
|
237
|
+
setSelected([]);
|
|
238
|
+
},
|
|
239
|
+
disabled: selected.length === 0,
|
|
240
|
+
children: getValidationButtonText()
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
] })
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
TreeViewFinder.propTypes = {
|
|
249
|
+
// Controlled
|
|
250
|
+
open: PropTypes.bool.isRequired,
|
|
251
|
+
onClose: PropTypes.func,
|
|
252
|
+
data: PropTypes.arrayOf(
|
|
253
|
+
PropTypes.shape({
|
|
254
|
+
id: PropTypes.string.isRequired,
|
|
255
|
+
name: PropTypes.string.isRequired,
|
|
256
|
+
children: PropTypes.array
|
|
257
|
+
})
|
|
258
|
+
).isRequired,
|
|
259
|
+
onTreeBrowse: PropTypes.func,
|
|
260
|
+
//uncontrolled
|
|
261
|
+
classes: PropTypes.object,
|
|
262
|
+
title: PropTypes.string,
|
|
263
|
+
contentText: PropTypes.string,
|
|
264
|
+
validationButtonText: PropTypes.string,
|
|
265
|
+
defaultSelected: PropTypes.arrayOf(PropTypes.string),
|
|
266
|
+
defaultExpanded: PropTypes.arrayOf(PropTypes.string),
|
|
267
|
+
onlyLeaves: PropTypes.bool,
|
|
268
|
+
multiselect: PropTypes.bool,
|
|
269
|
+
sortMethod: PropTypes.func,
|
|
270
|
+
cancelButtonProps: PropTypes.object
|
|
271
|
+
};
|
|
272
|
+
TreeViewFinder.defaultProps = {
|
|
273
|
+
defaultSelected: [],
|
|
274
|
+
defaultExpanded: [],
|
|
275
|
+
onlyLeaves: true,
|
|
276
|
+
multiselect: false,
|
|
277
|
+
sortMethod: void 0,
|
|
278
|
+
classes: {}
|
|
279
|
+
};
|
|
280
|
+
const nestedGlobalSelectorsStyles = toNestedGlobalSelectors(
|
|
281
|
+
defaultStyles,
|
|
282
|
+
generateTreeViewFinderClass
|
|
283
|
+
);
|
|
284
|
+
const TreeViewFinder$1 = styled(TreeViewFinder)(nestedGlobalSelectorsStyles);
|
|
285
|
+
export {
|
|
286
|
+
TreeViewFinder$1 as default,
|
|
287
|
+
generateTreeViewFinderClass
|
|
288
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { Autocomplete, TextField } from "@mui/material";
|
|
5
|
+
import { useFormContext, useController } from "react-hook-form";
|
|
6
|
+
import { isFieldRequired, genHelperPreviousValue, genHelperError, identity } from "./utils/functions.js";
|
|
7
|
+
import FieldLabel from "./utils/field-label.js";
|
|
8
|
+
const AutocompleteInput = ({
|
|
9
|
+
name,
|
|
10
|
+
label,
|
|
11
|
+
options,
|
|
12
|
+
outputTransform = identity,
|
|
13
|
+
//transform materialUi input value before sending it to react hook form, mostly used to deal with select fields that need to return a string
|
|
14
|
+
inputTransform = identity,
|
|
15
|
+
//transform react hook form value before sending it to materialUi input, mostly used to deal with select fields that need to return a string
|
|
16
|
+
readOnly = false,
|
|
17
|
+
previousValue,
|
|
18
|
+
allowNewValue,
|
|
19
|
+
onChangeCallback,
|
|
20
|
+
// method called when input value is changing
|
|
21
|
+
formProps,
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const { validationSchema, getValues, removeOptional } = useFormContext();
|
|
25
|
+
const {
|
|
26
|
+
field: { onChange, value, ref },
|
|
27
|
+
fieldState: { error }
|
|
28
|
+
} = useController({ name });
|
|
29
|
+
const handleChange = (value2) => {
|
|
30
|
+
onChangeCallback && onChangeCallback();
|
|
31
|
+
if (!allowNewValue || typeof value2 !== "string") {
|
|
32
|
+
onChange(outputTransform(value2));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const matchingOption = options.find((option) => option.id === value2);
|
|
36
|
+
if (matchingOption) {
|
|
37
|
+
onChange(outputTransform(matchingOption));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
onChange(outputTransform(value2));
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
Autocomplete,
|
|
44
|
+
{
|
|
45
|
+
value: inputTransform(value),
|
|
46
|
+
onChange: (_, data) => handleChange(data),
|
|
47
|
+
...allowNewValue && {
|
|
48
|
+
freeSolo: true,
|
|
49
|
+
autoComplete: true,
|
|
50
|
+
blurOnSelect: true,
|
|
51
|
+
autoSelect: false,
|
|
52
|
+
onInputChange: (_, data) => {
|
|
53
|
+
handleChange(data);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
options,
|
|
57
|
+
renderInput: ({ inputProps, ...rest }) => /* @__PURE__ */ jsx(
|
|
58
|
+
TextField,
|
|
59
|
+
{
|
|
60
|
+
...label && {
|
|
61
|
+
label: FieldLabel({
|
|
62
|
+
label,
|
|
63
|
+
optional: !isFieldRequired(
|
|
64
|
+
name,
|
|
65
|
+
validationSchema,
|
|
66
|
+
getValues()
|
|
67
|
+
) && !(props == null ? void 0 : props.disabled) && !removeOptional
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
inputRef: ref,
|
|
71
|
+
inputProps: { ...inputProps, readOnly },
|
|
72
|
+
...genHelperPreviousValue(previousValue),
|
|
73
|
+
...genHelperError(error == null ? void 0 : error.message),
|
|
74
|
+
...formProps,
|
|
75
|
+
...rest
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
...props
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
AutocompleteInput.propTypes = {
|
|
83
|
+
name: PropTypes.string.isRequired,
|
|
84
|
+
label: PropTypes.string,
|
|
85
|
+
options: PropTypes.array.isRequired,
|
|
86
|
+
outputTransform: PropTypes.func,
|
|
87
|
+
inputTransform: PropTypes.func,
|
|
88
|
+
readOnly: PropTypes.bool,
|
|
89
|
+
previousValue: PropTypes.any,
|
|
90
|
+
allowNewValue: PropTypes.bool,
|
|
91
|
+
onChangeCallback: PropTypes.func,
|
|
92
|
+
formProps: PropTypes.object
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
AutocompleteInput as default
|
|
96
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { FormControlLabel } from "@mui/material";
|
|
6
|
+
import { useController } from "react-hook-form";
|
|
7
|
+
const BooleanInput = ({ name, label, formProps, Input }) => {
|
|
8
|
+
const {
|
|
9
|
+
field: { onChange, value, ref }
|
|
10
|
+
} = useController({ name });
|
|
11
|
+
const intl = useIntl();
|
|
12
|
+
const handleChangeValue = useCallback(
|
|
13
|
+
(event) => {
|
|
14
|
+
onChange(event.target.checked);
|
|
15
|
+
},
|
|
16
|
+
[onChange]
|
|
17
|
+
);
|
|
18
|
+
const CustomInput = /* @__PURE__ */ jsx(
|
|
19
|
+
Input,
|
|
20
|
+
{
|
|
21
|
+
checked: value,
|
|
22
|
+
onChange: (e) => handleChangeValue(e),
|
|
23
|
+
inputRef: ref,
|
|
24
|
+
inputProps: {
|
|
25
|
+
"aria-label": "primary checkbox"
|
|
26
|
+
},
|
|
27
|
+
...formProps
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
if (label) {
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
FormControlLabel,
|
|
33
|
+
{
|
|
34
|
+
control: CustomInput,
|
|
35
|
+
label: intl.formatMessage({ id: label })
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return CustomInput;
|
|
40
|
+
};
|
|
41
|
+
BooleanInput.propTypes = {
|
|
42
|
+
name: PropTypes.string.isRequired,
|
|
43
|
+
label: PropTypes.string,
|
|
44
|
+
formProps: PropTypes.object,
|
|
45
|
+
Input: PropTypes.elementType.isRequired
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
BooleanInput as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import BooleanInput from "./boolean-input.js";
|
|
5
|
+
import { Checkbox } from "@mui/material";
|
|
6
|
+
const CheckboxInput = ({ name, label, formProps }) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
BooleanInput,
|
|
9
|
+
{
|
|
10
|
+
name,
|
|
11
|
+
label,
|
|
12
|
+
formProps,
|
|
13
|
+
Input: Checkbox
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
CheckboxInput.propTypes = {
|
|
18
|
+
name: PropTypes.string.isRequired,
|
|
19
|
+
label: PropTypes.string,
|
|
20
|
+
formProps: PropTypes.object
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
CheckboxInput as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import BooleanInput from "./boolean-input.js";
|
|
5
|
+
import { Switch } from "@mui/material";
|
|
6
|
+
const SwitchInput = ({ name, label, formProps }) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
BooleanInput,
|
|
9
|
+
{
|
|
10
|
+
name,
|
|
11
|
+
label,
|
|
12
|
+
formProps,
|
|
13
|
+
Input: Switch
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
SwitchInput.propTypes = {
|
|
18
|
+
name: PropTypes.string.isRequired,
|
|
19
|
+
label: PropTypes.string,
|
|
20
|
+
formProps: PropTypes.object
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
SwitchInput as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect } from "react";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { useController } from "react-hook-form";
|
|
5
|
+
const ErrorInput = ({ name, InputField }) => {
|
|
6
|
+
const {
|
|
7
|
+
fieldState: { error },
|
|
8
|
+
formState: { isSubmitting }
|
|
9
|
+
} = useController({
|
|
10
|
+
name
|
|
11
|
+
});
|
|
12
|
+
const errorRef = useRef(null);
|
|
13
|
+
const errorProps = (errorMsg) => {
|
|
14
|
+
if (typeof errorMsg === "string") {
|
|
15
|
+
return {
|
|
16
|
+
id: errorMsg
|
|
17
|
+
};
|
|
18
|
+
} else if (typeof errorMsg === "object") {
|
|
19
|
+
return {
|
|
20
|
+
id: errorMsg.id,
|
|
21
|
+
values: {
|
|
22
|
+
value: errorMsg.value
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
};
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (error && errorRef.current) {
|
|
30
|
+
errorRef.current.scrollIntoView({ behavior: "smooth" });
|
|
31
|
+
}
|
|
32
|
+
}, [isSubmitting]);
|
|
33
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (error == null ? void 0 : error.message) && /* @__PURE__ */ jsx("div", { ref: errorRef, children: /* @__PURE__ */ jsx(
|
|
34
|
+
InputField,
|
|
35
|
+
{
|
|
36
|
+
message: /* @__PURE__ */ jsx(FormattedMessage, { ...errorProps(error == null ? void 0 : error.message) })
|
|
37
|
+
}
|
|
38
|
+
) }) });
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
ErrorInput as default
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Grid, Alert } from "@mui/material";
|
|
4
|
+
const FieldErrorAlert = ({ message }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Alert, { severity: "error", children: message }) });
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
FieldErrorAlert as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Box } from "@mui/material";
|
|
4
|
+
const MidFormError = ({ message }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
Box,
|
|
7
|
+
{
|
|
8
|
+
sx: (theme) => ({
|
|
9
|
+
color: theme.palette.error.main,
|
|
10
|
+
fontSize: "small",
|
|
11
|
+
marginLeft: theme.spacing(2),
|
|
12
|
+
marginRight: theme.spacing(2)
|
|
13
|
+
}),
|
|
14
|
+
children: message
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
MidFormError as default
|
|
20
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import TextInput from "../text-input.js";
|
|
4
|
+
import { isFloatNumber } from "./utils.js";
|
|
5
|
+
const normalizeFixed = (number) => {
|
|
6
|
+
return number.toLocaleString("en-US", {
|
|
7
|
+
maximumFractionDigits: 20,
|
|
8
|
+
useGrouping: false
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const FloatInput = (props) => {
|
|
12
|
+
const inputTransform = (value) => {
|
|
13
|
+
if (typeof value == "number" && !isNaN(value)) {
|
|
14
|
+
return normalizeFixed(value);
|
|
15
|
+
} else {
|
|
16
|
+
if (["-", "."].includes(value)) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return value === null || isNaN(value) ? "" : value;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const outputTransform = (value) => {
|
|
23
|
+
if (value === "-") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
if (value === "") {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const tmp = (value == null ? void 0 : value.replace(",", ".")) || "";
|
|
30
|
+
if (tmp.endsWith(".") || tmp.includes(".") && tmp.endsWith("0")) {
|
|
31
|
+
return tmp;
|
|
32
|
+
}
|
|
33
|
+
const parsed = parseFloat(tmp);
|
|
34
|
+
return isNaN(parsed) ? null : normalizeFixed(parsed);
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
TextInput,
|
|
38
|
+
{
|
|
39
|
+
acceptValue: isFloatNumber,
|
|
40
|
+
outputTransform,
|
|
41
|
+
inputTransform,
|
|
42
|
+
...props
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
FloatInput.propTypes = {
|
|
47
|
+
...TextInput.propTypes
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
FloatInput as default
|
|
51
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import TextInput from "../text-input.js";
|
|
4
|
+
import { isIntegerNumber } from "./utils.js";
|
|
5
|
+
const IntegerInput = (props) => {
|
|
6
|
+
const inputTransform = (value) => {
|
|
7
|
+
if ("-" === value) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return value === null || isNaN(value) ? "" : value.toString();
|
|
11
|
+
};
|
|
12
|
+
const outputTransform = (value) => {
|
|
13
|
+
if (value === "-") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (value === "0") {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
return parseInt(value) || null;
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
TextInput,
|
|
23
|
+
{
|
|
24
|
+
acceptValue: isIntegerNumber,
|
|
25
|
+
outputTransform,
|
|
26
|
+
inputTransform,
|
|
27
|
+
...props
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
IntegerInput.propTypes = {
|
|
32
|
+
...TextInput.propTypes
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
IntegerInput as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { FormControl, FormLabel, RadioGroup, FormControlLabel, Radio } from "@mui/material";
|
|
5
|
+
import { FormattedMessage } from "react-intl";
|
|
6
|
+
import { useController } from "react-hook-form";
|
|
7
|
+
import FieldLabel from "./utils/field-label.js";
|
|
8
|
+
const RadioInput = ({ name, label, id, options, formProps }) => {
|
|
9
|
+
const {
|
|
10
|
+
field: { onChange, value }
|
|
11
|
+
} = useController({ name });
|
|
12
|
+
return /* @__PURE__ */ jsxs(FormControl, { children: [
|
|
13
|
+
label && /* @__PURE__ */ jsx(FormLabel, { id: id ?? label, children: /* @__PURE__ */ jsx(FormattedMessage, { id: label }) }),
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
RadioGroup,
|
|
16
|
+
{
|
|
17
|
+
row: true,
|
|
18
|
+
"aria-labelledby": id ?? label,
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
...formProps,
|
|
22
|
+
children: options.map((option) => /* @__PURE__ */ jsx(
|
|
23
|
+
FormControlLabel,
|
|
24
|
+
{
|
|
25
|
+
control: /* @__PURE__ */ jsx(Radio, {}),
|
|
26
|
+
value: option.id,
|
|
27
|
+
label: /* @__PURE__ */ jsx(FieldLabel, { label: option.label })
|
|
28
|
+
},
|
|
29
|
+
option.id
|
|
30
|
+
))
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] });
|
|
34
|
+
};
|
|
35
|
+
RadioInput.propTypes = {
|
|
36
|
+
name: PropTypes.string.isRequired,
|
|
37
|
+
label: PropTypes.string,
|
|
38
|
+
id: PropTypes.string,
|
|
39
|
+
options: PropTypes.array.isRequired,
|
|
40
|
+
formProps: PropTypes.object
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
RadioInput as default
|
|
44
|
+
};
|