pcm-shared-components 0.0.166 → 0.0.169
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.
|
@@ -8,6 +8,15 @@ import { createTheme, useTheme } from '@mui/material/styles';
|
|
|
8
8
|
import MoreIcon from "@mui/icons-material/MoreVert";
|
|
9
9
|
import GenericAppBarSubMenu from './components/GenericAppBarSubMenu';
|
|
10
10
|
import PropTypes from "prop-types";
|
|
11
|
+
const defaultState = {
|
|
12
|
+
appBarTitle: '',
|
|
13
|
+
showBackButton: true,
|
|
14
|
+
closeMenu: {
|
|
15
|
+
onClick: () => {},
|
|
16
|
+
name: ''
|
|
17
|
+
},
|
|
18
|
+
mainMenu: []
|
|
19
|
+
};
|
|
11
20
|
/**
|
|
12
21
|
* Generic App Bar component used to create dynamic top bar with dynamic menus.
|
|
13
22
|
*
|
|
@@ -25,6 +34,7 @@ import {GenericAppBar} from 'pcm-shared-components';
|
|
|
25
34
|
Has three main part to it:
|
|
26
35
|
*
|
|
27
36
|
* - **appBarTitle**: ```String``` controls title
|
|
37
|
+
* - **showBackButton**: ```Bool``` controls if we show the back arrow button beside the title
|
|
28
38
|
* - **closeMenu**: ```Object``` controls the back button
|
|
29
39
|
* - onClick: ```Callback```
|
|
30
40
|
* - name: ```String```
|
|
@@ -41,6 +51,7 @@ Has three main part to it:
|
|
|
41
51
|
``` js
|
|
42
52
|
{
|
|
43
53
|
appBarTitle: '',
|
|
54
|
+
showBackButton: true,
|
|
44
55
|
|
|
45
56
|
closeMenu:{
|
|
46
57
|
onClick : callback,
|
|
@@ -80,7 +91,11 @@ export const GenericAppBar = props => {
|
|
|
80
91
|
const {
|
|
81
92
|
appBarMenu,
|
|
82
93
|
theme
|
|
83
|
-
} = props
|
|
94
|
+
} = { ...props,
|
|
95
|
+
appBarMenu: { ...defaultState,
|
|
96
|
+
...props.appBarMenu
|
|
97
|
+
}
|
|
98
|
+
};
|
|
84
99
|
const compTheme = theme ? theme : useTheme();
|
|
85
100
|
const defaultTheme = createTheme(compTheme);
|
|
86
101
|
const useStyles = makeStyles(() => ({
|
|
@@ -230,8 +245,7 @@ export const GenericAppBar = props => {
|
|
|
230
245
|
key: `main_sub_items_${new Date()}`
|
|
231
246
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
232
247
|
title: menu.name
|
|
233
|
-
}, menu.isButton ? /*#__PURE__*/React.createElement(Button
|
|
234
|
-
, {
|
|
248
|
+
}, menu.isButton ? /*#__PURE__*/React.createElement(Button, {
|
|
235
249
|
startIcon: menu.icon,
|
|
236
250
|
color: "inherit",
|
|
237
251
|
"aria-owns": "menu-appbar",
|
|
@@ -294,12 +308,7 @@ export const GenericAppBar = props => {
|
|
|
294
308
|
marginRight: 24
|
|
295
309
|
}
|
|
296
310
|
})))));
|
|
297
|
-
};
|
|
298
|
-
// <div className='flex flex-row'>
|
|
299
|
-
// <MainItems key='main_item_id' />
|
|
300
|
-
// </div>
|
|
301
|
-
// );
|
|
302
|
-
|
|
311
|
+
};
|
|
303
312
|
|
|
304
313
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
305
314
|
theme: defaultTheme
|
|
@@ -310,7 +319,7 @@ export const GenericAppBar = props => {
|
|
|
310
319
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
311
320
|
variant: "dense",
|
|
312
321
|
className: classes.gutters
|
|
313
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CloseContext, appBarMenu.closeMenu)), /*#__PURE__*/React.createElement(TitleContext, null), /*#__PURE__*/React.createElement("div", {
|
|
322
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, appBarMenu.showBackButton && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CloseContext, appBarMenu.closeMenu)), /*#__PURE__*/React.createElement(TitleContext, null), /*#__PURE__*/React.createElement("div", {
|
|
314
323
|
className: classes.grow
|
|
315
324
|
}), /*#__PURE__*/React.createElement("div", {
|
|
316
325
|
className: classes.sectionDesktop
|
|
@@ -325,7 +334,7 @@ export const GenericAppBar = props => {
|
|
|
325
334
|
export default GenericAppBar; // Specifies the default values for the props:
|
|
326
335
|
|
|
327
336
|
GenericAppBar.defaultProps = {
|
|
328
|
-
appBarMenu:
|
|
337
|
+
appBarMenu: defaultState,
|
|
329
338
|
theme: undefined
|
|
330
339
|
}; //Define the types associated with the prop types
|
|
331
340
|
|
|
@@ -14,9 +14,11 @@ export const GenericDialogWindow = props => {
|
|
|
14
14
|
component,
|
|
15
15
|
data,
|
|
16
16
|
showSaveButton = false,
|
|
17
|
+
showBackButton = true,
|
|
17
18
|
dialogSize = 'false',
|
|
18
19
|
appBarMenu = undefined,
|
|
19
20
|
fullWidth = false,
|
|
21
|
+
closeOnBackdropClick,
|
|
20
22
|
theme
|
|
21
23
|
} = props;
|
|
22
24
|
const compTheme = theme ? theme : useTheme();
|
|
@@ -134,19 +136,25 @@ export const GenericDialogWindow = props => {
|
|
|
134
136
|
//Need to re-apply any onClick override to ensure they are still properly set by what was overridden from the child component.
|
|
135
137
|
// setOverrides();
|
|
136
138
|
}
|
|
137
|
-
}, [appBarMenu, can_save, showSaveButton, save_button_label]);
|
|
139
|
+
}, [appBarMenu, can_save, showSaveButton, save_button_label]);
|
|
140
|
+
|
|
141
|
+
const handleOnClose = (event, reason) => {
|
|
142
|
+
if (reason !== 'backdropClick' || closeOnBackdropClick) {
|
|
143
|
+
closeDialog();
|
|
144
|
+
}
|
|
145
|
+
}; // -----------------------------------------
|
|
138
146
|
// Note make sure to include disableEnforceFocus or else I'll have infinite error/warnings on Uncaught RangeError.
|
|
139
147
|
// I think this error comes only after a state has changed when multiple dialog windows are open they are fighting for focus.
|
|
140
148
|
// Bug: https://github.com/mui/material-ui/issues/8741
|
|
141
149
|
// -----------------------------------------
|
|
142
150
|
|
|
151
|
+
|
|
143
152
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
144
153
|
theme: defaultTheme
|
|
145
154
|
}, /*#__PURE__*/React.createElement(Dialog, {
|
|
146
155
|
disableEnforceFocus: true,
|
|
147
156
|
open: open,
|
|
148
|
-
onClose:
|
|
149
|
-
onBackdropClick: false,
|
|
157
|
+
onClose: handleOnClose,
|
|
150
158
|
maxWidth: dialogSize,
|
|
151
159
|
fullScreen: dialogSize && !fullWidth ? false : true,
|
|
152
160
|
fullWidth: fullWidth,
|
|
@@ -190,9 +198,11 @@ GenericDialogWindow.defaultProps = {
|
|
|
190
198
|
component: undefined,
|
|
191
199
|
data: undefined,
|
|
192
200
|
showSaveButton: true,
|
|
201
|
+
showBackButton: true,
|
|
193
202
|
appBarMenu: undefined,
|
|
194
203
|
dialogSize: false,
|
|
195
204
|
fullWidth: false,
|
|
205
|
+
closeOnBackdropClick: false,
|
|
196
206
|
theme: undefined
|
|
197
207
|
};
|
|
198
208
|
GenericDialogWindow.propTypes = {
|
|
@@ -208,6 +218,9 @@ GenericDialogWindow.propTypes = {
|
|
|
208
218
|
/** To display or hide the save button on the dialog */
|
|
209
219
|
showSaveButton: PropTypes.bool,
|
|
210
220
|
|
|
221
|
+
/** To display or hide the back button in the top left corner */
|
|
222
|
+
showBackButton: PropTypes.bool,
|
|
223
|
+
|
|
211
224
|
/** Same props as the GenericAppBar component... */
|
|
212
225
|
appBarMenu: PropTypes.object,
|
|
213
226
|
|
|
@@ -217,6 +230,9 @@ GenericDialogWindow.propTypes = {
|
|
|
217
230
|
/**If true, the dialog stretches to maxWidth. Notice that the dialog width grow is limited by the default margin. */
|
|
218
231
|
fullWidth: PropTypes.bool,
|
|
219
232
|
|
|
233
|
+
/**Determines if the dialog window will close when the user clicks on the backdrop area */
|
|
234
|
+
closeOnBackdropClick: PropTypes.bool,
|
|
235
|
+
|
|
220
236
|
/** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
|
|
221
237
|
theme: PropTypes.object
|
|
222
238
|
};
|