@gridsuite/commons-ui 0.45.0 → 0.47.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 (183) hide show
  1. package/README.md +0 -17
  2. package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
  3. package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
  4. package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
  5. package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
  6. package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
  7. package/dist/components/FlatParameters/FlatParameters.js +411 -0
  8. package/dist/components/Login/Login.js +78 -0
  9. package/dist/components/Login/Logout.js +69 -0
  10. package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
  11. package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
  12. package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
  13. package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
  14. package/dist/components/OverflowableText/overflowable-text.js +87 -0
  15. package/dist/components/ReportViewer/filter-button.js +64 -0
  16. package/dist/components/ReportViewer/log-report-item.js +95 -0
  17. package/dist/components/ReportViewer/log-report.js +49 -0
  18. package/dist/components/ReportViewer/log-table.js +131 -0
  19. package/dist/components/ReportViewer/multi-select-list.js +40 -0
  20. package/dist/components/ReportViewer/report-item.js +112 -0
  21. package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
  22. package/dist/components/ReportViewer/report-viewer.js +158 -0
  23. package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
  24. package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
  25. package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
  26. package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
  27. package/dist/components/TopBar/AboutDialog.js +467 -0
  28. package/dist/components/TopBar/GridLogo.js +71 -0
  29. package/dist/components/TopBar/TopBar.js +679 -0
  30. package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
  31. package/dist/components/react-hook-form/autocomplete-input.js +96 -0
  32. package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
  33. package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
  34. package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
  35. package/dist/components/react-hook-form/error-management/error-input.js +42 -0
  36. package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
  37. package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
  38. package/dist/components/react-hook-form/numbers/float-input.js +51 -0
  39. package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
  40. package/dist/components/react-hook-form/numbers/utils.js +10 -0
  41. package/dist/components/react-hook-form/radio-input.js +44 -0
  42. package/dist/components/react-hook-form/select-input.js +31 -0
  43. package/dist/components/react-hook-form/slider-input.js +43 -0
  44. package/dist/components/react-hook-form/text-input.js +94 -0
  45. package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
  46. package/dist/components/react-hook-form/utils/field-label.js +12 -0
  47. package/dist/components/react-hook-form/utils/functions.js +36 -0
  48. package/dist/components/react-hook-form/utils/submit-button.js +23 -0
  49. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
  50. package/dist/components/translations/card-error-boundary-en.js +8 -0
  51. package/dist/components/translations/card-error-boundary-fr.js +8 -0
  52. package/dist/components/translations/common-button-en.js +7 -0
  53. package/dist/components/translations/common-button-fr.js +7 -0
  54. package/dist/components/translations/element-search-en.js +7 -0
  55. package/dist/components/translations/element-search-fr.js +7 -0
  56. package/dist/components/translations/equipment-search-en.js +21 -0
  57. package/dist/components/translations/equipment-search-fr.js +21 -0
  58. package/dist/components/translations/flat-parameters-en.js +8 -0
  59. package/dist/components/translations/flat-parameters-fr.js +8 -0
  60. package/dist/components/translations/login-en.js +14 -0
  61. package/dist/components/translations/login-fr.js +14 -0
  62. package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
  63. package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
  64. package/dist/components/translations/report-viewer-en.js +8 -0
  65. package/dist/components/translations/report-viewer-fr.js +8 -0
  66. package/dist/components/translations/table-en.js +6 -0
  67. package/dist/components/translations/table-fr.js +6 -0
  68. package/dist/components/translations/top-bar-en.js +27 -0
  69. package/dist/components/translations/top-bar-fr.js +27 -0
  70. package/dist/components/translations/treeview-finder-en.js +12 -0
  71. package/dist/components/translations/treeview-finder-fr.js +12 -0
  72. package/dist/hooks/useDebounce.js +17 -0
  73. package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
  74. package/dist/hooks/useIntlRef.js +13 -0
  75. package/dist/hooks/useSnackMessage.js +81 -0
  76. package/dist/index.d.ts +225 -0
  77. package/dist/index.js +154 -0
  78. package/dist/utils/AuthService.js +336 -0
  79. package/dist/utils/ElementType.js +38 -0
  80. package/dist/utils/EquipmentType.js +132 -0
  81. package/dist/utils/UserManagerMock.js +85 -0
  82. package/dist/utils/actions.js +71 -0
  83. package/dist/utils/algos.js +24 -0
  84. package/dist/utils/styles.js +13 -0
  85. package/package.json +36 -21
  86. package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
  87. package/es/components/AuthenticationRouter/index.js +0 -7
  88. package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
  89. package/es/components/CardErrorBoundary/index.js +0 -7
  90. package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
  91. package/es/components/ElementSearchDialog/equipment-item.js +0 -63
  92. package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
  93. package/es/components/FlatParameters/FlatParameters.js +0 -448
  94. package/es/components/FlatParameters/index.js +0 -8
  95. package/es/components/Login/Login.js +0 -79
  96. package/es/components/Login/Logout.js +0 -78
  97. package/es/components/Login/index.js +0 -7
  98. package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
  99. package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
  100. package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
  101. package/es/components/MuiVirtualizedTable/index.js +0 -9
  102. package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
  103. package/es/components/MultipleSelectionDialog/index.js +0 -8
  104. package/es/components/OverflowableText/index.js +0 -7
  105. package/es/components/OverflowableText/overflowable-text.js +0 -81
  106. package/es/components/ReportViewer/filter-button.js +0 -77
  107. package/es/components/ReportViewer/index.js +0 -7
  108. package/es/components/ReportViewer/log-report-item.js +0 -97
  109. package/es/components/ReportViewer/log-report.js +0 -63
  110. package/es/components/ReportViewer/log-table.js +0 -130
  111. package/es/components/ReportViewer/multi-select-list.js +0 -56
  112. package/es/components/ReportViewer/report-item.js +0 -131
  113. package/es/components/ReportViewer/report-tree-view-context.js +0 -13
  114. package/es/components/ReportViewer/report-viewer.js +0 -167
  115. package/es/components/ReportViewerDialog/index.js +0 -7
  116. package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
  117. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
  118. package/es/components/SignInCallbackHandler/index.js +0 -7
  119. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
  120. package/es/components/SilentRenewCallbackHandler/index.js +0 -7
  121. package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
  122. package/es/components/SnackbarProvider/index.js +0 -7
  123. package/es/components/TopBar/AboutDialog.js +0 -456
  124. package/es/components/TopBar/GridLogo.js +0 -73
  125. package/es/components/TopBar/TopBar.js +0 -487
  126. package/es/components/TopBar/index.js +0 -9
  127. package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
  128. package/es/components/TreeViewFinder/index.js +0 -7
  129. package/es/components/images/powsybl_logo.svg +0 -35
  130. package/es/components/react-hook-form/autocomplete-input.js +0 -110
  131. package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
  132. package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
  133. package/es/components/react-hook-form/booleans/switch-input.js +0 -28
  134. package/es/components/react-hook-form/error-management/error-input.js +0 -50
  135. package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
  136. package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
  137. package/es/components/react-hook-form/numbers/float-input.js +0 -105
  138. package/es/components/react-hook-form/numbers/integer-input.js +0 -35
  139. package/es/components/react-hook-form/numbers/utils.js +0 -6
  140. package/es/components/react-hook-form/radio-input.js +0 -55
  141. package/es/components/react-hook-form/select-input.js +0 -40
  142. package/es/components/react-hook-form/slider-input.js +0 -48
  143. package/es/components/react-hook-form/text-input.js +0 -100
  144. package/es/components/react-hook-form/utils/cancel-button.js +0 -28
  145. package/es/components/react-hook-form/utils/field-label.js +0 -15
  146. package/es/components/react-hook-form/utils/functions.js +0 -42
  147. package/es/components/react-hook-form/utils/submit-button.js +0 -29
  148. package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
  149. package/es/components/translations/card-error-boundary-en.js +0 -13
  150. package/es/components/translations/card-error-boundary-fr.js +0 -13
  151. package/es/components/translations/common-button-en.js +0 -12
  152. package/es/components/translations/common-button-fr.js +0 -12
  153. package/es/components/translations/element-search-en.js +0 -12
  154. package/es/components/translations/element-search-fr.js +0 -12
  155. package/es/components/translations/equipment-search-en.js +0 -26
  156. package/es/components/translations/equipment-search-fr.js +0 -26
  157. package/es/components/translations/flat-parameters-en.js +0 -13
  158. package/es/components/translations/flat-parameters-fr.js +0 -13
  159. package/es/components/translations/inputs-en.js +0 -25
  160. package/es/components/translations/inputs-fr.js +0 -25
  161. package/es/components/translations/login-en.js +0 -19
  162. package/es/components/translations/login-fr.js +0 -19
  163. package/es/components/translations/multiple-selection-dialog-en.js +0 -13
  164. package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
  165. package/es/components/translations/report-viewer-en.js +0 -13
  166. package/es/components/translations/report-viewer-fr.js +0 -13
  167. package/es/components/translations/table-en.js +0 -11
  168. package/es/components/translations/table-fr.js +0 -11
  169. package/es/components/translations/top-bar-en.js +0 -32
  170. package/es/components/translations/top-bar-fr.js +0 -32
  171. package/es/components/translations/treeview-finder-en.js +0 -17
  172. package/es/components/translations/treeview-finder-fr.js +0 -17
  173. package/es/hooks/useDebounce.js +0 -26
  174. package/es/hooks/useIntlRef.js +0 -22
  175. package/es/hooks/useSnackMessage.js +0 -81
  176. package/es/index.js +0 -71
  177. package/es/utils/AuthService.js +0 -312
  178. package/es/utils/ElementType.js +0 -49
  179. package/es/utils/EquipmentType.js +0 -133
  180. package/es/utils/UserManagerMock.js +0 -81
  181. package/es/utils/actions.js +0 -65
  182. package/es/utils/algos.js +0 -29
  183. package/es/utils/styles.js +0 -35
@@ -0,0 +1,13 @@
1
+ const makeComposeClasses = (generateGlobalClass) => (classes, ruleName) => [generateGlobalClass(ruleName), classes[ruleName]].filter((x) => x).join(" ");
2
+ const toNestedGlobalSelectors = (styles, generateGlobalClass) => Object.fromEntries(
3
+ Object.entries(styles).map(([k, v]) => [
4
+ `& .${generateGlobalClass(k)}`,
5
+ v
6
+ ])
7
+ );
8
+ const mergeSx = (...allSx) => allSx.flat();
9
+ export {
10
+ makeComposeClasses,
11
+ mergeSx,
12
+ toNestedGlobalSelectors
13
+ };
package/package.json CHANGED
@@ -1,27 +1,26 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.45.0",
3
+ "version": "0.47.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",
7
7
  "node": ">=18"
8
8
  },
9
- "exports": "es/index.js",
10
- "module": "es/index.js",
9
+ "exports": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
11
12
  "files": [
12
- "css",
13
- "es",
14
- "lib",
15
- "umd"
13
+ "dist"
16
14
  ],
17
15
  "scripts": {
18
- "build": "npm install;nwb build-react-component --copy-files --no-demo;npm prune --production",
19
- "clean": "nwb clean-module && nwb clean-demo",
16
+ "start": "vite demo/ --config vite.config.mts",
17
+ "build": "npm install && tsc && vite build && npm prune --production",
18
+ "build:only": "vite build",
20
19
  "prepublishOnly": "npm run build",
21
- "start": "npm install;nwb serve-react-demo",
22
- "test": "nwb test-react",
23
- "test:coverage": "nwb test-react --coverage",
24
- "test:watch": "nwb test-react --server"
20
+ "test": "jest",
21
+ "test:coverage": "jest --coverage",
22
+ "test:watch": "jest --watch",
23
+ "lint": "eslint . --ext js,mjs,jsx,ts,mts,tsx --max-warnings 0"
25
24
  },
26
25
  "dependencies": {
27
26
  "autosuggest-highlight": "^3.2.0",
@@ -32,7 +31,8 @@
32
31
  "prop-types": "^15.7.2",
33
32
  "react-csv-downloader": "^2.7.0",
34
33
  "react-request-fullscreen": "^1.1.2",
35
- "react-virtualized": "^9.21.2"
34
+ "react-virtualized": "^9.22.5",
35
+ "uuid": "^3.4.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@emotion/react": "^11.8.1",
@@ -50,6 +50,9 @@
50
50
  "yup": "^1.0.0"
51
51
  },
52
52
  "devDependencies": {
53
+ "@babel/preset-env": "^7.23.8",
54
+ "@babel/preset-react": "^7.23.3",
55
+ "@babel/preset-typescript": "^7.23.3",
53
56
  "@emotion/react": "^11.8.1",
54
57
  "@emotion/styled": "^11.8.1",
55
58
  "@mui/icons-material": "^5.5.0",
@@ -58,33 +61,43 @@
58
61
  "@mui/styles": "^5.5.0",
59
62
  "@hookform/resolvers": "^3.0.0",
60
63
  "@babel/helper-builder-react-jsx": "7.15.4",
61
- "@svgr/webpack": "^5.4.0",
64
+ "@types/react": "^18.2.56",
65
+ "@types/react-dom": "^18.2.19",
66
+ "@typescript-eslint/eslint-plugin": "5.62.0",
67
+ "@typescript-eslint/parser": "5.62.0",
68
+ "@vitejs/plugin-react": "^4.2.1",
62
69
  "babel-eslint": "^10.1.0",
63
70
  "bufferutil": "^4.0.1",
64
71
  "eslint": "^7.9.0",
65
72
  "eslint-config-prettier": "^8.0.0",
66
73
  "eslint-config-react-app": "^6.0.0",
67
- "eslint-webpack-plugin": "^2.0.0",
68
74
  "eslint-plugin-flowtype": "^5.2.0",
69
75
  "eslint-plugin-import": "^2.22.0",
70
76
  "eslint-plugin-jsx-a11y": "^6.3.1",
71
77
  "eslint-plugin-prettier": "^4.0.0",
72
78
  "eslint-plugin-react": "^7.21.0",
73
79
  "eslint-plugin-react-hooks": "^4.1.2",
80
+ "jest": "^29.7.0",
81
+ "jest-environment-jsdom": "^29.7.0",
82
+ "jest-svg-transformer": "^1.0.0",
74
83
  "notistack": "^3.0.0",
75
- "nwb": "^0.25.x",
76
84
  "prettier": "^2.0.0",
77
- "puppeteer": "^17.0.0",
78
85
  "react": "^18.0.0",
79
86
  "react-dom": "^18.0.0",
80
87
  "react-intl": "^6.0.0",
81
88
  "react-hook-form": "^7.41.0",
82
89
  "react-router-dom": "^6.0.0",
90
+ "ts-node": "^10.9.2",
83
91
  "type-fest": "^2.0.0",
92
+ "typescript": "5.1.6",
84
93
  "utf-8-validate": "^5.0.2",
85
- "webpack-plugin-serve": "^1.0.1",
86
94
  "@react-hook/window-size": "^3.1.1",
87
95
  "react-resizable": "^3.0.4",
96
+ "vite": "^5.0.11",
97
+ "vite-plugin-eslint": "^1.8.1",
98
+ "vite-plugin-externalize-deps": "^0.8.0",
99
+ "vite-plugin-svgr": "^4.2.0",
100
+ "vite-plugin-dts": "^2.3.0",
88
101
  "yup": "^1.0.0"
89
102
  },
90
103
  "eslintConfig": {
@@ -92,10 +105,12 @@
92
105
  "react-app",
93
106
  "plugin:prettier/recommended"
94
107
  ],
108
+ "ignorePatterns": [
109
+ "dist"
110
+ ],
95
111
  "rules": {
96
112
  "prettier/prettier": "warn",
97
- "curly": "error",
98
- "import/no-webpack-loader-syntax": "off"
113
+ "curly": "error"
99
114
  }
100
115
  },
101
116
  "author": "gridsuite team",
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright (c) 2020, 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
-
8
- import React, { useCallback } from 'react';
9
- import { Navigate, Route, Routes } from 'react-router-dom';
10
- import SignInCallbackHandler from '../SignInCallbackHandler';
11
- import { handleSigninCallback, handleSilentRenewCallback, login, logout } from '../../utils/AuthService';
12
- import SilentRenewCallbackHandler from '../SilentRenewCallbackHandler';
13
- import Login from '../Login';
14
- import Logout from '../Login/Logout';
15
- import { Grid } from '@mui/material';
16
- import Alert from '@mui/material/Alert';
17
- import AlertTitle from '@mui/material/AlertTitle';
18
- import { FormattedMessage } from 'react-intl';
19
- var AuthenticationRouter = function AuthenticationRouter(_ref) {
20
- var userManager = _ref.userManager,
21
- signInCallbackError = _ref.signInCallbackError,
22
- authenticationRouterError = _ref.authenticationRouterError,
23
- showAuthenticationRouterLogin = _ref.showAuthenticationRouterLogin,
24
- dispatch = _ref.dispatch,
25
- navigate = _ref.navigate,
26
- location = _ref.location;
27
- var handleSigninCallbackClosure = useCallback(function () {
28
- return handleSigninCallback(dispatch, navigate, userManager.instance);
29
- }, [dispatch, navigate, userManager.instance]);
30
- var handleSilentRenewCallbackClosure = useCallback(function () {
31
- return handleSilentRenewCallback(userManager.instance);
32
- }, [userManager.instance]);
33
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
34
- container: true,
35
- alignContent: 'center',
36
- alignItems: 'center',
37
- direction: 'column'
38
- }, userManager.error !== null && /*#__PURE__*/React.createElement("h1", null, "Error : Getting userManager; ", userManager.error), signInCallbackError !== null && /*#__PURE__*/React.createElement("h1", null, "Error : SignIn Callback Error;", signInCallbackError.message), /*#__PURE__*/React.createElement(Routes, null, /*#__PURE__*/React.createElement(Route, {
39
- path: "sign-in-callback",
40
- element: /*#__PURE__*/React.createElement(SignInCallbackHandler, {
41
- userManager: userManager.instance,
42
- handleSignInCallback: handleSigninCallbackClosure
43
- })
44
- }), /*#__PURE__*/React.createElement(Route, {
45
- path: "silent-renew-callback",
46
- element: /*#__PURE__*/React.createElement(SilentRenewCallbackHandler, {
47
- userManager: userManager.instance,
48
- handleSilentRenewCallback: handleSilentRenewCallbackClosure
49
- })
50
- }), /*#__PURE__*/React.createElement(Route, {
51
- path: "logout-callback",
52
- element: /*#__PURE__*/React.createElement(Navigate, {
53
- to: "/"
54
- })
55
- }), /*#__PURE__*/React.createElement(Route, {
56
- path: "*",
57
- element: showAuthenticationRouterLogin && authenticationRouterError == null && /*#__PURE__*/React.createElement(Login, {
58
- disabled: userManager.instance === null,
59
- onLoginClick: function onLoginClick() {
60
- return login(location, userManager.instance);
61
- }
62
- })
63
- })), authenticationRouterError !== null && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
64
- item: true
65
- }, /*#__PURE__*/React.createElement(Logout, {
66
- disabled: userManager.instance === null,
67
- onLogoutClick: function onLogoutClick() {
68
- return logout(location, userManager.instance);
69
- }
70
- })), /*#__PURE__*/React.createElement(Grid, {
71
- item: true,
72
- xs: 4
73
- }, authenticationRouterError.logoutError != null && /*#__PURE__*/React.createElement(Alert, {
74
- severity: "error"
75
- }, /*#__PURE__*/React.createElement(AlertTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
76
- id: "login/errorInLogout"
77
- })), /*#__PURE__*/React.createElement(FormattedMessage, {
78
- id: "login/errorInLogoutMessage",
79
- values: {
80
- userName: authenticationRouterError.userName
81
- }
82
- }), /*#__PURE__*/React.createElement("p", null, authenticationRouterError.logoutError.error.message)), (authenticationRouterError === null || authenticationRouterError === void 0 ? void 0 : authenticationRouterError.userValidationError) != null && /*#__PURE__*/React.createElement(Alert, {
83
- severity: "error"
84
- }, /*#__PURE__*/React.createElement(AlertTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
85
- id: "login/errorInUserValidation"
86
- })), /*#__PURE__*/React.createElement(FormattedMessage, {
87
- id: "login/errorInUserValidationMessage",
88
- values: {
89
- userName: authenticationRouterError.userName
90
- }
91
- }), /*#__PURE__*/React.createElement("p", null, authenticationRouterError.userValidationError.error.message)), (authenticationRouterError === null || authenticationRouterError === void 0 ? void 0 : authenticationRouterError.unauthorizedUserInfo) != null && /*#__PURE__*/React.createElement(Alert, {
92
- severity: "info"
93
- }, /*#__PURE__*/React.createElement(AlertTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
94
- id: "login/unauthorizedAccess"
95
- })), /*#__PURE__*/React.createElement(FormattedMessage, {
96
- id: "login/unauthorizedAccessMessage",
97
- values: {
98
- userName: authenticationRouterError.userName
99
- }
100
- }))))));
101
- };
102
- export default AuthenticationRouter;
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) 2020, 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 { default } from './AuthenticationRouter';
@@ -1,138 +0,0 @@
1
- var _excluded = ["expand"];
2
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
3
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
4
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
5
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
- /**
7
- * Copyright (c) 2022, RTE (http://www.rte-france.com)
8
- * This Source Code Form is subject to the terms of the Mozilla Public
9
- * License, v. 2.0. If a copy of the MPL was not distributed with this
10
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
- */
12
-
13
- // adapted from
14
- // https://reactjs.org/docs/error-boundaries.html
15
- // https://mui.com/material-ui/react-card/#complex-interaction
16
-
17
- import * as React from 'react';
18
- import Box from '@mui/material/Box';
19
- import Card from '@mui/material/Card';
20
- import CardHeader from '@mui/material/CardHeader';
21
- import CardContent from '@mui/material/CardContent';
22
- import CardActions from '@mui/material/CardActions';
23
- import Collapse from '@mui/material/Collapse';
24
- import IconButton from '@mui/material/IconButton';
25
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
26
- import ReplayIcon from '@mui/icons-material/Replay';
27
- import Typography from '@mui/material/Typography';
28
- import { styled } from '@mui/material/styles';
29
- import { FormattedMessage } from 'react-intl';
30
- var ExpandMore = styled(function (props) {
31
- var expand = props.expand,
32
- other = _objectWithoutPropertiesLoose(props, _excluded);
33
- return /*#__PURE__*/React.createElement(IconButton, other);
34
- })(function (_ref) {
35
- var theme = _ref.theme,
36
- expand = _ref.expand;
37
- return {
38
- transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)',
39
- marginLeft: 'auto',
40
- transition: theme.transitions.create('transform', {
41
- duration: theme.transitions.duration.shortest
42
- })
43
- };
44
- });
45
- var CardErrorBoundary = /*#__PURE__*/function (_React$Component) {
46
- _inheritsLoose(CardErrorBoundary, _React$Component);
47
- function CardErrorBoundary(props) {
48
- var _this;
49
- _this = _React$Component.call(this, props) || this;
50
- _this.state = {
51
- hasError: false,
52
- expanded: false,
53
- error: undefined
54
- };
55
- _this.handleExpandClick = _this.handleExpandClick.bind(_assertThisInitialized(_this));
56
- _this.handleReloadClick = _this.handleReloadClick.bind(_assertThisInitialized(_this));
57
- return _this;
58
- }
59
- CardErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
60
- // Update state so the next render will show the fallback UI.
61
- return {
62
- hasError: true,
63
- error: error
64
- };
65
- };
66
- var _proto = CardErrorBoundary.prototype;
67
- _proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
68
- // You can also log the error to an error reporting service
69
- console.error('CardErrorBoundary caught: ', error, errorInfo);
70
- };
71
- _proto.handleExpandClick = function handleExpandClick() {
72
- this.setState(function (state) {
73
- return {
74
- expanded: !state.expanded
75
- };
76
- });
77
- };
78
- _proto.handleReloadClick = function handleReloadClick() {
79
- this.setState(function (state) {
80
- return {
81
- hasError: false,
82
- expanded: false,
83
- error: undefined
84
- };
85
- });
86
- };
87
- _proto.render = function render() {
88
- if (this.state.hasError) {
89
- var _this$state = this.state,
90
- error = _this$state.error,
91
- expanded = _this$state.expanded;
92
- return /*#__PURE__*/React.createElement(Box, {
93
- sx: {
94
- p: 4
95
- }
96
- }, /*#__PURE__*/React.createElement(Card, {
97
- sx: {
98
- mx: 'auto',
99
- maxWidth: 600
100
- }
101
- }, /*#__PURE__*/React.createElement(CardHeader, {
102
- title: /*#__PURE__*/React.createElement(FormattedMessage, {
103
- id: "card_error_boundary/title",
104
- defaultMessage: "Sorry, Unexpected error :("
105
- })
106
- }), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
107
- variant: "body2",
108
- color: "text.secondary"
109
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
110
- id: "card_error_boundary/content",
111
- defaultMessage: "Please reload, or close and reopen this application, or contact support."
112
- }))), /*#__PURE__*/React.createElement(CardActions, {
113
- disableSpacing: true
114
- }, /*#__PURE__*/React.createElement(IconButton, {
115
- onClick: this.handleReloadClick,
116
- "aria-label": "reload"
117
- }, /*#__PURE__*/React.createElement(ReplayIcon, null)), /*#__PURE__*/React.createElement(ExpandMore, {
118
- expand: expanded,
119
- onClick: this.handleExpandClick,
120
- "aria-expanded": expanded,
121
- "aria-label": "show more"
122
- }, /*#__PURE__*/React.createElement(ExpandMoreIcon, null))), /*#__PURE__*/React.createElement(Collapse, {
123
- "in": expanded
124
- }, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
125
- variant: "body2",
126
- color: "text.secondary"
127
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
128
- id: "card_error_boundary/expandederrorheader",
129
- defaultMessage: "Error message (and see more information in the developper console):"
130
- })), /*#__PURE__*/React.createElement(Typography, {
131
- variant: "caption"
132
- }, error.message)))));
133
- }
134
- return this.props.children;
135
- };
136
- return CardErrorBoundary;
137
- }(React.Component);
138
- export default CardErrorBoundary;
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) 2022, 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 { default } from './card-error-boundary.js';
@@ -1,153 +0,0 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- /**
3
- * Copyright (c) 2021, RTE (http://www.rte-france.com)
4
- * This Source Code Form is subject to the terms of the Mozilla Public
5
- * License, v. 2.0. If a copy of the MPL was not distributed with this
6
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
- */
8
-
9
- import React, { useCallback, useEffect, useState } from 'react';
10
- import { Autocomplete, Dialog, DialogContent, TextField } from '@mui/material';
11
- import PropTypes from 'prop-types';
12
- import { Search, SearchOff } from '@mui/icons-material';
13
- import { useIntl } from 'react-intl';
14
- var ElementSearchDialog = function ElementSearchDialog(props) {
15
- var intl = useIntl();
16
- var open = props.open,
17
- onClose = props.onClose,
18
- searchingLabel = props.searchingLabel,
19
- onSearchTermChange = props.onSearchTermChange,
20
- onSelectionChange = props.onSelectionChange,
21
- elementsFound = props.elementsFound,
22
- renderElement = props.renderElement,
23
- searchTermDisabled = props.searchTermDisabled,
24
- searchTermDisableReason = props.searchTermDisableReason;
25
- var _useState = useState(false),
26
- expanded = _useState[0],
27
- setExpanded = _useState[1];
28
- var _useState2 = useState(searchTermDisabled && searchTermDisableReason ? {
29
- label: searchTermDisableReason
30
- } : null),
31
- value = _useState2[0],
32
- setValue = _useState2[1];
33
- var _useState3 = useState(false),
34
- loading = _useState3[0],
35
- setLoading = _useState3[1];
36
- useEffect(function () {
37
- setLoading(false);
38
- }, [elementsFound]);
39
- useEffect(function () {
40
- if (!searchTermDisabled || !searchTermDisableReason) {
41
- setValue(null);
42
- } else {
43
- setValue({
44
- label: searchTermDisableReason
45
- });
46
- }
47
- }, [searchTermDisabled, searchTermDisableReason]);
48
-
49
- // to reset the value between the dialog closing and opening
50
- useEffect(function () {
51
- setValue(function (old) {
52
- return !open ? null : old;
53
- });
54
- }, [open]);
55
- var handleSearchTermChange = function handleSearchTermChange(term) {
56
- if (term) {
57
- setLoading(true);
58
- onSearchTermChange(term);
59
- setExpanded(true);
60
- setValue({
61
- label: term
62
- });
63
- } else {
64
- setExpanded(false);
65
- setValue(null);
66
- }
67
- };
68
- var handleClose = useCallback(function () {
69
- setValue(null);
70
- setExpanded(false);
71
- onClose();
72
- }, [onClose]);
73
- return /*#__PURE__*/React.createElement(Dialog, {
74
- open: open,
75
- onClose: handleClose,
76
- disableRestoreFocus: true,
77
- "aria-labelledby": "dialog-title-search",
78
- fullWidth: true
79
- }, /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Autocomplete, {
80
- id: "element-search",
81
- forcePopupIcon: false,
82
- open: expanded,
83
- onClose: function onClose() {
84
- setExpanded(false);
85
- },
86
- fullWidth: true,
87
- freeSolo: true,
88
- clearOnBlur: true,
89
- onInputChange: function onInputChange(_event, value) {
90
- if (!searchTermDisabled) {
91
- handleSearchTermChange(value);
92
- }
93
- },
94
- onChange: function onChange(_event, newValue, reason) {
95
- if (reason === 'selectOption') {
96
- onSelectionChange(newValue);
97
- setValue(newValue);
98
- } else {
99
- setValue(null);
100
- }
101
- },
102
- getOptionLabel: function getOptionLabel(option) {
103
- return option.label;
104
- },
105
- isOptionEqualToValue: function isOptionEqualToValue(option, value) {
106
- return option.id === value.id;
107
- },
108
- options: loading ? [] : elementsFound,
109
- loading: loading,
110
- autoHighlight: true,
111
- noOptionsText: intl.formatMessage({
112
- id: 'element_search/noResult'
113
- }),
114
- renderOption: function renderOption(optionProps, element, _ref) {
115
- var inputValue = _ref.inputValue;
116
- return renderElement(_extends({}, optionProps, {
117
- element: element,
118
- inputValue: inputValue,
119
- onClose: handleClose
120
- }));
121
- },
122
- renderInput: function renderInput(params) {
123
- return /*#__PURE__*/React.createElement(TextField, _extends({
124
- autoFocus: true
125
- }, params, {
126
- label: searchingLabel || intl.formatMessage({
127
- id: 'element_search/label'
128
- }),
129
- InputProps: _extends({}, params.InputProps, {
130
- startAdornment: /*#__PURE__*/React.createElement(React.Fragment, null, searchTermDisabled ? /*#__PURE__*/React.createElement(SearchOff, {
131
- color: "disabled"
132
- }) : /*#__PURE__*/React.createElement(Search, {
133
- color: "disabled"
134
- }), params.InputProps.startAdornment)
135
- })
136
- }));
137
- },
138
- value: value,
139
- disabled: searchTermDisabled
140
- })));
141
- };
142
- ElementSearchDialog.propTypes = process.env.NODE_ENV !== "production" ? {
143
- open: PropTypes.bool.isRequired,
144
- onClose: PropTypes.func.isRequired,
145
- searchingLabel: PropTypes.string,
146
- onSearchTermChange: PropTypes.func.isRequired,
147
- onSelectionChange: PropTypes.func.isRequired,
148
- elementsFound: PropTypes.array.isRequired,
149
- renderElement: PropTypes.func.isRequired,
150
- searchTermDisabled: PropTypes.bool,
151
- searchTermDisableReason: PropTypes.string
152
- } : {};
153
- export default ElementSearchDialog;
@@ -1,63 +0,0 @@
1
- var _excluded = ["inputValue", "suffixRenderer", "element", "showsJustText"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
- /**
5
- * Copyright (c) 2022, RTE (http://www.rte-france.com)
6
- * This Source Code Form is subject to the terms of the Mozilla Public
7
- * License, v. 2.0. If a copy of the MPL was not distributed with this
8
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
- */
10
- import { TagRenderer } from './index';
11
- import match from 'autosuggest-highlight/match';
12
- import parse from 'autosuggest-highlight/parse';
13
- import clsx from 'clsx';
14
- import { FormattedMessage } from 'react-intl';
15
- import OverflowableText from '../OverflowableText';
16
- import React from 'react';
17
- import { EQUIPMENT_TYPE } from '../../utils/EquipmentType';
18
- import Box from '@mui/material/Box';
19
- import { mergeSx } from '../../utils/styles';
20
- export var EquipmentItem = function EquipmentItem(_ref) {
21
- var _props$classes, _props$styles, _props$classes2, _props$classes3, _props$styles2, _props$styles3, _props$classes4, _props$styles4;
22
- var inputValue = _ref.inputValue,
23
- _ref$suffixRenderer = _ref.suffixRenderer,
24
- suffixRenderer = _ref$suffixRenderer === void 0 ? TagRenderer : _ref$suffixRenderer,
25
- element = _ref.element,
26
- _ref$showsJustText = _ref.showsJustText,
27
- showsJustText = _ref$showsJustText === void 0 ? false : _ref$showsJustText,
28
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
29
- var matches = match(element.label, inputValue, {
30
- insideWords: true,
31
- findAllOccurrences: true
32
- });
33
- var parts = parse(element.label, matches);
34
- /* override li.key otherwise it will use label which could be duplicated */
35
- return /*#__PURE__*/React.createElement("li", _extends({
36
- key: element.key
37
- }, props), /*#__PURE__*/React.createElement(Box, {
38
- className: (_props$classes = props.classes) === null || _props$classes === void 0 ? void 0 : _props$classes.equipmentOption,
39
- sx: (_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.equipmentOption
40
- }, !showsJustText && /*#__PURE__*/React.createElement(Box, {
41
- component: "span",
42
- className: clsx((_props$classes2 = props.classes) === null || _props$classes2 === void 0 ? void 0 : _props$classes2.equipmentTag, (_props$classes3 = props.classes) === null || _props$classes3 === void 0 ? void 0 : _props$classes3.equipmentTypeTag),
43
- sx: mergeSx((_props$styles2 = props.styles) === null || _props$styles2 === void 0 ? void 0 : _props$styles2.equipmentTag, (_props$styles3 = props.styles) === null || _props$styles3 === void 0 ? void 0 : _props$styles3.equipmentTypeTag)
44
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
45
- id: EQUIPMENT_TYPE[element.type].tagLabel
46
- })), /*#__PURE__*/React.createElement(OverflowableText, {
47
- text: parts.map(function (e) {
48
- return e.text;
49
- }).join(),
50
- className: (_props$classes4 = props.classes) === null || _props$classes4 === void 0 ? void 0 : _props$classes4.result,
51
- sx: (_props$styles4 = props.styles) === null || _props$styles4 === void 0 ? void 0 : _props$styles4.result
52
- }, parts.map(function (part, index) {
53
- return /*#__PURE__*/React.createElement("span", {
54
- key: index,
55
- style: {
56
- fontWeight: part.highlight ? 'bold' : 'inherit'
57
- }
58
- }, part.text);
59
- })), !showsJustText && suffixRenderer({
60
- props: props,
61
- element: element
62
- })));
63
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Copyright (c) 2022, 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
- import OverflowableText from '../OverflowableText';
8
- import clsx from 'clsx';
9
- import React from 'react';
10
- import { EQUIPMENT_TYPE } from '../../utils/EquipmentType';
11
- import PropTypes from 'prop-types';
12
- import { mergeSx } from '../../utils/styles';
13
- export var TagRenderer = function TagRenderer(_ref) {
14
- var props = _ref.props,
15
- element = _ref.element;
16
- if (element.type !== EQUIPMENT_TYPE.SUBSTATION.name && element.type !== EQUIPMENT_TYPE.VOLTAGE_LEVEL.name) {
17
- var _props$classes, _props$classes2, _props$styles, _props$styles2;
18
- return /*#__PURE__*/React.createElement(OverflowableText, {
19
- text: element.voltageLevelLabel,
20
- className: clsx((_props$classes = props.classes) === null || _props$classes === void 0 ? void 0 : _props$classes.equipmentTag, (_props$classes2 = props.classes) === null || _props$classes2 === void 0 ? void 0 : _props$classes2.equipmentVlTag),
21
- sx: mergeSx((_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.equipmentTag, (_props$styles2 = props.styles) === null || _props$styles2 === void 0 ? void 0 : _props$styles2.equipmentVlTag)
22
- });
23
- }
24
- return /*#__PURE__*/React.createElement(React.Fragment, null);
25
- };
26
- TagRenderer.propTypes = process.env.NODE_ENV !== "production" ? {
27
- element: PropTypes.object,
28
- props: PropTypes.object
29
- } : {};