pcm-shared-components 2.1.115 → 2.1.117

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.
@@ -1,11 +1,10 @@
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
1
  import React, { memo } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
5
- // import { ThemeProvider } from '@mui/system';
6
- import { createTheme, useTheme } from '@mui/material/styles';
7
- import { ReusablePopupMenu } from '../../Menus/ReusablePopupMenu';
4
+ import { useTheme } from '@mui/material/styles';
5
+ import useMediaQuery from '@mui/material/useMediaQuery';
8
6
  import Button from '@mui/material/Button';
7
+ import { ReusablePopupMenu } from '../../Menus/ReusablePopupMenu';
9
8
  import i18next from 'i18next';
10
9
 
11
10
  /**
@@ -35,19 +34,22 @@ export const TillButton = props => {
35
34
  className,
36
35
  theme
37
36
  } = props;
38
- const compTheme = theme ? theme : useTheme();
39
- const defaultTheme = createTheme(compTheme);
40
- const isTillInuse = name ? true : inUse ? true : false;
41
- return /*#__PURE__*/React.createElement(ReusablePopupMenu, _extends({}, menuData, {
42
- theme: defaultTheme
43
- }), /*#__PURE__*/React.createElement(Button, {
37
+ const outerTheme = useTheme(); // may be undefined if no ThemeProvider
38
+ const compTheme = theme || outerTheme; // may still be undefined
39
+
40
+ // Use theme breakpoints if available, otherwise fall back to a raw media query
41
+ const mdQuery = compTheme?.breakpoints?.up ? compTheme.breakpoints.up('md') : '(min-width:900px)'; // MUI default md is 900px
42
+
43
+ const isMdUp = useMediaQuery(mdQuery);
44
+ const isTillInuse = !!(name || inUse);
45
+ const label = isMdUp && name ? `${defaultText} : ${name}` : defaultText;
46
+ return /*#__PURE__*/React.createElement(ReusablePopupMenu, menuData, /*#__PURE__*/React.createElement(Button, {
44
47
  className: className,
45
48
  endIcon: /*#__PURE__*/React.createElement(KeyboardArrowDownIcon, null),
46
49
  color: isTillInuse ? 'primary' : 'secondary',
47
50
  size: className ? undefined : size
48
- }, `${defaultText} ${name ? ':' : ''} ${name}`));
51
+ }, label));
49
52
  };
50
- export default /*#__PURE__*/memo(TillButton);
51
53
  TillButton.defaultProps = {
52
54
  inUse: false,
53
55
  name: '',
@@ -58,18 +60,12 @@ TillButton.defaultProps = {
58
60
  theme: undefined
59
61
  };
60
62
  TillButton.propTypes = {
61
- /** Determines if a till is currently being used */
62
63
  inUse: PropTypes.bool,
63
- /** Name of the till being used. Note: if till name exist then inUse is true */
64
64
  name: PropTypes.string,
65
- /** Text used to identify the string in front of the till name. example: Till : Some name */
66
65
  defaultText: PropTypes.string,
67
- /** Menu items for the dropdown, see the ReusablePopupMenu component for a better understanding of the props parameters */
68
66
  menuData: PropTypes.object,
69
- /** Classes applied to the button */
70
67
  className: PropTypes.string,
71
- /** Supported size of the button ['x-small', 'small','medium'] */
72
68
  size: PropTypes.oneOf(['small', 'medium', 'large']),
73
- /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
74
69
  theme: PropTypes.object
75
- };
70
+ };
71
+ export default /*#__PURE__*/memo(TillButton);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "2.1.115",
3
+ "version": "2.1.117",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {