@gridsuite/commons-ui 0.46.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 -53
  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,467 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect, useCallback } from "react";
3
+ import { useTheme, Dialog, useMediaQuery, DialogTitle, Collapse, Alert, Box, Fade, CircularProgress, Typography, DialogContent, Accordion, AccordionSummary, AccordionDetails, Grid, DialogActions, Button, Tooltip, Zoom, Stack, tooltipClasses } from "@mui/material";
4
+ import { LoadingButton } from "@mui/lab";
5
+ import { Refresh, ExpandMore, Gavel, Apps, WidgetsOutlined, DnsOutlined, QuestionMark } from "@mui/icons-material";
6
+ import { FormattedMessage } from "react-intl";
7
+ import PropTypes from "prop-types";
8
+ import { LogoText } from "./GridLogo.js";
9
+ const styles = {
10
+ general: {
11
+ ".MuiAccordion-root": {
12
+ //dunno why the theme has the background as black in dark mode
13
+ bgcolor: "unset"
14
+ }
15
+ },
16
+ mainSection: { height: "5em" },
17
+ logoSection: {
18
+ display: "flex",
19
+ alignItems: "center",
20
+ justifyContent: "center"
21
+ },
22
+ mainInfos: {
23
+ textAlign: "center",
24
+ marginTop: 0
25
+ },
26
+ versionField: (isUnknown) => isUnknown ? {
27
+ fontSize: "1.5em",
28
+ fontWeight: "bold"
29
+ } : {
30
+ fontStyle: "italic"
31
+ },
32
+ detailsSection: {
33
+ ".MuiAccordionSummary-content > .MuiSvgIcon-root": {
34
+ marginRight: "0.5rem"
35
+ }
36
+ }
37
+ };
38
+ function getGlobalVersion(fnPromise, type, setData, setLoader) {
39
+ if (fnPromise) {
40
+ console.debug("Getting", type, "global version...");
41
+ return new Promise((resolve, reject) => {
42
+ if (setLoader) {
43
+ setLoader(true);
44
+ }
45
+ resolve();
46
+ }).then(() => fnPromise()).then(
47
+ (value) => {
48
+ console.debug(type, "global version is", value);
49
+ setData(value ?? null);
50
+ },
51
+ (reason) => {
52
+ console.debug(
53
+ type,
54
+ "global version isn't available",
55
+ reason
56
+ );
57
+ setData(null);
58
+ }
59
+ ).finally(() => {
60
+ if (setLoader) {
61
+ setLoader(false);
62
+ }
63
+ });
64
+ } else {
65
+ console.debug("No getter for global version");
66
+ setData(null);
67
+ }
68
+ }
69
+ const moduleTypeSort = {
70
+ app: 1,
71
+ server: 10,
72
+ other: 20
73
+ };
74
+ function compareModules(c1, c2) {
75
+ return [moduleTypeSort[c1.type] || 100] - [moduleTypeSort[c2.type] || 100] || (c1.name || "").localeCompare(c2.name || "");
76
+ }
77
+ const AboutDialog = ({
78
+ open,
79
+ onClose,
80
+ globalVersionPromise,
81
+ appName,
82
+ appVersion,
83
+ appGitTag,
84
+ appLicense,
85
+ additionalModulesPromise
86
+ }) => {
87
+ const theme = useTheme();
88
+ const [isRefreshing, setRefreshState] = useState(false);
89
+ const [loadingGlobalVersion, setLoadingGlobalVersion] = useState(false);
90
+ const [showGlobalVersion, setShowGlobalVersion] = useState(false);
91
+ const [initialGlobalVersion, setInitialGlobalVersion] = useState(void 0);
92
+ useEffect(() => {
93
+ if (initialGlobalVersion === void 0) {
94
+ getGlobalVersion(
95
+ globalVersionPromise,
96
+ "Initial",
97
+ setInitialGlobalVersion,
98
+ void 0
99
+ );
100
+ }
101
+ }, [globalVersionPromise, initialGlobalVersion]);
102
+ const [actualGlobalVersion, setActualGlobalVersion] = useState(null);
103
+ useEffect(() => {
104
+ if (open) {
105
+ getGlobalVersion(
106
+ globalVersionPromise,
107
+ "Actual",
108
+ setActualGlobalVersion,
109
+ (loading) => {
110
+ setLoadingGlobalVersion(loading);
111
+ setShowGlobalVersion(false);
112
+ }
113
+ );
114
+ }
115
+ }, [open, globalVersionPromise]);
116
+ const [loadingAdditionalModules, setLoadingAdditionalModules] = useState(false);
117
+ const [modules, setModules] = useState(null);
118
+ useEffect(() => {
119
+ if (open) {
120
+ const currentApp = {
121
+ name: `Grid${appName}`,
122
+ type: "app",
123
+ version: appVersion,
124
+ gitTag: appGitTag,
125
+ license: appLicense
126
+ };
127
+ (additionalModulesPromise ? Promise.resolve(setLoadingAdditionalModules(true)).then(
128
+ () => additionalModulesPromise()
129
+ ) : Promise.reject(new Error("no getter"))).then(
130
+ (values) => Array.isArray(values) ? values : [],
131
+ (reason) => []
132
+ ).then((values) => {
133
+ setModules([currentApp, ...values]);
134
+ }).finally(() => setLoadingAdditionalModules(false));
135
+ }
136
+ }, [
137
+ open,
138
+ additionalModulesPromise,
139
+ appName,
140
+ appVersion,
141
+ appGitTag,
142
+ appLicense
143
+ ]);
144
+ const handleClose = useCallback(() => {
145
+ if (onClose) {
146
+ onClose();
147
+ }
148
+ }, [onClose]);
149
+ return /* @__PURE__ */ jsxs(
150
+ Dialog,
151
+ {
152
+ onClose: handleClose,
153
+ open,
154
+ fullWidth: true,
155
+ maxWidth: "md",
156
+ fullScreen: useMediaQuery(theme.breakpoints.down("md")),
157
+ sx: styles.general,
158
+ "aria-labelledby": "alert-dialog-title",
159
+ "aria-describedby": "alert-dialog-description",
160
+ TransitionProps: {
161
+ onExited: (node) => {
162
+ setModules(null);
163
+ setActualGlobalVersion(null);
164
+ }
165
+ },
166
+ children: [
167
+ /* @__PURE__ */ jsxs(DialogTitle, { id: "alert-dialog-title", children: [
168
+ /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/title" }),
169
+ initialGlobalVersion !== void 0 && initialGlobalVersion !== null && actualGlobalVersion !== null && initialGlobalVersion !== actualGlobalVersion && /* @__PURE__ */ jsx(Collapse, { in: open, children: /* @__PURE__ */ jsx(
170
+ Alert,
171
+ {
172
+ severity: "warning",
173
+ variant: "outlined",
174
+ action: /* @__PURE__ */ jsx(
175
+ LoadingButton,
176
+ {
177
+ color: "inherit",
178
+ size: "small",
179
+ startIcon: /* @__PURE__ */ jsx(Refresh, { fontSize: "small" }),
180
+ loadingPosition: "start",
181
+ loading: isRefreshing,
182
+ onClick: () => {
183
+ setRefreshState(true);
184
+ window.location.reload();
185
+ },
186
+ children: /* @__PURE__ */ jsx(FormattedMessage, { id: "refresh" })
187
+ }
188
+ ),
189
+ sx: { marginBottom: 2 },
190
+ children: /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/alert-running-old-version-msg" })
191
+ }
192
+ ) }),
193
+ /* @__PURE__ */ jsxs(Box, { sx: styles.mainSection, children: [
194
+ /* @__PURE__ */ jsx(Box, { sx: styles.logoSection, children: /* @__PURE__ */ jsx(
195
+ LogoText,
196
+ {
197
+ appName: "Suite",
198
+ appColor: theme.palette.grey["500"]
199
+ }
200
+ ) }),
201
+ /* @__PURE__ */ jsxs(Box, { sx: styles.mainInfos, children: [
202
+ /* @__PURE__ */ jsx(
203
+ Fade,
204
+ {
205
+ in: loadingGlobalVersion,
206
+ appear: true,
207
+ unmountOnExit: true,
208
+ onExited: (node) => setShowGlobalVersion(true),
209
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
210
+ }
211
+ ),
212
+ showGlobalVersion && /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(
213
+ FormattedMessage,
214
+ {
215
+ id: "about-dialog/version",
216
+ defaultMessage: "Version {version}",
217
+ values: {
218
+ version: /* @__PURE__ */ jsx(
219
+ Typography,
220
+ {
221
+ component: "span",
222
+ sx: styles.versionField(
223
+ !loadingGlobalVersion && actualGlobalVersion
224
+ ),
225
+ children: actualGlobalVersion || "unknown"
226
+ }
227
+ )
228
+ }
229
+ }
230
+ ) })
231
+ ] })
232
+ ] })
233
+ ] }),
234
+ /* @__PURE__ */ jsx(DialogContent, { id: "alert-dialog-description", children: /* @__PURE__ */ jsxs(Box, { sx: styles.detailsSection, children: [
235
+ /* @__PURE__ */ jsxs(
236
+ Accordion,
237
+ {
238
+ disableGutters: true,
239
+ variant: "outlined",
240
+ disabled: true,
241
+ sx: { display: "none" },
242
+ children: [
243
+ /* @__PURE__ */ jsxs(
244
+ AccordionSummary,
245
+ {
246
+ expandIcon: /* @__PURE__ */ jsx(ExpandMore, {}),
247
+ "aria-controls": "panel1-content",
248
+ id: "panel1-header",
249
+ children: [
250
+ /* @__PURE__ */ jsx(Gavel, { fontSize: "small" }),
251
+ /* @__PURE__ */ jsx(Typography, { sx: { width: "33%", flexShrink: 0 }, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/license" }) }),
252
+ /* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: appLicense })
253
+ ]
254
+ }
255
+ ),
256
+ /* @__PURE__ */ jsx(AccordionDetails, { children: "license app summary text" })
257
+ ]
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsxs(
261
+ Accordion,
262
+ {
263
+ disableGutters: true,
264
+ variant: "outlined",
265
+ TransitionProps: { unmountOnExit: true },
266
+ children: [
267
+ /* @__PURE__ */ jsxs(
268
+ AccordionSummary,
269
+ {
270
+ expandIcon: /* @__PURE__ */ jsx(ExpandMore, {}),
271
+ "aria-controls": "panel2-content",
272
+ id: "panel2-header",
273
+ children: [
274
+ /* @__PURE__ */ jsx(Apps, { fontSize: "small" }),
275
+ /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/modules-section" })
276
+ ]
277
+ }
278
+ ),
279
+ /* @__PURE__ */ jsx(AccordionDetails, { children: /* @__PURE__ */ jsx(Grid, { container: true, sx: { pl: 2 }, spacing: 1, children: loadingAdditionalModules ? /* @__PURE__ */ jsx(
280
+ Grid,
281
+ {
282
+ item: true,
283
+ xs: true,
284
+ display: "inline-flex",
285
+ justifyContent: "center",
286
+ children: /* @__PURE__ */ jsx(CircularProgress, { color: "inherit" })
287
+ }
288
+ ) : Array.isArray(modules) && /* @__PURE__ */ jsx(Fragment, { children: [...modules].sort(compareModules).map((module, idx) => /* @__PURE__ */ jsx(
289
+ Module,
290
+ {
291
+ type: module.type,
292
+ name: module.name,
293
+ version: module.version,
294
+ gitTag: module.gitTag,
295
+ license: module.license
296
+ },
297
+ `module-${idx}`
298
+ )) }) || /* @__PURE__ */ jsx(
299
+ Typography,
300
+ {
301
+ color: (theme2) => theme2.palette.error.main,
302
+ children: "Error"
303
+ }
304
+ ) }) })
305
+ ]
306
+ }
307
+ )
308
+ ] }) }),
309
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, { onClick: handleClose, autoFocus: true, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "close" }) }) })
310
+ ]
311
+ }
312
+ );
313
+ };
314
+ AboutDialog.propTypes = {
315
+ open: PropTypes.bool.isRequired,
316
+ onClose: PropTypes.func,
317
+ appName: PropTypes.string.isRequired,
318
+ appVersion: PropTypes.string,
319
+ appGitTag: PropTypes.string,
320
+ appLicense: PropTypes.string,
321
+ globalVersionPromise: PropTypes.func,
322
+ additionalModulesPromise: PropTypes.func
323
+ };
324
+ const moduleStyles = {
325
+ icons: {
326
+ flexGrow: 0,
327
+ position: "relative",
328
+ top: "4px",
329
+ flexShrink: 0
330
+ },
331
+ version: {
332
+ flexGrow: 0,
333
+ alignSelf: "flex-end",
334
+ flexShrink: 0
335
+ },
336
+ tooltip: (theme) => ({
337
+ [`& .${tooltipClasses.tooltip}`]: {
338
+ border: "1px solid #dadde9",
339
+ boxShadow: theme.shadows[1]
340
+ }
341
+ }),
342
+ tooltipDetails: {
343
+ display: "grid",
344
+ gridTemplateColumns: "max-content auto",
345
+ margin: 0,
346
+ dt: {
347
+ gridColumnStart: 1,
348
+ "&:after": {
349
+ content: '" :"'
350
+ }
351
+ },
352
+ dd: {
353
+ gridColumnStart: 2,
354
+ paddingLeft: "0.5em"
355
+ }
356
+ }
357
+ };
358
+ const ModuleTypesIcons = {
359
+ app: /* @__PURE__ */ jsx(
360
+ WidgetsOutlined,
361
+ {
362
+ sx: moduleStyles.icons,
363
+ fontSize: "small",
364
+ color: "primary"
365
+ }
366
+ ),
367
+ server: /* @__PURE__ */ jsx(
368
+ DnsOutlined,
369
+ {
370
+ sx: moduleStyles.icons,
371
+ fontSize: "small",
372
+ color: "secondary"
373
+ }
374
+ ),
375
+ other: /* @__PURE__ */ jsx(QuestionMark, { sx: moduleStyles.icons, fontSize: "small" })
376
+ };
377
+ function insensitiveCaseCompare(str, obj) {
378
+ return str.localeCompare(obj, void 0, {
379
+ sensitivity: "base"
380
+ });
381
+ }
382
+ function tooltipTypeLabel(type) {
383
+ if (insensitiveCaseCompare("app", type) === 0) {
384
+ return "about-dialog/module-tooltip-app";
385
+ } else if (insensitiveCaseCompare("server", type) === 0) {
386
+ return "about-dialog/module-tooltip-server";
387
+ } else {
388
+ return "about-dialog/module-tooltip-other";
389
+ }
390
+ }
391
+ const Module = ({ type, name, version, gitTag, license }) => {
392
+ return /* @__PURE__ */ jsx(
393
+ Grid,
394
+ {
395
+ item: true,
396
+ xs: 12,
397
+ sm: 6,
398
+ md: 4,
399
+ sx: {
400
+ ".MuiTypography-root": {
401
+ minWidth: "3em"
402
+ }
403
+ },
404
+ children: /* @__PURE__ */ jsx(
405
+ Tooltip,
406
+ {
407
+ TransitionComponent: Zoom,
408
+ enterDelay: 2500,
409
+ enterNextDelay: 350,
410
+ leaveDelay: 200,
411
+ placement: "bottom-start",
412
+ arrow: true,
413
+ sx: moduleStyles.tooltip,
414
+ title: /* @__PURE__ */ jsxs(Fragment, { children: [
415
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", children: name || "<?>" }),
416
+ /* @__PURE__ */ jsxs(Box, { component: "dl", sx: moduleStyles.tooltipDetails, children: [
417
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dt", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/label-type" }) }),
418
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dd", children: /* @__PURE__ */ jsx(FormattedMessage, { id: tooltipTypeLabel(type) }) }),
419
+ version && /* @__PURE__ */ jsxs(Fragment, { children: [
420
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dt", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/label-version" }) }),
421
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dd", children: version })
422
+ ] }),
423
+ gitTag && /* @__PURE__ */ jsxs(Fragment, { children: [
424
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dt", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "about-dialog/label-git-version" }) }),
425
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "dd", children: gitTag })
426
+ ] })
427
+ ] })
428
+ ] }),
429
+ children: /* @__PURE__ */ jsxs(
430
+ Stack,
431
+ {
432
+ direction: "row",
433
+ justifyContent: "flex-start",
434
+ alignItems: "baseline",
435
+ spacing: 1,
436
+ children: [
437
+ ModuleTypesIcons[type] || ModuleTypesIcons["other"],
438
+ /* @__PURE__ */ jsx(Typography, { display: "inline", noWrap: true, children: name || "<?>" }),
439
+ /* @__PURE__ */ jsx(
440
+ Typography,
441
+ {
442
+ variant: "caption",
443
+ color: (theme) => theme.palette.text.secondary,
444
+ display: "inline",
445
+ noWrap: true,
446
+ sx: moduleStyles.version,
447
+ children: gitTag || version || null
448
+ }
449
+ )
450
+ ]
451
+ }
452
+ )
453
+ }
454
+ )
455
+ }
456
+ );
457
+ };
458
+ Module.propTypes = {
459
+ type: PropTypes.string,
460
+ name: PropTypes.string,
461
+ version: PropTypes.string,
462
+ gitTag: PropTypes.string,
463
+ license: PropTypes.string
464
+ };
465
+ export {
466
+ AboutDialog as default
467
+ };
@@ -0,0 +1,71 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Box, Typography } from "@mui/material";
4
+ import { BrokenImage } from "@mui/icons-material";
5
+ import { mergeSx } from "../../utils/styles.js";
6
+ import PropTypes from "prop-types";
7
+ const styles = {
8
+ logo: {
9
+ flexShrink: 0,
10
+ width: 48,
11
+ height: 48,
12
+ marginBottom: "8px"
13
+ },
14
+ title: {
15
+ marginLeft: "18px"
16
+ },
17
+ clickable: {
18
+ cursor: "pointer"
19
+ }
20
+ };
21
+ const GridLogo = ({ appLogo, appName, appColor, onClick }) => {
22
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
23
+ /* @__PURE__ */ jsx(
24
+ Box,
25
+ {
26
+ sx: mergeSx(styles.logo, onClick && styles.clickable),
27
+ onClick,
28
+ children: appLogo || /* @__PURE__ */ jsx(BrokenImage, {})
29
+ }
30
+ ),
31
+ /* @__PURE__ */ jsx(
32
+ LogoText,
33
+ {
34
+ appName,
35
+ appColor,
36
+ onClick,
37
+ style: styles.title
38
+ }
39
+ )
40
+ ] });
41
+ };
42
+ GridLogo.propTypes = {
43
+ appLogo: PropTypes.element,
44
+ appName: PropTypes.string.isRequired,
45
+ appColor: PropTypes.string.isRequired,
46
+ onClick: PropTypes.func
47
+ };
48
+ const LogoText = ({ appName, appColor, style, onClick }) => {
49
+ return /* @__PURE__ */ jsxs(
50
+ Typography,
51
+ {
52
+ variant: "h4",
53
+ sx: mergeSx(style, onClick && styles.clickable),
54
+ onClick,
55
+ children: [
56
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: "bold" }, children: "Grid" }),
57
+ /* @__PURE__ */ jsx("span", { style: { color: appColor }, children: appName })
58
+ ]
59
+ }
60
+ );
61
+ };
62
+ LogoText.propTypes = {
63
+ appName: PropTypes.string.isRequired,
64
+ appColor: PropTypes.string.isRequired,
65
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
66
+ onClick: PropTypes.func
67
+ };
68
+ export {
69
+ LogoText,
70
+ GridLogo as default
71
+ };