@gridsuite/commons-ui 0.131.0 → 0.132.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 (38) hide show
  1. package/dist/components/customAGGrid/separatorCellRenderer.d.ts +2 -11
  2. package/dist/components/customAGGrid/separatorCellRenderer.js +7 -2
  3. package/dist/components/dnd-table/dnd-table.js +3 -3
  4. package/dist/components/index.js +2 -0
  5. package/dist/components/inputs/index.js +2 -0
  6. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.d.ts +2 -2
  7. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +4 -2
  8. package/dist/components/inputs/reactHookForm/agGridTable/CustomAgGridTable.js +4 -0
  9. package/dist/components/inputs/reactHookForm/index.js +2 -0
  10. package/dist/components/inputs/reactHookForm/utils/RefreshButton.d.ts +2 -0
  11. package/dist/components/inputs/reactHookForm/utils/RefreshButton.js +9 -0
  12. package/dist/components/inputs/reactHookForm/utils/index.d.ts +1 -0
  13. package/dist/components/inputs/reactHookForm/utils/index.js +2 -0
  14. package/dist/components/parameters/short-circuit/short-circuit-fields.d.ts +2 -1
  15. package/dist/components/parameters/short-circuit/short-circuit-fields.js +20 -5
  16. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.d.ts +1 -1
  17. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +4 -2
  18. package/dist/components/parameters/short-circuit/short-circuit-parameters-form.d.ts +2 -1
  19. package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +3 -2
  20. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.d.ts +2 -1
  21. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +3 -1
  22. package/dist/index.js +11 -2
  23. package/dist/services/index.js +3 -1
  24. package/dist/services/utils.d.ts +14 -3
  25. package/dist/services/utils.js +33 -6
  26. package/dist/translations/en/errorsEn.d.ts +9 -0
  27. package/dist/translations/en/errorsEn.js +6 -0
  28. package/dist/translations/en/index.d.ts +1 -0
  29. package/dist/translations/en/index.js +2 -0
  30. package/dist/translations/fr/errorsFr.d.ts +9 -0
  31. package/dist/translations/fr/errorsFr.js +6 -0
  32. package/dist/translations/fr/index.d.ts +1 -0
  33. package/dist/translations/fr/index.js +2 -0
  34. package/dist/utils/index.js +2 -1
  35. package/dist/utils/types/index.js +2 -1
  36. package/dist/utils/types/types.d.ts +4 -0
  37. package/dist/utils/types/types.js +7 -1
  38. package/package.json +1 -1
@@ -1,11 +1,2 @@
1
- /**
2
- * Copyright (c) 2025, 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
- type SeparatorCellRendererProps = {
8
- value: string;
9
- };
10
- export declare function SeparatorCellRenderer({ value }: Readonly<SeparatorCellRendererProps>): import("react/jsx-runtime").JSX.Element;
11
- export {};
1
+ import { TypographyProps } from '@mui/material';
2
+ export declare function SeparatorCellRenderer({ children, sx, ...otherProps }: Readonly<TypographyProps>): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Typography } from "@mui/material";
3
+ import "../../utils/conversionUtils.js";
4
+ import "@mui/icons-material";
5
+ import { mergeSx } from "../../utils/styles.js";
6
+ import "../../utils/types/equipmentType.js";
7
+ import "../../utils/yupConfig.js";
3
8
  const styles = {
4
9
  separator: (theme) => ({
5
10
  fontWeight: "bold",
@@ -8,8 +13,8 @@ const styles = {
8
13
  marginTop: theme.spacing(1)
9
14
  })
10
15
  };
11
- function SeparatorCellRenderer({ value }) {
12
- return /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", color: "primary", sx: styles.separator, children: value });
16
+ function SeparatorCellRenderer({ children, sx, ...otherProps }) {
17
+ return /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", color: "primary", sx: mergeSx(styles.separator, sx), ...otherProps, children });
13
18
  }
14
19
  export {
15
20
  SeparatorCellRenderer
@@ -14,12 +14,12 @@ import { DirectoryItemsInput } from "../inputs/reactHookForm/DirectoryItemsInput
14
14
  import { RawReadOnlyInput } from "../inputs/reactHookForm/RawReadOnlyInput.js";
15
15
  import "../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
16
16
  import "../customAGGrid/customAggrid.js";
17
- import "ag-grid-community";
18
- import "react-papaparse";
19
- import "react-csv-downloader";
20
17
  import "../../utils/conversionUtils.js";
21
18
  import "../../utils/types/equipmentType.js";
22
19
  import "../../utils/yupConfig.js";
20
+ import "ag-grid-community";
21
+ import "react-papaparse";
22
+ import "react-csv-downloader";
23
23
  import "yup";
24
24
  import { AutocompleteInput } from "../inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
25
25
  import { CheckboxInput } from "../inputs/reactHookForm/booleans/CheckboxInput.js";
@@ -92,6 +92,7 @@ import { UniqueNameInput } from "./inputs/reactHookForm/text/UniqueNameInput.js"
92
92
  import { CancelButton } from "./inputs/reactHookForm/utils/CancelButton.js";
93
93
  import { FieldLabel } from "./inputs/reactHookForm/utils/FieldLabel.js";
94
94
  import { SubmitButton } from "./inputs/reactHookForm/utils/SubmitButton.js";
95
+ import { RefreshButton } from "./inputs/reactHookForm/utils/RefreshButton.js";
95
96
  import { TextFieldWithAdornment } from "./inputs/reactHookForm/utils/TextFieldWithAdornment.js";
96
97
  import { genHelperError, gridItem, identity, isFieldRequired, toFloatOrNullValue } from "./inputs/reactHookForm/utils/functions.js";
97
98
  import { HelperPreviousValue } from "./inputs/reactHookForm/utils/HelperPreviousValue.js";
@@ -396,6 +397,7 @@ export {
396
397
  RangeType,
397
398
  RawReadOnlyInput,
398
399
  ReactivePowerAdornment,
400
+ RefreshButton,
399
401
  RemoveButton,
400
402
  RuleValueEditor,
401
403
  SELECTED,
@@ -35,6 +35,7 @@ import { UniqueNameInput } from "./reactHookForm/text/UniqueNameInput.js";
35
35
  import { CancelButton } from "./reactHookForm/utils/CancelButton.js";
36
36
  import { FieldLabel } from "./reactHookForm/utils/FieldLabel.js";
37
37
  import { SubmitButton } from "./reactHookForm/utils/SubmitButton.js";
38
+ import { RefreshButton } from "./reactHookForm/utils/RefreshButton.js";
38
39
  import { TextFieldWithAdornment } from "./reactHookForm/utils/TextFieldWithAdornment.js";
39
40
  import { genHelperError, gridItem, identity, isFieldRequired, toFloatOrNullValue } from "./reactHookForm/utils/functions.js";
40
41
  import { HelperPreviousValue } from "./reactHookForm/utils/HelperPreviousValue.js";
@@ -98,6 +99,7 @@ export {
98
99
  RangeInput,
99
100
  RangeType,
100
101
  RawReadOnlyInput,
102
+ RefreshButton,
101
103
  RemoveButton,
102
104
  RuleValueEditor,
103
105
  SelectClearable,
@@ -1,4 +1,4 @@
1
- import { ElementAttributes } from '../../../utils';
1
+ import { ArrayAction, ElementAttributes } from '../../../utils';
2
2
  export interface DirectoryItemsInputProps {
3
3
  label: string | undefined;
4
4
  name: string;
@@ -8,7 +8,7 @@ export interface DirectoryItemsInputProps {
8
8
  titleId?: string;
9
9
  hideErrorMessage?: boolean;
10
10
  onRowChanged?: (a: boolean) => void;
11
- onChange?: (e: any) => void;
11
+ onChange?: (e: any, action?: ArrayAction, element?: any) => void;
12
12
  disable?: boolean;
13
13
  allowMultiSelect?: boolean;
14
14
  labelRequiredFromContext?: boolean;
@@ -21,6 +21,7 @@ import { OverflowableText } from "../../overflowableText/OverflowableText.js";
21
21
  import { DirectoryItemSelector } from "../../directoryItemSelector/DirectoryItemSelector.js";
22
22
  import "../../../utils/conversionUtils.js";
23
23
  import { mergeSx } from "../../../utils/styles.js";
24
+ import { ArrayAction } from "../../../utils/types/types.js";
24
25
  import "../../../utils/yupConfig.js";
25
26
  import { NAME } from "./constants.js";
26
27
  import { getFilterEquipmentTypeLabel } from "../../filter/expert/expertFilterUtils.js";
@@ -111,7 +112,7 @@ function DirectoryItemsInput({
111
112
  } else {
112
113
  append(otherElementAttributes);
113
114
  onRowChanged == null ? void 0 : onRowChanged(true);
114
- onChange == null ? void 0 : onChange(getValues(name));
115
+ onChange == null ? void 0 : onChange(getValues(name), ArrayAction.ADD, otherElementAttributes);
115
116
  }
116
117
  });
117
118
  setDirectoryItemSelectorOpen(false);
@@ -121,9 +122,10 @@ function DirectoryItemsInput({
121
122
  );
122
123
  const removeElements = useCallback(
123
124
  (index) => {
125
+ const currentValues = getValues(name);
124
126
  remove(index);
125
127
  onRowChanged == null ? void 0 : onRowChanged(true);
126
- onChange == null ? void 0 : onChange(getValues(name));
128
+ onChange == null ? void 0 : onChange(currentValues, ArrayAction.REMOVE, currentValues[index]);
127
129
  },
128
130
  [onRowChanged, remove, getValues, name, onChange]
129
131
  );
@@ -5,6 +5,10 @@ import { useTheme, Box } from "@mui/material";
5
5
  import { BottomRightButtons } from "./BottomRightButtons.js";
6
6
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
7
7
  import { CustomAGGrid } from "../../../customAGGrid/customAggrid.js";
8
+ import "../../../../utils/conversionUtils.js";
9
+ import "@mui/icons-material";
10
+ import "../../../../utils/types/equipmentType.js";
11
+ import "../../../../utils/yupConfig.js";
8
12
  const style = (customProps) => ({
9
13
  grid: (theme) => ({
10
14
  width: "auto",
@@ -34,6 +34,7 @@ import { UniqueNameInput } from "./text/UniqueNameInput.js";
34
34
  import { CancelButton } from "./utils/CancelButton.js";
35
35
  import { FieldLabel } from "./utils/FieldLabel.js";
36
36
  import { SubmitButton } from "./utils/SubmitButton.js";
37
+ import { RefreshButton } from "./utils/RefreshButton.js";
37
38
  import { TextFieldWithAdornment } from "./utils/TextFieldWithAdornment.js";
38
39
  import { genHelperError, gridItem, identity, isFieldRequired, toFloatOrNullValue } from "./utils/functions.js";
39
40
  import { HelperPreviousValue } from "./utils/HelperPreviousValue.js";
@@ -71,6 +72,7 @@ export {
71
72
  RangeInput,
72
73
  RangeType,
73
74
  RawReadOnlyInput,
75
+ RefreshButton,
74
76
  SelectInput,
75
77
  SliderInput,
76
78
  SubmitButton,
@@ -0,0 +1,2 @@
1
+ import { ButtonProps } from '@mui/material';
2
+ export declare function RefreshButton(buttonProps: Readonly<ButtonProps>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IconButton } from "@mui/material";
3
+ import { Refresh } from "@mui/icons-material";
4
+ function RefreshButton(buttonProps) {
5
+ return /* @__PURE__ */ jsx(IconButton, { ...buttonProps, children: /* @__PURE__ */ jsx(Refresh, { fontSize: "large" }) });
6
+ }
7
+ export {
8
+ RefreshButton
9
+ };
@@ -7,6 +7,7 @@
7
7
  export * from './CancelButton';
8
8
  export * from './FieldLabel';
9
9
  export * from './SubmitButton';
10
+ export * from './RefreshButton';
10
11
  export * from './TextFieldWithAdornment';
11
12
  export * from './functions';
12
13
  export * from './HelperPreviousValue';
@@ -1,6 +1,7 @@
1
1
  import { CancelButton } from "./CancelButton.js";
2
2
  import { FieldLabel } from "./FieldLabel.js";
3
3
  import { SubmitButton } from "./SubmitButton.js";
4
+ import { RefreshButton } from "./RefreshButton.js";
4
5
  import { TextFieldWithAdornment } from "./TextFieldWithAdornment.js";
5
6
  import { genHelperError, gridItem, identity, isFieldRequired, toFloatOrNullValue } from "./functions.js";
6
7
  import { HelperPreviousValue } from "./HelperPreviousValue.js";
@@ -8,6 +9,7 @@ export {
8
9
  CancelButton,
9
10
  FieldLabel,
10
11
  HelperPreviousValue,
12
+ RefreshButton,
11
13
  SubmitButton,
12
14
  TextFieldWithAdornment,
13
15
  genHelperError,
@@ -1,9 +1,10 @@
1
1
  import { PredefinedParameters } from './constants';
2
2
  export interface ShortCircuitFieldsProps {
3
3
  resetAll: (predefinedParams: PredefinedParameters) => void;
4
+ enableDeveloperMode: boolean;
4
5
  }
5
6
  export declare enum Status {
6
7
  SUCCESS = "SUCCESS",
7
8
  ERROR = "ERROR"
8
9
  }
9
- export declare function ShortCircuitFields({ resetAll }: Readonly<ShortCircuitFieldsProps>): import("react/jsx-runtime").JSX.Element;
10
+ export declare function ShortCircuitFields({ resetAll, enableDeveloperMode }: Readonly<ShortCircuitFieldsProps>): import("react/jsx-runtime").JSX.Element;
@@ -3,8 +3,8 @@ import { useState, useMemo, useEffect } from "react";
3
3
  import { Grid } from "@mui/material";
4
4
  import { green, red } from "@mui/material/colors";
5
5
  import { Lens } from "@mui/icons-material";
6
- import { useWatch } from "react-hook-form";
7
- import { SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, SHORT_CIRCUIT_PREDEFINED_PARAMS, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, intlPredefinedParametersOptions, intlInitialVoltageProfileMode, PredefinedParameters, InitialVoltage, SHORT_CIRCUIT_WITH_FEEDER_RESULT } from "./constants.js";
6
+ import { useWatch, useFormContext } from "react-hook-form";
7
+ import { SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, SHORT_CIRCUIT_PREDEFINED_PARAMS, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, intlPredefinedParametersOptions, PredefinedParameters, intlInitialVoltageProfileMode, InitialVoltage, SHORT_CIRCUIT_WITH_FEEDER_RESULT } from "./constants.js";
8
8
  import { VoltageTable } from "./short-circuit-voltage-table.js";
9
9
  import GridItem from "../../grid/grid-item.js";
10
10
  import GridSection from "../../grid/grid-section.js";
@@ -42,7 +42,7 @@ var Status = /* @__PURE__ */ ((Status2) => {
42
42
  Status2["ERROR"] = "ERROR";
43
43
  return Status2;
44
44
  })(Status || {});
45
- function ShortCircuitFields({ resetAll }) {
45
+ function ShortCircuitFields({ resetAll, enableDeveloperMode = true }) {
46
46
  const [status, setStatus] = useState(
47
47
  "SUCCESS"
48
48
  /* SUCCESS */
@@ -72,8 +72,12 @@ function ShortCircuitFields({ resetAll }) {
72
72
  return !watchLoads && !watchShuntCompensators && watchVSC && !watchNeutralPosition;
73
73
  }, [watchLoads, watchShuntCompensators, watchVSC, watchNeutralPosition]);
74
74
  const predefinedParamsOptions = useMemo(() => {
75
- return intlPredefinedParametersOptions();
76
- }, []);
75
+ const options = intlPredefinedParametersOptions();
76
+ if (!enableDeveloperMode) {
77
+ return options.filter((opt) => opt.id !== PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP);
78
+ }
79
+ return options;
80
+ }, [enableDeveloperMode]);
77
81
  const initialVoltageProfileMode = useMemo(() => {
78
82
  return intlInitialVoltageProfileMode();
79
83
  }, []);
@@ -87,6 +91,17 @@ function ShortCircuitFields({ resetAll }) {
87
91
  console.debug("onPredefinedParametersManualChange new:", newPredefinedParameters);
88
92
  resetAll(newPredefinedParameters);
89
93
  };
94
+ const { setValue } = useFormContext();
95
+ useEffect(() => {
96
+ if (!enableDeveloperMode) {
97
+ if (watchPredefinedParams === PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP) {
98
+ setValue(SHORT_CIRCUIT_PREDEFINED_PARAMS, PredefinedParameters.ICC_MAX_WITH_NOMINAL_VOLTAGE_MAP, {
99
+ shouldDirty: false,
100
+ shouldValidate: true
101
+ });
102
+ }
103
+ }
104
+ }, [enableDeveloperMode, watchPredefinedParams, setValue]);
90
105
  const feederResult = /* @__PURE__ */ jsxs(Grid, { container: true, alignItems: "center", spacing: 2, direction: "row", children: [
91
106
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 10, children: /* @__PURE__ */ jsx(FieldLabel, { label: "descWithFeederResult" }) }),
92
107
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 2, children: /* @__PURE__ */ jsx(SwitchInput, { name: SHORT_CIRCUIT_WITH_FEEDER_RESULT }) })
@@ -1,2 +1,2 @@
1
1
  import { ParametersEditionDialogProps } from '../common';
2
- export declare function ShortCircuitParametersEditionDialog({ id, open, onClose, titleId, name, description, activeDirectory, language, }: Readonly<ParametersEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ShortCircuitParametersEditionDialog({ id, open, onClose, titleId, name, description, activeDirectory, language, enableDeveloperMode, }: Readonly<ParametersEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
@@ -42,7 +42,8 @@ function ShortCircuitParametersEditionDialog({
42
42
  name,
43
43
  description,
44
44
  activeDirectory,
45
- language
45
+ language,
46
+ enableDeveloperMode
46
47
  }) {
47
48
  const shortCircuitMethods = useShortCircuitParametersForm({
48
49
  parametersUuid: id,
@@ -80,7 +81,8 @@ function ShortCircuitParametersEditionDialog({
80
81
  elementType: ElementType.SHORT_CIRCUIT_PARAMETERS
81
82
  }
82
83
  );
83
- }
84
+ },
85
+ enableDeveloperMode: enableDeveloperMode ?? false
84
86
  }
85
87
  )
86
88
  }
@@ -4,6 +4,7 @@ interface ShortCircuitParametersFormProps {
4
4
  shortCircuitMethods: UseShortCircuitParametersFormReturn;
5
5
  renderTitleFields?: () => ReactNode;
6
6
  renderActions?: () => ReactNode;
7
+ enableDeveloperMode: boolean;
7
8
  }
8
- export declare function ShortCircuitParametersForm({ shortCircuitMethods, renderTitleFields, renderActions, }: Readonly<ShortCircuitParametersFormProps>): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ShortCircuitParametersForm({ shortCircuitMethods, renderTitleFields, renderActions, enableDeveloperMode, }: Readonly<ShortCircuitParametersFormProps>): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -32,7 +32,8 @@ import { ShortCircuitFields } from "./short-circuit-fields.js";
32
32
  function ShortCircuitParametersForm({
33
33
  shortCircuitMethods,
34
34
  renderTitleFields,
35
- renderActions
35
+ renderActions,
36
+ enableDeveloperMode
36
37
  }) {
37
38
  const { formMethods, formSchema, paramsLoading, resetAll } = shortCircuitMethods;
38
39
  return /* @__PURE__ */ jsx(CustomFormProvider, { validationSchema: formSchema, ...formMethods, removeOptional: true, children: /* @__PURE__ */ jsxs(
@@ -46,7 +47,7 @@ function ShortCircuitParametersForm({
46
47
  },
47
48
  children: [
48
49
  /* @__PURE__ */ jsx(Grid, { item: true, container: true, direction: "column", children: renderTitleFields == null ? void 0 : renderTitleFields() }),
49
- paramsLoading ? /* @__PURE__ */ jsx(LinearProgress, {}) : /* @__PURE__ */ jsx(Grid, { sx: parametersStyles.scrollableGrid, children: /* @__PURE__ */ jsx(ShortCircuitFields, { resetAll }) }),
50
+ paramsLoading ? /* @__PURE__ */ jsx(LinearProgress, {}) : /* @__PURE__ */ jsx(Grid, { sx: parametersStyles.scrollableGrid, children: /* @__PURE__ */ jsx(ShortCircuitFields, { enableDeveloperMode, resetAll }) }),
50
51
  /* @__PURE__ */ jsx(
51
52
  Grid,
52
53
  {
@@ -1,7 +1,8 @@
1
1
  import { UUID } from 'node:crypto';
2
2
  import { ShortCircuitParametersInfos } from './short-circuit-parameters.type';
3
- export declare function ShortCircuitParametersInLine({ studyUuid, setHaveDirtyFields, shortCircuitParameters, }: Readonly<{
3
+ export declare function ShortCircuitParametersInLine({ studyUuid, setHaveDirtyFields, shortCircuitParameters, enableDeveloperMode, }: Readonly<{
4
4
  studyUuid: UUID | null;
5
5
  setHaveDirtyFields: (isDirty: boolean) => void;
6
6
  shortCircuitParameters: ShortCircuitParametersInfos | null;
7
+ enableDeveloperMode: boolean;
7
8
  }>): import("react/jsx-runtime").JSX.Element;
@@ -40,7 +40,8 @@ import { useShortCircuitParametersForm } from "./use-short-circuit-parameters-fo
40
40
  function ShortCircuitParametersInLine({
41
41
  studyUuid,
42
42
  setHaveDirtyFields,
43
- shortCircuitParameters
43
+ shortCircuitParameters,
44
+ enableDeveloperMode
44
45
  }) {
45
46
  const shortCircuitMethods = useShortCircuitParametersForm({
46
47
  parametersUuid: null,
@@ -98,6 +99,7 @@ function ShortCircuitParametersInLine({
98
99
  ShortCircuitParametersForm,
99
100
  {
100
101
  shortCircuitMethods,
102
+ enableDeveloperMode,
101
103
  renderActions: () => {
102
104
  return /* @__PURE__ */ jsxs(Box, { children: [
103
105
  /* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
package/dist/index.js CHANGED
@@ -93,6 +93,7 @@ import { UniqueNameInput } from "./components/inputs/reactHookForm/text/UniqueNa
93
93
  import { CancelButton } from "./components/inputs/reactHookForm/utils/CancelButton.js";
94
94
  import { FieldLabel } from "./components/inputs/reactHookForm/utils/FieldLabel.js";
95
95
  import { SubmitButton } from "./components/inputs/reactHookForm/utils/SubmitButton.js";
96
+ import { RefreshButton } from "./components/inputs/reactHookForm/utils/RefreshButton.js";
96
97
  import { TextFieldWithAdornment } from "./components/inputs/reactHookForm/utils/TextFieldWithAdornment.js";
97
98
  import { genHelperError, gridItem, identity, isFieldRequired, toFloatOrNullValue } from "./components/inputs/reactHookForm/utils/functions.js";
98
99
  import { HelperPreviousValue } from "./components/inputs/reactHookForm/utils/HelperPreviousValue.js";
@@ -188,7 +189,7 @@ import { OptionalServicesStatus, useParametersBackend } from "./hooks/use-parame
188
189
  import { useCreateRowDataSensi } from "./hooks/use-create-row-data-sensi.js";
189
190
  import { LOGOUT_ERROR, RESET_AUTHENTICATION_ROUTER_ERROR, SHOW_AUTH_INFO_LOGIN, SIGNIN_CALLBACK_ERROR, UNAUTHORIZED_USER_INFO, USER, USER_VALIDATION_ERROR, resetAuthenticationRouterError, setLoggedUser, setLogoutError, setShowAuthenticationRouterLogin, setSignInCallbackError, setUnauthorizedUserInfo, setUserValidationError } from "./redux/actions/authActions.js";
190
191
  import { getUserToken, setCommonStore } from "./redux/commonStore.js";
191
- import { backendFetch, backendFetchJson, backendFetchText, catchErrorHandler, getRequestParamFromList } from "./services/utils.js";
192
+ import { NetworkTimeoutError, backendFetch, backendFetchFile, backendFetchJson, backendFetchText, catchErrorHandler, getRequestParamFromList } from "./services/utils.js";
192
193
  import { createFilter, createParameter, fetchElementsInfos, saveFilter, updateParameter } from "./services/explore.js";
193
194
  import { fetchAppsMetadata, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./services/appsMetadata.js";
194
195
  import { elementAlreadyExists, fetchConfigParameter, fetchConfigParameters, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders, getAppName, updateConfigParameter } from "./services/directory.js";
@@ -214,7 +215,7 @@ import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSel
214
215
  import { ElementType } from "./utils/types/elementType.js";
215
216
  import { BASE_EQUIPMENTS, EQUIPMENT_TYPE, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./utils/types/equipmentType.js";
216
217
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./utils/types/equipmentTypes.js";
217
- import { AnnouncementSeverity } from "./utils/types/types.js";
218
+ import { AnnouncementSeverity, ArrayAction } from "./utils/types/types.js";
218
219
  import { MODIFICATION_TYPES, ModificationType } from "./utils/types/modificationType.js";
219
220
  import { FieldType } from "./utils/types/fieldType.js";
220
221
  import { ParameterType } from "./utils/types/parameters.type.js";
@@ -231,6 +232,7 @@ import { dndTableEn } from "./translations/en/dndTableEn.js";
231
232
  import { elementSearchEn } from "./translations/en/elementSearchEn.js";
232
233
  import { equipmentSearchEn } from "./translations/en/equipmentSearchEn.js";
233
234
  import { equipmentsEn } from "./translations/en/equipmentsEn.js";
235
+ import { errorsEn } from "./translations/en/errorsEn.js";
234
236
  import { filterEn } from "./translations/en/filterEn.js";
235
237
  import { filterExpertEn } from "./translations/en/filterExpertEn.js";
236
238
  import { flatParametersEn } from "./translations/en/flatParametersEn.js";
@@ -256,6 +258,7 @@ import { dndTableFr } from "./translations/fr/dndTableFr.js";
256
258
  import { elementSearchFr } from "./translations/fr/elementSearchFr.js";
257
259
  import { equipmentSearchFr } from "./translations/fr/equipmentSearchFr.js";
258
260
  import { equipmentsFr } from "./translations/fr/equipmentsFr.js";
261
+ import { errorsFr } from "./translations/fr/errorsFr.js";
259
262
  import { filterExpertFr } from "./translations/fr/filterExpertFr.js";
260
263
  import { filterFr } from "./translations/fr/filterFr.js";
261
264
  import { flatParametersFr } from "./translations/fr/flatParametersFr.js";
@@ -281,6 +284,7 @@ export {
281
284
  AnnouncementBanner,
282
285
  AnnouncementNotification,
283
286
  AnnouncementSeverity,
287
+ ArrayAction,
284
288
  ArrowsOutputIcon,
285
289
  AuthenticationRouter,
286
290
  default3 as AuthenticationRouterErrorDisplay,
@@ -485,6 +489,7 @@ export {
485
489
  NAME,
486
490
  NO_ITEM_SELECTION_FOR_COPY,
487
491
  NadPositionsGenerationMode,
492
+ NetworkTimeoutError,
488
493
  NetworkVisualizationParametersInline,
489
494
  NetworkVisualizationTabValues,
490
495
  NetworkVisualizationsParametersEditionDialog,
@@ -553,6 +558,7 @@ export {
553
558
  RangeType,
554
559
  RawReadOnlyInput,
555
560
  ReactivePowerAdornment,
561
+ RefreshButton,
556
562
  RemoveButton,
557
563
  RuleValueEditor,
558
564
  SEARCH_EQUIPMENTS,
@@ -654,6 +660,7 @@ export {
654
660
  alertThresholdMarks,
655
661
  areArrayElementsUnique,
656
662
  backendFetch,
663
+ backendFetchFile,
657
664
  backendFetchJson,
658
665
  backendFetchText,
659
666
  cardErrorBoundaryEn,
@@ -687,6 +694,8 @@ export {
687
694
  equipmentTypesForPredefinedPropertiesMapper,
688
695
  equipmentsEn,
689
696
  equipmentsFr,
697
+ errorsEn,
698
+ errorsFr,
690
699
  expertFilterSchema,
691
700
  explicitNamingFilterSchema,
692
701
  exportExpertRules,
@@ -1,4 +1,4 @@
1
- import { backendFetch, backendFetchJson, backendFetchText, catchErrorHandler, getRequestParamFromList } from "./utils.js";
1
+ import { NetworkTimeoutError, backendFetch, backendFetchFile, backendFetchJson, backendFetchText, catchErrorHandler, getRequestParamFromList } from "./utils.js";
2
2
  import { createFilter, createParameter, fetchElementsInfos, saveFilter, updateParameter } from "./explore.js";
3
3
  import { fetchAppsMetadata, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./appsMetadata.js";
4
4
  import { elementAlreadyExists, fetchConfigParameter, fetchConfigParameters, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders, getAppName, updateConfigParameter } from "./directory.js";
@@ -9,8 +9,10 @@ import { fetchCurrentAnnouncement, fetchUserDetails } from "./userAdmin.js";
9
9
  import { getVoltageInitParameters, getVoltageInitUrl } from "./voltage-init.js";
10
10
  import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters, fetchSecurityAnalysisProviders, getSecurityAnalysisDefaultLimitReductions, getSecurityAnalysisParameters, getStudyUrl, safeEncodeURIComponent, setSecurityAnalysisParameters, updateSecurityAnalysisParameters, updateSecurityAnalysisProvider } from "./security-analysis.js";
11
11
  export {
12
+ NetworkTimeoutError,
12
13
  PREFIX_STUDY_QUERIES,
13
14
  backendFetch,
15
+ backendFetchFile,
14
16
  backendFetchJson,
15
17
  backendFetchText,
16
18
  catchErrorHandler,
@@ -4,8 +4,19 @@
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 const backendFetch: (url: string, init: RequestInit, token?: string) => Promise<Response>;
8
- export declare const backendFetchJson: (url: string, init?: RequestInit, token?: string) => Promise<any>;
9
- export declare function backendFetchText(url: string, init?: RequestInit, token?: string): Promise<string>;
7
+ /** Optional convenience: allow per-call timeout override without crafting a signal manually. */
8
+ type FetchInitWithTimeout = RequestInit & {
9
+ /** If provided and no signal is set, use this as the timeout override (ms). */
10
+ timeoutMs?: number;
11
+ };
12
+ /** Custom error type thrown when AbortSignal.timeout triggers. */
13
+ export declare class NetworkTimeoutError extends Error {
14
+ constructor(messageKey?: string);
15
+ }
16
+ export declare const backendFetch: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<Response>;
17
+ export declare const backendFetchJson: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<any>;
18
+ export declare function backendFetchText(url: string, init?: FetchInitWithTimeout, token?: string): Promise<string>;
19
+ export declare const backendFetchFile: (url: string, init: RequestInit, token?: string) => Promise<Blob>;
10
20
  export declare const getRequestParamFromList: (paramName: string, params?: string[]) => URLSearchParams;
11
21
  export declare const catchErrorHandler: (error: unknown, callback: (message: string) => void) => void;
22
+ export {};
@@ -1,20 +1,35 @@
1
1
  import { getUserToken } from "../redux/commonStore.js";
2
+ const DEFAULT_TIMEOUT_MS = 5e4;
3
+ class NetworkTimeoutError extends Error {
4
+ constructor(messageKey = "errors.network.timeout") {
5
+ super(messageKey);
6
+ this.name = "NetworkTimeoutError";
7
+ }
8
+ }
2
9
  const parseError = (text) => {
3
10
  try {
4
11
  return JSON.parse(text);
5
- } catch (err) {
12
+ } catch {
6
13
  return null;
7
14
  }
8
15
  };
16
+ const ensureSignal = (init) => {
17
+ if (init == null ? void 0 : init.signal) return init;
18
+ const timeoutMs = typeof (init == null ? void 0 : init.timeoutMs) === "number" ? init.timeoutMs : DEFAULT_TIMEOUT_MS;
19
+ return {
20
+ ...init,
21
+ signal: AbortSignal.timeout(timeoutMs)
22
+ };
23
+ };
9
24
  const prepareRequest = (init, token) => {
10
25
  if (!(typeof init === "undefined" || typeof init === "object")) {
11
26
  throw new TypeError(`First argument of prepareRequest is not an object : ${typeof init}`);
12
27
  }
13
- const initCopy = { ...init };
14
- initCopy.headers = new Headers(initCopy.headers || {});
28
+ const initWithSignal = ensureSignal(init);
29
+ initWithSignal.headers = new Headers(initWithSignal.headers || {});
15
30
  const tokenCopy = token ?? getUserToken();
16
- initCopy.headers.append("Authorization", `Bearer ${tokenCopy}`);
17
- return initCopy;
31
+ initWithSignal.headers.append("Authorization", `Bearer ${tokenCopy}`);
32
+ return initWithSignal;
18
33
  };
19
34
  const handleError = (response) => {
20
35
  return response.text().then((text) => {
@@ -33,8 +48,14 @@ const handleError = (response) => {
33
48
  throw customError;
34
49
  });
35
50
  };
51
+ const handleTimeoutError = (error) => {
52
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
53
+ throw new NetworkTimeoutError();
54
+ }
55
+ throw error;
56
+ };
36
57
  const safeFetch = (url, initCopy) => {
37
- return fetch(url, initCopy).then((response) => response.ok ? response : handleError(response));
58
+ return fetch(url, initCopy).then((response) => response.ok ? response : handleError(response)).catch(handleTimeoutError);
38
59
  };
39
60
  const backendFetch = (url, init, token) => {
40
61
  const initCopy = prepareRequest(init, token);
@@ -48,6 +69,10 @@ function backendFetchText(url, init, token) {
48
69
  const initCopy = prepareRequest(init, token);
49
70
  return safeFetch(url, initCopy).then((safeResponse) => safeResponse.text());
50
71
  }
72
+ const backendFetchFile = (url, init, token) => {
73
+ const initCopy = prepareRequest(init, token);
74
+ return safeFetch(url, initCopy).then((safeResponse) => safeResponse.blob());
75
+ };
51
76
  const getRequestParamFromList = (paramName, params = []) => {
52
77
  return new URLSearchParams(params.map((param) => [paramName, param]));
53
78
  };
@@ -59,7 +84,9 @@ const catchErrorHandler = (error, callback) => {
59
84
  }
60
85
  };
61
86
  export {
87
+ NetworkTimeoutError,
62
88
  backendFetch,
89
+ backendFetchFile,
63
90
  backendFetchJson,
64
91
  backendFetchText,
65
92
  catchErrorHandler,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2025, 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 errorsEn: {
8
+ 'errors.network.timeout': string;
9
+ };
@@ -0,0 +1,6 @@
1
+ const errorsEn = {
2
+ "errors.network.timeout": "The request timed out. Please try again."
3
+ };
4
+ export {
5
+ errorsEn
6
+ };
@@ -13,6 +13,7 @@ export * from './dndTableEn';
13
13
  export * from './elementSearchEn';
14
14
  export * from './equipmentSearchEn';
15
15
  export * from './equipmentsEn';
16
+ export * from './errorsEn';
16
17
  export * from './filterEn';
17
18
  export * from './filterExpertEn';
18
19
  export * from './flatParametersEn';
@@ -7,6 +7,7 @@ import { dndTableEn } from "./dndTableEn.js";
7
7
  import { elementSearchEn } from "./elementSearchEn.js";
8
8
  import { equipmentSearchEn } from "./equipmentSearchEn.js";
9
9
  import { equipmentsEn } from "./equipmentsEn.js";
10
+ import { errorsEn } from "./errorsEn.js";
10
11
  import { filterEn } from "./filterEn.js";
11
12
  import { filterExpertEn } from "./filterExpertEn.js";
12
13
  import { flatParametersEn } from "./flatParametersEn.js";
@@ -34,6 +35,7 @@ export {
34
35
  elementSearchEn,
35
36
  equipmentSearchEn,
36
37
  equipmentsEn,
38
+ errorsEn,
37
39
  exportParamsEn,
38
40
  filterEn,
39
41
  filterExpertEn,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2025, 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 errorsFr: {
8
+ 'errors.network.timeout': string;
9
+ };
@@ -0,0 +1,6 @@
1
+ const errorsFr = {
2
+ "errors.network.timeout": "La requête a expiré. Veuillez réessayer."
3
+ };
4
+ export {
5
+ errorsFr
6
+ };
@@ -13,6 +13,7 @@ export * from './dndTableFr';
13
13
  export * from './elementSearchFr';
14
14
  export * from './equipmentSearchFr';
15
15
  export * from './equipmentsFr';
16
+ export * from './errorsFr';
16
17
  export * from './filterExpertFr';
17
18
  export * from './filterFr';
18
19
  export * from './flatParametersFr';
@@ -7,6 +7,7 @@ import { dndTableFr } from "./dndTableFr.js";
7
7
  import { elementSearchFr } from "./elementSearchFr.js";
8
8
  import { equipmentSearchFr } from "./equipmentSearchFr.js";
9
9
  import { equipmentsFr } from "./equipmentsFr.js";
10
+ import { errorsFr } from "./errorsFr.js";
10
11
  import { filterExpertFr } from "./filterExpertFr.js";
11
12
  import { filterFr } from "./filterFr.js";
12
13
  import { flatParametersFr } from "./flatParametersFr.js";
@@ -34,6 +35,7 @@ export {
34
35
  elementSearchFr,
35
36
  equipmentSearchFr,
36
37
  equipmentsFr,
38
+ errorsFr,
37
39
  exportParamsFr,
38
40
  filterExpertFr,
39
41
  filterFr,
@@ -14,7 +14,7 @@ import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSel
14
14
  import { ElementType } from "./types/elementType.js";
15
15
  import { BASE_EQUIPMENTS, EQUIPMENT_TYPE, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./types/equipmentType.js";
16
16
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./types/equipmentTypes.js";
17
- import { AnnouncementSeverity } from "./types/types.js";
17
+ import { AnnouncementSeverity, ArrayAction } from "./types/types.js";
18
18
  import { MODIFICATION_TYPES, ModificationType } from "./types/modificationType.js";
19
19
  import { FieldType } from "./types/fieldType.js";
20
20
  import { ParameterType } from "./types/parameters.type.js";
@@ -26,6 +26,7 @@ import * as yup from "yup";
26
26
  export {
27
27
  AMPERE,
28
28
  AnnouncementSeverity,
29
+ ArrayAction,
29
30
  BASE_EQUIPMENTS,
30
31
  Battery,
31
32
  BusBar,
@@ -1,7 +1,7 @@
1
1
  import { ElementType } from "./elementType.js";
2
2
  import { BASE_EQUIPMENTS, EQUIPMENT_TYPE, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./equipmentType.js";
3
3
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./equipmentTypes.js";
4
- import { AnnouncementSeverity } from "./types.js";
4
+ import { AnnouncementSeverity, ArrayAction } from "./types.js";
5
5
  import { MODIFICATION_TYPES, ModificationType } from "./modificationType.js";
6
6
  import { FieldType } from "./fieldType.js";
7
7
  import { ParameterType } from "./parameters.type.js";
@@ -9,6 +9,7 @@ import { SolverTypeInfos } from "./dynamic-simulation.type.js";
9
9
  import { DistributionType, SensitivityType } from "./sensitivity-analysis.type.js";
10
10
  export {
11
11
  AnnouncementSeverity,
12
+ ArrayAction,
12
13
  BASE_EQUIPMENTS,
13
14
  Battery,
14
15
  BusBar,
@@ -56,3 +56,7 @@ export type AnnouncementDto = {
56
56
  severity: AnnouncementSeverity;
57
57
  remainingDuration: number;
58
58
  };
59
+ export declare enum ArrayAction {
60
+ ADD = "ADD",
61
+ REMOVE = "REMOVE"
62
+ }
@@ -3,6 +3,12 @@ var AnnouncementSeverity = /* @__PURE__ */ ((AnnouncementSeverity2) => {
3
3
  AnnouncementSeverity2["WARN"] = "WARN";
4
4
  return AnnouncementSeverity2;
5
5
  })(AnnouncementSeverity || {});
6
+ var ArrayAction = /* @__PURE__ */ ((ArrayAction2) => {
7
+ ArrayAction2["ADD"] = "ADD";
8
+ ArrayAction2["REMOVE"] = "REMOVE";
9
+ return ArrayAction2;
10
+ })(ArrayAction || {});
6
11
  export {
7
- AnnouncementSeverity
12
+ AnnouncementSeverity,
13
+ ArrayAction
8
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.131.0",
3
+ "version": "0.132.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",