@gridsuite/commons-ui 0.170.0 → 0.172.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.
Files changed (61) hide show
  1. package/dist/components/index.js +6 -1
  2. package/dist/components/inputs/reactHookForm/selectInputs/CountriesInput.js +13 -10
  3. package/dist/components/parameters/common/contingency-table/contingency-table.d.ts +4 -2
  4. package/dist/components/parameters/common/contingency-table/contingency-table.js +22 -11
  5. package/dist/components/parameters/common/contingency-table/types.d.ts +4 -0
  6. package/dist/components/parameters/common/parameters.js +1 -1
  7. package/dist/components/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +5 -5
  8. package/dist/components/parameters/index.js +6 -1
  9. package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +8 -15
  10. package/dist/components/parameters/loadflow/load-flow-parameters-form.js +2 -2
  11. package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +2 -4
  12. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.d.ts +2 -3
  13. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +33 -43
  14. package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +7 -9
  15. package/dist/components/parameters/security-analysis/security-analysis-parameters-form.d.ts +4 -2
  16. package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +5 -3
  17. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.d.ts +4 -2
  18. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +5 -4
  19. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.d.ts +1 -3
  20. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +10 -11
  21. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +6 -7
  22. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +1 -1
  23. package/dist/components/parameters/short-circuit/constants.d.ts +5 -0
  24. package/dist/components/parameters/short-circuit/constants.js +10 -0
  25. package/dist/components/parameters/short-circuit/index.js +6 -1
  26. package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.d.ts +10 -0
  27. package/dist/components/parameters/short-circuit/short-circuit-general-tab-panel.js +206 -0
  28. package/dist/components/parameters/short-circuit/short-circuit-parameters-content.d.ts +7 -0
  29. package/dist/components/parameters/short-circuit/short-circuit-parameters-content.js +108 -0
  30. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +7 -14
  31. package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +33 -30
  32. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +1 -1
  33. package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.d.ts +5 -0
  34. package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +72 -25
  35. package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.d.ts +2 -0
  36. package/dist/components/parameters/short-circuit/short-circuit-power-electronics-tab-panel.js +95 -0
  37. package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.d.ts +2 -0
  38. package/dist/components/parameters/short-circuit/short-circuit-study-area-tab-panel.js +143 -0
  39. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.d.ts +5 -1
  40. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +34 -14
  41. package/dist/hooks/use-parameters-backend.d.ts +2 -3
  42. package/dist/hooks/use-parameters-backend.js +33 -110
  43. package/dist/index.js +8 -6
  44. package/dist/services/directory.js +1 -1
  45. package/dist/services/explore.js +1 -1
  46. package/dist/services/index.js +2 -5
  47. package/dist/services/loadflow.d.ts +0 -1
  48. package/dist/services/loadflow.js +1 -8
  49. package/dist/services/security-analysis.d.ts +0 -2
  50. package/dist/services/security-analysis.js +2 -23
  51. package/dist/services/sensitivity-analysis.d.ts +0 -1
  52. package/dist/services/sensitivity-analysis.js +1 -8
  53. package/dist/translations/en/parameters.d.ts +10 -8
  54. package/dist/translations/en/parameters.js +10 -8
  55. package/dist/translations/fr/parameters.d.ts +10 -9
  56. package/dist/translations/fr/parameters.js +10 -9
  57. package/dist/utils/constants/adornments.js +1 -1
  58. package/dist/utils/types/parameters.type.d.ts +16 -13
  59. package/package.json +1 -1
  60. package/dist/components/parameters/short-circuit/short-circuit-fields.d.ts +0 -10
  61. package/dist/components/parameters/short-circuit/short-circuit-fields.js +0 -276
@@ -59,7 +59,7 @@ function ShortCircuitParametersInLine({
59
59
  const intl = useIntl();
60
60
  const [openCreateParameterDialog, setOpenCreateParameterDialog] = useState(false);
61
61
  const [openSelectParameterDialog, setOpenSelectParameterDialog] = useState(false);
62
- const [, , , , , , , , resetParameters, ,] = parametersBackend;
62
+ const { resetParameters } = parametersBackend;
63
63
  const [openResetConfirmation, setOpenResetConfirmation] = useState(false);
64
64
  const [pendingResetAction, setPendingResetAction] = useState(null);
65
65
  const { snackError } = useSnackMessage();
@@ -2,6 +2,11 @@ import { InitialVoltage } from './constants';
2
2
  import { default as yup } from '../../../utils/yupConfig';
3
3
  import { SpecificParameterInfos, SpecificParametersValues } from '../../../utils';
4
4
  import { SnackInputs } from '../../../hooks';
5
+ export declare enum ShortCircuitParametersTabValues {
6
+ GENERAL = "General",
7
+ STUDY_AREA = "StudyArea",
8
+ POWER_ELECTRONICS = "PowerElectronics"
9
+ }
5
10
  export declare const getCommonShortCircuitParametersFormSchema: () => yup.ObjectSchema<{
6
11
  commonParameters: {
7
12
  withFeederResult: NonNullable<boolean | undefined>;
@@ -1,4 +1,4 @@
1
- import { SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, InitialVoltage, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_FEEDER_RESULT, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS } from "./constants.js";
1
+ import { SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, InitialVoltage, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_FEEDER_RESULT, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, NODE_CLUSTER, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS, NODE_CLUSTER_FILTER_IDS } from "./constants.js";
2
2
  import "../../../utils/yupConfig.js";
3
3
  import { COMMON_PARAMETERS, SPECIFIC_PARAMETERS } from "../common/constants.js";
4
4
  import "react/jsx-runtime";
@@ -41,6 +41,12 @@ import "react-querybuilder";
41
41
  import "../common/widget/parameter-line-slider.js";
42
42
  import "../common/limitreductions/columns-definitions.js";
43
43
  import { getSpecificParametersFormSchema, getDefaultSpecificParamsValues, getAllSpecificParametersValues, formatSpecificParameters } from "../common/utils.js";
44
+ var ShortCircuitParametersTabValues = /* @__PURE__ */ ((ShortCircuitParametersTabValues2) => {
45
+ ShortCircuitParametersTabValues2["GENERAL"] = "General";
46
+ ShortCircuitParametersTabValues2["STUDY_AREA"] = "StudyArea";
47
+ ShortCircuitParametersTabValues2["POWER_ELECTRONICS"] = "PowerElectronics";
48
+ return ShortCircuitParametersTabValues2;
49
+ })(ShortCircuitParametersTabValues || {});
44
50
  const getCommonShortCircuitParametersFormSchema = () => {
45
51
  return yup.object().shape({
46
52
  [COMMON_PARAMETERS]: yup.object().shape({
@@ -68,6 +74,15 @@ const getSpecificShortCircuitParametersFormSchema = (specificParametersDescripti
68
74
  type: yup.string().oneOf(["WIND", "SOLAR", "HVDC"]).required()
69
75
  })
70
76
  ).required() : void 0;
77
+ const nodeClusterParam = specificParametersDescriptionForProvider?.find(
78
+ (specificParam) => specificParam.name === NODE_CLUSTER
79
+ );
80
+ const nodeClusterSchema = nodeClusterParam ? yup.array().of(
81
+ yup.object().shape({
82
+ [ID]: yup.string().required(),
83
+ [NAME]: yup.string().required()
84
+ })
85
+ ) : void 0;
71
86
  const powerElectronicsClustersParam = specificParametersDescriptionForProvider?.find(
72
87
  (specificParam) => specificParam.name === SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS
73
88
  );
@@ -92,7 +107,8 @@ const getSpecificShortCircuitParametersFormSchema = (specificParametersDescripti
92
107
  const mergedSpecificShape = {
93
108
  ...existingSpecificFields,
94
109
  ...powerElectronicsMaterialsSchema ? { [SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS]: powerElectronicsMaterialsSchema } : {},
95
- ...powerElectronicsClustersSchema ? { [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: powerElectronicsClustersSchema } : {}
110
+ ...powerElectronicsClustersSchema ? { [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: powerElectronicsClustersSchema } : {},
111
+ ...nodeClusterSchema ? { [NODE_CLUSTER_FILTER_IDS]: nodeClusterSchema } : {}
96
112
  };
97
113
  const overrideSchema = yup.object().shape({
98
114
  [SPECIFIC_PARAMETERS]: yup.object().shape(mergedSpecificShape)
@@ -133,6 +149,12 @@ const getDefaultShortCircuitSpecificParamsValues = (specificParametersDescriptio
133
149
  active: false
134
150
  }));
135
151
  }
152
+ const nodeClusterParam = specificParametersDescriptionForProvider.find(
153
+ (specificParam) => specificParam.name === NODE_CLUSTER
154
+ );
155
+ if (nodeClusterParam) {
156
+ defaultValues[NODE_CLUSTER_FILTER_IDS] = nodeClusterParam.defaultValue;
157
+ }
136
158
  const powerElectronicsClustersParam = specificParametersDescriptionForProvider.find(
137
159
  (specificParam) => specificParam.name === SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS
138
160
  );
@@ -144,31 +166,42 @@ const getDefaultShortCircuitSpecificParamsValues = (specificParametersDescriptio
144
166
  const getShortCircuitSpecificParametersValues = (formData, _specificParametersValues) => {
145
167
  const powerElectronicsMaterialsParam = formData[SPECIFIC_PARAMETERS][SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS];
146
168
  const powerElectronicsClustersParam = formData[SPECIFIC_PARAMETERS][SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS];
169
+ const nodeClusterFilterIds = formData[SPECIFIC_PARAMETERS][NODE_CLUSTER_FILTER_IDS];
170
+ const finalSpecificParameters = getAllSpecificParametersValues(
171
+ formData,
172
+ _specificParametersValues
173
+ );
147
174
  if (powerElectronicsMaterialsParam && powerElectronicsClustersParam) {
148
- return {
149
- ...getAllSpecificParametersValues(formData, _specificParametersValues),
150
- [SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS]: JSON.stringify(
151
- powerElectronicsMaterialsParam.filter((sParam) => sParam.active).map((sParam) => {
152
- const { active, ...rest } = sParam;
153
- return rest;
154
- })
155
- ),
156
- [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: JSON.stringify(
157
- powerElectronicsClustersParam.map((sParam) => {
158
- const { filters, ...rest } = sParam;
159
- const lightFilters = (
160
- // keep only id and name in filters for backend
161
- filters?.map((filter) => ({
162
- filterId: filter[ID],
163
- filterName: filter.name
164
- })) ?? []
165
- );
166
- return { ...rest, filters: lightFilters };
167
- })
168
- )
169
- };
175
+ finalSpecificParameters[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] = JSON.stringify(
176
+ powerElectronicsMaterialsParam.filter((sParam) => sParam.active).map((sParam) => {
177
+ const { active, ...rest } = sParam;
178
+ return rest;
179
+ })
180
+ );
181
+ finalSpecificParameters[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = JSON.stringify(
182
+ powerElectronicsClustersParam.map((sParam) => {
183
+ const { filters, ...rest } = sParam;
184
+ const lightFilters = (
185
+ // keep only id and name in filters for backend
186
+ filters?.map((filter) => ({
187
+ filterId: filter[ID],
188
+ filterName: filter.name
189
+ })) ?? []
190
+ );
191
+ return { ...rest, filters: lightFilters };
192
+ })
193
+ );
170
194
  }
171
- return getAllSpecificParametersValues(formData, _specificParametersValues);
195
+ if (nodeClusterFilterIds) {
196
+ const lightFilters = nodeClusterFilterIds.map((filter) => {
197
+ return {
198
+ filterId: filter[ID],
199
+ filterName: filter.name
200
+ };
201
+ });
202
+ finalSpecificParameters[NODE_CLUSTER_FILTER_IDS] = JSON.stringify(lightFilters);
203
+ }
204
+ return finalSpecificParameters;
172
205
  };
173
206
  const formatElectronicsMaterialsParamString = (defaultValues, specificParamValue, snackError) => {
174
207
  const electronicsMaterialsArrayInParams = parsePowerElectronicsMaterialsParamString(
@@ -229,9 +262,23 @@ const formatShortCircuitSpecificParameters = (specificParametersDescriptionForPr
229
262
  ])?.[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS];
230
263
  }
231
264
  }
265
+ const nodeClusterParam = specificParametersDescriptionForProvider.find((p) => p.name === NODE_CLUSTER);
266
+ if (nodeClusterParam) {
267
+ if (Object.hasOwn(specificParamsList, NODE_CLUSTER_FILTER_IDS)) {
268
+ const filters = JSON.parse(specificParamsList[NODE_CLUSTER_FILTER_IDS]);
269
+ formatted[NODE_CLUSTER_FILTER_IDS] = filters.map((filter) => ({
270
+ [ID]: filter.filterId,
271
+ [NAME]: filter.filterName
272
+ // from back to front -> {id: uuid, name: string}
273
+ }));
274
+ } else {
275
+ formatted[NODE_CLUSTER_FILTER_IDS] = getDefaultSpecificParamsValues([nodeClusterParam])?.[NODE_CLUSTER_FILTER_IDS];
276
+ }
277
+ }
232
278
  return formatted;
233
279
  };
234
280
  export {
281
+ ShortCircuitParametersTabValues,
235
282
  formatShortCircuitSpecificParameters,
236
283
  getCommonShortCircuitParametersFormSchema,
237
284
  getDefaultShortCircuitSpecificParamsValues,
@@ -0,0 +1,2 @@
1
+ import { TabPanelProps } from '@mui/lab';
2
+ export declare const ShortCircuitPowerElectronicsTabPanel: import('react').ForwardRefExoticComponent<Omit<Readonly<TabPanelProps>, "ref"> & import('react').RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,95 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { Grid } from "@mui/material";
4
+ import { FormattedMessage } from "react-intl";
5
+ import { ShortCircuitIccMaterialTable } from "./short-circuit-icc-material-table.js";
6
+ import { SPECIFIC_PARAMETERS } from "../common/constants.js";
7
+ import { TabPanel } from "../common/parameters.js";
8
+ import "../../../utils/conversionUtils.js";
9
+ import "../../../utils/types/equipmentType.js";
10
+ import "@mui/icons-material";
11
+ import "../../../utils/yupConfig.js";
12
+ import "localized-countries";
13
+ import "localized-countries/data/fr";
14
+ import "localized-countries/data/en";
15
+ import "notistack";
16
+ import "react-hook-form";
17
+ import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
18
+ import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
19
+ import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
20
+ import "../../treeViewFinder/TreeViewFinder.js";
21
+ import { FieldLabel } from "../../inputs/reactHookForm/utils/FieldLabel.js";
22
+ import "../../overflowableText/OverflowableText.js";
23
+ import "yup";
24
+ import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
25
+ import "../../customAGGrid/customAggrid.js";
26
+ import "ag-grid-community";
27
+ import "react-papaparse";
28
+ import "react-csv-downloader";
29
+ import { SwitchInput } from "../../inputs/reactHookForm/booleans/SwitchInput.js";
30
+ import "../../inputs/reactHookForm/numbers/RangeInput.js";
31
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
32
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
33
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
34
+ import "@material-symbols/svg-400/outlined/add_notes.svg?react";
35
+ import "@react-querybuilder/material";
36
+ import "../../filter/expert/expertFilterConstants.js";
37
+ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
38
+ import "uuid";
39
+ import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
40
+ import "react-querybuilder";
41
+ import "../common/widget/parameter-line-slider.js";
42
+ import "../common/limitreductions/columns-definitions.js";
43
+ import GridSection from "../../grid/grid-section.js";
44
+ import GridItem from "../../grid/grid-item.js";
45
+ import { SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS, SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS } from "./constants.js";
46
+ import { ShortCircuitIccClusterTable } from "./short-circuit-icc-cluster-table.js";
47
+ import { COLUMNS_DEFINITIONS_ICC_MATERIALS, COLUMNS_DEFINITIONS_ICC_CLUSTERS } from "./columns-definition.js";
48
+ import { ShortCircuitParametersTabValues } from "./short-circuit-parameters-utils.js";
49
+ const iccMaterialsColumnsDef = COLUMNS_DEFINITIONS_ICC_MATERIALS.map((col) => ({
50
+ ...col,
51
+ label: /* @__PURE__ */ jsx(FormattedMessage, { id: col.label }),
52
+ tooltip: /* @__PURE__ */ jsx(FormattedMessage, { id: col.tooltip })
53
+ }));
54
+ const iccClustersColumnsDef = COLUMNS_DEFINITIONS_ICC_CLUSTERS.map((col) => ({
55
+ ...col,
56
+ label: /* @__PURE__ */ jsx(FormattedMessage, { id: col.label }),
57
+ tooltip: /* @__PURE__ */ jsx(FormattedMessage, { id: col.tooltip })
58
+ }));
59
+ function createRows() {
60
+ const rowData = {};
61
+ iccClustersColumnsDef.forEach((column) => {
62
+ rowData[column.dataKey] = column.initialValue;
63
+ });
64
+ return rowData;
65
+ }
66
+ const ShortCircuitPowerElectronicsTabPanel = forwardRef(
67
+ ({ ...othersTabPanelProps }, ref) => {
68
+ const modelPowerElectronics = /* @__PURE__ */ jsxs(Grid, { container: true, alignItems: "center", spacing: 2, direction: "row", children: [
69
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 10, children: /* @__PURE__ */ jsx(FieldLabel, { label: "ShortCircuitModelPowerElectronics" }) }),
70
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 2, children: /* @__PURE__ */ jsx(SwitchInput, { name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS}` }) })
71
+ ] });
72
+ return /* @__PURE__ */ jsxs(TabPanel, { index: ShortCircuitParametersTabValues.POWER_ELECTRONICS, ref, ...othersTabPanelProps, children: [
73
+ /* @__PURE__ */ jsx(GridSection, { title: "ShortCircuitPowerElectronicsSection", heading: 4 }),
74
+ /* @__PURE__ */ jsx(Grid, { container: true, xl: 6, children: /* @__PURE__ */ jsx(GridItem, { size: 10, children: modelPowerElectronics }) }),
75
+ /* @__PURE__ */ jsx(
76
+ ShortCircuitIccMaterialTable,
77
+ {
78
+ formName: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS}`,
79
+ columnsDefinition: iccMaterialsColumnsDef
80
+ }
81
+ ),
82
+ /* @__PURE__ */ jsx(
83
+ ShortCircuitIccClusterTable,
84
+ {
85
+ formName: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS}`,
86
+ columnsDefinition: iccClustersColumnsDef,
87
+ createRows
88
+ }
89
+ )
90
+ ] });
91
+ }
92
+ );
93
+ export {
94
+ ShortCircuitPowerElectronicsTabPanel
95
+ };
@@ -0,0 +1,2 @@
1
+ import { TabPanelProps } from '@mui/lab';
2
+ export declare const ShortCircuitStudyAreaTabPanel: import('react').ForwardRefExoticComponent<Omit<Readonly<TabPanelProps>, "ref"> & import('react').RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,143 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { Grid, Box } from "@mui/material";
4
+ import { useFormContext } from "react-hook-form";
5
+ import { SPECIFIC_PARAMETERS } from "../common/constants.js";
6
+ import { TabPanel } from "../common/parameters.js";
7
+ import "react-intl";
8
+ import { ActivePowerAdornment } from "../../../utils/constants/adornments.js";
9
+ import "../../../utils/conversionUtils.js";
10
+ import { ElementType } from "../../../utils/types/elementType.js";
11
+ import { EquipmentType } from "../../../utils/types/equipmentType.js";
12
+ import "@mui/icons-material";
13
+ import "../../../utils/yupConfig.js";
14
+ import "localized-countries";
15
+ import "localized-countries/data/fr";
16
+ import "localized-countries/data/en";
17
+ import "notistack";
18
+ import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
19
+ import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
20
+ import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
21
+ import "../../treeViewFinder/TreeViewFinder.js";
22
+ import { FieldLabel } from "../../inputs/reactHookForm/utils/FieldLabel.js";
23
+ import "../../overflowableText/OverflowableText.js";
24
+ import { OverflowableChipWithHelperText } from "../../inputs/reactHookForm/OverflowableChipWithHelperText.js";
25
+ import "yup";
26
+ import { DirectoryItemsInput } from "../../inputs/reactHookForm/DirectoryItemsInput.js";
27
+ import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
28
+ import "../../customAGGrid/customAggrid.js";
29
+ import "ag-grid-community";
30
+ import "react-papaparse";
31
+ import "react-csv-downloader";
32
+ import { RadioInput } from "../../inputs/reactHookForm/booleans/RadioInput.js";
33
+ import { FloatInput } from "../../inputs/reactHookForm/numbers/FloatInput.js";
34
+ import "../../inputs/reactHookForm/numbers/RangeInput.js";
35
+ import "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
36
+ import "@material-symbols/svg-400/outlined/arrows_output.svg?react";
37
+ import "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
38
+ import "@material-symbols/svg-400/outlined/add_notes.svg?react";
39
+ import "@react-querybuilder/material";
40
+ import "../../filter/expert/expertFilterConstants.js";
41
+ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
42
+ import "uuid";
43
+ import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
44
+ import "react-querybuilder";
45
+ import "../common/widget/parameter-line-slider.js";
46
+ import "../common/limitreductions/columns-definitions.js";
47
+ import GridSection from "../../grid/grid-section.js";
48
+ import GridItem from "../../grid/grid-item.js";
49
+ import { NODE_CLUSTER_FILTER_IDS, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, onlyStartedGeneratorsOptions, STARTED_GENERATORS_IN_CALCULATION_CLUSTER_THRESHOLD, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER, STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER_THRESHOLD } from "./constants.js";
50
+ import { ShortCircuitParametersTabValues } from "./short-circuit-parameters-utils.js";
51
+ const equipmentTypes = [EquipmentType.VOLTAGE_LEVEL];
52
+ const styles = {
53
+ h4: {
54
+ marginBottom: 1
55
+ }
56
+ };
57
+ const ShortCircuitStudyAreaTabPanel = forwardRef(
58
+ ({ ...othersTabPanelProps }, ref) => {
59
+ const { setValue } = useFormContext();
60
+ const startedGeneratorsInCalculationClusterThreshold = /* @__PURE__ */ jsx(
61
+ FloatInput,
62
+ {
63
+ name: `${SPECIFIC_PARAMETERS}.${STARTED_GENERATORS_IN_CALCULATION_CLUSTER_THRESHOLD}`,
64
+ label: "startedGeneratorsInCalculationClusterThreshold",
65
+ adornment: ActivePowerAdornment
66
+ }
67
+ );
68
+ const inClusterOnlyStartedGenerators = /* @__PURE__ */ jsx(
69
+ RadioInput,
70
+ {
71
+ name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`,
72
+ options: Object.values(onlyStartedGeneratorsOptions),
73
+ formProps: {
74
+ onChange: (_event, value) => {
75
+ setValue(
76
+ `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`,
77
+ value === "true",
78
+ {
79
+ shouldDirty: true
80
+ }
81
+ );
82
+ }
83
+ }
84
+ }
85
+ );
86
+ const startedGeneratorsOutsideCalculationClusterThreshold = /* @__PURE__ */ jsx(
87
+ FloatInput,
88
+ {
89
+ name: `${SPECIFIC_PARAMETERS}.${STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER_THRESHOLD}`,
90
+ label: "startedGeneratorsOutsideCalculationClusterThreshold",
91
+ adornment: ActivePowerAdornment
92
+ }
93
+ );
94
+ const outClusterOnlyStartedGenerators = /* @__PURE__ */ jsx(
95
+ RadioInput,
96
+ {
97
+ name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER}`,
98
+ options: Object.values(onlyStartedGeneratorsOptions),
99
+ formProps: {
100
+ onChange: (_event, value) => {
101
+ setValue(
102
+ `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER}`,
103
+ value === "true",
104
+ {
105
+ shouldDirty: true
106
+ }
107
+ );
108
+ }
109
+ }
110
+ }
111
+ );
112
+ return /* @__PURE__ */ jsxs(TabPanel, { index: ShortCircuitParametersTabValues.STUDY_AREA, ref, ...othersTabPanelProps, children: [
113
+ /* @__PURE__ */ jsx(GridSection, { title: "ShortCircuitInClusterFilter", heading: 4 }),
114
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: true, sx: { paddingBottom: 4 }, children: /* @__PURE__ */ jsx(
115
+ DirectoryItemsInput,
116
+ {
117
+ titleId: "FiltersListsSelection",
118
+ label: "Filters",
119
+ name: `${SPECIFIC_PARAMETERS}.${NODE_CLUSTER_FILTER_IDS}`,
120
+ elementType: ElementType.FILTER,
121
+ equipmentTypes,
122
+ ChipComponent: OverflowableChipWithHelperText,
123
+ chipProps: { variant: "outlined" },
124
+ fullHeight: true
125
+ }
126
+ ) }),
127
+ /* @__PURE__ */ jsx(GridSection, { title: "ShortCircuitStartedGeneratorsMode", heading: 4, customStyle: styles.h4 }),
128
+ /* @__PURE__ */ jsxs(Box, { sx: { paddingTop: 2, display: "flex", alignItems: "center" }, children: [
129
+ /* @__PURE__ */ jsx(GridItem, { size: 2, children: /* @__PURE__ */ jsx(FieldLabel, { label: "ShortCircuitInCluster" }) }),
130
+ /* @__PURE__ */ jsx(GridItem, { size: 3, children: inClusterOnlyStartedGenerators }),
131
+ /* @__PURE__ */ jsx(GridItem, { size: 2, children: startedGeneratorsInCalculationClusterThreshold })
132
+ ] }),
133
+ /* @__PURE__ */ jsxs(Box, { sx: { paddingTop: 2, display: "flex", alignItems: "center" }, children: [
134
+ /* @__PURE__ */ jsx(GridItem, { size: 2, children: /* @__PURE__ */ jsx(FieldLabel, { label: "ShortCircuitOutCluster" }) }),
135
+ /* @__PURE__ */ jsx(GridItem, { size: 3, children: outClusterOnlyStartedGenerators }),
136
+ /* @__PURE__ */ jsx(GridItem, { size: 2, children: startedGeneratorsOutsideCalculationClusterThreshold })
137
+ ] })
138
+ ] });
139
+ }
140
+ );
141
+ export {
142
+ ShortCircuitStudyAreaTabPanel
143
+ };
@@ -1,19 +1,23 @@
1
1
  import { FieldErrors, UseFormReturn } from 'react-hook-form';
2
+ import { SyntheticEvent } from 'react';
2
3
  import { ObjectSchema } from 'yup';
3
4
  import { UUID } from 'node:crypto';
4
5
  import { PredefinedParameters } from './constants';
5
6
  import { SpecificParameterInfos, UseParametersBackendReturnProps } from '../../../utils';
6
7
  import { ShortCircuitParametersInfos } from './short-circuit-parameters.type';
7
8
  import { ComputingType } from '../common';
9
+ import { ShortCircuitParametersTabValues } from './short-circuit-parameters-utils';
8
10
  export interface UseShortCircuitParametersFormReturn {
9
11
  formMethods: UseFormReturn;
10
12
  formSchema: ObjectSchema<any>;
13
+ selectedTab: ShortCircuitParametersTabValues;
14
+ handleTabChange: (event: SyntheticEvent, newValue: ShortCircuitParametersTabValues) => void;
15
+ tabIndexesWithError: ShortCircuitParametersTabValues[];
11
16
  resetAll: (predefinedParameter: PredefinedParameters) => void;
12
17
  specificParametersDescriptionForProvider: SpecificParameterInfos[];
13
18
  toShortCircuitFormValues: (_params: ShortCircuitParametersInfos) => any;
14
19
  formatNewParams: (formData: Record<string, any>) => ShortCircuitParametersInfos;
15
20
  params: ShortCircuitParametersInfos | null;
16
- provider: string | undefined;
17
21
  paramsLoaded: boolean;
18
22
  onValidationError: (errors: FieldErrors) => void;
19
23
  onSaveInline: (formData: Record<string, any>) => void;
@@ -1,6 +1,6 @@
1
1
  import { useForm } from "react-hook-form";
2
2
  import { yupResolver } from "@hookform/resolvers/yup";
3
- import { useState, useMemo, useCallback, useEffect } from "react";
3
+ import { useState, useCallback, useMemo, useEffect } from "react";
4
4
  import "../../../utils/yupConfig.js";
5
5
  import "react/jsx-runtime";
6
6
  import "react-intl";
@@ -37,26 +37,34 @@ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
37
37
  import "uuid";
38
38
  import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
39
39
  import "react-querybuilder";
40
- import { SHORT_CIRCUIT_PREDEFINED_PARAMS, PredefinedParameters, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, InitialVoltage, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, SHORT_CIRCUIT_VOLTAGE_RANGES } from "./constants.js";
40
+ import { SHORT_CIRCUIT_PREDEFINED_PARAMS, PredefinedParameters, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, InitialVoltage, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, SHORT_CIRCUIT_VOLTAGE_RANGES, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER, NODE_CLUSTER_FILTER_IDS } from "./constants.js";
41
41
  import "../../filter/HeaderFilterForm.js";
42
42
  import { getNameElementEditorSchema, getNameElementEditorEmptyFormData } from "../common/name-element-editor/name-element-editor-utils.js";
43
43
  import { SPECIFIC_PARAMETERS, COMMON_PARAMETERS, VERSION_PARAMETER, PROVIDER } from "../common/constants.js";
44
44
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
45
45
  import "../common/widget/parameter-line-slider.js";
46
46
  import "../common/limitreductions/columns-definitions.js";
47
- import { getDefaultShortCircuitSpecificParamsValues, getSpecificShortCircuitParametersFormSchema, getCommonShortCircuitParametersFormSchema, getShortCircuitSpecificParametersValues, formatShortCircuitSpecificParameters } from "./short-circuit-parameters-utils.js";
47
+ import { ShortCircuitParametersTabValues, getDefaultShortCircuitSpecificParamsValues, getSpecificShortCircuitParametersFormSchema, getCommonShortCircuitParametersFormSchema, getShortCircuitSpecificParametersValues, formatShortCircuitSpecificParameters } from "./short-circuit-parameters-utils.js";
48
48
  const useShortCircuitParametersForm = ({
49
49
  parametersBackend,
50
50
  parametersUuid,
51
51
  name,
52
52
  description
53
53
  }) => {
54
- const [, provider, , , , params, , updateParameters, , specificParamsDescriptions] = parametersBackend;
54
+ const { params, updateParameters, specificParamsDescription } = parametersBackend;
55
+ const provider = params?.provider;
56
+ const [selectedTab, setSelectedTab] = useState(
57
+ ShortCircuitParametersTabValues.GENERAL
58
+ );
59
+ const [tabIndexesWithError, setTabIndexesWithError] = useState([]);
55
60
  const [paramsLoaded, setParamsLoaded] = useState(false);
56
61
  const { snackError } = useSnackMessage();
62
+ const handleTabChange = useCallback((event, newValue) => {
63
+ setSelectedTab(newValue);
64
+ }, []);
57
65
  const specificParametersDescriptionForProvider = useMemo(() => {
58
- return provider && specificParamsDescriptions?.[provider] ? specificParamsDescriptions[provider] : [];
59
- }, [provider, specificParamsDescriptions]);
66
+ return provider && specificParamsDescription?.[provider] ? specificParamsDescription[provider] : [];
67
+ }, [provider, specificParamsDescription]);
60
68
  const specificParametersDefaultValues = useMemo(() => {
61
69
  return {
62
70
  ...getDefaultShortCircuitSpecificParamsValues(specificParametersDescriptionForProvider, snackError)
@@ -144,7 +152,7 @@ const useShortCircuitParametersForm = ({
144
152
  return {};
145
153
  }
146
154
  const specificParamsListForCurrentProvider = _params.specificParametersPerProvider[provider];
147
- const values = {
155
+ return {
148
156
  [PROVIDER]: _params.provider,
149
157
  [SHORT_CIRCUIT_PREDEFINED_PARAMS]: _params.predefinedParameters,
150
158
  [COMMON_PARAMETERS]: {
@@ -161,13 +169,23 @@ const useShortCircuitParametersForm = ({
161
169
  )
162
170
  }
163
171
  };
164
- return values;
165
172
  },
166
173
  [provider, snackError, specificParametersDescriptionForProvider]
167
174
  );
168
- const onValidationError = useCallback((_errors) => {
169
- console.error("onValidationError: ", _errors);
170
- }, []);
175
+ const onValidationError = useCallback(
176
+ (_errors) => {
177
+ console.error("onValidationError: ", _errors);
178
+ const tabsInError = [];
179
+ if ((_errors?.[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] || _errors?.[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]) && ShortCircuitParametersTabValues.POWER_ELECTRONICS !== selectedTab) {
180
+ tabsInError.push(ShortCircuitParametersTabValues.POWER_ELECTRONICS);
181
+ }
182
+ if ((_errors?.[SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER] || _errors?.[SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_OUTSIDE_CALCULATION_CLUSTER] || _errors?.[NODE_CLUSTER_FILTER_IDS]) && ShortCircuitParametersTabValues.STUDY_AREA !== selectedTab) {
183
+ tabsInError.push(ShortCircuitParametersTabValues.STUDY_AREA);
184
+ }
185
+ setTabIndexesWithError(tabsInError);
186
+ },
187
+ [selectedTab]
188
+ );
171
189
  const onSaveInline = useCallback(
172
190
  (formData) => {
173
191
  const data = formatNewParams(formData);
@@ -192,20 +210,22 @@ const useShortCircuitParametersForm = ({
192
210
  [formatNewParams, parametersUuid, snackError]
193
211
  );
194
212
  useEffect(() => {
195
- if (!params || !provider || !specificParamsDescriptions) {
213
+ if (!params || !provider || !specificParamsDescription) {
196
214
  return;
197
215
  }
198
216
  reset(toShortCircuitFormValues(params));
199
217
  setParamsLoaded(true);
200
- }, [provider, params, reset, specificParamsDescriptions, toShortCircuitFormValues]);
218
+ }, [provider, params, reset, specificParamsDescription, toShortCircuitFormValues]);
201
219
  return {
202
220
  formMethods,
203
221
  formSchema,
222
+ selectedTab,
223
+ handleTabChange,
224
+ tabIndexesWithError,
204
225
  specificParametersDescriptionForProvider,
205
226
  toShortCircuitFormValues,
206
227
  formatNewParams,
207
228
  params,
208
- provider,
209
229
  paramsLoaded,
210
230
  onValidationError,
211
231
  onSaveInline,
@@ -1,11 +1,10 @@
1
1
  import { UUID } from 'node:crypto';
2
2
  import { User } from 'oidc-client';
3
3
  import { ComputingType } from '../components/parameters/common/computing-type';
4
- import { ILimitReductionsByVoltageLevel } from '../components/parameters/common/limitreductions/columns-definitions';
5
- import { ParametersInfos, SpecificParametersDescription, UseParametersBackendReturnProps } from '../utils/types/parameters.type';
4
+ import { BackendFunctions, UseParametersBackendReturnProps } from '../utils/types/parameters.type';
6
5
  export declare enum OptionalServicesStatus {
7
6
  Up = "UP",
8
7
  Down = "DOWN",
9
8
  Pending = "PENDING"
10
9
  }
11
- export declare const useParametersBackend: <T extends ComputingType>(user: User | null, studyUuid: UUID | null, type: T, optionalServiceStatus: OptionalServicesStatus | undefined, backendFetchProviders: (() => Promise<string[]>) | null, backendFetchProvider: ((studyUuid: UUID) => Promise<string>) | null, backendFetchDefaultProvider: (() => Promise<string>) | null, backendUpdateProvider: ((studyUuid: UUID, newProvider: string) => Promise<any>) | null, backendFetchParameters: (studyUuid: UUID) => Promise<ParametersInfos<T>>, backendUpdateParameters?: (studyUuid: UUID, newParam: ParametersInfos<T> | null) => Promise<any>, backendFetchSpecificParametersDescription?: () => Promise<SpecificParametersDescription>, backendFetchDefaultLimitReductions?: () => Promise<ILimitReductionsByVoltageLevel[]>) => UseParametersBackendReturnProps<T>;
10
+ export declare const useParametersBackend: <T extends ComputingType>(user: User | null, studyUuid: UUID | null, type: T, optionalServiceStatus: OptionalServicesStatus | undefined, backendFunctions: BackendFunctions<T>) => UseParametersBackendReturnProps<T>;