pcm-shared-components 0.0.138 → 0.0.141

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.
@@ -31,6 +31,7 @@ export const DropdownButton = props => {
31
31
  menuData,
32
32
  variant,
33
33
  size,
34
+ menuAnchorLocation,
34
35
  theme
35
36
  } = props;
36
37
  const compTheme = theme ? theme : useTheme();
@@ -38,7 +39,8 @@ export const DropdownButton = props => {
38
39
  return /*#__PURE__*/React.createElement(ThemeProvider, {
39
40
  theme: defaultTheme
40
41
  }, /*#__PURE__*/React.createElement(ReusablePopupMenu, _extends({}, menuData, {
41
- theme: defaultTheme
42
+ theme: defaultTheme,
43
+ menuAnchorLocation: menuAnchorLocation
42
44
  }), /*#__PURE__*/React.createElement(Button, {
43
45
  variant: variant,
44
46
  className: className,
@@ -55,7 +57,8 @@ DropdownButton.defaultProps = {
55
57
  color: 'primary',
56
58
  className: '',
57
59
  variant: 'text',
58
- theme: {}
60
+ theme: {},
61
+ menuAnchorLocation: 'right'
59
62
  };
60
63
  DropdownButton.propTypes = {
61
64
  /** Name of the till being used. Note: if till name exist then inUse is true */
@@ -77,5 +80,8 @@ DropdownButton.propTypes = {
77
80
  size: PropTypes.oneOf(['small', 'medium', 'large']),
78
81
 
79
82
  /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
80
- theme: PropTypes.object
83
+ theme: PropTypes.object,
84
+
85
+ /** Controls the location of the dropdown popup menu */
86
+ menuAnchorLocation: PropTypes.oneOf(['left', 'center', 'right'])
81
87
  };
@@ -19,8 +19,7 @@ import './css/style.css';
19
19
  export const DateRangeCalendar = props => {
20
20
  const {
21
21
  minBookingDate,
22
- numberOfMonthsMobile,
23
- numberOfMonthsDesktop,
22
+ numberOfMonthsVisible,
24
23
  dateFormat,
25
24
  minBookingDays,
26
25
  onDayRender,
@@ -30,22 +29,12 @@ export const DateRangeCalendar = props => {
30
29
  onFocusChange,
31
30
  startDate,
32
31
  endDate,
33
- variant
32
+ variant,
33
+ zIndex
34
34
  } = props;
35
35
 
36
- const isValidRenderFunction = functionToCheck => {
37
- try {
38
- //Makes sure we have a function and also that it's a valid react element which the calendar will use to display the date.
39
- return functionToCheck && /*#__PURE__*/React.isValidElement(functionToCheck) ? true : false;
40
- } catch (error) {
41
- console.error(error);
42
- }
43
-
44
- return false;
45
- };
46
-
47
36
  const handleOnDayRender = date => {
48
- return /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender && isValidRenderFunction(onDayRender(date)) ? /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender(date)) : /*#__PURE__*/React.createElement("span", {
37
+ return /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender ? /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender(date)) : /*#__PURE__*/React.createElement("span", {
49
38
  className: ""
50
39
  }, new Date(date).getDate()));
51
40
  };
@@ -103,7 +92,10 @@ export const DateRangeCalendar = props => {
103
92
  selectDateDateFontSize: 18,
104
93
  dateRangeArrowIconColor: orange[700],
105
94
  inputLabelBorder: variant === 'outlined' ? undefined : 'none',
106
- datepickerBorderRadius: 5
95
+ datepickerBorderRadius: 5,
96
+ datepickerZIndex: zIndex,
97
+ dateRangeZIndex: zIndex,
98
+ dateSingleZIndex: zIndex
107
99
  }
108
100
  }
109
101
  }, /*#__PURE__*/React.createElement(DateRangeInput, {
@@ -126,8 +118,8 @@ export const DateRangeCalendar = props => {
126
118
  firstDayOfWeek: 0,
127
119
  minBookingDays: minBookingDays,
128
120
  minBookingDate: minBookingDate,
129
- vertical: window.innerWidth < 800 ? true : false,
130
- numberOfMonths: window.innerWidth < 800 ? numberOfMonthsMobile : numberOfMonthsDesktop,
121
+ vertical: vertical,
122
+ numberOfMonths: numberOfMonthsVisible,
131
123
  onDatesChange: handleOnDatesChange,
132
124
  onFocusChange: handleOnFocusChange,
133
125
  startDate: startDate // Date or null
@@ -141,8 +133,7 @@ export const DateRangeCalendar = props => {
141
133
  export default DateRangeCalendar;
142
134
  DateRangeCalendar.defaultProps = {
143
135
  minBookingDate: new Date(new Date().setDate(new Date().getDate() + 1)),
144
- numberOfMonthsMobile: 1,
145
- numberOfMonthsDesktop: 2,
136
+ numberOfMonthsVisible: 2,
146
137
  dateFormat: 'MMM d, yyyy',
147
138
  minBookingDays: 1,
148
139
  onDayRender: undefined,
@@ -152,17 +143,16 @@ DateRangeCalendar.defaultProps = {
152
143
  startDate: null,
153
144
  endDate: null,
154
145
  focusedInput: null,
155
- variant: 'standard'
146
+ variant: 'standard',
147
+ vertical: false,
148
+ zIndex: 1000
156
149
  };
157
150
  DateRangeCalendar.propTypes = {
158
151
  /** Used to provide the minimum booking date. To allow date selection past todays date simply pas it an old past date example 'new Date('1999-10-02')' */
159
152
  minBookingDate: PropTypes.instanceOf(Date),
160
153
 
161
- /** Number of calendar months to display when we are in mobile view.*/
162
- numberOfMonthsMobile: PropTypes.number,
163
-
164
- /** Number of calendar months to display when we are in desktop view.*/
165
- numberOfMonthsDesktop: PropTypes.number,
154
+ /** Number of calendar months to display.*/
155
+ numberOfMonthsVisible: PropTypes.number,
166
156
 
167
157
  /** Date format to use when displaying the selected dates in the text boxes.*/
168
158
  dateFormat: PropTypes.string,
@@ -192,5 +182,11 @@ DateRangeCalendar.propTypes = {
192
182
  focusedInput: PropTypes.oneOf(['startDate', 'endDate', null]),
193
183
 
194
184
  /** Controls the type of border to display around the date input boxes*/
195
- variant: PropTypes.oneOf(['outlined', 'standard', 'none'])
185
+ variant: PropTypes.oneOf(['outlined', 'standard', 'none']),
186
+
187
+ /** Controls the orientation of the calendar */
188
+ vertical: PropTypes.bool,
189
+
190
+ /** Controls the z-index of the calendar dropdown date selection */
191
+ zIndex: PropTypes.number
196
192
  };
@@ -94,5 +94,7 @@ ReusableMenu.propTypes = {
94
94
  * 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
95
95
  */
96
96
  theme: PropTypes.object,
97
+
98
+ /** Controls the location of the dropdown popup menu */
97
99
  menuAnchorLocation: PropTypes.oneOf(['left', 'center', 'right'])
98
100
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "0.0.138",
3
+ "version": "0.0.141",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {