@gridsuite/commons-ui 0.112.0 → 0.113.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/dist/components/dnd-table/dnd-table.js +2 -2
- package/dist/components/index.js +27 -6
- package/dist/components/inputs/reactHookForm/provider/CustomFormProvider.js +0 -4
- package/dist/components/inputs/reactHookForm/text/DescriptionField.js +0 -3
- package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +1 -0
- package/dist/components/parameters/common/index.js +0 -2
- package/dist/components/parameters/common/limitreductions/columns-definitions.d.ts +7 -2
- package/dist/components/parameters/common/limitreductions/columns-definitions.js +16 -3
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.d.ts +3 -3
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +4 -1
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-row.d.ts +2 -2
- package/dist/components/parameters/common/name-element-editor/name-element-editor-form.js +5 -28
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.d.ts +2 -2
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +2 -2
- package/dist/components/parameters/common/parameters-edition-dialog-props.d.ts +0 -4
- package/dist/components/parameters/common/parameters-edition-dialog-props.js +1 -14
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.d.ts +2 -2
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-row.d.ts +2 -2
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table.d.ts +2 -2
- package/dist/components/parameters/index.d.ts +1 -1
- package/dist/components/parameters/index.js +27 -6
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +1 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +1 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +1 -1
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +0 -2
- package/dist/components/parameters/network-visualizations/map-parameters.js +1 -1
- package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +1 -1
- package/dist/components/parameters/parameters-style.d.ts +0 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +8 -2
- package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +2 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +1 -1
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -1
- package/dist/components/parameters/sensi/columns-definitions.d.ts +222 -0
- package/dist/components/parameters/sensi/columns-definitions.js +305 -0
- package/dist/components/parameters/sensi/constants.d.ts +29 -0
- package/dist/components/parameters/sensi/constants.js +48 -0
- package/dist/components/parameters/sensi/index.d.ts +10 -0
- package/dist/components/parameters/sensi/index.js +29 -0
- package/dist/components/parameters/sensi/sensitivity-Flow-parameters.d.ts +7 -0
- package/dist/components/parameters/sensi/sensitivity-Flow-parameters.js +72 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.d.ts +2 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +113 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.d.ts +8 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +129 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.d.ts +13 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +185 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.d.ts +16 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +274 -0
- package/dist/components/parameters/sensi/sensitivity-table.d.ts +15 -0
- package/dist/components/parameters/sensi/sensitivity-table.js +134 -0
- package/dist/components/parameters/sensi/table-cell.d.ts +8 -0
- package/dist/components/parameters/sensi/table-cell.js +86 -0
- package/dist/components/parameters/sensi/table-row.d.ts +11 -0
- package/dist/components/parameters/sensi/table-row.js +42 -0
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +49 -0
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +413 -0
- package/dist/components/parameters/sensi/utils.d.ts +419 -0
- package/dist/components/parameters/sensi/utils.js +357 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/use-create-row-data-sensi.d.ts +4 -0
- package/dist/hooks/use-create-row-data-sensi.js +20 -0
- package/dist/index.js +29 -6
- package/dist/services/sensitivity-analysis.d.ts +12 -0
- package/dist/services/sensitivity-analysis.js +87 -0
- package/dist/translations/en/parameters.d.ts +64 -0
- package/dist/translations/en/parameters.js +70 -1
- package/dist/translations/fr/parameters.d.ts +64 -0
- package/dist/translations/fr/parameters.js +70 -1
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
|
+
import { Grid, Tabs, Tab, Box, CircularProgress } from "@mui/material";
|
|
5
|
+
import { ErrorOutline } from "@mui/icons-material";
|
|
6
|
+
import { SensiTabValues, SensiBranchesTabValues, SensiInjectionsSet, SensiInjection, SensiHvdcs, SensiPsts, SensiNodes, COLUMNS_DEFINITIONS_INJECTIONS_SET, COLUMNS_DEFINITIONS_INJECTIONS, COLUMNS_DEFINITIONS_HVDCS, COLUMNS_DEFINITIONS_PSTS, COLUMNS_DEFINITIONS_NODES } from "./columns-definitions.js";
|
|
7
|
+
import { SensitivityTable } from "./sensitivity-table.js";
|
|
8
|
+
import { TabPanel } from "../common/parameters.js";
|
|
9
|
+
import "../../../utils/types/equipmentType.js";
|
|
10
|
+
import "localized-countries";
|
|
11
|
+
import "localized-countries/data/fr";
|
|
12
|
+
import "localized-countries/data/en";
|
|
13
|
+
import "notistack";
|
|
14
|
+
import { useCreateRowDataSensi } from "../../../hooks/use-create-row-data-sensi.js";
|
|
15
|
+
import "react-hook-form";
|
|
16
|
+
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
17
|
+
import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
18
|
+
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
19
|
+
import "../../treeViewFinder/TreeViewFinder.js";
|
|
20
|
+
import "yup";
|
|
21
|
+
import "../../overflowableText/OverflowableText.js";
|
|
22
|
+
import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
23
|
+
import "../../customAGGrid/customAggrid.js";
|
|
24
|
+
import "ag-grid-community";
|
|
25
|
+
import "react-papaparse";
|
|
26
|
+
import "react-csv-downloader";
|
|
27
|
+
import "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
28
|
+
import "../../../utils/conversionUtils.js";
|
|
29
|
+
import "../../../utils/yupConfig.js";
|
|
30
|
+
import "@react-querybuilder/material";
|
|
31
|
+
import "../../filter/expert/expertFilterConstants.js";
|
|
32
|
+
import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
33
|
+
import "uuid";
|
|
34
|
+
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
35
|
+
import "react-querybuilder";
|
|
36
|
+
import "../common/widget/parameter-line-slider.js";
|
|
37
|
+
import "../common/limitreductions/columns-definitions.js";
|
|
38
|
+
const styles = {
|
|
39
|
+
circularProgress: (theme) => ({
|
|
40
|
+
display: "flex",
|
|
41
|
+
marginRight: theme.spacing(1),
|
|
42
|
+
color: theme.palette.primary.main
|
|
43
|
+
}),
|
|
44
|
+
errorOutlineIcon: (theme) => ({
|
|
45
|
+
marginRight: theme.spacing(1),
|
|
46
|
+
color: theme.palette.error.main,
|
|
47
|
+
display: "flex"
|
|
48
|
+
}),
|
|
49
|
+
textInfo: (theme) => ({
|
|
50
|
+
color: theme.palette.primary.main,
|
|
51
|
+
display: "flex"
|
|
52
|
+
}),
|
|
53
|
+
textInitial: {
|
|
54
|
+
color: "grey"
|
|
55
|
+
},
|
|
56
|
+
textAlert: (theme) => ({
|
|
57
|
+
color: theme.palette.error.main,
|
|
58
|
+
display: "flex"
|
|
59
|
+
}),
|
|
60
|
+
boxContent: {
|
|
61
|
+
display: "flex",
|
|
62
|
+
alignItems: "end",
|
|
63
|
+
justifyContent: "right",
|
|
64
|
+
flex: "auto",
|
|
65
|
+
flexGrow: "1",
|
|
66
|
+
whiteSpace: "pre-wrap"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function SensitivityParametersSelector({
|
|
70
|
+
onFormChanged,
|
|
71
|
+
onChangeParams,
|
|
72
|
+
launchLoader,
|
|
73
|
+
analysisComputeComplexity,
|
|
74
|
+
enableDeveloperMode,
|
|
75
|
+
isStudyLinked
|
|
76
|
+
}) {
|
|
77
|
+
const intl = useIntl();
|
|
78
|
+
const [tabValue, setTabValue] = useState(SensiTabValues.SensitivityBranches);
|
|
79
|
+
const [subTabValue, setSubTabValue] = useState(SensiBranchesTabValues.SensiInjectionsSet);
|
|
80
|
+
const handleTabChange = useCallback((event, newValue) => {
|
|
81
|
+
setTabValue(newValue);
|
|
82
|
+
}, []);
|
|
83
|
+
const handleSubTabChange = useCallback((event, newValue) => {
|
|
84
|
+
setSubTabValue(newValue);
|
|
85
|
+
}, []);
|
|
86
|
+
const tabInfo = [
|
|
87
|
+
{
|
|
88
|
+
label: "SensitivityBranches",
|
|
89
|
+
subTabs: [
|
|
90
|
+
{ label: "SensiInjectionsSet" },
|
|
91
|
+
{ label: "SensiInjection" },
|
|
92
|
+
{ label: "SensiHVDC" },
|
|
93
|
+
{ label: "SensiPST" }
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
...enableDeveloperMode && [{ label: "SensitivityNodes" }] || []
|
|
97
|
+
];
|
|
98
|
+
const [rowDataInjectionsSet, useFieldArrayOutputInjectionsSet] = useCreateRowDataSensi(
|
|
99
|
+
SensiInjectionsSet
|
|
100
|
+
);
|
|
101
|
+
const [rowDataInjections, useFieldArrayOutputInjections] = useCreateRowDataSensi(SensiInjection);
|
|
102
|
+
const [rowDataHvdc, useFieldArrayOutputHvdc] = useCreateRowDataSensi(SensiHvdcs);
|
|
103
|
+
const [rowDataPst, useFieldArrayOutputPst] = useCreateRowDataSensi(SensiPsts);
|
|
104
|
+
const [rowDataNodes, useFieldArrayOutputNodes] = useCreateRowDataSensi(SensiNodes);
|
|
105
|
+
const getColumnsDefinition = useCallback(
|
|
106
|
+
(sensiColumns) => {
|
|
107
|
+
if (sensiColumns) {
|
|
108
|
+
return sensiColumns.map((column) => ({
|
|
109
|
+
...column,
|
|
110
|
+
label: intl.formatMessage({ id: column.label })
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
return [];
|
|
114
|
+
},
|
|
115
|
+
[intl]
|
|
116
|
+
);
|
|
117
|
+
const renderComputingEventLoading = () => {
|
|
118
|
+
return /* @__PURE__ */ jsxs(Box, { sx: styles.textInfo, children: [
|
|
119
|
+
/* @__PURE__ */ jsx(CircularProgress, { size: "1em", sx: styles.circularProgress }),
|
|
120
|
+
/* @__PURE__ */ jsx(FormattedMessage, { id: "loadingComputing" })
|
|
121
|
+
] });
|
|
122
|
+
};
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!enableDeveloperMode) {
|
|
125
|
+
setTabValue(SensiTabValues.SensitivityBranches);
|
|
126
|
+
}
|
|
127
|
+
}, [enableDeveloperMode]);
|
|
128
|
+
const ComputingEvent = useMemo(() => {
|
|
129
|
+
const renderComputingEvent = () => {
|
|
130
|
+
if (analysisComputeComplexity < 999999 && analysisComputeComplexity > 5e5) {
|
|
131
|
+
return /* @__PURE__ */ jsxs(Box, { sx: styles.textAlert, children: [
|
|
132
|
+
/* @__PURE__ */ jsx(ErrorOutline, { sx: styles.errorOutlineIcon }),
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
FormattedMessage,
|
|
135
|
+
{
|
|
136
|
+
id: "sensitivityAnalysis.simulatedComputations",
|
|
137
|
+
values: {
|
|
138
|
+
count: analysisComputeComplexity.toString()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
if (analysisComputeComplexity > 999999) {
|
|
145
|
+
return /* @__PURE__ */ jsxs(Box, { sx: styles.textAlert, children: [
|
|
146
|
+
/* @__PURE__ */ jsx(ErrorOutline, { sx: styles.errorOutlineIcon }),
|
|
147
|
+
/* @__PURE__ */ jsx(FormattedMessage, { id: "sensitivityAnalysis.moreThanOneMillionComputations" })
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
if (analysisComputeComplexity === 0) {
|
|
151
|
+
return /* @__PURE__ */ jsx(Box, { sx: styles.textInitial, children: /* @__PURE__ */ jsx(
|
|
152
|
+
FormattedMessage,
|
|
153
|
+
{
|
|
154
|
+
id: "sensitivityAnalysis.simulatedComputations",
|
|
155
|
+
values: {
|
|
156
|
+
count: analysisComputeComplexity.toString()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
) });
|
|
160
|
+
}
|
|
161
|
+
return /* @__PURE__ */ jsx(Box, { sx: styles.textInfo, children: /* @__PURE__ */ jsx(
|
|
162
|
+
FormattedMessage,
|
|
163
|
+
{
|
|
164
|
+
id: "sensitivityAnalysis.simulatedComputations",
|
|
165
|
+
values: {
|
|
166
|
+
count: analysisComputeComplexity.toString()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
) });
|
|
170
|
+
};
|
|
171
|
+
return launchLoader ? renderComputingEventLoading() : renderComputingEvent();
|
|
172
|
+
}, [analysisComputeComplexity, launchLoader]);
|
|
173
|
+
return /* @__PURE__ */ jsxs(Grid, { sx: { width: "100%" }, children: [
|
|
174
|
+
/* @__PURE__ */ jsx(Tabs, { value: tabValue, onChange: handleTabChange, children: tabInfo.map((tab, index) => /* @__PURE__ */ jsx(
|
|
175
|
+
Tab,
|
|
176
|
+
{
|
|
177
|
+
label: /* @__PURE__ */ jsx(FormattedMessage, { id: tab.label }),
|
|
178
|
+
value: index,
|
|
179
|
+
sx: {
|
|
180
|
+
fontSize: 17,
|
|
181
|
+
fontWeight: "bold",
|
|
182
|
+
textTransform: "capitalize"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
tab.label
|
|
186
|
+
)) }),
|
|
187
|
+
tabInfo.map((tab, index) => /* @__PURE__ */ jsxs(TabPanel, { value: tabValue, index, sx: { paddingTop: 1 }, children: [
|
|
188
|
+
tabValue === SensiTabValues.SensitivityBranches && tab.subTabs && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
189
|
+
/* @__PURE__ */ jsx(Tabs, { value: subTabValue, onChange: handleSubTabChange, children: tab.subTabs.map((subTab, subIndex) => /* @__PURE__ */ jsx(
|
|
190
|
+
Tab,
|
|
191
|
+
{
|
|
192
|
+
value: subIndex,
|
|
193
|
+
sx: {
|
|
194
|
+
fontWeight: "bold",
|
|
195
|
+
textTransform: "capitalize"
|
|
196
|
+
},
|
|
197
|
+
label: /* @__PURE__ */ jsx(FormattedMessage, { id: subTab.label })
|
|
198
|
+
},
|
|
199
|
+
subTab.label
|
|
200
|
+
)) }),
|
|
201
|
+
isStudyLinked && /* @__PURE__ */ jsxs(Box, { sx: styles.boxContent, children: [
|
|
202
|
+
ComputingEvent,
|
|
203
|
+
/* @__PURE__ */ jsx(FormattedMessage, { id: "sensitivityAnalysis.separator" }),
|
|
204
|
+
/* @__PURE__ */ jsx(FormattedMessage, { id: "sensitivityAnalysis.maximumSimulatedComputations" })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ jsx(TabPanel, { index: SensiBranchesTabValues.SensiInjectionsSet, value: subTabValue, children: /* @__PURE__ */ jsx(
|
|
207
|
+
SensitivityTable,
|
|
208
|
+
{
|
|
209
|
+
arrayFormName: `${SensiInjectionsSet.name}`,
|
|
210
|
+
columnsDefinition: getColumnsDefinition(
|
|
211
|
+
COLUMNS_DEFINITIONS_INJECTIONS_SET
|
|
212
|
+
),
|
|
213
|
+
useFieldArrayOutput: useFieldArrayOutputInjectionsSet,
|
|
214
|
+
createRows: rowDataInjectionsSet,
|
|
215
|
+
tableHeight: 300,
|
|
216
|
+
onFormChanged,
|
|
217
|
+
onChangeParams
|
|
218
|
+
}
|
|
219
|
+
) }),
|
|
220
|
+
/* @__PURE__ */ jsx(TabPanel, { index: SensiBranchesTabValues.SensiInjection, value: subTabValue, children: /* @__PURE__ */ jsx(
|
|
221
|
+
SensitivityTable,
|
|
222
|
+
{
|
|
223
|
+
arrayFormName: `${SensiInjection.name}`,
|
|
224
|
+
columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_INJECTIONS),
|
|
225
|
+
useFieldArrayOutput: useFieldArrayOutputInjections,
|
|
226
|
+
createRows: rowDataInjections,
|
|
227
|
+
tableHeight: 300,
|
|
228
|
+
onFormChanged,
|
|
229
|
+
onChangeParams
|
|
230
|
+
}
|
|
231
|
+
) }),
|
|
232
|
+
/* @__PURE__ */ jsx(TabPanel, { index: SensiBranchesTabValues.SensiHVDC, value: subTabValue, children: /* @__PURE__ */ jsx(
|
|
233
|
+
SensitivityTable,
|
|
234
|
+
{
|
|
235
|
+
arrayFormName: `${SensiHvdcs.name}`,
|
|
236
|
+
columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_HVDCS),
|
|
237
|
+
useFieldArrayOutput: useFieldArrayOutputHvdc,
|
|
238
|
+
createRows: rowDataHvdc,
|
|
239
|
+
tableHeight: 300,
|
|
240
|
+
onFormChanged,
|
|
241
|
+
onChangeParams
|
|
242
|
+
}
|
|
243
|
+
) }),
|
|
244
|
+
/* @__PURE__ */ jsx(TabPanel, { index: SensiBranchesTabValues.SensiPST, value: subTabValue, children: /* @__PURE__ */ jsx(
|
|
245
|
+
SensitivityTable,
|
|
246
|
+
{
|
|
247
|
+
arrayFormName: `${SensiPsts.name}`,
|
|
248
|
+
columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_PSTS),
|
|
249
|
+
useFieldArrayOutput: useFieldArrayOutputPst,
|
|
250
|
+
createRows: rowDataPst,
|
|
251
|
+
tableHeight: 300,
|
|
252
|
+
onFormChanged,
|
|
253
|
+
onChangeParams
|
|
254
|
+
}
|
|
255
|
+
) })
|
|
256
|
+
] }),
|
|
257
|
+
tabValue === SensiTabValues.SensitivityNodes && /* @__PURE__ */ jsx(
|
|
258
|
+
SensitivityTable,
|
|
259
|
+
{
|
|
260
|
+
arrayFormName: `${SensiNodes.name}`,
|
|
261
|
+
columnsDefinition: getColumnsDefinition(COLUMNS_DEFINITIONS_NODES),
|
|
262
|
+
useFieldArrayOutput: useFieldArrayOutputNodes,
|
|
263
|
+
createRows: rowDataNodes,
|
|
264
|
+
tableHeight: 367,
|
|
265
|
+
onFormChanged,
|
|
266
|
+
onChangeParams
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
] }, tab.label))
|
|
270
|
+
] });
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
SensitivityParametersSelector as default
|
|
274
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseFieldArrayReturn } from 'react-hook-form';
|
|
2
|
+
import { IColumnsDef } from './columns-definitions';
|
|
3
|
+
interface SensitivityTableProps {
|
|
4
|
+
arrayFormName: string;
|
|
5
|
+
useFieldArrayOutput: UseFieldArrayReturn;
|
|
6
|
+
columnsDefinition: IColumnsDef[];
|
|
7
|
+
tableHeight: number;
|
|
8
|
+
createRows: (a: number) => void;
|
|
9
|
+
disableAdd?: boolean;
|
|
10
|
+
disableDelete?: boolean;
|
|
11
|
+
onFormChanged: (a: boolean) => void;
|
|
12
|
+
onChangeParams: (a: Record<string, any>, b: string, c: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function SensitivityTable({ arrayFormName, useFieldArrayOutput, columnsDefinition, tableHeight, createRows, disableAdd, disableDelete, onFormChanged, onChangeParams, }: Readonly<SensitivityTableProps>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TableContainer, Table, TableHead, TableRow, TableCell, Box, Tooltip, IconButton, TableBody } from "@mui/material";
|
|
3
|
+
import { AddCircle } from "@mui/icons-material";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
6
|
+
import { useFormContext } from "react-hook-form";
|
|
7
|
+
import { TableRowComponent } from "./table-row.js";
|
|
8
|
+
import { ACTIVATED, MONITORED_BRANCHES, INJECTIONS, HVDC_LINES, PSTS, COUNT } from "./constants.js";
|
|
9
|
+
import "@hello-pangea/dnd";
|
|
10
|
+
import { MAX_ROWS_NUMBER } from "../../dnd-table/dnd-table.type.js";
|
|
11
|
+
import "../../../utils/types/equipmentType.js";
|
|
12
|
+
import "localized-countries";
|
|
13
|
+
import "localized-countries/data/fr";
|
|
14
|
+
import "localized-countries/data/en";
|
|
15
|
+
import "notistack";
|
|
16
|
+
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
17
|
+
import "yup";
|
|
18
|
+
import "../../overflowableText/OverflowableText.js";
|
|
19
|
+
import "../../treeViewFinder/TreeViewFinder.js";
|
|
20
|
+
import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
21
|
+
import "../../customAGGrid/customAggrid.js";
|
|
22
|
+
import "ag-grid-community";
|
|
23
|
+
import "react-papaparse";
|
|
24
|
+
import "react-csv-downloader";
|
|
25
|
+
import "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
26
|
+
import "../../../utils/conversionUtils.js";
|
|
27
|
+
import "../../../utils/yupConfig.js";
|
|
28
|
+
import "@react-querybuilder/material";
|
|
29
|
+
import "../../filter/expert/expertFilterConstants.js";
|
|
30
|
+
import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
31
|
+
import "uuid";
|
|
32
|
+
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
33
|
+
import "react-querybuilder";
|
|
34
|
+
function SensitivityTable({
|
|
35
|
+
arrayFormName,
|
|
36
|
+
useFieldArrayOutput,
|
|
37
|
+
columnsDefinition,
|
|
38
|
+
tableHeight,
|
|
39
|
+
createRows,
|
|
40
|
+
disableAdd,
|
|
41
|
+
disableDelete = false,
|
|
42
|
+
onFormChanged,
|
|
43
|
+
onChangeParams
|
|
44
|
+
}) {
|
|
45
|
+
const intl = useIntl();
|
|
46
|
+
const { getValues } = useFormContext();
|
|
47
|
+
const { fields: currentRows, append, remove } = useFieldArrayOutput;
|
|
48
|
+
const handleAddRowsButton = useCallback(() => {
|
|
49
|
+
if (currentRows.length >= MAX_ROWS_NUMBER) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
append(createRows(1));
|
|
53
|
+
}, [append, createRows, currentRows.length]);
|
|
54
|
+
const fetchCount = useCallback(
|
|
55
|
+
(providedArrayFormName, index, source) => {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
const row = getValues(providedArrayFormName)[index];
|
|
58
|
+
const isActivated = row[ACTIVATED];
|
|
59
|
+
const hasMonitoredBranches = ((_a = row[MONITORED_BRANCHES]) == null ? void 0 : _a.length) > 0;
|
|
60
|
+
const hasInjections = ((_b = row[INJECTIONS]) == null ? void 0 : _b.length) > 0 || ((_c = row[HVDC_LINES]) == null ? void 0 : _c.length) > 0 || ((_d = row[PSTS]) == null ? void 0 : _d.length) > 0;
|
|
61
|
+
if (source === "switch" && hasMonitoredBranches && hasInjections) {
|
|
62
|
+
if (isActivated) {
|
|
63
|
+
onChangeParams(row, providedArrayFormName, index);
|
|
64
|
+
} else {
|
|
65
|
+
onFormChanged(true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (source === "directory" && isActivated) {
|
|
69
|
+
if (hasMonitoredBranches && hasInjections) {
|
|
70
|
+
onChangeParams(row, providedArrayFormName, index);
|
|
71
|
+
} else if ((!hasMonitoredBranches || !hasInjections) && row.count === 0) {
|
|
72
|
+
onFormChanged(false);
|
|
73
|
+
} else if (!hasMonitoredBranches || !hasInjections) {
|
|
74
|
+
onFormChanged(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[onChangeParams, onFormChanged, getValues]
|
|
79
|
+
);
|
|
80
|
+
const handleDeleteButton = useCallback(
|
|
81
|
+
(index) => {
|
|
82
|
+
const currentRowsValues = getValues(arrayFormName);
|
|
83
|
+
let isFormChanged = false;
|
|
84
|
+
if (index >= 0 && index < currentRowsValues.length) {
|
|
85
|
+
if (currentRowsValues[index][COUNT] && currentRowsValues[index][ACTIVATED]) {
|
|
86
|
+
isFormChanged = true;
|
|
87
|
+
}
|
|
88
|
+
remove(index);
|
|
89
|
+
}
|
|
90
|
+
if (isFormChanged) {
|
|
91
|
+
onFormChanged(true);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
[arrayFormName, getValues, onFormChanged, remove]
|
|
95
|
+
);
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
TableContainer,
|
|
98
|
+
{
|
|
99
|
+
sx: {
|
|
100
|
+
height: tableHeight,
|
|
101
|
+
border: "solid 0px rgba(0,0,0,0.1)"
|
|
102
|
+
},
|
|
103
|
+
children: /* @__PURE__ */ jsxs(Table, { stickyHeader: true, size: "small", sx: { tableLayout: "fixed" }, children: [
|
|
104
|
+
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
105
|
+
columnsDefinition.map((column) => /* @__PURE__ */ jsx(TableCell, { sx: { width: column.width, textAlign: "center" }, children: /* @__PURE__ */ jsx(Box, { children: column.label }) }, column.dataKey)),
|
|
106
|
+
/* @__PURE__ */ jsx(TableCell, { sx: { width: "5rem", textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
107
|
+
Tooltip,
|
|
108
|
+
{
|
|
109
|
+
title: intl.formatMessage({
|
|
110
|
+
id: "AddRows"
|
|
111
|
+
}),
|
|
112
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, { disabled: disableAdd, onClick: handleAddRowsButton, children: /* @__PURE__ */ jsx(AddCircle, {}) }) })
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
] }) }),
|
|
116
|
+
/* @__PURE__ */ jsx(TableBody, { children: currentRows.map((row, index) => /* @__PURE__ */ jsx(
|
|
117
|
+
TableRowComponent,
|
|
118
|
+
{
|
|
119
|
+
arrayFormName,
|
|
120
|
+
columnsDefinition,
|
|
121
|
+
index,
|
|
122
|
+
handleDeleteButton,
|
|
123
|
+
disableDelete,
|
|
124
|
+
fetchCount
|
|
125
|
+
},
|
|
126
|
+
row.id
|
|
127
|
+
)) })
|
|
128
|
+
] })
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
SensitivityTable
|
|
134
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
declare function EditableTableCell(arrayFormName: string, rowIndex: number, column: any, onRowChanged: (a: boolean, source: string) => void): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default EditableTableCell;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TableCell } from "@mui/material";
|
|
3
|
+
import "react-intl";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-hook-form";
|
|
6
|
+
import "../../../utils/types/equipmentType.js";
|
|
7
|
+
import "localized-countries";
|
|
8
|
+
import "localized-countries/data/fr";
|
|
9
|
+
import "localized-countries/data/en";
|
|
10
|
+
import "notistack";
|
|
11
|
+
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
12
|
+
import "@mui/icons-material";
|
|
13
|
+
import "yup";
|
|
14
|
+
import "../../overflowableText/OverflowableText.js";
|
|
15
|
+
import { DirectoryItemsInput } from "../../inputs/reactHookForm/DirectoryItemsInput.js";
|
|
16
|
+
import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
17
|
+
import "../../customAGGrid/customAggrid.js";
|
|
18
|
+
import "ag-grid-community";
|
|
19
|
+
import "react-papaparse";
|
|
20
|
+
import "react-csv-downloader";
|
|
21
|
+
import { SwitchInput } from "../../inputs/reactHookForm/booleans/SwitchInput.js";
|
|
22
|
+
import { FloatInput } from "../../inputs/reactHookForm/numbers/FloatInput.js";
|
|
23
|
+
import { TextInput } from "../../inputs/reactHookForm/text/TextInput.js";
|
|
24
|
+
import "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
25
|
+
import { MuiSelectInput } from "../../inputs/reactHookForm/selectInputs/MuiSelectInput.js";
|
|
26
|
+
import "../../../utils/conversionUtils.js";
|
|
27
|
+
import "../../../utils/yupConfig.js";
|
|
28
|
+
import "@react-querybuilder/material";
|
|
29
|
+
import "../../filter/expert/expertFilterConstants.js";
|
|
30
|
+
import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
31
|
+
import "uuid";
|
|
32
|
+
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
33
|
+
import "react-querybuilder";
|
|
34
|
+
function EditableTableCell(arrayFormName, rowIndex, column, onRowChanged) {
|
|
35
|
+
const handleDirectoryItemsChange = () => {
|
|
36
|
+
onRowChanged(true, "directory");
|
|
37
|
+
};
|
|
38
|
+
const handleSwitchInputChange = () => {
|
|
39
|
+
onRowChanged(true, "switch");
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ jsxs(
|
|
42
|
+
TableCell,
|
|
43
|
+
{
|
|
44
|
+
sx: {
|
|
45
|
+
width: column.width
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
column.directoryItems && /* @__PURE__ */ jsx(
|
|
49
|
+
DirectoryItemsInput,
|
|
50
|
+
{
|
|
51
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
52
|
+
equipmentTypes: column.equipmentTypes,
|
|
53
|
+
elementType: column.elementType,
|
|
54
|
+
titleId: column.titleId,
|
|
55
|
+
hideErrorMessage: true,
|
|
56
|
+
label: void 0,
|
|
57
|
+
itemFilter: void 0,
|
|
58
|
+
onRowChanged: handleDirectoryItemsChange
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
column.menuItems && /* @__PURE__ */ jsx(
|
|
62
|
+
MuiSelectInput,
|
|
63
|
+
{
|
|
64
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
65
|
+
options: column.equipmentTypes,
|
|
66
|
+
size: "small",
|
|
67
|
+
fullWidth: true
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
column.checkboxItems && /* @__PURE__ */ jsx("span", { onChange: handleSwitchInputChange, children: /* @__PURE__ */ jsx(SwitchInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}` }) }),
|
|
71
|
+
column.floatItems && /* @__PURE__ */ jsx(FloatInput, { name: `${arrayFormName}[${rowIndex}].${column.dataKey}` }),
|
|
72
|
+
column.textItems && /* @__PURE__ */ jsx(
|
|
73
|
+
TextInput,
|
|
74
|
+
{
|
|
75
|
+
name: `${arrayFormName}[${rowIndex}].${column.dataKey}`,
|
|
76
|
+
formProps: { disabled: !column.editable }
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
column.dataKey
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
EditableTableCell as default
|
|
86
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IColumnsDef } from './columns-definitions';
|
|
2
|
+
interface TableRowComponentProps {
|
|
3
|
+
arrayFormName: string;
|
|
4
|
+
columnsDefinition: IColumnsDef[];
|
|
5
|
+
index: number;
|
|
6
|
+
handleDeleteButton: (index: number) => void;
|
|
7
|
+
disableDelete: boolean;
|
|
8
|
+
fetchCount: (a: string, b: number, c: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function TableRowComponent({ arrayFormName, columnsDefinition, index, handleDeleteButton, disableDelete, fetchCount, }: Readonly<TableRowComponentProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TableRow, TableCell, Tooltip, IconButton } from "@mui/material";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useIntl } from "react-intl";
|
|
5
|
+
import { Delete } from "@mui/icons-material";
|
|
6
|
+
import EditableTableCell from "./table-cell.js";
|
|
7
|
+
function TableRowComponent({
|
|
8
|
+
arrayFormName,
|
|
9
|
+
columnsDefinition,
|
|
10
|
+
index,
|
|
11
|
+
handleDeleteButton,
|
|
12
|
+
disableDelete = false,
|
|
13
|
+
fetchCount
|
|
14
|
+
}) {
|
|
15
|
+
const [isHover, setIsHover] = useState(false);
|
|
16
|
+
const intl = useIntl();
|
|
17
|
+
function handleHover(enter) {
|
|
18
|
+
return setIsHover(enter);
|
|
19
|
+
}
|
|
20
|
+
const handleRowChanged = (isChanged, source) => {
|
|
21
|
+
if (isChanged) {
|
|
22
|
+
fetchCount(arrayFormName, index, source);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsxs(TableRow, { onMouseEnter: () => handleHover(true), onMouseLeave: () => handleHover(false), children: [
|
|
26
|
+
columnsDefinition.map(
|
|
27
|
+
(column) => EditableTableCell(arrayFormName, index, column, handleRowChanged)
|
|
28
|
+
),
|
|
29
|
+
!disableDelete && /* @__PURE__ */ jsx(TableCell, { sx: { width: "5rem", textAlign: "center" }, children: isHover && /* @__PURE__ */ jsx(
|
|
30
|
+
Tooltip,
|
|
31
|
+
{
|
|
32
|
+
title: intl.formatMessage({
|
|
33
|
+
id: "DeleteRows"
|
|
34
|
+
}),
|
|
35
|
+
children: /* @__PURE__ */ jsx(IconButton, { onClick: () => handleDeleteButton(index), children: /* @__PURE__ */ jsx(Delete, {}) })
|
|
36
|
+
}
|
|
37
|
+
) })
|
|
38
|
+
] });
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
TableRowComponent
|
|
42
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { ObjectSchema } from 'yup';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { UUID } from 'crypto';
|
|
5
|
+
import { ComputingType } from '../common';
|
|
6
|
+
import { SensitivityAnalysisParametersInfos, UseParametersBackendReturnProps } from '../../../utils';
|
|
7
|
+
type SubTabsValues = 'sensitivityInjectionsSet' | 'sensitivityInjection' | 'sensitivityHVDC' | 'sensitivityPST';
|
|
8
|
+
export interface UseSensitivityAnalysisParametersReturn {
|
|
9
|
+
formMethods: UseFormReturn<any>;
|
|
10
|
+
formSchema: ObjectSchema<any>;
|
|
11
|
+
formattedProviders: {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
fromSensitivityAnalysisParamsDataToFormValues: (parameters: SensitivityAnalysisParametersInfos) => any;
|
|
16
|
+
formatNewParams: (formData: Record<string, any>) => SensitivityAnalysisParametersInfos;
|
|
17
|
+
params: SensitivityAnalysisParametersInfos | null;
|
|
18
|
+
paramsLoaded: boolean;
|
|
19
|
+
isStudyLinked: boolean;
|
|
20
|
+
onSaveInline: (formData: Record<string, any>) => void;
|
|
21
|
+
onSaveDialog: (formData: Record<string, any>) => void;
|
|
22
|
+
isMaxReached: boolean;
|
|
23
|
+
launchLoader: boolean;
|
|
24
|
+
initRowsCount: () => void;
|
|
25
|
+
onFormChanged: (formChanged: boolean) => void;
|
|
26
|
+
onChangeParams: (row: any, arrayFormName: SubTabsValues, index: number) => void;
|
|
27
|
+
emptyFormData: Record<string, unknown>;
|
|
28
|
+
analysisComputeComplexity: number;
|
|
29
|
+
setAnalysisComputeComplexity: Dispatch<SetStateAction<number>>;
|
|
30
|
+
}
|
|
31
|
+
type UseSensitivityAnalysisParametersFormProps = {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string | null;
|
|
34
|
+
studyUuid: null;
|
|
35
|
+
currentNodeUuid: null;
|
|
36
|
+
currentRootNetworkUuid: null;
|
|
37
|
+
parametersBackend: UseParametersBackendReturnProps<ComputingType.SENSITIVITY_ANALYSIS>;
|
|
38
|
+
parametersUuid: UUID;
|
|
39
|
+
} | {
|
|
40
|
+
name: null;
|
|
41
|
+
description: null;
|
|
42
|
+
studyUuid: UUID | null;
|
|
43
|
+
currentNodeUuid: UUID | null;
|
|
44
|
+
currentRootNetworkUuid: UUID | null;
|
|
45
|
+
parametersBackend: UseParametersBackendReturnProps<ComputingType.SENSITIVITY_ANALYSIS>;
|
|
46
|
+
parametersUuid: null;
|
|
47
|
+
};
|
|
48
|
+
export declare const useSensitivityAnalysisParametersForm: ({ studyUuid, currentNodeUuid, currentRootNetworkUuid, parametersBackend, parametersUuid, name, description, }: UseSensitivityAnalysisParametersFormProps) => UseSensitivityAnalysisParametersReturn;
|
|
49
|
+
export {};
|