pcm-shared-components 0.0.86 → 0.0.89

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.
@@ -2,6 +2,7 @@ import React, { Fragment, useState, useEffect } from "react";
2
2
  import { Typography, Button, Tooltip, IconButton, Toolbar, MenuItem, Menu, AppBar, Badge } from "@mui/material";
3
3
  import { makeStyles } from '@mui/styles';
4
4
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
5
+ import Divider from '@mui/material/Divider';
5
6
  import { ThemeProvider } from '@mui/system';
6
7
  import { createTheme, useTheme } from '@mui/material/styles';
7
8
  import MoreIcon from "@mui/icons-material/MoreVert";
@@ -98,7 +99,7 @@ export const GenericAppBar = props => {
98
99
  borderLeft: "0.1em solid #aeaeae",
99
100
  padding: "0.5em",
100
101
  margin: "10px 10px 10px 10px",
101
- height: 30
102
+ height: 5
102
103
  },
103
104
  mobile_divider: {
104
105
  borderBottom: "0.1em solid #aeaeae",
@@ -221,7 +222,7 @@ export const GenericAppBar = props => {
221
222
  }, /*#__PURE__*/React.createElement("div", {
222
223
  className: "flex flex-row",
223
224
  key: `main_sub_items_${new Date()}`
224
- }, /*#__PURE__*/React.createElement(Tooltip, {
225
+ }, " ", /*#__PURE__*/React.createElement(Tooltip, {
225
226
  title: menu.name
226
227
  }, menu.isButton ? /*#__PURE__*/React.createElement(Button // className={classes.menuButton}
227
228
  , {
@@ -238,8 +239,17 @@ export const GenericAppBar = props => {
238
239
  onClick: () => {
239
240
  menu.onClick();
240
241
  }
241
- }, menu.icon)), menu.display_divider ? menu_divider : /*#__PURE__*/React.createElement("div", {
242
- className: "mr-12"
242
+ }, menu.icon)), menu.display_divider ? /*#__PURE__*/React.createElement(Divider, {
243
+ style: {
244
+ marginRight: 24,
245
+ marginLeft: 6
246
+ },
247
+ orientation: "vertical",
248
+ flexItem: true
249
+ }) : /*#__PURE__*/React.createElement("div", {
250
+ style: {
251
+ marginRight: 24
252
+ }
243
253
  })))); //? ------------------------------------------------
244
254
  //! Mobile menu
245
255
  //? ------------------------------------------------
@@ -270,10 +280,7 @@ export const GenericAppBar = props => {
270
280
  //? ------------------------------------------------
271
281
 
272
282
  const MainItems = () => {
273
- return /*#__PURE__*/React.createElement("div", {
274
- className: "flex flex-row",
275
- key: `main_items_${new Date()}`
276
- }, (appBarMenu.mainMenu || []).filter(mn => !(mn.hideMenu && mn.hideMenu === true)).map((menu, idx) => /*#__PURE__*/React.createElement(DesktopItemMenu, {
283
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (appBarMenu.mainMenu || []).filter(mn => !(mn.hideMenu && mn.hideMenu === true)).map((menu, idx) => /*#__PURE__*/React.createElement(DesktopItemMenu, {
277
284
  key: `desktop_item_menu_${idx}`,
278
285
  menu: menu,
279
286
  idx: idx
@@ -60,6 +60,25 @@ export const GenericDialogWindow = props => {
60
60
  } catch (error) {}
61
61
 
62
62
  return return_value;
63
+ }; //?-------------------------------------------------------
64
+ //? Children on click callback override, updates the onclick for a given menu
65
+ //?-------------------------------------------------------
66
+
67
+
68
+ const updateObjectByID = (obj, id, onClick) => {
69
+ if (!obj) return;
70
+
71
+ if (obj.id && obj.id === id) {
72
+ obj.onClick = onClick;
73
+ } else if (typeof obj === 'object' && Array.isArray(obj)) {
74
+ for (var i = 0; i < obj.length; i++) {
75
+ updateObjectByID(obj[i], id, onClick);
76
+ }
77
+ } else if (obj.subMenu) {
78
+ updateObjectByID(obj.subMenu, id, onClick);
79
+ }
80
+
81
+ return obj;
63
82
  };
64
83
 
65
84
  const setMenuOnClickCallback = useCallback((id, onClick) => {
@@ -75,7 +94,7 @@ export const GenericDialogWindow = props => {
75
94
  }];
76
95
  });
77
96
  }
78
- }, []);
97
+ }, [appBarMenu]);
79
98
 
80
99
  const setOverrides = () => {
81
100
  try {
@@ -83,15 +102,7 @@ export const GenericDialogWindow = props => {
83
102
  onClickOverride.forEach(item => {
84
103
  setManagedAppBarMenu(previousState => {
85
104
  return { ...previousState,
86
- mainMenu: [...previousState.mainMenu.map(mm => {
87
- if (mm.id.toLowerCase() === item.id.toLowerCase()) {
88
- return { ...mm,
89
- onClick: item.onClick
90
- };
91
- } else {
92
- return mm;
93
- }
94
- })]
105
+ mainMenu: updateObjectByID(previousState.mainMenu, item.id, item.onClick)
95
106
  };
96
107
  });
97
108
  });
@@ -106,7 +117,6 @@ export const GenericDialogWindow = props => {
106
117
  }, [onClickOverride]);
107
118
  useEffect(() => {
108
119
  if (appBarMenu && appBarMenu.mainMenu) {
109
- // 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
110
120
  setManagedAppBarMenu({ ...appBarMenu,
111
121
  mainMenu: [...appBarMenu.mainMenu.map(mm => {
112
122
  if (mm.id === 'save') {
@@ -119,7 +129,8 @@ export const GenericDialogWindow = props => {
119
129
  return mm;
120
130
  }
121
131
  })]
122
- }); //Need to re-apply any onClick override to ensure they are still properly set by what was overridden from the child component.
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.
123
134
 
124
135
  setOverrides();
125
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "0.0.86",
3
+ "version": "0.0.89",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {