@gridsuite/commons-ui 0.243.0 → 0.245.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.
@@ -65,10 +65,12 @@ import { ArrowsOutputIcon } from "./ui/icons/ArrowsOutputIcon.js";
65
65
  import { ArrowsInputIcon } from "./ui/icons/ArrowsInputIcon.js";
66
66
  import { LeftPanelCloseIcon } from "./ui/icons/LeftPanelCloseIcon.js";
67
67
  import { EditNoteIcon } from "./ui/icons/EditNoteIcon.js";
68
+ import { VoltageUnitIcon } from "./ui/icons/VoltageUnitIcon.js";
68
69
  import { CustomMenuItem, CustomNestedMenuItem } from "./ui/menus/custom-nested-menu.js";
69
70
  import { ResizeHandle } from "./ui/resizablePanels/ResizeHandle.js";
70
71
  import { CsvExport } from "./ui/csvDownloader/csv-export.js";
71
72
  import { ExportCsvButton } from "./ui/csvDownloader/export-csv-button.js";
73
+ import { ManagedExportCsvButton } from "./ui/csvDownloader/managed-export-csv-button.js";
72
74
  import { fetchCsvSeparator, useCsvExport } from "./ui/csvDownloader/use-csv-export.js";
73
75
  import { CsvPicker } from "./ui/csvPicker/csv-picker.js";
74
76
  import { TreeViewFinder, generateTreeViewFinderClass } from "./ui/treeViewFinder/TreeViewFinder.js";
@@ -268,6 +270,7 @@ export {
268
270
  LeftPanelOpenIcon,
269
271
  default2 as LogTable,
270
272
  MAX_ROWS_NUMBER,
273
+ ManagedExportCsvButton,
271
274
  MessageLogCellRenderer,
272
275
  MidFormError,
273
276
  ModifyElementSelection,
@@ -331,6 +334,7 @@ export {
331
334
  UniqueNameInput,
332
335
  ValueEditor,
333
336
  ValueSelector,
337
+ VoltageUnitIcon,
334
338
  addToleranceToFilter,
335
339
  computeTolerance,
336
340
  countRules,
@@ -1,3 +1,3 @@
1
1
  import { JSX } from 'react';
2
2
  import { CsvExportProps } from './csv-export.type';
3
- export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, skipPinnedBottom, language, getData, }: CsvExportProps): JSX.Element;
3
+ export declare function CsvExport({ columns, tableNamePrefix, tableName, disabled, skipColumnHeaders, skipPinnedBottom, language, getData, resetKey, }: CsvExportProps): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
3
  import { useCsvExport } from "./use-csv-export.js";
4
- import { ExportCsvButton } from "./export-csv-button.js";
4
+ import { ManagedExportCsvButton } from "./managed-export-csv-button.js";
5
5
  function CsvExport({
6
6
  columns,
7
7
  tableNamePrefix = "",
@@ -10,11 +10,12 @@ function CsvExport({
10
10
  skipColumnHeaders = false,
11
11
  skipPinnedBottom = false,
12
12
  language,
13
- getData
13
+ getData,
14
+ resetKey
14
15
  }) {
15
16
  const csvExport = useCsvExport();
16
- const download = useCallback(() => {
17
- csvExport.getData({
17
+ const exportCsv = useCallback(async () => {
18
+ await csvExport.getData({
18
19
  columns,
19
20
  tableName,
20
21
  tableNamePrefix,
@@ -24,7 +25,7 @@ function CsvExport({
24
25
  getData
25
26
  });
26
27
  }, [columns, csvExport, tableName, tableNamePrefix, skipColumnHeaders, skipPinnedBottom, language, getData]);
27
- return /* @__PURE__ */ jsx(ExportCsvButton, { disabled, onClick: download });
28
+ return /* @__PURE__ */ jsx(ManagedExportCsvButton, { disabled, exportCsv, resetKey });
28
29
  }
29
30
  export {
30
31
  CsvExport
@@ -1,4 +1,5 @@
1
1
  import { ColDef, CsvExportParams } from 'ag-grid-community';
2
+ import { Key } from 'react';
2
3
  import { GsLangUser } from '../../../utils';
3
4
  export type CsvDownloadProps = {
4
5
  columns: ColDef[];
@@ -9,6 +10,7 @@ export type CsvDownloadProps = {
9
10
  language: GsLangUser;
10
11
  getData: (params?: CsvExportParams) => string | undefined | void;
11
12
  isCopyCsv?: boolean;
13
+ resetKey?: Key;
12
14
  };
13
15
  export type CsvExportProps = CsvDownloadProps & {
14
16
  disabled: boolean;
@@ -7,4 +7,5 @@
7
7
  export * from './csv-export';
8
8
  export * from './csv-export.type';
9
9
  export * from './export-csv-button';
10
+ export * from './managed-export-csv-button';
10
11
  export * from './use-csv-export';
@@ -1,9 +1,11 @@
1
1
  import { CsvExport } from "./csv-export.js";
2
2
  import { ExportCsvButton } from "./export-csv-button.js";
3
+ import { ManagedExportCsvButton } from "./managed-export-csv-button.js";
3
4
  import { fetchCsvSeparator, useCsvExport } from "./use-csv-export.js";
4
5
  export {
5
6
  CsvExport,
6
7
  ExportCsvButton,
8
+ ManagedExportCsvButton,
7
9
  fetchCsvSeparator,
8
10
  useCsvExport
9
11
  };
@@ -0,0 +1,8 @@
1
+ export interface ManagedExportCsvButtonProps {
2
+ disabled?: boolean;
3
+ exportCsv: () => Promise<void>;
4
+ resetKey?: unknown;
5
+ onSuccess?: () => void;
6
+ onError?: (error: unknown) => void;
7
+ }
8
+ export declare function ManagedExportCsvButton({ disabled, exportCsv, resetKey, onSuccess, onError, }: Readonly<ManagedExportCsvButtonProps>): import("react").JSX.Element;
@@ -0,0 +1,48 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect, useCallback } from "react";
3
+ import { ExportCsvButton } from "./export-csv-button.js";
4
+ function ManagedExportCsvButton({
5
+ disabled = false,
6
+ exportCsv,
7
+ resetKey,
8
+ onSuccess,
9
+ onError
10
+ }) {
11
+ const [isLoading, setIsLoading] = useState(false);
12
+ const [isSuccessful, setIsSuccessful] = useState(false);
13
+ useEffect(() => {
14
+ setIsLoading(false);
15
+ setIsSuccessful(false);
16
+ }, [resetKey]);
17
+ useEffect(() => {
18
+ if (disabled) {
19
+ setIsSuccessful(false);
20
+ }
21
+ }, [disabled]);
22
+ const handleClick = useCallback(async () => {
23
+ setIsSuccessful(false);
24
+ setIsLoading(true);
25
+ try {
26
+ await exportCsv();
27
+ setIsSuccessful(true);
28
+ onSuccess?.();
29
+ } catch (error) {
30
+ setIsSuccessful(false);
31
+ onError?.(error);
32
+ } finally {
33
+ setIsLoading(false);
34
+ }
35
+ }, [exportCsv, onSuccess, onError]);
36
+ return /* @__PURE__ */ jsx(
37
+ ExportCsvButton,
38
+ {
39
+ disabled: disabled || isLoading,
40
+ onClick: handleClick,
41
+ isDownloadLoading: isLoading,
42
+ isDownloadSuccessful: isSuccessful
43
+ }
44
+ );
45
+ }
46
+ export {
47
+ ManagedExportCsvButton
48
+ };
@@ -0,0 +1,2 @@
1
+ import { SvgIconProps } from '@mui/material';
2
+ export declare function VoltageUnitIcon(props: SvgIconProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { SvgIcon } from "@mui/material";
3
+ import * as React from "react";
4
+ const SvgVoltageUnit = (props) => /* @__PURE__ */ React.createElement("svg", { width: 21, height: 21, viewBox: "-0.265 -0.266 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("rect", { x: 2.34576, y: 4.04986, width: 15.7794, height: 12.3676, rx: 1.06618, fill: "none", stroke: "currentColor", strokeWidth: 1.27941 }), /* @__PURE__ */ React.createElement("path", { d: "M6.1435 6.02734V13.4954H4.74414V6.02734H6.1435ZM9.45725 8.23813L7.17358 10.8425L5.94914 12.0815L5.43896 11.0709L6.41074 9.8367L7.77608 8.23813H9.45725ZM8.00445 13.4954L6.44961 11.066L7.41652 10.2206L9.61759 13.4954H8.00445Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M12.6981 12.0183L14.3647 6.42091H15.9876L13.5241 13.4954H12.4552L12.6981 12.0183ZM11.1627 6.42091L12.8245 12.0183L13.0771 13.4954H11.9984L9.54957 6.42091H11.1627Z", fill: "currentColor" }));
5
+ function VoltageUnitIcon(props) {
6
+ return /* @__PURE__ */ jsx(SvgIcon, { component: SvgVoltageUnit, inheritViewBox: true, ...props });
7
+ }
8
+ export {
9
+ VoltageUnitIcon
10
+ };
@@ -9,3 +9,4 @@ export { ArrowsOutputIcon } from './ArrowsOutputIcon';
9
9
  export { ArrowsInputIcon } from './ArrowsInputIcon';
10
10
  export { LeftPanelCloseIcon } from './LeftPanelCloseIcon';
11
11
  export { EditNoteIcon } from './EditNoteIcon';
12
+ export { VoltageUnitIcon } from './VoltageUnitIcon';
@@ -3,10 +3,12 @@ import { ArrowsOutputIcon } from "./ArrowsOutputIcon.js";
3
3
  import { ArrowsInputIcon } from "./ArrowsInputIcon.js";
4
4
  import { LeftPanelCloseIcon } from "./LeftPanelCloseIcon.js";
5
5
  import { EditNoteIcon } from "./EditNoteIcon.js";
6
+ import { VoltageUnitIcon } from "./VoltageUnitIcon.js";
6
7
  export {
7
8
  ArrowsInputIcon,
8
9
  ArrowsOutputIcon,
9
10
  EditNoteIcon,
10
11
  LeftPanelCloseIcon,
11
- LeftPanelOpenIcon
12
+ LeftPanelOpenIcon,
13
+ VoltageUnitIcon
12
14
  };
@@ -65,10 +65,12 @@ import { ArrowsOutputIcon } from "./icons/ArrowsOutputIcon.js";
65
65
  import { ArrowsInputIcon } from "./icons/ArrowsInputIcon.js";
66
66
  import { LeftPanelCloseIcon } from "./icons/LeftPanelCloseIcon.js";
67
67
  import { EditNoteIcon } from "./icons/EditNoteIcon.js";
68
+ import { VoltageUnitIcon } from "./icons/VoltageUnitIcon.js";
68
69
  import { CustomMenuItem, CustomNestedMenuItem } from "./menus/custom-nested-menu.js";
69
70
  import { ResizeHandle } from "./resizablePanels/ResizeHandle.js";
70
71
  import { CsvExport } from "./csvDownloader/csv-export.js";
71
72
  import { ExportCsvButton } from "./csvDownloader/export-csv-button.js";
73
+ import { ManagedExportCsvButton } from "./csvDownloader/managed-export-csv-button.js";
72
74
  import { fetchCsvSeparator, useCsvExport } from "./csvDownloader/use-csv-export.js";
73
75
  import { CsvPicker } from "./csvPicker/csv-picker.js";
74
76
  import { TreeViewFinder, generateTreeViewFinderClass } from "./treeViewFinder/TreeViewFinder.js";
@@ -126,6 +128,7 @@ export {
126
128
  IntegerInput,
127
129
  LeftPanelCloseIcon,
128
130
  LeftPanelOpenIcon,
131
+ ManagedExportCsvButton,
129
132
  MidFormError,
130
133
  ModifyElementSelection,
131
134
  MuiSelectInput,
@@ -155,6 +158,7 @@ export {
155
158
  TextInput,
156
159
  TreeViewFinder,
157
160
  UniqueNameInput,
161
+ VoltageUnitIcon,
158
162
  directoryItemSchema,
159
163
  doesNodeHasChildren,
160
164
  fetchCsvSeparator,
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Stack, Box, Grid2, ButtonGroup, Tooltip, LinearProgress } from "@mui/material";
2
+ import { Stack, Grid2, Typography, ButtonGroup, Tooltip, Box, LinearProgress } from "@mui/material";
3
3
  import { Upload, RestartAlt } from "@mui/icons-material";
4
4
  import { useState, useCallback } from "react";
5
5
  import { useIntl, FormattedMessage } from "react-intl";
@@ -78,29 +78,32 @@ function ParameterLayout({
78
78
  }, []);
79
79
  const intl = useIntl();
80
80
  return /* @__PURE__ */ jsxs(Stack, { sx: styles.stack, children: [
81
- (title || selectParameterHandler || resetHandler) && /* @__PURE__ */ jsx(Box, { sx: styles.title, children: /* @__PURE__ */ jsxs(Grid2, { container: true, sx: { alignItems: "center", justifyContent: "space-between" }, children: [
82
- /* @__PURE__ */ jsx(Grid2, { size: 4, children: title && !isXsScreen && /* @__PURE__ */ jsx(FormattedMessage, { id: title }) }),
83
- /* @__PURE__ */ jsx(Grid2, { size: "auto", children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
84
- selectParameterHandler && /* @__PURE__ */ jsx(
85
- LabelledButton,
86
- {
87
- callback: handlePrefillClick,
88
- label: "button.prefill",
89
- "data-testid": "PrefillButton",
90
- startIcon: /* @__PURE__ */ jsx(Upload, {})
91
- }
92
- ),
93
- resetHandler && /* @__PURE__ */ jsx(Tooltip, { title: /* @__PURE__ */ jsx(FormattedMessage, { id: "tooltip.reset" }), children: /* @__PURE__ */ jsx(
94
- LabelledButton,
95
- {
96
- callback: handleResetClick,
97
- label: "button.reset",
98
- "data-testid": "ResetButton",
99
- startIcon: /* @__PURE__ */ jsx(RestartAlt, {})
100
- }
101
- ) })
102
- ] }) })
103
- ] }) }),
81
+ (title || selectParameterHandler || resetHandler) && /* @__PURE__ */ jsxs(Stack, { sx: styles.title, children: [
82
+ /* @__PURE__ */ jsxs(Grid2, { container: true, sx: { alignItems: "center", justifyContent: "space-between" }, paddingBottom: 1, children: [
83
+ /* @__PURE__ */ jsx(Grid2, { size: "auto", children: title && !isXsScreen && /* @__PURE__ */ jsx(Typography, { variant: "h6", children: /* @__PURE__ */ jsx(FormattedMessage, { id: title }) }) }),
84
+ /* @__PURE__ */ jsx(Grid2, { size: "auto", children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
85
+ selectParameterHandler && /* @__PURE__ */ jsx(
86
+ LabelledButton,
87
+ {
88
+ callback: handlePrefillClick,
89
+ label: "button.prefill",
90
+ "data-testid": "PrefillButton",
91
+ startIcon: /* @__PURE__ */ jsx(Upload, {})
92
+ }
93
+ ),
94
+ resetHandler && /* @__PURE__ */ jsx(Tooltip, { title: /* @__PURE__ */ jsx(FormattedMessage, { id: "tooltip.reset" }), children: /* @__PURE__ */ jsx(
95
+ LabelledButton,
96
+ {
97
+ callback: handleResetClick,
98
+ label: "button.reset",
99
+ "data-testid": "ResetButton",
100
+ startIcon: /* @__PURE__ */ jsx(RestartAlt, {})
101
+ }
102
+ ) })
103
+ ] }) })
104
+ ] }),
105
+ /* @__PURE__ */ jsx(LineSeparator, {})
106
+ ] }),
104
107
  /* @__PURE__ */ jsx(Box, { sx: styles.content, children: isLoading ? /* @__PURE__ */ jsx(LinearProgress, {}) : children }),
105
108
  /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
106
109
  /* @__PURE__ */ jsx(LineSeparator, {}),
@@ -57,7 +57,7 @@ const parametersStyles = {
57
57
  overflowY: "auto",
58
58
  overflowX: "hidden",
59
59
  paddingRight: theme.spacing(2),
60
- paddingTop: theme.spacing(2),
60
+ paddingTop: theme.spacing(1),
61
61
  paddingBottom: theme.spacing(1),
62
62
  flexGrow: 1
63
63
  }),
package/dist/index.js CHANGED
@@ -66,10 +66,12 @@ import { ArrowsOutputIcon } from "./components/ui/icons/ArrowsOutputIcon.js";
66
66
  import { ArrowsInputIcon } from "./components/ui/icons/ArrowsInputIcon.js";
67
67
  import { LeftPanelCloseIcon } from "./components/ui/icons/LeftPanelCloseIcon.js";
68
68
  import { EditNoteIcon } from "./components/ui/icons/EditNoteIcon.js";
69
+ import { VoltageUnitIcon } from "./components/ui/icons/VoltageUnitIcon.js";
69
70
  import { CustomMenuItem, CustomNestedMenuItem } from "./components/ui/menus/custom-nested-menu.js";
70
71
  import { ResizeHandle } from "./components/ui/resizablePanels/ResizeHandle.js";
71
72
  import { CsvExport } from "./components/ui/csvDownloader/csv-export.js";
72
73
  import { ExportCsvButton } from "./components/ui/csvDownloader/export-csv-button.js";
74
+ import { ManagedExportCsvButton } from "./components/ui/csvDownloader/managed-export-csv-button.js";
73
75
  import { fetchCsvSeparator, useCsvExport } from "./components/ui/csvDownloader/use-csv-export.js";
74
76
  import { CsvPicker } from "./components/ui/csvPicker/csv-picker.js";
75
77
  import { TreeViewFinder, generateTreeViewFinderClass } from "./components/ui/treeViewFinder/TreeViewFinder.js";
@@ -844,6 +846,7 @@ export {
844
846
  MONITORED_BRANCHES_EQUIPMENT_TYPES,
845
847
  MONITORED_VOLTAGE_LEVELS_EQUIPMENT_TYPES,
846
848
  MVAPowerAdornment,
849
+ ManagedExportCsvButton,
847
850
  MessageLogCellRenderer,
848
851
  MicroSusceptanceAdornment,
849
852
  MidFormError,
@@ -1119,6 +1122,7 @@ export {
1119
1122
  VoltageLevelCreationForm,
1120
1123
  VoltageLevelModificationForm,
1121
1124
  VoltageRegulationForm,
1125
+ VoltageUnitIcon,
1122
1126
  WRITE_SLACK_BUS,
1123
1127
  YUP_DEFAULT,
1124
1128
  YUP_NOT_NULL,
@@ -38,6 +38,7 @@ export declare const businessErrorsEn: {
38
38
  'study.tooManyNadConfigs': string;
39
39
  'study.tooManyMapCards': string;
40
40
  'study.elementAlreadyExists': string;
41
+ 'study.maxOperationTypeExceeded': string;
41
42
  'useradmin.permissionDenied': string;
42
43
  'useradmin.userNotFound': string;
43
44
  'useradmin.userAlreadyExists': string;
@@ -32,6 +32,7 @@ const businessErrorsEn = {
32
32
  "study.tooManyNadConfigs": "Maximum number of NAD configuration exceeded.",
33
33
  "study.tooManyMapCards": "Maximum number of cards exceeded.",
34
34
  "study.elementAlreadyExists": "An element with the name {fileName} already exists",
35
+ "study.maxOperationTypeExceeded": "Max number of operation reached : {currentComputation}/{maxComputation}",
35
36
  "useradmin.permissionDenied": "You don't have permission to perform this action.",
36
37
  "useradmin.userNotFound": "User not found.",
37
38
  "useradmin.userAlreadyExists": "User already exists.",
@@ -38,6 +38,7 @@ export declare const businessErrorsFr: {
38
38
  'study.tooManyNadConfigs': string;
39
39
  'study.tooManyMapCards': string;
40
40
  'study.elementAlreadyExists': string;
41
+ 'study.maxOperationTypeExceeded': string;
41
42
  'useradmin.permissionDenied': string;
42
43
  'useradmin.userNotFound': string;
43
44
  'useradmin.userAlreadyExists': string;
@@ -32,6 +32,7 @@ const businessErrorsFr = {
32
32
  "study.tooManyNadConfigs": "Nombre maximal de configurations d'image nodale de zone atteint.",
33
33
  "study.tooManyMapCards": "Nombre maximal de carte atteint.",
34
34
  "study.elementAlreadyExists": "Un élément avec le nom {fileName} est déjà présent",
35
+ "study.maxOperationTypeExceeded": "Nombre maximal d'opération de ce type atteint : {currentComputation}/{maxComputation}",
35
36
  "useradmin.permissionDenied": "Vous n'avez pas la permission d'effectuer cette action.",
36
37
  "useradmin.userNotFound": "Utilisateur introuvable.",
37
38
  "useradmin.userAlreadyExists": "L'utilisateur existe déjà.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.243.0",
3
+ "version": "0.245.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",