react-datetime-picker
Advanced tools
Comparing version 4.1.1 to 4.2.0
@@ -32,6 +32,6 @@ "use strict"; | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
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; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
@@ -45,3 +45,5 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -52,3 +54,3 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
var getFormatterOptionsCache = {}; | ||
@@ -435,3 +437,3 @@ var defaultMinDate = new Date(); | ||
key: "hour12" | ||
}, _this.commonInputProps, { | ||
}, _this.commonInputProps, _this.commonTimeInputProps, { | ||
amPm: amPm, | ||
@@ -460,3 +462,3 @@ ariaLabel: hourAriaLabel | ||
key: "hour24" | ||
}, _this.commonInputProps, { | ||
}, _this.commonInputProps, _this.commonTimeInputProps, { | ||
ariaLabel: hourAriaLabel | ||
@@ -486,3 +488,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
key: "minute" | ||
}, _this.commonInputProps, { | ||
}, _this.commonInputProps, _this.commonTimeInputProps, { | ||
ariaLabel: minuteAriaLabel | ||
@@ -514,3 +516,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
key: "second" | ||
}, _this.commonInputProps, { | ||
}, _this.commonInputProps, _this.commonTimeInputProps, { | ||
ariaLabel: secondAriaLabel | ||
@@ -536,3 +538,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
key: "ampm" | ||
}, _this.commonInputProps, { | ||
}, _this.commonInputProps, _this.commonTimeInputProps, { | ||
ariaLabel: amPmAriaLabel | ||
@@ -650,3 +652,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
} | ||
return (0, _dateUtils.getHoursMinutesSeconds)(maxDate); | ||
return (0, _dateUtils.getHoursMinutesSeconds)(maxDate || defaultMaxDate); | ||
} | ||
@@ -667,3 +669,3 @@ }, { | ||
} | ||
return (0, _dateUtils.getHoursMinutesSeconds)(minDate); | ||
return (0, _dateUtils.getHoursMinutesSeconds)(minDate || defaultMinDate); | ||
} | ||
@@ -670,0 +672,0 @@ }, { |
@@ -56,2 +56,3 @@ "use strict"; | ||
disabled: disabled, | ||
hidden: true, | ||
max: maxDate ? nativeValueParser(maxDate) : null, | ||
@@ -58,0 +59,0 @@ min: minDate ? nativeValueParser(minDate) : null, |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -24,2 +23,3 @@ value: true | ||
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"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _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; } | ||
@@ -31,7 +31,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
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; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
@@ -45,3 +45,5 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var allViews = ['hour', 'minute', 'second']; | ||
@@ -420,2 +422,3 @@ var baseClassName = 'react-datetime-picker'; | ||
className = _this$props6.className, | ||
dataTestid = _this$props6['data-testid'], | ||
disabled = _this$props6.disabled; | ||
@@ -428,3 +431,4 @@ var _this$state4 = this.state, | ||
return /*#__PURE__*/_react["default"].createElement("div", _extends({ | ||
className: (0, _clsx["default"])(baseClassName, "".concat(baseClassName, "--").concat(isCalendarOpen || isClockOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className) | ||
className: (0, _clsx["default"])(baseClassName, "".concat(baseClassName, "--").concat(isCalendarOpen || isClockOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className), | ||
"data-testid": dataTestid | ||
}, eventPropsWithoutOnChange, { | ||
@@ -514,2 +518,3 @@ onFocus: this.onFocus, | ||
closeWidgets: _propTypes["default"].bool, | ||
'data-testid': _propTypes["default"].string, | ||
dayAriaLabel: _propTypes["default"].string, | ||
@@ -516,0 +521,0 @@ dayPlaceholder: _propTypes["default"].string, |
@@ -12,4 +12,4 @@ "use strict"; | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
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; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
@@ -16,0 +16,0 @@ /** |
{ | ||
"name": "react-datetime-picker", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "A date range picker for your React app.", | ||
@@ -8,5 +8,4 @@ "main": "dist/entry.js", | ||
"scripts": { | ||
"build": "yarn build-js && yarn copy-styles && yarn build-styles", | ||
"build": "yarn build-js && yarn copy-styles", | ||
"build-js": "babel src -d dist --ignore \"**/*.spec.js,**/*.spec.jsx\"", | ||
"build-styles": "lessc ./dist/DateTimePicker.less ./dist/DateTimePicker.css", | ||
"clean": "rimraf dist", | ||
@@ -43,5 +42,5 @@ "copy-styles": "node ./copy-styles.js", | ||
"react-clock": "^4.0.0", | ||
"react-date-picker": "^9.1.0", | ||
"react-date-picker": "^9.2.0", | ||
"react-fit": "^1.4.0", | ||
"react-time-picker": "^5.1.0" | ||
"react-time-picker": "^5.2.0" | ||
}, | ||
@@ -55,2 +54,3 @@ "devDependencies": { | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/user-event": "^14.4.0", | ||
"eslint": "^8.26.0", | ||
@@ -61,3 +61,2 @@ "eslint-config-wojtekmaj": "^0.7.1", | ||
"jest-environment-jsdom": "^29.0.0", | ||
"less": "^4.0.0", | ||
"prettier": "^2.7.0", | ||
@@ -64,0 +63,0 @@ "pretty-quick": "^3.1.0", |
@@ -96,2 +96,3 @@ [![npm](https://img.shields.io/npm/v/react-datetime-picker.svg)](https://www.npmjs.com/package/react-datetime-picker) ![downloads](https://img.shields.io/npm/dt/react-datetime-picker.svg) [![CI](https://github.com/wojtekmaj/react-datetime-picker/workflows/CI/badge.svg)](https://github.com/wojtekmaj/react-datetime-picker/actions) ![dependencies](https://img.shields.io/david/wojtekmaj/react-datetime-picker.svg) ![dev dependencies](https://img.shields.io/david/dev/wojtekmaj/react-datetime-picker.svg) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) | ||
| closeWidgets | Whether to close the widgets on value selection. | `true` | `false` | | ||
| data-testid | `data-testid` attribute for the main React-DateTime-Picker `<div>` element. | n/a | `"date-picker"` | | ||
| dayAriaLabel | `aria-label` for the day input. | n/a | `"Day"` | | ||
@@ -98,0 +99,0 @@ | dayPlaceholder | `placeholder` for the day input. | `"--"` | `"dd"` | |
@@ -346,3 +346,3 @@ import React, { createRef, PureComponent } from 'react'; | ||
return getHoursMinutesSeconds(maxDate); | ||
return getHoursMinutesSeconds(maxDate || defaultMaxDate); | ||
} | ||
@@ -363,3 +363,3 @@ | ||
return getHoursMinutesSeconds(minDate); | ||
return getHoursMinutesSeconds(minDate || defaultMinDate); | ||
} | ||
@@ -686,2 +686,3 @@ | ||
{...this.commonInputProps} | ||
{...this.commonTimeInputProps} | ||
amPm={amPm} | ||
@@ -713,2 +714,3 @@ ariaLabel={hourAriaLabel} | ||
{...this.commonInputProps} | ||
{...this.commonTimeInputProps} | ||
ariaLabel={hourAriaLabel} | ||
@@ -739,2 +741,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
{...this.commonInputProps} | ||
{...this.commonTimeInputProps} | ||
ariaLabel={minuteAriaLabel} | ||
@@ -766,2 +769,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
{...this.commonInputProps} | ||
{...this.commonTimeInputProps} | ||
ariaLabel={secondAriaLabel} | ||
@@ -788,2 +792,3 @@ // eslint-disable-next-line jsx-a11y/no-autofocus | ||
{...this.commonInputProps} | ||
{...this.commonTimeInputProps} | ||
ariaLabel={amPmAriaLabel} | ||
@@ -790,0 +795,0 @@ // eslint-disable-next-line jsx-a11y/no-autofocus |
@@ -21,6 +21,6 @@ import React from 'react'; | ||
const keyCodes = { | ||
'ArrowLeft': 37, | ||
'ArrowUp': 38, | ||
'ArrowRight': 39, | ||
'ArrowDown': 40, | ||
ArrowLeft: 37, | ||
ArrowUp: 38, | ||
ArrowRight: 39, | ||
ArrowDown: 40, | ||
'-': 189, | ||
@@ -27,0 +27,0 @@ '.': 190, |
@@ -58,2 +58,3 @@ import React from 'react'; | ||
disabled={disabled} | ||
hidden | ||
max={maxDate ? nativeValueParser(maxDate) : null} | ||
@@ -60,0 +61,0 @@ min={minDate ? nativeValueParser(minDate) : null} |
@@ -452,3 +452,3 @@ import React, { createRef, PureComponent } from 'react'; | ||
const { eventProps } = this; | ||
const { className, disabled } = this.props; | ||
const { className, 'data-testid': dataTestid, disabled } = this.props; | ||
const { isCalendarOpen, isClockOpen } = this.state; | ||
@@ -466,2 +466,3 @@ | ||
)} | ||
data-testid={dataTestid} | ||
{...eventPropsWithoutOnChange} | ||
@@ -532,2 +533,3 @@ onFocus={this.onFocus} | ||
closeWidgets: PropTypes.bool, | ||
'data-testid': PropTypes.string, | ||
dayAriaLabel: PropTypes.string, | ||
@@ -534,0 +536,0 @@ dayPlaceholder: PropTypes.string, |
import React, { createRef } from 'react'; | ||
import { act, fireEvent, render, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import { act, fireEvent, render, waitFor, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import DateTimePicker from './DateTimePicker'; | ||
async function waitForElementToBeRemovedOrHidden(callback) { | ||
const element = callback(); | ||
if (element) { | ||
try { | ||
await waitFor(() => | ||
expect(element).toHaveAttribute('class', expect.stringContaining('--closed')), | ||
); | ||
} catch (error) { | ||
await waitForElementToBeRemoved(element); | ||
} | ||
} | ||
} | ||
describe('DateTimePicker', () => { | ||
@@ -412,3 +427,3 @@ it('passes default name to DateTimeInput', () => { | ||
it('closes Calendar component when clicked outside', () => { | ||
it('closes Calendar component when clicked outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -419,8 +434,10 @@ document.body.appendChild(root); | ||
fireEvent.mouseDown(document.body); | ||
userEvent.click(document.body); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-calendar')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__calendar'), | ||
); | ||
}); | ||
it('closes Calendar component when focused outside', () => { | ||
it('closes Calendar component when focused outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -433,6 +450,8 @@ document.body.appendChild(root); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-calendar')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__calendar'), | ||
); | ||
}); | ||
it('closes Calendar component when tapped outside', () => { | ||
it('closes Calendar component when tapped outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -443,6 +462,10 @@ document.body.appendChild(root); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-calendar')); | ||
fireEvent.touchStart(document.body); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__calendar'), | ||
); | ||
}); | ||
it('closes Clock component when clicked outside', () => { | ||
it('closes Clock component when clicked outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -453,8 +476,10 @@ document.body.appendChild(root); | ||
fireEvent.mouseDown(document.body); | ||
userEvent.click(document.body); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-clock')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__clock'), | ||
); | ||
}); | ||
it('closes Clock component when focused outside', () => { | ||
it('closes Clock component when focused outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -467,6 +492,8 @@ document.body.appendChild(root); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-clock')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__clock'), | ||
); | ||
}); | ||
it('closes Clock component when tapped outside', () => { | ||
it('closes Clock component when tapped outside', async () => { | ||
const root = document.createElement('div'); | ||
@@ -479,3 +506,5 @@ document.body.appendChild(root); | ||
waitForElementToBeRemoved(() => container.querySelector('.react-clock')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__clock'), | ||
); | ||
}); | ||
@@ -513,3 +542,3 @@ | ||
it('closes Clock when Calendar is opened by a click on the calendar icon', () => { | ||
it('closes Clock when Calendar is opened by a click on the calendar icon', async () => { | ||
const { container } = render(<DateTimePicker isClockOpen />); | ||
@@ -524,6 +553,8 @@ | ||
waitForElementToBeRemoved(() => container.querySelector('.react-clock')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__clock'), | ||
); | ||
}); | ||
it('closes Calendar when calling internal onChange by default', () => { | ||
it('closes Calendar when calling internal onChange by default', async () => { | ||
const instance = createRef(); | ||
@@ -539,3 +570,5 @@ | ||
waitForElementToBeRemoved(() => container.querySelector('.react-calendar')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__calendar'), | ||
); | ||
}); | ||
@@ -577,3 +610,3 @@ | ||
it('closes Clock when calling internal onChange by default', () => { | ||
it('closes Clock when calling internal onChange by default', async () => { | ||
const instance = createRef(); | ||
@@ -589,3 +622,5 @@ | ||
waitForElementToBeRemoved(() => container.querySelector('.react-clock')); | ||
await waitForElementToBeRemovedOrHidden(() => | ||
container.querySelector('.react-datetime-picker__clock'), | ||
); | ||
}); | ||
@@ -592,0 +627,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227474
4711
161
31
Updatedreact-date-picker@^9.2.0
Updatedreact-time-picker@^5.2.0