@gridsuite/commons-ui 0.158.0 → 0.159.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.
@@ -1,12 +1,6 @@
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 EditNoteIconProps = {
1
+ import { SvgIconProps } from '@mui/material';
2
+ type EditNoteIconProps = SvgIconProps & {
8
3
  empty?: boolean;
9
- hidden?: boolean;
10
4
  };
11
- export declare function EditNoteIcon({ empty, hidden }: Readonly<EditNoteIconProps>): import("react/jsx-runtime").JSX.Element;
5
+ export declare function EditNoteIcon({ empty, ...props }: Readonly<EditNoteIconProps>): import("react/jsx-runtime").JSX.Element;
12
6
  export {};
@@ -1,17 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import AddNote from "@material-symbols/svg-400/outlined/add_notes.svg?react";
3
- import { useTheme } from "@mui/material";
2
+ import AddNotes from "@material-symbols/svg-400/outlined/add_notes.svg?react";
3
+ import { SvgIcon } from "@mui/material";
4
4
  import { StickyNote2Outlined } from "@mui/icons-material";
5
- function EditNoteIcon({ empty = false, hidden = false }) {
6
- const theme = useTheme();
7
- const size = 25;
8
- const style = {
9
- width: size,
10
- height: size,
11
- fill: theme.palette.text.primary,
12
- visibility: hidden ? "hidden" : "visible"
13
- };
14
- return empty ? /* @__PURE__ */ jsx(AddNote, { style }) : /* @__PURE__ */ jsx(StickyNote2Outlined, { sx: style });
5
+ function EditNoteIcon({ empty = false, ...props }) {
6
+ return empty ? /* @__PURE__ */ jsx(SvgIcon, { component: AddNotes, inheritViewBox: true, ...props }) : /* @__PURE__ */ jsx(StickyNote2Outlined, { ...props });
15
7
  }
16
8
  export {
17
9
  EditNoteIcon
@@ -1,7 +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
- export declare function LeftPanelCloseIcon(): import("react/jsx-runtime").JSX.Element;
1
+ import { SvgIconProps } from '@mui/material';
2
+ export declare function LeftPanelCloseIcon(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import LeftPanelClose from "@material-symbols/svg-400/outlined/left_panel_close.svg?react";
3
- import { useTheme } from "@mui/material";
4
- function LeftPanelCloseIcon() {
5
- const theme = useTheme();
6
- return /* @__PURE__ */ jsx(
7
- LeftPanelClose,
8
- {
9
- style: {
10
- width: 24,
11
- height: 24,
12
- fill: theme.palette.text.primary
13
- }
14
- }
15
- );
3
+ import { SvgIcon } from "@mui/material";
4
+ function LeftPanelCloseIcon(props) {
5
+ return /* @__PURE__ */ jsx(SvgIcon, { component: LeftPanelClose, inheritViewBox: true, ...props });
16
6
  }
17
7
  export {
18
8
  LeftPanelCloseIcon
@@ -1,7 +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
- export declare function LeftPanelOpenIcon(): import("react/jsx-runtime").JSX.Element;
1
+ import { SvgIconProps } from '@mui/material';
2
+ export declare function LeftPanelOpenIcon(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import LeftPanelOpen from "@material-symbols/svg-400/outlined/left_panel_open.svg?react";
3
- import { useTheme } from "@mui/material";
4
- function LeftPanelOpenIcon() {
5
- const theme = useTheme();
6
- return /* @__PURE__ */ jsx(
7
- LeftPanelOpen,
8
- {
9
- style: {
10
- width: 24,
11
- height: 24,
12
- fill: theme.palette.text.primary
13
- }
14
- }
15
- );
3
+ import { SvgIcon } from "@mui/material";
4
+ function LeftPanelOpenIcon(props) {
5
+ return /* @__PURE__ */ jsx(SvgIcon, { component: LeftPanelOpen, inheritViewBox: true, ...props });
16
6
  }
17
7
  export {
18
8
  LeftPanelOpenIcon
package/dist/index.js CHANGED
@@ -204,7 +204,7 @@ import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters,
204
204
  import { exportFilter, getAvailableComponentLibraries, getStudyNetworkVisualizationsParameters, getStudyShortCircuitParameters, setStudyNetworkVisualizationParameters, updateVoltageInitParameters } from "./services/study.js";
205
205
  import { getNetworkVisualizationsParameters } from "./services/study-config.js";
206
206
  import { fetchCurrentAnnouncement, fetchUserDetails } from "./services/userAdmin.js";
207
- import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse } from "./services/utils.js";
207
+ import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse, parseError } from "./services/utils.js";
208
208
  import { getVoltageInitParameters, getVoltageInitUrl } from "./services/voltage-init.js";
209
209
  import { fetchShortCircuitParameters, getShortCircuitSpecificParametersDescription, updateShortCircuitParameters } from "./services/short-circuit-analysis.js";
210
210
  import { equalsArray } from "./utils/algos.js";
@@ -852,6 +852,7 @@ export {
852
852
  onlyStartedGeneratorsOptions,
853
853
  parametersEn,
854
854
  parametersFr,
855
+ parseError,
855
856
  queryValidator,
856
857
  recursiveRemove,
857
858
  reportViewerEn,
@@ -8,7 +8,7 @@ import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters,
8
8
  import { exportFilter, getAvailableComponentLibraries, getStudyNetworkVisualizationsParameters, getStudyShortCircuitParameters, setStudyNetworkVisualizationParameters, updateVoltageInitParameters } from "./study.js";
9
9
  import { getNetworkVisualizationsParameters } from "./study-config.js";
10
10
  import { fetchCurrentAnnouncement, fetchUserDetails } from "./userAdmin.js";
11
- import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse } from "./utils.js";
11
+ import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse, parseError } from "./utils.js";
12
12
  import { getVoltageInitParameters, getVoltageInitUrl } from "./voltage-init.js";
13
13
  import { fetchShortCircuitParameters, getShortCircuitSpecificParametersDescription, updateShortCircuitParameters } from "./short-circuit-analysis.js";
14
14
  export {
@@ -63,6 +63,7 @@ export {
63
63
  handleNotOkResponse,
64
64
  hasElementPermission,
65
65
  isStudyMetadata,
66
+ parseError,
66
67
  safeEncodeURIComponent,
67
68
  saveFilter,
68
69
  setLoadFlowParameters,
@@ -9,6 +9,7 @@ type FetchInitWithTimeout = RequestInit & {
9
9
  /** If provided and no signal is set, use this as the timeout override (ms). */
10
10
  timeoutMs?: number;
11
11
  };
12
+ export declare const parseError: (errorTxt: string) => Error;
12
13
  export declare const handleNotOkResponse: (response: Response) => Promise<never>;
13
14
  export declare const backendFetch: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<Response>;
14
15
  export declare const backendFetchJson: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<any>;
@@ -28,6 +28,26 @@ const isProblemDetail = (error) => {
28
28
  const e = error;
29
29
  return typeof e.status === "number" && typeof e.server === "string" && typeof e.timestamp === "string" && typeof e.traceId === "string" && typeof e.detail === "string";
30
30
  };
31
+ const parseError = (errorTxt) => {
32
+ let error;
33
+ try {
34
+ error = JSON.parse(errorTxt);
35
+ } catch {
36
+ return new Error(errorTxt);
37
+ }
38
+ if (isProblemDetail(error)) {
39
+ return new ProblemDetailError(
40
+ error.status,
41
+ error.detail,
42
+ error.server,
43
+ error.timestamp,
44
+ error.traceId,
45
+ error.businessErrorCode,
46
+ error.businessErrorValues
47
+ );
48
+ }
49
+ return new Error(errorTxt);
50
+ };
31
51
  const handleNotOkResponse = async (response) => {
32
52
  let bodyText;
33
53
  try {
@@ -38,7 +58,7 @@ const handleNotOkResponse = async (response) => {
38
58
  });
39
59
  }
40
60
  const contentType = response.headers.get("content-type") ?? "";
41
- if (!contentType.includes("application/json")) {
61
+ if (!contentType.includes("application/json") && !contentType.includes("application/problem+json")) {
42
62
  throw new CustomError(response.status, bodyText);
43
63
  }
44
64
  let body;
@@ -97,5 +117,6 @@ export {
97
117
  backendFetchJson,
98
118
  backendFetchText,
99
119
  getRequestParamFromList,
100
- handleNotOkResponse
120
+ handleNotOkResponse,
121
+ parseError
101
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.158.0",
3
+ "version": "0.159.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",