pcm-shared-components 2.1.107 → 2.1.109

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 (28) hide show
  1. package/README.md +21 -1
  2. package/dist/components/Buttons/CustomFab/index.js +55 -88
  3. package/dist/components/Buttons/DropdownButton/index.js +1 -1
  4. package/dist/components/Buttons/ProductItemButton/index.js +164 -209
  5. package/dist/components/Buttons/TillButton/index.js +1 -1
  6. package/dist/components/Cards/EventCard/components/OpenEventViewAllImageDialog.js +3 -3
  7. package/dist/components/Cards/EventCard/index.js +1 -1
  8. package/dist/components/Date/DatePickerReactStyled/DateCalendar/index.js +1 -1
  9. package/dist/components/Date/DatePickerReactStyled/DateCalendar/storybook/index.stories.js +1 -1
  10. package/dist/components/Date/DatePickerReactStyled/DateRangeCalendar/index.js +1 -1
  11. package/dist/components/Date/DatePickerReactStyled/DateRangeCalendar/storybook/index.stories.js +1 -1
  12. package/dist/components/Date/DatePickerReactStyled/common/theme.js +0 -2
  13. package/dist/components/Date/PricingCalendar/index.js +0 -1
  14. package/dist/components/Dialogs/GenericAppBar/components/GenericAppBarSubMenu.js +3 -5
  15. package/dist/components/Dialogs/GenericAppBar/index.js +78 -171
  16. package/dist/components/Dialogs/GenericDialogWindow/index.js +2 -2
  17. package/dist/components/Dialogs/GenericDialogWindow/index_UPGRADED.js +226 -0
  18. package/dist/components/Drawing/ImageCanvasDraw/components/Controls.js +0 -1
  19. package/dist/components/Layout/SimpleTab/index.js +38 -62
  20. package/dist/components/Menus/ReusablePopupMenu/components/ReusableMenu.js +58 -58
  21. package/dist/components/Menus/ReusablePopupMenu/components/{GenericSubMenu.js → SubMenuInternal.js} +50 -80
  22. package/dist/components/Menus/ReusablePopupMenu/index copy.js +98 -0
  23. package/dist/components/Menus/ReusablePopupMenu/index.js +39 -44
  24. package/dist/components/PcSharedComponentThemeInheritor/index.js +11 -7
  25. package/dist/components/Platform/PlatformPaymentPlans/index.js +1 -1
  26. package/dist/locals/i18n.js +0 -1
  27. package/dist/styles/tailwind.css +1 -1
  28. package/package.json +14 -11
@@ -1,13 +1,10 @@
1
- import React, { Fragment, useState, useEffect } from "react";
2
- import { Typography, Button, Tooltip, IconButton, Toolbar, MenuItem, Menu, AppBar, Badge } from "@mui/material";
3
- import { makeStyles } from '@mui/styles';
1
+ import React, { useState, Fragment } from 'react';
2
+ import { Typography, Button, Tooltip, IconButton, Toolbar, MenuItem, Menu, AppBar, Divider } from '@mui/material';
3
+ import { ThemeProvider, createTheme, useTheme } from '@mui/material/styles';
4
4
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
5
- import Divider from '@mui/material/Divider';
6
- import { ThemeProvider } from '@mui/system';
7
- import { createTheme, useTheme } from '@mui/material/styles';
8
- import MoreIcon from "@mui/icons-material/MoreVert";
5
+ import MoreIcon from '@mui/icons-material/MoreVert';
9
6
  import GenericAppBarSubMenu from './components/GenericAppBarSubMenu';
10
- import PropTypes from "prop-types";
7
+ import PropTypes from 'prop-types';
11
8
  const defaultState = {
12
9
  appBarTitle: '',
13
10
  showBackButton: true,
@@ -20,72 +17,6 @@ const defaultState = {
20
17
 
21
18
  /**
22
19
  * Generic App Bar component used to create dynamic top bar with dynamic menus.
23
- *
24
- *
25
- * ## Importing the component
26
-
27
- ```//PitchCamp shared component
28
- import {GenericAppBar} from 'pcm-shared-components';
29
- ```
30
-
31
- ## Component Props
32
-
33
- * Expects only one parameters: **appBarMenu**
34
- *
35
- Has three main part to it:
36
- *
37
- * - **appBarTitle**: ```String``` controls title
38
- * - **showBackButton**: ```Bool``` controls if we show the back arrow button beside the title
39
- * - **closeMenu**: ```Object``` controls the back button
40
- * - onClick: ```Callback```
41
- * - name: ```String```
42
- * - **mainMenu**: Array controls the main menu items
43
- * - id: ```string``` uniquely identifies the menu so it can be manipulated by other processes
44
- * - onClick: ```Callback```
45
- * - icon: ```Icon```
46
- * - name: ```String```
47
- * - isButton: ```Bool``` controls if the menu is displayed as a Button or and IconButton default is IconButton
48
- * - hideMenu: ```Bool``` controls if the menu item is displayed or not
49
- * - displayDivider: ```Bool``` display a divider after the menu.
50
- * - subMenu: ```Array``` of menus, same structure as the ```mainMenu```
51
- *
52
- ``` js
53
- {
54
- appBarTitle: '',
55
- showBackButton: true,
56
-
57
- closeMenu:{
58
- onClick : callback,
59
- name: 'Any tooltip'
60
- },
61
-
62
- mainMenu: [
63
- {
64
- onClick: callback,
65
- icon: <Icon/>,
66
- name: 'Menu Name',
67
- isButton: true,
68
- hideMenu: false,
69
- displayDivider: true,
70
- subMenu:[
71
- {
72
- onClick: callback,
73
- icon: <Icon />,
74
- name: 'Sub Menu Name',
75
- },
76
- {
77
- ...
78
- },
79
- ]
80
- },
81
- {
82
- ...
83
- },
84
- ]
85
- }
86
- ```
87
-
88
- *
89
20
  */
90
21
  export const GenericAppBar = props => {
91
22
  const {
@@ -98,91 +29,56 @@ export const GenericAppBar = props => {
98
29
  ...props.appBarMenu
99
30
  }
100
31
  };
101
- const compTheme = theme ? theme : useTheme();
102
- const defaultTheme = createTheme(compTheme);
103
- const useStyles = makeStyles(() => ({
104
- root: {
105
- flexGrow: 1
106
- },
107
- menuButton: {
108
- marginLeft: -18,
109
- fontSize: 20
110
- },
111
- appContextMenu: {
112
- background: "#58524c"
113
- },
114
- grow: {
115
- flexGrow: 1
116
- },
117
- divider: {
118
- borderLeft: "0.1em solid #aeaeae",
119
- padding: "0.5em",
120
- margin: "10px 10px 10px 10px",
121
- height: 5
122
- },
123
- mobile_divider: {
124
- borderBottom: "0.1em solid #aeaeae",
125
- width: "100%"
126
- },
127
- sectionDesktop: {
128
- display: "none",
129
- [compTheme.breakpoints.up("md")]: {
130
- display: "flex"
131
- }
132
- },
133
- sectionMobile: {
134
- display: "flex",
135
- [compTheme.breakpoints.up("md")]: {
136
- display: "none"
137
- }
138
- },
139
- gutters: {
140
- paddingRight: 6
141
- }
142
- }));
143
- const classes = useStyles();
144
32
 
145
- //---------------------------------------------------
146
- // Hooks
147
- //---------------------------------------------------
148
- const [mobileMoreAnchorEl, setmobileMoreAnchorEl] = useState(null);
33
+ // Uses the default MUI theme if none is passed.
34
+ const compTheme = theme || useTheme();
35
+ const defaultTheme = createTheme(compTheme);
149
36
 
150
37
  //---------------------------------------------------
151
- // Use Effect
38
+ // Hooks
152
39
  //---------------------------------------------------
40
+ const [mobileMoreAnchorEl, setMobileMoreAnchorEl] = useState(null);
153
41
 
154
42
  //---------------------------------------------------
155
- // Local Functions
43
+ // Local Functions
156
44
  //---------------------------------------------------
157
45
  const handleMobileMenuOpen = event => {
158
- setmobileMoreAnchorEl(event.currentTarget);
46
+ setMobileMoreAnchorEl(event.currentTarget);
159
47
  };
160
48
  const handleMobileMenuClose = () => {
161
- setmobileMoreAnchorEl(null);
49
+ setMobileMoreAnchorEl(null);
162
50
  };
163
51
  const handleMenuClose = () => {
164
52
  handleMobileMenuClose();
165
53
  };
166
54
  const menu_divider = /*#__PURE__*/React.createElement(Typography, {
167
- className: classes.divider
55
+ sx: {
56
+ borderLeft: '0.1em solid #aeaeae',
57
+ p: '0.5em',
58
+ m: '10px',
59
+ height: 5
60
+ }
168
61
  });
169
62
  const mobile_menu_divider = /*#__PURE__*/React.createElement(Typography, {
170
- className: classes.mobile_divider
63
+ sx: {
64
+ borderBottom: '0.1em solid #aeaeae',
65
+ width: '100%'
66
+ }
171
67
  });
172
- const CloseContext = props => {
173
- const {
174
- onClick,
175
- name
176
- } = props;
177
- return /*#__PURE__*/React.createElement(Tooltip, {
178
- title: name
179
- }, /*#__PURE__*/React.createElement(IconButton, {
180
- onClick: onClick,
181
- className: classes.menuButton,
182
- color: "inherit",
183
- "aria-label": "Menu"
184
- }, /*#__PURE__*/React.createElement(ArrowBackIcon, null)));
185
- };
68
+ const CloseContext = ({
69
+ onClick,
70
+ name
71
+ }) => /*#__PURE__*/React.createElement(Tooltip, {
72
+ title: name
73
+ }, /*#__PURE__*/React.createElement(IconButton, {
74
+ onClick: onClick,
75
+ color: "inherit",
76
+ "aria-label": "Menu",
77
+ sx: {
78
+ ml: -2.25,
79
+ fontSize: 20
80
+ }
81
+ }, /*#__PURE__*/React.createElement(ArrowBackIcon, null)));
186
82
  const TitleContext = () => /*#__PURE__*/React.createElement(Typography, {
187
83
  variant: "h6",
188
84
  color: "inherit"
@@ -198,21 +94,20 @@ export const GenericAppBar = props => {
198
94
  menu,
199
95
  idx
200
96
  }) => /*#__PURE__*/React.createElement("div", {
201
- key: 'main_menu_bar_items'
97
+ key: `main_menu_bar_items_mobile_${idx}`
202
98
  }, menu.subMenu && menu.subMenu.length > 0 ? /*#__PURE__*/React.createElement("div", {
203
99
  key: `menu_bar__${menu.icon}`
204
100
  }, /*#__PURE__*/React.createElement("div", {
205
101
  className: "flex flex-row",
206
- key: `main_sub_items_${new Date()}`
102
+ key: `main_sub_items_${idx}`
207
103
  }, /*#__PURE__*/React.createElement(GenericAppBarSubMenu, {
208
104
  menu: menu,
209
- classes: classes,
210
105
  full_menu: true
211
106
  }), menu.displayDivider ? mobile_menu_divider : undefined)) : /*#__PURE__*/React.createElement("div", {
212
107
  key: `main_menu_item_${idx}`
213
108
  }, /*#__PURE__*/React.createElement("div", {
214
109
  className: "w-full",
215
- key: `main_sub_items_${new Date()}`
110
+ key: `main_sub_items_${idx}`
216
111
  }, /*#__PURE__*/React.createElement(MenuItem, {
217
112
  key: `mobile_menu_item_${idx}`,
218
113
  className: "flex flex-row",
@@ -230,34 +125,32 @@ export const GenericAppBar = props => {
230
125
  key: `main_menu_bar_items__${idx}`
231
126
  }, menu.subMenu && menu.subMenu.length > 0 ? /*#__PURE__*/React.createElement("div", {
232
127
  className: "flex flex-row",
233
- key: `main_sub_items_${new Date()}`
128
+ key: `main_sub_items_${idx}`
234
129
  }, /*#__PURE__*/React.createElement(GenericAppBarSubMenu, {
235
130
  key: `common_grid_app_bar_sub_desktop_${idx}`,
236
- menu: menu,
237
- classes: classes
238
- }), menu.displayDivider ? menu_divider : /*#__PURE__*/React.createElement("div", {
239
- className: ""
240
- })) : /*#__PURE__*/React.createElement("div", {
131
+ menu: menu
132
+ }), menu.displayDivider ? menu_divider : /*#__PURE__*/React.createElement("div", null)) : /*#__PURE__*/React.createElement("div", {
241
133
  className: "h-full my-auto",
242
134
  key: `main_menu_item_${idx}`
243
135
  }, /*#__PURE__*/React.createElement("div", {
244
136
  className: "flex flex-row h-full m-auto",
245
- key: `main_sub_items_${new Date()}`
137
+ key: `main_sub_items_${idx}`
246
138
  }, /*#__PURE__*/React.createElement(Tooltip, {
247
139
  title: menu.name
248
140
  }, menu.isButton ? /*#__PURE__*/React.createElement(Button, {
249
141
  startIcon: menu.icon,
250
142
  color: "inherit",
251
- "aria-owns": "menu-appbar",
252
143
  onClick: () => {
253
144
  menu.onClick();
254
145
  }
255
146
  }, menu.name) : /*#__PURE__*/React.createElement(IconButton, {
256
- className: classes.menuButton,
257
147
  color: "inherit",
258
- "aria-owns": "menu-appbar",
259
148
  onClick: () => {
260
149
  menu.onClick();
150
+ },
151
+ sx: {
152
+ ml: -2.25,
153
+ fontSize: 20
261
154
  }
262
155
  }, menu.icon)))));
263
156
 
@@ -268,17 +161,19 @@ export const GenericAppBar = props => {
268
161
  const renderMobileMenu = /*#__PURE__*/React.createElement(Menu, {
269
162
  anchorEl: mobileMoreAnchorEl,
270
163
  anchorOrigin: {
271
- vertical: "top",
272
- horizontal: "right"
164
+ vertical: 'top',
165
+ horizontal: 'right'
273
166
  },
274
167
  transformOrigin: {
275
- vertical: "top",
276
- horizontal: "right"
168
+ vertical: 'top',
169
+ horizontal: 'right'
277
170
  },
278
171
  open: Boolean(mobileMoreAnchorEl),
279
- onClose: () => handleMenuClose()
172
+ onClose: handleMenuClose
280
173
  }, /*#__PURE__*/React.createElement("div", {
281
- className: classes.root
174
+ style: {
175
+ flexGrow: 1
176
+ }
282
177
  }, /*#__PURE__*/React.createElement("div", {
283
178
  className: "flex flex-col"
284
179
  }, mobile_menu_divider, (appBarMenu.mainMenu || []).map((menu, idx) => /*#__PURE__*/React.createElement(MobileItemMenu, {
@@ -294,8 +189,9 @@ export const GenericAppBar = props => {
294
189
  const menuItems = (appBarMenu.mainMenu || []).filter(mn => !(mn.hideMenu && mn.hideMenu === true));
295
190
  return /*#__PURE__*/React.createElement("div", {
296
191
  className: "flex flex-row"
297
- }, menuItems.map((menu, idx) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DesktopItemMenu, {
298
- key: `desktop_item_menu_${idx}`,
192
+ }, menuItems.map((menu, idx) => /*#__PURE__*/React.createElement(Fragment, {
193
+ key: `desktop_item_menu_wrapper_${idx}`
194
+ }, /*#__PURE__*/React.createElement(DesktopItemMenu, {
299
195
  menu: menu,
300
196
  idx: idx
301
197
  }), idx < menuItems.length - 1 && /*#__PURE__*/React.createElement(React.Fragment, null, menu.displayDivider ? /*#__PURE__*/React.createElement(Divider, {
@@ -314,21 +210,32 @@ export const GenericAppBar = props => {
314
210
  return /*#__PURE__*/React.createElement(ThemeProvider, {
315
211
  theme: defaultTheme
316
212
  }, /*#__PURE__*/React.createElement("div", {
317
- className: classes.root
213
+ style: {
214
+ flexGrow: 1
215
+ }
318
216
  }, /*#__PURE__*/React.createElement(AppBar, {
319
217
  position: "static"
320
218
  }, /*#__PURE__*/React.createElement(Toolbar, {
321
219
  variant: "dense",
322
- className: classes.gutters
220
+ sx: {
221
+ pr: 0.75 // 6px, replacing classes.gutters
222
+ }
323
223
  }, /*#__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", {
324
- className: classes.grow
224
+ style: {
225
+ flexGrow: 1
226
+ }
325
227
  }), /*#__PURE__*/React.createElement("div", {
326
- className: classes.sectionDesktop
228
+ // Desktop
229
+ style: {
230
+ display: 'none'
231
+ },
232
+ className: "hidden md:flex"
327
233
  }, /*#__PURE__*/React.createElement(MainItems, null)), /*#__PURE__*/React.createElement("div", {
328
- className: classes.sectionMobile
234
+ // Mobile
235
+ className: "flex md:hidden"
329
236
  }, /*#__PURE__*/React.createElement(IconButton, {
330
237
  "aria-haspopup": "true",
331
- onClick: event => handleMobileMenuOpen(event),
238
+ onClick: handleMobileMenuOpen,
332
239
  color: "inherit"
333
240
  }, /*#__PURE__*/React.createElement(MoreIcon, null)))))), renderMobileMenu));
334
241
  };
@@ -340,10 +247,10 @@ GenericAppBar.defaultProps = {
340
247
  theme: undefined
341
248
  };
342
249
 
343
- //Define the types associated with the prop types
250
+ // Define the types associated with the prop types
344
251
  GenericAppBar.propTypes = {
345
252
  /** The menu structure used to control the menu: */
346
253
  appBarMenu: PropTypes.object.isRequired,
347
- /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
254
+ /** Theme object to use on this component, if none provided then the MUI theme provider theme is used */
348
255
  theme: PropTypes.object
349
256
  };
@@ -1,4 +1,4 @@
1
- import React, { useState, useRef, useEffect, useCallback } from 'react';
1
+ import React, { useState, useRef, useEffect, cloneElement } from 'react';
2
2
  import { Button, Dialog, DialogActions, DialogContent, IconButton, Typography, Toolbar, AppBar } from '@mui/material';
3
3
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
4
4
  import { ThemeProvider } from '@mui/system';
@@ -163,7 +163,7 @@ export const GenericDialogWindow = props => {
163
163
  enable: true
164
164
  }, /*#__PURE__*/React.createElement("div", {
165
165
  className: "w-full h-full "
166
- }, component ? /*#__PURE__*/React.cloneElement(component, {
166
+ }, component ? /*#__PURE__*/cloneElement(component, {
167
167
  parentProps: {
168
168
  canSave,
169
169
  setCanSave,
@@ -0,0 +1,226 @@
1
+ import React, { useState, useRef, useEffect, cloneElement } from 'react';
2
+ import { Button, Dialog, DialogActions, DialogContent, IconButton, Typography, Toolbar, AppBar } from '@mui/material';
3
+ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
4
+ import { ThemeProvider } from '@mui/system';
5
+ import { createTheme, useTheme } from '@mui/material/styles';
6
+ import LoadingBackdrop from '../../Loaders/LoadingBackdrop';
7
+ import PerfectScrollbar from '../../Tools/PCMScrollbar';
8
+ import GenericAppBar from '../GenericAppBar';
9
+ import PropTypes from 'prop-types';
10
+ let debounce;
11
+ export const GenericDialogWindow = props => {
12
+ const {
13
+ open,
14
+ component,
15
+ data,
16
+ showSaveButton = false,
17
+ showBackButton = true,
18
+ dialogSize = 'false',
19
+ appBarMenu = undefined,
20
+ fullWidth = false,
21
+ closeOnBackdropClick,
22
+ theme
23
+ } = props;
24
+ const compTheme = theme ? theme : useTheme();
25
+ const defaultTheme = createTheme(compTheme);
26
+
27
+ //---------------------------------------------------
28
+ // Hooks
29
+ //---------------------------------------------------
30
+ const [canSave, setCanSave] = useState(false);
31
+ const [isLoading, setIsLoading] = useState(false);
32
+ const [managedAppBarMenu, setManagedAppBarMenu] = useState(undefined);
33
+ const [save_button_label, setSaveButtonLabel] = useState(undefined);
34
+ const [onClickOverride, setOnClickOverride] = useState([]);
35
+ const childRef = useRef();
36
+ const onSave = () => {
37
+ clearTimeout(debounce);
38
+ debounce = setTimeout(() => {
39
+ //! Allows this parent component to call a sub function inside of the child component
40
+ childRef.current ? childRef.current.childRefSave() : undefined;
41
+ }, 300);
42
+ };
43
+ const closeDialog = () => {
44
+ //returns the onClick function assigned to the appBarMenu.closeMenu.onClick
45
+ try {
46
+ appBarMenu.closeMenu.onClick();
47
+ } catch (error) {
48
+ console.error('Error no onClose function found in the appBarMenu.closeMenu, Please ensure the dialog has a valid closeMenu with a close function assigned to the onClick', error);
49
+ }
50
+ };
51
+ const getSaveButtonLabel = () => {
52
+ let return_value = 'Save';
53
+ //returns the save label for the save button in the bottom right of the dialog.
54
+ // The save label is taken from the mainMenu name item having an id='save'
55
+ try {
56
+ const save_menu = appBarMenu.mainMenu.find(mm => mm.id === 'save');
57
+ if (save_menu && save_menu.name) {
58
+ return_value = save_menu.name;
59
+ }
60
+ } catch (error) {}
61
+ return return_value;
62
+ };
63
+
64
+ //?-------------------------------------------------------
65
+ //? Children on click callback override, updates the onclick for a given menu
66
+ //?-------------------------------------------------------
67
+ const updateObjectByID = (obj, id, onClick) => {
68
+ if (!obj) return;
69
+ if (obj.id && obj.id === id) {
70
+ obj.onClick = onClick;
71
+ } else if (typeof obj === 'object' && Array.isArray(obj)) {
72
+ for (var i = 0; i < obj.length; i++) {
73
+ updateObjectByID(obj[i], id, onClick);
74
+ }
75
+ } else if (obj.subMenu) {
76
+ updateObjectByID(obj.subMenu, id, onClick);
77
+ }
78
+ return obj;
79
+ };
80
+ const setMenuOnClickCallback = (id, onClick) => {
81
+ //Used to set the onClick callback on a specific menu matching the id provided.
82
+ //Example: Used by the children component to set the onClick of a menu.
83
+ // A menu must have a unique id object matching the id on which we are searching for and a callback function must be provided
84
+ //Need to filter out previous ids and add the new ones
85
+ setOnClickOverride(previousState => {
86
+ return [...previousState.filter(ps => ps.id !== id), {
87
+ id: id,
88
+ onClick: onClick
89
+ }];
90
+ });
91
+ };
92
+ const setOverrides = () => {
93
+ try {
94
+ //Loop over all our on click overrides and apply the onClick callback for each id found in the onClickOverride state
95
+
96
+ onClickOverride.forEach(item => {
97
+ if (item && item.id) {
98
+ setManagedAppBarMenu(previousState => {
99
+ return {
100
+ ...previousState,
101
+ mainMenu: updateObjectByID(previousState.mainMenu, item.id, item.onClick)
102
+ };
103
+ });
104
+ }
105
+ });
106
+ } catch (error) {
107
+ console.error('Error in setMenuOnClickCallback: ', error);
108
+ }
109
+ };
110
+ useEffect(() => {
111
+ //Wait for the state to be updated then loop over the overrides to ensure they are properly applied
112
+ setOverrides();
113
+ }, [onClickOverride]);
114
+ useEffect(() => {
115
+ if (appBarMenu && appBarMenu.mainMenu && appBarMenu.mainMenu.length > 0) {
116
+ setManagedAppBarMenu({
117
+ ...appBarMenu,
118
+ mainMenu: [...appBarMenu.mainMenu.map(mm => {
119
+ if (mm.id && mm.id === 'save') {
120
+ return {
121
+ ...mm,
122
+ onClick: onSave,
123
+ name: save_button_label ? save_button_label : mm.name,
124
+ hideMenu: !(canSave && showSaveButton)
125
+ };
126
+ } else {
127
+ return mm;
128
+ }
129
+ })]
130
+ });
131
+
132
+ // If we have a mainMenu item with the id='save' then override the onClick event to use the onSave function which reaches into the child ref
133
+ //Need to re-apply any onClick override to ensure they are still properly set by what was overridden from the child component.
134
+ // setOverrides();
135
+ }
136
+ }, [appBarMenu, canSave, showSaveButton, save_button_label]);
137
+ const handleOnClose = (event, reason) => {
138
+ if (reason !== 'backdropClick' || closeOnBackdropClick) {
139
+ closeDialog();
140
+ }
141
+ };
142
+ // -----------------------------------------
143
+ // Note make sure to include disableEnforceFocus or else I'll have infinite error/warnings on Uncaught RangeError.
144
+ // I think this error comes only after a state has changed when multiple dialog windows are open they are fighting for focus.
145
+ // Bug: https://github.com/mui/material-ui/issues/8741
146
+ // -----------------------------------------
147
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
148
+ theme: defaultTheme
149
+ }, /*#__PURE__*/React.createElement(Dialog, {
150
+ disableEnforceFocus: true,
151
+ open: open,
152
+ onClose: handleOnClose,
153
+ maxWidth: dialogSize,
154
+ fullScreen: dialogSize && !fullWidth ? false : true,
155
+ fullWidth: fullWidth,
156
+ className: ""
157
+ }, /*#__PURE__*/React.createElement(GenericAppBar, {
158
+ appBarMenu: managedAppBarMenu
159
+ }), /*#__PURE__*/React.createElement(DialogContent, {
160
+ className: "pt-4 pl-0 pr-0 h-full"
161
+ }, /*#__PURE__*/React.createElement(PerfectScrollbar, {
162
+ className: "w-fit",
163
+ enable: true
164
+ }, /*#__PURE__*/React.createElement("div", {
165
+ className: "w-full h-full "
166
+ }, component ? /*#__PURE__*/cloneElement(component, {
167
+ parentProps: {
168
+ canSave,
169
+ setCanSave,
170
+ isLoading,
171
+ setIsLoading,
172
+ setSaveButtonLabel,
173
+ closeDialog,
174
+ data: data,
175
+ setMenuOnClickCallback
176
+ },
177
+ ref: childRef
178
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)))), showSaveButton && /*#__PURE__*/React.createElement(DialogActions, {
179
+ className: "my-4 w-fit"
180
+ }, /*#__PURE__*/React.createElement("div", {
181
+ className: "flex flex-row justify-start w-full"
182
+ }, /*#__PURE__*/React.createElement(Button, {
183
+ className: `${dialogSize === 'sm' || dialogSize === 'xs' || dialogSize === 'md' ? 'w-full' : 'w-auto'}`,
184
+ variant: "contained",
185
+ color: "primary",
186
+ onClick: onSave,
187
+ disabled: !canSave
188
+ }, save_button_label ? save_button_label : getSaveButtonLabel()))), /*#__PURE__*/React.createElement(LoadingBackdrop, {
189
+ isLoading: isLoading
190
+ })));
191
+ };
192
+ export default GenericDialogWindow;
193
+ GenericDialogWindow.defaultProps = {
194
+ open: false,
195
+ component: undefined,
196
+ data: undefined,
197
+ showSaveButton: true,
198
+ showBackButton: true,
199
+ appBarMenu: undefined,
200
+ dialogSize: false,
201
+ fullWidth: false,
202
+ closeOnBackdropClick: false,
203
+ theme: undefined
204
+ };
205
+ GenericDialogWindow.propTypes = {
206
+ /** Controls weather to open or close the dialog */
207
+ open: PropTypes.bool,
208
+ /** Any React component to be displayed inside of the dialog body */
209
+ component: PropTypes.element,
210
+ /** Any data needing to be passed down to the child component */
211
+ data: PropTypes.any,
212
+ /** To display or hide the save button on the dialog */
213
+ showSaveButton: PropTypes.bool,
214
+ /** To display or hide the back button in the top left corner */
215
+ showBackButton: PropTypes.bool,
216
+ /** Same props as the GenericAppBar component... */
217
+ appBarMenu: PropTypes.object,
218
+ /** Determine the max-width of the dialog. The dialog width grows with the size of the screen. Set to false to disable maxWidth.*/
219
+ dialogSize: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]),
220
+ /**If true, the dialog stretches to maxWidth. Notice that the dialog width grow is limited by the default margin. */
221
+ fullWidth: PropTypes.bool,
222
+ /**Determines if the dialog window will close when the user clicks on the backdrop area */
223
+ closeOnBackdropClick: PropTypes.bool,
224
+ /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
225
+ theme: PropTypes.object
226
+ };
@@ -162,7 +162,6 @@ const Controls = props => {
162
162
  });
163
163
  // saveableCanvas.current.eraseAll();
164
164
  },
165
-
166
165
  marks: imageScaleMarks,
167
166
  min: 1.5,
168
167
  max: 2.5