baseui 10.11.1 → 11.0.0
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 +1 -1
- package/data-table/data-table.js.flow +1 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/datepicker/calendar.js +15 -7
- package/datepicker/calendar.js.flow +23 -9
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +61 -30
- package/datepicker/datepicker.js.flow +77 -37
- 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-container.js.flow +2 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +35 -10
- 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 +1 -1
- package/es/data-table/header-cell.js +3 -0
- package/es/datepicker/calendar.js +15 -7
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +56 -29
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -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/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/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 +32 -20
- package/es/select/styled-components.js +4 -4
- 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 +1 -1
- package/esm/data-table/header-cell.js +3 -0
- package/esm/datepicker/calendar.js +15 -7
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +60 -30
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -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/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/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 +34 -19
- package/esm/select/styled-components.js +4 -4
- 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/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/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 +10 -10
- 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/progress-bar/index.d.ts +3 -3
- 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 +8 -3
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +34 -19
- package/select/select-component.js.flow +29 -13
- package/select/styled-components.js +4 -4
- package/select/styled-components.js.flow +4 -4
- package/select/types.js.flow +11 -7
- 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/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
package/datepicker/datepicker.js
CHANGED
|
@@ -27,6 +27,8 @@ var _dateHelpers = _interopRequireDefault(require("./utils/date-helpers.js"));
|
|
|
27
27
|
|
|
28
28
|
var _dateFnsAdapter = _interopRequireDefault(require("./utils/date-fns-adapter.js"));
|
|
29
29
|
|
|
30
|
+
var _constants = require("./constants.js");
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
@@ -83,26 +85,26 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
83
85
|
|
|
84
86
|
var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
85
87
|
exports.DEFAULT_DATE_FORMAT = DEFAULT_DATE_FORMAT;
|
|
86
|
-
var INPUT_DELIMITER = '
|
|
88
|
+
var INPUT_DELIMITER = '–';
|
|
87
89
|
|
|
88
90
|
var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
|
|
89
91
|
var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
90
|
-
var
|
|
92
|
+
var inputRole = arguments.length > 2 ? arguments[2] : undefined;
|
|
91
93
|
var inputValue = newInputValue;
|
|
92
94
|
|
|
93
|
-
var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
|
|
95
|
+
var _prevCombinedInputVal = prevCombinedInputValue.split(" ".concat(INPUT_DELIMITER, " ")),
|
|
94
96
|
_prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
|
|
95
97
|
_prevCombinedInputVal3 = _prevCombinedInputVal2[0],
|
|
96
98
|
prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
|
|
97
99
|
_prevCombinedInputVal4 = _prevCombinedInputVal2[1],
|
|
98
100
|
prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
|
|
99
101
|
|
|
100
|
-
if (
|
|
101
|
-
inputValue = "".concat(inputValue, "
|
|
102
|
+
if (inputRole === _constants.INPUT_ROLE.startDate && prevEndDate) {
|
|
103
|
+
inputValue = "".concat(inputValue, " ").concat(INPUT_DELIMITER, " ").concat(prevEndDate);
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
if (
|
|
105
|
-
inputValue = "".concat(prevStartDate, "
|
|
106
|
+
if (inputRole === _constants.INPUT_ROLE.endDate) {
|
|
107
|
+
inputValue = "".concat(prevStartDate, " ").concat(INPUT_DELIMITER, " ").concat(inputValue);
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
return inputValue;
|
|
@@ -118,7 +120,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
118
120
|
|
|
119
121
|
_classCallCheck(this, Datepicker);
|
|
120
122
|
|
|
121
|
-
_this = _super.call(this, props); //$FlowFixMe
|
|
123
|
+
_this = _super.call(this, props); //$FlowFixMe[incompatible-call]
|
|
122
124
|
|
|
123
125
|
_defineProperty(_assertThisInitialized(_this), "calendar", void 0);
|
|
124
126
|
|
|
@@ -131,18 +133,27 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
131
133
|
var nextDate = data.date;
|
|
132
134
|
|
|
133
135
|
if (Array.isArray(nextDate) && _this.props.range) {
|
|
134
|
-
if (nextDate
|
|
136
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
135
137
|
isOpen = true;
|
|
136
138
|
isPseudoFocused = true;
|
|
137
139
|
calendarFocused = null;
|
|
138
|
-
} else if (nextDate
|
|
140
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
139
141
|
var _nextDate = nextDate,
|
|
140
142
|
_nextDate2 = _slicedToArray(_nextDate, 2),
|
|
141
143
|
start = _nextDate2[0],
|
|
142
144
|
end = _nextDate2[1];
|
|
143
145
|
|
|
144
146
|
if (_this.dateHelpers.isAfter(start, end)) {
|
|
145
|
-
|
|
147
|
+
if (_this.hasLockedBehavior()) {
|
|
148
|
+
nextDate = _this.props.value;
|
|
149
|
+
isOpen = true;
|
|
150
|
+
} else {
|
|
151
|
+
nextDate = [start, start];
|
|
152
|
+
}
|
|
153
|
+
} 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]
|
|
154
|
+
nextDate, _this.props.excludeDates)) {
|
|
155
|
+
nextDate = _this.props.value;
|
|
156
|
+
isOpen = true;
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
if (_this.state.lastActiveElm) {
|
|
@@ -234,11 +245,12 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
234
245
|
return _this.formatDate(date, formatString);
|
|
235
246
|
});
|
|
236
247
|
|
|
237
|
-
_defineProperty(_assertThisInitialized(_this), "open", function () {
|
|
248
|
+
_defineProperty(_assertThisInitialized(_this), "open", function (inputRole) {
|
|
238
249
|
_this.setState({
|
|
239
250
|
isOpen: true,
|
|
240
251
|
isPseudoFocused: true,
|
|
241
|
-
calendarFocused: false
|
|
252
|
+
calendarFocused: false,
|
|
253
|
+
selectedInput: inputRole
|
|
242
254
|
}, _this.props.onOpen);
|
|
243
255
|
});
|
|
244
256
|
|
|
@@ -247,6 +259,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
247
259
|
|
|
248
260
|
_this.setState({
|
|
249
261
|
isOpen: false,
|
|
262
|
+
selectedInput: null,
|
|
250
263
|
isPseudoFocused: isPseudoFocused,
|
|
251
264
|
calendarFocused: false
|
|
252
265
|
}, _this.props.onClose);
|
|
@@ -282,14 +295,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
282
295
|
}
|
|
283
296
|
|
|
284
297
|
if (range && !separateRangeInputs) {
|
|
285
|
-
return
|
|
298
|
+
return "9999/99/99 ".concat(INPUT_DELIMITER, " 9999/99/99");
|
|
286
299
|
}
|
|
287
300
|
|
|
288
301
|
return '9999/99/99';
|
|
289
302
|
});
|
|
290
303
|
|
|
291
|
-
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event,
|
|
292
|
-
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue,
|
|
304
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, inputRole) {
|
|
305
|
+
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, inputRole) : event.currentTarget.value;
|
|
293
306
|
|
|
294
307
|
var mask = _this.getMask();
|
|
295
308
|
|
|
@@ -322,7 +335,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
322
335
|
};
|
|
323
336
|
|
|
324
337
|
if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
|
|
325
|
-
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
|
|
338
|
+
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(" ".concat(INPUT_DELIMITER, " ")),
|
|
326
339
|
_this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
|
|
327
340
|
left = _this$normalizeDashes2[0],
|
|
328
341
|
right = _this$normalizeDashes2[1];
|
|
@@ -454,13 +467,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
454
467
|
|
|
455
468
|
_defineProperty(_assertThisInitialized(_this), "normalizeDashes", function (inputValue) {
|
|
456
469
|
// replacing both hyphens and em-dashes with en-dashes
|
|
457
|
-
return inputValue.replace(/-/g,
|
|
470
|
+
return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
_defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
|
|
474
|
+
return _this.props.rangedCalendarBehavior === _constants.RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
|
|
458
475
|
});
|
|
459
476
|
|
|
460
477
|
_this.dateHelpers = new _dateHelpers.default(props.adapter);
|
|
461
478
|
_this.state = {
|
|
462
479
|
calendarFocused: false,
|
|
463
480
|
isOpen: false,
|
|
481
|
+
selectedInput: null,
|
|
464
482
|
isPseudoFocused: false,
|
|
465
483
|
lastActiveElm: null,
|
|
466
484
|
inputValue: _this.formatDisplayValue(props.value) || ''
|
|
@@ -469,6 +487,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
469
487
|
}
|
|
470
488
|
|
|
471
489
|
_createClass(Datepicker, [{
|
|
490
|
+
key: "getNullDatePlaceholder",
|
|
491
|
+
value: function getNullDatePlaceholder(formatString) {
|
|
492
|
+
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
493
|
+
}
|
|
494
|
+
}, {
|
|
472
495
|
key: "formatDate",
|
|
473
496
|
value: function formatDate(date, formatString) {
|
|
474
497
|
var _this2 = this;
|
|
@@ -485,10 +508,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
485
508
|
return '';
|
|
486
509
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
487
510
|
return '';
|
|
511
|
+
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
512
|
+
var endDate = format(date[1]);
|
|
513
|
+
var startDate = this.getNullDatePlaceholder(formatString);
|
|
514
|
+
return [startDate, endDate].join(" ".concat(INPUT_DELIMITER, " "));
|
|
488
515
|
} else if (Array.isArray(date)) {
|
|
489
516
|
return date.map(function (day) {
|
|
490
|
-
return format(day);
|
|
491
|
-
}).join(INPUT_DELIMITER);
|
|
517
|
+
return day ? format(day) : '';
|
|
518
|
+
}).join(" ".concat(INPUT_DELIMITER, " "));
|
|
492
519
|
} else {
|
|
493
520
|
return format(date);
|
|
494
521
|
}
|
|
@@ -504,7 +531,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
504
531
|
}
|
|
505
532
|
}, {
|
|
506
533
|
key: "renderInputComponent",
|
|
507
|
-
value: function renderInputComponent(locale,
|
|
534
|
+
value: function renderInputComponent(locale, inputRole) {
|
|
508
535
|
var _this3 = this;
|
|
509
536
|
|
|
510
537
|
var _this$props$overrides = this.props.overrides,
|
|
@@ -515,19 +542,19 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
515
542
|
InputComponent = _getOverrides2[0],
|
|
516
543
|
inputProps = _getOverrides2[1];
|
|
517
544
|
|
|
518
|
-
var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ?
|
|
545
|
+
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';
|
|
519
546
|
|
|
520
|
-
var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
|
|
547
|
+
var _split = (this.state.inputValue || '').split(" ".concat(INPUT_DELIMITER, " ")),
|
|
521
548
|
_split2 = _slicedToArray(_split, 2),
|
|
522
549
|
_split2$ = _split2[0],
|
|
523
550
|
startDate = _split2$ === void 0 ? '' : _split2$,
|
|
524
551
|
_split2$2 = _split2[1],
|
|
525
552
|
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
526
553
|
|
|
527
|
-
var value =
|
|
554
|
+
var value = inputRole === _constants.INPUT_ROLE.startDate ? startDate : inputRole === _constants.INPUT_ROLE.endDate ? endDate : this.state.inputValue;
|
|
528
555
|
|
|
529
556
|
var onChange = function onChange(event) {
|
|
530
|
-
return _this3.handleInputChange(event,
|
|
557
|
+
return _this3.handleInputChange(event, inputRole);
|
|
531
558
|
};
|
|
532
559
|
|
|
533
560
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
@@ -541,7 +568,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
541
568
|
disabled: this.props.disabled,
|
|
542
569
|
size: this.props.size,
|
|
543
570
|
value: value,
|
|
544
|
-
onFocus:
|
|
571
|
+
onFocus: function onFocus() {
|
|
572
|
+
return _this3.open(inputRole);
|
|
573
|
+
},
|
|
545
574
|
onBlur: this.handleInputBlur,
|
|
546
575
|
onKeyDown: this.handleKeyDown,
|
|
547
576
|
onChange: onChange,
|
|
@@ -604,11 +633,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
604
633
|
trapTabbing: true,
|
|
605
634
|
value: _this4.props.value
|
|
606
635
|
}, _this4.props, {
|
|
607
|
-
onChange: _this4.onChange
|
|
636
|
+
onChange: _this4.onChange,
|
|
637
|
+
selectedInput: _this4.state.selectedInput,
|
|
638
|
+
hasLockedBehavior: _this4.hasLockedBehavior()
|
|
608
639
|
}))
|
|
609
640
|
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
|
|
610
641
|
$separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
|
|
611
|
-
}), _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,
|
|
642
|
+
}), _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, _constants.INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, _constants.INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
|
|
612
643
|
id: _this4.props['aria-describedby'],
|
|
613
644
|
style: {
|
|
614
645
|
position: 'fixed',
|
|
@@ -639,11 +670,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
639
670
|
clipPath: 'inset(100%)'
|
|
640
671
|
}
|
|
641
672
|
}, // No date selected
|
|
642
|
-
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.
|
|
673
|
+
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
|
|
643
674
|
!Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
644
675
|
date: _this4.state.inputValue || ''
|
|
645
676
|
}) : // Start and end dates are selected in a range picker
|
|
646
|
-
_this4.props.value
|
|
677
|
+
_this4.props.value[0] && _this4.props.value[1] ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
|
|
647
678
|
startDate: _this4.formatDisplayValue(_this4.props.value[0]),
|
|
648
679
|
endDate: _this4.formatDisplayValue( // $FlowFixMe
|
|
649
680
|
_this4.props.value[1])
|
|
@@ -19,23 +19,26 @@ import {
|
|
|
19
19
|
StyledStartDate,
|
|
20
20
|
StyledEndDate,
|
|
21
21
|
} from './styled-components.js';
|
|
22
|
-
import type { DatepickerPropsT } from './types.js';
|
|
22
|
+
import type { DatepickerPropsT, DateValueT, InputRoleT } from './types.js';
|
|
23
23
|
import DateHelpers from './utils/date-helpers.js';
|
|
24
24
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
25
25
|
import type { LocaleT } from '../locale/types.js';
|
|
26
|
+
import { INPUT_ROLE, RANGED_CALENDAR_BEHAVIOR } from './constants.js';
|
|
26
27
|
|
|
27
28
|
export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
28
29
|
|
|
29
|
-
const INPUT_DELIMITER = '
|
|
30
|
+
const INPUT_DELIMITER = '–';
|
|
30
31
|
|
|
31
|
-
const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '',
|
|
32
|
+
const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', inputRole) => {
|
|
32
33
|
let inputValue = newInputValue;
|
|
33
|
-
const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(
|
|
35
|
+
` ${INPUT_DELIMITER} `
|
|
36
|
+
);
|
|
37
|
+
if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
|
|
38
|
+
inputValue = `${inputValue} ${INPUT_DELIMITER} ${prevEndDate}`;
|
|
36
39
|
}
|
|
37
|
-
if (
|
|
38
|
-
inputValue = `${prevStartDate}
|
|
40
|
+
if (inputRole === INPUT_ROLE.endDate) {
|
|
41
|
+
inputValue = `${prevStartDate} ${INPUT_DELIMITER} ${inputValue}`;
|
|
39
42
|
}
|
|
40
43
|
return inputValue;
|
|
41
44
|
};
|
|
@@ -43,6 +46,7 @@ const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', sepa
|
|
|
43
46
|
type StateT = {|
|
|
44
47
|
calendarFocused: boolean,
|
|
45
48
|
isOpen: boolean,
|
|
49
|
+
selectedInput: ?InputRoleT,
|
|
46
50
|
isPseudoFocused: boolean,
|
|
47
51
|
lastActiveElm: ?HTMLElement,
|
|
48
52
|
inputValue?: string,
|
|
@@ -62,32 +66,47 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
62
66
|
|
|
63
67
|
constructor(props: DatepickerPropsT<T>) {
|
|
64
68
|
super(props);
|
|
65
|
-
//$FlowFixMe
|
|
69
|
+
//$FlowFixMe[incompatible-call]
|
|
66
70
|
this.dateHelpers = new DateHelpers(props.adapter);
|
|
67
71
|
this.state = {
|
|
68
72
|
calendarFocused: false,
|
|
69
73
|
isOpen: false,
|
|
74
|
+
selectedInput: null,
|
|
70
75
|
isPseudoFocused: false,
|
|
71
76
|
lastActiveElm: null,
|
|
72
77
|
inputValue: this.formatDisplayValue(props.value) || '',
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
onChange: ({ date:
|
|
81
|
+
onChange: ({ date: DateValueT<T> }) => void = (data) => {
|
|
77
82
|
let isOpen = false;
|
|
78
83
|
let isPseudoFocused = false;
|
|
79
84
|
let calendarFocused = false;
|
|
80
85
|
let nextDate = data.date;
|
|
81
86
|
|
|
82
87
|
if (Array.isArray(nextDate) && this.props.range) {
|
|
83
|
-
if (nextDate
|
|
88
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
84
89
|
isOpen = true;
|
|
85
90
|
isPseudoFocused = true;
|
|
86
91
|
calendarFocused = null;
|
|
87
|
-
} else if (nextDate
|
|
92
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
88
93
|
const [start, end] = nextDate;
|
|
89
94
|
if (this.dateHelpers.isAfter(start, end)) {
|
|
90
|
-
|
|
95
|
+
if (this.hasLockedBehavior()) {
|
|
96
|
+
nextDate = this.props.value;
|
|
97
|
+
isOpen = true;
|
|
98
|
+
} else {
|
|
99
|
+
nextDate = [start, start];
|
|
100
|
+
}
|
|
101
|
+
} else if (
|
|
102
|
+
this.dateHelpers.dateRangeIncludesDates(
|
|
103
|
+
// $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]
|
|
104
|
+
nextDate,
|
|
105
|
+
this.props.excludeDates
|
|
106
|
+
)
|
|
107
|
+
) {
|
|
108
|
+
nextDate = this.props.value;
|
|
109
|
+
isOpen = true;
|
|
91
110
|
}
|
|
92
111
|
|
|
93
112
|
if (this.state.lastActiveElm) {
|
|
@@ -134,25 +153,34 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
134
153
|
this.props.onChange && this.props.onChange({ date: nextDate });
|
|
135
154
|
};
|
|
136
155
|
|
|
137
|
-
|
|
138
|
-
|
|
156
|
+
getNullDatePlaceholder(formatString: string) {
|
|
157
|
+
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
formatDate(date: DateValueT<T>, formatString: string) {
|
|
161
|
+
const format = (date: T) => {
|
|
139
162
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
140
163
|
return this.dateHelpers.format(date, 'slashDate', this.props.locale);
|
|
141
164
|
}
|
|
142
165
|
return this.dateHelpers.formatDate(date, formatString, this.props.locale);
|
|
143
166
|
};
|
|
167
|
+
|
|
144
168
|
if (!date) {
|
|
145
169
|
return '';
|
|
146
170
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
147
171
|
return '';
|
|
172
|
+
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
173
|
+
const endDate = format(date[1]);
|
|
174
|
+
const startDate = this.getNullDatePlaceholder(formatString);
|
|
175
|
+
return [startDate, endDate].join(` ${INPUT_DELIMITER} `);
|
|
148
176
|
} else if (Array.isArray(date)) {
|
|
149
|
-
return date.map((day) => format(day)).join(INPUT_DELIMITER);
|
|
177
|
+
return date.map((day) => (day ? format(day) : '')).join(` ${INPUT_DELIMITER} `);
|
|
150
178
|
} else {
|
|
151
179
|
return format(date);
|
|
152
180
|
}
|
|
153
181
|
}
|
|
154
182
|
|
|
155
|
-
formatDisplayValue: (
|
|
183
|
+
formatDisplayValue: (DateValueT<T>) => string = (date: DateValueT<T>) => {
|
|
156
184
|
const { displayValueAtRangeIndex, formatDisplayValue, range } = this.props;
|
|
157
185
|
const formatString = this.normalizeDashes(this.props.formatString);
|
|
158
186
|
|
|
@@ -181,12 +209,13 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
181
209
|
return this.formatDate(date, formatString);
|
|
182
210
|
};
|
|
183
211
|
|
|
184
|
-
open = () => {
|
|
212
|
+
open = (inputRole?: InputRoleT) => {
|
|
185
213
|
this.setState(
|
|
186
214
|
{
|
|
187
215
|
isOpen: true,
|
|
188
216
|
isPseudoFocused: true,
|
|
189
217
|
calendarFocused: false,
|
|
218
|
+
selectedInput: inputRole,
|
|
190
219
|
},
|
|
191
220
|
this.props.onOpen
|
|
192
221
|
);
|
|
@@ -197,6 +226,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
197
226
|
this.setState(
|
|
198
227
|
{
|
|
199
228
|
isOpen: false,
|
|
229
|
+
selectedInput: null,
|
|
200
230
|
isPseudoFocused,
|
|
201
231
|
calendarFocused: false,
|
|
202
232
|
},
|
|
@@ -229,19 +259,16 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
229
259
|
}
|
|
230
260
|
|
|
231
261
|
if (range && !separateRangeInputs) {
|
|
232
|
-
return
|
|
262
|
+
return `9999/99/99 ${INPUT_DELIMITER} 9999/99/99`;
|
|
233
263
|
}
|
|
234
264
|
|
|
235
265
|
return '9999/99/99';
|
|
236
266
|
};
|
|
237
267
|
|
|
238
|
-
handleInputChange = (
|
|
239
|
-
event: SyntheticInputEvent<HTMLInputElement>,
|
|
240
|
-
separatedInput?: 'startDate' | 'endDate'
|
|
241
|
-
) => {
|
|
268
|
+
handleInputChange = (event: SyntheticInputEvent<HTMLInputElement>, inputRole?: InputRoleT) => {
|
|
242
269
|
const inputValue =
|
|
243
270
|
this.props.range && this.props.separateRangeInputs
|
|
244
|
-
? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue,
|
|
271
|
+
? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, inputRole)
|
|
245
272
|
: event.currentTarget.value;
|
|
246
273
|
|
|
247
274
|
const mask = this.getMask();
|
|
@@ -270,7 +297,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
270
297
|
};
|
|
271
298
|
|
|
272
299
|
if (this.props.range && typeof this.props.displayValueAtRangeIndex !== 'number') {
|
|
273
|
-
const [left, right] = this.normalizeDashes(inputValue).split(INPUT_DELIMITER);
|
|
300
|
+
const [left, right] = this.normalizeDashes(inputValue).split(` ${INPUT_DELIMITER} `);
|
|
274
301
|
|
|
275
302
|
let startDate = this.dateHelpers.date(left);
|
|
276
303
|
let endDate = this.dateHelpers.date(right);
|
|
@@ -370,7 +397,15 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
370
397
|
|
|
371
398
|
normalizeDashes = (inputValue: string) => {
|
|
372
399
|
// replacing both hyphens and em-dashes with en-dashes
|
|
373
|
-
return inputValue.replace(/-/g,
|
|
400
|
+
return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
hasLockedBehavior = () => {
|
|
404
|
+
return (
|
|
405
|
+
this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked &&
|
|
406
|
+
this.props.range &&
|
|
407
|
+
this.props.separateRangeInputs
|
|
408
|
+
);
|
|
374
409
|
};
|
|
375
410
|
|
|
376
411
|
componentDidUpdate(prevProps: DatepickerPropsT<T>) {
|
|
@@ -381,7 +416,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
381
416
|
}
|
|
382
417
|
}
|
|
383
418
|
|
|
384
|
-
renderInputComponent(locale: LocaleT,
|
|
419
|
+
renderInputComponent(locale: LocaleT, inputRole?: InputRoleT) {
|
|
385
420
|
const { overrides = {} } = this.props;
|
|
386
421
|
|
|
387
422
|
const [InputComponent, inputProps] = getOverrides(overrides.Input, MaskedInput);
|
|
@@ -390,19 +425,21 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
390
425
|
this.props.placeholder || this.props.placeholder === ''
|
|
391
426
|
? this.props.placeholder
|
|
392
427
|
: this.props.range && !this.props.separateRangeInputs
|
|
393
|
-
?
|
|
428
|
+
? `YYYY/MM/DD ${INPUT_DELIMITER} YYYY/MM/DD`
|
|
394
429
|
: 'YYYY/MM/DD';
|
|
395
430
|
|
|
396
|
-
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(
|
|
431
|
+
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(
|
|
432
|
+
` ${INPUT_DELIMITER} `
|
|
433
|
+
);
|
|
397
434
|
|
|
398
435
|
const value =
|
|
399
|
-
|
|
436
|
+
inputRole === INPUT_ROLE.startDate
|
|
400
437
|
? startDate
|
|
401
|
-
:
|
|
438
|
+
: inputRole === INPUT_ROLE.endDate
|
|
402
439
|
? endDate
|
|
403
440
|
: this.state.inputValue;
|
|
404
441
|
|
|
405
|
-
const onChange = (event) => this.handleInputChange(event,
|
|
442
|
+
const onChange = (event) => this.handleInputChange(event, inputRole);
|
|
406
443
|
|
|
407
444
|
return (
|
|
408
445
|
<InputComponent
|
|
@@ -419,7 +456,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
419
456
|
disabled={this.props.disabled}
|
|
420
457
|
size={this.props.size}
|
|
421
458
|
value={value}
|
|
422
|
-
onFocus={this.open}
|
|
459
|
+
onFocus={() => this.open(inputRole)}
|
|
423
460
|
onBlur={this.handleInputBlur}
|
|
424
461
|
onKeyDown={this.handleKeyDown}
|
|
425
462
|
onChange={onChange}
|
|
@@ -463,6 +500,8 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
463
500
|
value={this.props.value}
|
|
464
501
|
{...this.props}
|
|
465
502
|
onChange={this.onChange}
|
|
503
|
+
selectedInput={this.state.selectedInput}
|
|
504
|
+
hasLockedBehavior={this.hasLockedBehavior()}
|
|
466
505
|
/>
|
|
467
506
|
}
|
|
468
507
|
{...popoverProps}
|
|
@@ -476,11 +515,11 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
476
515
|
<>
|
|
477
516
|
<StartDate {...startDateProps}>
|
|
478
517
|
<InputLabel {...inputLabelProps}>{startDateLabel}</InputLabel>
|
|
479
|
-
{this.renderInputComponent(locale,
|
|
518
|
+
{this.renderInputComponent(locale, INPUT_ROLE.startDate)}
|
|
480
519
|
</StartDate>
|
|
481
520
|
<EndDate {...endDateProps}>
|
|
482
521
|
<InputLabel {...inputLabelProps}>{endDateLabel}</InputLabel>
|
|
483
|
-
{this.renderInputComponent(locale,
|
|
522
|
+
{this.renderInputComponent(locale, INPUT_ROLE.endDate)}
|
|
484
523
|
</EndDate>
|
|
485
524
|
</>
|
|
486
525
|
) : (
|
|
@@ -524,7 +563,8 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
524
563
|
>
|
|
525
564
|
{
|
|
526
565
|
// No date selected
|
|
527
|
-
!this.props.value ||
|
|
566
|
+
!this.props.value ||
|
|
567
|
+
(Array.isArray(this.props.value) && !this.props.value[0] && !this.props.value[1])
|
|
528
568
|
? ''
|
|
529
569
|
: // Date selected in a non-range picker
|
|
530
570
|
!Array.isArray(this.props.value)
|
|
@@ -532,7 +572,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
532
572
|
date: this.state.inputValue || '',
|
|
533
573
|
})
|
|
534
574
|
: // Start and end dates are selected in a range picker
|
|
535
|
-
this.props.value
|
|
575
|
+
this.props.value[0] && this.props.value[1]
|
|
536
576
|
? getInterpolatedString(locale.datepicker.selectedDateRange, {
|
|
537
577
|
startDate: this.formatDisplayValue(this.props.value[0]),
|
|
538
578
|
endDate: this.formatDisplayValue(
|