@gridsuite/commons-ui 0.96.0 → 0.98.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.
package/README.md CHANGED
@@ -30,7 +30,8 @@ To fix this, run this command from the app **after** running "npm install"
30
30
  #### For integrators
31
31
 
32
32
  If you want to deploy a new version of commons-ui in the [NPM package registry](https://www.npmjs.com/package/@gridsuite/commons-ui),
33
- you need to follow the steps below:
33
+ first you need **some permissions**. You need to be a member of the *gridsuite* organization and a member of the *'developers'* team.
34
+ Only in this case, you need to follow the steps below:
34
35
 
35
36
  - [Make a release action](https://github.com/gridsuite/commons-ui/actions/workflows/release.yml)
36
37
  - In the 'run workflow' combobox select, let the branch on main
@@ -38,6 +39,8 @@ you need to follow the steps below:
38
39
  - Enter your NPM access token (it must be an **automation** access token to bypass 2FA, see the [access token documentation](https://docs.npmjs.com/creating-and-viewing-access-tokens) for details)
39
40
  - Click 'run workflow'
40
41
 
42
+ Otherwise ask someone who has the permission.
43
+
41
44
  #### License Headers and dependencies checking
42
45
 
43
46
  To check dependencies license compatibility with this project one locally, please run the following command :
@@ -21,3 +21,4 @@ export * from './topBar';
21
21
  export * from './treeViewFinder';
22
22
  export * from './notifications';
23
23
  export * from './icons';
24
+ export * from './menus';
@@ -107,6 +107,7 @@ import { useNotificationsListener } from "./notifications/hooks/useNotifications
107
107
  import { useListenerManager } from "./notifications/hooks/useListenerManager.js";
108
108
  import { LeftPanelOpenIcon } from "./icons/LeftPanelOpenIcon.js";
109
109
  import { LeftPanelCloseIcon } from "./icons/LeftPanelCloseIcon.js";
110
+ import { CustomMenuItem, CustomNestedMenuItem } from "./menus/custom-nested-menu.js";
110
111
  export {
111
112
  AboutDialog,
112
113
  ActivableChip,
@@ -135,7 +136,9 @@ export {
135
136
  CustomAgGridTable,
136
137
  CustomFormContext,
137
138
  CustomFormProvider,
139
+ CustomMenuItem,
138
140
  CustomMuiDialog,
141
+ CustomNestedMenuItem,
139
142
  CustomReactQueryBuilder,
140
143
  DEFAULT_RANGE_VALUE,
141
144
  DISTRIBUTION_KEY,
@@ -11,10 +11,11 @@ export interface DirectoryItemsInputProps {
11
11
  onRowChanged?: (a: boolean) => void;
12
12
  onChange?: (e: any) => void;
13
13
  disable?: boolean;
14
+ allowMultiSelect?: boolean;
14
15
  labelRequiredFromContext?: boolean;
15
16
  }
16
17
  export declare function DirectoryItemsInput({ label, name, elementType, // Used to specify type of element (Filter, Contingency list, ...)
17
18
  equipmentTypes, // Mostly used for filters, it allows the user to get elements of specific equipment only
18
19
  itemFilter, // Used to further filter the results displayed according to specific requirement
19
20
  titleId, // title of directory item selector dialogue
20
- hideErrorMessage, onRowChanged, onChange, disable, labelRequiredFromContext, }: DirectoryItemsInputProps): import("react/jsx-runtime").JSX.Element;
21
+ hideErrorMessage, onRowChanged, onChange, disable, allowMultiSelect, labelRequiredFromContext, }: Readonly<DirectoryItemsInputProps>): import("react/jsx-runtime").JSX.Element;
@@ -58,13 +58,14 @@ function DirectoryItemsInput({
58
58
  onRowChanged,
59
59
  onChange,
60
60
  disable = false,
61
+ allowMultiSelect = true,
61
62
  labelRequiredFromContext = true
62
63
  }) {
63
64
  const { snackError } = useSnackMessage();
64
65
  const intl = useIntl();
65
66
  const [selected, setSelected] = useState([]);
66
67
  const [expanded, setExpanded] = useState([]);
67
- const [multiSelect, setMultiSelect] = useState(true);
68
+ const [multiSelect, setMultiSelect] = useState(allowMultiSelect);
68
69
  const types = useMemo(() => [elementType], [elementType]);
69
70
  const [directoryItemSelectorOpen, setDirectoryItemSelectorOpen] = useState(false);
70
71
  const {
@@ -134,6 +135,9 @@ function DirectoryItemsInput({
134
135
  },
135
136
  [getValues, name]
136
137
  );
138
+ const shouldReplaceElement = useMemo(() => {
139
+ return allowMultiSelect === false && (elements == null ? void 0 : elements.length) === 1;
140
+ }, [allowMultiSelect, elements]);
137
141
  return /* @__PURE__ */ jsxs(Fragment, { children: [
138
142
  /* @__PURE__ */ jsxs(
139
143
  FormControl,
@@ -175,8 +179,14 @@ function DirectoryItemsInput({
175
179
  size: "small",
176
180
  disabled: disable,
177
181
  onClick: () => {
178
- setDirectoryItemSelectorOpen(true);
179
- setMultiSelect(true);
182
+ if (shouldReplaceElement) {
183
+ handleChipClick(0);
184
+ } else {
185
+ setDirectoryItemSelectorOpen(true);
186
+ if (allowMultiSelect) {
187
+ setMultiSelect(true);
188
+ }
189
+ }
180
190
  },
181
191
  children: /* @__PURE__ */ jsx(Folder, {})
182
192
  }
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { NestedMenuItemProps } from 'mui-nested-menu';
3
+ import { MenuItemProps, SxProps, Theme } from '@mui/material';
4
+ interface CustomNestedMenuItemProps extends PropsWithChildren, Omit<NestedMenuItemProps, 'parentMenuOpen'> {
5
+ sx?: SxProps<Theme>;
6
+ }
7
+ export declare function CustomNestedMenuItem({ sx, children, ...other }: Readonly<CustomNestedMenuItemProps>): import("react/jsx-runtime").JSX.Element;
8
+ export declare function CustomMenuItem({ sx, ...other }: Readonly<MenuItemProps>): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { NestedMenuItem } from "mui-nested-menu";
4
+ import { Box, MenuItem } from "@mui/material";
5
+ import "../../utils/conversionUtils.js";
6
+ import "@mui/icons-material";
7
+ import { mergeSx } from "../../utils/styles.js";
8
+ import "../../utils/types/equipmentType.js";
9
+ import "../../utils/yupConfig.js";
10
+ const styles = {
11
+ highlightedParentLine: {
12
+ backgroundColor: "action.hover",
13
+ color: "primary.main",
14
+ transition: "all 300ms ease"
15
+ },
16
+ highlightedLine: {
17
+ transition: "all 300ms ease",
18
+ "&:hover": {
19
+ backgroundColor: "action.hover",
20
+ color: "primary.main"
21
+ }
22
+ }
23
+ };
24
+ function CustomNestedMenuItem({ sx, children, ...other }) {
25
+ const [subMenuActive, setSubMenuActive] = useState(false);
26
+ return /* @__PURE__ */ jsx(
27
+ NestedMenuItem,
28
+ {
29
+ ...other,
30
+ parentMenuOpen: true,
31
+ sx: mergeSx(subMenuActive ? styles.highlightedParentLine : styles.highlightedLine, sx),
32
+ children: /* @__PURE__ */ jsx(Box, { onMouseEnter: () => setSubMenuActive(true), onMouseLeave: () => setSubMenuActive(false), children })
33
+ }
34
+ );
35
+ }
36
+ function CustomMenuItem({ sx, ...other }) {
37
+ return /* @__PURE__ */ jsx(MenuItem, { sx: mergeSx(styles.highlightedLine, sx), ...other });
38
+ }
39
+ export {
40
+ CustomMenuItem,
41
+ CustomNestedMenuItem
42
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2021, 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 * from './custom-nested-menu';
@@ -0,0 +1,5 @@
1
+ import { CustomMenuItem, CustomNestedMenuItem } from "./custom-nested-menu.js";
2
+ export {
3
+ CustomMenuItem,
4
+ CustomNestedMenuItem
5
+ };
package/dist/index.js CHANGED
@@ -108,6 +108,7 @@ import { useNotificationsListener } from "./components/notifications/hooks/useNo
108
108
  import { useListenerManager } from "./components/notifications/hooks/useListenerManager.js";
109
109
  import { LeftPanelOpenIcon } from "./components/icons/LeftPanelOpenIcon.js";
110
110
  import { LeftPanelCloseIcon } from "./components/icons/LeftPanelCloseIcon.js";
111
+ import { CustomMenuItem, CustomNestedMenuItem } from "./components/menus/custom-nested-menu.js";
111
112
  import { useStateBoolean } from "./hooks/customStates/useStateBoolean.js";
112
113
  import { useStateNumber } from "./hooks/customStates/useStateNumber.js";
113
114
  import { useModificationLabelComputer } from "./hooks/useModificationLabelComputer.js";
@@ -221,7 +222,9 @@ export {
221
222
  CustomAgGridTable,
222
223
  CustomFormContext,
223
224
  CustomFormProvider,
225
+ CustomMenuItem,
224
226
  CustomMuiDialog,
227
+ CustomNestedMenuItem,
225
228
  CustomReactQueryBuilder,
226
229
  DARK_THEME,
227
230
  DEFAULT_RANGE_VALUE,
@@ -58,6 +58,8 @@ export declare const networkModificationsEn: {
58
58
  'network_modifications.TABULAR_CREATION': string;
59
59
  'network_modifications.tabular.GENERATOR_CREATION': string;
60
60
  'network_modifications.LCC_CREATION': string;
61
+ 'network_modifications.LCC_MODIFICATION': string;
61
62
  'network_modifications.STATIC_VAR_COMPENSATOR_CREATION': string;
62
63
  'network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION': string;
64
+ 'network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION': string;
63
65
  };
@@ -52,8 +52,10 @@ const networkModificationsEn = {
52
52
  "network_modifications.TABULAR_CREATION": "Tabular creation - {computedLabel}",
53
53
  "network_modifications.tabular.GENERATOR_CREATION": "generator creations",
54
54
  "network_modifications.LCC_CREATION": "Creating HVDC (LCC) {computedLabel}",
55
+ "network_modifications.LCC_MODIFICATION": "Modifying HVDC (LCC) {computedLabel}",
55
56
  "network_modifications.STATIC_VAR_COMPENSATOR_CREATION": "Creating static var compensator {computedLabel}",
56
- "network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION": "Creating voltage level {voltageLevelEquipmentId} and substation {substationEquipmentId}"
57
+ "network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION": "Creating voltage level {voltageLevelEquipmentId} and substation {substationEquipmentId}",
58
+ "network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION": "Modifying voltage level topology {computedLabel}"
57
59
  };
58
60
  export {
59
61
  networkModificationsEn
@@ -58,6 +58,8 @@ export declare const networkModificationsFr: {
58
58
  'network_modifications.TABULAR_CREATION': string;
59
59
  'network_modifications.tabular.GENERATOR_CREATION': string;
60
60
  'network_modifications.LCC_CREATION': string;
61
+ 'network_modifications.LCC_MODIFICATION': string;
61
62
  'network_modifications.STATIC_VAR_COMPENSATOR_CREATION': string;
62
63
  'network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION': string;
64
+ 'network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION': string;
63
65
  };
@@ -52,8 +52,10 @@ const networkModificationsFr = {
52
52
  "network_modifications.TABULAR_CREATION": "Création tabulaire - {computedLabel}",
53
53
  "network_modifications.tabular.GENERATOR_CREATION": "créations de générateurs",
54
54
  "network_modifications.LCC_CREATION": "Création de la HVDC (LCC) {computedLabel}",
55
+ "network_modifications.LCC_MODIFICATION": "Modification de la HVDC (LCC) {computedLabel}",
55
56
  "network_modifications.STATIC_VAR_COMPENSATOR_CREATION": "Création de CSPR {computedLabel}",
56
- "network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION": "Création du poste {voltageLevelEquipmentId} et du site {substationEquipmentId}"
57
+ "network_modifications.VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION": "Création du poste {voltageLevelEquipmentId} et du site {substationEquipmentId}",
58
+ "network_modifications.VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION": "Modification de la topologie du poste {computedLabel}"
57
59
  };
58
60
  export {
59
61
  networkModificationsFr
@@ -46,7 +46,10 @@ export declare enum ModificationType {
46
46
  CONVERTER_STATION_MODIFICATION = "CONVERTER_STATION_MODIFICATION",
47
47
  COMPOSITE_MODIFICATION = "COMPOSITE_MODIFICATION",
48
48
  LCC_CONVERTER_STATION_CREATION = "LCC_CONVERTER_STATION_CREATION",
49
- LCC_CREATION = "LCC_CREATION"
49
+ LCC_CONVERTER_STATION_MODIFICATION = "LCC_CONVERTER_STATION_MODIFICATION",
50
+ LCC_CREATION = "LCC_CREATION",
51
+ LCC_MODIFICATION = "LCC_MODIFICATION",
52
+ VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION = "VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION"
50
53
  }
51
54
  export declare const MODIFICATION_TYPES: {
52
55
  GROOVY_SCRIPT: {
@@ -172,10 +175,19 @@ export declare const MODIFICATION_TYPES: {
172
175
  LCC_CONVERTER_STATION_CREATION: {
173
176
  type: ModificationType;
174
177
  };
178
+ LCC_CONVERTER_STATION_MODIFICATION: {
179
+ type: ModificationType;
180
+ };
175
181
  LCC_CREATION: {
176
182
  type: ModificationType;
177
183
  };
184
+ LCC_MODIFICATION: {
185
+ type: ModificationType;
186
+ };
178
187
  VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION: {
179
188
  type: string;
180
189
  };
190
+ VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION: {
191
+ type: ModificationType;
192
+ };
181
193
  };
@@ -40,7 +40,10 @@ var ModificationType = /* @__PURE__ */ ((ModificationType2) => {
40
40
  ModificationType2["CONVERTER_STATION_MODIFICATION"] = "CONVERTER_STATION_MODIFICATION";
41
41
  ModificationType2["COMPOSITE_MODIFICATION"] = "COMPOSITE_MODIFICATION";
42
42
  ModificationType2["LCC_CONVERTER_STATION_CREATION"] = "LCC_CONVERTER_STATION_CREATION";
43
+ ModificationType2["LCC_CONVERTER_STATION_MODIFICATION"] = "LCC_CONVERTER_STATION_MODIFICATION";
43
44
  ModificationType2["LCC_CREATION"] = "LCC_CREATION";
45
+ ModificationType2["LCC_MODIFICATION"] = "LCC_MODIFICATION";
46
+ ModificationType2["VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION"] = "VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION";
44
47
  return ModificationType2;
45
48
  })(ModificationType || {});
46
49
  const MODIFICATION_TYPES = {
@@ -207,12 +210,24 @@ const MODIFICATION_TYPES = {
207
210
  type: "LCC_CONVERTER_STATION_CREATION"
208
211
  /* LCC_CONVERTER_STATION_CREATION */
209
212
  },
213
+ LCC_CONVERTER_STATION_MODIFICATION: {
214
+ type: "LCC_CONVERTER_STATION_MODIFICATION"
215
+ /* LCC_CONVERTER_STATION_MODIFICATION */
216
+ },
210
217
  LCC_CREATION: {
211
218
  type: "LCC_CREATION"
212
219
  /* LCC_CREATION */
213
220
  },
221
+ LCC_MODIFICATION: {
222
+ type: "LCC_MODIFICATION"
223
+ /* LCC_MODIFICATION */
224
+ },
214
225
  VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION: {
215
226
  type: "VOLTAGE_LEVEL_CREATION_SUBSTATION_CREATION"
227
+ },
228
+ VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION: {
229
+ type: "VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION"
230
+ /* VOLTAGE_LEVEL_TOPOLOGY_MODIFICATION */
216
231
  }
217
232
  };
218
233
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.96.0",
3
+ "version": "0.98.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",
@@ -41,6 +41,7 @@
41
41
  "@react-querybuilder/material": "^8.2.0",
42
42
  "autosuggest-highlight": "^3.3.4",
43
43
  "clsx": "^2.1.1",
44
+ "mui-nested-menu": "^4.0.0",
44
45
  "jwt-decode": "^4.0.0",
45
46
  "localized-countries": "^2.0.0",
46
47
  "oidc-client": "^1.11.5",