baseui 0.0.0-alpha-cfc8585 → 0.0.0-alpha-fd35cbd
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/button/styled-components.js +1 -1
- package/button/styled-components.js.flow +4 -1
- 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 +3 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/data-table.js +13 -3
- package/data-table/data-table.js.flow +20 -4
- package/data-table/types.js.flow +2 -1
- package/datepicker/calendar-header.js +255 -109
- package/datepicker/calendar-header.js.flow +282 -145
- package/datepicker/calendar.js +18 -7
- package/datepicker/calendar.js.flow +28 -13
- package/datepicker/constants.js +9 -2
- package/datepicker/constants.js.flow +7 -0
- package/datepicker/datepicker.js +149 -76
- package/datepicker/datepicker.js.flow +185 -71
- package/datepicker/day.js +60 -30
- package/datepicker/day.js.flow +105 -51
- package/datepicker/index.d.ts +8 -0
- package/datepicker/month.js +4 -0
- package/datepicker/month.js.flow +3 -0
- package/datepicker/stateful-container.js.flow +2 -1
- package/datepicker/styled-components.js +116 -56
- package/datepicker/styled-components.js.flow +101 -36
- package/datepicker/types.js.flow +29 -10
- package/datepicker/utils/calendar-header-helpers.js +51 -0
- package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
- 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/index.js.flow +2 -1
- 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/drawer/drawer.js +2 -1
- package/drawer/drawer.js.flow +1 -1
- package/es/app-nav-bar/user-menu.js +1 -0
- package/es/button/styled-components.js +1 -1
- package/es/card/styled-components.js +0 -1
- package/es/combobox/combobox.js +5 -1
- package/es/data-table/column-datetime.js +3 -1
- package/es/data-table/data-table.js +13 -3
- package/es/datepicker/calendar-header.js +204 -93
- package/es/datepicker/calendar.js +19 -8
- package/es/datepicker/constants.js +6 -1
- package/es/datepicker/datepicker.js +84 -46
- package/es/datepicker/day.js +53 -30
- 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/calendar-header-helpers.js +34 -0
- package/es/datepicker/utils/date-helpers.js +1 -1
- package/es/datepicker/week.js +1 -0
- package/es/dnd-list/index.js +2 -1
- package/es/dnd-list/list.js +1 -2
- package/es/dnd-list/styled-components.js +1 -0
- package/es/drawer/drawer.js +2 -1
- package/es/helper/helper.js +1 -0
- package/es/layer/layer.js +8 -0
- package/es/map-marker/constants.js +69 -0
- package/es/map-marker/fixed-marker.js +98 -0
- package/es/map-marker/floating-marker.js +65 -0
- package/es/map-marker/index.js +9 -0
- package/es/map-marker/pin-head.js +108 -0
- package/es/map-marker/styled-components.js +156 -0
- package/es/map-marker/types.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 +8 -2
- package/es/rating/emoticon-rating.js +3 -1
- package/es/rating/star-rating.js +3 -1
- package/es/select/select-component.js +20 -5
- package/es/select/styled-components.js +34 -4
- package/es/snackbar/snackbar-context.js +16 -4
- package/es/table-semantic/styled-components.js +6 -4
- package/es/table-semantic/table-builder.js +3 -0
- package/es/themes/dark-theme/color-component-tokens.js +1 -1
- package/es/themes/light-theme/color-component-tokens.js +9 -9
- package/es/themes/shared/lighting.js +5 -1
- package/es/timepicker/timepicker.js +16 -11
- package/es/tooltip/styled-components.js +8 -0
- package/es/tooltip/tooltip.js +1 -0
- package/esm/app-nav-bar/user-menu.js +1 -0
- package/esm/button/styled-components.js +1 -1
- package/esm/card/styled-components.js +0 -1
- package/esm/combobox/combobox.js +5 -1
- package/esm/data-table/column-datetime.js +3 -1
- package/esm/data-table/data-table.js +13 -3
- package/esm/datepicker/calendar-header.js +255 -110
- package/esm/datepicker/calendar.js +19 -8
- package/esm/datepicker/constants.js +6 -1
- package/esm/datepicker/datepicker.js +150 -77
- package/esm/datepicker/day.js +60 -30
- 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/calendar-header-helpers.js +45 -0
- package/esm/datepicker/utils/date-helpers.js +1 -1
- package/esm/datepicker/week.js +1 -0
- package/esm/dnd-list/index.js +2 -1
- package/esm/dnd-list/list.js +1 -2
- package/esm/dnd-list/styled-components.js +1 -1
- package/esm/drawer/drawer.js +2 -1
- package/esm/helper/helper.js +1 -0
- package/esm/layer/layer.js +8 -0
- package/esm/map-marker/constants.js +62 -0
- package/esm/map-marker/fixed-marker.js +137 -0
- package/esm/map-marker/floating-marker.js +94 -0
- package/esm/map-marker/index.js +9 -0
- package/esm/map-marker/pin-head.js +144 -0
- package/esm/map-marker/styled-components.js +168 -0
- package/esm/map-marker/types.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 +8 -2
- package/esm/rating/emoticon-rating.js +2 -2
- package/esm/rating/star-rating.js +2 -2
- package/esm/select/select-component.js +19 -5
- package/esm/select/styled-components.js +28 -4
- package/esm/snackbar/snackbar-context.js +16 -4
- package/esm/table-semantic/styled-components.js +6 -4
- package/esm/table-semantic/table-builder.js +3 -0
- package/esm/themes/dark-theme/color-component-tokens.js +1 -1
- package/esm/themes/light-theme/color-component-tokens.js +9 -9
- package/esm/themes/shared/lighting.js +5 -1
- package/esm/timepicker/timepicker.js +17 -11
- package/esm/tooltip/styled-components.js +8 -0
- 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/link/index.d.ts +1 -0
- package/map-marker/constants.js +82 -0
- package/map-marker/constants.js.flow +74 -0
- package/map-marker/fixed-marker.js +152 -0
- package/map-marker/fixed-marker.js.flow +137 -0
- package/map-marker/floating-marker.js +109 -0
- package/map-marker/floating-marker.js.flow +102 -0
- package/map-marker/index.d.ts +105 -0
- package/map-marker/index.js +55 -0
- package/map-marker/index.js.flow +23 -0
- package/map-marker/package.json +4 -0
- package/map-marker/pin-head.js +159 -0
- package/map-marker/pin-head.js.flow +155 -0
- package/map-marker/styled-components.js +184 -0
- package/map-marker/styled-components.js.flow +177 -0
- package/map-marker/types.js +11 -0
- package/map-marker/types.js.flow +114 -0
- package/menu/index.d.ts +7 -0
- package/menu/maybe-child-menu.js +1 -0
- package/menu/maybe-child-menu.js.flow +1 -0
- package/menu/types.js.flow +12 -0
- package/modal/index.d.ts +1 -1
- package/modal/types.js.flow +4 -1
- package/package.json +5 -3
- 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 +8 -2
- package/popover/stateful-container.js.flow +5 -0
- package/popover/types.js.flow +6 -1
- package/rating/emoticon-rating.js +2 -2
- package/rating/emoticon-rating.js.flow +4 -1
- package/rating/star-rating.js +2 -2
- package/rating/star-rating.js.flow +4 -1
- package/select/select-component.js +19 -5
- package/select/select-component.js.flow +19 -5
- package/select/styled-components.js +28 -4
- package/select/styled-components.js.flow +30 -2
- package/select/types.js.flow +9 -0
- package/snackbar/index.d.ts +21 -16
- package/snackbar/snackbar-context.js +15 -4
- package/snackbar/snackbar-context.js.flow +15 -3
- package/table-semantic/styled-components.js +6 -4
- package/table-semantic/styled-components.js.flow +6 -4
- package/table-semantic/table-builder.js +3 -0
- package/table-semantic/table-builder.js.flow +3 -0
- package/themes/dark-theme/color-component-tokens.js +1 -1
- package/themes/dark-theme/color-component-tokens.js.flow +1 -1
- package/themes/light-theme/color-component-tokens.js +9 -9
- package/themes/light-theme/color-component-tokens.js.flow +9 -9
- 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/styled-components.js +8 -0
- package/tooltip/styled-components.js.flow +8 -0
- package/tooltip/tooltip.js +1 -0
- package/tooltip/tooltip.js.flow +6 -1
|
@@ -22,8 +22,12 @@ import {
|
|
|
22
22
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
23
23
|
import DateHelpers from './utils/date-helpers.js';
|
|
24
24
|
import {getOverrides, mergeOverrides} from '../helpers/overrides.js';
|
|
25
|
-
import type {
|
|
26
|
-
|
|
25
|
+
import type {
|
|
26
|
+
CalendarPropsT,
|
|
27
|
+
CalendarInternalState,
|
|
28
|
+
DateValueT,
|
|
29
|
+
} from './types.js';
|
|
30
|
+
import {DENSITY, ORIENTATION} from './constants.js';
|
|
27
31
|
|
|
28
32
|
export default class Calendar<T = Date> extends React.Component<
|
|
29
33
|
CalendarPropsT<T>,
|
|
@@ -32,6 +36,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
32
36
|
static defaultProps: {adapter: DateIOAdapter<Date>} = {
|
|
33
37
|
autoFocusCalendar: false,
|
|
34
38
|
dateLabel: null,
|
|
39
|
+
density: DENSITY.default,
|
|
35
40
|
excludeDates: null,
|
|
36
41
|
filterDate: null,
|
|
37
42
|
highlightedDate: null,
|
|
@@ -139,7 +144,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
139
144
|
return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
|
|
140
145
|
}
|
|
141
146
|
|
|
142
|
-
getSingleDate(value:
|
|
147
|
+
getSingleDate(value: DateValueT<T>): ?T {
|
|
143
148
|
// need to check this.props.range but flow would complain
|
|
144
149
|
// at the return value in the else clause
|
|
145
150
|
if (Array.isArray(value)) {
|
|
@@ -345,20 +350,26 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
345
350
|
this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
|
|
346
351
|
};
|
|
347
352
|
|
|
348
|
-
handleDateChange: ({date:
|
|
353
|
+
handleDateChange: ({date: DateValueT<T>}) => void = data => {
|
|
349
354
|
const {onChange = params => {}} = this.props;
|
|
350
355
|
let updatedDate = data.date;
|
|
351
356
|
// We'll need to update the date in time values of internal state
|
|
352
357
|
const newTimeState = [...this.state.time];
|
|
353
358
|
// Apply the currently selected time values (saved in state) to the updated date
|
|
354
359
|
if (Array.isArray(data.date)) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
const start = data.date[0]
|
|
361
|
+
? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0])
|
|
362
|
+
: null;
|
|
363
|
+
const end = data.date[1]
|
|
364
|
+
? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1])
|
|
365
|
+
: null;
|
|
366
|
+
newTimeState[0] = start;
|
|
367
|
+
if (end) {
|
|
368
|
+
updatedDate = [start, end];
|
|
369
|
+
newTimeState[1] = end;
|
|
370
|
+
} else {
|
|
371
|
+
updatedDate = [start];
|
|
372
|
+
}
|
|
362
373
|
} else if (!Array.isArray(this.props.value) && data.date) {
|
|
363
374
|
newTimeState[0] = this.dateHelpers.applyDateToTime(
|
|
364
375
|
newTimeState[0],
|
|
@@ -366,6 +377,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
366
377
|
);
|
|
367
378
|
updatedDate = newTimeState[0];
|
|
368
379
|
}
|
|
380
|
+
|
|
369
381
|
// Update the date in time values of internal state
|
|
370
382
|
this.setState({time: newTimeState});
|
|
371
383
|
onChange({date: updatedDate});
|
|
@@ -384,12 +396,12 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
384
396
|
// with the date value set to the date with updated time
|
|
385
397
|
if (Array.isArray(this.props.value)) {
|
|
386
398
|
const dates = this.props.value.map((date, i) => {
|
|
387
|
-
if (index === i) {
|
|
399
|
+
if (date && index === i) {
|
|
388
400
|
return this.dateHelpers.applyTimeToDate(date, time);
|
|
389
401
|
}
|
|
390
402
|
return date;
|
|
391
403
|
});
|
|
392
|
-
onChange({date: dates});
|
|
404
|
+
onChange({date: [dates[0], dates[1]]});
|
|
393
405
|
} else {
|
|
394
406
|
const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
|
|
395
407
|
onChange({date});
|
|
@@ -442,11 +454,13 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
442
454
|
aria-multiselectable={this.props.range || null}
|
|
443
455
|
onKeyDown={this.onKeyDown}
|
|
444
456
|
{...calendarContainerProps}
|
|
457
|
+
$density={this.props.density}
|
|
445
458
|
>
|
|
446
459
|
<Month
|
|
447
460
|
adapter={this.props.adapter}
|
|
448
461
|
date={monthDate}
|
|
449
462
|
dateLabel={this.props.dateLabel}
|
|
463
|
+
density={this.props.density}
|
|
450
464
|
excludeDates={this.props.excludeDates}
|
|
451
465
|
filterDate={this.props.filterDate}
|
|
452
466
|
highlightedDate={this.state.highlightedDate}
|
|
@@ -643,6 +657,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
643
657
|
<LocaleContext.Consumer>
|
|
644
658
|
{locale => (
|
|
645
659
|
<Root
|
|
660
|
+
$density={this.props.density}
|
|
646
661
|
data-baseweb="calendar"
|
|
647
662
|
role="application"
|
|
648
663
|
aria-roledescription="datepicker"
|
package/datepicker/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
|
|
6
|
+
exports.DENSITY = exports.DEFAULT_MONTHS = exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
Copyright (c) Uber Technologies, Inc.
|
|
@@ -33,4 +33,11 @@ var STATE_CHANGE_TYPE = Object.freeze({
|
|
|
33
33
|
});
|
|
34
34
|
exports.STATE_CHANGE_TYPE = STATE_CHANGE_TYPE;
|
|
35
35
|
var WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
36
|
-
exports.WEEKDAYS = WEEKDAYS;
|
|
36
|
+
exports.WEEKDAYS = WEEKDAYS;
|
|
37
|
+
var DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
38
|
+
exports.DEFAULT_MONTHS = DEFAULT_MONTHS;
|
|
39
|
+
var DENSITY = {
|
|
40
|
+
high: 'high',
|
|
41
|
+
default: 'default'
|
|
42
|
+
};
|
|
43
|
+
exports.DENSITY = DENSITY;
|
|
@@ -26,6 +26,13 @@ export const STATE_CHANGE_TYPE = Object.freeze({
|
|
|
26
26
|
|
|
27
27
|
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
28
28
|
|
|
29
|
+
export const DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
30
|
+
|
|
31
|
+
export const DENSITY = {
|
|
32
|
+
high: 'high',
|
|
33
|
+
default: 'default',
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
declare var __DEV__: boolean;
|
|
30
37
|
declare var __NODE__: boolean;
|
|
31
38
|
declare var __BROWSER__: boolean;
|
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,45 @@ 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
|
+
// TODO(LUKE): use INPUT_DELIMITER below
|
|
102
|
+
inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (separatedInput === 'endDate') {
|
|
106
|
+
inputValue = "".concat(prevStartDate, " \u2013 ").concat(inputValue);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return inputValue;
|
|
110
|
+
};
|
|
86
111
|
|
|
87
112
|
var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
88
113
|
_inherits(Datepicker, _React$Component);
|
|
@@ -107,11 +132,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
107
132
|
var nextDate = data.date;
|
|
108
133
|
|
|
109
134
|
if (Array.isArray(nextDate) && _this.props.range) {
|
|
110
|
-
if (nextDate
|
|
135
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
111
136
|
isOpen = true;
|
|
112
137
|
isPseudoFocused = true;
|
|
113
138
|
calendarFocused = null;
|
|
114
|
-
} else if (nextDate
|
|
139
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
115
140
|
var _nextDate = nextDate,
|
|
116
141
|
_nextDate2 = _slicedToArray(_nextDate, 2),
|
|
117
142
|
start = _nextDate2[0],
|
|
@@ -215,7 +240,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
215
240
|
isOpen: true,
|
|
216
241
|
isPseudoFocused: true,
|
|
217
242
|
calendarFocused: false
|
|
218
|
-
});
|
|
243
|
+
}, _this.props.onOpen);
|
|
219
244
|
});
|
|
220
245
|
|
|
221
246
|
_defineProperty(_assertThisInitialized(_this), "close", function () {
|
|
@@ -246,9 +271,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
246
271
|
var _this$props2 = _this.props,
|
|
247
272
|
formatString = _this$props2.formatString,
|
|
248
273
|
mask = _this$props2.mask,
|
|
249
|
-
range = _this$props2.range
|
|
274
|
+
range = _this$props2.range,
|
|
275
|
+
separateRangeInputs = _this$props2.separateRangeInputs;
|
|
250
276
|
|
|
251
|
-
if (mask === null) {
|
|
277
|
+
if (mask === null || mask === undefined && formatString !== DEFAULT_DATE_FORMAT) {
|
|
252
278
|
return null;
|
|
253
279
|
}
|
|
254
280
|
|
|
@@ -256,28 +282,21 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
256
282
|
return _this.normalizeDashes(mask);
|
|
257
283
|
}
|
|
258
284
|
|
|
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) {
|
|
285
|
+
if (range && !separateRangeInputs) {
|
|
286
|
+
// TODO(LUKE): use INPUT_DELIMITER below
|
|
270
287
|
return '9999/99/99 – 9999/99/99';
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
return '9999/99/99';
|
|
274
291
|
});
|
|
275
292
|
|
|
276
|
-
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event) {
|
|
277
|
-
var inputValue = event.currentTarget.value;
|
|
293
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, separatedInput) {
|
|
294
|
+
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, separatedInput) : event.currentTarget.value;
|
|
278
295
|
|
|
279
296
|
var mask = _this.getMask();
|
|
280
297
|
|
|
298
|
+
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
299
|
+
|
|
281
300
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
282
301
|
if (_this.props.onChange) {
|
|
283
302
|
if (_this.props.range) {
|
|
@@ -296,8 +315,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
296
315
|
inputValue: inputValue
|
|
297
316
|
});
|
|
298
317
|
|
|
299
|
-
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
300
|
-
|
|
301
318
|
var parseDateString = function parseDateString(dateString) {
|
|
302
319
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
303
320
|
return _this.dateHelpers.parse(dateString, 'slashDate', _this.props.locale);
|
|
@@ -307,7 +324,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
307
324
|
};
|
|
308
325
|
|
|
309
326
|
if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
|
|
310
|
-
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(
|
|
327
|
+
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
|
|
311
328
|
_this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
|
|
312
329
|
left = _this$normalizeDashes2[0],
|
|
313
330
|
right = _this$normalizeDashes2[1];
|
|
@@ -454,6 +471,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
454
471
|
}
|
|
455
472
|
|
|
456
473
|
_createClass(Datepicker, [{
|
|
474
|
+
key: "getNullDatePlaceholder",
|
|
475
|
+
value: function getNullDatePlaceholder(formatString) {
|
|
476
|
+
return (this.getMask() || formatString).split('–')[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
457
479
|
key: "formatDate",
|
|
458
480
|
value: function formatDate(date, formatString) {
|
|
459
481
|
var _this2 = this;
|
|
@@ -470,10 +492,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
470
492
|
return '';
|
|
471
493
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
472
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(INPUT_DELIMITER);
|
|
473
499
|
} else if (Array.isArray(date)) {
|
|
474
500
|
return date.map(function (day) {
|
|
475
|
-
return format(day);
|
|
476
|
-
}).join(
|
|
501
|
+
return day ? format(day) : '';
|
|
502
|
+
}).join(INPUT_DELIMITER);
|
|
477
503
|
} else {
|
|
478
504
|
return format(date);
|
|
479
505
|
}
|
|
@@ -488,8 +514,8 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
488
514
|
}
|
|
489
515
|
}
|
|
490
516
|
}, {
|
|
491
|
-
key: "
|
|
492
|
-
value: function
|
|
517
|
+
key: "renderInputComponent",
|
|
518
|
+
value: function renderInputComponent(locale, separatedInput) {
|
|
493
519
|
var _this3 = this;
|
|
494
520
|
|
|
495
521
|
var _this$props$overrides = this.props.overrides,
|
|
@@ -500,6 +526,55 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
500
526
|
InputComponent = _getOverrides2[0],
|
|
501
527
|
inputProps = _getOverrides2[1];
|
|
502
528
|
|
|
529
|
+
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';
|
|
530
|
+
|
|
531
|
+
var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
|
|
532
|
+
_split2 = _slicedToArray(_split, 2),
|
|
533
|
+
_split2$ = _split2[0],
|
|
534
|
+
startDate = _split2$ === void 0 ? '' : _split2$,
|
|
535
|
+
_split2$2 = _split2[1],
|
|
536
|
+
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
537
|
+
|
|
538
|
+
var value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
|
|
539
|
+
|
|
540
|
+
var onChange = function onChange(event) {
|
|
541
|
+
return _this3.handleInputChange(event, separatedInput);
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
545
|
+
"aria-disabled": this.props.disabled,
|
|
546
|
+
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
547
|
+
error: this.props.error,
|
|
548
|
+
positive: this.props.positive,
|
|
549
|
+
"aria-describedby": this.props['aria-describedby'],
|
|
550
|
+
"aria-labelledby": this.props['aria-labelledby'],
|
|
551
|
+
"aria-required": this.props.required || null,
|
|
552
|
+
disabled: this.props.disabled,
|
|
553
|
+
size: this.props.size,
|
|
554
|
+
value: value,
|
|
555
|
+
onFocus: this.open,
|
|
556
|
+
onBlur: this.handleInputBlur,
|
|
557
|
+
onKeyDown: this.handleKeyDown,
|
|
558
|
+
onChange: onChange,
|
|
559
|
+
placeholder: placeholder,
|
|
560
|
+
mask: this.getMask(),
|
|
561
|
+
required: this.props.required,
|
|
562
|
+
clearable: this.props.clearable
|
|
563
|
+
}, inputProps));
|
|
564
|
+
}
|
|
565
|
+
}, {
|
|
566
|
+
key: "render",
|
|
567
|
+
value: function render() {
|
|
568
|
+
var _this4 = this;
|
|
569
|
+
|
|
570
|
+
var _this$props4 = this.props,
|
|
571
|
+
_this$props4$override = _this$props4.overrides,
|
|
572
|
+
overrides = _this$props4$override === void 0 ? {} : _this$props4$override,
|
|
573
|
+
_this$props4$startDat = _this$props4.startDateLabel,
|
|
574
|
+
startDateLabel = _this$props4$startDat === void 0 ? 'Start Date' : _this$props4$startDat,
|
|
575
|
+
_this$props4$endDateL = _this$props4.endDateLabel,
|
|
576
|
+
endDateLabel = _this$props4$endDateL === void 0 ? 'End Date' : _this$props4$endDateL;
|
|
577
|
+
|
|
503
578
|
var _getOverrides3 = (0, _overrides.getOverrides)(overrides.Popover, _index2.Popover),
|
|
504
579
|
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
505
580
|
PopoverComponent = _getOverrides4[0],
|
|
@@ -510,44 +585,42 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
510
585
|
InputWrapper = _getOverrides6[0],
|
|
511
586
|
inputWrapperProps = _getOverrides6[1];
|
|
512
587
|
|
|
513
|
-
var
|
|
588
|
+
var _getOverrides7 = (0, _overrides.getOverrides)(overrides.StartDate, _styledComponents.StyledStartDate),
|
|
589
|
+
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
590
|
+
StartDate = _getOverrides8[0],
|
|
591
|
+
startDateProps = _getOverrides8[1];
|
|
592
|
+
|
|
593
|
+
var _getOverrides9 = (0, _overrides.getOverrides)(overrides.EndDate, _styledComponents.StyledEndDate),
|
|
594
|
+
_getOverrides10 = _slicedToArray(_getOverrides9, 2),
|
|
595
|
+
EndDate = _getOverrides10[0],
|
|
596
|
+
endDateProps = _getOverrides10[1];
|
|
597
|
+
|
|
598
|
+
var _getOverrides11 = (0, _overrides.getOverrides)(overrides.InputLabel, _styledComponents.StyledInputLabel),
|
|
599
|
+
_getOverrides12 = _slicedToArray(_getOverrides11, 2),
|
|
600
|
+
InputLabel = _getOverrides12[0],
|
|
601
|
+
inputLabelProps = _getOverrides12[1];
|
|
602
|
+
|
|
514
603
|
return /*#__PURE__*/React.createElement(_index3.LocaleContext.Consumer, null, function (locale) {
|
|
515
604
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PopoverComponent, _extends({
|
|
516
605
|
focusLock: false,
|
|
517
|
-
|
|
606
|
+
autoFocus: false,
|
|
607
|
+
mountNode: _this4.props.mountNode,
|
|
518
608
|
placement: _index2.PLACEMENT.bottom,
|
|
519
|
-
isOpen:
|
|
520
|
-
onClickOutside:
|
|
521
|
-
onEsc:
|
|
609
|
+
isOpen: _this4.state.isOpen,
|
|
610
|
+
onClickOutside: _this4.close,
|
|
611
|
+
onEsc: _this4.handleEsc,
|
|
522
612
|
content: /*#__PURE__*/React.createElement(_calendar.default, _extends({
|
|
523
|
-
adapter:
|
|
524
|
-
autoFocusCalendar:
|
|
613
|
+
adapter: _this4.props.adapter,
|
|
614
|
+
autoFocusCalendar: _this4.state.calendarFocused,
|
|
525
615
|
trapTabbing: true,
|
|
526
|
-
value:
|
|
527
|
-
},
|
|
528
|
-
onChange:
|
|
616
|
+
value: _this4.props.value
|
|
617
|
+
}, _this4.props, {
|
|
618
|
+
onChange: _this4.onChange
|
|
529
619
|
}))
|
|
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'],
|
|
620
|
+
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
|
|
621
|
+
$separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
|
|
622
|
+
}), _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", {
|
|
623
|
+
id: _this4.props['aria-describedby'],
|
|
551
624
|
style: {
|
|
552
625
|
position: 'fixed',
|
|
553
626
|
width: '0px',
|
|
@@ -577,17 +650,17 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
577
650
|
clipPath: 'inset(100%)'
|
|
578
651
|
}
|
|
579
652
|
}, // No date selected
|
|
580
|
-
!
|
|
581
|
-
!Array.isArray(
|
|
582
|
-
date:
|
|
653
|
+
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
|
|
654
|
+
!Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
655
|
+
date: _this4.state.inputValue || ''
|
|
583
656
|
}) : // Start and end dates are selected in a range picker
|
|
584
|
-
|
|
585
|
-
startDate:
|
|
586
|
-
endDate:
|
|
587
|
-
|
|
657
|
+
_this4.props.value[0] && _this4.props.value[1] ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
|
|
658
|
+
startDate: _this4.formatDisplayValue(_this4.props.value[0]),
|
|
659
|
+
endDate: _this4.formatDisplayValue( // $FlowFixMe
|
|
660
|
+
_this4.props.value[1])
|
|
588
661
|
}) : // A single date selected in a range picker
|
|
589
662
|
"".concat((0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
590
|
-
date:
|
|
663
|
+
date: _this4.formatDisplayValue(_this4.props.value[0])
|
|
591
664
|
}), " ").concat(locale.datepicker.selectSecondDatePrompt)));
|
|
592
665
|
});
|
|
593
666
|
}
|