@gridsuite/commons-ui 0.138.0 → 0.140.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 (66) hide show
  1. package/dist/components/cardErrorBoundary/CardErrorBoundary.d.ts +1 -1
  2. package/dist/components/csvDownloader/csv-export.d.ts +1 -1
  3. package/dist/components/csvDownloader/csv-export.js +5 -14
  4. package/dist/components/csvDownloader/csv-export.type.d.ts +1 -1
  5. package/dist/components/csvDownloader/use-csv-export.d.ts +1 -1
  6. package/dist/components/csvDownloader/use-csv-export.js +11 -11
  7. package/dist/components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js +2 -6
  8. package/dist/components/directoryItemSelector/DirectoryItemSelector.js +2 -4
  9. package/dist/components/elementSearch/hooks/useElementSearch.js +2 -4
  10. package/dist/components/filter/FilterCreationDialog.js +5 -17
  11. package/dist/components/filter/FilterForm.d.ts +16 -2
  12. package/dist/components/filter/FilterForm.js +5 -10
  13. package/dist/components/filter/HeaderFilterForm.d.ts +7 -11
  14. package/dist/components/filter/expert/ExpertFilterEditionDialog.js +4 -23
  15. package/dist/components/filter/expert/expertFilterUtils.d.ts +0 -1
  16. package/dist/components/filter/expert/expertFilterUtils.js +0 -11
  17. package/dist/components/filter/expert/index.js +1 -2
  18. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +11 -8
  19. package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.d.ts +3 -1
  20. package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +11 -6
  21. package/dist/components/filter/index.js +1 -2
  22. package/dist/components/filter/utils/filterApi.js +1 -1
  23. package/dist/components/index.js +1 -2
  24. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +7 -4
  25. package/dist/components/inputs/reactHookForm/OverflowableChipWithHelperText.js +1 -1
  26. package/dist/components/parameters/common/parameters-creation-dialog.js +4 -9
  27. package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -6
  28. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +3 -5
  29. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +2 -5
  30. package/dist/components/parameters/network-visualizations/use-network-visualizations-parameters-form.js +4 -12
  31. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -5
  32. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +3 -5
  33. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +3 -9
  34. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +4 -12
  35. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +2 -5
  36. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +5 -16
  37. package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +4 -12
  38. package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +3 -8
  39. package/dist/hooks/use-parameters-backend.js +10 -20
  40. package/dist/hooks/usePredefinedProperties.js +2 -3
  41. package/dist/hooks/useSnackMessage.d.ts +1 -2
  42. package/dist/index.js +11 -4
  43. package/dist/services/index.d.ts +0 -1
  44. package/dist/services/index.js +1 -4
  45. package/dist/services/utils.d.ts +0 -1
  46. package/dist/services/utils.js +7 -10
  47. package/dist/translations/en/businessErrorsEn.d.ts +18 -0
  48. package/dist/translations/en/businessErrorsEn.js +19 -1
  49. package/dist/translations/en/equipmentShortEn.js +3 -3
  50. package/dist/translations/fr/businessErrorsFr.d.ts +18 -0
  51. package/dist/translations/fr/businessErrorsFr.js +19 -1
  52. package/dist/translations/fr/equipmentShortFr.js +3 -3
  53. package/dist/utils/error.d.ts +4 -0
  54. package/dist/utils/error.js +28 -0
  55. package/dist/utils/index.d.ts +3 -0
  56. package/dist/utils/index.js +11 -0
  57. package/dist/utils/labelUtils.d.ts +8 -0
  58. package/dist/utils/labelUtils.js +17 -0
  59. package/dist/utils/navigator-clipboard.d.ts +7 -0
  60. package/dist/utils/navigator-clipboard.js +16 -0
  61. package/dist/{services/businessErrorCode.d.ts → utils/types/CustomError.d.ts} +3 -1
  62. package/dist/utils/types/CustomError.js +20 -0
  63. package/dist/utils/types/index.d.ts +1 -0
  64. package/dist/utils/types/index.js +3 -0
  65. package/package.json +1 -1
  66. package/dist/services/businessErrorCode.js +0 -10
@@ -1,4 +1,4 @@
1
- import { NetworkTimeoutError, backendFetch, backendFetchFile, backendFetchJson, backendFetchText, catchErrorHandler, getRequestParamFromList } from "./utils.js";
1
+ import { NetworkTimeoutError, backendFetch, backendFetchFile, backendFetchJson, backendFetchText, 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,16 +9,13 @@ import { fetchCurrentAnnouncement, fetchUserDetails } from "./userAdmin.js";
9
9
  import { getVoltageInitParameters, getVoltageInitUrl } from "./voltage-init.js";
10
10
  import { getPccMinStudyParameters, updatePccMinParameters } from "./pcc-min.js";
11
11
  import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters, fetchSecurityAnalysisProviders, getSecurityAnalysisDefaultLimitReductions, getSecurityAnalysisParameters, getStudyUrl, safeEncodeURIComponent, setSecurityAnalysisParameters, updateSecurityAnalysisParameters, updateSecurityAnalysisProvider } from "./security-analysis.js";
12
- import { CustomError } from "./businessErrorCode.js";
13
12
  export {
14
- CustomError,
15
13
  NetworkTimeoutError,
16
14
  PREFIX_STUDY_QUERIES,
17
15
  backendFetch,
18
16
  backendFetchFile,
19
17
  backendFetchJson,
20
18
  backendFetchText,
21
- catchErrorHandler,
22
19
  createFilter,
23
20
  createParameter,
24
21
  elementAlreadyExists,
@@ -18,5 +18,4 @@ export declare const backendFetchJson: (url: string, init?: FetchInitWithTimeout
18
18
  export declare function backendFetchText(url: string, init?: FetchInitWithTimeout, token?: string): Promise<string>;
19
19
  export declare const backendFetchFile: (url: string, init: RequestInit, token?: string) => Promise<Blob>;
20
20
  export declare const getRequestParamFromList: (paramName: string, params?: string[]) => URLSearchParams;
21
- export declare const catchErrorHandler: (error: unknown, callback: (message: string) => void) => void;
22
21
  export {};
@@ -1,5 +1,5 @@
1
1
  import { getUserToken } from "../redux/commonStore.js";
2
- import { CustomError } from "./businessErrorCode.js";
2
+ import { CustomError } from "../utils/types/CustomError.js";
3
3
  const DEFAULT_TIMEOUT_MS = 5e4;
4
4
  class NetworkTimeoutError extends Error {
5
5
  constructor(messageKey = "errors.network.timeout") {
@@ -38,7 +38,12 @@ const handleError = (response) => {
38
38
  const errorJson = parseError(text);
39
39
  let customError;
40
40
  if (errorJson?.businessErrorCode != null) {
41
- throw new CustomError(errorJson.message, errorJson.status, errorJson.businessErrorCode);
41
+ throw new CustomError(
42
+ errorJson.message,
43
+ errorJson.status,
44
+ errorJson.businessErrorCode,
45
+ errorJson.businessErrorValues
46
+ );
42
47
  }
43
48
  if (errorJson && errorJson.status && errorJson.error && errorJson.message) {
44
49
  customError = new CustomError(
@@ -82,19 +87,11 @@ const backendFetchFile = (url, init, token) => {
82
87
  const getRequestParamFromList = (paramName, params = []) => {
83
88
  return new URLSearchParams(params.map((param) => [paramName, param]));
84
89
  };
85
- const catchErrorHandler = (error, callback) => {
86
- if (error instanceof Object && "message" in error && typeof error.message === "string") {
87
- callback(error.message);
88
- } else {
89
- callback("unknown error");
90
- }
91
- };
92
90
  export {
93
91
  NetworkTimeoutError,
94
92
  backendFetch,
95
93
  backendFetchFile,
96
94
  backendFetchJson,
97
95
  backendFetchText,
98
- catchErrorHandler,
99
96
  getRequestParamFromList
100
97
  };
@@ -15,6 +15,24 @@ export declare const businessErrorsEn: {
15
15
  'explore.permissionDenied': string;
16
16
  'explore.maxElementsExceeded': string;
17
17
  'explore.incorrectCaseFile': string;
18
+ 'study.notFound': string;
19
+ 'study.computationRunning': string;
20
+ 'study.loadflowError': string;
21
+ 'study.notAllowed': string;
22
+ 'study.cantDeleteRootNode': string;
23
+ 'study.moveNetworkModificationForbidden': string;
24
+ 'study.badNodeType': string;
25
+ 'study.nodeNotBuilt': string;
26
+ 'study.nodeNameAlreadyExist': string;
27
+ 'study.timeSeriesBadType': string;
28
+ 'study.noVoltageInitResultsForNode': string;
29
+ 'study.maxNodeBuildsExceeded': string;
30
+ 'study.rootNetworkDeleteForbidden': string;
31
+ 'study.maximumRootNetworkByStudyReached': string;
32
+ 'study.maximumTagLengthExceeded': string;
33
+ 'study.networkExportFailed': string;
34
+ 'study.tooManyNadConfigs': string;
35
+ 'study.tooManyMapCards': string;
18
36
  'useradmin.permissionDenied': string;
19
37
  'useradmin.userNotFound': string;
20
38
  'useradmin.userAlreadyExists': string;
@@ -9,6 +9,24 @@ const businessErrorsEn = {
9
9
  "explore.permissionDenied": "You are not allowed to perform this action.",
10
10
  "explore.maxElementsExceeded": "The number of allowed elements has been exceeded.",
11
11
  "explore.incorrectCaseFile": "The provided case file is incorrect.",
12
+ "study.notFound": "Study was not found.",
13
+ "study.computationRunning": "The operation cannot be performed because a computation is running.",
14
+ "study.loadflowError": "Loadflow error.",
15
+ "study.notAllowed": "Operation not allowed.",
16
+ "study.cantDeleteRootNode": "A root node cannot be deleted.",
17
+ "study.moveNetworkModificationForbidden": "Impossible to move this network modification.",
18
+ "study.badNodeType": "Bad node type.",
19
+ "study.nodeNotBuilt": "Node not built.",
20
+ "study.nodeNameAlreadyExist": "Node name already exists.",
21
+ "study.timeSeriesBadType": "Bad timeseries type.",
22
+ "study.noVoltageInitResultsForNode": "No voltage initialization results found.",
23
+ "study.maxNodeBuildsExceeded": "Maximum number of built nodes exceeded.",
24
+ "study.rootNetworkDeleteForbidden": "Impossible to delete this root network.",
25
+ "study.maximumRootNetworkByStudyReached": "Maximum number of root network per study exceeded.",
26
+ "study.maximumTagLengthExceeded": "Tag length exceeded.",
27
+ "study.networkExportFailed": "Failed to export network.",
28
+ "study.tooManyNadConfigs": "Maximum number of NAD configuration exceeded.",
29
+ "study.tooManyMapCards": "Maximum number of cards exceeded.",
12
30
  "useradmin.permissionDenied": "You don't have permission to perform this action.",
13
31
  "useradmin.userNotFound": "User not found.",
14
32
  "useradmin.userAlreadyExists": "User already exists.",
@@ -18,7 +36,7 @@ const businessErrorsEn = {
18
36
  "useradmin.groupAlreadyExists": "User group already exists.",
19
37
  "useradmin.announcementInvalidPeriod": "The announcement has an invalid time period.",
20
38
  "useradmin.announcementOverlap": "The announcement period overlaps with an existing one.",
21
- "filter.filterCycleDetected": "Filter cycle detected."
39
+ "filter.filterCycleDetected": "Filter cycle detected: {filters}"
22
40
  };
23
41
  export {
24
42
  businessErrorsEn
@@ -11,11 +11,11 @@ const equipmentShortEn = {
11
11
  "equipment_short/svc": "Static var compensators",
12
12
  "equipment_short/hvdcLine": "HVDC",
13
13
  "equipment_short/hvdcStation": "HVDC stations",
14
- "equipment_short/vscConverterStation": "VSC",
15
- "equipment_short/lccConverterStation": "LCC",
14
+ "equipment_short/vscConverterStation": "VSC stations",
15
+ "equipment_short/lccConverterStation": "LCC stations",
16
16
  "equipment_short/busbarSection": "BBS",
17
17
  "equipment_short/bus": "Bus",
18
- "equipment_short/switch": "Switch",
18
+ "equipment_short/switch": "Switches",
19
19
  "equipment_short/danglingLine": "Dangling lines",
20
20
  "equipment_short/hvdcLineLcc": "HVDC LCC",
21
21
  "equipment_short/hvdcLineVsc": "HVDC VSC"
@@ -15,6 +15,24 @@ export declare const businessErrorsFr: {
15
15
  'explore.permissionDenied': string;
16
16
  'explore.maxElementsExceeded': string;
17
17
  'explore.incorrectCaseFile': string;
18
+ 'study.notFound': string;
19
+ 'study.computationRunning': string;
20
+ 'study.loadflowError': string;
21
+ 'study.notAllowed': string;
22
+ 'study.cantDeleteRootNode': string;
23
+ 'study.moveNetworkModificationForbidden': string;
24
+ 'study.badNodeType': string;
25
+ 'study.nodeNotBuilt': string;
26
+ 'study.nodeNameAlreadyExist': string;
27
+ 'study.timeSeriesBadType': string;
28
+ 'study.noVoltageInitResultsForNode': string;
29
+ 'study.maxNodeBuildsExceeded': string;
30
+ 'study.rootNetworkDeleteForbidden': string;
31
+ 'study.maximumRootNetworkByStudyReached': string;
32
+ 'study.maximumTagLengthExceeded': string;
33
+ 'study.networkExportFailed': string;
34
+ 'study.tooManyNadConfigs': string;
35
+ 'study.tooManyMapCards': string;
18
36
  'useradmin.permissionDenied': string;
19
37
  'useradmin.userNotFound': string;
20
38
  'useradmin.userAlreadyExists': string;
@@ -9,6 +9,24 @@ const businessErrorsFr = {
9
9
  "explore.permissionDenied": "Vous n'êtes pas autorisé à effectuer cette action.",
10
10
  "explore.maxElementsExceeded": "Le nombre d'éléments autorisés a été dépassé.",
11
11
  "explore.incorrectCaseFile": "Le fichier réseau fourni est incorrect.",
12
+ "study.notFound": "Étude non trouvée.",
13
+ "study.computationRunning": "L'opération ne peut être menée car un calcul est en cours.",
14
+ "study.loadflowError": "Erreur de calcul de répartition.",
15
+ "study.notAllowed": "Opération non permise.",
16
+ "study.cantDeleteRootNode": "Un noeud racine ne peut être supprimé.",
17
+ "study.moveNetworkModificationForbidden": "Impossible de déplacer cette modification de réseau.",
18
+ "study.badNodeType": "Mauvais type de noeud.",
19
+ "study.nodeNotBuilt": "Noeud non réalisé.",
20
+ "study.nodeNameAlreadyExist": "Ce nom de noeud existe déjà.",
21
+ "study.timeSeriesBadType": "Série temporelle de mauvais type.",
22
+ "study.noVoltageInitResultsForNode": "Pas de résultats pour l'initialisation du plan de tension.",
23
+ "study.maxNodeBuildsExceeded": "Nombre maximal de noeuds réalisés atteint.",
24
+ "study.rootNetworkDeleteForbidden": "Impossible de supprimer ce réseau racine.",
25
+ "study.maximumRootNetworkByStudyReached": "Nombre maximal de réseau racine par étude atteint.",
26
+ "study.maximumTagLengthExceeded": "Taille maximale d'étiquette atteinte.",
27
+ "study.networkExportFailed": "Échec de l'export de réseau.",
28
+ "study.tooManyNadConfigs": "Nombre maximal de configurations d'image nodale de zone atteint.",
29
+ "study.tooManyMapCards": "Nombre maximal de carte atteint.",
12
30
  "useradmin.permissionDenied": "Vous n'avez pas la permission d'effectuer cette action.",
13
31
  "useradmin.userNotFound": "Utilisateur introuvable.",
14
32
  "useradmin.userAlreadyExists": "L'utilisateur existe déjà.",
@@ -18,7 +36,7 @@ const businessErrorsFr = {
18
36
  "useradmin.groupAlreadyExists": "Le groupe d'utilisateurs existe déjà.",
19
37
  "useradmin.announcementInvalidPeriod": "La période de l'annonce est invalide.",
20
38
  "useradmin.announcementOverlap": "La période de l'annonce chevauche une autre annonce existante.",
21
- "filter.filterCycleDetected": "Cycle de filtre détecté."
39
+ "filter.filterCycleDetected": "Cycle de filtre détecté: {filters}"
22
40
  };
23
41
  export {
24
42
  businessErrorsFr
@@ -11,11 +11,11 @@ const equipmentShortFr = {
11
11
  "equipment_short/svc": "CSPR",
12
12
  "equipment_short/hvdcLine": "HVDC",
13
13
  "equipment_short/hvdcStation": "Stations HVDC",
14
- "equipment_short/vscConverterStation": "VSC",
15
- "equipment_short/lccConverterStation": "LCC",
14
+ "equipment_short/vscConverterStation": "Stations VSC",
15
+ "equipment_short/lccConverterStation": "Stations LCC",
16
16
  "equipment_short/busbarSection": "SJB",
17
17
  "equipment_short/bus": "Noeud",
18
- "equipment_short/switch": "Switch",
18
+ "equipment_short/switch": "OC",
19
19
  "equipment_short/danglingLine": "Frontières",
20
20
  "equipment_short/hvdcLineLcc": "HVDC LCC",
21
21
  "equipment_short/hvdcLineVsc": "HVDC VSC"
@@ -0,0 +1,4 @@
1
+ import { SnackInputs, UseSnackMessageReturn } from '../hooks/useSnackMessage';
2
+ export type HeaderSnackInputs = Pick<SnackInputs, 'headerId' | 'headerTxt' | 'headerValues'>;
3
+ export declare function catchErrorHandler(error: unknown, callback: (message: string) => void): void;
4
+ export declare function snackWithFallback(snackError: UseSnackMessageReturn['snackError'], error: unknown, headerInputs?: HeaderSnackInputs): void;
@@ -0,0 +1,28 @@
1
+ import { CustomError, formatMessageValues } from "./types/CustomError.js";
2
+ function catchErrorHandler(error, callback) {
3
+ if (error instanceof Object && "message" in error && typeof error.message === "string") {
4
+ callback(error.message);
5
+ } else {
6
+ callback("unknown error");
7
+ }
8
+ }
9
+ function snackWithFallback(snackError, error, headerInputs) {
10
+ if (error instanceof CustomError && error.businessErrorCode) {
11
+ snackError({
12
+ messageId: error.businessErrorCode,
13
+ messageValues: error.businessErrorValues ? formatMessageValues(error.businessErrorValues) : void 0,
14
+ ...headerInputs
15
+ });
16
+ } else {
17
+ catchErrorHandler(error, (message) => {
18
+ snackError({
19
+ messageTxt: message,
20
+ ...headerInputs
21
+ });
22
+ });
23
+ }
24
+ }
25
+ export {
26
+ catchErrorHandler,
27
+ snackWithFallback
28
+ };
@@ -7,11 +7,14 @@
7
7
  export * from './algos';
8
8
  export * from './constants';
9
9
  export * from './conversionUtils';
10
+ export * from './error';
10
11
  export * from './functions';
11
12
  export * from './langs';
12
13
  export * from './mapper';
14
+ export * from './navigator-clipboard';
13
15
  export * from './constants/notificationsProvider';
14
16
  export * from './styles';
15
17
  export * from './types';
16
18
  export * from './validation-functions';
19
+ export * from './labelUtils';
17
20
  export { default as yupConfig } from './yupConfig';
@@ -6,12 +6,15 @@ import { AMPERE, DEGREE, KILO_AMPERE, KILO_METER, KILO_VOLT, MEGA_VAR, MEGA_VOLT
6
6
  import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, PARAM_DEVELOPER_MODE, PARAM_LANGUAGE, PARAM_THEME } from "./constants/configConstants.js";
7
7
  import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./constants/filterConstant.js";
8
8
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
9
+ import { catchErrorHandler, snackWithFallback } from "./error.js";
9
10
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions.js";
10
11
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
11
12
  import { getFileIcon } from "./mapper/getFileIcon.js";
12
13
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
14
+ import { copyToClipboard } from "./navigator-clipboard.js";
13
15
  import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./constants/notificationsProvider.js";
14
16
  import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./styles.js";
17
+ import { CustomError, formatMessageValues } from "./types/CustomError.js";
15
18
  import { ElementType } from "./types/elementType.js";
16
19
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./types/equipmentType.js";
17
20
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./types/equipmentTypes.js";
@@ -22,6 +25,7 @@ import { ParameterType } from "./types/parameters.type.js";
22
25
  import { SolverTypeInfos } from "./types/dynamic-simulation.type.js";
23
26
  import { DistributionType, SensitivityType } from "./types/sensitivity-analysis.type.js";
24
27
  import { toNumber, validateValueIsANumber } from "./validation-functions.js";
28
+ import { getEquipmentTypeShortLabel, getEquipmentTypeTagLabel } from "./labelUtils.js";
25
29
  import "./yupConfig.js";
26
30
  import * as yup from "yup";
27
31
  export {
@@ -34,6 +38,7 @@ export {
34
38
  BusBar,
35
39
  COMMON_APP_NAME,
36
40
  COMMON_CONFIG_PARAMS_NAMES,
41
+ CustomError,
37
42
  DARK_THEME,
38
43
  DEGREE,
39
44
  DanglingLine,
@@ -95,11 +100,16 @@ export {
95
100
  VSC,
96
101
  VoltageLevel,
97
102
  areArrayElementsUnique,
103
+ catchErrorHandler,
98
104
  convertInputValue,
99
105
  convertOutputValue,
106
+ copyToClipboard,
100
107
  equalsArray,
101
108
  equipmentStyles,
102
109
  equipmentTypesForPredefinedPropertiesMapper,
110
+ formatMessageValues,
111
+ getEquipmentTypeShortLabel,
112
+ getEquipmentTypeTagLabel,
103
113
  getEquipmentsInfosForSearchBar,
104
114
  getFileIcon,
105
115
  isBlankOrEmpty,
@@ -111,6 +121,7 @@ export {
111
121
  microUnitToUnit,
112
122
  roundToDefaultPrecision,
113
123
  roundToPrecision,
124
+ snackWithFallback,
114
125
  toNestedGlobalSelectors,
115
126
  toNumber,
116
127
  unitToKiloUnit,
@@ -0,0 +1,8 @@
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 getEquipmentTypeShortLabel(equipmentType: string | undefined): string;
8
+ export declare function getEquipmentTypeTagLabel(equipmentType: string | undefined): string;
@@ -0,0 +1,17 @@
1
+ import { ALL_EQUIPMENTS } from "./types/equipmentType.js";
2
+ function getEquipmentTypeShortLabel(equipmentType) {
3
+ if (!equipmentType) {
4
+ return "";
5
+ }
6
+ return ALL_EQUIPMENTS[equipmentType]?.shortLabel ?? "";
7
+ }
8
+ function getEquipmentTypeTagLabel(equipmentType) {
9
+ if (!equipmentType) {
10
+ return "";
11
+ }
12
+ return ALL_EQUIPMENTS[equipmentType]?.tagLabel ?? "";
13
+ }
14
+ export {
15
+ getEquipmentTypeShortLabel,
16
+ getEquipmentTypeTagLabel
17
+ };
@@ -0,0 +1,7 @@
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 copyToClipboard(valueToCopy: string, onSuccess?: () => void, onError?: () => void): void;
@@ -0,0 +1,16 @@
1
+ function copyToClipboard(valueToCopy, onSuccess, onError) {
2
+ if ("clipboard" in navigator) {
3
+ navigator.clipboard.writeText(valueToCopy).then(() => {
4
+ if (onSuccess) onSuccess();
5
+ }).catch((error) => {
6
+ console.error("Clipboard copy error: ", error);
7
+ if (onError) onError();
8
+ });
9
+ } else {
10
+ console.error("navigator.clipboard is not supported by your current navigator");
11
+ if (onError) onError();
12
+ }
13
+ }
14
+ export {
15
+ copyToClipboard
16
+ };
@@ -7,5 +7,7 @@
7
7
  export declare class CustomError extends Error {
8
8
  status: number;
9
9
  businessErrorCode?: string;
10
- constructor(message: string, status: number, businessErrorCode?: string);
10
+ businessErrorValues?: Record<string, unknown>;
11
+ constructor(message: string, status: number, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
11
12
  }
13
+ export declare function formatMessageValues(properties: Record<string, unknown>): Record<string, string>;
@@ -0,0 +1,20 @@
1
+ class CustomError extends Error {
2
+ constructor(message, status, businessErrorCode, businessErrorValues) {
3
+ super(message);
4
+ this.status = status;
5
+ this.businessErrorCode = businessErrorCode;
6
+ this.businessErrorValues = businessErrorValues;
7
+ }
8
+ }
9
+ function formatMessageValues(properties) {
10
+ return Object.fromEntries(
11
+ Object.entries(properties).map(([key, value]) => [
12
+ key,
13
+ typeof value === "object" && value !== null ? JSON.stringify(value) : String(value)
14
+ ])
15
+ );
16
+ }
17
+ export {
18
+ CustomError,
19
+ formatMessageValues
20
+ };
@@ -4,6 +4,7 @@
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 * from './CustomError';
7
8
  export * from './elementType';
8
9
  export * from './equipmentType';
9
10
  export * from './equipmentTypes';
@@ -1,3 +1,4 @@
1
+ import { CustomError, formatMessageValues } from "./CustomError.js";
1
2
  import { ElementType } from "./elementType.js";
2
3
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./equipmentType.js";
3
4
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./equipmentTypes.js";
@@ -14,6 +15,7 @@ export {
14
15
  BASE_EQUIPMENTS,
15
16
  Battery,
16
17
  BusBar,
18
+ CustomError,
17
19
  DanglingLine,
18
20
  DistributionType,
19
21
  ElementType,
@@ -43,5 +45,6 @@ export {
43
45
  VSC,
44
46
  VoltageLevel,
45
47
  equipmentStyles,
48
+ formatMessageValues,
46
49
  getEquipmentsInfosForSearchBar
47
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.138.0",
3
+ "version": "0.140.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",
@@ -1,10 +0,0 @@
1
- class CustomError extends Error {
2
- constructor(message, status, businessErrorCode) {
3
- super(message);
4
- this.status = status;
5
- this.businessErrorCode = businessErrorCode;
6
- }
7
- }
8
- export {
9
- CustomError
10
- };