@wojtekmaj/react-datetimerange-picker
Advanced tools
Comparing version 3.4.0 to 3.4.2
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -26,10 +28,12 @@ value: true | ||
var _excluded = ["calendarClassName", "className", "maxDetail", "onChange", "value"], | ||
_excluded2 = ["clockClassName", "className", "maxDetail", "onChange", "value"], | ||
_excluded3 = ["onChange"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
@@ -41,3 +45,3 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
@@ -54,3 +58,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
@@ -71,7 +75,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
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; } } | ||
@@ -198,2 +202,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
if (openWidgetsOnFocus) { | ||
if (event.target.getAttribute('data-select') === 'true') { | ||
return; | ||
} | ||
switch (event.target.name) { | ||
@@ -307,2 +315,7 @@ case 'day': | ||
}, { | ||
key: "eventProps", | ||
get: function get() { | ||
return (0, _makeEventProps["default"])(this.props); | ||
} | ||
}, { | ||
key: "handleOutsideActionListeners", | ||
@@ -446,3 +459,3 @@ value: function handleOutsideActionListeners(shouldListen) { | ||
value = _this$props4.value, | ||
calendarProps = _objectWithoutProperties(_this$props4, ["calendarClassName", "className", "maxDetail", "onChange", "value"]); | ||
calendarProps = _objectWithoutProperties(_this$props4, _excluded); | ||
@@ -475,3 +488,3 @@ var className = "".concat(baseClassName, "__calendar"); | ||
value = _this$props5.value, | ||
clockProps = _objectWithoutProperties(_this$props5, ["clockClassName", "className", "maxDetail", "onChange", "value"]); | ||
clockProps = _objectWithoutProperties(_this$props5, _excluded2); | ||
@@ -499,11 +512,14 @@ var className = "".concat(baseClassName, "__clock"); | ||
var eventProps = this.eventProps; | ||
var _this$props6 = this.props, | ||
className = _this$props6.className, | ||
disabled = _this$props6.disabled; | ||
var _this$state4 = this.state, | ||
isCalendarOpen = _this$state4.isCalendarOpen, | ||
isClockOpen = _this$state4.isClockOpen; | ||
var isOpen = this.state.isOpen; | ||
var onChange = eventProps.onChange, | ||
eventPropsWithoutOnChange = _objectWithoutProperties(eventProps, _excluded3); | ||
return /*#__PURE__*/_react["default"].createElement("div", _extends({ | ||
className: (0, _mergeClassNames["default"])(baseClassName, "".concat(baseClassName, "--").concat(isCalendarOpen || isClockOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className) | ||
}, this.eventProps, { | ||
className: (0, _mergeClassNames["default"])(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className) | ||
}, eventPropsWithoutOnChange, { | ||
onFocus: this.onFocus, | ||
@@ -519,7 +535,2 @@ ref: function ref(_ref3) { | ||
} | ||
}, { | ||
key: "eventProps", | ||
get: function get() { | ||
return (0, _makeEventProps["default"])(this.props); | ||
} | ||
}], [{ | ||
@@ -526,0 +537,0 @@ key: "getDerivedStateFromProps", |
{ | ||
"name": "@wojtekmaj/react-datetimerange-picker", | ||
"version": "3.4.0", | ||
"version": "3.4.2", | ||
"description": "A datetime range picker for your React app.", | ||
@@ -19,12 +19,2 @@ "main": "dist/entry.js", | ||
}, | ||
"jest": { | ||
"setupFiles": [ | ||
"<rootDir>/jest.setup.js" | ||
], | ||
"collectCoverageFrom": [ | ||
"**/src/**.{js,jsx}", | ||
"!**/src/entry.js", | ||
"!**/src/entry.nostyle.js" | ||
] | ||
}, | ||
"keywords": [ | ||
@@ -55,11 +45,10 @@ "calendar", | ||
"react-clock": "^3.0.0", | ||
"react-datetime-picker": "^3.4.0", | ||
"react-datetime-picker": "^3.4.1", | ||
"react-fit": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.0", | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-proposal-class-properties": "^7.8.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"@babel/preset-react": "^7.9.0", | ||
"@babel/cli": "^7.15.0", | ||
"@babel/core": "^7.15.0", | ||
"@babel/preset-env": "^7.15.0", | ||
"@babel/preset-react": "^7.14.0", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.0", | ||
@@ -70,3 +59,3 @@ "babel-eslint": "^10.0.0", | ||
"eslint-config-wojtekmaj": "^0.5.0", | ||
"jest": "^26.6.0", | ||
"jest": "^27.0.0", | ||
"less": "^4.0.0", | ||
@@ -73,0 +62,0 @@ "react": "^17.0.0", |
@@ -164,2 +164,6 @@ import React, { PureComponent } from 'react'; | ||
if (openWidgetsOnFocus) { | ||
if (event.target.getAttribute('data-select') === 'true') { | ||
return; | ||
} | ||
switch (event.target.name) { | ||
@@ -424,5 +428,8 @@ case 'day': | ||
render() { | ||
const { eventProps } = this; | ||
const { className, disabled } = this.props; | ||
const { isCalendarOpen, isClockOpen } = this.state; | ||
const { isOpen } = this.state; | ||
const { onChange, ...eventPropsWithoutOnChange } = eventProps; | ||
return ( | ||
@@ -432,7 +439,7 @@ <div | ||
baseClassName, | ||
`${baseClassName}--${isCalendarOpen || isClockOpen ? 'open' : 'closed'}`, | ||
`${baseClassName}--${isOpen ? 'open' : 'closed'}`, | ||
`${baseClassName}--${disabled ? 'disabled' : 'enabled'}`, | ||
className, | ||
)} | ||
{...this.eventProps} | ||
{...eventPropsWithoutOnChange} | ||
onFocus={this.onFocus} | ||
@@ -439,0 +446,0 @@ ref={(ref) => { |
@@ -415,2 +415,20 @@ import React from 'react'; | ||
}); | ||
it('does not open Calendar component when focusing on a select element', () => { | ||
const component = mount( | ||
<DateTimeRangePicker format="dd.MMMM.yyyy hh:mm:ss a" />, | ||
); | ||
const calendar = component.find('Calendar'); | ||
const select = component.find('select[name="month"]').first(); | ||
expect(calendar).toHaveLength(0); | ||
select.simulate('focus'); | ||
component.update(); | ||
const calendar2 = component.find('Calendar'); | ||
expect(calendar2).toHaveLength(0); | ||
}); | ||
}); | ||
@@ -472,2 +490,20 @@ | ||
}); | ||
it('does not open Clock component when focusing on a select element', () => { | ||
const component = mount( | ||
<DateTimeRangePicker format="dd.MMMM.yyyy hh:mm:ss a" />, | ||
); | ||
const clock = component.find('Clock'); | ||
const select = component.find('select[name="amPm"]').first(); | ||
expect(clock).toHaveLength(0); | ||
select.simulate('focus'); | ||
component.update(); | ||
const clock2 = component.find('Clock'); | ||
expect(clock2).toHaveLength(0); | ||
}); | ||
}); | ||
@@ -474,0 +510,0 @@ |
@@ -0,0 +0,0 @@ import 'react-calendar/dist/Calendar.css'; |
import DateTimeRangePicker from './DateTimeRangePicker'; | ||
export default DateTimeRangePicker; |
@@ -0,0 +0,0 @@ export const isMinDate = (props, propName, componentName) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
97659
14
1937
Updatedreact-datetime-picker@^3.4.1