baseui 10.6.0 → 10.7.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/app-nav-bar/user-menu.js +1 -0
- package/app-nav-bar/user-menu.js.flow +1 -0
- package/card/styled-components.js +0 -1
- package/card/styled-components.js.flow +0 -1
- package/combobox/combobox.js +5 -1
- package/combobox/combobox.js.flow +4 -0
- package/combobox/index.d.ts +6 -3
- package/data-table/column-datetime.js +2 -0
- package/data-table/column-datetime.js.flow +2 -0
- package/datepicker/calendar-header.js +29 -15
- package/datepicker/calendar-header.js.flow +13 -7
- package/datepicker/calendar.js +6 -1
- package/datepicker/calendar.js.flow +5 -1
- package/datepicker/constants.js +7 -2
- package/datepicker/constants.js.flow +5 -0
- package/datepicker/datepicker.js +135 -73
- package/datepicker/datepicker.js.flow +161 -62
- package/datepicker/day.js +1 -0
- package/datepicker/day.js.flow +1 -0
- package/datepicker/index.d.ts +7 -0
- package/datepicker/month.js +4 -0
- package/datepicker/month.js.flow +3 -0
- package/datepicker/styled-components.js +116 -56
- package/datepicker/styled-components.js.flow +101 -36
- package/datepicker/types.js.flow +17 -1
- package/datepicker/utils/date-helpers.js +1 -1
- package/datepicker/utils/date-helpers.js.flow +1 -1
- package/datepicker/week.js +1 -0
- package/datepicker/week.js.flow +1 -0
- package/dnd-list/list.js +1 -2
- package/dnd-list/list.js.flow +1 -1
- package/dnd-list/styled-components.js +1 -1
- package/dnd-list/styled-components.js.flow +1 -0
- package/es/app-nav-bar/user-menu.js +1 -0
- package/es/card/styled-components.js +0 -1
- package/es/combobox/combobox.js +5 -1
- package/es/data-table/column-datetime.js +2 -0
- package/es/datepicker/calendar-header.js +21 -10
- package/es/datepicker/calendar.js +7 -2
- package/es/datepicker/constants.js +5 -1
- package/es/datepicker/datepicker.js +70 -42
- package/es/datepicker/day.js +1 -0
- package/es/datepicker/month.js +3 -0
- package/es/datepicker/styled-components.js +98 -37
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +1 -1
- package/es/datepicker/week.js +1 -0
- package/es/dnd-list/list.js +1 -2
- package/es/dnd-list/styled-components.js +1 -0
- package/es/helper/helper.js +1 -0
- package/es/layer/layer.js +8 -0
- package/es/menu/maybe-child-menu.js +1 -0
- package/es/popover/popover.js +6 -5
- package/es/popover/stateful-container.js +4 -2
- package/es/select/select-component.js +1 -0
- package/es/themes/shared/lighting.js +5 -1
- package/es/timepicker/timepicker.js +16 -11
- package/es/tooltip/tooltip.js +1 -0
- package/esm/app-nav-bar/user-menu.js +1 -0
- package/esm/card/styled-components.js +0 -1
- package/esm/combobox/combobox.js +5 -1
- package/esm/data-table/column-datetime.js +2 -0
- package/esm/datepicker/calendar-header.js +30 -16
- package/esm/datepicker/calendar.js +7 -2
- package/esm/datepicker/constants.js +5 -1
- package/esm/datepicker/datepicker.js +136 -74
- package/esm/datepicker/day.js +1 -0
- package/esm/datepicker/month.js +3 -0
- package/esm/datepicker/styled-components.js +112 -55
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +1 -1
- package/esm/datepicker/week.js +1 -0
- package/esm/dnd-list/list.js +1 -2
- package/esm/dnd-list/styled-components.js +1 -1
- package/esm/helper/helper.js +1 -0
- package/esm/layer/layer.js +8 -0
- package/esm/menu/maybe-child-menu.js +1 -0
- package/esm/popover/popover.js +6 -5
- package/esm/popover/stateful-container.js +4 -2
- package/esm/select/select-component.js +1 -0
- package/esm/themes/shared/lighting.js +5 -1
- package/esm/timepicker/timepicker.js +17 -11
- package/esm/tooltip/tooltip.js +1 -0
- package/helper/helper.js +1 -0
- package/helper/helper.js.flow +1 -0
- package/layer/layer.js +8 -0
- package/layer/layer.js.flow +9 -0
- package/map-marker/index.d.ts +6 -5
- package/menu/maybe-child-menu.js +1 -0
- package/menu/maybe-child-menu.js.flow +1 -0
- package/modal/index.d.ts +1 -1
- package/modal/types.js.flow +4 -1
- package/package.json +3 -2
- package/popover/index.d.ts +2 -1
- package/popover/popover.js +6 -5
- package/popover/popover.js.flow +11 -4
- package/popover/stateful-container.js +4 -2
- package/popover/stateful-container.js.flow +2 -0
- package/popover/types.js.flow +6 -1
- package/select/select-component.js +1 -0
- package/select/select-component.js.flow +1 -0
- package/snackbar/index.d.ts +21 -16
- package/themes/shared/lighting.js +5 -1
- package/themes/shared/lighting.js.flow +4 -0
- package/themes/types.js.flow +4 -0
- package/timepicker/index.d.ts +1 -0
- package/timepicker/timepicker.js +17 -11
- package/timepicker/timepicker.js.flow +31 -12
- package/timepicker/types.js.flow +10 -0
- package/tooltip/tooltip.js +1 -0
- package/tooltip/tooltip.js.flow +6 -1
package/datepicker/datepicker.js
CHANGED
|
@@ -47,18 +47,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
47
47
|
|
|
48
48
|
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; }
|
|
49
49
|
|
|
50
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
51
|
-
|
|
52
|
-
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."); }
|
|
53
|
-
|
|
54
|
-
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); }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
59
|
-
|
|
60
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
61
|
-
|
|
62
50
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
63
51
|
|
|
64
52
|
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); } }
|
|
@@ -81,8 +69,44 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
81
69
|
|
|
82
70
|
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; }
|
|
83
71
|
|
|
72
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
73
|
+
|
|
74
|
+
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."); }
|
|
75
|
+
|
|
76
|
+
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); }
|
|
77
|
+
|
|
78
|
+
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; }
|
|
79
|
+
|
|
80
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
81
|
+
|
|
82
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
83
|
+
|
|
84
84
|
var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
85
85
|
exports.DEFAULT_DATE_FORMAT = DEFAULT_DATE_FORMAT;
|
|
86
|
+
var INPUT_DELIMITER = ' – ';
|
|
87
|
+
|
|
88
|
+
var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
|
|
89
|
+
var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
90
|
+
var separatedInput = arguments.length > 2 ? arguments[2] : undefined;
|
|
91
|
+
var inputValue = newInputValue;
|
|
92
|
+
|
|
93
|
+
var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
|
|
94
|
+
_prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
|
|
95
|
+
_prevCombinedInputVal3 = _prevCombinedInputVal2[0],
|
|
96
|
+
prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
|
|
97
|
+
_prevCombinedInputVal4 = _prevCombinedInputVal2[1],
|
|
98
|
+
prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
|
|
99
|
+
|
|
100
|
+
if (separatedInput === 'startDate' && prevEndDate) {
|
|
101
|
+
inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (separatedInput === 'endDate') {
|
|
105
|
+
inputValue = "".concat(prevStartDate, " \u2013 ").concat(inputValue);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return inputValue;
|
|
109
|
+
};
|
|
86
110
|
|
|
87
111
|
var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
88
112
|
_inherits(Datepicker, _React$Component);
|
|
@@ -215,7 +239,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
215
239
|
isOpen: true,
|
|
216
240
|
isPseudoFocused: true,
|
|
217
241
|
calendarFocused: false
|
|
218
|
-
});
|
|
242
|
+
}, _this.props.onOpen);
|
|
219
243
|
});
|
|
220
244
|
|
|
221
245
|
_defineProperty(_assertThisInitialized(_this), "close", function () {
|
|
@@ -246,9 +270,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
246
270
|
var _this$props2 = _this.props,
|
|
247
271
|
formatString = _this$props2.formatString,
|
|
248
272
|
mask = _this$props2.mask,
|
|
249
|
-
range = _this$props2.range
|
|
273
|
+
range = _this$props2.range,
|
|
274
|
+
separateRangeInputs = _this$props2.separateRangeInputs;
|
|
250
275
|
|
|
251
|
-
if (mask === null) {
|
|
276
|
+
if (mask === null || mask === undefined && formatString !== DEFAULT_DATE_FORMAT) {
|
|
252
277
|
return null;
|
|
253
278
|
}
|
|
254
279
|
|
|
@@ -256,28 +281,20 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
256
281
|
return _this.normalizeDashes(mask);
|
|
257
282
|
}
|
|
258
283
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (formatString) {
|
|
262
|
-
if (range) {
|
|
263
|
-
return "".concat(normalizedFormatString, " \u2013 ").concat(normalizedFormatString).replace(/[a-z]/gi, '9');
|
|
264
|
-
} else {
|
|
265
|
-
return normalizedFormatString.replace(/[a-z]/gi, '9');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (range) {
|
|
284
|
+
if (range && !separateRangeInputs) {
|
|
270
285
|
return '9999/99/99 – 9999/99/99';
|
|
271
286
|
}
|
|
272
287
|
|
|
273
288
|
return '9999/99/99';
|
|
274
289
|
});
|
|
275
290
|
|
|
276
|
-
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event) {
|
|
277
|
-
var inputValue = event.currentTarget.value;
|
|
291
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, separatedInput) {
|
|
292
|
+
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, separatedInput) : event.currentTarget.value;
|
|
278
293
|
|
|
279
294
|
var mask = _this.getMask();
|
|
280
295
|
|
|
296
|
+
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
297
|
+
|
|
281
298
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
282
299
|
if (_this.props.onChange) {
|
|
283
300
|
if (_this.props.range) {
|
|
@@ -296,8 +313,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
296
313
|
inputValue: inputValue
|
|
297
314
|
});
|
|
298
315
|
|
|
299
|
-
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
300
|
-
|
|
301
316
|
var parseDateString = function parseDateString(dateString) {
|
|
302
317
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
303
318
|
return _this.dateHelpers.parse(dateString, 'slashDate', _this.props.locale);
|
|
@@ -307,7 +322,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
307
322
|
};
|
|
308
323
|
|
|
309
324
|
if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
|
|
310
|
-
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(
|
|
325
|
+
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
|
|
311
326
|
_this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
|
|
312
327
|
left = _this$normalizeDashes2[0],
|
|
313
328
|
right = _this$normalizeDashes2[1];
|
|
@@ -473,7 +488,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
473
488
|
} else if (Array.isArray(date)) {
|
|
474
489
|
return date.map(function (day) {
|
|
475
490
|
return format(day);
|
|
476
|
-
}).join(
|
|
491
|
+
}).join(INPUT_DELIMITER);
|
|
477
492
|
} else {
|
|
478
493
|
return format(date);
|
|
479
494
|
}
|
|
@@ -488,8 +503,8 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
488
503
|
}
|
|
489
504
|
}
|
|
490
505
|
}, {
|
|
491
|
-
key: "
|
|
492
|
-
value: function
|
|
506
|
+
key: "renderInputComponent",
|
|
507
|
+
value: function renderInputComponent(locale, separatedInput) {
|
|
493
508
|
var _this3 = this;
|
|
494
509
|
|
|
495
510
|
var _this$props$overrides = this.props.overrides,
|
|
@@ -500,6 +515,55 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
500
515
|
InputComponent = _getOverrides2[0],
|
|
501
516
|
inputProps = _getOverrides2[1];
|
|
502
517
|
|
|
518
|
+
var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? 'YYYY/MM/DD – YYYY/MM/DD' : 'YYYY/MM/DD';
|
|
519
|
+
|
|
520
|
+
var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
|
|
521
|
+
_split2 = _slicedToArray(_split, 2),
|
|
522
|
+
_split2$ = _split2[0],
|
|
523
|
+
startDate = _split2$ === void 0 ? '' : _split2$,
|
|
524
|
+
_split2$2 = _split2[1],
|
|
525
|
+
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
526
|
+
|
|
527
|
+
var value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
|
|
528
|
+
|
|
529
|
+
var onChange = function onChange(event) {
|
|
530
|
+
return _this3.handleInputChange(event, separatedInput);
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
534
|
+
"aria-disabled": this.props.disabled,
|
|
535
|
+
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
536
|
+
error: this.props.error,
|
|
537
|
+
positive: this.props.positive,
|
|
538
|
+
"aria-describedby": this.props['aria-describedby'],
|
|
539
|
+
"aria-labelledby": this.props['aria-labelledby'],
|
|
540
|
+
"aria-required": this.props.required || null,
|
|
541
|
+
disabled: this.props.disabled,
|
|
542
|
+
size: this.props.size,
|
|
543
|
+
value: value,
|
|
544
|
+
onFocus: this.open,
|
|
545
|
+
onBlur: this.handleInputBlur,
|
|
546
|
+
onKeyDown: this.handleKeyDown,
|
|
547
|
+
onChange: onChange,
|
|
548
|
+
placeholder: placeholder,
|
|
549
|
+
mask: this.getMask(),
|
|
550
|
+
required: this.props.required,
|
|
551
|
+
clearable: this.props.clearable
|
|
552
|
+
}, inputProps));
|
|
553
|
+
}
|
|
554
|
+
}, {
|
|
555
|
+
key: "render",
|
|
556
|
+
value: function render() {
|
|
557
|
+
var _this4 = this;
|
|
558
|
+
|
|
559
|
+
var _this$props4 = this.props,
|
|
560
|
+
_this$props4$override = _this$props4.overrides,
|
|
561
|
+
overrides = _this$props4$override === void 0 ? {} : _this$props4$override,
|
|
562
|
+
_this$props4$startDat = _this$props4.startDateLabel,
|
|
563
|
+
startDateLabel = _this$props4$startDat === void 0 ? 'Start Date' : _this$props4$startDat,
|
|
564
|
+
_this$props4$endDateL = _this$props4.endDateLabel,
|
|
565
|
+
endDateLabel = _this$props4$endDateL === void 0 ? 'End Date' : _this$props4$endDateL;
|
|
566
|
+
|
|
503
567
|
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.Popover, _index2.Popover),
|
|
504
568
|
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
505
569
|
PopoverComponent = _getOverrides4[0],
|
|
@@ -510,44 +574,42 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
510
574
|
InputWrapper = _getOverrides6[0],
|
|
511
575
|
inputWrapperProps = _getOverrides6[1];
|
|
512
576
|
|
|
513
|
-
var
|
|
577
|
+
var _getOverrides7 = (0, _overrides.getOverrides)(overrides.StartDate, _styledComponents.StyledStartDate),
|
|
578
|
+
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
579
|
+
StartDate = _getOverrides8[0],
|
|
580
|
+
startDateProps = _getOverrides8[1];
|
|
581
|
+
|
|
582
|
+
var _getOverrides9 = (0, _overrides.getOverrides)(overrides.EndDate, _styledComponents.StyledEndDate),
|
|
583
|
+
_getOverrides10 = _slicedToArray(_getOverrides9, 2),
|
|
584
|
+
EndDate = _getOverrides10[0],
|
|
585
|
+
endDateProps = _getOverrides10[1];
|
|
586
|
+
|
|
587
|
+
var _getOverrides11 = (0, _overrides.getOverrides)(overrides.InputLabel, _styledComponents.StyledInputLabel),
|
|
588
|
+
_getOverrides12 = _slicedToArray(_getOverrides11, 2),
|
|
589
|
+
InputLabel = _getOverrides12[0],
|
|
590
|
+
inputLabelProps = _getOverrides12[1];
|
|
591
|
+
|
|
514
592
|
return /*#__PURE__*/React.createElement(_index3.LocaleContext.Consumer, null, function (locale) {
|
|
515
593
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PopoverComponent, _extends({
|
|
516
594
|
focusLock: false,
|
|
517
|
-
|
|
595
|
+
autoFocus: false,
|
|
596
|
+
mountNode: _this4.props.mountNode,
|
|
518
597
|
placement: _index2.PLACEMENT.bottom,
|
|
519
|
-
isOpen:
|
|
520
|
-
onClickOutside:
|
|
521
|
-
onEsc:
|
|
598
|
+
isOpen: _this4.state.isOpen,
|
|
599
|
+
onClickOutside: _this4.close,
|
|
600
|
+
onEsc: _this4.handleEsc,
|
|
522
601
|
content: /*#__PURE__*/React.createElement(_calendar.default, _extends({
|
|
523
|
-
adapter:
|
|
524
|
-
autoFocusCalendar:
|
|
602
|
+
adapter: _this4.props.adapter,
|
|
603
|
+
autoFocusCalendar: _this4.state.calendarFocused,
|
|
525
604
|
trapTabbing: true,
|
|
526
|
-
value:
|
|
527
|
-
},
|
|
528
|
-
onChange:
|
|
605
|
+
value: _this4.props.value
|
|
606
|
+
}, _this4.props, {
|
|
607
|
+
onChange: _this4.onChange
|
|
529
608
|
}))
|
|
530
|
-
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper,
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
positive: _this3.props.positive,
|
|
535
|
-
"aria-describedby": _this3.props['aria-describedby'],
|
|
536
|
-
"aria-labelledby": _this3.props['aria-labelledby'],
|
|
537
|
-
"aria-required": _this3.props.required || null,
|
|
538
|
-
disabled: _this3.props.disabled,
|
|
539
|
-
size: _this3.props.size,
|
|
540
|
-
value: _this3.state.inputValue,
|
|
541
|
-
onFocus: _this3.open,
|
|
542
|
-
onBlur: _this3.handleInputBlur,
|
|
543
|
-
onKeyDown: _this3.handleKeyDown,
|
|
544
|
-
onChange: _this3.handleInputChange,
|
|
545
|
-
placeholder: placeholder,
|
|
546
|
-
mask: _this3.getMask(),
|
|
547
|
-
required: _this3.props.required,
|
|
548
|
-
clearable: _this3.props.clearable
|
|
549
|
-
}, inputProps)))), /*#__PURE__*/React.createElement("p", {
|
|
550
|
-
id: _this3.props['aria-describedby'],
|
|
609
|
+
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
|
|
610
|
+
$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, 'startDate')), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, 'endDate'))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
|
|
612
|
+
id: _this4.props['aria-describedby'],
|
|
551
613
|
style: {
|
|
552
614
|
position: 'fixed',
|
|
553
615
|
width: '0px',
|
|
@@ -577,17 +639,17 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
577
639
|
clipPath: 'inset(100%)'
|
|
578
640
|
}
|
|
579
641
|
}, // No date selected
|
|
580
|
-
!
|
|
581
|
-
!Array.isArray(
|
|
582
|
-
date:
|
|
642
|
+
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
|
|
643
|
+
!Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
644
|
+
date: _this4.state.inputValue || ''
|
|
583
645
|
}) : // Start and end dates are selected in a range picker
|
|
584
|
-
|
|
585
|
-
startDate:
|
|
586
|
-
endDate:
|
|
587
|
-
|
|
646
|
+
_this4.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
|
|
647
|
+
startDate: _this4.formatDisplayValue(_this4.props.value[0]),
|
|
648
|
+
endDate: _this4.formatDisplayValue( // $FlowFixMe
|
|
649
|
+
_this4.props.value[1])
|
|
588
650
|
}) : // A single date selected in a range picker
|
|
589
651
|
"".concat((0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
590
|
-
date:
|
|
652
|
+
date: _this4.formatDisplayValue(_this4.props.value[0])
|
|
591
653
|
}), " ").concat(locale.datepicker.selectSecondDatePrompt)));
|
|
592
654
|
});
|
|
593
655
|
}
|
|
@@ -13,10 +13,38 @@ import Calendar from './calendar.js';
|
|
|
13
13
|
import {getOverrides} from '../helpers/overrides.js';
|
|
14
14
|
import getInterpolatedString from '../helpers/i18n-interpolation.js';
|
|
15
15
|
import {LocaleContext} from '../locale/index.js';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
StyledInputWrapper,
|
|
18
|
+
StyledInputLabel,
|
|
19
|
+
StyledStartDate,
|
|
20
|
+
StyledEndDate,
|
|
21
|
+
} from './styled-components.js';
|
|
17
22
|
import type {DatepickerPropsT} from './types.js';
|
|
18
23
|
import DateHelpers from './utils/date-helpers.js';
|
|
19
24
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
25
|
+
import type {LocaleT} from '../locale/types.js';
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
28
|
+
|
|
29
|
+
const INPUT_DELIMITER = ' – ';
|
|
30
|
+
|
|
31
|
+
const combineSeparatedInputs = (
|
|
32
|
+
newInputValue,
|
|
33
|
+
prevCombinedInputValue = '',
|
|
34
|
+
separatedInput,
|
|
35
|
+
) => {
|
|
36
|
+
let inputValue = newInputValue;
|
|
37
|
+
const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(
|
|
38
|
+
INPUT_DELIMITER,
|
|
39
|
+
);
|
|
40
|
+
if (separatedInput === 'startDate' && prevEndDate) {
|
|
41
|
+
inputValue = `${inputValue} – ${prevEndDate}`;
|
|
42
|
+
}
|
|
43
|
+
if (separatedInput === 'endDate') {
|
|
44
|
+
inputValue = `${prevStartDate} – ${inputValue}`;
|
|
45
|
+
}
|
|
46
|
+
return inputValue;
|
|
47
|
+
};
|
|
20
48
|
|
|
21
49
|
type StateT = {|
|
|
22
50
|
calendarFocused: boolean,
|
|
@@ -25,7 +53,6 @@ type StateT = {|
|
|
|
25
53
|
lastActiveElm: ?HTMLElement,
|
|
26
54
|
inputValue?: string,
|
|
27
55
|
|};
|
|
28
|
-
export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
29
56
|
|
|
30
57
|
export default class Datepicker<T = Date> extends React.Component<
|
|
31
58
|
DatepickerPropsT<T>,
|
|
@@ -128,7 +155,7 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
128
155
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
129
156
|
return '';
|
|
130
157
|
} else if (Array.isArray(date)) {
|
|
131
|
-
return date.map(day => format(day)).join(
|
|
158
|
+
return date.map(day => format(day)).join(INPUT_DELIMITER);
|
|
132
159
|
} else {
|
|
133
160
|
return format(date);
|
|
134
161
|
}
|
|
@@ -164,11 +191,14 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
164
191
|
};
|
|
165
192
|
|
|
166
193
|
open = () => {
|
|
167
|
-
this.setState(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
194
|
+
this.setState(
|
|
195
|
+
{
|
|
196
|
+
isOpen: true,
|
|
197
|
+
isPseudoFocused: true,
|
|
198
|
+
calendarFocused: false,
|
|
199
|
+
},
|
|
200
|
+
this.props.onOpen,
|
|
201
|
+
);
|
|
172
202
|
};
|
|
173
203
|
|
|
174
204
|
close = () => {
|
|
@@ -197,9 +227,12 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
197
227
|
};
|
|
198
228
|
|
|
199
229
|
getMask = () => {
|
|
200
|
-
const {formatString, mask, range} = this.props;
|
|
230
|
+
const {formatString, mask, range, separateRangeInputs} = this.props;
|
|
201
231
|
|
|
202
|
-
if (
|
|
232
|
+
if (
|
|
233
|
+
mask === null ||
|
|
234
|
+
(mask === undefined && formatString !== DEFAULT_DATE_FORMAT)
|
|
235
|
+
) {
|
|
203
236
|
return null;
|
|
204
237
|
}
|
|
205
238
|
|
|
@@ -207,28 +240,28 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
207
240
|
return this.normalizeDashes(mask);
|
|
208
241
|
}
|
|
209
242
|
|
|
210
|
-
|
|
211
|
-
if (formatString) {
|
|
212
|
-
if (range) {
|
|
213
|
-
return `${normalizedFormatString} – ${normalizedFormatString}`.replace(
|
|
214
|
-
/[a-z]/gi,
|
|
215
|
-
'9',
|
|
216
|
-
);
|
|
217
|
-
} else {
|
|
218
|
-
return normalizedFormatString.replace(/[a-z]/gi, '9');
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (range) {
|
|
243
|
+
if (range && !separateRangeInputs) {
|
|
223
244
|
return '9999/99/99 – 9999/99/99';
|
|
224
245
|
}
|
|
225
246
|
|
|
226
247
|
return '9999/99/99';
|
|
227
248
|
};
|
|
228
249
|
|
|
229
|
-
handleInputChange = (
|
|
230
|
-
|
|
250
|
+
handleInputChange = (
|
|
251
|
+
event: SyntheticInputEvent<HTMLInputElement>,
|
|
252
|
+
separatedInput?: 'startDate' | 'endDate',
|
|
253
|
+
) => {
|
|
254
|
+
const inputValue =
|
|
255
|
+
this.props.range && this.props.separateRangeInputs
|
|
256
|
+
? combineSeparatedInputs(
|
|
257
|
+
event.currentTarget.value,
|
|
258
|
+
this.state.inputValue,
|
|
259
|
+
separatedInput,
|
|
260
|
+
)
|
|
261
|
+
: event.currentTarget.value;
|
|
262
|
+
|
|
231
263
|
const mask = this.getMask();
|
|
264
|
+
const formatString = this.normalizeDashes(this.props.formatString);
|
|
232
265
|
|
|
233
266
|
if (
|
|
234
267
|
(typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ')) ||
|
|
@@ -245,7 +278,6 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
245
278
|
|
|
246
279
|
this.setState({inputValue});
|
|
247
280
|
|
|
248
|
-
const formatString = this.normalizeDashes(this.props.formatString);
|
|
249
281
|
const parseDateString = dateString => {
|
|
250
282
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
251
283
|
return this.dateHelpers.parse(
|
|
@@ -265,7 +297,9 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
265
297
|
this.props.range &&
|
|
266
298
|
typeof this.props.displayValueAtRangeIndex !== 'number'
|
|
267
299
|
) {
|
|
268
|
-
const [left, right] = this.normalizeDashes(inputValue).split(
|
|
300
|
+
const [left, right] = this.normalizeDashes(inputValue).split(
|
|
301
|
+
INPUT_DELIMITER,
|
|
302
|
+
);
|
|
269
303
|
|
|
270
304
|
let startDate = this.dateHelpers.date(left);
|
|
271
305
|
let endDate = this.dateHelpers.date(right);
|
|
@@ -391,12 +425,73 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
391
425
|
}
|
|
392
426
|
}
|
|
393
427
|
|
|
394
|
-
|
|
428
|
+
renderInputComponent(
|
|
429
|
+
locale: LocaleT,
|
|
430
|
+
separatedInput?: 'startDate' | 'endDate',
|
|
431
|
+
) {
|
|
395
432
|
const {overrides = {}} = this.props;
|
|
433
|
+
|
|
396
434
|
const [InputComponent, inputProps] = getOverrides(
|
|
397
435
|
overrides.Input,
|
|
398
436
|
MaskedInput,
|
|
399
437
|
);
|
|
438
|
+
|
|
439
|
+
const placeholder =
|
|
440
|
+
this.props.placeholder || this.props.placeholder === ''
|
|
441
|
+
? this.props.placeholder
|
|
442
|
+
: this.props.range && !this.props.separateRangeInputs
|
|
443
|
+
? 'YYYY/MM/DD – YYYY/MM/DD'
|
|
444
|
+
: 'YYYY/MM/DD';
|
|
445
|
+
|
|
446
|
+
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(
|
|
447
|
+
INPUT_DELIMITER,
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
const value =
|
|
451
|
+
separatedInput === 'startDate'
|
|
452
|
+
? startDate
|
|
453
|
+
: separatedInput === 'endDate'
|
|
454
|
+
? endDate
|
|
455
|
+
: this.state.inputValue;
|
|
456
|
+
|
|
457
|
+
const onChange = event => this.handleInputChange(event, separatedInput);
|
|
458
|
+
|
|
459
|
+
return (
|
|
460
|
+
<InputComponent
|
|
461
|
+
aria-disabled={this.props.disabled}
|
|
462
|
+
aria-label={
|
|
463
|
+
this.props['aria-label'] ||
|
|
464
|
+
(this.props.range
|
|
465
|
+
? locale.datepicker.ariaLabelRange
|
|
466
|
+
: locale.datepicker.ariaLabel)
|
|
467
|
+
}
|
|
468
|
+
error={this.props.error}
|
|
469
|
+
positive={this.props.positive}
|
|
470
|
+
aria-describedby={this.props['aria-describedby']}
|
|
471
|
+
aria-labelledby={this.props['aria-labelledby']}
|
|
472
|
+
aria-required={this.props.required || null}
|
|
473
|
+
disabled={this.props.disabled}
|
|
474
|
+
size={this.props.size}
|
|
475
|
+
value={value}
|
|
476
|
+
onFocus={this.open}
|
|
477
|
+
onBlur={this.handleInputBlur}
|
|
478
|
+
onKeyDown={this.handleKeyDown}
|
|
479
|
+
onChange={onChange}
|
|
480
|
+
placeholder={placeholder}
|
|
481
|
+
mask={this.getMask()}
|
|
482
|
+
required={this.props.required}
|
|
483
|
+
clearable={this.props.clearable}
|
|
484
|
+
{...inputProps}
|
|
485
|
+
/>
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
render() {
|
|
490
|
+
const {
|
|
491
|
+
overrides = {},
|
|
492
|
+
startDateLabel = 'Start Date',
|
|
493
|
+
endDateLabel = 'End Date',
|
|
494
|
+
} = this.props;
|
|
400
495
|
const [PopoverComponent, popoverProps] = getOverrides(
|
|
401
496
|
overrides.Popover,
|
|
402
497
|
Popover,
|
|
@@ -405,13 +500,18 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
405
500
|
overrides.InputWrapper,
|
|
406
501
|
StyledInputWrapper,
|
|
407
502
|
);
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
503
|
+
const [StartDate, startDateProps] = getOverrides(
|
|
504
|
+
overrides.StartDate,
|
|
505
|
+
StyledStartDate,
|
|
506
|
+
);
|
|
507
|
+
const [EndDate, endDateProps] = getOverrides(
|
|
508
|
+
overrides.EndDate,
|
|
509
|
+
StyledEndDate,
|
|
510
|
+
);
|
|
511
|
+
const [InputLabel, inputLabelProps] = getOverrides(
|
|
512
|
+
overrides.InputLabel,
|
|
513
|
+
StyledInputLabel,
|
|
514
|
+
);
|
|
415
515
|
|
|
416
516
|
return (
|
|
417
517
|
<LocaleContext.Consumer>
|
|
@@ -419,6 +519,7 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
419
519
|
<React.Fragment>
|
|
420
520
|
<PopoverComponent
|
|
421
521
|
focusLock={false}
|
|
522
|
+
autoFocus={false}
|
|
422
523
|
mountNode={this.props.mountNode}
|
|
423
524
|
placement={PLACEMENT.bottom}
|
|
424
525
|
isOpen={this.state.isOpen}
|
|
@@ -436,33 +537,31 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
436
537
|
}
|
|
437
538
|
{...popoverProps}
|
|
438
539
|
>
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
{...inputProps}
|
|
465
|
-
/>
|
|
540
|
+
{}
|
|
541
|
+
<InputWrapper
|
|
542
|
+
{...inputWrapperProps}
|
|
543
|
+
$separateRangeInputs={
|
|
544
|
+
this.props.range && this.props.separateRangeInputs
|
|
545
|
+
}
|
|
546
|
+
>
|
|
547
|
+
{this.props.range && this.props.separateRangeInputs ? (
|
|
548
|
+
<>
|
|
549
|
+
<StartDate {...startDateProps}>
|
|
550
|
+
<InputLabel {...inputLabelProps}>
|
|
551
|
+
{startDateLabel}
|
|
552
|
+
</InputLabel>
|
|
553
|
+
{this.renderInputComponent(locale, 'startDate')}
|
|
554
|
+
</StartDate>
|
|
555
|
+
<EndDate {...endDateProps}>
|
|
556
|
+
<InputLabel {...inputLabelProps}>
|
|
557
|
+
{endDateLabel}
|
|
558
|
+
</InputLabel>
|
|
559
|
+
{this.renderInputComponent(locale, 'endDate')}
|
|
560
|
+
</EndDate>
|
|
561
|
+
</>
|
|
562
|
+
) : (
|
|
563
|
+
<>{this.renderInputComponent(locale)}</>
|
|
564
|
+
)}
|
|
466
565
|
</InputWrapper>
|
|
467
566
|
</PopoverComponent>
|
|
468
567
|
<p
|
package/datepicker/day.js
CHANGED
|
@@ -345,6 +345,7 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
345
345
|
var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !this.props.peekNextMonth && this.isOutsideOfMonthButWithinRange());
|
|
346
346
|
return {
|
|
347
347
|
$date: date,
|
|
348
|
+
$density: this.props.density,
|
|
348
349
|
$disabled: this.props.disabled,
|
|
349
350
|
$endDate: Array.isArray(value) && this.props.range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
|
|
350
351
|
$hasDateLabel: !!this.props.dateLabel,
|
package/datepicker/day.js.flow
CHANGED
package/datepicker/index.d.ts
CHANGED
|
@@ -148,6 +148,9 @@ export interface DatepickerOverrides<T> {
|
|
|
148
148
|
Input?: Override<T>;
|
|
149
149
|
InputWrapper?: Override<T>;
|
|
150
150
|
Popover?: Override<T>;
|
|
151
|
+
StartDate?: Override<T>;
|
|
152
|
+
EndDate?: Override<T>;
|
|
153
|
+
InputLabel?: Override<T>;
|
|
151
154
|
}
|
|
152
155
|
export type DatepickerProps = CalendarProps & {
|
|
153
156
|
'aria-label'?: string;
|
|
@@ -166,6 +169,10 @@ export type DatepickerProps = CalendarProps & {
|
|
|
166
169
|
mask?: string | null;
|
|
167
170
|
mountNode?: HTMLElement;
|
|
168
171
|
onClose?: () => any;
|
|
172
|
+
onOpen?: () => any;
|
|
173
|
+
separateRangeInputs?: boolean;
|
|
174
|
+
startDateLabel?: string;
|
|
175
|
+
endDateLabel?: string;
|
|
169
176
|
};
|
|
170
177
|
export interface DatepickerState {
|
|
171
178
|
calendarFocused: boolean;
|