@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.
- package/README.md +0 -17
- package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
- package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
- package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
- package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
- package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
- package/dist/components/FlatParameters/FlatParameters.js +411 -0
- package/dist/components/Login/Login.js +78 -0
- package/dist/components/Login/Logout.js +69 -0
- package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
- package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
- package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
- package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
- package/dist/components/OverflowableText/overflowable-text.js +87 -0
- package/dist/components/ReportViewer/filter-button.js +64 -0
- package/dist/components/ReportViewer/log-report-item.js +95 -0
- package/dist/components/ReportViewer/log-report.js +49 -0
- package/dist/components/ReportViewer/log-table.js +131 -0
- package/dist/components/ReportViewer/multi-select-list.js +40 -0
- package/dist/components/ReportViewer/report-item.js +112 -0
- package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
- package/dist/components/ReportViewer/report-viewer.js +158 -0
- package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
- package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
- package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
- package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
- package/dist/components/TopBar/AboutDialog.js +467 -0
- package/dist/components/TopBar/GridLogo.js +71 -0
- package/dist/components/TopBar/TopBar.js +679 -0
- package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
- package/dist/components/react-hook-form/autocomplete-input.js +96 -0
- package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
- package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
- package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
- package/dist/components/react-hook-form/error-management/error-input.js +42 -0
- package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
- package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
- package/dist/components/react-hook-form/numbers/float-input.js +51 -0
- package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
- package/dist/components/react-hook-form/numbers/utils.js +10 -0
- package/dist/components/react-hook-form/radio-input.js +44 -0
- package/dist/components/react-hook-form/select-input.js +31 -0
- package/dist/components/react-hook-form/slider-input.js +43 -0
- package/dist/components/react-hook-form/text-input.js +94 -0
- package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
- package/dist/components/react-hook-form/utils/field-label.js +12 -0
- package/dist/components/react-hook-form/utils/functions.js +36 -0
- package/dist/components/react-hook-form/utils/submit-button.js +23 -0
- package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
- package/dist/components/translations/card-error-boundary-en.js +8 -0
- package/dist/components/translations/card-error-boundary-fr.js +8 -0
- package/dist/components/translations/common-button-en.js +7 -0
- package/dist/components/translations/common-button-fr.js +7 -0
- package/dist/components/translations/element-search-en.js +7 -0
- package/dist/components/translations/element-search-fr.js +7 -0
- package/dist/components/translations/equipment-search-en.js +21 -0
- package/dist/components/translations/equipment-search-fr.js +21 -0
- package/dist/components/translations/flat-parameters-en.js +8 -0
- package/dist/components/translations/flat-parameters-fr.js +8 -0
- package/dist/components/translations/login-en.js +14 -0
- package/dist/components/translations/login-fr.js +14 -0
- package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
- package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
- package/dist/components/translations/report-viewer-en.js +8 -0
- package/dist/components/translations/report-viewer-fr.js +8 -0
- package/dist/components/translations/table-en.js +6 -0
- package/dist/components/translations/table-fr.js +6 -0
- package/dist/components/translations/top-bar-en.js +27 -0
- package/dist/components/translations/top-bar-fr.js +27 -0
- package/dist/components/translations/treeview-finder-en.js +12 -0
- package/dist/components/translations/treeview-finder-fr.js +12 -0
- package/dist/hooks/useDebounce.js +17 -0
- package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
- package/dist/hooks/useIntlRef.js +13 -0
- package/dist/hooks/useSnackMessage.js +81 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +154 -0
- package/dist/utils/AuthService.js +336 -0
- package/dist/utils/ElementType.js +38 -0
- package/dist/utils/EquipmentType.js +132 -0
- package/dist/utils/UserManagerMock.js +85 -0
- package/dist/utils/actions.js +71 -0
- package/dist/utils/algos.js +24 -0
- package/dist/utils/styles.js +13 -0
- package/package.json +36 -21
- package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
- package/es/components/AuthenticationRouter/index.js +0 -7
- package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
- package/es/components/CardErrorBoundary/index.js +0 -7
- package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
- package/es/components/ElementSearchDialog/equipment-item.js +0 -63
- package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
- package/es/components/FlatParameters/FlatParameters.js +0 -448
- package/es/components/FlatParameters/index.js +0 -8
- package/es/components/Login/Login.js +0 -79
- package/es/components/Login/Logout.js +0 -78
- package/es/components/Login/index.js +0 -7
- package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
- package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
- package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
- package/es/components/MuiVirtualizedTable/index.js +0 -9
- package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
- package/es/components/MultipleSelectionDialog/index.js +0 -8
- package/es/components/OverflowableText/index.js +0 -7
- package/es/components/OverflowableText/overflowable-text.js +0 -81
- package/es/components/ReportViewer/filter-button.js +0 -77
- package/es/components/ReportViewer/index.js +0 -7
- package/es/components/ReportViewer/log-report-item.js +0 -97
- package/es/components/ReportViewer/log-report.js +0 -63
- package/es/components/ReportViewer/log-table.js +0 -130
- package/es/components/ReportViewer/multi-select-list.js +0 -56
- package/es/components/ReportViewer/report-item.js +0 -131
- package/es/components/ReportViewer/report-tree-view-context.js +0 -13
- package/es/components/ReportViewer/report-viewer.js +0 -167
- package/es/components/ReportViewerDialog/index.js +0 -7
- package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
- package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
- package/es/components/SignInCallbackHandler/index.js +0 -7
- package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
- package/es/components/SilentRenewCallbackHandler/index.js +0 -7
- package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
- package/es/components/SnackbarProvider/index.js +0 -7
- package/es/components/TopBar/AboutDialog.js +0 -456
- package/es/components/TopBar/GridLogo.js +0 -73
- package/es/components/TopBar/TopBar.js +0 -487
- package/es/components/TopBar/index.js +0 -9
- package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
- package/es/components/TreeViewFinder/index.js +0 -7
- package/es/components/images/powsybl_logo.svg +0 -35
- package/es/components/react-hook-form/autocomplete-input.js +0 -110
- package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
- package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
- package/es/components/react-hook-form/booleans/switch-input.js +0 -28
- package/es/components/react-hook-form/error-management/error-input.js +0 -50
- package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
- package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
- package/es/components/react-hook-form/numbers/float-input.js +0 -105
- package/es/components/react-hook-form/numbers/integer-input.js +0 -35
- package/es/components/react-hook-form/numbers/utils.js +0 -6
- package/es/components/react-hook-form/radio-input.js +0 -55
- package/es/components/react-hook-form/select-input.js +0 -40
- package/es/components/react-hook-form/slider-input.js +0 -48
- package/es/components/react-hook-form/text-input.js +0 -100
- package/es/components/react-hook-form/utils/cancel-button.js +0 -28
- package/es/components/react-hook-form/utils/field-label.js +0 -15
- package/es/components/react-hook-form/utils/functions.js +0 -42
- package/es/components/react-hook-form/utils/submit-button.js +0 -29
- package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
- package/es/components/translations/card-error-boundary-en.js +0 -13
- package/es/components/translations/card-error-boundary-fr.js +0 -13
- package/es/components/translations/common-button-en.js +0 -12
- package/es/components/translations/common-button-fr.js +0 -12
- package/es/components/translations/element-search-en.js +0 -12
- package/es/components/translations/element-search-fr.js +0 -12
- package/es/components/translations/equipment-search-en.js +0 -26
- package/es/components/translations/equipment-search-fr.js +0 -26
- package/es/components/translations/flat-parameters-en.js +0 -13
- package/es/components/translations/flat-parameters-fr.js +0 -13
- package/es/components/translations/inputs-en.js +0 -25
- package/es/components/translations/inputs-fr.js +0 -25
- package/es/components/translations/login-en.js +0 -19
- package/es/components/translations/login-fr.js +0 -19
- package/es/components/translations/multiple-selection-dialog-en.js +0 -13
- package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
- package/es/components/translations/report-viewer-en.js +0 -13
- package/es/components/translations/report-viewer-fr.js +0 -13
- package/es/components/translations/table-en.js +0 -11
- package/es/components/translations/table-fr.js +0 -11
- package/es/components/translations/top-bar-en.js +0 -32
- package/es/components/translations/top-bar-fr.js +0 -32
- package/es/components/translations/treeview-finder-en.js +0 -17
- package/es/components/translations/treeview-finder-fr.js +0 -17
- package/es/hooks/useDebounce.js +0 -26
- package/es/hooks/useIntlRef.js +0 -22
- package/es/hooks/useSnackMessage.js +0 -81
- package/es/index.js +0 -71
- package/es/utils/AuthService.js +0 -312
- package/es/utils/ElementType.js +0 -49
- package/es/utils/EquipmentType.js +0 -133
- package/es/utils/UserManagerMock.js +0 -81
- package/es/utils/actions.js +0 -65
- package/es/utils/algos.js +0 -29
- package/es/utils/styles.js +0 -35
package/README.md
CHANGED
|
@@ -11,23 +11,6 @@ If you want to test your library integration with a consumer application my-app
|
|
|
11
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
12
|
to `@gridsuite/commons-ui:"file:../path/to/the/commons-ui"` then type `npm install` `npm start`.
|
|
13
13
|
|
|
14
|
-
NOTE: if you have the following error:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
Module not found: Can't resolve '@svgr/webpack'
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
You can try to temporarily regenerate a package-lock.json in the consumer application (`cd my-app/;` `rm -rf node_modules;` `rm package-lock.json;` `npm install;`). Or temporarily add
|
|
21
|
-
"@svgr/webpack" to your consummer application package.json dependencies
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@svgr/webpack": "^4.3.0",
|
|
26
|
-
...
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
and then rerun npm install.
|
|
31
14
|
|
|
32
15
|
#### For integrators
|
|
33
16
|
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback } from "react";
|
|
3
|
+
import { Routes, Route, Navigate } from "react-router-dom";
|
|
4
|
+
import SignInCallbackHandler from "../SignInCallbackHandler/SignInCallbackHandler.js";
|
|
5
|
+
import { handleSigninCallback, handleSilentRenewCallback, login, logout } from "../../utils/AuthService.js";
|
|
6
|
+
import SilentRenewCallbackHandler from "../SilentRenewCallbackHandler/SilentRenewCallbackHandler.js";
|
|
7
|
+
import Login from "../Login/Login.js";
|
|
8
|
+
import Logout from "../Login/Logout.js";
|
|
9
|
+
import { Grid, Alert, AlertTitle } from "@mui/material";
|
|
10
|
+
import { FormattedMessage } from "react-intl";
|
|
11
|
+
const AuthenticationRouter = ({
|
|
12
|
+
userManager,
|
|
13
|
+
signInCallbackError,
|
|
14
|
+
authenticationRouterError,
|
|
15
|
+
showAuthenticationRouterLogin,
|
|
16
|
+
dispatch,
|
|
17
|
+
navigate,
|
|
18
|
+
location
|
|
19
|
+
}) => {
|
|
20
|
+
const handleSigninCallbackClosure = useCallback(
|
|
21
|
+
() => handleSigninCallback(dispatch, navigate, userManager.instance),
|
|
22
|
+
[dispatch, navigate, userManager.instance]
|
|
23
|
+
);
|
|
24
|
+
const handleSilentRenewCallbackClosure = useCallback(
|
|
25
|
+
() => handleSilentRenewCallback(userManager.instance),
|
|
26
|
+
[userManager.instance]
|
|
27
|
+
);
|
|
28
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsxs(
|
|
29
|
+
Grid,
|
|
30
|
+
{
|
|
31
|
+
container: true,
|
|
32
|
+
alignContent: "center",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
direction: "column",
|
|
35
|
+
children: [
|
|
36
|
+
userManager.error !== null && /* @__PURE__ */ jsxs("h1", { children: [
|
|
37
|
+
"Error : Getting userManager; ",
|
|
38
|
+
userManager.error
|
|
39
|
+
] }),
|
|
40
|
+
signInCallbackError !== null && /* @__PURE__ */ jsxs("h1", { children: [
|
|
41
|
+
"Error : SignIn Callback Error;",
|
|
42
|
+
signInCallbackError.message
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsxs(Routes, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
Route,
|
|
47
|
+
{
|
|
48
|
+
path: "sign-in-callback",
|
|
49
|
+
element: /* @__PURE__ */ jsx(
|
|
50
|
+
SignInCallbackHandler,
|
|
51
|
+
{
|
|
52
|
+
userManager: userManager.instance,
|
|
53
|
+
handleSignInCallback: handleSigninCallbackClosure
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
Route,
|
|
60
|
+
{
|
|
61
|
+
path: "silent-renew-callback",
|
|
62
|
+
element: /* @__PURE__ */ jsx(
|
|
63
|
+
SilentRenewCallbackHandler,
|
|
64
|
+
{
|
|
65
|
+
userManager: userManager.instance,
|
|
66
|
+
handleSilentRenewCallback: handleSilentRenewCallbackClosure
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
Route,
|
|
73
|
+
{
|
|
74
|
+
path: "logout-callback",
|
|
75
|
+
element: /* @__PURE__ */ jsx(Navigate, { to: "/" })
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
Route,
|
|
80
|
+
{
|
|
81
|
+
path: "*",
|
|
82
|
+
element: showAuthenticationRouterLogin && authenticationRouterError == null && /* @__PURE__ */ jsx(
|
|
83
|
+
Login,
|
|
84
|
+
{
|
|
85
|
+
disabled: userManager.instance === null,
|
|
86
|
+
onLoginClick: () => login(location, userManager.instance)
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] }),
|
|
92
|
+
authenticationRouterError !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
94
|
+
Logout,
|
|
95
|
+
{
|
|
96
|
+
disabled: userManager.instance === null,
|
|
97
|
+
onLogoutClick: () => logout(location, userManager.instance)
|
|
98
|
+
}
|
|
99
|
+
) }),
|
|
100
|
+
/* @__PURE__ */ jsxs(Grid, { item: true, xs: 4, children: [
|
|
101
|
+
authenticationRouterError.logoutError != null && /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
|
|
102
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: "login/errorInLogout" }) }),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
FormattedMessage,
|
|
105
|
+
{
|
|
106
|
+
id: "login/errorInLogoutMessage",
|
|
107
|
+
values: {
|
|
108
|
+
userName: authenticationRouterError.userName
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx("p", { children: authenticationRouterError.logoutError.error.message })
|
|
113
|
+
] }),
|
|
114
|
+
(authenticationRouterError == null ? void 0 : authenticationRouterError.userValidationError) != null && /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
|
|
115
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: "login/errorInUserValidation" }) }),
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
FormattedMessage,
|
|
118
|
+
{
|
|
119
|
+
id: "login/errorInUserValidationMessage",
|
|
120
|
+
values: {
|
|
121
|
+
userName: authenticationRouterError.userName
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsx("p", { children: authenticationRouterError.userValidationError.error.message })
|
|
126
|
+
] }),
|
|
127
|
+
(authenticationRouterError == null ? void 0 : authenticationRouterError.unauthorizedUserInfo) != null && /* @__PURE__ */ jsxs(Alert, { severity: "info", children: [
|
|
128
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: "login/unauthorizedAccess" }) }),
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
FormattedMessage,
|
|
131
|
+
{
|
|
132
|
+
id: "login/unauthorizedAccessMessage",
|
|
133
|
+
values: {
|
|
134
|
+
userName: authenticationRouterError.userName
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] })
|
|
139
|
+
] })
|
|
140
|
+
] })
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
) });
|
|
144
|
+
};
|
|
145
|
+
export {
|
|
146
|
+
AuthenticationRouter as default
|
|
147
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { styled, IconButton, Box, Card, CardHeader, CardContent, Typography, CardActions, Collapse } from "@mui/material";
|
|
4
|
+
import { Replay, ExpandMore as ExpandMore$1 } from "@mui/icons-material";
|
|
5
|
+
import { FormattedMessage } from "react-intl";
|
|
6
|
+
const ExpandMore = styled((props) => {
|
|
7
|
+
const { expand, ...other } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(IconButton, { ...other });
|
|
9
|
+
})(({ theme, expand }) => ({
|
|
10
|
+
transform: !expand ? "rotate(0deg)" : "rotate(180deg)",
|
|
11
|
+
marginLeft: "auto",
|
|
12
|
+
transition: theme.transitions.create("transform", {
|
|
13
|
+
duration: theme.transitions.duration.shortest
|
|
14
|
+
})
|
|
15
|
+
}));
|
|
16
|
+
class CardErrorBoundary extends React.Component {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this.state = {
|
|
20
|
+
hasError: false,
|
|
21
|
+
expanded: false,
|
|
22
|
+
error: void 0
|
|
23
|
+
};
|
|
24
|
+
this.handleExpandClick = this.handleExpandClick.bind(this);
|
|
25
|
+
this.handleReloadClick = this.handleReloadClick.bind(this);
|
|
26
|
+
}
|
|
27
|
+
static getDerivedStateFromError(error) {
|
|
28
|
+
return { hasError: true, error };
|
|
29
|
+
}
|
|
30
|
+
componentDidCatch(error, errorInfo) {
|
|
31
|
+
console.error("CardErrorBoundary caught: ", error, errorInfo);
|
|
32
|
+
}
|
|
33
|
+
handleExpandClick() {
|
|
34
|
+
this.setState((state) => ({ expanded: !state.expanded }));
|
|
35
|
+
}
|
|
36
|
+
handleReloadClick() {
|
|
37
|
+
this.setState((state) => ({
|
|
38
|
+
hasError: false,
|
|
39
|
+
expanded: false,
|
|
40
|
+
error: void 0
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
if (this.state.hasError) {
|
|
45
|
+
const { error, expanded } = this.state;
|
|
46
|
+
return /* @__PURE__ */ jsx(Box, { sx: { p: 4 }, children: /* @__PURE__ */ jsxs(Card, { sx: { mx: "auto", maxWidth: 600 }, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
CardHeader,
|
|
49
|
+
{
|
|
50
|
+
title: /* @__PURE__ */ jsx(
|
|
51
|
+
FormattedMessage,
|
|
52
|
+
{
|
|
53
|
+
id: "card_error_boundary/title",
|
|
54
|
+
defaultMessage: "Sorry, Unexpected error :("
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: /* @__PURE__ */ jsx(
|
|
60
|
+
FormattedMessage,
|
|
61
|
+
{
|
|
62
|
+
id: "card_error_boundary/content",
|
|
63
|
+
defaultMessage: "Please reload, or close and reopen this application, or contact support."
|
|
64
|
+
}
|
|
65
|
+
) }) }),
|
|
66
|
+
/* @__PURE__ */ jsxs(CardActions, { disableSpacing: true, children: [
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
IconButton,
|
|
69
|
+
{
|
|
70
|
+
onClick: this.handleReloadClick,
|
|
71
|
+
"aria-label": "reload",
|
|
72
|
+
children: /* @__PURE__ */ jsx(Replay, {})
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
ExpandMore,
|
|
77
|
+
{
|
|
78
|
+
expand: expanded,
|
|
79
|
+
onClick: this.handleExpandClick,
|
|
80
|
+
"aria-expanded": expanded,
|
|
81
|
+
"aria-label": "show more",
|
|
82
|
+
children: /* @__PURE__ */ jsx(ExpandMore$1, {})
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ jsx(Collapse, { in: expanded, children: /* @__PURE__ */ jsxs(CardContent, { children: [
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
Typography,
|
|
89
|
+
{
|
|
90
|
+
variant: "body2",
|
|
91
|
+
color: "text.secondary",
|
|
92
|
+
children: /* @__PURE__ */ jsx(
|
|
93
|
+
FormattedMessage,
|
|
94
|
+
{
|
|
95
|
+
id: "card_error_boundary/expandederrorheader",
|
|
96
|
+
defaultMessage: "Error message (and see more information in the developper console):"
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error.message })
|
|
102
|
+
] }) })
|
|
103
|
+
] }) });
|
|
104
|
+
}
|
|
105
|
+
return this.props.children;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
CardErrorBoundary as default
|
|
110
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { Dialog, DialogContent, Autocomplete, TextField } from "@mui/material";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import { SearchOff, Search } from "@mui/icons-material";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
const ElementSearchDialog = (props) => {
|
|
8
|
+
const intl = useIntl();
|
|
9
|
+
const {
|
|
10
|
+
open,
|
|
11
|
+
onClose,
|
|
12
|
+
searchingLabel,
|
|
13
|
+
onSearchTermChange,
|
|
14
|
+
onSelectionChange,
|
|
15
|
+
elementsFound,
|
|
16
|
+
// [{ label: aLabel, id: anId }, ...]
|
|
17
|
+
renderElement,
|
|
18
|
+
searchTermDisabled,
|
|
19
|
+
searchTermDisableReason
|
|
20
|
+
} = props;
|
|
21
|
+
const [expanded, setExpanded] = useState(false);
|
|
22
|
+
const [value, setValue] = useState(
|
|
23
|
+
searchTermDisabled && searchTermDisableReason ? { label: searchTermDisableReason } : null
|
|
24
|
+
);
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setLoading(false);
|
|
28
|
+
}, [elementsFound]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!searchTermDisabled || !searchTermDisableReason) {
|
|
31
|
+
setValue(null);
|
|
32
|
+
} else {
|
|
33
|
+
setValue({ label: searchTermDisableReason });
|
|
34
|
+
}
|
|
35
|
+
}, [searchTermDisabled, searchTermDisableReason]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setValue((old) => !open ? null : old);
|
|
38
|
+
}, [open]);
|
|
39
|
+
const handleSearchTermChange = (term) => {
|
|
40
|
+
if (term) {
|
|
41
|
+
setLoading(true);
|
|
42
|
+
onSearchTermChange(term);
|
|
43
|
+
setExpanded(true);
|
|
44
|
+
setValue({ label: term });
|
|
45
|
+
} else {
|
|
46
|
+
setExpanded(false);
|
|
47
|
+
setValue(null);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const handleClose = useCallback(() => {
|
|
51
|
+
setValue(null);
|
|
52
|
+
setExpanded(false);
|
|
53
|
+
onClose();
|
|
54
|
+
}, [onClose]);
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
Dialog,
|
|
57
|
+
{
|
|
58
|
+
open,
|
|
59
|
+
onClose: handleClose,
|
|
60
|
+
disableRestoreFocus: true,
|
|
61
|
+
"aria-labelledby": "dialog-title-search",
|
|
62
|
+
fullWidth: true,
|
|
63
|
+
children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(
|
|
64
|
+
Autocomplete,
|
|
65
|
+
{
|
|
66
|
+
id: "element-search",
|
|
67
|
+
forcePopupIcon: false,
|
|
68
|
+
open: expanded,
|
|
69
|
+
onClose: () => {
|
|
70
|
+
setExpanded(false);
|
|
71
|
+
},
|
|
72
|
+
fullWidth: true,
|
|
73
|
+
freeSolo: true,
|
|
74
|
+
clearOnBlur: true,
|
|
75
|
+
onInputChange: (_event, value2) => {
|
|
76
|
+
if (!searchTermDisabled) {
|
|
77
|
+
handleSearchTermChange(value2);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
onChange: (_event, newValue, reason) => {
|
|
81
|
+
if (reason === "selectOption") {
|
|
82
|
+
onSelectionChange(newValue);
|
|
83
|
+
setValue(newValue);
|
|
84
|
+
} else {
|
|
85
|
+
setValue(null);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
getOptionLabel: (option) => option.label,
|
|
89
|
+
isOptionEqualToValue: (option, value2) => option.id === value2.id,
|
|
90
|
+
options: loading ? [] : elementsFound,
|
|
91
|
+
loading,
|
|
92
|
+
autoHighlight: true,
|
|
93
|
+
noOptionsText: intl.formatMessage({
|
|
94
|
+
id: "element_search/noResult"
|
|
95
|
+
}),
|
|
96
|
+
renderOption: (optionProps, element, { inputValue }) => renderElement({
|
|
97
|
+
...optionProps,
|
|
98
|
+
element,
|
|
99
|
+
inputValue,
|
|
100
|
+
onClose: handleClose
|
|
101
|
+
}),
|
|
102
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
103
|
+
TextField,
|
|
104
|
+
{
|
|
105
|
+
autoFocus: true,
|
|
106
|
+
...params,
|
|
107
|
+
label: searchingLabel || intl.formatMessage({
|
|
108
|
+
id: "element_search/label"
|
|
109
|
+
}),
|
|
110
|
+
InputProps: {
|
|
111
|
+
...params.InputProps,
|
|
112
|
+
startAdornment: /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
113
|
+
searchTermDisabled ? /* @__PURE__ */ jsx(SearchOff, { color: "disabled" }) : /* @__PURE__ */ jsx(Search, { color: "disabled" }),
|
|
114
|
+
params.InputProps.startAdornment
|
|
115
|
+
] })
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
value,
|
|
120
|
+
disabled: searchTermDisabled
|
|
121
|
+
}
|
|
122
|
+
) })
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
ElementSearchDialog.propTypes = {
|
|
127
|
+
open: PropTypes.bool.isRequired,
|
|
128
|
+
onClose: PropTypes.func.isRequired,
|
|
129
|
+
searchingLabel: PropTypes.string,
|
|
130
|
+
onSearchTermChange: PropTypes.func.isRequired,
|
|
131
|
+
onSelectionChange: PropTypes.func.isRequired,
|
|
132
|
+
elementsFound: PropTypes.array.isRequired,
|
|
133
|
+
renderElement: PropTypes.func.isRequired,
|
|
134
|
+
searchTermDisabled: PropTypes.bool,
|
|
135
|
+
searchTermDisableReason: PropTypes.string
|
|
136
|
+
};
|
|
137
|
+
export {
|
|
138
|
+
ElementSearchDialog as default
|
|
139
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "./element-search-dialog.js";
|
|
3
|
+
import { TagRenderer } from "./tag-renderer.js";
|
|
4
|
+
import match from "autosuggest-highlight/match";
|
|
5
|
+
import parse from "autosuggest-highlight/parse";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { FormattedMessage } from "react-intl";
|
|
8
|
+
import { OverflowableText } from "../OverflowableText/overflowable-text.js";
|
|
9
|
+
import "react";
|
|
10
|
+
import { EQUIPMENT_TYPE } from "../../utils/EquipmentType.js";
|
|
11
|
+
import { Box } from "@mui/material";
|
|
12
|
+
import { mergeSx } from "../../utils/styles.js";
|
|
13
|
+
const EquipmentItem = ({
|
|
14
|
+
inputValue,
|
|
15
|
+
suffixRenderer = TagRenderer,
|
|
16
|
+
element,
|
|
17
|
+
showsJustText = false,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
let matches = match(element.label, inputValue, {
|
|
22
|
+
insideWords: true,
|
|
23
|
+
findAllOccurrences: true
|
|
24
|
+
});
|
|
25
|
+
let parts = parse(element.label, matches);
|
|
26
|
+
return /* @__PURE__ */ jsx("li", { ...props, children: /* @__PURE__ */ jsxs(
|
|
27
|
+
Box,
|
|
28
|
+
{
|
|
29
|
+
className: (_a = props.classes) == null ? void 0 : _a.equipmentOption,
|
|
30
|
+
sx: (_b = props.styles) == null ? void 0 : _b.equipmentOption,
|
|
31
|
+
children: [
|
|
32
|
+
!showsJustText && /* @__PURE__ */ jsx(
|
|
33
|
+
Box,
|
|
34
|
+
{
|
|
35
|
+
component: "span",
|
|
36
|
+
className: clsx(
|
|
37
|
+
(_c = props.classes) == null ? void 0 : _c.equipmentTag,
|
|
38
|
+
(_d = props.classes) == null ? void 0 : _d.equipmentTypeTag
|
|
39
|
+
),
|
|
40
|
+
sx: mergeSx(
|
|
41
|
+
(_e = props.styles) == null ? void 0 : _e.equipmentTag,
|
|
42
|
+
(_f = props.styles) == null ? void 0 : _f.equipmentTypeTag
|
|
43
|
+
),
|
|
44
|
+
children: /* @__PURE__ */ jsx(
|
|
45
|
+
FormattedMessage,
|
|
46
|
+
{
|
|
47
|
+
id: EQUIPMENT_TYPE[element.type].tagLabel
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
OverflowableText,
|
|
54
|
+
{
|
|
55
|
+
text: parts.map((e) => e.text).join(),
|
|
56
|
+
className: (_g = props.classes) == null ? void 0 : _g.result,
|
|
57
|
+
sx: (_h = props.styles) == null ? void 0 : _h.result,
|
|
58
|
+
children: parts.map((part, index) => /* @__PURE__ */ jsx(
|
|
59
|
+
"span",
|
|
60
|
+
{
|
|
61
|
+
style: {
|
|
62
|
+
fontWeight: part.highlight ? "bold" : "inherit"
|
|
63
|
+
},
|
|
64
|
+
children: part.text
|
|
65
|
+
},
|
|
66
|
+
index
|
|
67
|
+
))
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
!showsJustText && suffixRenderer({ props, element })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
) }, element.key);
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
EquipmentItem
|
|
77
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { OverflowableText } from "../OverflowableText/overflowable-text.js";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import "react";
|
|
5
|
+
import { EQUIPMENT_TYPE } from "../../utils/EquipmentType.js";
|
|
6
|
+
import PropTypes from "prop-types";
|
|
7
|
+
import { mergeSx } from "../../utils/styles.js";
|
|
8
|
+
const TagRenderer = ({ props, element }) => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
if (element.type !== EQUIPMENT_TYPE.SUBSTATION.name && element.type !== EQUIPMENT_TYPE.VOLTAGE_LEVEL.name) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
OverflowableText,
|
|
13
|
+
{
|
|
14
|
+
text: element.voltageLevelLabel,
|
|
15
|
+
className: clsx(
|
|
16
|
+
(_a = props.classes) == null ? void 0 : _a.equipmentTag,
|
|
17
|
+
(_b = props.classes) == null ? void 0 : _b.equipmentVlTag
|
|
18
|
+
),
|
|
19
|
+
sx: mergeSx(
|
|
20
|
+
(_c = props.styles) == null ? void 0 : _c.equipmentTag,
|
|
21
|
+
(_d = props.styles) == null ? void 0 : _d.equipmentVlTag
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
27
|
+
};
|
|
28
|
+
TagRenderer.propTypes = {
|
|
29
|
+
element: PropTypes.object,
|
|
30
|
+
props: PropTypes.object
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
TagRenderer
|
|
34
|
+
};
|