pcm-shared-components 0.0.139 → 0.0.142

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.
@@ -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,13 @@ export const DateRangeCalendar = props => {
30
29
  onFocusChange,
31
30
  startDate,
32
31
  endDate,
33
- variant
32
+ variant,
33
+ vertical,
34
+ zIndex
34
35
  } = props;
35
36
 
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
37
  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", {
38
+ return /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender ? /*#__PURE__*/React.createElement(React.Fragment, null, onDayRender(date)) : /*#__PURE__*/React.createElement("span", {
49
39
  className: ""
50
40
  }, new Date(date).getDate()));
51
41
  };
@@ -103,7 +93,10 @@ export const DateRangeCalendar = props => {
103
93
  selectDateDateFontSize: 18,
104
94
  dateRangeArrowIconColor: orange[700],
105
95
  inputLabelBorder: variant === 'outlined' ? undefined : 'none',
106
- datepickerBorderRadius: 5
96
+ datepickerBorderRadius: 5,
97
+ datepickerZIndex: zIndex,
98
+ dateRangeZIndex: zIndex,
99
+ dateSingleZIndex: zIndex
107
100
  }
108
101
  }
109
102
  }, /*#__PURE__*/React.createElement(DateRangeInput, {
@@ -126,8 +119,8 @@ export const DateRangeCalendar = props => {
126
119
  firstDayOfWeek: 0,
127
120
  minBookingDays: minBookingDays,
128
121
  minBookingDate: minBookingDate,
129
- vertical: window.innerWidth < 800 ? true : false,
130
- numberOfMonths: window.innerWidth < 800 ? numberOfMonthsMobile : numberOfMonthsDesktop,
122
+ vertical: vertical,
123
+ numberOfMonths: numberOfMonthsVisible,
131
124
  onDatesChange: handleOnDatesChange,
132
125
  onFocusChange: handleOnFocusChange,
133
126
  startDate: startDate // Date or null
@@ -141,8 +134,7 @@ export const DateRangeCalendar = props => {
141
134
  export default DateRangeCalendar;
142
135
  DateRangeCalendar.defaultProps = {
143
136
  minBookingDate: new Date(new Date().setDate(new Date().getDate() + 1)),
144
- numberOfMonthsMobile: 1,
145
- numberOfMonthsDesktop: 2,
137
+ numberOfMonthsVisible: 2,
146
138
  dateFormat: 'MMM d, yyyy',
147
139
  minBookingDays: 1,
148
140
  onDayRender: undefined,
@@ -152,17 +144,16 @@ DateRangeCalendar.defaultProps = {
152
144
  startDate: null,
153
145
  endDate: null,
154
146
  focusedInput: null,
155
- variant: 'standard'
147
+ variant: 'standard',
148
+ vertical: false,
149
+ zIndex: 1000
156
150
  };
157
151
  DateRangeCalendar.propTypes = {
158
152
  /** 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
153
  minBookingDate: PropTypes.instanceOf(Date),
160
154
 
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,
155
+ /** Number of calendar months to display.*/
156
+ numberOfMonthsVisible: PropTypes.number,
166
157
 
167
158
  /** Date format to use when displaying the selected dates in the text boxes.*/
168
159
  dateFormat: PropTypes.string,
@@ -192,5 +183,11 @@ DateRangeCalendar.propTypes = {
192
183
  focusedInput: PropTypes.oneOf(['startDate', 'endDate', null]),
193
184
 
194
185
  /** Controls the type of border to display around the date input boxes*/
195
- variant: PropTypes.oneOf(['outlined', 'standard', 'none'])
186
+ variant: PropTypes.oneOf(['outlined', 'standard', 'none']),
187
+
188
+ /** Controls the orientation of the calendar */
189
+ vertical: PropTypes.bool,
190
+
191
+ /** Controls the z-index of the calendar dropdown date selection */
192
+ zIndex: PropTypes.number
196
193
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "0.0.139",
3
+ "version": "0.0.142",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {