@gridsuite/commons-ui 0.130.0 → 0.131.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.
@@ -4,4 +4,10 @@
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
- export declare function TuneIcon(): import("react/jsx-runtime").JSX.Element;
7
+ type TuneIconProps = {
8
+ disabled?: boolean;
9
+ size?: number;
10
+ color?: string;
11
+ };
12
+ export declare function TuneIcon({ disabled, size, color }: TuneIconProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -1,15 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import Tune from "@material-symbols/svg-400/outlined/tune.svg?react";
3
3
  import { useTheme } from "@mui/material";
4
- function TuneIcon() {
4
+ function TuneIcon({ disabled = false, size = 14.4, color }) {
5
5
  const theme = useTheme();
6
+ const fillColor = color ?? (disabled ? theme.palette.action.disabled : theme.palette.text.primary);
6
7
  return /* @__PURE__ */ jsx(
7
8
  Tune,
8
9
  {
9
10
  style: {
10
- width: 14.4,
11
- height: 14.4,
12
- fill: theme.palette.text.primary
11
+ width: size,
12
+ height: size,
13
+ fill: fillColor
13
14
  }
14
15
  }
15
16
  );
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useCallback } from "react";
2
+ import { useMemo, useCallback } from "react";
3
3
  import { Grid, Autocomplete, TextField, FormControl, Select, MenuItem } from "@mui/material";
4
4
  import { useIntl } from "react-intl";
5
5
  import { useValid } from "./hooks/useValid.js";
@@ -13,10 +13,7 @@ function PropertyValueEditor(props) {
13
13
  const valid = useValid(valueEditorProps);
14
14
  const intl = useIntl();
15
15
  const { propertyName, propertyOperator, propertyValues } = (valueEditorProps == null ? void 0 : valueEditorProps.value) ?? {};
16
- const [equipmentPredefinedProps, setEquipmentType] = usePredefinedProperties(equipmentType);
17
- useEffect(() => {
18
- setEquipmentType(equipmentType);
19
- }, [equipmentType, setEquipmentType]);
16
+ const [equipmentPredefinedProps] = usePredefinedProperties(equipmentType);
20
17
  const predefinedNames = useMemo(() => {
21
18
  return Object.keys(equipmentPredefinedProps ?? {}).sort();
22
19
  }, [equipmentPredefinedProps]);
@@ -16,7 +16,7 @@ import "../../../utils/yupConfig.js";
16
16
  import "localized-countries";
17
17
  import "localized-countries/data/fr";
18
18
  import "localized-countries/data/en";
19
- import "notistack";
19
+ import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
20
20
  import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
21
21
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
22
22
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
@@ -59,6 +59,7 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
59
59
  const [currentProvider, setCurrentProvider] = useState(params == null ? void 0 : params.provider);
60
60
  const [selectedTab, setSelectedTab] = useState(TabValues.GENERAL);
61
61
  const [tabIndexesWithError, setTabIndexesWithError] = useState([]);
62
+ const { snackError } = useSnackMessage();
62
63
  const handleTabChange = useCallback((event, newValue) => {
63
64
  setSelectedTab(newValue);
64
65
  }, []);
@@ -223,10 +224,15 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
223
224
  formData[NAME],
224
225
  ElementType.LOADFLOW_PARAMETERS,
225
226
  formData[DESCRIPTION] ?? ""
226
- );
227
+ ).catch((errmsg) => {
228
+ snackError({
229
+ messageTxt: errmsg,
230
+ headerId: "updateLoadFlowParametersError"
231
+ });
232
+ });
227
233
  }
228
234
  },
229
- [parametersUuid, formatNewParams]
235
+ [parametersUuid, formatNewParams, snackError]
230
236
  );
231
237
  useEffect(() => {
232
238
  if (!params) {
@@ -14,7 +14,7 @@ import { updateParameter } from "../../../services/explore.js";
14
14
  import "localized-countries";
15
15
  import "localized-countries/data/fr";
16
16
  import "localized-countries/data/en";
17
- import "notistack";
17
+ import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
18
18
  import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
19
19
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
20
20
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
@@ -42,6 +42,7 @@ import { getNameElementEditorEmptyFormData } from "../common/name-element-editor
42
42
  const useSecurityAnalysisParametersForm = (parametersBackend, parametersUuid, name, description) => {
43
43
  const [providers, provider, , , , params, , updateParameters, , , defaultLimitReductions] = parametersBackend;
44
44
  const [currentProvider, setCurrentProvider] = useState(params == null ? void 0 : params.provider);
45
+ const { snackError } = useSnackMessage();
45
46
  const formattedProviders = useMemo(() => {
46
47
  return Object.entries(providers).filter(([key]) => !key.includes("DynaFlow")).map(([key, value]) => ({
47
48
  id: key,
@@ -117,10 +118,15 @@ const useSecurityAnalysisParametersForm = (parametersBackend, parametersUuid, na
117
118
  formData[NAME],
118
119
  ElementType.SECURITY_ANALYSIS_PARAMETERS,
119
120
  formData[DESCRIPTION] ?? ""
120
- );
121
+ ).catch((errmsg) => {
122
+ snackError({
123
+ messageTxt: errmsg,
124
+ headerId: "updateSecurityAnalysisParametersError"
125
+ });
126
+ });
121
127
  }
122
128
  },
123
- [parametersUuid, formatNewParams]
129
+ [parametersUuid, formatNewParams, snackError]
124
130
  );
125
131
  useEffect(() => {
126
132
  if (watchProvider !== currentProvider) {
@@ -53,10 +53,10 @@ const useSensitivityAnalysisParametersForm = ({
53
53
  }) => {
54
54
  const [providers, , , , , params, , updateParameters] = parametersBackend;
55
55
  const [sensitivityAnalysisParams, setSensitivityAnalysisParams] = useState(params);
56
+ const { snackError } = useSnackMessage();
56
57
  const [analysisComputeComplexity, setAnalysisComputeComplexity] = useState(0);
57
58
  const [launchLoader, setLaunchLoader] = useState(false);
58
59
  const [isSubmitAction, setIsSubmitAction] = useState(false);
59
- const { snackError } = useSnackMessage();
60
60
  const emptyFormData = useMemo(() => {
61
61
  return {
62
62
  ...getNameElementEditorEmptyFormData(name, description),
@@ -361,10 +361,15 @@ const useSensitivityAnalysisParametersForm = ({
361
361
  formData[FieldConstants.NAME],
362
362
  ElementType.SENSITIVITY_PARAMETERS,
363
363
  formData[FieldConstants.DESCRIPTION] ?? ""
364
- );
364
+ ).catch((error) => {
365
+ snackError({
366
+ messageTxt: error.message,
367
+ headerId: "updateSensitivityAnalysisParametersError"
368
+ });
369
+ });
365
370
  }
366
371
  },
367
- [parametersUuid, formatNewParams]
372
+ [parametersUuid, formatNewParams, snackError]
368
373
  );
369
374
  useEffect(() => {
370
375
  if (sensitivityAnalysisParams) {
@@ -1,4 +1,2 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
1
  import { PredefinedProperties } from '../utils/types/types';
3
- import { EquipmentType } from '../utils';
4
- export declare const usePredefinedProperties: (initialType: EquipmentType | null) => [PredefinedProperties, Dispatch<SetStateAction<EquipmentType | null>>];
2
+ export declare const usePredefinedProperties: (type: string | null) => [PredefinedProperties];
@@ -16,8 +16,7 @@ const fetchPredefinedProperties = async (equipmentType) => {
16
16
  const studyMetadata = await fetchStudyMetadata();
17
17
  return (_a = studyMetadata.predefinedEquipmentProperties) == null ? void 0 : _a[networkEquipmentType];
18
18
  };
19
- const usePredefinedProperties = (initialType) => {
20
- const [type, setType] = useState(initialType);
19
+ const usePredefinedProperties = (type) => {
21
20
  const [equipmentPredefinedProps, setEquipmentPredefinedProps] = useState({});
22
21
  const { snackError } = useSnackMessage();
23
22
  useEffect(() => {
@@ -33,7 +32,7 @@ const usePredefinedProperties = (initialType) => {
33
32
  });
34
33
  }
35
34
  }, [type, setEquipmentPredefinedProps, snackError]);
36
- return [equipmentPredefinedProps, setType];
35
+ return [equipmentPredefinedProps];
37
36
  };
38
37
  export {
39
38
  usePredefinedProperties
@@ -1,2 +1,7 @@
1
- import { EquipmentType } from '../types';
2
- export declare const equipmentTypesForPredefinedPropertiesMapper: (type: EquipmentType) => string | undefined;
1
+ /**
2
+ * Copyright (c) 2024, 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
+ export declare const equipmentTypesForPredefinedPropertiesMapper: (type: string) => string | undefined;
@@ -25,7 +25,7 @@ const equipmentTypesForPredefinedPropertiesMapper = (type) => {
25
25
  case "VSC_CONVERTER_STATION":
26
26
  return void 0;
27
27
  default:
28
- return void 0;
28
+ return type;
29
29
  }
30
30
  };
31
31
  export {
@@ -173,5 +173,7 @@ export declare enum FieldType {
173
173
  PHASE_TAP_POSITION = "PHASE_TAP_POSITION",
174
174
  PHASE_TARGET_DEADBAND = "PHASE_TARGET_DEADBAND",
175
175
  SELECTED_OPERATIONAL_LIMITS_GROUP_1 = "SELECTED_OPERATIONAL_LIMITS_GROUP_1",
176
- SELECTED_OPERATIONAL_LIMITS_GROUP_2 = "SELECTED_OPERATIONAL_LIMITS_GROUP_2"
176
+ SELECTED_OPERATIONAL_LIMITS_GROUP_2 = "SELECTED_OPERATIONAL_LIMITS_GROUP_2",
177
+ OPERATIONAL_LIMITS_GROUP_1_WITH_PROPERTIES = "OPERATIONAL_LIMITS_GROUP_1_WITH_PROPERTIES",
178
+ OPERATIONAL_LIMITS_GROUP_2_WITH_PROPERTIES = "OPERATIONAL_LIMITS_GROUP_2_WITH_PROPERTIES"
177
179
  }
@@ -168,6 +168,8 @@ var FieldType = /* @__PURE__ */ ((FieldType2) => {
168
168
  FieldType2["PHASE_TARGET_DEADBAND"] = "PHASE_TARGET_DEADBAND";
169
169
  FieldType2["SELECTED_OPERATIONAL_LIMITS_GROUP_1"] = "SELECTED_OPERATIONAL_LIMITS_GROUP_1";
170
170
  FieldType2["SELECTED_OPERATIONAL_LIMITS_GROUP_2"] = "SELECTED_OPERATIONAL_LIMITS_GROUP_2";
171
+ FieldType2["OPERATIONAL_LIMITS_GROUP_1_WITH_PROPERTIES"] = "OPERATIONAL_LIMITS_GROUP_1_WITH_PROPERTIES";
172
+ FieldType2["OPERATIONAL_LIMITS_GROUP_2_WITH_PROPERTIES"] = "OPERATIONAL_LIMITS_GROUP_2_WITH_PROPERTIES";
171
173
  return FieldType2;
172
174
  })(FieldType || {});
173
175
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.130.0",
3
+ "version": "0.131.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",