envoc-form 2.0.1-13 → 2.0.1-14

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.
@@ -7,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- var _excluded = ["value", "className"];
10
+ var _excluded = ["value", "className", "maxDate"];
11
11
 
12
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
13
 
@@ -18,6 +18,7 @@ import DatePicker from 'react-date-picker';
18
18
  import parseISO from 'date-fns/parseISO';
19
19
  import classnames from 'classnames';
20
20
  var dateOnlyRegex = /^\d{4}-\d{2}-\d{2}$/;
21
+ var defaultMaxDate = new Date('9999-12-31');
21
22
 
22
23
  var DatePickerInput = /*#__PURE__*/function (_React$Component) {
23
24
  _inherits(DatePickerInput, _React$Component);
@@ -60,6 +61,8 @@ var DatePickerInput = /*#__PURE__*/function (_React$Component) {
60
61
  var _this$props = this.props,
61
62
  value = _this$props.value,
62
63
  className = _this$props.className,
64
+ _this$props$maxDate = _this$props.maxDate,
65
+ maxDate = _this$props$maxDate === void 0 ? defaultMaxDate : _this$props$maxDate,
63
66
  rest = _objectWithoutProperties(_this$props, _excluded);
64
67
 
65
68
  if (value && !dateOnlyRegex.test(value)) {
@@ -80,7 +83,8 @@ var DatePickerInput = /*#__PURE__*/function (_React$Component) {
80
83
  }, rest, {
81
84
  value: parsedValue,
82
85
  onChange: this.handleChange,
83
- onBlur: this.handleBlur
86
+ onBlur: this.handleBlur,
87
+ maxDate: maxDate
84
88
  }));
85
89
  }
86
90
  }]);
@@ -33,13 +33,14 @@ var _parseISO = _interopRequireDefault(require("date-fns/parseISO"));
33
33
 
34
34
  var _classnames = _interopRequireDefault(require("classnames"));
35
35
 
36
- var _excluded = ["value", "className"];
36
+ var _excluded = ["value", "className", "maxDate"];
37
37
 
38
38
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
39
39
 
40
40
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
41
 
42
42
  var dateOnlyRegex = /^\d{4}-\d{2}-\d{2}$/;
43
+ var defaultMaxDate = new Date('9999-12-31');
43
44
 
44
45
  var DatePickerInput = /*#__PURE__*/function (_React$Component) {
45
46
  (0, _inherits2["default"])(DatePickerInput, _React$Component);
@@ -79,6 +80,8 @@ var DatePickerInput = /*#__PURE__*/function (_React$Component) {
79
80
  var _this$props = this.props,
80
81
  value = _this$props.value,
81
82
  className = _this$props.className,
83
+ _this$props$maxDate = _this$props.maxDate,
84
+ maxDate = _this$props$maxDate === void 0 ? defaultMaxDate : _this$props$maxDate,
82
85
  rest = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
83
86
 
84
87
  if (value && !dateOnlyRegex.test(value)) {
@@ -99,7 +102,8 @@ var DatePickerInput = /*#__PURE__*/function (_React$Component) {
99
102
  }, rest, {
100
103
  value: parsedValue,
101
104
  onChange: this.handleChange,
102
- onBlur: this.handleBlur
105
+ onBlur: this.handleBlur,
106
+ maxDate: maxDate
103
107
  }));
104
108
  }
105
109
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envoc-form",
3
- "version": "2.0.1-13",
3
+ "version": "2.0.1-14",
4
4
  "description": "Envoc form components",
5
5
  "keywords": [
6
6
  "react-component",
@@ -37,7 +37,7 @@
37
37
  "axios": "^0.21.1",
38
38
  "classnames": "^2.3.1",
39
39
  "date-fns": "^2.22.1",
40
- "envoc-request": "^2.0.1-13",
40
+ "envoc-request": "^2.0.1-14",
41
41
  "lru-cache": "^6.0.0",
42
42
  "prop-types": "^15.7.2",
43
43
  "react-date-picker": "^8.2.0",
@@ -4,9 +4,11 @@ import parseISO from 'date-fns/parseISO';
4
4
  import classnames from 'classnames';
5
5
 
6
6
  const dateOnlyRegex = /^\d{4}-\d{2}-\d{2}$/;
7
+ const defaultMaxDate = new Date('9999-12-31');
8
+
7
9
  export default class DatePickerInput extends React.Component {
8
10
  render() {
9
- const { value, className, ...rest } = this.props;
11
+ const { value, className, maxDate = defaultMaxDate, ...rest } = this.props;
10
12
 
11
13
  if (value && !dateOnlyRegex.test(value)) {
12
14
  const errorMessage = `Invalid date only value of ${value} passed to DatePicker input. This input is only configured to handle dates in the format yyyy-mm-dd. Ensure that the server is configured to return date only values.`;
@@ -27,6 +29,7 @@ export default class DatePickerInput extends React.Component {
27
29
  value={parsedValue}
28
30
  onChange={this.handleChange}
29
31
  onBlur={this.handleBlur}
32
+ maxDate={maxDate}
30
33
  />
31
34
  );
32
35
  }