pcm-shared-components 2.1.107 → 2.1.108

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 +2 -2
  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,35 +1,10 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useState, useCallback } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import AppBar from '@mui/material/AppBar';
5
5
  import Tabs from '@mui/material/Tabs';
6
6
  import Tab from '@mui/material/Tab';
7
- import { ThemeProvider } from '@mui/system';
8
- import { createTheme, useTheme } from '@mui/material/styles';
9
- import { makeStyles } from '@mui/styles';
10
- const useStyles = makeStyles(() => ({
11
- root: {
12
- height: ({
13
- tabHeight
14
- }) => tabHeight,
15
- minHeight: ({
16
- tabHeight
17
- }) => tabHeight,
18
- backgroundColor: 'transparent'
19
- // textTransform: 'none', //changes so the text is not upper cased
20
- // color: 'white !important',
21
- // '&:focus': {
22
- // color: 'orange !important',
23
- // },
24
- },
25
-
26
- indicator: {
27
- height: 3,
28
- borderRadius: 25
29
- // backgroundColor: 'orange',
30
- }
31
- }));
32
-
7
+ import { ThemeProvider, createTheme, useTheme } from '@mui/material/styles';
33
8
  export const SimpleTab = props => {
34
9
  const {
35
10
  childrenTabs,
@@ -40,12 +15,10 @@ export const SimpleTab = props => {
40
15
  tabsWrapperClassName,
41
16
  theme
42
17
  } = props;
43
- const classes = useStyles({
44
- tabHeight: variant === 'dense' ? 24 : 48
45
- });
18
+ const tabHeight = variant === 'dense' ? 24 : 48;
46
19
 
47
- //Uses the default mui theme if none is passed.
48
- const compTheme = theme ? theme : useTheme();
20
+ // Uses the default MUI theme if none is passed.
21
+ const compTheme = theme || useTheme();
49
22
  const defaultTheme = createTheme(compTheme);
50
23
  const handleChange = (event, newValue) => {
51
24
  setSelectedTabIndex(newValue);
@@ -56,21 +29,20 @@ export const SimpleTab = props => {
56
29
  'aria-controls': `scrollable-auto-tabpanel-${index}`
57
30
  };
58
31
  };
59
- const TabPanel = useCallback(props => {
32
+ const TabPanel = useCallback(panelProps => {
60
33
  const {
61
34
  children,
62
35
  value,
63
36
  index,
64
37
  ...other
65
- } = props;
38
+ } = panelProps;
66
39
  return /*#__PURE__*/React.createElement("div", _extends({
67
40
  role: "tabpanel",
68
41
  hidden: value !== index,
69
42
  id: `scrollable-auto-tabpanel-${index}`,
70
43
  "aria-labelledby": `scrollable-auto-tab-${index}`
71
44
  }, other, {
72
- className: "w-full h-full overflow-hidden",
73
- style: {}
45
+ className: "w-full h-full overflow-hidden"
74
46
  }), value === index && /*#__PURE__*/React.createElement("div", {
75
47
  className: "w-full h-full"
76
48
  }, children));
@@ -78,7 +50,7 @@ export const SimpleTab = props => {
78
50
  return /*#__PURE__*/React.createElement(ThemeProvider, {
79
51
  theme: defaultTheme
80
52
  }, /*#__PURE__*/React.createElement("div", {
81
- className: "flex flex-col w-full h-full overflow-hidden "
53
+ className: "flex flex-col w-full h-full overflow-hidden"
82
54
  }, /*#__PURE__*/React.createElement(AppBar, {
83
55
  position: "static",
84
56
  color: "default",
@@ -86,20 +58,32 @@ export const SimpleTab = props => {
86
58
  }, /*#__PURE__*/React.createElement("div", {
87
59
  className: tabsWrapperClassName
88
60
  }, /*#__PURE__*/React.createElement(Tabs, {
89
- classes: classes,
90
61
  value: selectedTabIndex,
91
62
  onChange: handleChange,
92
63
  indicatorColor: "primary",
93
64
  textColor: "primary",
94
65
  variant: "scrollable",
95
66
  scrollButtons: "auto",
96
- "aria-label": ""
67
+ "aria-label": "",
68
+ sx: {
69
+ minHeight: tabHeight,
70
+ height: tabHeight,
71
+ backgroundColor: 'transparent',
72
+ '& .MuiTab-root': {
73
+ minHeight: tabHeight,
74
+ height: tabHeight,
75
+ textTransform: 'none'
76
+ },
77
+ '& .MuiTabs-indicator': {
78
+ height: 3,
79
+ borderRadius: 25
80
+ }
81
+ }
97
82
  }, childrenTabs.map((ct, idx) => /*#__PURE__*/React.createElement(Tab, _extends({
98
- classes: classes,
99
- style: tabStyles,
83
+ key: `simple_tabs_${idx}`,
100
84
  label: ct.tabTitle
101
85
  }, a11yProps(idx), {
102
- key: `simple_tabs_${idx}`
86
+ sx: tabStyles
103
87
  })))))), childrenTabs.map((ct, idx) => /*#__PURE__*/React.createElement(TabPanel, {
104
88
  value: selectedTabIndex,
105
89
  index: idx,
@@ -117,31 +101,23 @@ SimpleTab.defaultProps = {
117
101
  theme: undefined
118
102
  };
119
103
  SimpleTab.propTypes = {
120
- /** An array of object that determines the tab title and tab content.
121
- *
122
- * - The childrenTabs are object withing an array
123
- *
124
- ```
125
- [{tabTitle:'something',tabPanel:<Object/>}]
126
- ```
127
- */
104
+ /** An array of objects that determines the tab title and tab content.
105
+ *
106
+ * - The childrenTabs are objects within an array
107
+ *
108
+ * [{tabTitle:'something', tabPanel:<Object/>}]
109
+ */
128
110
  childrenTabs: PropTypes.array,
129
- /** Controls the heigh and spacing of the tab control */
111
+ /** Controls the height and spacing of the tab control */
130
112
  variant: PropTypes.oneOf(['dense', 'normal']),
131
- /** Is the index value of the current selected tab */
113
+ /** Index value of the currently selected tab */
132
114
  selectedTabIndex: PropTypes.number,
133
- /** The setter for selectedTabIndex: receives one parameter and it's the ```value``` of the index*/
115
+ /** Setter for selectedTabIndex: receives the `value` of the index */
134
116
  setSelectedTabIndex: PropTypes.func,
135
- /** Additional classes passed to the Div wrapper of the <Tabs></Tabs> component.
136
- * Example:
137
- * - Center tabs 'flex flex-row justify-center w-full'
138
- * - Right tabs 'flex flex-row justify-end w-full'
139
- * - Gray background 'bg-gray-200'
140
- */
117
+ /** Additional classes passed to the div wrapper of the <Tabs /> component. */
141
118
  tabsWrapperClassName: PropTypes.string,
142
- /** Additional styles to be applied to the Tab component
143
- * Example: {margin:'auto'} */
119
+ /** Additional styles to be applied to the Tab component, e.g. { margin: 'auto' } */
144
120
  tabStyles: PropTypes.object,
145
- /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
121
+ /** Theme object to use on this component; if none provided, the MUI theme from context is used */
146
122
  theme: PropTypes.object
147
123
  };
@@ -1,37 +1,41 @@
1
1
  import React from 'react';
2
- import withStyles from "@mui/styles/withStyles";
3
- import Menu from "@mui/material/Menu";
4
- import MenuItem from "@mui/material/MenuItem";
5
- import ListItemIcon from "@mui/material/ListItemIcon";
6
- import ListItemText from "@mui/material/ListItemText";
7
- import Switch from "@mui/material/Switch";
8
- import PropTypes from "prop-types";
9
- import GenericSubMenu from './GenericSubMenu';
10
- const StyledMenu = withStyles({
11
- paper: {
12
- border: "1px solid #d3d4d5",
2
+ import Menu from '@mui/material/Menu';
3
+ import MenuItem from '@mui/material/MenuItem';
4
+ import ListItemIcon from '@mui/material/ListItemIcon';
5
+ import ListItemText from '@mui/material/ListItemText';
6
+ import Switch from '@mui/material/Switch';
7
+ import PropTypes from 'prop-types';
8
+ import { styled } from '@mui/material/styles';
9
+ import SubMenuInternal from './SubMenuInternal';
10
+ const StyledMenu = styled(Menu)(({
11
+ theme
12
+ }) => ({
13
+ '& .MuiPaper-root': {
14
+ border: '1px solid #d3d4d5',
13
15
  paddingTop: 4,
14
16
  paddingBottom: 4
15
17
  }
16
- })(props => /*#__PURE__*/React.createElement(Menu, props));
17
- const StyledMenuItem = withStyles(() => ({
18
- root: {
19
- minHeight: 32,
20
- paddingLeft: 12,
21
- paddingRight: 12,
22
- minWidth: '100% !important',
23
- "&:focus": {
24
- backgroundColor: "primary",
25
- "& .MuiListItemIcon-root, & .MuiListItemText-primary": {
26
- color: "primary"
27
- }
18
+ }));
19
+ const StyledMenuItem = styled(MenuItem)(({
20
+ theme
21
+ }) => ({
22
+ minHeight: 32,
23
+ paddingLeft: 12,
24
+ paddingRight: 12,
25
+ minWidth: '100% !important',
26
+ '&:focus': {
27
+ backgroundColor: theme.palette.primary.main,
28
+ '& .MuiListItemIcon-root, & .MuiListItemText-primary': {
29
+ color: theme.palette.primary.main
28
30
  }
29
31
  }
30
- }))(MenuItem);
32
+ }));
31
33
  const handleMenuOnClick = (menu, handleClose) => {
32
- menu.onClick();
33
- if (typeof menu.isChecked !== "boolean") {
34
- //This is NOT a menu with a CheckState SO close the menu after the onclick.
34
+ if (typeof menu.onClick === 'function') {
35
+ menu.onClick();
36
+ }
37
+ if (typeof menu.isChecked !== 'boolean') {
38
+ // This is NOT a menu with a CheckState so close the menu after the onclick.
35
39
  handleClose();
36
40
  }
37
41
  };
@@ -39,7 +43,7 @@ const ReusableMenu = props => {
39
43
  const {
40
44
  menuAnchor,
41
45
  handleClose,
42
- menuData,
46
+ menuData = [],
43
47
  keepMounted,
44
48
  classes = undefined,
45
49
  menuAnchorLocation
@@ -49,11 +53,11 @@ const ReusableMenu = props => {
49
53
  elevation: 0,
50
54
  anchorEl: menuAnchor,
51
55
  anchorOrigin: {
52
- vertical: "bottom",
56
+ vertical: 'bottom',
53
57
  horizontal: menuAnchorLocation
54
58
  },
55
59
  transformOrigin: {
56
- vertical: "top",
60
+ vertical: 'top',
57
61
  horizontal: menuAnchorLocation
58
62
  },
59
63
  keepMounted: keepMounted,
@@ -63,17 +67,17 @@ const ReusableMenu = props => {
63
67
  className: "w-full",
64
68
  key: `ReusableMenu_${idx}`
65
69
  }, menu.name && /*#__PURE__*/React.createElement("div", {
66
- key: 'this_menu_' + idx
70
+ key: `this_menu_${idx}`
67
71
  }, menu.subMenu ? /*#__PURE__*/React.createElement("div", {
68
72
  className: "flex flex-row w-full",
69
- key: `main_sub_items_${new Date()}`
70
- }, /*#__PURE__*/React.createElement(GenericSubMenu, {
73
+ key: `main_sub_items_${idx}`
74
+ }, /*#__PURE__*/React.createElement(SubMenuInternal, {
71
75
  key: `common_grid_app_bar_sub_desktop_${idx}`,
72
76
  menu: menu,
73
77
  full_menu: true,
74
78
  classes: classes,
75
79
  onClose: handleClose
76
- })) : /*#__PURE__*/React.createElement(StyledMenuItem, {
80
+ })) : /*#__PURE__*/React.createElement(MenuItem, {
77
81
  className: "w-full",
78
82
  onClick: () => {
79
83
  handleMenuOnClick(menu, handleClose);
@@ -81,33 +85,29 @@ const ReusableMenu = props => {
81
85
  key: `reusable_menu_item_${idx}`
82
86
  }, menu.icon && /*#__PURE__*/React.createElement(ListItemIcon, null, menu.icon), /*#__PURE__*/React.createElement(ListItemText, {
83
87
  primary: menu.name
84
- }), typeof menu.isChecked === "boolean" && /*#__PURE__*/React.createElement(Switch, {
88
+ }), typeof menu.isChecked === 'boolean' && /*#__PURE__*/React.createElement(Switch, {
85
89
  checked: menu.isChecked
86
90
  }))))));
87
91
  };
88
- export default ReusableMenu;
89
92
 
90
- // required props for component to work...
91
- ReusableMenu.propTypes = {
92
- menuAnchor: PropTypes.element.isRequired,
93
- handleClose: PropTypes.element.isRequired,
94
- menuData: PropTypes.element.isRequired
95
- };
93
+ // ReusableMenu.defaultProps = {
94
+ // menuAnchor: undefined,
95
+ // handleClose: undefined,
96
+ // menuData: [],
97
+ // keepMounted: false,
98
+ // menuAnchorLocation: 'center',
99
+ // };
96
100
 
97
- // Specifies the default values for the props:
98
- ReusableMenu.defaultProps = {
99
- menuAnchor: undefined,
100
- handleClose: undefined,
101
- menuData: [],
102
- keepMounted: false,
103
- menuAnchorLocation: 'center'
104
- };
101
+ // ReusableMenu.propTypes = {
102
+ // menuAnchor: PropTypes.oneOfType([
103
+ // PropTypes.element,
104
+ // PropTypes.object,
105
+ // ]),
106
+ // handleClose: PropTypes.func,
107
+ // menuData: PropTypes.array,
108
+ // keepMounted: PropTypes.bool,
109
+ // menuAnchorLocation: PropTypes.oneOf(['left', 'center', 'right']),
110
+ // classes: PropTypes.object,
111
+ // };
105
112
 
106
- // Type of
107
- ReusableMenu.propTypes = {
108
- menuAnchor: PropTypes.object,
109
- handleClose: PropTypes.func,
110
- menuData: PropTypes.array,
111
- keepMounted: PropTypes.bool,
112
- menuAnchorLocation: PropTypes.string
113
- };
113
+ export default ReusableMenu;
@@ -1,90 +1,54 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { Tooltip, IconButton, MenuItem, Menu } from "@mui/material";
2
+ import { Tooltip, IconButton, MenuItem, Menu } from '@mui/material';
3
3
  import ChevronRightIcon from '@mui/icons-material/ChevronRight';
4
- import { makeStyles } from '@mui/styles';
5
- import withStyles from "@mui/styles/withStyles";
6
- import ListItemIcon from "@mui/material/ListItemIcon";
7
- import ListItemText from "@mui/material/ListItemText";
8
- import Switch from "@mui/material/Switch";
9
- const StyledMenuItem = withStyles(() => ({
10
- root: {
11
- minHeight: 32,
12
- paddingLeft: 12,
13
- paddingRight: 12,
14
- minWidth: '100% !important',
15
- "&:focus": {
16
- backgroundColor: "primary",
17
- "& .MuiListItemIcon-root, & .MuiListItemText-primary": {
18
- color: "primary"
19
- }
20
- }
21
- }
22
- }))(MenuItem);
23
- const GenericSubMenu = ({
24
- menu,
4
+ import ListItemIcon from '@mui/material/ListItemIcon';
5
+ import ListItemText from '@mui/material/ListItemText';
6
+ import Switch from '@mui/material/Switch';
7
+ import { styled } from '@mui/material/styles';
8
+
9
+ // const StyledMenuItem = styled(MenuItem)(({ theme }) => ({
10
+ // minHeight: 32,
11
+ // paddingLeft: 12,
12
+ // paddingRight: 12,
13
+ // minWidth: '100% !important',
14
+ // '&:focus': {
15
+ // backgroundColor: theme.palette.primary.main,
16
+ // '& .MuiListItemIcon-root, & .MuiListItemText-primary': {
17
+ // color: theme.palette.primary.main,
18
+ // },
19
+ // },
20
+ // }));
21
+
22
+ function SubMenuInternal({
23
+ menu = [],
25
24
  full_menu = true,
26
25
  handleParentMenuClose = undefined,
27
- onClose
28
- }) => {
29
- const [anchorSubMenu, setAnchorSubMenu] = useState(false);
26
+ onClose = () => {}
27
+ }) {
28
+ const [anchorSubMenu, setAnchorSubMenu] = useState(null);
30
29
  const [isSubMenuOpen, setSubMenuOpen] = useState(false);
31
- const useStyles = makeStyles(theme => ({
32
- root: {
33
- flexGrow: 1
34
- },
35
- menuButton: {
36
- marginLeft: -18,
37
- fontSize: 20
38
- },
39
- appContextMenu: {
40
- background: "#58524c"
41
- },
42
- grow: {
43
- flexGrow: 1
44
- },
45
- divider: {
46
- borderLeft: "0.1em solid #aeaeae",
47
- padding: "0.5em",
48
- margin: "10px 10px 10px 10px",
49
- height: 5
50
- },
51
- mobile_divider: {
52
- borderBottom: "0.1em solid #aeaeae",
53
- width: "100%"
54
- },
55
- sectionDesktop: {
56
- display: "none",
57
- [theme.breakpoints.up("md")]: {
58
- display: "flex"
59
- }
60
- },
61
- sectionMobile: {
62
- display: "flex",
63
- [theme.breakpoints.up("md")]: {
64
- display: "none"
65
- }
66
- }
67
- }));
68
- const classes = useStyles();
30
+ const menuId = `menu-appbar-${menu?.name || 'submenu'}`;
69
31
  const openSubMenu = event => {
70
32
  setAnchorSubMenu(event.currentTarget);
71
33
  };
72
34
  const handleSubMenuClose = () => {
73
- setAnchorSubMenu(false);
35
+ setAnchorSubMenu(null);
74
36
 
75
- //Closes the previous parent menu too..
37
+ // Closes the previous parent menu too..
76
38
  if (handleParentMenuClose) {
77
39
  handleParentMenuClose();
78
40
  }
79
- onClose();
41
+ if (onClose) {
42
+ onClose();
43
+ }
80
44
  };
81
45
  useEffect(() => {
82
46
  setSubMenuOpen(Boolean(anchorSubMenu));
83
47
  }, [anchorSubMenu]);
84
48
  return /*#__PURE__*/React.createElement("div", {
85
49
  key: `main_sub_menu_items_${menu.icon}`,
86
- className: !full_menu ? "flex flex-row" : 'flex flex-col w-full'
87
- }, full_menu ? /*#__PURE__*/React.createElement(StyledMenuItem, {
50
+ className: !full_menu ? 'flex flex-row' : 'flex flex-col w-full'
51
+ }, full_menu ? /*#__PURE__*/React.createElement(MenuItem, {
88
52
  onClick: openSubMenu
89
53
  }, menu.icon && /*#__PURE__*/React.createElement(ListItemIcon, null, menu.icon), /*#__PURE__*/React.createElement("div", {
90
54
  className: "flex flex-row justify-between w-full"
@@ -97,15 +61,20 @@ const GenericSubMenu = ({
97
61
  })))) : /*#__PURE__*/React.createElement(Tooltip, {
98
62
  title: menu.name
99
63
  }, /*#__PURE__*/React.createElement(IconButton, {
100
- className: classes.menuButton,
64
+ sx: {
65
+ ml: -2.25,
66
+ fontSize: 20
67
+ } // replaces classes.menuButton
68
+ ,
101
69
  color: "inherit",
102
- "aria-owns": "menu-appbar",
70
+ "aria-controls": isSubMenuOpen ? menuId : undefined,
71
+ "aria-haspopup": "true",
103
72
  onClick: openSubMenu
104
73
  }, menu.icon)), /*#__PURE__*/React.createElement(Menu, {
105
- className: "",
74
+ id: menuId,
106
75
  style: {
107
76
  display: anchorSubMenu ? 'block' : 'none'
108
- } //Makes the disappearing menu smoother so I don't see it being jarred in a corner.
77
+ } // Makes the disappearing menu smoother
109
78
  ,
110
79
  anchorEl: anchorSubMenu,
111
80
  anchorOrigin: {
@@ -120,14 +89,14 @@ const GenericSubMenu = ({
120
89
  onClose: handleSubMenuClose,
121
90
  onClick: menu.onClick
122
91
  }, (menu.subMenu || []).filter(mn => !(mn.hideMenu && mn.hideMenu === true)).map((sub_menu, idx) => /*#__PURE__*/React.createElement("div", {
123
- key: 'this_submenu_' + idx
124
- }, sub_menu.subMenu ? /*#__PURE__*/React.createElement(GenericSubMenu, {
92
+ key: `this_submenu_${idx}`
93
+ }, sub_menu.subMenu ? /*#__PURE__*/React.createElement(SubMenuInternal, {
125
94
  key: `app_bar_common_grid_app_bar_sub_desktop_sub_${idx}`,
126
95
  menu: sub_menu,
127
- classes: classes,
128
96
  full_menu: true,
129
- handleParentMenuClose: handleSubMenuClose
130
- }) : /*#__PURE__*/React.createElement(StyledMenuItem, {
97
+ handleParentMenuClose: handleSubMenuClose,
98
+ onClose: onClose
99
+ }) : /*#__PURE__*/React.createElement(MenuItem, {
131
100
  key: `sub_menu_items__${idx}}`,
132
101
  onClick: () => {
133
102
  handleSubMenuClose();
@@ -135,8 +104,9 @@ const GenericSubMenu = ({
135
104
  }
136
105
  }, sub_menu.icon && /*#__PURE__*/React.createElement(ListItemIcon, null, sub_menu.icon), /*#__PURE__*/React.createElement(ListItemText, {
137
106
  primary: sub_menu.name
138
- }), typeof sub_menu.isChecked === "boolean" && /*#__PURE__*/React.createElement(Switch, {
107
+ }), typeof sub_menu.isChecked === 'boolean' && /*#__PURE__*/React.createElement(Switch, {
139
108
  checked: sub_menu.isChecked
140
109
  }))))));
141
- };
142
- export default GenericSubMenu;
110
+ }
111
+ ;
112
+ export default SubMenuInternal;
@@ -0,0 +1,98 @@
1
+ import React, { useState, Children, isValidElement, cloneElement } from 'react';
2
+ import ReusableMenu from './components/ReusableMenu';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import PropTypes from 'prop-types';
5
+ import { useTheme } from '@mui/material/styles';
6
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
7
+
8
+ /**
9
+ * Wraps any simple component and generates a simple dropdown menu on the wrapped component.
10
+ *
11
+ *
12
+ * ### Importing the component
13
+
14
+ ```//PitchCamp shared component
15
+ import {ReusablePopupMenu} from 'pcm-shared-components';
16
+ ```
17
+
18
+ *
19
+ */
20
+ export const ReusablePopupMenu = props => {
21
+ const {
22
+ children,
23
+ menuData = [],
24
+ tooltipTitle,
25
+ keepMounted,
26
+ menuAnchorLocation,
27
+ theme
28
+ } = props;
29
+ const [menuAnchor, setMenuAnchor] = useState(null);
30
+ const componentTheme = createTheme(theme ? theme : useTheme());
31
+ const onClick = event => {
32
+ setMenuAnchor(event.currentTarget);
33
+ };
34
+ const handleClose = () => {
35
+ setMenuAnchor(null);
36
+ };
37
+ const hocProps = {
38
+ menuAnchor,
39
+ handleClose,
40
+ menuData,
41
+ keepMounted,
42
+ menuAnchorLocation
43
+ };
44
+ console.log('debug menuData', menuData);
45
+ const childrenWithProps = Children.map(children, child => {
46
+ // Checking isValidElement is the safe way and avoids a typescript
47
+ if (/*#__PURE__*/isValidElement(child)) {
48
+ return /*#__PURE__*/React.createElement(Tooltip, {
49
+ title: tooltipTitle.length > 0 ? tooltipTitle : ''
50
+ }, /*#__PURE__*/cloneElement(child, {
51
+ onClick
52
+ }));
53
+ }
54
+ return child;
55
+ });
56
+ return /*#__PURE__*/React.createElement(React.Fragment, null, childrenWithProps, /*#__PURE__*/React.createElement(ThemeProvider, {
57
+ theme: componentTheme
58
+ }, /*#__PURE__*/React.createElement(ReusableMenu, hocProps)));
59
+ };
60
+
61
+ // required props for component to work...
62
+ ReusablePopupMenu.propTypes = {
63
+ children: PropTypes.element.isRequired,
64
+ menuData: PropTypes.element.isRequired
65
+ };
66
+
67
+ // Specifies the default values for the props:
68
+ ReusablePopupMenu.defaultProps = {
69
+ children: undefined,
70
+ tooltipTitle: '',
71
+ menuData: [],
72
+ keepMounted: false,
73
+ theme: undefined,
74
+ menuAnchorLocation: 'center'
75
+ };
76
+
77
+ // Type of
78
+ ReusablePopupMenu.propTypes = {
79
+ children: PropTypes.object,
80
+ tooltipTitle: PropTypes.string,
81
+ menuData: PropTypes.array,
82
+ keepMounted: PropTypes.bool,
83
+ /**
84
+ * The theme object to apply to this object, if no theme provided then the component will used the default theme passed down by the ThemeProvider
85
+ */
86
+ theme: PropTypes.object,
87
+ /** Controls the location of the dropdown popup menu */
88
+ menuAnchorLocation: PropTypes.oneOf(['left', 'center', 'right'])
89
+ };
90
+ export default ReusablePopupMenu;
91
+ export const createReusablePopupMenuObject = (onClick = undefined, icon = undefined, name = undefined, isChecked = undefined) => {
92
+ return {
93
+ onClick: onClick,
94
+ icon: icon,
95
+ name: name,
96
+ isChecked: isChecked
97
+ };
98
+ };