@gridsuite/commons-ui 0.35.1 → 0.35.2

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 (116) hide show
  1. package/README.md +2 -2
  2. package/es/components/AuthenticationRouter/AuthenticationRouter.js +102 -0
  3. package/es/components/AuthenticationRouter/index.js +7 -0
  4. package/{lib → es}/components/CardErrorBoundary/card-error-boundary.js +35 -42
  5. package/es/components/CardErrorBoundary/index.js +7 -0
  6. package/es/components/ElementSearchDialog/element-search-dialog.js +120 -0
  7. package/{lib → es}/components/ElementSearchDialog/equipment-item.js +26 -32
  8. package/es/components/ElementSearchDialog/index.js +8 -0
  9. package/es/components/ElementSearchDialog/tag-renderer.js +29 -0
  10. package/{lib → es}/components/FlatParameters/FlatParameters.js +42 -49
  11. package/es/components/FlatParameters/index.js +8 -0
  12. package/es/components/Login/Login.js +79 -0
  13. package/es/components/Login/Logout.js +78 -0
  14. package/es/components/Login/index.js +7 -0
  15. package/es/components/MuiVirtualizedTable/ColumnHeader.js +125 -0
  16. package/{lib → es}/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +18 -25
  17. package/{lib → es}/components/MuiVirtualizedTable/MuiVirtualizedTable.js +88 -99
  18. package/es/components/MuiVirtualizedTable/index.js +9 -0
  19. package/es/components/OverflowableText/index.js +7 -0
  20. package/{lib → es}/components/OverflowableText/overflowable-text.js +20 -29
  21. package/es/components/ReportViewer/index.js +7 -0
  22. package/{lib → es}/components/ReportViewer/log-report-item.js +1 -6
  23. package/{lib → es}/components/ReportViewer/log-report.js +8 -13
  24. package/{lib → es}/components/ReportViewer/log-table.js +14 -24
  25. package/{lib → es}/components/ReportViewer/report-item.js +23 -30
  26. package/{lib → es}/components/ReportViewer/report-tree-view-context.js +3 -9
  27. package/{lib → es}/components/ReportViewer/report-viewer.js +32 -40
  28. package/es/components/ReportViewerDialog/index.js +7 -0
  29. package/es/components/ReportViewerDialog/report-viewer-dialog.js +67 -0
  30. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +19 -0
  31. package/es/components/SignInCallbackHandler/index.js +7 -0
  32. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +19 -0
  33. package/es/components/SilentRenewCallbackHandler/index.js +7 -0
  34. package/es/components/SnackbarProvider/SnackbarProvider.js +39 -0
  35. package/es/components/SnackbarProvider/index.js +7 -0
  36. package/es/components/TopBar/TopBar.js +565 -0
  37. package/es/components/TopBar/index.js +7 -0
  38. package/{lib → es}/components/TreeViewFinder/TreeViewFinder.js +59 -66
  39. package/es/components/TreeViewFinder/index.js +7 -0
  40. package/es/components/react-hook-form/autocomplete-input.js +110 -0
  41. package/es/components/react-hook-form/booleans/boolean-input.js +56 -0
  42. package/es/components/react-hook-form/booleans/checkbox-input.js +28 -0
  43. package/es/components/react-hook-form/booleans/switch-input.js +28 -0
  44. package/es/components/react-hook-form/error-management/error-input.js +50 -0
  45. package/es/components/react-hook-form/error-management/field-error-alert.js +22 -0
  46. package/es/components/react-hook-form/error-management/mid-form-error.js +25 -0
  47. package/es/components/react-hook-form/numbers/float-input.js +40 -0
  48. package/es/components/react-hook-form/numbers/integer-input.js +35 -0
  49. package/es/components/react-hook-form/numbers/utils.js +6 -0
  50. package/es/components/react-hook-form/radio-input.js +55 -0
  51. package/es/components/react-hook-form/select-input.js +40 -0
  52. package/es/components/react-hook-form/slider-input.js +48 -0
  53. package/es/components/react-hook-form/text-input.js +100 -0
  54. package/es/components/react-hook-form/utils/field-label.js +15 -0
  55. package/es/components/react-hook-form/utils/functions.js +42 -0
  56. package/es/components/react-hook-form/utils/submit-button.js +25 -0
  57. package/es/components/react-hook-form/utils/text-field-with-adornment.js +92 -0
  58. package/{lib → es}/components/translations/card-error-boundary-en.js +1 -7
  59. package/{lib → es}/components/translations/card-error-boundary-fr.js +1 -7
  60. package/{lib → es}/components/translations/element-search-en.js +1 -7
  61. package/{lib → es}/components/translations/element-search-fr.js +1 -7
  62. package/{lib → es}/components/translations/equipment-search-en.js +1 -7
  63. package/{lib → es}/components/translations/equipment-search-fr.js +1 -7
  64. package/es/components/translations/inputs-en.js +25 -0
  65. package/es/components/translations/inputs-fr.js +25 -0
  66. package/{lib → es}/components/translations/login-en.js +1 -7
  67. package/{lib → es}/components/translations/login-fr.js +1 -7
  68. package/{lib → es}/components/translations/report-viewer-en.js +1 -7
  69. package/{lib → es}/components/translations/report-viewer-fr.js +1 -7
  70. package/{lib → es}/components/translations/table-en.js +1 -7
  71. package/{lib → es}/components/translations/table-fr.js +1 -7
  72. package/{lib → es}/components/translations/top-bar-en.js +1 -7
  73. package/{lib → es}/components/translations/top-bar-fr.js +1 -7
  74. package/{lib → es}/components/translations/treeview-finder-en.js +1 -7
  75. package/{lib → es}/components/translations/treeview-finder-fr.js +1 -7
  76. package/{lib → es}/hooks/useDebounce.js +7 -12
  77. package/{lib → es}/hooks/useIntlRef.js +7 -10
  78. package/{lib → es}/hooks/useSnackMessage.js +9 -13
  79. package/es/index.js +62 -0
  80. package/{lib → es}/utils/AuthService.js +23 -34
  81. package/es/utils/ElementType.js +37 -0
  82. package/{lib → es}/utils/EquipmentType.js +8 -18
  83. package/{lib → es}/utils/UserManagerMock.js +2 -7
  84. package/es/utils/actions.js +65 -0
  85. package/{lib → es}/utils/algos.js +1 -5
  86. package/{lib → es}/utils/styles.js +4 -11
  87. package/package.json +10 -4
  88. package/lib/components/AuthenticationRouter/AuthenticationRouter.js +0 -111
  89. package/lib/components/AuthenticationRouter/index.js +0 -8
  90. package/lib/components/CardErrorBoundary/index.js +0 -8
  91. package/lib/components/ElementSearchDialog/element-search-dialog.js +0 -127
  92. package/lib/components/ElementSearchDialog/index.js +0 -9
  93. package/lib/components/ElementSearchDialog/tag-renderer.js +0 -36
  94. package/lib/components/FlatParameters/index.js +0 -8
  95. package/lib/components/Login/Login.js +0 -86
  96. package/lib/components/Login/Logout.js +0 -85
  97. package/lib/components/Login/index.js +0 -8
  98. package/lib/components/MuiVirtualizedTable/ColumnHeader.js +0 -134
  99. package/lib/components/MuiVirtualizedTable/index.js +0 -12
  100. package/lib/components/OverflowableText/index.js +0 -8
  101. package/lib/components/ReportViewer/index.js +0 -8
  102. package/lib/components/ReportViewerDialog/index.js +0 -8
  103. package/lib/components/ReportViewerDialog/report-viewer-dialog.js +0 -75
  104. package/lib/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -27
  105. package/lib/components/SignInCallbackHandler/index.js +0 -8
  106. package/lib/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -27
  107. package/lib/components/SilentRenewCallbackHandler/index.js +0 -8
  108. package/lib/components/SnackbarProvider/SnackbarProvider.js +0 -45
  109. package/lib/components/SnackbarProvider/index.js +0 -8
  110. package/lib/components/TopBar/TopBar.js +0 -576
  111. package/lib/components/TopBar/index.js +0 -8
  112. package/lib/components/TreeViewFinder/index.js +0 -9
  113. package/lib/index.js +0 -105
  114. package/lib/utils/ElementType.js +0 -45
  115. package/lib/utils/actions.js +0 -83
  116. /package/{lib → es}/components/images/powsybl_logo.svg +0 -0
package/README.md CHANGED
@@ -8,8 +8,8 @@ The commons-ui library have a demo app in which you can call your components to
8
8
  The `npm start` command install the library's dependencies then launches the demo app.
9
9
 
10
10
  If you want to test your library integration with a consumer application my-app you have first
11
- to build commons-ui via `npm run build` then change the commons-ui dependency in my-app's package.json from `@gridsuite/commons-ui:'^x.x.x'`
12
- to `@gridsuite/commons-ui:'file:../path/to/the/commons-ui'` then type `npm install` `npm start`.
11
+ to build commons-ui via `npm run build` then change the commons-ui dependency in my-app's package.json from `@gridsuite/commons-ui:"^x.x.x"`
12
+ to `@gridsuite/commons-ui:"file:../path/to/the/commons-ui"` then type `npm install` `npm start`.
13
13
 
14
14
  NOTE: if you have the following error:
15
15
 
@@ -0,0 +1,102 @@
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;
@@ -0,0 +1,7 @@
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,41 +1,36 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
- var React = _interopRequireWildcard(require("react"));
6
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
7
- var _Card = _interopRequireDefault(require("@mui/material/Card"));
8
- var _CardHeader = _interopRequireDefault(require("@mui/material/CardHeader"));
9
- var _CardContent = _interopRequireDefault(require("@mui/material/CardContent"));
10
- var _CardActions = _interopRequireDefault(require("@mui/material/CardActions"));
11
- var _Collapse = _interopRequireDefault(require("@mui/material/Collapse"));
12
- var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
13
- var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
14
- var _Replay = _interopRequireDefault(require("@mui/icons-material/Replay"));
15
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
16
- var _styles = require("@mui/material/styles");
17
- var _reactIntl = require("react-intl");
18
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; }
19
6
  /**
20
7
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
21
8
  * This Source Code Form is subject to the terms of the Mozilla Public
22
9
  * License, v. 2.0. If a copy of the MPL was not distributed with this
23
10
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
24
11
  */
12
+
25
13
  // adapted from
26
14
  // https://reactjs.org/docs/error-boundaries.html
27
15
  // https://mui.com/material-ui/react-card/#complex-interaction
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
33
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
34
- 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; }
35
- var ExpandMore = (0, _styles.styled)(function (props) {
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) {
36
31
  var expand = props.expand,
37
32
  other = _objectWithoutPropertiesLoose(props, _excluded);
38
- return /*#__PURE__*/React.createElement(_IconButton["default"], other);
33
+ return /*#__PURE__*/React.createElement(IconButton, other);
39
34
  })(function (_ref) {
40
35
  var theme = _ref.theme,
41
36
  expand = _ref.expand;
@@ -94,45 +89,45 @@ var CardErrorBoundary = /*#__PURE__*/function (_React$Component) {
94
89
  var _this$state = this.state,
95
90
  error = _this$state.error,
96
91
  expanded = _this$state.expanded;
97
- return /*#__PURE__*/React.createElement(_Box["default"], {
92
+ return /*#__PURE__*/React.createElement(Box, {
98
93
  sx: {
99
94
  p: 4
100
95
  }
101
- }, /*#__PURE__*/React.createElement(_Card["default"], {
96
+ }, /*#__PURE__*/React.createElement(Card, {
102
97
  sx: {
103
98
  mx: 'auto',
104
99
  maxWidth: 600
105
100
  }
106
- }, /*#__PURE__*/React.createElement(_CardHeader["default"], {
107
- title: /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
101
+ }, /*#__PURE__*/React.createElement(CardHeader, {
102
+ title: /*#__PURE__*/React.createElement(FormattedMessage, {
108
103
  id: "card_error_boundary/title",
109
104
  defaultMessage: "Sorry, Unexpected error :("
110
105
  })
111
- }), /*#__PURE__*/React.createElement(_CardContent["default"], null, /*#__PURE__*/React.createElement(_Typography["default"], {
106
+ }), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
112
107
  variant: "body2",
113
108
  color: "text.secondary"
114
- }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
109
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
115
110
  id: "card_error_boundary/content",
116
111
  defaultMessage: "Please reload, or close and reopen this application, or contact support."
117
- }))), /*#__PURE__*/React.createElement(_CardActions["default"], {
112
+ }))), /*#__PURE__*/React.createElement(CardActions, {
118
113
  disableSpacing: true
119
- }, /*#__PURE__*/React.createElement(_IconButton["default"], {
114
+ }, /*#__PURE__*/React.createElement(IconButton, {
120
115
  onClick: this.handleReloadClick,
121
116
  "aria-label": "reload"
122
- }, /*#__PURE__*/React.createElement(_Replay["default"], null)), /*#__PURE__*/React.createElement(ExpandMore, {
117
+ }, /*#__PURE__*/React.createElement(ReplayIcon, null)), /*#__PURE__*/React.createElement(ExpandMore, {
123
118
  expand: expanded,
124
119
  onClick: this.handleExpandClick,
125
120
  "aria-expanded": expanded,
126
121
  "aria-label": "show more"
127
- }, /*#__PURE__*/React.createElement(_ExpandMore["default"], null))), /*#__PURE__*/React.createElement(_Collapse["default"], {
122
+ }, /*#__PURE__*/React.createElement(ExpandMoreIcon, null))), /*#__PURE__*/React.createElement(Collapse, {
128
123
  "in": expanded
129
- }, /*#__PURE__*/React.createElement(_CardContent["default"], null, /*#__PURE__*/React.createElement(_Typography["default"], {
124
+ }, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
130
125
  variant: "body2",
131
126
  color: "text.secondary"
132
- }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
127
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
133
128
  id: "card_error_boundary/expandederrorheader",
134
129
  defaultMessage: "Error message (and see more information in the developper console):"
135
- })), /*#__PURE__*/React.createElement(_Typography["default"], {
130
+ })), /*#__PURE__*/React.createElement(Typography, {
136
131
  variant: "caption"
137
132
  }, error.message)))));
138
133
  }
@@ -140,6 +135,4 @@ var CardErrorBoundary = /*#__PURE__*/function (_React$Component) {
140
135
  };
141
136
  return CardErrorBoundary;
142
137
  }(React.Component);
143
- var _default = CardErrorBoundary;
144
- exports["default"] = _default;
145
- module.exports = exports.default;
138
+ export default CardErrorBoundary;
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,120 @@
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 { Dialog, DialogContent, TextField, Autocomplete } from '@mui/material';
11
+ import PropTypes from 'prop-types';
12
+ import SearchIcon from '@mui/icons-material/Search';
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
+ initialSearchTerm = props.initialSearchTerm;
25
+ var _useState = useState(false),
26
+ expanded = _useState[0],
27
+ setExpanded = _useState[1];
28
+ var _useState2 = useState(false),
29
+ loading = _useState2[0],
30
+ setLoading = _useState2[1];
31
+ useEffect(function () {
32
+ setLoading(false);
33
+ }, [elementsFound]);
34
+ var handleSearchTermChange = function handleSearchTermChange(term) {
35
+ if (term) {
36
+ setLoading(true);
37
+ onSearchTermChange(term);
38
+ setExpanded(true);
39
+ } else {
40
+ setExpanded(false);
41
+ }
42
+ };
43
+ var handleClose = useCallback(function () {
44
+ setExpanded(false);
45
+ onClose();
46
+ }, [onClose]);
47
+ return /*#__PURE__*/React.createElement(Dialog, {
48
+ open: open,
49
+ onClose: onClose,
50
+ disableRestoreFocus: true,
51
+ "aria-labelledby": "dialog-title-search",
52
+ fullWidth: true
53
+ }, /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Autocomplete, {
54
+ id: "element-search",
55
+ forcePopupIcon: false,
56
+ open: expanded,
57
+ onClose: function onClose() {
58
+ setExpanded(false);
59
+ },
60
+ fullWidth: true,
61
+ onInputChange: function onInputChange(_event, value) {
62
+ if (!searchTermDisabled) {
63
+ handleSearchTermChange(value);
64
+ }
65
+ },
66
+ onChange: function onChange(_event, newValue) {
67
+ return onSelectionChange(newValue);
68
+ },
69
+ getOptionLabel: function getOptionLabel(option) {
70
+ return option.label;
71
+ },
72
+ isOptionEqualToValue: function isOptionEqualToValue(option, value) {
73
+ return option.id === value.id;
74
+ },
75
+ options: loading ? [] : elementsFound,
76
+ loading: loading,
77
+ autoHighlight: true,
78
+ noOptionsText: intl.formatMessage({
79
+ id: 'element_search/noResult'
80
+ }),
81
+ renderOption: function renderOption(optionProps, element, _ref) {
82
+ var inputValue = _ref.inputValue;
83
+ return renderElement(_extends({}, optionProps, {
84
+ element: element,
85
+ inputValue: inputValue,
86
+ onClose: handleClose
87
+ }));
88
+ },
89
+ renderInput: function renderInput(params) {
90
+ return /*#__PURE__*/React.createElement(TextField, _extends({
91
+ autoFocus: true
92
+ }, params, {
93
+ label: searchingLabel || intl.formatMessage({
94
+ id: 'element_search/label'
95
+ }),
96
+ InputProps: _extends({}, params.InputProps, {
97
+ startAdornment: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchIcon, {
98
+ color: "disabled"
99
+ }), params.InputProps.startAdornment)
100
+ })
101
+ }));
102
+ },
103
+ defaultValue: searchTermDisabled ? {
104
+ label: initialSearchTerm
105
+ } : null,
106
+ disabled: searchTermDisabled
107
+ })));
108
+ };
109
+ ElementSearchDialog.propTypes = process.env.NODE_ENV !== "production" ? {
110
+ open: PropTypes.bool.isRequired,
111
+ onClose: PropTypes.func.isRequired,
112
+ searchingLabel: PropTypes.string,
113
+ onSearchTermChange: PropTypes.func.isRequired,
114
+ onSelectionChange: PropTypes.func.isRequired,
115
+ elementsFound: PropTypes.array.isRequired,
116
+ renderElement: PropTypes.func.isRequired,
117
+ searchTermDisabled: PropTypes.bool,
118
+ initialSearchTerm: PropTypes.string
119
+ } : {};
120
+ export default ElementSearchDialog;
@@ -1,61 +1,56 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.EquipmentItem = void 0;
5
- var _index = require("./index");
6
- var _match = _interopRequireDefault(require("autosuggest-highlight/match"));
7
- var _parse = _interopRequireDefault(require("autosuggest-highlight/parse"));
8
- var _clsx = _interopRequireDefault(require("clsx"));
9
- var _reactIntl = require("react-intl");
10
- var _OverflowableText = _interopRequireDefault(require("../OverflowableText"));
11
- var _react = _interopRequireDefault(require("react"));
12
- var _EquipmentType = require("../../utils/EquipmentType");
13
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
14
- var _styles = require("../../utils/styles");
15
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; }
16
4
  /**
17
5
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
18
6
  * This Source Code Form is subject to the terms of the Mozilla Public
19
7
  * License, v. 2.0. If a copy of the MPL was not distributed with this
20
8
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
21
9
  */
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
- 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); }
24
- 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; }
25
- var EquipmentItem = function EquipmentItem(_ref) {
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) {
26
21
  var _props$classes, _props$styles, _props$classes2, _props$classes3, _props$styles2, _props$styles3, _props$classes4, _props$styles4;
27
22
  var inputValue = _ref.inputValue,
28
23
  _ref$suffixRenderer = _ref.suffixRenderer,
29
- suffixRenderer = _ref$suffixRenderer === void 0 ? _index.TagRenderer : _ref$suffixRenderer,
24
+ suffixRenderer = _ref$suffixRenderer === void 0 ? TagRenderer : _ref$suffixRenderer,
30
25
  element = _ref.element,
31
26
  _ref$showsJustText = _ref.showsJustText,
32
27
  showsJustText = _ref$showsJustText === void 0 ? false : _ref$showsJustText,
33
28
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
34
- var matches = (0, _match["default"])(element.label, inputValue, {
29
+ var matches = match(element.label, inputValue, {
35
30
  insideWords: true,
36
31
  findAllOccurrences: true
37
32
  });
38
- var parts = (0, _parse["default"])(element.label, matches);
33
+ var parts = parse(element.label, matches);
39
34
  /* override li.key otherwise it will use label which could be duplicated */
40
- return /*#__PURE__*/_react["default"].createElement("li", _extends({
35
+ return /*#__PURE__*/React.createElement("li", _extends({
41
36
  key: element.key
42
- }, props), /*#__PURE__*/_react["default"].createElement(_Box["default"], {
37
+ }, props), /*#__PURE__*/React.createElement(Box, {
43
38
  className: (_props$classes = props.classes) === null || _props$classes === void 0 ? void 0 : _props$classes.equipmentOption,
44
39
  sx: (_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.equipmentOption
45
- }, !showsJustText && /*#__PURE__*/_react["default"].createElement(_Box["default"], {
40
+ }, !showsJustText && /*#__PURE__*/React.createElement(Box, {
46
41
  component: "span",
47
- className: (0, _clsx["default"])((_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),
48
- sx: (0, _styles.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)
49
- }, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
50
- id: _EquipmentType.EQUIPMENT_TYPE[element.type].tagLabel
51
- })), /*#__PURE__*/_react["default"].createElement(_OverflowableText["default"], {
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, {
52
47
  text: parts.map(function (e) {
53
48
  return e.text;
54
49
  }).join(),
55
50
  className: (_props$classes4 = props.classes) === null || _props$classes4 === void 0 ? void 0 : _props$classes4.result,
56
51
  sx: (_props$styles4 = props.styles) === null || _props$styles4 === void 0 ? void 0 : _props$styles4.result
57
52
  }, parts.map(function (part, index) {
58
- return /*#__PURE__*/_react["default"].createElement("span", {
53
+ return /*#__PURE__*/React.createElement("span", {
59
54
  key: index,
60
55
  style: {
61
56
  fontWeight: part.highlight ? 'bold' : 'inherit'
@@ -65,5 +60,4 @@ var EquipmentItem = function EquipmentItem(_ref) {
65
60
  props: props,
66
61
  element: element
67
62
  })));
68
- };
69
- exports.EquipmentItem = EquipmentItem;
63
+ };
@@ -0,0 +1,8 @@
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 { default } from './element-search-dialog';
8
+ export { TagRenderer } from './tag-renderer';
@@ -0,0 +1,29 @@
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
+ } : {};