baseui 10.12.1 → 11.0.2
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.
- package/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +10 -2
- package/data-table/data-table.js.flow +4 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +28 -15
- package/datepicker/calendar.js.flow +31 -14
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +117 -86
- package/datepicker/datepicker.js.flow +123 -66
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -3
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +46 -43
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +6 -2
- package/es/data-table/header-cell.js +3 -0
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +28 -15
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +106 -79
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/datepicker/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/form-control/styled-components.js +0 -1
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +20 -20
- package/es/select/styled-components.js +21 -17
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +10 -2
- package/esm/data-table/header-cell.js +3 -0
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +28 -15
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +116 -86
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/datepicker/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/form-control/styled-components.js +0 -1
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +20 -20
- package/esm/select/styled-components.js +21 -14
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +3 -2
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +0 -2
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +23 -24
- package/select/select-component.js.flow +25 -14
- package/select/styled-components.js +23 -17
- package/select/styled-components.js.flow +17 -12
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/tag/types.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
|
@@ -2,6 +2,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
5
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
10
|
|
|
7
11
|
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."); }
|
|
@@ -10,10 +14,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.it
|
|
|
10
14
|
|
|
11
15
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
16
|
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
18
|
|
|
19
19
|
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); } }
|
|
@@ -64,27 +64,28 @@ import { LocaleContext } from '../locale/index.js';
|
|
|
64
64
|
import { StyledInputWrapper, StyledInputLabel, StyledStartDate, StyledEndDate } from './styled-components.js';
|
|
65
65
|
import DateHelpers from './utils/date-helpers.js';
|
|
66
66
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
67
|
+
import { INPUT_ROLE, RANGED_CALENDAR_BEHAVIOR } from './constants.js';
|
|
67
68
|
export var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
68
|
-
var INPUT_DELIMITER = '
|
|
69
|
+
var INPUT_DELIMITER = '–';
|
|
69
70
|
|
|
70
71
|
var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
|
|
71
72
|
var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
72
|
-
var
|
|
73
|
+
var inputRole = arguments.length > 2 ? arguments[2] : undefined;
|
|
73
74
|
var inputValue = newInputValue;
|
|
74
75
|
|
|
75
|
-
var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
|
|
76
|
+
var _prevCombinedInputVal = prevCombinedInputValue.split(" ".concat(INPUT_DELIMITER, " ")),
|
|
76
77
|
_prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
|
|
77
78
|
_prevCombinedInputVal3 = _prevCombinedInputVal2[0],
|
|
78
79
|
prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
|
|
79
80
|
_prevCombinedInputVal4 = _prevCombinedInputVal2[1],
|
|
80
81
|
prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
|
|
81
82
|
|
|
82
|
-
if (
|
|
83
|
-
inputValue = "".concat(inputValue, "
|
|
83
|
+
if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
|
|
84
|
+
inputValue = "".concat(inputValue, " ").concat(INPUT_DELIMITER, " ").concat(prevEndDate);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
if (
|
|
87
|
-
inputValue = "".concat(prevStartDate, "
|
|
87
|
+
if (inputRole === INPUT_ROLE.endDate) {
|
|
88
|
+
inputValue = "".concat(prevStartDate, " ").concat(INPUT_DELIMITER, " ").concat(inputValue);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
return inputValue;
|
|
@@ -100,31 +101,72 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
100
101
|
|
|
101
102
|
_classCallCheck(this, Datepicker);
|
|
102
103
|
|
|
103
|
-
_this = _super.call(this, props); //$FlowFixMe
|
|
104
|
+
_this = _super.call(this, props); //$FlowFixMe[incompatible-call]
|
|
104
105
|
|
|
105
106
|
_defineProperty(_assertThisInitialized(_this), "calendar", void 0);
|
|
106
107
|
|
|
107
108
|
_defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
|
|
108
109
|
|
|
109
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
|
|
111
|
+
var onChange = _this.props.onChange;
|
|
112
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
113
|
+
|
|
114
|
+
if (Array.isArray(date)) {
|
|
115
|
+
if (onChange && date.every(Boolean)) {
|
|
116
|
+
// flowlint-next-line unclear-type:off
|
|
117
|
+
onChange({
|
|
118
|
+
date: date
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (onRangeChange) {
|
|
123
|
+
onRangeChange({
|
|
124
|
+
date: _toConsumableArray(date)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
if (onChange) {
|
|
129
|
+
onChange({
|
|
130
|
+
date: date
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (onRangeChange) {
|
|
135
|
+
onRangeChange({
|
|
136
|
+
date: date
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (data) {
|
|
110
143
|
var isOpen = false;
|
|
111
144
|
var isPseudoFocused = false;
|
|
112
145
|
var calendarFocused = false;
|
|
113
146
|
var nextDate = data.date;
|
|
114
147
|
|
|
115
148
|
if (Array.isArray(nextDate) && _this.props.range) {
|
|
116
|
-
if (nextDate
|
|
149
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
117
150
|
isOpen = true;
|
|
118
151
|
isPseudoFocused = true;
|
|
119
152
|
calendarFocused = null;
|
|
120
|
-
} else if (nextDate
|
|
153
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
121
154
|
var _nextDate = nextDate,
|
|
122
155
|
_nextDate2 = _slicedToArray(_nextDate, 2),
|
|
123
156
|
start = _nextDate2[0],
|
|
124
157
|
end = _nextDate2[1];
|
|
125
158
|
|
|
126
159
|
if (_this.dateHelpers.isAfter(start, end)) {
|
|
127
|
-
|
|
160
|
+
if (_this.hasLockedBehavior()) {
|
|
161
|
+
nextDate = _this.props.value;
|
|
162
|
+
isOpen = true;
|
|
163
|
+
} else {
|
|
164
|
+
nextDate = [start, start];
|
|
165
|
+
}
|
|
166
|
+
} else if (_this.dateHelpers.dateRangeIncludesDates( // $FlowFixMe Cannot call `this.dateHelpers.dateRangeIncludesDates` with `nextDate` bound to the first parameter because read-only array type [1] is incompatible with array type [2]
|
|
167
|
+
nextDate, _this.props.excludeDates)) {
|
|
168
|
+
nextDate = _this.props.value;
|
|
169
|
+
isOpen = true;
|
|
128
170
|
}
|
|
129
171
|
|
|
130
172
|
if (_this.state.lastActiveElm) {
|
|
@@ -174,9 +216,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
174
216
|
inputValue: _this.formatDisplayValue(nextDate)
|
|
175
217
|
}));
|
|
176
218
|
|
|
177
|
-
_this.
|
|
178
|
-
date: nextDate
|
|
179
|
-
});
|
|
219
|
+
_this.handleChange(nextDate);
|
|
180
220
|
});
|
|
181
221
|
|
|
182
222
|
_defineProperty(_assertThisInitialized(_this), "formatDisplayValue", function (date) {
|
|
@@ -216,11 +256,12 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
216
256
|
return _this.formatDate(date, formatString);
|
|
217
257
|
});
|
|
218
258
|
|
|
219
|
-
_defineProperty(_assertThisInitialized(_this), "open", function () {
|
|
259
|
+
_defineProperty(_assertThisInitialized(_this), "open", function (inputRole) {
|
|
220
260
|
_this.setState({
|
|
221
261
|
isOpen: true,
|
|
222
262
|
isPseudoFocused: true,
|
|
223
|
-
calendarFocused: false
|
|
263
|
+
calendarFocused: false,
|
|
264
|
+
selectedInput: inputRole
|
|
224
265
|
}, _this.props.onOpen);
|
|
225
266
|
});
|
|
226
267
|
|
|
@@ -229,6 +270,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
229
270
|
|
|
230
271
|
_this.setState({
|
|
231
272
|
isOpen: false,
|
|
273
|
+
selectedInput: null,
|
|
232
274
|
isPseudoFocused: isPseudoFocused,
|
|
233
275
|
calendarFocused: false
|
|
234
276
|
}, _this.props.onClose);
|
|
@@ -264,30 +306,24 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
264
306
|
}
|
|
265
307
|
|
|
266
308
|
if (range && !separateRangeInputs) {
|
|
267
|
-
return
|
|
309
|
+
return "9999/99/99 ".concat(INPUT_DELIMITER, " 9999/99/99");
|
|
268
310
|
}
|
|
269
311
|
|
|
270
312
|
return '9999/99/99';
|
|
271
313
|
});
|
|
272
314
|
|
|
273
|
-
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event,
|
|
274
|
-
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue,
|
|
315
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, inputRole) {
|
|
316
|
+
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, inputRole) : event.currentTarget.value;
|
|
275
317
|
|
|
276
318
|
var mask = _this.getMask();
|
|
277
319
|
|
|
278
320
|
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
279
321
|
|
|
280
322
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
281
|
-
if (_this.props.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
});
|
|
286
|
-
} else {
|
|
287
|
-
_this.props.onChange({
|
|
288
|
-
date: null
|
|
289
|
-
});
|
|
290
|
-
}
|
|
323
|
+
if (_this.props.range) {
|
|
324
|
+
_this.handleChange([]);
|
|
325
|
+
} else {
|
|
326
|
+
_this.handleChange(null);
|
|
291
327
|
}
|
|
292
328
|
}
|
|
293
329
|
|
|
@@ -304,7 +340,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
304
340
|
};
|
|
305
341
|
|
|
306
342
|
if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
|
|
307
|
-
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
|
|
343
|
+
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(" ".concat(INPUT_DELIMITER, " ")),
|
|
308
344
|
_this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
|
|
309
345
|
left = _this$normalizeDashes2[0],
|
|
310
346
|
right = _this$normalizeDashes2[1];
|
|
@@ -318,19 +354,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
318
354
|
endDate = parseDateString(right);
|
|
319
355
|
}
|
|
320
356
|
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
if (onChange) {
|
|
324
|
-
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
357
|
+
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
325
358
|
|
|
326
359
|
|
|
327
|
-
|
|
360
|
+
var rangeValid = _this.dateHelpers.isAfter(endDate, startDate) || _this.dateHelpers.isEqual(startDate, endDate);
|
|
328
361
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
date: [startDate, endDate]
|
|
332
|
-
});
|
|
333
|
-
}
|
|
362
|
+
if (datesValid && rangeValid) {
|
|
363
|
+
_this.handleChange([startDate, endDate]);
|
|
334
364
|
}
|
|
335
365
|
} else {
|
|
336
366
|
var dateString = _this.normalizeDashes(inputValue);
|
|
@@ -348,11 +378,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
348
378
|
|
|
349
379
|
var _this$props3 = _this.props,
|
|
350
380
|
displayValueAtRangeIndex = _this$props3.displayValueAtRangeIndex,
|
|
351
|
-
_onChange = _this$props3.onChange,
|
|
352
381
|
range = _this$props3.range,
|
|
353
382
|
value = _this$props3.value;
|
|
354
383
|
|
|
355
|
-
if (date && _this.dateHelpers.isValid(date)
|
|
384
|
+
if (date && _this.dateHelpers.isValid(date)) {
|
|
356
385
|
if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
|
|
357
386
|
var _value = _slicedToArray(value, 2),
|
|
358
387
|
_left = _value[0],
|
|
@@ -362,22 +391,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
362
391
|
_left = date;
|
|
363
392
|
|
|
364
393
|
if (!_right) {
|
|
365
|
-
|
|
366
|
-
date: [_left]
|
|
367
|
-
});
|
|
394
|
+
_this.handleChange([_left]);
|
|
368
395
|
} else {
|
|
369
396
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
370
|
-
|
|
371
|
-
date: [_left, _right]
|
|
372
|
-
});
|
|
397
|
+
_this.handleChange([_left, _right]);
|
|
373
398
|
} else {
|
|
374
399
|
// Is resetting back to previous value appropriate? Invalid range is not
|
|
375
400
|
// communicated to the user, but if it was not reset the text value would
|
|
376
401
|
// show one value and date value another. This seems a bit better but clearly
|
|
377
402
|
// has a downside.
|
|
378
|
-
|
|
379
|
-
date: _toConsumableArray(value)
|
|
380
|
-
});
|
|
403
|
+
_this.handleChange(_toConsumableArray(value));
|
|
381
404
|
}
|
|
382
405
|
}
|
|
383
406
|
} else if (displayValueAtRangeIndex === 1) {
|
|
@@ -385,26 +408,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
385
408
|
|
|
386
409
|
if (!_left) {
|
|
387
410
|
// If start value is not defined, set start/end to the same day.
|
|
388
|
-
|
|
389
|
-
date: [_right, _right]
|
|
390
|
-
});
|
|
411
|
+
_this.handleChange([_right, _right]);
|
|
391
412
|
} else {
|
|
392
413
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
393
|
-
|
|
394
|
-
date: [_left, _right]
|
|
395
|
-
});
|
|
414
|
+
_this.handleChange([_left, _right]);
|
|
396
415
|
} else {
|
|
397
416
|
// See comment above about resetting dates on invalid range
|
|
398
|
-
|
|
399
|
-
date: _toConsumableArray(value)
|
|
400
|
-
});
|
|
417
|
+
_this.handleChange(_toConsumableArray(value));
|
|
401
418
|
}
|
|
402
419
|
}
|
|
403
420
|
}
|
|
404
421
|
} else {
|
|
405
|
-
|
|
406
|
-
date: date
|
|
407
|
-
});
|
|
422
|
+
_this.handleChange(date);
|
|
408
423
|
}
|
|
409
424
|
}
|
|
410
425
|
}
|
|
@@ -436,13 +451,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
436
451
|
|
|
437
452
|
_defineProperty(_assertThisInitialized(_this), "normalizeDashes", function (inputValue) {
|
|
438
453
|
// replacing both hyphens and em-dashes with en-dashes
|
|
439
|
-
return inputValue.replace(/-/g,
|
|
454
|
+
return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
_defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
|
|
458
|
+
return _this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
|
|
440
459
|
});
|
|
441
460
|
|
|
442
461
|
_this.dateHelpers = new DateHelpers(props.adapter);
|
|
443
462
|
_this.state = {
|
|
444
463
|
calendarFocused: false,
|
|
445
464
|
isOpen: false,
|
|
465
|
+
selectedInput: null,
|
|
446
466
|
isPseudoFocused: false,
|
|
447
467
|
lastActiveElm: null,
|
|
448
468
|
inputValue: _this.formatDisplayValue(props.value) || ''
|
|
@@ -451,6 +471,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
451
471
|
}
|
|
452
472
|
|
|
453
473
|
_createClass(Datepicker, [{
|
|
474
|
+
key: "getNullDatePlaceholder",
|
|
475
|
+
value: function getNullDatePlaceholder(formatString) {
|
|
476
|
+
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
454
479
|
key: "formatDate",
|
|
455
480
|
value: function formatDate(date, formatString) {
|
|
456
481
|
var _this2 = this;
|
|
@@ -467,10 +492,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
467
492
|
return '';
|
|
468
493
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
469
494
|
return '';
|
|
495
|
+
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
496
|
+
var endDate = format(date[1]);
|
|
497
|
+
var startDate = this.getNullDatePlaceholder(formatString);
|
|
498
|
+
return [startDate, endDate].join(" ".concat(INPUT_DELIMITER, " "));
|
|
470
499
|
} else if (Array.isArray(date)) {
|
|
471
500
|
return date.map(function (day) {
|
|
472
|
-
return format(day);
|
|
473
|
-
}).join(INPUT_DELIMITER);
|
|
501
|
+
return day ? format(day) : '';
|
|
502
|
+
}).join(" ".concat(INPUT_DELIMITER, " "));
|
|
474
503
|
} else {
|
|
475
504
|
return format(date);
|
|
476
505
|
}
|
|
@@ -486,7 +515,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
486
515
|
}
|
|
487
516
|
}, {
|
|
488
517
|
key: "renderInputComponent",
|
|
489
|
-
value: function renderInputComponent(locale,
|
|
518
|
+
value: function renderInputComponent(locale, inputRole) {
|
|
490
519
|
var _this3 = this;
|
|
491
520
|
|
|
492
521
|
var _this$props$overrides = this.props.overrides,
|
|
@@ -497,21 +526,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
497
526
|
InputComponent = _getOverrides2[0],
|
|
498
527
|
inputProps = _getOverrides2[1];
|
|
499
528
|
|
|
500
|
-
var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ?
|
|
529
|
+
var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? "YYYY/MM/DD ".concat(INPUT_DELIMITER, " YYYY/MM/DD") : 'YYYY/MM/DD';
|
|
501
530
|
|
|
502
|
-
var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
|
|
531
|
+
var _split = (this.state.inputValue || '').split(" ".concat(INPUT_DELIMITER, " ")),
|
|
503
532
|
_split2 = _slicedToArray(_split, 2),
|
|
504
533
|
_split2$ = _split2[0],
|
|
505
534
|
startDate = _split2$ === void 0 ? '' : _split2$,
|
|
506
535
|
_split2$2 = _split2[1],
|
|
507
536
|
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
508
537
|
|
|
509
|
-
var value =
|
|
510
|
-
|
|
511
|
-
var onChange = function onChange(event) {
|
|
512
|
-
return _this3.handleInputChange(event, separatedInput);
|
|
513
|
-
};
|
|
514
|
-
|
|
538
|
+
var value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
|
|
515
539
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
516
540
|
"aria-disabled": this.props.disabled,
|
|
517
541
|
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
@@ -523,10 +547,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
523
547
|
disabled: this.props.disabled,
|
|
524
548
|
size: this.props.size,
|
|
525
549
|
value: value,
|
|
526
|
-
onFocus:
|
|
550
|
+
onFocus: function onFocus() {
|
|
551
|
+
return _this3.open(inputRole);
|
|
552
|
+
},
|
|
527
553
|
onBlur: this.handleInputBlur,
|
|
528
554
|
onKeyDown: this.handleKeyDown,
|
|
529
|
-
onChange: onChange
|
|
555
|
+
onChange: function onChange(event) {
|
|
556
|
+
return _this3.handleInputChange(event, inputRole);
|
|
557
|
+
},
|
|
530
558
|
placeholder: placeholder,
|
|
531
559
|
mask: this.getMask(),
|
|
532
560
|
required: this.props.required,
|
|
@@ -586,11 +614,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
586
614
|
trapTabbing: true,
|
|
587
615
|
value: _this4.props.value
|
|
588
616
|
}, _this4.props, {
|
|
589
|
-
onChange: _this4.
|
|
617
|
+
onChange: _this4.onCalendarSelect,
|
|
618
|
+
selectedInput: _this4.state.selectedInput,
|
|
619
|
+
hasLockedBehavior: _this4.hasLockedBehavior()
|
|
590
620
|
}))
|
|
591
621
|
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
|
|
592
622
|
$separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
|
|
593
|
-
}), _this4.props.range && _this4.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), _this4.renderInputComponent(locale,
|
|
623
|
+
}), _this4.props.range && _this4.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), _this4.renderInputComponent(locale, INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
|
|
594
624
|
id: _this4.props['aria-describedby'],
|
|
595
625
|
style: {
|
|
596
626
|
position: 'fixed',
|
|
@@ -621,11 +651,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
621
651
|
clipPath: 'inset(100%)'
|
|
622
652
|
}
|
|
623
653
|
}, // No date selected
|
|
624
|
-
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.
|
|
654
|
+
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
|
|
625
655
|
!Array.isArray(_this4.props.value) ? getInterpolatedString(locale.datepicker.selectedDate, {
|
|
626
656
|
date: _this4.state.inputValue || ''
|
|
627
657
|
}) : // Start and end dates are selected in a range picker
|
|
628
|
-
_this4.props.value
|
|
658
|
+
_this4.props.value[0] && _this4.props.value[1] ? getInterpolatedString(locale.datepicker.selectedDateRange, {
|
|
629
659
|
startDate: _this4.formatDisplayValue(_this4.props.value[0]),
|
|
630
660
|
endDate: _this4.formatDisplayValue( // $FlowFixMe
|
|
631
661
|
_this4.props.value[1])
|
package/esm/datepicker/day.js
CHANGED
|
@@ -49,6 +49,7 @@ import DateHelpers from './utils/date-helpers.js';
|
|
|
49
49
|
import { getOverrides } from '../helpers/overrides.js';
|
|
50
50
|
import { LocaleContext } from '../locale/index.js';
|
|
51
51
|
import { isFocusVisible } from '../utils/focusVisible.js';
|
|
52
|
+
import { INPUT_ROLE } from './constants.js';
|
|
52
53
|
|
|
53
54
|
var Day = /*#__PURE__*/function (_React$Component) {
|
|
54
55
|
_inherits(Day, _React$Component);
|
|
@@ -83,22 +84,49 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
83
84
|
var _this$props = _this.props,
|
|
84
85
|
range = _this$props.range,
|
|
85
86
|
value = _this$props.value;
|
|
86
|
-
var
|
|
87
|
+
var nextDate;
|
|
88
|
+
|
|
89
|
+
if (Array.isArray(value) && range && _this.props.hasLockedBehavior) {
|
|
90
|
+
var currentDate = _this.props.value;
|
|
91
|
+
var nextStartDate = null;
|
|
92
|
+
var nextEndDate = null;
|
|
93
|
+
|
|
94
|
+
if (_this.props.selectedInput === INPUT_ROLE.startDate) {
|
|
95
|
+
nextStartDate = selectedDate;
|
|
96
|
+
nextEndDate = Array.isArray(currentDate) && currentDate[1] ? currentDate[1] : null;
|
|
97
|
+
} else if (_this.props.selectedInput === INPUT_ROLE.endDate) {
|
|
98
|
+
nextStartDate = Array.isArray(currentDate) && currentDate[0] ? currentDate[0] : null;
|
|
99
|
+
nextEndDate = selectedDate;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
nextDate = [nextStartDate];
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
if (nextEndDate) {
|
|
105
|
+
nextDate.push(nextEndDate);
|
|
106
|
+
}
|
|
107
|
+
} else if (Array.isArray(value) && range && !_this.props.hasLockedBehavior) {
|
|
108
|
+
var _value = _slicedToArray(value, 2),
|
|
109
|
+
start = _value[0],
|
|
110
|
+
end = _value[1]; // Starting a new range
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if (!start && !end || start && end) {
|
|
114
|
+
nextDate = [selectedDate, null]; // EndDate needs a StartDate, SelectedDate comes before EndDate
|
|
115
|
+
} else if (!start && end && _this.dateHelpers.isAfter(end, selectedDate)) {
|
|
116
|
+
nextDate = [selectedDate, end]; // EndDate needs a StartDate, but SelectedDate comes after EndDate
|
|
117
|
+
} else if (!start && end && _this.dateHelpers.isAfter(selectedDate, end)) {
|
|
118
|
+
nextDate = [end, selectedDate]; // StartDate needs an EndDate, SelectedDate comes after StartDate
|
|
119
|
+
} else if (start && !end && _this.dateHelpers.isAfter(selectedDate, start)) {
|
|
120
|
+
nextDate = [start, selectedDate];
|
|
93
121
|
} else {
|
|
94
|
-
|
|
122
|
+
nextDate = [selectedDate, start];
|
|
95
123
|
}
|
|
96
124
|
} else {
|
|
97
|
-
|
|
125
|
+
nextDate = selectedDate;
|
|
98
126
|
}
|
|
99
127
|
|
|
100
128
|
_this.props.onSelect({
|
|
101
|
-
date:
|
|
129
|
+
date: nextDate
|
|
102
130
|
});
|
|
103
131
|
});
|
|
104
132
|
|
|
@@ -285,13 +313,18 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
285
313
|
var date = this.getDateProp();
|
|
286
314
|
var value = this.props.value;
|
|
287
315
|
|
|
288
|
-
if (Array.isArray(value)
|
|
289
|
-
|
|
290
|
-
|
|
316
|
+
if (Array.isArray(value)) {
|
|
317
|
+
var _value2 = _slicedToArray(value, 2),
|
|
318
|
+
start = _value2[0],
|
|
319
|
+
end = _value2[1];
|
|
291
320
|
|
|
321
|
+
if (!start && !end) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
292
324
|
|
|
293
|
-
|
|
294
|
-
|
|
325
|
+
if (start && end) {
|
|
326
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(end));
|
|
327
|
+
}
|
|
295
328
|
}
|
|
296
329
|
} // calculated for range case only
|
|
297
330
|
|
|
@@ -303,16 +336,29 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
303
336
|
value = _this$props4.value,
|
|
304
337
|
highlightedDate = _this$props4.highlightedDate;
|
|
305
338
|
|
|
306
|
-
if (Array.isArray(value)
|
|
307
|
-
|
|
308
|
-
|
|
339
|
+
if (Array.isArray(value)) {
|
|
340
|
+
var _value3 = _slicedToArray(value, 2),
|
|
341
|
+
start = _value3[0],
|
|
342
|
+
end = _value3[1];
|
|
343
|
+
|
|
344
|
+
if (!start && !end) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
309
347
|
|
|
348
|
+
if (highlightedDate && start && !end) {
|
|
349
|
+
if (this.dateHelpers.isAfter(highlightedDate, start)) {
|
|
350
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(highlightedDate));
|
|
351
|
+
} else {
|
|
352
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(start));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
310
355
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
356
|
+
if (highlightedDate && !start && end) {
|
|
357
|
+
if (this.dateHelpers.isAfter(highlightedDate, end)) {
|
|
358
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(end), this.clampToDayStart(highlightedDate));
|
|
359
|
+
} else {
|
|
360
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(end));
|
|
361
|
+
}
|
|
316
362
|
}
|
|
317
363
|
}
|
|
318
364
|
}
|
|
@@ -324,21 +370,22 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
324
370
|
value = _this$props5.value,
|
|
325
371
|
highlightedDate = _this$props5.highlightedDate,
|
|
326
372
|
range = _this$props5.range,
|
|
327
|
-
highlighted = _this$props5.highlighted
|
|
373
|
+
highlighted = _this$props5.highlighted,
|
|
374
|
+
peekNextMonth = _this$props5.peekNextMonth;
|
|
328
375
|
var $isHighlighted = highlighted;
|
|
329
376
|
var $selected = this.isSelected();
|
|
330
|
-
var $hasRangeHighlighted = !!(Array.isArray(value) && range && value
|
|
331
|
-
var $outsideMonth = !
|
|
332
|
-
var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !
|
|
377
|
+
var $hasRangeHighlighted = !!(Array.isArray(value) && range && highlightedDate && (value[0] && !value[1] && !this.dateHelpers.isSameDay(value[0], highlightedDate) || !value[0] && value[1] && !this.dateHelpers.isSameDay(value[1], highlightedDate)));
|
|
378
|
+
var $outsideMonth = !peekNextMonth && this.isOutsideMonth();
|
|
379
|
+
var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !peekNextMonth && this.isOutsideOfMonthButWithinRange());
|
|
333
380
|
return {
|
|
334
381
|
$date: date,
|
|
335
382
|
$density: this.props.density,
|
|
336
383
|
$disabled: this.props.disabled,
|
|
337
|
-
$endDate: Array.isArray(value) &&
|
|
384
|
+
$endDate: Array.isArray(value) && !!(value[0] && value[1]) && range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
|
|
338
385
|
$hasDateLabel: !!this.props.dateLabel,
|
|
339
386
|
$hasRangeHighlighted: $hasRangeHighlighted,
|
|
340
|
-
$hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]),
|
|
341
|
-
$hasRangeSelected: Array.isArray(value) ? value
|
|
387
|
+
$hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && (value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]) || value[1] && this.dateHelpers.isAfter(highlightedDate, value[1])),
|
|
388
|
+
$hasRangeSelected: Array.isArray(value) ? !!(value[0] && value[1]) : false,
|
|
342
389
|
$highlightedDate: highlightedDate,
|
|
343
390
|
$isHighlighted: $isHighlighted,
|
|
344
391
|
$isHovered: this.state.isHovered,
|
|
@@ -348,12 +395,15 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
348
395
|
$month: this.getMonthProp(),
|
|
349
396
|
$outsideMonth: $outsideMonth,
|
|
350
397
|
$outsideMonthWithinRange: $outsideMonthWithinRange,
|
|
351
|
-
$peekNextMonth:
|
|
352
|
-
$pseudoHighlighted:
|
|
353
|
-
$pseudoSelected:
|
|
354
|
-
$range:
|
|
398
|
+
$peekNextMonth: peekNextMonth,
|
|
399
|
+
$pseudoHighlighted: range && !$isHighlighted && !$selected ? this.isPseudoHighlighted() : false,
|
|
400
|
+
$pseudoSelected: range && !$selected ? this.isPseudoSelected() : false,
|
|
401
|
+
$range: range,
|
|
355
402
|
$selected: $selected,
|
|
356
|
-
$startDate: Array.isArray(
|
|
403
|
+
$startDate: Array.isArray(value) && value[0] && value[1] && range && $selected ? this.dateHelpers.isSameDay(date, value[0]) : false,
|
|
404
|
+
$hasLockedBehavior: this.props.hasLockedBehavior,
|
|
405
|
+
$selectedInput: this.props.selectedInput,
|
|
406
|
+
$value: this.props.value
|
|
357
407
|
};
|
|
358
408
|
}
|
|
359
409
|
}, {
|
package/esm/datepicker/month.js
CHANGED
|
@@ -129,7 +129,9 @@ var CalendarMonth = /*#__PURE__*/function (_React$Component) {
|
|
|
129
129
|
onChange: _this.props.onChange,
|
|
130
130
|
overrides: _this.props.overrides,
|
|
131
131
|
peekNextMonth: _this.props.peekNextMonth,
|
|
132
|
-
value: _this.props.value
|
|
132
|
+
value: _this.props.value,
|
|
133
|
+
hasLockedBehavior: _this.props.hasLockedBehavior,
|
|
134
|
+
selectedInput: _this.props.selectedInput
|
|
133
135
|
}));
|
|
134
136
|
i++;
|
|
135
137
|
currentWeekStart = _this.dateHelpers.addWeeks(currentWeekStart, 1); // It will break on the next week if the week is out of the month
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
6
|
|
|
5
7
|
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); } }
|
|
@@ -47,7 +49,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
47
49
|
key: "render",
|
|
48
50
|
value: function render() {
|
|
49
51
|
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, function (extendedProps) {
|
|
50
|
-
return /*#__PURE__*/React.createElement(Calendar, extendedProps
|
|
52
|
+
return /*#__PURE__*/React.createElement(Calendar, _extends({}, extendedProps, {
|
|
53
|
+
// flowlint-next-line unclear-type:off
|
|
54
|
+
onChange: extendedProps.onChange
|
|
55
|
+
}));
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
58
|
}]);
|